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
53} paulaVoice_t;53} paulaVoice_t;
54 54
55static volatile int8_t filterFlags;55static volatile int8_t filterFlags;
56static volatile bool audioLocked;
57static int8_t defStereoSep;56static int8_t defStereoSep;
58static bool amigaPanFlag, wavRenderingDone;57static bool amigaPanFlag, wavRenderingDone;
59static uint16_t ch1Pan, ch2Pan, ch3Pan, ch4Pan, oldPeriod;58static uint16_t ch1Pan, ch2Pan, ch3Pan, ch4Pan;
60static int32_t sampleCounter, maxSamplesToMix, randSeed = INITIAL_DITHER_SEED;59static int32_t oldPeriod, sampleCounter, maxSamplesToMix, randSeed = INITIAL_DITHER_SEED;
61static uint32_t oldScopeDelta;60static uint32_t oldScopeDelta;
62static double *dMixBufferL, *dMixBufferR, *dMixBufferLUnaligned, *dMixBufferRUnaligned, dOldVoiceDelta, dOldVoiceDeltaMul;61static double *dMixBufferL, *dMixBufferR, *dMixBufferLUnaligned, *dMixBufferRUnaligned, dOldVoiceDelta, dOldVoiceDeltaMul;
63static double dPrngStateL, dPrngStateR;62static double dPrngStateL, dPrngStateR;
@@ -69,7 +68,6 @@ static paulaVoice_t paula[AMIGA_VOICES]; · 5 unmodified lines
69static SDL_AudioDeviceID dev;68static SDL_AudioDeviceID dev;
70 69
71// globalized70// globalized
72bool forceMixerOff = false;
73int32_t samplesPerTick;71int32_t samplesPerTick;
74 72
75bool intMusic(void); // defined in pt_modplayer.c73bool intMusic(void); // defined in pt_modplayer.c
@@ -128,7 +126,8 @@ static void calcCoeffLED(double dSr, double dHz, ledFilterCoeff_t *filter) · 52 unmodified lines
128 126
129#ifndef NO_FILTER_FINETUNING127#ifndef NO_FILTER_FINETUNING
130 /* 8bitbubsy: makes the filter curve sound (and look) much closer to the real deal.128 /* 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 */
132 dFb *= 0.62;131 dFb *= 0.62;
133#endif132#endif
134 133
@@ -184,7 +183,8 @@ void lossyIntegrator(lossyIntegrator_t *filter, double *dIn, double *dOut) · 49 unmodified lines
184 ** This implementation has a less smooth cutoff curve compared to the old one, so it's183 ** This implementation has a less smooth cutoff curve compared to the old one, so it's
185 ** maybe not the best. However, I stick to this one because it has a higher gain184 ** maybe not the best. However, I stick to this one because it has a higher gain
186 ** at the end of the curve (closer to real tested Amiga 500). It also sounds much closer when185 ** 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 */
188 188
189 // left channel low-pass189 // left channel low-pass
190 filter->dBuffer[0] = (filter->b0 * dIn[0]) + (filter->b1 * filter->dBuffer[0]) + DENORMAL_OFFSET;190 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
224** parameter range and have 'normalized' (1/2 = 0db) coeffs224** parameter range and have 'normalized' (1/2 = 0db) coeffs
225**225**
226** the coeffs are for LERP(x, x * x, 0.224) * sqrt(2)226** 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*/
228static double sinApx(double fX)229static double sinApx(double fX)
229{230{
230 fX = fX * (2.0 - fX);231 fX = fX * (2.0 - fX);
@@ -242,7 +243,7 @@ void lockAudio(void) · 11 unmodified lines
242 if (dev != 0)243 if (dev != 0)
243 SDL_LockAudioDevice(dev);244 SDL_LockAudioDevice(dev);
244 245
245 audioLocked = true;246 audio.locked = true;
246}247}
247 248
248void unlockAudio(void)249void unlockAudio(void)
@@ -250,33 +251,7 @@ void unlockAudio(void) · 1 unmodified line
250 if (dev != 0)251 if (dev != 0)
251 SDL_UnlockAudioDevice(dev);252 SDL_UnlockAudioDevice(dev);
252 253
253 audioLocked = false;254 audio.locked = false;
254}
255
256void 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();
280}255}
281 256
282void mixerUpdateLoops(void) // updates Paula loop (+ scopes)257void mixerUpdateLoops(void) // updates Paula loop (+ scopes)
@@ -284,14 +259,14 @@ void mixerUpdateLoops(void) // updates Paula loop (+ scopes) · 1 unmodified line
284 moduleChannel_t *ch;259 moduleChannel_t *ch;
285 moduleSample_t *s;260 moduleSample_t *s;
286 261
287 for (uint8_t i = 0; i < AMIGA_VOICES; i++)262 for (int32_t i = 0; i < AMIGA_VOICES; i++)
288 {263 {
289 ch = &modEntry->channels[i];264 ch = &modEntry->channels[i];
290 if (ch->n_samplenum == editor.currSample)265 if (ch->n_samplenum == editor.currSample)
291 {266 {
292 s = &modEntry->samples[editor.currSample];267 s = &modEntry->samples[editor.currSample];
293 paulaSetData(i, ch->n_start + s->loopStart);268 paulaSetData(i, ch->n_start + s->loopStart);
294 paulaSetLength(i, s->loopLength / 2);269 paulaSetLength(i, s->loopLength >> 1);
295 }270 }
296 }271 }
297}272}
@@ -302,7 +277,8 @@ static void mixerSetVoicePan(uint8_t ch, uint16_t pan) // pan = 0..256 · 4 unmodified lines
302 277
303 /* proper 'normalized' equal-power panning is (assuming pan left to right):278 /* proper 'normalized' equal-power panning is (assuming pan left to right):
304 ** L = cos(p * pi * 1/2) * sqrt(2);279 ** 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 */
306 dPan = pan * (1.0 / 256.0); // 0.0..1.0282 dPan = pan * (1.0 / 256.0); // 0.0..1.0
307 283
308 paula[ch].dPanL = cosApx(dPan);284 paula[ch].dPanL = cosApx(dPan);
@@ -311,24 +287,34 @@ static void mixerSetVoicePan(uint8_t ch, uint16_t pan) // pan = 0..256 · 2 unmodified lines
311 287
312void mixerKillVoice(uint8_t ch)288void mixerKillVoice(uint8_t ch)
313{289{
314 paulaVoice_t *v;290 const bool wasLocked = audio.locked;
315 scopeChannelExt_t *s;291 if (!wasLocked)
292 lockAudio();
316 293
317 v = &paula[ch];294 // copy old pans
318 s = &scopeExt[ch];295 const double dOldPanL = paula[ch].dPanL;
296 const double dOldPanR = paula[ch].dPanR;
319 297
320 v->active = false;298 memset(&paula[ch], 0, sizeof (paulaVoice_t));
321 v->dVolume = 0.0;299 stopScope(ch);
322 300
323 s->active = false;301 // store old pans
324 s->didSwapData = false;302 paula[ch].dPanL = dOldPanL;
303 paula[ch].dPanR = dOldPanR;
325 304
326 memset(&blep[ch], 0, sizeof (blep_t));305 memset(&blep[ch], 0, sizeof (blep_t));
327 memset(&blepVol[ch], 0, sizeof (blep_t));306 memset(&blepVol[ch], 0, sizeof (blep_t));
307
308 if (!wasLocked)
309 unlockAudio();
328}310}
329 311
330void turnOffVoices(void)312void turnOffVoices(void)
331{313{
314 const bool wasLocked = audio.locked;
315 if (!wasLocked)
316 lockAudio();
317
332 for (uint8_t i = 0; i < AMIGA_VOICES; i++)318 for (uint8_t i = 0; i < AMIGA_VOICES; i++)
333 mixerKillVoice(i);319 mixerKillVoice(i);
334 320
@@ -339,121 +325,59 @@ void turnOffVoices(void) · 4 unmodified lines
339 resetAudioDithering();325 resetAudioDithering();
340 326
341 editor.tuningFlag = false;327 editor.tuningFlag = false;
342}
343 328
344void paulaStopDMA(uint8_t ch)329 if (!wasLocked)
345{330 unlockAudio();
346 scopeExt[ch].active = paula[ch].active = false;
347}
348
349void 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
399}331}
400 332
401void resetCachedMixerPeriod(void)333void resetCachedMixerPeriod(void)
402{334{
403 oldPeriod = 0;335 oldPeriod = 0xFFFFFFFF;
404}336}
405 337
338// the following routines are only called from the mixer thread.
339
406void paulaSetPeriod(uint8_t ch, uint16_t period)340void paulaSetPeriod(uint8_t ch, uint16_t period)
407{341{
342 int32_t realPeriod;
408 double dPeriodToDeltaDiv;343 double dPeriodToDeltaDiv;
409 paulaVoice_t *v;344 paulaVoice_t *v;
410 345
411 v = &paula[ch];346 v = &paula[ch];
412 347
413 if (period == 0)348 if (period == 0)
414 {349 realPeriod = 65536; // confirmed behavior on real Amiga
415 v->dDelta = 0.0; // confirmed behavior on real Amiga350 else if (period < 113)
416 v->dDeltaMul = 1.0; // for BLEP synthesis351 realPeriod = 113; // confirmed behavior on real Amiga
417 setScopeDelta(ch, 0);352 else
418 return;353 realPeriod = period;
419 }
420
421 if (period < 113)
422 period = 113; // confirmed behavior on real Amiga
423 354
424 // if the new period was the same as the previous period, use cached deltas355 // if the new period was the same as the previous period, use cached deltas
425 if (period == oldPeriod)356 if (realPeriod != oldPeriod)
426 {
427 v->dDelta = dOldVoiceDelta;
428 v->dDeltaMul = dOldVoiceDeltaMul; // for BLEP synthesis
429 setScopeDelta(ch, oldScopeDelta);
430 }
431 else
432 {357 {
358 oldPeriod = realPeriod;
359
433 // this period is not cached, calculate mixer/scope deltas360 // this period is not cached, calculate mixer/scope deltas
434 361
435#if SCOPE_HZ != 64362#if SCOPE_HZ != 64
436#error Scope Hz is not 64 (2^n), change rate calc. to use doubles+round in pt2_scope.c363#error Scope Hz is not 64 (2^n), change rate calc. to use doubles+round in pt2_scope.c
437#endif364#endif
438 oldPeriod = period;
439
440 // if we are rendering pattern to sample (PAT2SMP), use different frequencies365 // if we are rendering pattern to sample (PAT2SMP), use different frequencies
441 if (editor.isSMPRendering)366 if (editor.isSMPRendering)
442 dPeriodToDeltaDiv = editor.pat2SmpHQ ? (PAULA_PAL_CLK / 28836.0) : (PAULA_PAL_CLK / 22168.0);367 dPeriodToDeltaDiv = editor.pat2SmpHQ ? (PAULA_PAL_CLK / 28836.0) : (PAULA_PAL_CLK / 22168.0);
443 else368 else
444 dPeriodToDeltaDiv = audio.dPeriodToDeltaDiv;369 dPeriodToDeltaDiv = audio.dPeriodToDeltaDiv;
445 370
446 v->dDelta = dPeriodToDeltaDiv / period;
447 v->dDeltaMul = 1.0 / v->dDelta; // for BLEP synthesis
448
449 // cache these371 // cache these
450 dOldVoiceDelta = v->dDelta;372 dOldVoiceDelta = dPeriodToDeltaDiv / realPeriod;
451 dOldVoiceDeltaMul = v->dDeltaMul; // for BLEP synthesis373 dOldVoiceDeltaMul = 1.0 / dOldVoiceDelta; // for BLEP synthesis
452 oldScopeDelta = (PAULA_PAL_CLK * (65536UL / SCOPE_HZ)) / period;374 oldScopeDelta = (PAULA_PAL_CLK * (65536UL / SCOPE_HZ)) / realPeriod;
453
454 setScopeDelta(ch, oldScopeDelta);
455 }375 }
456 376
377 v->dDelta = dOldVoiceDelta;
378 v->dDeltaMul = dOldVoiceDeltaMul; // for BLEP synthesis
379 setScopeDelta(ch, oldScopeDelta);
380
457 // for BLEP synthesis381 // for BLEP synthesis
458 382
459 if (v->dLastDelta == 0.0)383 if (v->dLastDelta == 0.0)
@@ -478,13 +402,13 @@ void paulaSetLength(uint8_t ch, uint16_t len) · 18 unmodified lines
478 if (len == 0)402 if (len == 0)
479 {403 {
480 len = 65535;404 len = 65535;
481 /* confirmed behavior on real Amiga (also needed for safety)405 /* Confirmed behavior on real Amiga (also needed for safety).
482 ** And yes, we have room for this, it will never overflow!406 ** And yes, we have room for this, it will never overflow!
483 */407 */
484 }408 }
485 409
486 // our mixer works with bytes, not words. Multiply by two410 // 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;
488}412}
489 413
490void paulaSetData(uint8_t ch, const int8_t *src)414void paulaSetData(uint8_t ch, const int8_t *src)
@@ -514,25 +438,86 @@ void paulaSetData(uint8_t ch, const int8_t *src) · 23 unmodified lines
514 *se = tmp; // update it438 *se = tmp; // update it
515}439}
516 440
441void paulaStopDMA(uint8_t ch)
442{
443 scopeExt[ch].active = paula[ch].active = false;
444}
445
446void 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
517void toggleA500Filters(void)498void toggleA500Filters(void)
518{499{
500 lockAudio();
501 clearLossyIntegrator(&filterLo);
502 clearLossyIntegrator(&filterHi);
503 clearLEDFilter(&filterLED);
504 unlockAudio();
505
519 if (filterFlags & FILTER_A500)506 if (filterFlags & FILTER_A500)
520 {507 {
521 filterFlags &= ~FILTER_A500;508 filterFlags &= ~FILTER_A500;
522 displayMsg("FILTER MOD: A1200");509 displayMsg("LP FILTER: A1200");
523 }510 }
524 else511 else
525 {512 {
526 filterFlags |= FILTER_A500;513 filterFlags |= FILTER_A500;
527 clearLossyIntegrator(&filterLo);514 displayMsg("LP FILTER: A500");
528 displayMsg("FILTER MOD: A500");
529 }515 }
530}516}
531 517
532void mixChannels(int32_t numSamples)518void mixChannels(int32_t numSamples)
533{519{
534 const int8_t *dataPtr;520 double dSmp, dVol;
535 double dTempSample, dTempVolume;
536 blep_t *bSmp, *bVol;521 blep_t *bSmp, *bVol;
537 paulaVoice_t *v;522 paulaVoice_t *v;
538 523
@@ -542,7 +527,7 @@ void mixChannels(int32_t numSamples) · 3 unmodified lines
542 for (int32_t i = 0; i < AMIGA_VOICES; i++)527 for (int32_t i = 0; i < AMIGA_VOICES; i++)
543 {528 {
544 v = &paula[i];529 v = &paula[i];
545 if (!v->active)530 if (!v->active || v->data == NULL)
546 continue;531 continue;
547 532
548 bSmp = &blep[i];533 bSmp = &blep[i];
@@ -550,47 +535,108 @@ void mixChannels(int32_t numSamples) · 1 unmodified line
550 535
551 for (int32_t j = 0; j < numSamples; j++)536 for (int32_t j = 0; j < numSamples; j++)
552 {537 {
553 dataPtr = v->data;538 assert(v->data != NULL);
554 if (dataPtr == NULL)539 dSmp = v->data[v->pos] * (1.0 / 128.0);
540 dVol = v->dVolume;
541
542 if (dSmp != bSmp->dLastValue)
555 {543 {
556 dTempSample = 0.0;544 if (v->dLastDelta > v->dLastPhase)
557 dTempVolume = 0.0;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;
558 }551 }
559 else552
553 if (dVol != bVol->dLastValue)
560 {554 {
561 dTempSample = dataPtr[v->pos] * (1.0 / 128.0);555 blepVolAdd(bVol, bVol->dLastValue - dVol);
562 dTempVolume = v->dVolume;556 bVol->dLastValue = dVol;
563 }557 }
564 558
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
589void 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)
566 {614 {
567 if (v->dLastDelta > v->dLastPhase)615 if (v->dLastDelta > v->dLastPhase)
568 {616 {
569 // div->mul trick: v->dLastDeltaMul is 1.0 / v->dLastDelta617 // 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);
571 }619 }
572 620
573 bSmp->dLastValue = dTempSample;621 bSmp->dLastValue = dSmp;
574 }622 }
575 623
576 if (dTempVolume != bVol->dLastValue)624 if (dVol != bVol->dLastValue)
577 {625 {
578 blepVolAdd(bVol, bVol->dLastValue - dTempVolume);626 blepVolAdd(bVol, bVol->dLastValue - dVol);
579 bVol->dLastValue = dTempVolume;627 bVol->dLastValue = dVol;
580 }628 }
581 629
582 if (bSmp->samplesLeft > 0) dTempSample += blepRun(bSmp);630 if (bSmp->samplesLeft > 0) dSmp += blepRun(bSmp);
583 if (bVol->samplesLeft > 0) dTempVolume += blepRun(bVol);631 if (bVol->samplesLeft > 0) dVol += blepRun(bVol);
584 632
585 dTempSample *= dTempVolume;633 dSmp *= dVol;
586 634
587 dMixBufferL[j] += dTempSample * v->dPanL;635 dMixBufferL[j] += dSmp * v->dPanL;
588 dMixBufferR[j] += dTempSample * v->dPanR;636 dMixBufferR[j] += dSmp * v->dPanR;
589 637
590 v->dPhase += v->dDelta;638 v->dPhase += v->dDelta;
591 639 while (v->dPhase >= 1.0) // multi-step
592 // PAT2SMP needs multi-step, so use while() here (will be only one iteration in normal mixing mode)
593 while (v->dPhase >= 1.0)
594 {640 {
595 v->dPhase -= 1.0;641 v->dPhase -= 1.0;
596 642
@@ -636,9 +682,42 @@ static inline void processMixedSamplesA1200(int32_t i, int16_t *out) · 39 unmodified lines
636 682
637 // don't process any low-pass filter since the cut-off is around 28-31kHz on A1200683 // don't process any low-pass filter since the cut-off is around 28-31kHz on A1200
638 684
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
709static 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
639 // process "LED" filter719 // process "LED" filter
640 if (filterFlags & FILTER_LED_ENABLED)720 lossyIntegratorLED(filterLEDC, &filterLED, dOut, dOut);
641 lossyIntegratorLED(filterLEDC, &filterLED, dOut, dOut);
642 721
643 // process high-pass filter722 // process high-pass filter
644 lossyIntegratorHighPass(&filterHi, dOut, dOut);723 lossyIntegratorHighPass(&filterHi, dOut, dOut);
@@ -702,17 +781,54 @@ static inline void processMixedSamplesA500(int32_t i, int16_t *out) · 57 unmodified lines
702 out[1] = (int16_t)smp32;781 out[1] = (int16_t)smp32;
703}782}
704 783
784static 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
705void outputAudio(int16_t *target, int32_t numSamples)821void outputAudio(int16_t *target, int32_t numSamples)
706{822{
707 int16_t *outStream, out[2];823 int16_t *outStream, out[2];
708 int32_t j;824 int32_t j;
709 825
710 mixChannels(numSamples);
711
712 if (editor.isSMPRendering)826 if (editor.isSMPRendering)
713 {827 {
714 // render to sample (PAT2SMP)828 // render to sample (PAT2SMP)
715 829
830 mixChannelsMultiStep(numSamples);
831
716 for (j = 0; j < numSamples; j++)832 for (j = 0; j < numSamples; j++)
717 {833 {
718 processMixedSamplesA1200(j, out);834 processMixedSamplesA1200(j, out);
@@ -730,23 +846,53 @@ void outputAudio(int16_t *target, int32_t numSamples) · 11 unmodified lines
730 {846 {
731 // render to stream847 // render to stream
732 848
849 mixChannels(numSamples);
850
733 outStream = target;851 outStream = target;
734 if (filterFlags & FILTER_A500)852 if (filterFlags & FILTER_A500)
735 {853 {
736 for (j = 0; j < numSamples; j++)854 // Amiga 500 filter model
855
856 if (filterFlags & FILTER_LED_ENABLED)
737 {857 {
738 processMixedSamplesA500(j, out);858 for (j = 0; j < numSamples; j++)
739 *outStream++ = out[0];859 {
740 *outStream++ = out[1];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 }
741 }873 }
742 }874 }
743 else875 else
744 {876 {
745 for (j = 0; j < numSamples; j++)877 // Amiga 1200 filter model
878
879 if (filterFlags & FILTER_LED_ENABLED)
746 {880 {
747 processMixedSamplesA1200(j, out);881 for (j = 0; j < numSamples; j++)
748 *outStream++ = out[0];882 {
749 *outStream++ = out[1];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 }
750 }896 }
751 }897 }
752 }898 }
@@ -759,7 +905,7 @@ static void SDLCALL audioCallback(void *userdata, Uint8 *stream, int len) · 6 unmodified lines
759 905
760 (void)userdata;906 (void)userdata;
761 907
762 if (forceMixerOff) // during MOD2WAV908 if (audio.forceMixerOff) // during MOD2WAV
763 {909 {
764 memset(stream, 0, len);910 memset(stream, 0, len);
765 return;911 return;
@@ -878,12 +1024,12 @@ bool setupAudio(void) · 112 unmodified lines
878{1024{
879 SDL_AudioSpec want, have;1025 SDL_AudioSpec want, have;
880 1026
881 want.freq = ptConfig.soundFrequency;1027 want.freq = config.soundFrequency;
882 want.format = AUDIO_S16;1028 want.format = AUDIO_S16;
883 want.channels = 2;1029 want.channels = 2;
884 want.callback = audioCallback;1030 want.callback = audioCallback;
885 want.userdata = NULL;1031 want.userdata = NULL;
886 want.samples = ptConfig.soundBufferSize;1032 want.samples = config.soundBufferSize;
887 1033
888 dev = SDL_OpenAudioDevice(NULL, 0, &want, &have, 0);1034 dev = SDL_OpenAudioDevice(NULL, 0, &want, &have, 0);
889 if (dev == 0)1035 if (dev == 0)
@@ -921,15 +1067,15 @@ bool setupAudio(void) · 31 unmodified lines
921 dMixBufferR = (double *)ALIGN_PTR(dMixBufferRUnaligned, 256);1067 dMixBufferR = (double *)ALIGN_PTR(dMixBufferRUnaligned, 256);
922 1068
923 audio.audioBufferSize = have.samples;1069 audio.audioBufferSize = have.samples;
924 ptConfig.soundFrequency = have.freq;1070 config.soundFrequency = have.freq;
925 audio.audioFreq = ptConfig.soundFrequency;1071 audio.audioFreq = config.soundFrequency;
926 audio.dAudioFreq = (double)ptConfig.soundFrequency;1072 audio.dAudioFreq = (double)config.soundFrequency;
927 audio.dPeriodToDeltaDiv = PAULA_PAL_CLK / audio.dAudioFreq;1073 audio.dPeriodToDeltaDiv = PAULA_PAL_CLK / audio.dAudioFreq;
928 1074
929 mixerCalcVoicePans(ptConfig.stereoSeparation);1075 mixerCalcVoicePans(config.stereoSeparation);
930 defStereoSep = ptConfig.stereoSeparation;1076 defStereoSep = config.stereoSeparation;
931 1077
932 filterFlags = ptConfig.a500LowPassFilter ? FILTER_A500 : 0;1078 filterFlags = config.a500LowPassFilter ? FILTER_A500 : 0;
933 1079
934 calculateFilterCoeffs();1080 calculateFilterCoeffs();
935 generateBpmTables();1081 generateBpmTables();
src/pt2_audio.h+0−1
@@ -37,7 +37,6 @@ void paulaSetLength(uint8_t ch, uint16_t len); · 36 unmodified lines
37void paulaSetData(uint8_t ch, const int8_t *src);37void paulaSetData(uint8_t ch, const int8_t *src);
38void lockAudio(void);38void lockAudio(void);
39void unlockAudio(void);39void unlockAudio(void);
40void clearPaulaAndScopes(void);
41void mixerUpdateLoops(void);40void mixerUpdateLoops(void);
42void mixerKillVoice(uint8_t ch);41void mixerKillVoice(uint8_t ch);
43void turnOffVoices(void);42void turnOffVoices(void);
src/pt2_config.c+71−71
@@ -41,26 +41,26 @@ void loadConfig(void) · 40 unmodified lines
41 FILE *f;41 FILE *f;
42 42
43 // set default config values first43 // set default config values first
44 ptConfig.fullScreenStretch = false;44 config.fullScreenStretch = false;
45 ptConfig.pattDots = false;45 config.pattDots = false;
46 ptConfig.dottedCenterFlag = true;46 config.dottedCenterFlag = true;
47 ptConfig.a500LowPassFilter = false;47 config.a500LowPassFilter = false;
48 ptConfig.soundFrequency = 48000;48 config.soundFrequency = 48000;
49 ptConfig.rememberPlayMode = false;49 config.rememberPlayMode = false;
50 ptConfig.stereoSeparation = 20;50 config.stereoSeparation = 20;
51 ptConfig.videoScaleFactor = 2;51 config.videoScaleFactor = 2;
52 ptConfig.realVuMeters = false;52 config.realVuMeters = false;
53 ptConfig.modDot = false;53 config.modDot = false;
54 ptConfig.accidental = 0; // sharp54 config.accidental = 0; // sharp
55 ptConfig.quantizeValue = 1;55 config.quantizeValue = 1;
56 ptConfig.transDel = false;56 config.transDel = false;
57 ptConfig.blankZeroFlag = false;57 config.blankZeroFlag = false;
58 ptConfig.compoMode = false;58 config.compoMode = false;
59 ptConfig.soundBufferSize = 1024;59 config.soundBufferSize = 1024;
60 ptConfig.autoCloseDiskOp = true;60 config.autoCloseDiskOp = true;
61 ptConfig.vsyncOff = false;61 config.vsyncOff = false;
62 ptConfig.hwMouse = false;62 config.hwMouse = false;
63 ptConfig.sampleLowpass = true;63 config.sampleLowpass = true;
64 64
65#ifndef _WIN3265#ifndef _WIN32
66 getcwd(oldCwd, PATH_MAX);66 getcwd(oldCwd, PATH_MAX);
@@ -191,127 +191,127 @@ static bool loadProTrackerDotIni(FILE *f) · 124 unmodified lines
191 // HWMOUSE191 // HWMOUSE
192 else if (!_strnicmp(configLine, "HWMOUSE=", 8))192 else if (!_strnicmp(configLine, "HWMOUSE=", 8))
193 {193 {
194 if (!_strnicmp(&configLine[8], "TRUE", 4)) ptConfig.hwMouse = true;194 if (!_strnicmp(&configLine[8], "TRUE", 4)) config.hwMouse = true;
195 else if (!_strnicmp(&configLine[8], "FALSE", 5)) ptConfig.hwMouse = false;195 else if (!_strnicmp(&configLine[8], "FALSE", 5)) config.hwMouse = false;
196 }196 }
197 197
198 // SAMPLELOWPASS198 // SAMPLELOWPASS
199 else if (!_strnicmp(configLine, "SAMPLELOWPASS=", 14))199 else if (!_strnicmp(configLine, "SAMPLELOWPASS=", 14))
200 {200 {
201 if (!_strnicmp(&configLine[14], "TRUE", 4)) ptConfig.sampleLowpass = true;201 if (!_strnicmp(&configLine[14], "TRUE", 4)) config.sampleLowpass = true;
202 else if (!_strnicmp(&configLine[14], "FALSE", 5)) ptConfig.sampleLowpass = false;202 else if (!_strnicmp(&configLine[14], "FALSE", 5)) config.sampleLowpass = false;
203 }203 }
204 204
205 // VSYNCOFF205 // VSYNCOFF
206 else if (!_strnicmp(configLine, "VSYNCOFF=", 9))206 else if (!_strnicmp(configLine, "VSYNCOFF=", 9))
207 {207 {
208 if (!_strnicmp(&configLine[9], "TRUE", 4)) ptConfig.vsyncOff = true;208 if (!_strnicmp(&configLine[9], "TRUE", 4)) config.vsyncOff = true;
209 else if (!_strnicmp(&configLine[9], "FALSE", 5)) ptConfig.vsyncOff = false;209 else if (!_strnicmp(&configLine[9], "FALSE", 5)) config.vsyncOff = false;
210 }210 }
211 211
212 // FULLSCREENSTRETCH212 // FULLSCREENSTRETCH
213 else if (!_strnicmp(configLine, "FULLSCREENSTRETCH=", 18))213 else if (!_strnicmp(configLine, "FULLSCREENSTRETCH=", 18))
214 {214 {
215 if (!_strnicmp(&configLine[18], "TRUE", 4)) ptConfig.fullScreenStretch = true;215 if (!_strnicmp(&configLine[18], "TRUE", 4)) config.fullScreenStretch = true;
216 else if (!_strnicmp(&configLine[18], "FALSE", 5)) ptConfig.fullScreenStretch = false;216 else if (!_strnicmp(&configLine[18], "FALSE", 5)) config.fullScreenStretch = false;
217 }217 }
218 218
219 // HIDEDISKOPDATES219 // HIDEDISKOPDATES
220 else if (!_strnicmp(configLine, "HIDEDISKOPDATES=", 16))220 else if (!_strnicmp(configLine, "HIDEDISKOPDATES=", 16))
221 {221 {
222 if (!_strnicmp(&configLine[16], "TRUE", 4)) ptConfig.hideDiskOpDates = true;222 if (!_strnicmp(&configLine[16], "TRUE", 4)) config.hideDiskOpDates = true;
223 else if (!_strnicmp(&configLine[16], "FALSE", 5)) ptConfig.hideDiskOpDates = false;223 else if (!_strnicmp(&configLine[16], "FALSE", 5)) config.hideDiskOpDates = false;
224 }224 }
225 225
226 // AUTOCLOSEDISKOP226 // AUTOCLOSEDISKOP
227 else if (!_strnicmp(configLine, "AUTOCLOSEDISKOP=", 16))227 else if (!_strnicmp(configLine, "AUTOCLOSEDISKOP=", 16))
228 {228 {
229 if (!_strnicmp(&configLine[16], "TRUE", 4)) ptConfig.autoCloseDiskOp = true;229 if (!_strnicmp(&configLine[16], "TRUE", 4)) config.autoCloseDiskOp = true;
230 else if (!_strnicmp(&configLine[16], "FALSE", 5)) ptConfig.autoCloseDiskOp = false;230 else if (!_strnicmp(&configLine[16], "FALSE", 5)) config.autoCloseDiskOp = false;
231 }231 }
232 232
233 // COMPOMODE233 // COMPOMODE
234 else if (!_strnicmp(configLine, "COMPOMODE=", 10))234 else if (!_strnicmp(configLine, "COMPOMODE=", 10))
235 {235 {
236 if (!_strnicmp(&configLine[10], "TRUE", 4)) ptConfig.compoMode = true;236 if (!_strnicmp(&configLine[10], "TRUE", 4)) config.compoMode = true;
237 else if (!_strnicmp(&configLine[10], "FALSE", 5)) ptConfig.compoMode = false;237 else if (!_strnicmp(&configLine[10], "FALSE", 5)) config.compoMode = false;
238 }238 }
239 239
240 // PATTDOTS240 // PATTDOTS
241 else if (!_strnicmp(configLine, "PATTDOTS=", 9))241 else if (!_strnicmp(configLine, "PATTDOTS=", 9))
242 {242 {
243 if (!_strnicmp(&configLine[9], "TRUE", 4)) ptConfig.pattDots = true;243 if (!_strnicmp(&configLine[9], "TRUE", 4)) config.pattDots = true;
244 else if (!_strnicmp(&configLine[9], "FALSE", 5)) ptConfig.pattDots = false;244 else if (!_strnicmp(&configLine[9], "FALSE", 5)) config.pattDots = false;
245 }245 }
246 246
247 // BLANKZERO247 // BLANKZERO
248 else if (!_strnicmp(configLine, "BLANKZERO=", 10))248 else if (!_strnicmp(configLine, "BLANKZERO=", 10))
249 {249 {
250 if (!_strnicmp(&configLine[10], "TRUE", 4)) ptConfig.blankZeroFlag = true;250 if (!_strnicmp(&configLine[10], "TRUE", 4)) config.blankZeroFlag = true;
251 else if (!_strnicmp(&configLine[10], "FALSE", 5)) ptConfig.blankZeroFlag = false;251 else if (!_strnicmp(&configLine[10], "FALSE", 5)) config.blankZeroFlag = false;
252 }252 }
253 253
254 // REALVUMETERS254 // REALVUMETERS
255 else if (!_strnicmp(configLine, "REALVUMETERS=", 13))255 else if (!_strnicmp(configLine, "REALVUMETERS=", 13))
256 {256 {
257 if (!_strnicmp(&configLine[13], "TRUE", 4)) ptConfig.realVuMeters = true;257 if (!_strnicmp(&configLine[13], "TRUE", 4)) config.realVuMeters = true;
258 else if (!_strnicmp(&configLine[13], "FALSE", 5)) ptConfig.realVuMeters = false;258 else if (!_strnicmp(&configLine[13], "FALSE", 5)) config.realVuMeters = false;
259 }259 }
260 260
261 // ACCIDENTAL261 // ACCIDENTAL
262 else if (!_strnicmp(configLine, "ACCIDENTAL=", 11))262 else if (!_strnicmp(configLine, "ACCIDENTAL=", 11))
263 {263 {
264 if (!_strnicmp(&configLine[11], "SHARP", 4)) ptConfig.accidental = 0;264 if (!_strnicmp(&configLine[11], "SHARP", 4)) config.accidental = 0;
265 else if (!_strnicmp(&configLine[11], "FLAT", 5)) ptConfig.accidental = 1;265 else if (!_strnicmp(&configLine[11], "FLAT", 5)) config.accidental = 1;
266 }266 }
267 267
268 // QUANTIZE268 // QUANTIZE
269 else if (!_strnicmp(configLine, "QUANTIZE=", 9))269 else if (!_strnicmp(configLine, "QUANTIZE=", 9))
270 {270 {
271 if (configLine[9] != '\0')271 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));
273 }273 }
274 274
275 // TRANSDEL275 // TRANSDEL
276 else if (!_strnicmp(configLine, "TRANSDEL=", 9))276 else if (!_strnicmp(configLine, "TRANSDEL=", 9))
277 {277 {
278 if (!_strnicmp(&configLine[9], "TRUE", 4)) ptConfig.transDel = true;278 if (!_strnicmp(&configLine[9], "TRUE", 4)) config.transDel = true;
279 else if (!_strnicmp(&configLine[9], "FALSE", 5)) ptConfig.transDel = false;279 else if (!_strnicmp(&configLine[9], "FALSE", 5)) config.transDel = false;
280 }280 }
281 281
282 // DOTTEDCENTER282 // DOTTEDCENTER
283 else if (!_strnicmp(configLine, "DOTTEDCENTER=", 13))283 else if (!_strnicmp(configLine, "DOTTEDCENTER=", 13))
284 {284 {
285 if (!_strnicmp(&configLine[13], "TRUE", 4)) ptConfig.dottedCenterFlag = true;285 if (!_strnicmp(&configLine[13], "TRUE", 4)) config.dottedCenterFlag = true;
286 else if (!_strnicmp(&configLine[13], "FALSE", 5)) ptConfig.dottedCenterFlag = false;286 else if (!_strnicmp(&configLine[13], "FALSE", 5)) config.dottedCenterFlag = false;
287 }287 }
288 288
289 // MODDOT289 // MODDOT
290 else if (!_strnicmp(configLine, "MODDOT=", 7))290 else if (!_strnicmp(configLine, "MODDOT=", 7))
291 {291 {
292 if (!_strnicmp(&configLine[7], "TRUE", 4)) ptConfig.modDot = true;292 if (!_strnicmp(&configLine[7], "TRUE", 4)) config.modDot = true;
293 else if (!_strnicmp(&configLine[7], "FALSE", 5)) ptConfig.modDot = false;293 else if (!_strnicmp(&configLine[7], "FALSE", 5)) config.modDot = false;
294 }294 }
295 295
296 // SCALE3X (deprecated)296 // SCALE3X (deprecated)
297 else if (!_strnicmp(configLine, "SCALE3X=", 8))297 else if (!_strnicmp(configLine, "SCALE3X=", 8))
298 {298 {
299 if (!_strnicmp(&configLine[8], "TRUE", 4)) ptConfig.videoScaleFactor = 3;299 if (!_strnicmp(&configLine[8], "TRUE", 4)) config.videoScaleFactor = 3;
300 else if (!_strnicmp(&configLine[8], "FALSE", 5)) ptConfig.videoScaleFactor = 2;300 else if (!_strnicmp(&configLine[8], "FALSE", 5)) config.videoScaleFactor = 2;
301 }301 }
302 302
303 // VIDEOSCALE303 // VIDEOSCALE
304 else if (!_strnicmp(configLine, "VIDEOSCALE=", 11))304 else if (!_strnicmp(configLine, "VIDEOSCALE=", 11))
305 {305 {
306 if (lineLen >= 13 && configLine[12] == 'X' && isdigit(configLine[11]))306 if (lineLen >= 13 && configLine[12] == 'X' && isdigit(configLine[11]))
307 ptConfig.videoScaleFactor = configLine[11] - '0';307 config.videoScaleFactor = configLine[11] - '0';
308 }308 }
309 309
310 // REMEMBERPLAYMODE310 // REMEMBERPLAYMODE
311 else if (!_strnicmp(configLine, "REMEMBERPLAYMODE=", 17))311 else if (!_strnicmp(configLine, "REMEMBERPLAYMODE=", 17))
312 {312 {
313 if (!_strnicmp(&configLine[17], "TRUE", 4)) ptConfig.rememberPlayMode = true;313 if (!_strnicmp(&configLine[17], "TRUE", 4)) config.rememberPlayMode = true;
314 else if (!_strnicmp(&configLine[17], "FALSE", 5)) ptConfig.rememberPlayMode = false;314 else if (!_strnicmp(&configLine[17], "FALSE", 5)) config.rememberPlayMode = false;
315 }315 }
316 316
317 // DEFAULTDIR317 // DEFAULTDIR
@@ -325,7 +325,7 @@ static bool loadProTrackerDotIni(FILE *f) · 7 unmodified lines
325 325
326 lineLen -= i;326 lineLen -= i;
327 if (lineLen > 0)327 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);
329 }329 }
330 }330 }
331 331
@@ -340,43 +340,43 @@ static bool loadProTrackerDotIni(FILE *f) · 8 unmodified lines
340 340
341 lineLen -= i;341 lineLen -= i;
342 if (lineLen > 0)342 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);
344 }344 }
345 }345 }
346 346
347 // A500LOWPASSFILTER347 // A500LOWPASSFILTER
348 else if (!_strnicmp(configLine, "A500LOWPASSFILTER=", 18))348 else if (!_strnicmp(configLine, "A500LOWPASSFILTER=", 18))
349 {349 {
350 if (!_strnicmp(&configLine[18], "TRUE", 4)) ptConfig.a500LowPassFilter = true;350 if (!_strnicmp(&configLine[18], "TRUE", 4)) config.a500LowPassFilter = true;
351 else if (!_strnicmp(&configLine[18], "FALSE", 5)) ptConfig.a500LowPassFilter = false;351 else if (!_strnicmp(&configLine[18], "FALSE", 5)) config.a500LowPassFilter = false;
352 }352 }
353 353
354 // A4000LOWPASSFILTER (deprecated, same as A500LOWPASSFILTER)354 // A4000LOWPASSFILTER (deprecated, same as A500LOWPASSFILTER)
355 else if (!_strnicmp(configLine, "A4000LOWPASSFILTER=", 19))355 else if (!_strnicmp(configLine, "A4000LOWPASSFILTER=", 19))
356 {356 {
357 if (!_strnicmp(&configLine[19], "TRUE", 4)) ptConfig.a500LowPassFilter = true;357 if (!_strnicmp(&configLine[19], "TRUE", 4)) config.a500LowPassFilter = true;
358 else if (!_strnicmp(&configLine[19], "FALSE", 5)) ptConfig.a500LowPassFilter = false;358 else if (!_strnicmp(&configLine[19], "FALSE", 5)) config.a500LowPassFilter = false;
359 }359 }
360 360
361 // FREQUENCY361 // FREQUENCY
362 else if (!_strnicmp(configLine, "FREQUENCY=", 10))362 else if (!_strnicmp(configLine, "FREQUENCY=", 10))
363 {363 {
364 if (configLine[10] != '\0')364 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));
366 }366 }
367 367
368 // BUFFERSIZE368 // BUFFERSIZE
369 else if (!_strnicmp(configLine, "BUFFERSIZE=", 11))369 else if (!_strnicmp(configLine, "BUFFERSIZE=", 11))
370 {370 {
371 if (configLine[11] != '\0')371 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));
373 }373 }
374 374
375 // STEREOSEPARATION375 // STEREOSEPARATION
376 else if (!_strnicmp(configLine, "STEREOSEPARATION=", 17))376 else if (!_strnicmp(configLine, "STEREOSEPARATION=", 17))
377 {377 {
378 if (configLine[17] != '\0')378 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));
380 }380 }
381 381
382 configLine = strtok(NULL, "\n");382 configLine = strtok(NULL, "\n");
@@ -450,20 +450,20 @@ static bool loadPTDotConfig(FILE *f) · 67 unmodified lines
450 {450 {
451 fread(&tmp16, 2, 1, f); // stored as Big-Endian451 fread(&tmp16, 2, 1, f); // stored as Big-Endian
452 tmp16 = SWAP16(tmp16);452 tmp16 = SWAP16(tmp16);
453 palette[i] = RGB12_to_RGB24(tmp16);453 video.palette[i] = RGB12_to_RGB24(tmp16);
454 }454 }
455 455
456 // Transpose Delete (delete out of range notes on transposing)456 // Transpose Delete (delete out of range notes on transposing)
457 fseek(f, 174, SEEK_SET);457 fseek(f, 174, SEEK_SET);
458 fread(&tmp8, 1, 1, f);458 fread(&tmp8, 1, 1, f);
459 ptConfig.transDel = tmp8 ? true : false;459 config.transDel = tmp8 ? true : false;
460 ptConfig.transDel = ptConfig.transDel;460 config.transDel = config.transDel;
461 461
462 // Note style (sharps/flats)462 // Note style (sharps/flats)
463 fseek(f, 200, SEEK_SET);463 fseek(f, 200, SEEK_SET);
464 fread(&tmp8, 1, 1, f);464 fread(&tmp8, 1, 1, f);
465 ptConfig.accidental = tmp8 ? 1 : 0;465 config.accidental = tmp8 ? 1 : 0;
466 ptConfig.accidental = ptConfig.accidental;466 config.accidental = config.accidental;
467 467
468 // Multi Mode Next468 // Multi Mode Next
469 fseek(f, 462, SEEK_SET);469 fseek(f, 462, SEEK_SET);
@@ -489,8 +489,8 @@ static bool loadPTDotConfig(FILE *f) · 19 unmodified lines
489 // Blank Zeroes489 // Blank Zeroes
490 fseek(f, 490, SEEK_SET);490 fseek(f, 490, SEEK_SET);
491 fread(&tmp8, 1, 1, f);491 fread(&tmp8, 1, 1, f);
492 ptConfig.blankZeroFlag = tmp8 ? true : false;492 config.blankZeroFlag = tmp8 ? true : false;
493 ptConfig.blankZeroFlag = ptConfig.blankZeroFlag;493 config.blankZeroFlag = config.blankZeroFlag;
494 494
495 // Initial Tempo (don't load if timing is set to VBLANK)495 // Initial Tempo (don't load if timing is set to VBLANK)
496 if (editor.timingMode == TEMPO_MODE_CIA)496 if (editor.timingMode == TEMPO_MODE_CIA)
@@ -603,7 +603,7 @@ static bool loadColorsDotIni(void) · 106 unmodified lines
603 {603 {
604 color = (hex2int(configLine[0]) << 8) | (hex2int(configLine[1]) << 4) | hex2int(configLine[2]);604 color = (hex2int(configLine[0]) << 8) | (hex2int(configLine[1]) << 4) | hex2int(configLine[2]);
605 color &= 0xFFF;605 color &= 0xFFF;
606 palette[line] = RGB12_to_RGB24(color);606 video.palette[line] = RGB12_to_RGB24(color);
607 607
608 configLine = strtok(NULL, "\n");608 configLine = strtok(NULL, "\n");
609 line++;609 line++;
src/pt2_config.h+2−2
@@ -3,7 +3,7 @@ · 2 unmodified lines
3#include <stdint.h>3#include <stdint.h>
4#include <stdbool.h>4#include <stdbool.h>
5 5
6struct ptConfig_t6struct config_t
7{7{
8 char *defModulesDir, *defSamplesDir;8 char *defModulesDir, *defSamplesDir;
9 bool dottedCenterFlag, pattDots, a500LowPassFilter, compoMode, autoCloseDiskOp, hideDiskOpDates, hwMouse;9 bool dottedCenterFlag, pattDots, a500LowPassFilter, compoMode, autoCloseDiskOp, hideDiskOpDates, hwMouse;
@@ -12,6 +12,6 @@ struct ptConfig_t · 2 unmodified lines
12 int8_t stereoSeparation, videoScaleFactor, accidental;12 int8_t stereoSeparation, videoScaleFactor, accidental;
13 uint16_t quantizeValue;13 uint16_t quantizeValue;
14 uint32_t soundFrequency, soundBufferSize;14 uint32_t soundFrequency, soundBufferSize;
15} ptConfig;15} config;
16 16
17void loadConfig(void);17void loadConfig(void);
src/pt2_diskop.c+25−25
@@ -450,12 +450,12 @@ bool diskOpSetPath(UNICHAR *path, bool cache) · 449 unmodified lines
450void diskOpSetInitPath(void)450void diskOpSetInitPath(void)
451{451{
452 // default module path452 // default module path
453 if (ptConfig.defModulesDir[0] != '\0')453 if (config.defModulesDir[0] != '\0')
454 {454 {
455#ifdef _WIN32455#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);
457#else457#else
458 strcpy(pathTmp, ptConfig.defModulesDir);458 strcpy(pathTmp, config.defModulesDir);
459#endif459#endif
460 UNICHAR_STRCPY(editor.modulesPathU, pathTmp);460 UNICHAR_STRCPY(editor.modulesPathU, pathTmp);
461 }461 }
@@ -466,12 +466,12 @@ void diskOpSetInitPath(void) · 4 unmodified lines
466 }466 }
467 467
468 // default sample path468 // default sample path
469 if (ptConfig.defSamplesDir[0] != '\0')469 if (config.defSamplesDir[0] != '\0')
470 {470 {
471#ifdef _WIN32471#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);
473#else473#else
474 strcpy(pathTmp, ptConfig.defSamplesDir);474 strcpy(pathTmp, config.defSamplesDir);
475#endif475#endif
476 UNICHAR_STRCPY(editor.samplesPathU, pathTmp);476 UNICHAR_STRCPY(editor.samplesPathU, pathTmp);
477 }477 }
@@ -715,14 +715,14 @@ static int32_t SDLCALL diskOpFillThreadFunc(void *ptr) · 237 unmodified lines
715 return true;715 return true;
716}716}
717 717
718static void printFileSize(uint32_t *frameBuffer, fileEntry_t *entry, uint16_t x, uint16_t y)718static void printFileSize(fileEntry_t *entry, uint16_t x, uint16_t y)
719{719{
720 char tmpStr[7];720 char tmpStr[7];
721 uint32_t fileSize, j;721 uint32_t fileSize, j;
722 722
723 if (entry->filesize == -1) // -1 means that the original filesize is above 2GB in our directory reader723 if (entry->filesize == -1) // -1 means that the original filesize is above 2GB in our directory reader
724 {724 {
725 textOut(frameBuffer, x, y, " >2GB", palette[PAL_QADSCP]);725 textOut(x, y, " >2GB", video.palette[PAL_QADSCP]);
726 return;726 return;
727 }727 }
728 728
@@ -754,27 +754,27 @@ static void printFileSize(uint32_t *frameBuffer, fileEntry_t *entry, uint16_t x, · 25 unmodified lines
754 tmpStr[j] = ' ';754 tmpStr[j] = ' ';
755 }755 }
756 756
757 textOut(frameBuffer, x, y, tmpStr, palette[PAL_QADSCP]);757 textOut(x, y, tmpStr, video.palette[PAL_QADSCP]);
758}758}
759 759
760static void printEntryName(uint32_t *frameBuffer, char *entryName, int32_t entryLength, int32_t maxLength, uint16_t x, uint16_t y)760static void printEntryName(char *entryName, int32_t entryLength, int32_t maxLength, uint16_t x, uint16_t y)
761{761{
762 if (entryLength > maxLength)762 if (entryLength > maxLength)
763 {763 {
764 // shorten name and add ".." to end764 // shorten name and add ".." to end
765 for (int32_t j = 0; j < maxLength-2; j++)765 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]);
767 767
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]);
769 }769 }
770 else770 else
771 {771 {
772 // print whole name772 // print whole name
773 textOut(frameBuffer, x, y, entryName, palette[PAL_QADSCP]);773 textOut(x, y, entryName, video.palette[PAL_QADSCP]);
774 }774 }
775}775}
776 776
777void diskOpRenderFileList(uint32_t *frameBuffer)777void diskOpRenderFileList(void)
778{778{
779 char *entryName;779 char *entryName;
780 uint8_t maxFilenameChars, maxDirNameChars;780 uint8_t maxFilenameChars, maxDirNameChars;
@@ -783,7 +783,7 @@ void diskOpRenderFileList(uint32_t *frameBuffer) · 2 unmodified lines
783 uint32_t *dstPtr;783 uint32_t *dstPtr;
784 fileEntry_t *entry;784 fileEntry_t *entry;
785 785
786 if (ptConfig.hideDiskOpDates)786 if (config.hideDiskOpDates)
787 {787 {
788 textXStart = 8;788 textXStart = 8;
789 maxFilenameChars = 30;789 maxFilenameChars = 30;
@@ -813,11 +813,11 @@ void diskOpRenderFileList(uint32_t *frameBuffer) · 23 unmodified lines
813 }813 }
814 814
815 // clear list815 // clear list
816 dstPtr = &frameBuffer[(35 * SCREEN_W) + 8];816 dstPtr = &video.frameBuffer[(35 * SCREEN_W) + 8];
817 for (y = 0; y < 59; y++)817 for (y = 0; y < 59; y++)
818 {818 {
819 for (x = 0; x < 295; x++)819 for (x = 0; x < 295; x++)
820 dstPtr[x] = palette[PAL_BACKGRD];820 dstPtr[x] = video.palette[PAL_BACKGRD];
821 821
822 dstPtr += SCREEN_W;822 dstPtr += SCREEN_W;
823 }823 }
@@ -840,19 +840,19 @@ void diskOpRenderFileList(uint32_t *frameBuffer) · 16 unmodified lines
840 840
841 if (!entry->isDir)841 if (!entry->isDir)
842 {842 {
843 printEntryName(frameBuffer, entryName, entryLength, maxFilenameChars, x, y);843 printEntryName(entryName, entryLength, maxFilenameChars, x, y);
844 844
845 // print modification date845 // print modification date
846 if (!ptConfig.hideDiskOpDates)846 if (!config.hideDiskOpDates)
847 textOut(frameBuffer, 8, y, entry->dateChanged, palette[PAL_QADSCP]);847 textOut(8, y, entry->dateChanged, video.palette[PAL_QADSCP]);
848 848
849 // print file size849 // print file size
850 printFileSize(frameBuffer, entry, 256, y);850 printFileSize(entry, 256, y);
851 }851 }
852 else852 else
853 {853 {
854 printEntryName(frameBuffer, entryName, entryLength, maxDirNameChars, x, y);854 printEntryName(entryName, entryLength, maxDirNameChars, x, y);
855 textOut(frameBuffer, 264, y, "(DIR)", palette[PAL_QADSCP]);855 textOut(264, y, "(DIR)", video.palette[PAL_QADSCP]);
856 }856 }
857 }857 }
858}858}
@@ -900,10 +900,10 @@ void diskOpLoadFile(uint32_t fileEntryRow, bool songModifiedCheck) · 41 unmodified lines
900 900
901 statusAllRight();901 statusAllRight();
902 902
903 if (ptConfig.autoCloseDiskOp)903 if (config.autoCloseDiskOp)
904 editor.ui.diskOpScreenShown = false;904 editor.ui.diskOpScreenShown = false;
905 905
906 if (ptConfig.rememberPlayMode)906 if (config.rememberPlayMode)
907 {907 {
908 if (oldMode == MODE_PLAY || oldMode == MODE_RECORD)908 if (oldMode == MODE_PLAY || oldMode == MODE_RECORD)
909 {909 {
src/pt2_diskop.h+1−1
@@ -22,7 +22,7 @@ char *diskOpGetAnsiEntry(int32_t fileIndex); · 21 unmodified lines
22UNICHAR *diskOpGetUnicodeEntry(int32_t fileIndex);22UNICHAR *diskOpGetUnicodeEntry(int32_t fileIndex);
23bool diskOpSetPath(UNICHAR *path, bool cache);23bool diskOpSetPath(UNICHAR *path, bool cache);
24void diskOpSetInitPath(void);24void diskOpSetInitPath(void);
25void diskOpRenderFileList(uint32_t *frameBuffer);25void diskOpRenderFileList(void);
26bool allocDiskOpVars(void);26bool allocDiskOpVars(void);
27void freeDiskOpMem(void);27void freeDiskOpMem(void);
28void freeDiskOpEntryMem(void);28void freeDiskOpEntryMem(void);
src/pt2_edit.c+17−17
@@ -256,14 +256,14 @@ void exitGetTextLine(bool updateValue) · 255 unmodified lines
256 256
257 case PTB_EO_QUANTIZE:257 case PTB_EO_QUANTIZE:
258 {258 {
259 editor.quantizeValueDisp = &ptConfig.quantizeValue;259 editor.quantizeValueDisp = &config.quantizeValue;
260 260
261 if (updateValue)261 if (updateValue)
262 {262 {
263 if (editor.ui.tmpDisp16 > 63)263 if (editor.ui.tmpDisp16 > 63)
264 editor.ui.tmpDisp16 = 63;264 editor.ui.tmpDisp16 = 63;
265 265
266 ptConfig.quantizeValue = editor.ui.tmpDisp16;266 config.quantizeValue = editor.ui.tmpDisp16;
267 editor.ui.updateQuantizeText = true;267 editor.ui.updateQuantizeText = true;
268 }268 }
269 }269 }
@@ -679,7 +679,7 @@ void handleEditKeys(SDL_Scancode scancode, bool normalMode) · 409 unmodified lines
679 if (editor.ui.samplerScreenShown || (editor.currMode == MODE_IDLE || editor.currMode == MODE_PLAY))679 if (editor.ui.samplerScreenShown || (editor.currMode == MODE_IDLE || editor.currMode == MODE_PLAY))
680 {680 {
681 // at this point it will only jam, not place it681 // 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)
683 jamAndPlaceSample(scancode, normalMode);683 jamAndPlaceSample(scancode, normalMode);
684 684
685 return;685 return;
@@ -701,7 +701,7 @@ void handleEditKeys(SDL_Scancode scancode, bool normalMode) · 15 unmodified lines
701 if (editor.cursor.mode != CURSOR_NOTE)701 if (editor.cursor.mode != CURSOR_NOTE)
702 {702 {
703 // if we held down any key modifier at this point, then do nothing703 // 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)
705 return;705 return;
706 706
707 if (editor.currMode == MODE_EDIT || editor.currMode == MODE_RECORD)707 if (editor.currMode == MODE_EDIT || editor.currMode == MODE_RECORD)
@@ -821,13 +821,13 @@ void handleEditKeys(SDL_Scancode scancode, bool normalMode) · 113 unmodified lines
821 {821 {
822 note = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];822 note = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
823 823
824 if (!input.keyb.leftAltPressed)824 if (!keyb.leftAltPressed)
825 {825 {
826 note->sample = 0;826 note->sample = 0;
827 note->period = 0;827 note->period = 0;
828 }828 }
829 829
830 if (input.keyb.shiftPressed || input.keyb.leftAltPressed)830 if (keyb.shiftPressed || keyb.leftAltPressed)
831 {831 {
832 note->command = 0;832 note->command = 0;
833 note->param = 0;833 note->param = 0;
@@ -842,7 +842,7 @@ void handleEditKeys(SDL_Scancode scancode, bool normalMode) · 8 unmodified lines
842 else842 else
843 {843 {
844 // if we held down any key modifier at this point, then do nothing844 // 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)
846 return;846 return;
847 847
848 jamAndPlaceSample(scancode, normalMode);848 jamAndPlaceSample(scancode, normalMode);
@@ -854,7 +854,7 @@ bool handleSpecialKeys(SDL_Scancode scancode) · 5 unmodified lines
854{854{
855 note_t *patt, *note, *prevNote;855 note_t *patt, *note, *prevNote;
856 856
857 if (!input.keyb.leftAltPressed)857 if (!keyb.leftAltPressed)
858 return false;858 return false;
859 859
860 patt = modEntry->patterns[modEntry->currPattern];860 patt = modEntry->patterns[modEntry->currPattern];
@@ -1015,7 +1015,7 @@ uint8_t quantizeCheck(uint8_t row) · 154 unmodified lines
1015{1015{
1016 uint8_t tempRow, quantize;1016 uint8_t tempRow, quantize;
1017 1017
1018 quantize = (uint8_t)ptConfig.quantizeValue;1018 quantize = (uint8_t)config.quantizeValue;
1019 1019
1020 editor.didQuantize = false;1020 editor.didQuantize = false;
1021 if (editor.currMode == MODE_RECORD)1021 if (editor.currMode == MODE_RECORD)
@@ -1307,7 +1307,7 @@ void trackNoteUp(bool sampleAllFlag, uint8_t from, uint8_t to) · 285 unmodified lines
1307 {1307 {
1308 j = 35;1308 j = 35;
1309 1309
1310 if (ptConfig.transDel)1310 if (config.transDel)
1311 {1311 {
1312 noteSrc->period = 0;1312 noteSrc->period = 0;
1313 noteSrc->sample = 0;1313 noteSrc->sample = 0;
@@ -1360,7 +1360,7 @@ void trackNoteDown(bool sampleAllFlag, uint8_t from, uint8_t to) · 46 unmodified lines
1360 {1360 {
1361 j = 0;1361 j = 0;
1362 1362
1363 if (ptConfig.transDel)1363 if (config.transDel)
1364 {1364 {
1365 noteSrc->period = 0;1365 noteSrc->period = 0;
1366 noteSrc->sample = 0;1366 noteSrc->sample = 0;
@@ -1409,7 +1409,7 @@ void trackOctaUp(bool sampleAllFlag, uint8_t from, uint8_t to) · 42 unmodified lines
1409 }1409 }
1410 1410
1411 noteDeleted = false;1411 noteDeleted = false;
1412 if (j+12 > 35 && ptConfig.transDel)1412 if (j+12 > 35 && config.transDel)
1413 {1413 {
1414 noteSrc->period = 0;1414 noteSrc->period = 0;
1415 noteSrc->sample = 0;1415 noteSrc->sample = 0;
@@ -1460,7 +1460,7 @@ void trackOctaDown(bool sampleAllFlag, uint8_t from, uint8_t to) · 44 unmodified lines
1460 }1460 }
1461 1461
1462 noteDeleted = false;1462 noteDeleted = false;
1463 if (j-12 < 0 && ptConfig.transDel)1463 if (j-12 < 0 && config.transDel)
1464 {1464 {
1465 noteSrc->period = 0;1465 noteSrc->period = 0;
1466 noteSrc->sample = 0;1466 noteSrc->sample = 0;
@@ -1510,7 +1510,7 @@ void pattNoteUp(bool sampleAllFlag) · 43 unmodified lines
1510 {1510 {
1511 k = 35;1511 k = 35;
1512 1512
1513 if (ptConfig.transDel)1513 if (config.transDel)
1514 {1514 {
1515 noteSrc->period = 0;1515 noteSrc->period = 0;
1516 noteSrc->sample = 0;1516 noteSrc->sample = 0;
@@ -1559,7 +1559,7 @@ void pattNoteDown(bool sampleAllFlag) · 42 unmodified lines
1559 {1559 {
1560 k = 0;1560 k = 0;
1561 1561
1562 if (ptConfig.transDel)1562 if (config.transDel)
1563 {1563 {
1564 noteSrc->period = 0;1564 noteSrc->period = 0;
1565 noteSrc->sample = 0;1565 noteSrc->sample = 0;
@@ -1604,7 +1604,7 @@ void pattOctaUp(bool sampleAllFlag) · 38 unmodified lines
1604 }1604 }
1605 1605
1606 noteDeleted = false;1606 noteDeleted = false;
1607 if (k+12 > 35 && ptConfig.transDel)1607 if (k+12 > 35 && config.transDel)
1608 {1608 {
1609 noteSrc->period = 0;1609 noteSrc->period = 0;
1610 noteSrc->sample = 0;1610 noteSrc->sample = 0;
@@ -1651,7 +1651,7 @@ void pattOctaDown(bool sampleAllFlag) · 40 unmodified lines
1651 }1651 }
1652 1652
1653 noteDeleted = false;1653 noteDeleted = false;
1654 if (k-12 < 0 && ptConfig.transDel)1654 if (k-12 < 0 && config.transDel)
1655 {1655 {
1656 noteSrc->period = 0;1656 noteSrc->period = 0;
1657 noteSrc->sample = 0;1657 noteSrc->sample = 0;
src/pt2_header.h+45−37
@@ -12,8 +12,9 @@ · 11 unmodified lines
12#endif12#endif
13#include <stdint.h>13#include <stdint.h>
14#include "pt2_unicode.h"14#include "pt2_unicode.h"
15#include "pt2_palette.h"
15 16
16#define PROG_VER_STR "1.07"17#define PROG_VER_STR "1.08"
17 18
18#ifdef _WIN3219#ifdef _WIN32
19#define DIR_DELIMITER '\\'20#define DIR_DELIMITER '\\'
@@ -285,39 +286,53 @@ typedef struct module_t · 265 unmodified lines
285 note_t *patterns[MAX_PATTERNS];286 note_t *patterns[MAX_PATTERNS];
286} module_t;287} module_t;
287 288
288struct cpu_t
289{
290 bool hasSSE, hasSSE2;
291} cpu;
292
293struct audio_t289struct audio_t
294{290{
291 volatile bool locked;
292 bool forceMixerOff;
295 uint16_t bpmTab[256-32], bpmTab28kHz[256-32], bpmTab22kHz[256-32];293 uint16_t bpmTab[256-32], bpmTab28kHz[256-32], bpmTab22kHz[256-32];
296 uint32_t audioFreq, audioBufferSize;294 uint32_t audioFreq, audioBufferSize;
297 double dAudioFreq, dPeriodToDeltaDiv;295 double dAudioFreq, dPeriodToDeltaDiv;
298} audio;296} audio;
299 297
300struct input_t298struct keyb_t
301{299{
302 struct keyb_t300 bool repeatKey, delayKey;
303 {301 bool shiftPressed, leftCtrlPressed, leftAltPressed;
304 bool repeatKey, delayKey;302 bool leftCommandPressed, leftAmigaPressed, keypadEnterPressed;
305 bool shiftPressed, leftCtrlPressed, leftAltPressed;303 uint8_t repeatCounter, delayCounter;
306 bool leftCommandPressed, leftAmigaPressed, keypadEnterPressed;304 uint64_t repeatFrac;
307 uint8_t repeatCounter, delayCounter;305 SDL_Scancode lastRepKey, lastKey;
308 uint64_t repeatFrac;306} keyb;
309 SDL_Scancode lastRepKey, lastKey;307
310 } keyb;308struct mouse_t
311 309{
312 struct mouse_t310 volatile bool setPosFlag;
313 {311 bool buttonWaiting, leftButtonPressed, rightButtonPressed;
314 volatile bool setPosFlag;312 uint8_t repeatCounter, buttonWaitCounter;
315 bool buttonWaiting, leftButtonPressed, rightButtonPressed;313 int32_t x, y, lastMouseX, setPosX, setPosY, lastGUIButton, lastSmpFilterButton, prevX, prevY;
316 uint8_t repeatCounter, buttonWaitCounter;314 uint32_t buttonState;
317 int32_t setPosX, setPosY, lastGUIButton, lastSmpFilterButton, prevX, prevY;315} mouse;
318 int16_t x, y, lastMouseX;316
319 } mouse;317struct video_t
320} input;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;
321 336
322// this is massive...337// this is massive...
323struct editor_t338struct editor_t
@@ -337,7 +352,7 @@ struct editor_t · 13 unmodified lines
337 352
338 bool errorMsgActive, errorMsgBlock, multiFlag, metroFlag, keypadToggle8CFlag, normalizeFiltersFlag;353 bool errorMsgActive, errorMsgBlock, multiFlag, metroFlag, keypadToggle8CFlag, normalizeFiltersFlag;
339 bool sampleAllFlag, halfClipFlag, newOldFlag, pat2SmpHQ, mixFlag, useLEDFilter;354 bool sampleAllFlag, halfClipFlag, newOldFlag, pat2SmpHQ, mixFlag, useLEDFilter;
340 bool modLoaded, fullscreen, autoInsFlag, repeatKeyFlag, sampleZero, tuningFlag;355 bool modLoaded, autoInsFlag, repeatKeyFlag, sampleZero, tuningFlag;
341 bool stepPlayEnabled, stepPlayBackwards, blockBufferFlag, blockMarkFlag, didQuantize;356 bool stepPlayEnabled, stepPlayBackwards, blockBufferFlag, blockMarkFlag, didQuantize;
342 bool swapChannelFlag, configFound, abortMod2Wav, chordLengthMin, rowVisitTable[MOD_ORDERS * MOD_ROWS];357 bool swapChannelFlag, configFound, abortMod2Wav, chordLengthMin, rowVisitTable[MOD_ORDERS * MOD_ROWS];
343 bool muted[AMIGA_VOICES];358 bool muted[AMIGA_VOICES];
@@ -430,17 +445,10 @@ struct editor_t · 86 unmodified lines
430 // these are used when things are drawn on top, for example clear/ask dialogs445 // these are used when things are drawn on top, for example clear/ask dialogs
431 bool disablePosEd, disableVisualizer;446 bool disablePosEd, disableVisualizer;
432 447
433 bool vsync60HzPresent;
434 int16_t lineCurX, lineCurY, editObject, sampleMarkingPos;448 int16_t lineCurX, lineCurY, editObject, sampleMarkingPos;
435 uint16_t *numPtr16, tmpDisp16, *dstOffset, dstPos, textLength, editTextPos;449 uint16_t *numPtr16, tmpDisp16, *dstOffset, dstPos, textLength, editTextPos;
436 uint16_t dstOffsetEnd, lastSampleOffset;450 uint16_t dstOffsetEnd, lastSampleOffset;
437 int32_t askTempData, renderX, renderY, renderW, renderH, displayW, displayH;451 int32_t askTempData;
438 int32_t xScale, yScale;
439 double dMouseXMul, dMouseYMul;
440 SDL_PixelFormat *pixelFormat;
441#ifdef _WIN32
442 HWND hWnd;
443#endif
444 } ui;452 } ui;
445 453
446 struct sampler_t454 struct sampler_t
@@ -448,8 +456,8 @@ struct editor_t · 1 unmodified line
448 const int8_t *samStart;456 const int8_t *samStart;
449 int8_t *blankSample, *copyBuf;457 int8_t *blankSample, *copyBuf;
450 int16_t loopStartPos, loopEndPos;458 int16_t loopStartPos, loopEndPos;
451 uint16_t dragStart, dragEnd, saveMouseX, lastSamPos;459 uint16_t dragStart, dragEnd;
452 int32_t samPointWidth, samOffset, samDisplay, samLength;460 int32_t samPointWidth, samOffset, samDisplay, samLength, saveMouseX, lastSamPos;
453 int32_t lastMouseX, lastMouseY, tmpLoopStart, tmpLoopLength;461 int32_t lastMouseX, lastMouseY, tmpLoopStart, tmpLoopLength;
454 uint32_t copyBufSize, samDrawStart, samDrawEnd;462 uint32_t copyBufSize, samDrawStart, samDrawEnd;
455 } sampler;463 } sampler;
src/pt2_helpers.c+6−8
@@ -20,8 +20,6 @@ · 19 unmodified lines
20#include "pt2_tables.h"20#include "pt2_tables.h"
21#include "pt2_palette.h"21#include "pt2_palette.h"
22 22
23extern SDL_Window *window; // pt_main.c
24
25// used for Windows usleep() implementation23// used for Windows usleep() implementation
26#ifdef _WIN3224#ifdef _WIN32
27static NTSTATUS (__stdcall *NtDelayExecution)(BOOL Alertable, PLARGE_INTEGER DelayInterval);25static NTSTATUS (__stdcall *NtDelayExecution)(BOOL Alertable, PLARGE_INTEGER DelayInterval);
@@ -71,7 +69,7 @@ void showErrorMsgBox(const char *fmt, ...) · 43 unmodified lines
71 va_end(args);69 va_end(args);
72 70
73 // window can be NULL here, no problem...71 // 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);
75}73}
76 74
77void sanitizeFilenameChar(char *chr)75void sanitizeFilenameChar(char *chr)
@@ -129,14 +127,14 @@ void updateWindowTitle(bool modified) · 51 unmodified lines
129 {127 {
130 if (modified)128 if (modified)
131 {129 {
132 if (ptConfig.modDot)130 if (config.modDot)
133 sprintf(titleTemp, "ProTracker 2 clone v%s - \"mod.%s\" (unsaved)", PROG_VER_STR, modEntry->head.moduleTitle);131 sprintf(titleTemp, "ProTracker 2 clone v%s - \"mod.%s\" (unsaved)", PROG_VER_STR, modEntry->head.moduleTitle);
134 else132 else
135 sprintf(titleTemp, "ProTracker 2 clone v%s - \"%s.mod\" (unsaved)", PROG_VER_STR, modEntry->head.moduleTitle);133 sprintf(titleTemp, "ProTracker 2 clone v%s - \"%s.mod\" (unsaved)", PROG_VER_STR, modEntry->head.moduleTitle);
136 }134 }
137 else135 else
138 {136 {
139 if (ptConfig.modDot)137 if (config.modDot)
140 sprintf(titleTemp, "ProTracker 2 clone v%s - \"mod.%s\"", PROG_VER_STR, modEntry->head.moduleTitle);138 sprintf(titleTemp, "ProTracker 2 clone v%s - \"mod.%s\"", PROG_VER_STR, modEntry->head.moduleTitle);
141 else139 else
142 sprintf(titleTemp, "ProTracker 2 clone v%s - \"%s.mod\"", PROG_VER_STR, modEntry->head.moduleTitle);140 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
146 {144 {
147 if (modified)145 if (modified)
148 {146 {
149 if (ptConfig.modDot)147 if (config.modDot)
150 sprintf(titleTemp, "ProTracker 2 clone v%s - \"mod.untitled\" (unsaved)", PROG_VER_STR);148 sprintf(titleTemp, "ProTracker 2 clone v%s - \"mod.untitled\" (unsaved)", PROG_VER_STR);
151 else149 else
152 sprintf(titleTemp, "ProTracker 2 clone v%s - \"untitled.mod\" (unsaved)", PROG_VER_STR);150 sprintf(titleTemp, "ProTracker 2 clone v%s - \"untitled.mod\" (unsaved)", PROG_VER_STR);
153 }151 }
154 else152 else
155 {153 {
156 if (ptConfig.modDot)154 if (config.modDot)
157 sprintf(titleTemp, "ProTracker 2 clone v%s - \"mod.untitled\"", PROG_VER_STR);155 sprintf(titleTemp, "ProTracker 2 clone v%s - \"mod.untitled\"", PROG_VER_STR);
158 else156 else
159 sprintf(titleTemp, "ProTracker 2 clone v%s - \"untitled.mod\"", PROG_VER_STR);157 sprintf(titleTemp, "ProTracker 2 clone v%s - \"untitled.mod\"", PROG_VER_STR);
160 }158 }
161 }159 }
162 160
163 SDL_SetWindowTitle(window, titleTemp);161 SDL_SetWindowTitle(video.window, titleTemp);
164}162}
165 163
166void recalcChordLength(void)164void recalcChordLength(void)
src/pt2_keyboard.c+323−325
@@ -32,8 +32,6 @@ extern bool windowsKeyIsDown; · 31 unmodified lines
32extern HHOOK g_hKeyboardHook;32extern HHOOK g_hKeyboardHook;
33#endif33#endif
34 34
35extern SDL_Window *window;
36
37void movePatCurPrevCh(void);35void movePatCurPrevCh(void);
38void movePatCurNextCh(void);36void movePatCurNextCh(void);
39void movePatCurRight(void);37void movePatCurRight(void);
@@ -58,14 +56,14 @@ void readKeyModifiers(void) · 18 unmodified lines
58 56
59 modState = SDL_GetModState();57 modState = SDL_GetModState();
60 58
61 input.keyb.leftCtrlPressed = (modState & KMOD_LCTRL) ? true : false;59 keyb.leftCtrlPressed = (modState & KMOD_LCTRL) ? true : false;
62 input.keyb.leftAltPressed = (modState & KMOD_LALT) ? true : false;60 keyb.leftAltPressed = (modState & KMOD_LALT) ? true : false;
63 input.keyb.shiftPressed = (modState & (KMOD_LSHIFT + KMOD_RSHIFT)) ? true : false;61 keyb.shiftPressed = (modState & (KMOD_LSHIFT + KMOD_RSHIFT)) ? true : false;
64#ifdef __APPLE__62#ifdef __APPLE__
65 input.keyb.leftCommandPressed = (modState & KMOD_LGUI) ? true : false;63 keyb.leftCommandPressed = (modState & KMOD_LGUI) ? true : false;
66#endif64#endif
67#ifndef _WIN32 // MS Windows: handled in lowLevelKeyboardProc65#ifndef _WIN32 // MS Windows: handled in lowLevelKeyboardProc
68 input.keyb.leftAmigaPressed = (modState & KMOD_LGUI) ? true : false;66 keyb.leftAmigaPressed = (modState & KMOD_LGUI) ? true : false;
69#endif67#endif
70}68}
71 69
@@ -88,7 +86,7 @@ LRESULT CALLBACK lowLevelKeyboardProc(int32_t nCode, WPARAM wParam, LPARAM lPara · 16 unmodified lines
88 case WM_KEYUP:86 case WM_KEYUP:
89 case WM_KEYDOWN:87 case WM_KEYDOWN:
90 {88 {
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);
92 90
93 if (bEatKeystroke)91 if (bEatKeystroke)
94 {92 {
@@ -109,7 +107,7 @@ LRESULT CALLBACK lowLevelKeyboardProc(int32_t nCode, WPARAM wParam, LPARAM lPara · 14 unmodified lines
109 else if (!windowsKeyIsDown)107 else if (!windowsKeyIsDown)
110 {108 {
111 windowsKeyIsDown = true;109 windowsKeyIsDown = true;
112 input.keyb.leftAmigaPressed = true;110 keyb.leftAmigaPressed = true;
113 111
114 memset(&inputEvent, 0, sizeof (SDL_Event));112 memset(&inputEvent, 0, sizeof (SDL_Event));
115 inputEvent.type = SDL_KEYDOWN;113 inputEvent.type = SDL_KEYDOWN;
@@ -136,7 +134,7 @@ LRESULT CALLBACK lowLevelKeyboardProc(int32_t nCode, WPARAM wParam, LPARAM lPara · 20 unmodified lines
136 else134 else
137 {135 {
138 windowsKeyIsDown = false;136 windowsKeyIsDown = false;
139 input.keyb.leftAmigaPressed = false;137 keyb.leftAmigaPressed = false;
140 138
141 memset(&inputEvent, 0, sizeof (SDL_Event));139 memset(&inputEvent, 0, sizeof (SDL_Event));
142 inputEvent.type = SDL_KEYUP;140 inputEvent.type = SDL_KEYUP;
@@ -329,11 +327,11 @@ void keyUpHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 186 unmodified lines
329 327
330 if (scancode == SDL_SCANCODE_KP_PLUS)328 if (scancode == SDL_SCANCODE_KP_PLUS)
331 {329 {
332 input.keyb.keypadEnterPressed = false;330 keyb.keypadEnterPressed = false;
333 }331 }
334 332
335 if (scancode == input.keyb.lastRepKey)333 if (scancode == keyb.lastRepKey)
336 input.keyb.lastRepKey = SDL_SCANCODE_UNKNOWN;334 keyb.lastRepKey = SDL_SCANCODE_UNKNOWN;
337 335
338 switch (scancode)336 switch (scancode)
339 {337 {
@@ -353,10 +351,10 @@ void keyUpHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 13 unmodified lines
353 351
354 default:352 default:
355 {353 {
356 input.keyb.repeatKey = false;354 keyb.repeatKey = false;
357 input.keyb.delayKey = false;355 keyb.delayKey = false;
358 input.keyb.repeatFrac = 0;356 keyb.repeatFrac = 0;
359 input.keyb.delayCounter = 0;357 keyb.delayCounter = 0;
360 }358 }
361 break;359 break;
362 }360 }
@@ -392,17 +390,17 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 29 unmodified lines
392 }390 }
393 391
394 // kludge to allow certain repeat-keys to use custom repeat/delay values392 // kludge to allow certain repeat-keys to use custom repeat/delay values
395 if (editor.repeatKeyFlag && input.keyb.repeatKey && scancode == input.keyb.lastRepKey &&393 if (editor.repeatKeyFlag && keyb.repeatKey && scancode == keyb.lastRepKey &&
396 (input.keyb.leftAltPressed || input.keyb.leftAmigaPressed || input.keyb.leftCtrlPressed))394 (keyb.leftAltPressed || keyb.leftAmigaPressed || keyb.leftCtrlPressed))
397 {395 {
398 return;396 return;
399 }397 }
400 398
401 if (scancode == SDL_SCANCODE_KP_PLUS)399 if (scancode == SDL_SCANCODE_KP_PLUS)
402 input.keyb.keypadEnterPressed = true;400 keyb.keypadEnterPressed = true;
403 401
404 // TOGGLE FULLSCREEN (should always react)402 // TOGGLE FULLSCREEN (should always react)
405 if (scancode == SDL_SCANCODE_F11 && !input.keyb.leftAltPressed)403 if (scancode == SDL_SCANCODE_F11 && !keyb.leftAltPressed)
406 {404 {
407 toggleFullScreen();405 toggleFullScreen();
408 406
@@ -428,23 +426,23 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 19 unmodified lines
428 if (editor.repeatKeyFlag)426 if (editor.repeatKeyFlag)
429 {427 {
430 // if Repeat Flag, repeat all keys428 // if Repeat Flag, repeat all keys
431 if (!input.keyb.repeatKey)429 if (!keyb.repeatKey)
432 {430 {
433 input.keyb.repeatCounter = 0;431 keyb.repeatCounter = 0;
434 input.keyb.repeatFrac = 0;432 keyb.repeatFrac = 0;
435 }433 }
436 434
437 input.keyb.repeatKey = true;435 keyb.repeatKey = true;
438 input.keyb.delayKey = true;436 keyb.delayKey = true;
439 }437 }
440 438
441 input.keyb.repeatCounter = 0;439 keyb.repeatCounter = 0;
442 input.keyb.repeatFrac = 0;440 keyb.repeatFrac = 0;
443 input.keyb.lastRepKey = scancode;441 keyb.lastRepKey = scancode;
444 }442 }
445 443
446 // ENTRY JUMPING IN DISK OP. FILELIST444 // 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)
448 {446 {
449 if (keycode >= 32 && keycode <= 126)447 if (keycode >= 32 && keycode <= 126)
450 {448 {
@@ -472,7 +470,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 21 unmodified lines
472 {470 {
473 if (editor.autoInsFlag)471 if (editor.autoInsFlag)
474 {472 {
475 if (input.keyb.shiftPressed)473 if (keyb.shiftPressed)
476 editor.autoInsSlot -= 4;474 editor.autoInsSlot -= 4;
477 else475 else
478 editor.autoInsSlot--;476 editor.autoInsSlot--;
@@ -487,7 +485,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
487 485
488 case SDL_SCANCODE_BACKSLASH:486 case SDL_SCANCODE_BACKSLASH:
489 {487 {
490 if (input.keyb.leftAltPressed)488 if (keyb.leftAltPressed)
491 {489 {
492 if (handleSpecialKeys(scancode) && editor.currMode != MODE_RECORD)490 if (handleSpecialKeys(scancode) && editor.currMode != MODE_RECORD)
493 modSetPos(DONT_SET_ORDER, (modEntry->currRow + editor.editMoveAdd) & 0x3F);491 modSetPos(DONT_SET_ORDER, (modEntry->currRow + editor.editMoveAdd) & 0x3F);
@@ -496,7 +494,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
496 {494 {
497 if (editor.autoInsFlag)495 if (editor.autoInsFlag)
498 {496 {
499 if (input.keyb.shiftPressed)497 if (keyb.shiftPressed)
500 editor.autoInsSlot += 4;498 editor.autoInsSlot += 4;
501 else499 else
502 editor.autoInsSlot++;500 editor.autoInsSlot++;
@@ -644,11 +642,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 141 unmodified lines
644 }642 }
645 }643 }
646 644
647 if (!input.keyb.repeatKey)645 if (!keyb.repeatKey)
648 input.keyb.delayCounter = 0;646 keyb.delayCounter = 0;
649 647
650 input.keyb.repeatKey = true;648 keyb.repeatKey = true;
651 input.keyb.delayKey = true;649 keyb.delayKey = true;
652 }650 }
653 break;651 break;
654 652
@@ -681,11 +679,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 26 unmodified lines
681 modSetPos(DONT_SET_ORDER, modEntry->currRow + 16);679 modSetPos(DONT_SET_ORDER, modEntry->currRow + 16);
682 }680 }
683 681
684 if (!input.keyb.repeatKey)682 if (!keyb.repeatKey)
685 input.keyb.delayCounter = 0;683 keyb.delayCounter = 0;
686 684
687 input.keyb.repeatKey = true;685 keyb.repeatKey = true;
688 input.keyb.delayKey = true;686 keyb.delayKey = true;
689 }687 }
690 break;688 break;
691 689
@@ -745,7 +743,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 53 unmodified lines
745 743
746 case SDL_SCANCODE_F12:744 case SDL_SCANCODE_F12:
747 {745 {
748 if (input.keyb.leftCtrlPressed)746 if (keyb.leftCtrlPressed)
749 {747 {
750 editor.timingMode ^= 1;748 editor.timingMode ^= 1;
751 if (editor.timingMode == TEMPO_MODE_VBLANK)749 if (editor.timingMode == TEMPO_MODE_VBLANK)
@@ -760,7 +758,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
760 758
761 editor.ui.updateSongTiming = true;759 editor.ui.updateSongTiming = true;
762 }760 }
763 else if (input.keyb.shiftPressed)761 else if (keyb.shiftPressed)
764 {762 {
765 toggleAmigaPanMode();763 toggleAmigaPanMode();
766 }764 }
@@ -783,10 +781,10 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 16 unmodified lines
783 }781 }
784 else782 else
785 {783 {
786 if (input.keyb.shiftPressed || input.keyb.leftAltPressed || input.keyb.leftCtrlPressed)784 if (keyb.shiftPressed || keyb.leftAltPressed || keyb.leftCtrlPressed)
787 {785 {
788 saveUndo();786 saveUndo();
789 if (input.keyb.leftAltPressed && !input.keyb.leftCtrlPressed)787 if (keyb.leftAltPressed && !keyb.leftCtrlPressed)
790 {788 {
791 if (modEntry->currRow < 63)789 if (modEntry->currRow < 63)
792 {790 {
@@ -821,7 +819,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 28 unmodified lines
821 noteSrc = &modEntry->patterns[modEntry->currPattern][((i + 0) * AMIGA_VOICES) + editor.cursor.channel];819 noteSrc = &modEntry->patterns[modEntry->currPattern][((i + 0) * AMIGA_VOICES) + editor.cursor.channel];
822 noteDst = &modEntry->patterns[modEntry->currPattern][((i + 1) * AMIGA_VOICES) + editor.cursor.channel];820 noteDst = &modEntry->patterns[modEntry->currPattern][((i + 1) * AMIGA_VOICES) + editor.cursor.channel];
823 821
824 if (input.keyb.leftCtrlPressed)822 if (keyb.leftCtrlPressed)
825 {823 {
826 noteDst->command = noteSrc->command;824 noteDst->command = noteSrc->command;
827 noteDst->param = noteSrc->param;825 noteDst->param = noteSrc->param;
@@ -834,7 +832,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
834 832
835 noteDst = &modEntry->patterns[modEntry->currPattern][((i + 1) * AMIGA_VOICES) + editor.cursor.channel];833 noteDst = &modEntry->patterns[modEntry->currPattern][((i + 1) * AMIGA_VOICES) + editor.cursor.channel];
836 834
837 if (!input.keyb.leftCtrlPressed)835 if (!keyb.leftCtrlPressed)
838 {836 {
839 noteDst->period = 0;837 noteDst->period = 0;
840 noteDst->sample = 0;838 noteDst->sample = 0;
@@ -903,7 +901,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 62 unmodified lines
903 }901 }
904 else902 else
905 {903 {
906 if (input.keyb.shiftPressed)904 if (keyb.shiftPressed)
907 {905 {
908 // cut channel and put in buffer906 // cut channel and put in buffer
909 saveUndo();907 saveUndo();
@@ -923,7 +921,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 13 unmodified lines
923 updateWindowTitle(MOD_IS_MODIFIED);921 updateWindowTitle(MOD_IS_MODIFIED);
924 editor.ui.updatePatternData = true;922 editor.ui.updatePatternData = true;
925 }923 }
926 else if (input.keyb.leftAltPressed)924 else if (keyb.leftAltPressed)
927 {925 {
928 // cut pattern and put in buffer926 // cut pattern and put in buffer
929 saveUndo();927 saveUndo();
@@ -937,7 +935,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 7 unmodified lines
937 updateWindowTitle(MOD_IS_MODIFIED);935 updateWindowTitle(MOD_IS_MODIFIED);
938 editor.ui.updatePatternData = true;936 editor.ui.updatePatternData = true;
939 }937 }
940 else if (input.keyb.leftCtrlPressed)938 else if (keyb.leftCtrlPressed)
941 {939 {
942 // cut channel commands and put in buffer940 // cut channel commands and put in buffer
943 saveUndo();941 saveUndo();
@@ -967,7 +965,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 23 unmodified lines
967 }965 }
968 else966 else
969 {967 {
970 if (input.keyb.shiftPressed)968 if (keyb.shiftPressed)
971 {969 {
972 // copy channel to buffer970 // copy channel to buffer
973 971
@@ -975,14 +973,14 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 1 unmodified line
975 for (i = 0; i < MOD_ROWS; i++)973 for (i = 0; i < MOD_ROWS; i++)
976 *noteDst++ = modEntry->patterns[modEntry->currPattern][(i * AMIGA_VOICES) + editor.cursor.channel];974 *noteDst++ = modEntry->patterns[modEntry->currPattern][(i * AMIGA_VOICES) + editor.cursor.channel];
977 }975 }
978 else if (input.keyb.leftAltPressed)976 else if (keyb.leftAltPressed)
979 {977 {
980 // copy pattern to buffer978 // copy pattern to buffer
981 979
982 memcpy(editor.patternBuffer, modEntry->patterns[modEntry->currPattern],980 memcpy(editor.patternBuffer, modEntry->patterns[modEntry->currPattern],
983 sizeof (note_t) * (AMIGA_VOICES * MOD_ROWS));981 sizeof (note_t) * (AMIGA_VOICES * MOD_ROWS));
984 }982 }
985 else if (input.keyb.leftCtrlPressed)983 else if (keyb.leftCtrlPressed)
986 {984 {
987 // copy channel commands to buffer985 // copy channel commands to buffer
988 986
@@ -1008,7 +1006,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 19 unmodified lines
1008 }1006 }
1009 else1007 else
1010 {1008 {
1011 if (input.keyb.shiftPressed)1009 if (keyb.shiftPressed)
1012 {1010 {
1013 // paste channel buffer to channel1011 // paste channel buffer to channel
1014 saveUndo();1012 saveUndo();
@@ -1020,7 +1018,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
1020 updateWindowTitle(MOD_IS_MODIFIED);1018 updateWindowTitle(MOD_IS_MODIFIED);
1021 editor.ui.updatePatternData = true;1019 editor.ui.updatePatternData = true;
1022 }1020 }
1023 else if (input.keyb.leftAltPressed)1021 else if (keyb.leftAltPressed)
1024 {1022 {
1025 // paste pattern buffer to pattern1023 // paste pattern buffer to pattern
1026 saveUndo();1024 saveUndo();
@@ -1031,7 +1029,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 4 unmodified lines
1031 updateWindowTitle(MOD_IS_MODIFIED);1029 updateWindowTitle(MOD_IS_MODIFIED);
1032 editor.ui.updatePatternData = true;1030 editor.ui.updatePatternData = true;
1033 }1031 }
1034 else if (input.keyb.leftCtrlPressed)1032 else if (keyb.leftCtrlPressed)
1035 {1033 {
1036 // paste channel commands buffer to channel1034 // paste channel commands buffer to channel
1037 saveUndo();1035 saveUndo();
@@ -1055,14 +1053,14 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 17 unmodified lines
1055 1053
1056 case SDL_SCANCODE_F6:1054 case SDL_SCANCODE_F6:
1057 {1055 {
1058 if (input.keyb.shiftPressed)1056 if (keyb.shiftPressed)
1059 {1057 {
1060 editor.f6Pos = modEntry->currRow;1058 editor.f6Pos = modEntry->currRow;
1061 displayMsg("POSITION SET");1059 displayMsg("POSITION SET");
1062 }1060 }
1063 else1061 else
1064 {1062 {
1065 if (input.keyb.leftAltPressed)1063 if (keyb.leftAltPressed)
1066 {1064 {
1067 editor.playMode = PLAY_MODE_PATTERN;1065 editor.playMode = PLAY_MODE_PATTERN;
1068 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f6Pos);1066 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f6Pos);
@@ -1071,7 +1069,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
1071 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);1069 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
1072 statusAllRight();1070 statusAllRight();
1073 }1071 }
1074 else if (input.keyb.leftCtrlPressed)1072 else if (keyb.leftCtrlPressed)
1075 {1073 {
1076 if (!editor.ui.samplerScreenShown)1074 if (!editor.ui.samplerScreenShown)
1077 {1075 {
@@ -1083,7 +1081,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
1083 statusAllRight();1081 statusAllRight();
1084 }1082 }
1085 }1083 }
1086 else if (input.keyb.leftAmigaPressed)1084 else if (keyb.leftAmigaPressed)
1087 {1085 {
1088 editor.playMode = PLAY_MODE_NORMAL;1086 editor.playMode = PLAY_MODE_NORMAL;
1089 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f6Pos);1087 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f6Pos);
@@ -1102,14 +1100,14 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1102 1100
1103 case SDL_SCANCODE_F7:1101 case SDL_SCANCODE_F7:
1104 {1102 {
1105 if (input.keyb.shiftPressed)1103 if (keyb.shiftPressed)
1106 {1104 {
1107 editor.f7Pos = modEntry->currRow;1105 editor.f7Pos = modEntry->currRow;
1108 displayMsg("POSITION SET");1106 displayMsg("POSITION SET");
1109 }1107 }
1110 else1108 else
1111 {1109 {
1112 if (input.keyb.leftAltPressed)1110 if (keyb.leftAltPressed)
1113 {1111 {
1114 editor.playMode = PLAY_MODE_PATTERN;1112 editor.playMode = PLAY_MODE_PATTERN;
1115 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f7Pos);1113 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f7Pos);
@@ -1118,7 +1116,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
1118 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);1116 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
1119 statusAllRight();1117 statusAllRight();
1120 }1118 }
1121 else if (input.keyb.leftCtrlPressed)1119 else if (keyb.leftCtrlPressed)
1122 {1120 {
1123 if (!editor.ui.samplerScreenShown)1121 if (!editor.ui.samplerScreenShown)
1124 {1122 {
@@ -1130,7 +1128,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
1130 statusAllRight();1128 statusAllRight();
1131 }1129 }
1132 }1130 }
1133 else if (input.keyb.leftAmigaPressed)1131 else if (keyb.leftAmigaPressed)
1134 {1132 {
1135 editor.playMode = PLAY_MODE_NORMAL;1133 editor.playMode = PLAY_MODE_NORMAL;
1136 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f7Pos);1134 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f7Pos);
@@ -1149,14 +1147,14 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1149 1147
1150 case SDL_SCANCODE_F8:1148 case SDL_SCANCODE_F8:
1151 {1149 {
1152 if (input.keyb.shiftPressed)1150 if (keyb.shiftPressed)
1153 {1151 {
1154 editor.f8Pos = modEntry->currRow;1152 editor.f8Pos = modEntry->currRow;
1155 displayMsg("POSITION SET");1153 displayMsg("POSITION SET");
1156 }1154 }
1157 else1155 else
1158 {1156 {
1159 if (input.keyb.leftAltPressed)1157 if (keyb.leftAltPressed)
1160 {1158 {
1161 editor.playMode = PLAY_MODE_PATTERN;1159 editor.playMode = PLAY_MODE_PATTERN;
1162 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f8Pos);1160 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f8Pos);
@@ -1165,7 +1163,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
1165 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);1163 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
1166 statusAllRight();1164 statusAllRight();
1167 }1165 }
1168 else if (input.keyb.leftCtrlPressed)1166 else if (keyb.leftCtrlPressed)
1169 {1167 {
1170 if (!editor.ui.samplerScreenShown)1168 if (!editor.ui.samplerScreenShown)
1171 {1169 {
@@ -1177,7 +1175,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
1177 statusAllRight();1175 statusAllRight();
1178 }1176 }
1179 }1177 }
1180 else if (input.keyb.leftAmigaPressed)1178 else if (keyb.leftAmigaPressed)
1181 {1179 {
1182 editor.playMode = PLAY_MODE_NORMAL;1180 editor.playMode = PLAY_MODE_NORMAL;
1183 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f8Pos);1181 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f8Pos);
@@ -1196,14 +1194,14 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1196 1194
1197 case SDL_SCANCODE_F9:1195 case SDL_SCANCODE_F9:
1198 {1196 {
1199 if (input.keyb.shiftPressed)1197 if (keyb.shiftPressed)
1200 {1198 {
1201 editor.f9Pos = modEntry->currRow;1199 editor.f9Pos = modEntry->currRow;
1202 displayMsg("POSITION SET");1200 displayMsg("POSITION SET");
1203 }1201 }
1204 else1202 else
1205 {1203 {
1206 if (input.keyb.leftAltPressed)1204 if (keyb.leftAltPressed)
1207 {1205 {
1208 editor.playMode = PLAY_MODE_PATTERN;1206 editor.playMode = PLAY_MODE_PATTERN;
1209 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f9Pos);1207 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f9Pos);
@@ -1212,7 +1210,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
1212 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);1210 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
1213 statusAllRight();1211 statusAllRight();
1214 }1212 }
1215 else if (input.keyb.leftCtrlPressed)1213 else if (keyb.leftCtrlPressed)
1216 {1214 {
1217 if (!editor.ui.samplerScreenShown)1215 if (!editor.ui.samplerScreenShown)
1218 {1216 {
@@ -1224,7 +1222,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
1224 statusAllRight();1222 statusAllRight();
1225 }1223 }
1226 }1224 }
1227 else if (input.keyb.leftAmigaPressed)1225 else if (keyb.leftAmigaPressed)
1228 {1226 {
1229 editor.playMode = PLAY_MODE_NORMAL;1227 editor.playMode = PLAY_MODE_NORMAL;
1230 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f9Pos);1228 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f9Pos);
@@ -1243,14 +1241,14 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1243 1241
1244 case SDL_SCANCODE_F10:1242 case SDL_SCANCODE_F10:
1245 {1243 {
1246 if (input.keyb.shiftPressed)1244 if (keyb.shiftPressed)
1247 {1245 {
1248 editor.f10Pos = modEntry->currRow;1246 editor.f10Pos = modEntry->currRow;
1249 displayMsg("POSITION SET");1247 displayMsg("POSITION SET");
1250 }1248 }
1251 else1249 else
1252 {1250 {
1253 if (input.keyb.leftAltPressed)1251 if (keyb.leftAltPressed)
1254 {1252 {
1255 editor.playMode = PLAY_MODE_PATTERN;1253 editor.playMode = PLAY_MODE_PATTERN;
1256 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f10Pos);1254 modPlay(modEntry->currPattern, DONT_SET_ORDER, editor.f10Pos);
@@ -1259,7 +1257,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
1259 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);1257 pointerSetMode(POINTER_MODE_PLAY, DO_CARRY);
1260 statusAllRight();1258 statusAllRight();
1261 }1259 }
1262 else if (input.keyb.leftCtrlPressed)1260 else if (keyb.leftCtrlPressed)
1263 {1261 {
1264 if (!editor.ui.samplerScreenShown)1262 if (!editor.ui.samplerScreenShown)
1265 {1263 {
@@ -1271,7 +1269,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
1271 statusAllRight();1269 statusAllRight();
1272 }1270 }
1273 }1271 }
1274 else if (input.keyb.leftAmigaPressed)1272 else if (keyb.leftAmigaPressed)
1275 {1273 {
1276 editor.playMode = PLAY_MODE_NORMAL;1274 editor.playMode = PLAY_MODE_NORMAL;
1277 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f10Pos);1275 modPlay(DONT_SET_PATTERN, modEntry->currOrder, editor.f10Pos);
@@ -1290,17 +1288,17 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1290 1288
1291 case SDL_SCANCODE_F11:1289 case SDL_SCANCODE_F11:
1292 {1290 {
1293 if (input.keyb.leftAltPressed)1291 if (keyb.leftAltPressed)
1294 {1292 {
1295 ptConfig.realVuMeters ^= 1;1293 config.realVuMeters ^= 1;
1296 displayMsg(ptConfig.realVuMeters ? "VU-METERS: REAL" : "VU-METERS: FAKE");1294 displayMsg(config.realVuMeters ? "VU-METERS: REAL" : "VU-METERS: FAKE");
1297 }1295 }
1298 }1296 }
1299 break;1297 break;
1300 1298
1301 case SDL_SCANCODE_TAB:1299 case SDL_SCANCODE_TAB:
1302 {1300 {
1303 if (input.keyb.shiftPressed)1301 if (keyb.shiftPressed)
1304 movePatCurPrevCh();1302 movePatCurPrevCh();
1305 else1303 else
1306 movePatCurNextCh();1304 movePatCurNextCh();
@@ -1309,13 +1307,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
1309 1307
1310 case SDL_SCANCODE_0:1308 case SDL_SCANCODE_0:
1311 {1309 {
1312 if (input.keyb.leftCtrlPressed)1310 if (keyb.leftCtrlPressed)
1313 {1311 {
1314 editor.editMoveAdd = 0;1312 editor.editMoveAdd = 0;
1315 displayMsg("EDITSKIP = 0");1313 displayMsg("EDITSKIP = 0");
1316 editor.ui.updateTrackerFlags = true;1314 editor.ui.updateTrackerFlags = true;
1317 }1315 }
1318 else if (input.keyb.shiftPressed)1316 else if (keyb.shiftPressed)
1319 {1317 {
1320 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];1318 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
1321 editor.effectMacros[9] = (noteSrc->command << 8) | noteSrc->param;1319 editor.effectMacros[9] = (noteSrc->command << 8) | noteSrc->param;
@@ -1330,23 +1328,23 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
1330 1328
1331 case SDL_SCANCODE_1:1329 case SDL_SCANCODE_1:
1332 {1330 {
1333 if (input.keyb.leftAmigaPressed)1331 if (keyb.leftAmigaPressed)
1334 {1332 {
1335 trackNoteUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1);1333 trackNoteUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
1336 }1334 }
1337 else if (input.keyb.leftCtrlPressed)1335 else if (keyb.leftCtrlPressed)
1338 {1336 {
1339 editor.editMoveAdd = 1;1337 editor.editMoveAdd = 1;
1340 displayMsg("EDITSKIP = 1");1338 displayMsg("EDITSKIP = 1");
1341 editor.ui.updateTrackerFlags = true;1339 editor.ui.updateTrackerFlags = true;
1342 }1340 }
1343 else if (input.keyb.shiftPressed)1341 else if (keyb.shiftPressed)
1344 {1342 {
1345 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];1343 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
1346 editor.effectMacros[0] = (noteSrc->command << 8) | noteSrc->param;1344 editor.effectMacros[0] = (noteSrc->command << 8) | noteSrc->param;
1347 displayMsg("COMMAND STORED!");1345 displayMsg("COMMAND STORED!");
1348 }1346 }
1349 else if (editor.currMode == MODE_IDLE && input.keyb.leftAltPressed)1347 else if (editor.currMode == MODE_IDLE && keyb.leftAltPressed)
1350 {1348 {
1351 incMulti(0);1349 incMulti(0);
1352 }1350 }
@@ -1359,23 +1357,23 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
1359 1357
1360 case SDL_SCANCODE_2:1358 case SDL_SCANCODE_2:
1361 {1359 {
1362 if (input.keyb.leftAmigaPressed)1360 if (keyb.leftAmigaPressed)
1363 {1361 {
1364 pattNoteUp(TRANSPOSE_ALL);1362 pattNoteUp(TRANSPOSE_ALL);
1365 }1363 }
1366 else if (input.keyb.leftCtrlPressed)1364 else if (keyb.leftCtrlPressed)
1367 {1365 {
1368 editor.editMoveAdd = 2;1366 editor.editMoveAdd = 2;
1369 displayMsg("EDITSKIP = 2");1367 displayMsg("EDITSKIP = 2");
1370 editor.ui.updateTrackerFlags = true;1368 editor.ui.updateTrackerFlags = true;
1371 }1369 }
1372 else if (input.keyb.shiftPressed)1370 else if (keyb.shiftPressed)
1373 {1371 {
1374 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];1372 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
1375 editor.effectMacros[1] = (noteSrc->command << 8) | noteSrc->param;1373 editor.effectMacros[1] = (noteSrc->command << 8) | noteSrc->param;
1376 displayMsg("COMMAND STORED!");1374 displayMsg("COMMAND STORED!");
1377 }1375 }
1378 else if (editor.currMode == MODE_IDLE && input.keyb.leftAltPressed)1376 else if (editor.currMode == MODE_IDLE && keyb.leftAltPressed)
1379 {1377 {
1380 incMulti(1);1378 incMulti(1);
1381 }1379 }
@@ -1388,23 +1386,23 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
1388 1386
1389 case SDL_SCANCODE_3:1387 case SDL_SCANCODE_3:
1390 {1388 {
1391 if (input.keyb.leftAmigaPressed)1389 if (keyb.leftAmigaPressed)
1392 {1390 {
1393 trackNoteUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1);1391 trackNoteUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
1394 }1392 }
1395 else if (input.keyb.leftCtrlPressed)1393 else if (keyb.leftCtrlPressed)
1396 {1394 {
1397 editor.editMoveAdd = 3;1395 editor.editMoveAdd = 3;
1398 displayMsg("EDITSKIP = 3");1396 displayMsg("EDITSKIP = 3");
1399 editor.ui.updateTrackerFlags = true;1397 editor.ui.updateTrackerFlags = true;
1400 }1398 }
1401 else if (input.keyb.shiftPressed)1399 else if (keyb.shiftPressed)
1402 {1400 {
1403 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];1401 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
1404 editor.effectMacros[2] = (noteSrc->command << 8) | noteSrc->param;1402 editor.effectMacros[2] = (noteSrc->command << 8) | noteSrc->param;
1405 displayMsg("COMMAND STORED!");1403 displayMsg("COMMAND STORED!");
1406 }1404 }
1407 else if (editor.currMode == MODE_IDLE && input.keyb.leftAltPressed)1405 else if (editor.currMode == MODE_IDLE && keyb.leftAltPressed)
1408 {1406 {
1409 incMulti(2);1407 incMulti(2);
1410 }1408 }
@@ -1417,23 +1415,23 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
1417 1415
1418 case SDL_SCANCODE_4:1416 case SDL_SCANCODE_4:
1419 {1417 {
1420 if (input.keyb.leftAmigaPressed)1418 if (keyb.leftAmigaPressed)
1421 {1419 {
1422 pattNoteUp(TRANSPOSE_ALL);1420 pattNoteUp(TRANSPOSE_ALL);
1423 }1421 }
1424 else if (input.keyb.leftCtrlPressed)1422 else if (keyb.leftCtrlPressed)
1425 {1423 {
1426 editor.editMoveAdd = 4;1424 editor.editMoveAdd = 4;
1427 displayMsg("EDITSKIP = 4");1425 displayMsg("EDITSKIP = 4");
1428 editor.ui.updateTrackerFlags = true;1426 editor.ui.updateTrackerFlags = true;
1429 }1427 }
1430 else if (input.keyb.shiftPressed)1428 else if (keyb.shiftPressed)
1431 {1429 {
1432 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];1430 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
1433 editor.effectMacros[3] = (noteSrc->command << 8) | noteSrc->param;1431 editor.effectMacros[3] = (noteSrc->command << 8) | noteSrc->param;
1434 displayMsg("COMMAND STORED!");1432 displayMsg("COMMAND STORED!");
1435 }1433 }
1436 else if (editor.currMode == MODE_IDLE && input.keyb.leftAltPressed)1434 else if (editor.currMode == MODE_IDLE && keyb.leftAltPressed)
1437 {1435 {
1438 incMulti(3);1436 incMulti(3);
1439 }1437 }
@@ -1446,13 +1444,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
1446 1444
1447 case SDL_SCANCODE_5:1445 case SDL_SCANCODE_5:
1448 {1446 {
1449 if (input.keyb.leftCtrlPressed)1447 if (keyb.leftCtrlPressed)
1450 {1448 {
1451 editor.editMoveAdd = 5;1449 editor.editMoveAdd = 5;
1452 displayMsg("EDITSKIP = 5");1450 displayMsg("EDITSKIP = 5");
1453 editor.ui.updateTrackerFlags = true;1451 editor.ui.updateTrackerFlags = true;
1454 }1452 }
1455 else if (input.keyb.shiftPressed)1453 else if (keyb.shiftPressed)
1456 {1454 {
1457 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];1455 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
1458 editor.effectMacros[4] = (noteSrc->command << 8) | noteSrc->param;1456 editor.effectMacros[4] = (noteSrc->command << 8) | noteSrc->param;
@@ -1467,13 +1465,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
1467 1465
1468 case SDL_SCANCODE_6:1466 case SDL_SCANCODE_6:
1469 {1467 {
1470 if (input.keyb.leftCtrlPressed)1468 if (keyb.leftCtrlPressed)
1471 {1469 {
1472 editor.editMoveAdd = 6;1470 editor.editMoveAdd = 6;
1473 displayMsg("EDITSKIP = 6");1471 displayMsg("EDITSKIP = 6");
1474 editor.ui.updateTrackerFlags = true;1472 editor.ui.updateTrackerFlags = true;
1475 }1473 }
1476 else if (input.keyb.shiftPressed)1474 else if (keyb.shiftPressed)
1477 {1475 {
1478 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];1476 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
1479 editor.effectMacros[5] = (noteSrc->command << 8) | noteSrc->param;1477 editor.effectMacros[5] = (noteSrc->command << 8) | noteSrc->param;
@@ -1488,13 +1486,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
1488 1486
1489 case SDL_SCANCODE_7:1487 case SDL_SCANCODE_7:
1490 {1488 {
1491 if (input.keyb.leftCtrlPressed)1489 if (keyb.leftCtrlPressed)
1492 {1490 {
1493 editor.editMoveAdd = 7;1491 editor.editMoveAdd = 7;
1494 displayMsg("EDITSKIP = 7");1492 displayMsg("EDITSKIP = 7");
1495 editor.ui.updateTrackerFlags = true;1493 editor.ui.updateTrackerFlags = true;
1496 }1494 }
1497 else if (input.keyb.shiftPressed)1495 else if (keyb.shiftPressed)
1498 {1496 {
1499 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];1497 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
1500 editor.effectMacros[6] = (noteSrc->command << 8) | noteSrc->param;1498 editor.effectMacros[6] = (noteSrc->command << 8) | noteSrc->param;
@@ -1509,13 +1507,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
1509 1507
1510 case SDL_SCANCODE_8:1508 case SDL_SCANCODE_8:
1511 {1509 {
1512 if (input.keyb.leftCtrlPressed)1510 if (keyb.leftCtrlPressed)
1513 {1511 {
1514 editor.editMoveAdd = 8;1512 editor.editMoveAdd = 8;
1515 displayMsg("EDITSKIP = 8");1513 displayMsg("EDITSKIP = 8");
1516 editor.ui.updateTrackerFlags = true;1514 editor.ui.updateTrackerFlags = true;
1517 }1515 }
1518 else if (input.keyb.shiftPressed)1516 else if (keyb.shiftPressed)
1519 {1517 {
1520 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];1518 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
1521 editor.effectMacros[7] = (noteSrc->command << 8) | noteSrc->param;1519 editor.effectMacros[7] = (noteSrc->command << 8) | noteSrc->param;
@@ -1530,13 +1528,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
1530 1528
1531 case SDL_SCANCODE_9:1529 case SDL_SCANCODE_9:
1532 {1530 {
1533 if (input.keyb.leftCtrlPressed)1531 if (keyb.leftCtrlPressed)
1534 {1532 {
1535 editor.editMoveAdd = 9;1533 editor.editMoveAdd = 9;
1536 displayMsg("EDITSKIP = 9");1534 displayMsg("EDITSKIP = 9");
1537 editor.ui.updateTrackerFlags = true;1535 editor.ui.updateTrackerFlags = true;
1538 }1536 }
1539 else if (input.keyb.shiftPressed)1537 else if (keyb.shiftPressed)
1540 {1538 {
1541 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];1539 noteSrc = &modEntry->patterns[modEntry->currPattern][(modEntry->currRow * AMIGA_VOICES) + editor.cursor.channel];
1542 editor.effectMacros[8] = (noteSrc->command << 8) | noteSrc->param;1540 editor.effectMacros[8] = (noteSrc->command << 8) | noteSrc->param;
@@ -1562,7 +1560,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 19 unmodified lines
1562 editor.currSample = editor.keypadSampleOffset + 12;1560 editor.currSample = editor.keypadSampleOffset + 12;
1563 1561
1564 updateCurrSample();1562 updateCurrSample();
1565 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1563 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1566 {1564 {
1567 editor.ui.changingDrumPadNote = true;1565 editor.ui.changingDrumPadNote = true;
1568 setStatusMessage("SELECT NOTE", NO_CARRY);1566 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1581,7 +1579,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1581 editor.currSample = editor.keypadSampleOffset + 13;1579 editor.currSample = editor.keypadSampleOffset + 13;
1582 1580
1583 updateCurrSample();1581 updateCurrSample();
1584 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1582 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1585 {1583 {
1586 editor.ui.changingDrumPadNote = true;1584 editor.ui.changingDrumPadNote = true;
1587 setStatusMessage("SELECT NOTE", NO_CARRY);1585 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1600,7 +1598,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1600 editor.currSample = editor.keypadSampleOffset + 14;1598 editor.currSample = editor.keypadSampleOffset + 14;
1601 1599
1602 updateCurrSample();1600 updateCurrSample();
1603 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1601 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1604 {1602 {
1605 editor.ui.changingDrumPadNote = true;1603 editor.ui.changingDrumPadNote = true;
1606 setStatusMessage("SELECT NOTE", NO_CARRY);1604 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1619,7 +1617,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1619 editor.currSample = editor.keypadSampleOffset + 8;1617 editor.currSample = editor.keypadSampleOffset + 8;
1620 1618
1621 updateCurrSample();1619 updateCurrSample();
1622 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1620 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1623 {1621 {
1624 editor.ui.changingDrumPadNote = true;1622 editor.ui.changingDrumPadNote = true;
1625 setStatusMessage("SELECT NOTE", NO_CARRY);1623 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1638,7 +1636,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1638 editor.currSample = editor.keypadSampleOffset + 9;1636 editor.currSample = editor.keypadSampleOffset + 9;
1639 1637
1640 updateCurrSample();1638 updateCurrSample();
1641 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1639 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1642 {1640 {
1643 editor.ui.changingDrumPadNote = true;1641 editor.ui.changingDrumPadNote = true;
1644 setStatusMessage("SELECT NOTE", NO_CARRY);1642 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1657,7 +1655,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1657 editor.currSample = editor.keypadSampleOffset + 10;1655 editor.currSample = editor.keypadSampleOffset + 10;
1658 1656
1659 updateCurrSample();1657 updateCurrSample();
1660 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1658 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1661 {1659 {
1662 editor.ui.changingDrumPadNote = true;1660 editor.ui.changingDrumPadNote = true;
1663 setStatusMessage("SELECT NOTE", NO_CARRY);1661 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1676,7 +1674,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1676 editor.currSample = editor.keypadSampleOffset + 4;1674 editor.currSample = editor.keypadSampleOffset + 4;
1677 1675
1678 updateCurrSample();1676 updateCurrSample();
1679 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1677 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1680 {1678 {
1681 editor.ui.changingDrumPadNote = true;1679 editor.ui.changingDrumPadNote = true;
1682 setStatusMessage("SELECT NOTE", NO_CARRY);1680 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1695,7 +1693,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1695 editor.currSample = editor.keypadSampleOffset + 5;1693 editor.currSample = editor.keypadSampleOffset + 5;
1696 1694
1697 updateCurrSample();1695 updateCurrSample();
1698 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1696 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1699 {1697 {
1700 editor.ui.changingDrumPadNote = true;1698 editor.ui.changingDrumPadNote = true;
1701 setStatusMessage("SELECT NOTE", NO_CARRY);1699 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1714,7 +1712,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1714 editor.currSample = editor.keypadSampleOffset + 6;1712 editor.currSample = editor.keypadSampleOffset + 6;
1715 1713
1716 updateCurrSample();1714 updateCurrSample();
1717 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1715 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1718 {1716 {
1719 editor.ui.changingDrumPadNote = true;1717 editor.ui.changingDrumPadNote = true;
1720 setStatusMessage("SELECT NOTE", NO_CARRY);1718 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1757,7 +1755,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 36 unmodified lines
1757 editor.currSample--;1755 editor.currSample--;
1758 1756
1759 updateCurrSample();1757 updateCurrSample();
1760 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1758 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1761 {1759 {
1762 editor.ui.changingDrumPadNote = true;1760 editor.ui.changingDrumPadNote = true;
1763 setStatusMessage("SELECT NOTE", NO_CARRY);1761 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1782,7 +1780,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 18 unmodified lines
1782 editor.currSample = editor.keypadSampleOffset + (0x08 - 1);1780 editor.currSample = editor.keypadSampleOffset + (0x08 - 1);
1783 1781
1784 updateCurrSample();1782 updateCurrSample();
1785 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1783 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1786 displayErrorMsg("INVALID PAD KEY !");1784 displayErrorMsg("INVALID PAD KEY !");
1787 1785
1788 editor.keypadToggle8CFlag ^= 1;1786 editor.keypadToggle8CFlag ^= 1;
@@ -1795,7 +1793,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
1795 editor.currSample = editor.keypadSampleOffset + 3;1793 editor.currSample = editor.keypadSampleOffset + 3;
1796 1794
1797 updateCurrSample();1795 updateCurrSample();
1798 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1796 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1799 {1797 {
1800 editor.ui.changingDrumPadNote = true;1798 editor.ui.changingDrumPadNote = true;
1801 setStatusMessage("SELECT NOTE", NO_CARRY);1799 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1814,7 +1812,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1814 editor.currSample = editor.keypadSampleOffset + 2;1812 editor.currSample = editor.keypadSampleOffset + 2;
1815 1813
1816 updateCurrSample();1814 updateCurrSample();
1817 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1815 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1818 {1816 {
1819 editor.ui.changingDrumPadNote = true;1817 editor.ui.changingDrumPadNote = true;
1820 setStatusMessage("SELECT NOTE", NO_CARRY);1818 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1833,7 +1831,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1833 editor.currSample = editor.keypadSampleOffset + 1;1831 editor.currSample = editor.keypadSampleOffset + 1;
1834 1832
1835 updateCurrSample();1833 updateCurrSample();
1836 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1834 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1837 {1835 {
1838 editor.ui.changingDrumPadNote = true;1836 editor.ui.changingDrumPadNote = true;
1839 setStatusMessage("SELECT NOTE", NO_CARRY);1837 setStatusMessage("SELECT NOTE", NO_CARRY);
@@ -1852,7 +1850,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
1852 editor.currSample = editor.keypadSampleOffset + 0;1850 editor.currSample = editor.keypadSampleOffset + 0;
1853 1851
1854 updateCurrSample();1852 updateCurrSample();
1855 if (input.keyb.leftAltPressed && editor.pNoteFlag > 0)1853 if (keyb.leftAltPressed && editor.pNoteFlag > 0)
1856 {1854 {
1857 editor.ui.changingDrumPadNote = true;1855 editor.ui.changingDrumPadNote = true;
1858 1856
@@ -1879,15 +1877,15 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 20 unmodified lines
1879 1877
1880 case SDL_SCANCODE_DOWN:1878 case SDL_SCANCODE_DOWN:
1881 {1879 {
1882 input.keyb.delayKey = false;1880 keyb.delayKey = false;
1883 input.keyb.repeatKey = false;1881 keyb.repeatKey = false;
1884 1882
1885 if (editor.ui.diskOpScreenShown)1883 if (editor.ui.diskOpScreenShown)
1886 {1884 {
1887 if (editor.diskop.numEntries > DISKOP_LINES)1885 if (editor.diskop.numEntries > DISKOP_LINES)
1888 {1886 {
1889 editor.diskop.scrollOffset++;1887 editor.diskop.scrollOffset++;
1890 if (input.mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN1888 if (mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN
1891 editor.diskop.scrollOffset += 3;1889 editor.diskop.scrollOffset += 3;
1892 1890
1893 if (editor.diskop.scrollOffset > editor.diskop.numEntries-DISKOP_LINES)1891 if (editor.diskop.scrollOffset > editor.diskop.numEntries-DISKOP_LINES)
@@ -1896,11 +1894,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
1896 editor.ui.updateDiskOpFileList = true;1894 editor.ui.updateDiskOpFileList = true;
1897 }1895 }
1898 1896
1899 if (!input.keyb.repeatKey)1897 if (!keyb.repeatKey)
1900 input.keyb.delayCounter = 0;1898 keyb.delayCounter = 0;
1901 1899
1902 input.keyb.repeatKey = true;1900 keyb.repeatKey = true;
1903 input.keyb.delayKey = false;1901 keyb.delayKey = false;
1904 }1902 }
1905 else if (editor.ui.posEdScreenShown)1903 else if (editor.ui.posEdScreenShown)
1906 {1904 {
@@ -1913,31 +1911,31 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
1913 editor.ui.updatePosEd = true;1911 editor.ui.updatePosEd = true;
1914 }1912 }
1915 1913
1916 if (!input.keyb.repeatKey)1914 if (!keyb.repeatKey)
1917 input.keyb.delayCounter = 0;1915 keyb.delayCounter = 0;
1918 1916
1919 input.keyb.repeatKey = true;1917 keyb.repeatKey = true;
1920 input.keyb.delayKey = true;1918 keyb.delayKey = true;
1921 }1919 }
1922 else if (!editor.ui.samplerScreenShown)1920 else if (!editor.ui.samplerScreenShown)
1923 {1921 {
1924 if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD)1922 if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD)
1925 modSetPos(DONT_SET_ORDER, (modEntry->currRow + 1) & 0x3F);1923 modSetPos(DONT_SET_ORDER, (modEntry->currRow + 1) & 0x3F);
1926 1924
1927 input.keyb.repeatKey = true;1925 keyb.repeatKey = true;
1928 }1926 }
1929 }1927 }
1930 break;1928 break;
1931 1929
1932 case SDL_SCANCODE_UP:1930 case SDL_SCANCODE_UP:
1933 {1931 {
1934 input.keyb.delayKey = false;1932 keyb.delayKey = false;
1935 input.keyb.repeatKey = false;1933 keyb.repeatKey = false;
1936 1934
1937 if (editor.ui.diskOpScreenShown)1935 if (editor.ui.diskOpScreenShown)
1938 {1936 {
1939 editor.diskop.scrollOffset--;1937 editor.diskop.scrollOffset--;
1940 if (input.mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN1938 if (mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN
1941 editor.diskop.scrollOffset -= 3;1939 editor.diskop.scrollOffset -= 3;
1942 1940
1943 if (editor.diskop.scrollOffset < 0)1941 if (editor.diskop.scrollOffset < 0)
@@ -1945,11 +1943,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 1 unmodified line
1945 1943
1946 editor.ui.updateDiskOpFileList = true;1944 editor.ui.updateDiskOpFileList = true;
1947 1945
1948 if (!input.keyb.repeatKey)1946 if (!keyb.repeatKey)
1949 input.keyb.delayCounter = 0;1947 keyb.delayCounter = 0;
1950 1948
1951 input.keyb.repeatKey = true;1949 keyb.repeatKey = true;
1952 input.keyb.delayKey = false;1950 keyb.delayKey = false;
1953 }1951 }
1954 else if (editor.ui.posEdScreenShown)1952 else if (editor.ui.posEdScreenShown)
1955 {1953 {
@@ -1959,115 +1957,115 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 3 unmodified lines
1959 editor.ui.updatePosEd = true;1957 editor.ui.updatePosEd = true;
1960 }1958 }
1961 1959
1962 if (!input.keyb.repeatKey)1960 if (!keyb.repeatKey)
1963 input.keyb.delayCounter = 0;1961 keyb.delayCounter = 0;
1964 1962
1965 input.keyb.repeatKey = true;1963 keyb.repeatKey = true;
1966 input.keyb.delayKey = true;1964 keyb.delayKey = true;
1967 }1965 }
1968 else if (!editor.ui.samplerScreenShown)1966 else if (!editor.ui.samplerScreenShown)
1969 {1967 {
1970 if ((editor.currMode != MODE_PLAY) && (editor.currMode != MODE_RECORD))1968 if ((editor.currMode != MODE_PLAY) && (editor.currMode != MODE_RECORD))
1971 modSetPos(DONT_SET_ORDER, (modEntry->currRow - 1) & 0x3F);1969 modSetPos(DONT_SET_ORDER, (modEntry->currRow - 1) & 0x3F);
1972 1970
1973 input.keyb.repeatKey = true;1971 keyb.repeatKey = true;
1974 }1972 }
1975 }1973 }
1976 break;1974 break;
1977 1975
1978 case SDL_SCANCODE_LEFT:1976 case SDL_SCANCODE_LEFT:
1979 {1977 {
1980 input.keyb.delayKey = false;1978 keyb.delayKey = false;
1981 input.keyb.repeatKey = false;1979 keyb.repeatKey = false;
1982 1980
1983 if (input.keyb.leftCtrlPressed)1981 if (keyb.leftCtrlPressed)
1984 {1982 {
1985 sampleDownButton();1983 sampleDownButton();
1986 if (editor.repeatKeyFlag)1984 if (editor.repeatKeyFlag)
1987 {1985 {
1988 input.keyb.delayKey = true;1986 keyb.delayKey = true;
1989 input.keyb.repeatKey = true;1987 keyb.repeatKey = true;
1990 }1988 }
1991 }1989 }
1992 else if (input.keyb.shiftPressed)1990 else if (keyb.shiftPressed)
1993 {1991 {
1994 if (modEntry->currOrder > 0)1992 if (modEntry->currOrder > 0)
1995 {1993 {
1996 modSetPos(modEntry->currOrder - 1, DONT_SET_ROW);1994 modSetPos(modEntry->currOrder - 1, DONT_SET_ROW);
1997 if (editor.repeatKeyFlag)1995 if (editor.repeatKeyFlag)
1998 {1996 {
1999 input.keyb.delayKey = true;1997 keyb.delayKey = true;
2000 input.keyb.repeatKey = true;1998 keyb.repeatKey = true;
2001 }1999 }
2002 }2000 }
2003 }2001 }
2004 else if (input.keyb.leftAltPressed)2002 else if (keyb.leftAltPressed)
2005 {2003 {
2006 decPatt();2004 decPatt();
2007 if (editor.repeatKeyFlag)2005 if (editor.repeatKeyFlag)
2008 {2006 {
2009 input.keyb.delayKey = true;2007 keyb.delayKey = true;
2010 input.keyb.repeatKey = true;2008 keyb.repeatKey = true;
2011 }2009 }
2012 }2010 }
2013 else2011 else
2014 {2012 {
2015 movePatCurLeft();2013 movePatCurLeft();
2016 input.keyb.repeatKey = true;2014 keyb.repeatKey = true;
2017 }2015 }
2018 }2016 }
2019 break;2017 break;
2020 2018
2021 case SDL_SCANCODE_RIGHT:2019 case SDL_SCANCODE_RIGHT:
2022 {2020 {
2023 input.keyb.delayKey = false;2021 keyb.delayKey = false;
2024 input.keyb.repeatKey = false;2022 keyb.repeatKey = false;
2025 2023
2026 if (input.keyb.leftCtrlPressed)2024 if (keyb.leftCtrlPressed)
2027 {2025 {
2028 sampleUpButton();2026 sampleUpButton();
2029 if (editor.repeatKeyFlag)2027 if (editor.repeatKeyFlag)
2030 {2028 {
2031 input.keyb.delayKey = true;2029 keyb.delayKey = true;
2032 input.keyb.repeatKey = true;2030 keyb.repeatKey = true;
2033 }2031 }
2034 }2032 }
2035 else if (input.keyb.shiftPressed)2033 else if (keyb.shiftPressed)
2036 {2034 {
2037 if (modEntry->currOrder < 126)2035 if (modEntry->currOrder < 126)
2038 {2036 {
2039 modSetPos(modEntry->currOrder + 1, DONT_SET_ROW);2037 modSetPos(modEntry->currOrder + 1, DONT_SET_ROW);
2040 if (editor.repeatKeyFlag)2038 if (editor.repeatKeyFlag)
2041 {2039 {
2042 input.keyb.delayKey = true;2040 keyb.delayKey = true;
2043 input.keyb.repeatKey = true;2041 keyb.repeatKey = true;
2044 }2042 }
2045 }2043 }
2046 }2044 }
2047 else if (input.keyb.leftAltPressed)2045 else if (keyb.leftAltPressed)
2048 {2046 {
2049 incPatt();2047 incPatt();
2050 if (editor.repeatKeyFlag)2048 if (editor.repeatKeyFlag)
2051 {2049 {
2052 input.keyb.delayKey = true;2050 keyb.delayKey = true;
2053 input.keyb.repeatKey = true;2051 keyb.repeatKey = true;
2054 }2052 }
2055 }2053 }
2056 else2054 else
2057 {2055 {
2058 movePatCurRight();2056 movePatCurRight();
2059 input.keyb.repeatKey = true;2057 keyb.repeatKey = true;
2060 }2058 }
2061 }2059 }
2062 break;2060 break;
2063 2061
2064 case SDL_SCANCODE_A:2062 case SDL_SCANCODE_A:
2065 {2063 {
2066 if (input.keyb.leftAmigaPressed)2064 if (keyb.leftAmigaPressed)
2067 {2065 {
2068 trackOctaUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1);2066 trackOctaUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
2069 }2067 }
2070 else if (input.keyb.leftCtrlPressed)2068 else if (keyb.leftCtrlPressed)
2071 {2069 {
2072 if (editor.ui.samplerScreenShown)2070 if (editor.ui.samplerScreenShown)
2073 {2071 {
@@ -2075,7 +2073,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 1 unmodified line
2075 }2073 }
2076 else2074 else
2077 {2075 {
2078 if (input.keyb.shiftPressed)2076 if (keyb.shiftPressed)
2079 {2077 {
2080 editor.muted[0] = true;2078 editor.muted[0] = true;
2081 editor.muted[1] = true;2079 editor.muted[1] = true;
@@ -2100,7 +2098,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 18 unmodified lines
2100 2098
2101 case SDL_SCANCODE_B:2099 case SDL_SCANCODE_B:
2102 {2100 {
2103 if (input.keyb.leftCtrlPressed)2101 if (keyb.leftCtrlPressed)
2104 {2102 {
2105 // CTRL+B doesn't change the status message back, so do this:2103 // CTRL+B doesn't change the status message back, so do this:
2106 if (editor.ui.introScreenShown)2104 if (editor.ui.introScreenShown)
@@ -2122,7 +2120,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 15 unmodified lines
2122 2120
2123 editor.ui.updateStatusText = true;2121 editor.ui.updateStatusText = true;
2124 }2122 }
2125 else if (input.keyb.leftAltPressed)2123 else if (keyb.leftAltPressed)
2126 {2124 {
2127 s = &modEntry->samples[editor.currSample];2125 s = &modEntry->samples[editor.currSample];
2128 if (s->length == 0)2126 if (s->length == 0)
@@ -2145,11 +2143,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 16 unmodified lines
2145 2143
2146 case SDL_SCANCODE_C:2144 case SDL_SCANCODE_C:
2147 {2145 {
2148 if (input.keyb.leftAmigaPressed)2146 if (keyb.leftAmigaPressed)
2149 {2147 {
2150 trackOctaDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);2148 trackOctaDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
2151 }2149 }
2152 else if (input.keyb.leftCtrlPressed)2150 else if (keyb.leftCtrlPressed)
2153 {2151 {
2154 if (editor.ui.samplerScreenShown)2152 if (editor.ui.samplerScreenShown)
2155 {2153 {
@@ -2184,7 +2182,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 28 unmodified lines
2184 }2182 }
2185 else2183 else
2186 {2184 {
2187 if (input.keyb.leftAltPressed)2185 if (keyb.leftAltPressed)
2188 {2186 {
2189 editor.muted[2] ^= 1; // toggle channel 32187 editor.muted[2] ^= 1; // toggle channel 3
2190 renderMuteButtons();2188 renderMuteButtons();
@@ -2199,17 +2197,17 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
2199 2197
2200 case SDL_SCANCODE_D:2198 case SDL_SCANCODE_D:
2201 {2199 {
2202 if (input.keyb.leftAmigaPressed)2200 if (keyb.leftAmigaPressed)
2203 {2201 {
2204 trackOctaUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1);2202 trackOctaUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
2205 }2203 }
2206 else if (input.keyb.leftCtrlPressed)2204 else if (keyb.leftCtrlPressed)
2207 {2205 {
2208 saveUndo();2206 saveUndo();
2209 }2207 }
2210 else2208 else
2211 {2209 {
2212 if (input.keyb.leftAltPressed)2210 if (keyb.leftAltPressed)
2213 {2211 {
2214 if (!editor.ui.posEdScreenShown)2212 if (!editor.ui.posEdScreenShown)
2215 {2213 {
@@ -2239,11 +2237,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 23 unmodified lines
2239 2237
2240 case SDL_SCANCODE_E:2238 case SDL_SCANCODE_E:
2241 {2239 {
2242 if (input.keyb.leftAmigaPressed)2240 if (keyb.leftAmigaPressed)
2243 {2241 {
2244 trackNoteDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);2242 trackNoteDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
2245 }2243 }
2246 else if (input.keyb.leftAltPressed)2244 else if (keyb.leftAltPressed)
2247 {2245 {
2248 if (!editor.ui.diskOpScreenShown && !editor.ui.posEdScreenShown)2246 if (!editor.ui.diskOpScreenShown && !editor.ui.posEdScreenShown)
2249 {2247 {
@@ -2255,7 +2253,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
2255 renderEditOpScreen();2253 renderEditOpScreen();
2256 }2254 }
2257 }2255 }
2258 else if (input.keyb.leftCtrlPressed)2256 else if (keyb.leftCtrlPressed)
2259 {2257 {
2260 saveUndo();2258 saveUndo();
2261 2259
@@ -2290,17 +2288,17 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 28 unmodified lines
2290 case SDL_SCANCODE_F:2288 case SDL_SCANCODE_F:
2291 {2289 {
2292#ifdef __APPLE__2290#ifdef __APPLE__
2293 if (input.keyb.leftCommandPressed && input.keyb.leftCtrlPressed)2291 if (keyb.leftCommandPressed && keyb.leftCtrlPressed)
2294 {2292 {
2295 toggleFullScreen();2293 toggleFullScreen();
2296 }2294 }
2297 else2295 else
2298#endif2296#endif
2299 if (input.keyb.leftAmigaPressed)2297 if (keyb.leftAmigaPressed)
2300 {2298 {
2301 pattOctaUp(TRANSPOSE_ALL);2299 pattOctaUp(TRANSPOSE_ALL);
2302 }2300 }
2303 else if (input.keyb.leftCtrlPressed)2301 else if (keyb.leftCtrlPressed)
2304 {2302 {
2305 toggleLEDFilter();2303 toggleLEDFilter();
2306 2304
@@ -2309,7 +2307,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
2309 else2307 else
2310 displayMsg("LED FILTER OFF");2308 displayMsg("LED FILTER OFF");
2311 }2309 }
2312 else if (input.keyb.leftAltPressed)2310 else if (keyb.leftAltPressed)
2313 {2311 {
2314 s = &modEntry->samples[editor.currSample];2312 s = &modEntry->samples[editor.currSample];
2315 if (s->length == 0)2313 if (s->length == 0)
@@ -2331,7 +2329,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 15 unmodified lines
2331 2329
2332 case SDL_SCANCODE_G:2330 case SDL_SCANCODE_G:
2333 {2331 {
2334 if (input.keyb.leftCtrlPressed)2332 if (keyb.leftCtrlPressed)
2335 {2333 {
2336 editor.ui.askScreenShown = true;2334 editor.ui.askScreenShown = true;
2337 editor.ui.askScreenType = ASK_BOOST_ALL_SAMPLES;2335 editor.ui.askScreenType = ASK_BOOST_ALL_SAMPLES;
@@ -2339,7 +2337,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 1 unmodified line
2339 setStatusMessage("BOOST ALL SAMPLES", NO_CARRY);2337 setStatusMessage("BOOST ALL SAMPLES", NO_CARRY);
2340 renderAskDialog();2338 renderAskDialog();
2341 }2339 }
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)
2343 {2341 {
2344 editor.recordMode ^= 1;2342 editor.recordMode ^= 1;
2345 if (editor.recordMode == 0)2343 if (editor.recordMode == 0)
@@ -2359,7 +2357,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 13 unmodified lines
2359 2357
2360 case SDL_SCANCODE_H:2358 case SDL_SCANCODE_H:
2361 {2359 {
2362 if (input.keyb.leftCtrlPressed)2360 if (keyb.leftCtrlPressed)
2363 {2361 {
2364 if (!editor.blockMarkFlag)2362 if (!editor.blockMarkFlag)
2365 {2363 {
@@ -2378,7 +2376,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
2378 2376
2379 case SDL_SCANCODE_I:2377 case SDL_SCANCODE_I:
2380 {2378 {
2381 if (input.keyb.leftCtrlPressed)2379 if (keyb.leftCtrlPressed)
2382 {2380 {
2383 if (!editor.blockBufferFlag)2381 if (!editor.blockBufferFlag)
2384 {2382 {
@@ -2408,7 +2406,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 23 unmodified lines
2408 = editor.blockBuffer[editor.buffFromPos + i];2406 = editor.blockBuffer[editor.buffFromPos + i];
2409 }2407 }
2410 2408
2411 if (!input.keyb.shiftPressed)2409 if (!keyb.shiftPressed)
2412 {2410 {
2413 modEntry->currRow += i & 0xFF;2411 modEntry->currRow += i & 0xFF;
2414 if (modEntry->currRow > 63)2412 if (modEntry->currRow > 63)
@@ -2418,7 +2416,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 3 unmodified lines
2418 updateWindowTitle(MOD_IS_MODIFIED);2416 updateWindowTitle(MOD_IS_MODIFIED);
2419 editor.ui.updatePatternData = true;2417 editor.ui.updatePatternData = true;
2420 }2418 }
2421 else if (input.keyb.leftAltPressed)2419 else if (keyb.leftAltPressed)
2422 {2420 {
2423 editor.autoInsFlag ^= 1;2421 editor.autoInsFlag ^= 1;
2424 editor.ui.updateTrackerFlags = true;2422 editor.ui.updateTrackerFlags = true;
@@ -2432,7 +2430,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 7 unmodified lines
2432 2430
2433 case SDL_SCANCODE_J:2431 case SDL_SCANCODE_J:
2434 {2432 {
2435 if (input.keyb.leftCtrlPressed)2433 if (keyb.leftCtrlPressed)
2436 {2434 {
2437 if (!editor.blockBufferFlag)2435 if (!editor.blockBufferFlag)
2438 {2436 {
@@ -2466,7 +2464,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 27 unmodified lines
2466 j++;2464 j++;
2467 }2465 }
2468 2466
2469 if (!input.keyb.shiftPressed)2467 if (!keyb.shiftPressed)
2470 {2468 {
2471 modEntry->currRow += (editor.buffToPos-editor.buffFromPos) + 1;2469 modEntry->currRow += (editor.buffToPos-editor.buffFromPos) + 1;
2472 if (modEntry->currRow > 63)2470 if (modEntry->currRow > 63)
@@ -2485,7 +2483,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
2485 2483
2486 case SDL_SCANCODE_K:2484 case SDL_SCANCODE_K:
2487 {2485 {
2488 if (input.keyb.leftAltPressed)2486 if (keyb.leftAltPressed)
2489 {2487 {
2490 for (i = 0; i < MOD_ROWS; i++)2488 for (i = 0; i < MOD_ROWS; i++)
2491 {2489 {
@@ -2502,12 +2500,12 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 10 unmodified lines
2502 updateWindowTitle(MOD_IS_MODIFIED);2500 updateWindowTitle(MOD_IS_MODIFIED);
2503 editor.ui.updatePatternData = true;2501 editor.ui.updatePatternData = true;
2504 }2502 }
2505 else if (input.keyb.leftCtrlPressed)2503 else if (keyb.leftCtrlPressed)
2506 {2504 {
2507 saveUndo();2505 saveUndo();
2508 2506
2509 i = modEntry->currRow;2507 i = modEntry->currRow;
2510 if (input.keyb.shiftPressed)2508 if (keyb.shiftPressed)
2511 {2509 {
2512 // kill to start2510 // kill to start
2513 while (i >= 0)2511 while (i >= 0)
@@ -2548,7 +2546,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 34 unmodified lines
2548 2546
2549 case SDL_SCANCODE_L:2547 case SDL_SCANCODE_L:
2550 {2548 {
2551 if (input.keyb.leftCtrlPressed)2549 if (keyb.leftCtrlPressed)
2552 {2550 {
2553 if (!editor.blockMarkFlag)2551 if (!editor.blockMarkFlag)
2554 {2552 {
@@ -2567,15 +2565,15 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
2567 2565
2568 case SDL_SCANCODE_M:2566 case SDL_SCANCODE_M:
2569 {2567 {
2570 if (input.keyb.leftCtrlPressed)2568 if (keyb.leftCtrlPressed)
2571 {2569 {
2572 editor.multiFlag ^= 1;2570 editor.multiFlag ^= 1;
2573 editor.ui.updateTrackerFlags = true;2571 editor.ui.updateTrackerFlags = true;
2574 editor.ui.updateKeysText = true;2572 editor.ui.updateKeysText = true;
2575 }2573 }
2576 else if (input.keyb.leftAltPressed)2574 else if (keyb.leftAltPressed)
2577 {2575 {
2578 if (input.keyb.shiftPressed)2576 if (keyb.shiftPressed)
2579 editor.metroChannel = editor.cursor.channel + 1;2577 editor.metroChannel = editor.cursor.channel + 1;
2580 else2578 else
2581 editor.metroFlag ^= 1;2579 editor.metroFlag ^= 1;
@@ -2591,7 +2589,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 9 unmodified lines
2591 2589
2592 case SDL_SCANCODE_N:2590 case SDL_SCANCODE_N:
2593 {2591 {
2594 if (input.keyb.leftCtrlPressed)2592 if (keyb.leftCtrlPressed)
2595 {2593 {
2596 editor.blockMarkFlag = true;2594 editor.blockMarkFlag = true;
2597 modEntry->currRow = editor.blockToPos;2595 modEntry->currRow = editor.blockToPos;
@@ -2605,7 +2603,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 7 unmodified lines
2605 2603
2606 case SDL_SCANCODE_O:2604 case SDL_SCANCODE_O:
2607 {2605 {
2608 if (input.keyb.leftCtrlPressed)2606 if (keyb.leftCtrlPressed)
2609 {2607 {
2610 // fun fact: this function is broken in PT but I fixed it in my clone2608 // fun fact: this function is broken in PT but I fixed it in my clone
2611 2609
@@ -2642,7 +2640,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 30 unmodified lines
2642 2640
2643 case SDL_SCANCODE_P:2641 case SDL_SCANCODE_P:
2644 {2642 {
2645 if (input.keyb.leftCtrlPressed)2643 if (keyb.leftCtrlPressed)
2646 {2644 {
2647 if (!editor.blockBufferFlag)2645 if (!editor.blockBufferFlag)
2648 {2646 {
@@ -2667,7 +2665,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 18 unmodified lines
2667 j++;2665 j++;
2668 }2666 }
2669 2667
2670 if (!input.keyb.shiftPressed)2668 if (!keyb.shiftPressed)
2671 {2669 {
2672 modEntry->currRow += (editor.buffToPos-editor.buffFromPos) + 1;2670 modEntry->currRow += (editor.buffToPos-editor.buffFromPos) + 1;
2673 if (modEntry->currRow > 63)2671 if (modEntry->currRow > 63)
@@ -2677,7 +2675,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 3 unmodified lines
2677 updateWindowTitle(MOD_IS_MODIFIED);2675 updateWindowTitle(MOD_IS_MODIFIED);
2678 editor.ui.updatePatternData = true;2676 editor.ui.updatePatternData = true;
2679 }2677 }
2680 else if (input.keyb.leftAltPressed)2678 else if (keyb.leftAltPressed)
2681 {2679 {
2682 if (!editor.ui.diskOpScreenShown)2680 if (!editor.ui.diskOpScreenShown)
2683 {2681 {
@@ -2702,11 +2700,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 18 unmodified lines
2702 2700
2703 case SDL_SCANCODE_Q:2701 case SDL_SCANCODE_Q:
2704 {2702 {
2705 if (input.keyb.leftAmigaPressed)2703 if (keyb.leftAmigaPressed)
2706 {2704 {
2707 trackNoteDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);2705 trackNoteDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
2708 }2706 }
2709 else if (input.keyb.leftCtrlPressed)2707 else if (keyb.leftCtrlPressed)
2710 {2708 {
2711 editor.muted[0] = false;2709 editor.muted[0] = false;
2712 editor.muted[1] = false;2710 editor.muted[1] = false;
@@ -2714,7 +2712,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 1 unmodified line
2714 editor.muted[3] = false;2712 editor.muted[3] = false;
2715 renderMuteButtons();2713 renderMuteButtons();
2716 }2714 }
2717 else if (input.keyb.leftAltPressed)2715 else if (keyb.leftAltPressed)
2718 {2716 {
2719 editor.ui.askScreenShown = true;2717 editor.ui.askScreenShown = true;
2720 editor.ui.askScreenType = ASK_QUIT;2718 editor.ui.askScreenType = ASK_QUIT;
@@ -2732,11 +2730,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 11 unmodified lines
2732 2730
2733 case SDL_SCANCODE_R:2731 case SDL_SCANCODE_R:
2734 {2732 {
2735 if (input.keyb.leftAmigaPressed)2733 if (keyb.leftAmigaPressed)
2736 {2734 {
2737 pattNoteDown(TRANSPOSE_ALL);2735 pattNoteDown(TRANSPOSE_ALL);
2738 }2736 }
2739 else if (input.keyb.leftCtrlPressed)2737 else if (keyb.leftCtrlPressed)
2740 {2738 {
2741 editor.f6Pos = 0;2739 editor.f6Pos = 0;
2742 editor.f7Pos = 16;2740 editor.f7Pos = 16;
@@ -2746,7 +2744,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 3 unmodified lines
2746 2744
2747 displayMsg("POS RESTORED !");2745 displayMsg("POS RESTORED !");
2748 }2746 }
2749 else if (input.keyb.leftAltPressed)2747 else if (keyb.leftAltPressed)
2750 {2748 {
2751 editor.ui.askScreenShown = true;2749 editor.ui.askScreenShown = true;
2752 editor.ui.askScreenType = ASK_RESAMPLE;2750 editor.ui.askScreenType = ASK_RESAMPLE;
@@ -2763,7 +2761,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 10 unmodified lines
2763 2761
2764 case SDL_SCANCODE_S:2762 case SDL_SCANCODE_S:
2765 {2763 {
2766 if (input.keyb.leftCtrlPressed)2764 if (keyb.leftCtrlPressed)
2767 {2765 {
2768 // if we're in sample load/save mode, set current dir to modules path2766 // if we're in sample load/save mode, set current dir to modules path
2769 if (editor.diskop.mode == DISKOP_MODE_SMP)2767 if (editor.diskop.mode == DISKOP_MODE_SMP)
@@ -2775,11 +2773,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 5 unmodified lines
2775 if (editor.diskop.mode == DISKOP_MODE_SMP)2773 if (editor.diskop.mode == DISKOP_MODE_SMP)
2776 UNICHAR_CHDIR(editor.samplesPathU);2774 UNICHAR_CHDIR(editor.samplesPathU);
2777 }2775 }
2778 else if (input.keyb.leftAmigaPressed)2776 else if (keyb.leftAmigaPressed)
2779 {2777 {
2780 pattOctaUp(TRANSPOSE_ALL);2778 pattOctaUp(TRANSPOSE_ALL);
2781 }2779 }
2782 else if (input.keyb.leftAltPressed)2780 else if (keyb.leftAltPressed)
2783 {2781 {
2784 samplerScreen();2782 samplerScreen();
2785 }2783 }
@@ -2792,13 +2790,13 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
2792 2790
2793 case SDL_SCANCODE_T:2791 case SDL_SCANCODE_T:
2794 {2792 {
2795 if (input.keyb.leftCtrlPressed)2793 if (keyb.leftCtrlPressed)
2796 {2794 {
2797 editor.swapChannelFlag = true;2795 editor.swapChannelFlag = true;
2798 pointerSetMode(POINTER_MODE_MSG1, NO_CARRY);2796 pointerSetMode(POINTER_MODE_MSG1, NO_CARRY);
2799 setStatusMessage("SWAP (1/2/3/4) ?", NO_CARRY);2797 setStatusMessage("SWAP (1/2/3/4) ?", NO_CARRY);
2800 }2798 }
2801 else if (input.keyb.leftAltPressed)2799 else if (keyb.leftAltPressed)
2802 {2800 {
2803 toggleTuningTone();2801 toggleTuningTone();
2804 }2802 }
@@ -2811,7 +2809,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 6 unmodified lines
2811 2809
2812 case SDL_SCANCODE_U:2810 case SDL_SCANCODE_U:
2813 {2811 {
2814 if (input.keyb.leftCtrlPressed)2812 if (keyb.leftCtrlPressed)
2815 undoLastChange();2813 undoLastChange();
2816 else2814 else
2817 handleEditKeys(scancode, EDIT_NORMAL);2815 handleEditKeys(scancode, EDIT_NORMAL);
@@ -2820,11 +2818,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 2 unmodified lines
2820 2818
2821 case SDL_SCANCODE_V:2819 case SDL_SCANCODE_V:
2822 {2820 {
2823 if (input.keyb.leftAmigaPressed)2821 if (keyb.leftAmigaPressed)
2824 {2822 {
2825 pattOctaDown(TRANSPOSE_ALL);2823 pattOctaDown(TRANSPOSE_ALL);
2826 }2824 }
2827 else if (input.keyb.leftCtrlPressed)2825 else if (keyb.leftCtrlPressed)
2828 {2826 {
2829 if (editor.ui.samplerScreenShown)2827 if (editor.ui.samplerScreenShown)
2830 {2828 {
@@ -2840,7 +2838,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 9 unmodified lines
2840 renderAskDialog();2838 renderAskDialog();
2841 }2839 }
2842 }2840 }
2843 else if (input.keyb.leftAltPressed)2841 else if (keyb.leftAltPressed)
2844 {2842 {
2845 editor.muted[3] ^= 1; // toggle channel 42843 editor.muted[3] ^= 1; // toggle channel 4
2846 renderMuteButtons();2844 renderMuteButtons();
@@ -2854,11 +2852,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 7 unmodified lines
2854 2852
2855 case SDL_SCANCODE_W:2853 case SDL_SCANCODE_W:
2856 {2854 {
2857 if (input.keyb.leftAmigaPressed)2855 if (keyb.leftAmigaPressed)
2858 {2856 {
2859 pattNoteDown(TRANSPOSE_ALL);2857 pattNoteDown(TRANSPOSE_ALL);
2860 }2858 }
2861 else if (input.keyb.leftCtrlPressed)2859 else if (keyb.leftCtrlPressed)
2862 {2860 {
2863 // Polyphonize Block2861 // Polyphonize Block
2864 if (!editor.blockBufferFlag)2862 if (!editor.blockBufferFlag)
@@ -2893,7 +2891,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 28 unmodified lines
2893 gotoNextMulti();2891 gotoNextMulti();
2894 }2892 }
2895 2893
2896 if (!input.keyb.shiftPressed)2894 if (!keyb.shiftPressed)
2897 {2895 {
2898 modEntry->currRow += (editor.buffToPos-editor.buffFromPos) + 1;2896 modEntry->currRow += (editor.buffToPos-editor.buffFromPos) + 1;
2899 if (modEntry->currRow > 63)2897 if (modEntry->currRow > 63)
@@ -2912,11 +2910,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 12 unmodified lines
2912 2910
2913 case SDL_SCANCODE_X:2911 case SDL_SCANCODE_X:
2914 {2912 {
2915 if (input.keyb.leftAmigaPressed)2913 if (keyb.leftAmigaPressed)
2916 {2914 {
2917 pattOctaDown(TRANSPOSE_ALL);2915 pattOctaDown(TRANSPOSE_ALL);
2918 }2916 }
2919 else if (input.keyb.leftCtrlPressed)2917 else if (keyb.leftCtrlPressed)
2920 {2918 {
2921 if (editor.ui.samplerScreenShown)2919 if (editor.ui.samplerScreenShown)
2922 {2920 {
@@ -2963,7 +2961,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 40 unmodified lines
2963 }2961 }
2964 else2962 else
2965 {2963 {
2966 if (input.keyb.leftAltPressed)2964 if (keyb.leftAltPressed)
2967 {2965 {
2968 editor.muted[1] ^= 1; // toggle channel 22966 editor.muted[1] ^= 1; // toggle channel 2
2969 renderMuteButtons();2967 renderMuteButtons();
@@ -2978,7 +2976,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 8 unmodified lines
2978 2976
2979 case SDL_SCANCODE_Y:2977 case SDL_SCANCODE_Y:
2980 {2978 {
2981 if (input.keyb.leftCtrlPressed)2979 if (keyb.leftCtrlPressed)
2982 {2980 {
2983 if (!editor.blockMarkFlag)2981 if (!editor.blockMarkFlag)
2984 {2982 {
@@ -3018,7 +3016,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 33 unmodified lines
3018 updateWindowTitle(MOD_IS_MODIFIED);3016 updateWindowTitle(MOD_IS_MODIFIED);
3019 editor.ui.updatePatternData = true;3017 editor.ui.updatePatternData = true;
3020 }3018 }
3021 else if (input.keyb.leftAltPressed)3019 else if (keyb.leftAltPressed)
3022 {3020 {
3023 editor.ui.askScreenShown = true;3021 editor.ui.askScreenShown = true;
3024 editor.ui.askScreenType = ASK_SAVE_ALL_SAMPLES;3022 editor.ui.askScreenType = ASK_SAVE_ALL_SAMPLES;
@@ -3035,11 +3033,11 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 10 unmodified lines
3035 3033
3036 case SDL_SCANCODE_Z:3034 case SDL_SCANCODE_Z:
3037 {3035 {
3038 if (input.keyb.leftAmigaPressed)3036 if (keyb.leftAmigaPressed)
3039 {3037 {
3040 trackOctaDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);3038 trackOctaDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
3041 }3039 }
3042 else if (input.keyb.leftCtrlPressed)3040 else if (keyb.leftCtrlPressed)
3043 {3041 {
3044 if (editor.ui.samplerScreenShown)3042 if (editor.ui.samplerScreenShown)
3045 {3043 {
@@ -3067,7 +3065,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) · 21 unmodified lines
3067 displayMsg("EFX RESTORED !");3065 displayMsg("EFX RESTORED !");
3068 }3066 }
3069 }3067 }
3070 else if (input.keyb.leftAltPressed)3068 else if (keyb.leftAltPressed)
3071 {3069 {
3072 editor.muted[0] ^= 1; // toggle channel 13070 editor.muted[0] ^= 1; // toggle channel 1
3073 renderMuteButtons();3071 renderMuteButtons();
@@ -3145,16 +3143,16 @@ void handleKeyRepeat(SDL_Scancode scancode) · 71 unmodified lines
3145{3143{
3146 uint8_t repeatNum;3144 uint8_t repeatNum;
3147 3145
3148 if (!input.keyb.repeatKey || (editor.ui.clearScreenShown || editor.ui.askScreenShown))3146 if (!keyb.repeatKey || (editor.ui.clearScreenShown || editor.ui.askScreenShown))
3149 {3147 {
3150 input.keyb.repeatFrac = 0;3148 keyb.repeatFrac = 0;
3151 input.keyb.repeatCounter = 0;3149 keyb.repeatCounter = 0;
3152 return;3150 return;
3153 }3151 }
3154 3152
3155 if (input.keyb.delayKey && input.keyb.delayCounter < KEYB_REPEAT_DELAY)3153 if (keyb.delayKey && keyb.delayCounter < KEYB_REPEAT_DELAY)
3156 {3154 {
3157 input.keyb.delayCounter++;3155 keyb.delayCounter++;
3158 return;3156 return;
3159 }3157 }
3160 3158
@@ -3162,9 +3160,9 @@ void handleKeyRepeat(SDL_Scancode scancode) · 1 unmodified line
3162 {3160 {
3163 case SDL_SCANCODE_PAGEUP:3161 case SDL_SCANCODE_PAGEUP:
3164 {3162 {
3165 if (input.keyb.repeatCounter >= 3)3163 if (keyb.repeatCounter >= 3)
3166 {3164 {
3167 input.keyb.repeatCounter = 0;3165 keyb.repeatCounter = 0;
3168 3166
3169 if (editor.ui.posEdScreenShown)3167 if (editor.ui.posEdScreenShown)
3170 {3168 {
@@ -3199,9 +3197,9 @@ void handleKeyRepeat(SDL_Scancode scancode) · 28 unmodified lines
3199 3197
3200 case SDL_SCANCODE_PAGEDOWN:3198 case SDL_SCANCODE_PAGEDOWN:
3201 {3199 {
3202 if (input.keyb.repeatCounter >= 3)3200 if (keyb.repeatCounter >= 3)
3203 {3201 {
3204 input.keyb.repeatCounter = 0;3202 keyb.repeatCounter = 0;
3205 3203
3206 if (editor.ui.posEdScreenShown)3204 if (editor.ui.posEdScreenShown)
3207 {3205 {
@@ -3233,45 +3231,45 @@ void handleKeyRepeat(SDL_Scancode scancode) · 25 unmodified lines
3233 {3231 {
3234 if (editor.ui.editTextFlag)3232 if (editor.ui.editTextFlag)
3235 {3233 {
3236 if (input.keyb.repeatCounter >= 4)3234 if (keyb.repeatCounter >= 4)
3237 {3235 {
3238 input.keyb.repeatCounter = 0;3236 keyb.repeatCounter = 0;
3239 textCharPrevious();3237 textCharPrevious();
3240 }3238 }
3241 }3239 }
3242 else3240 else
3243 {3241 {
3244 if (input.keyb.leftCtrlPressed)3242 if (keyb.leftCtrlPressed)
3245 {3243 {
3246 if (input.keyb.repeatCounter >= 6)3244 if (keyb.repeatCounter >= 6)
3247 {3245 {
3248 input.keyb.repeatCounter = 0;3246 keyb.repeatCounter = 0;
3249 sampleDownButton();3247 sampleDownButton();
3250 }3248 }
3251 }3249 }
3252 else if (input.keyb.shiftPressed)3250 else if (keyb.shiftPressed)
3253 {3251 {
3254 if (input.keyb.repeatCounter >= 6)3252 if (keyb.repeatCounter >= 6)
3255 {3253 {
3256 input.keyb.repeatCounter = 0;3254 keyb.repeatCounter = 0;
3257 if (modEntry->currOrder > 0)3255 if (modEntry->currOrder > 0)
3258 modSetPos(modEntry->currOrder - 1, DONT_SET_ROW);3256 modSetPos(modEntry->currOrder - 1, DONT_SET_ROW);
3259 }3257 }
3260 }3258 }
3261 else if (input.keyb.leftAltPressed)3259 else if (keyb.leftAltPressed)
3262 {3260 {
3263 if (input.keyb.repeatCounter >= 4)3261 if (keyb.repeatCounter >= 4)
3264 {3262 {
3265 input.keyb.repeatCounter = 0;3263 keyb.repeatCounter = 0;
3266 decPatt();3264 decPatt();
3267 }3265 }
3268 }3266 }
3269 else3267 else
3270 {3268 {
3271 if (input.keyb.repeatCounter >= 6)3269 if (keyb.repeatCounter >= 6)
3272 {3270 {
3273 input.keyb.repeatCounter = 0;3271 keyb.repeatCounter = 0;
3274 if (!input.keyb.shiftPressed && !input.keyb.leftAltPressed && !input.keyb.leftCtrlPressed)3272 if (!keyb.shiftPressed && !keyb.leftAltPressed && !keyb.leftCtrlPressed)
3275 movePatCurLeft();3273 movePatCurLeft();
3276 }3274 }
3277 }3275 }
@@ -3283,45 +3281,45 @@ void handleKeyRepeat(SDL_Scancode scancode) · 5 unmodified lines
3283 {3281 {
3284 if (editor.ui.editTextFlag)3282 if (editor.ui.editTextFlag)
3285 {3283 {
3286 if (input.keyb.repeatCounter >= 4)3284 if (keyb.repeatCounter >= 4)
3287 {3285 {
3288 input.keyb.repeatCounter = 0;3286 keyb.repeatCounter = 0;
3289 textCharNext();3287 textCharNext();
3290 }3288 }
3291 }3289 }
3292 else3290 else
3293 {3291 {
3294 if (input.keyb.leftCtrlPressed)3292 if (keyb.leftCtrlPressed)
3295 {3293 {
3296 if (input.keyb.repeatCounter >= 6)3294 if (keyb.repeatCounter >= 6)
3297 {3295 {
3298 input.keyb.repeatCounter = 0;3296 keyb.repeatCounter = 0;
3299 sampleUpButton();3297 sampleUpButton();
3300 }3298 }
3301 }3299 }
3302 else if (input.keyb.shiftPressed)3300 else if (keyb.shiftPressed)
3303 {3301 {
3304 if (input.keyb.repeatCounter >= 6)3302 if (keyb.repeatCounter >= 6)
3305 {3303 {
3306 input.keyb.repeatCounter = 0;3304 keyb.repeatCounter = 0;
3307 if (modEntry->currOrder < 126)3305 if (modEntry->currOrder < 126)
3308 modSetPos(modEntry->currOrder + 1, DONT_SET_ROW);3306 modSetPos(modEntry->currOrder + 1, DONT_SET_ROW);
3309 }3307 }
3310 }3308 }
3311 else if (input.keyb.leftAltPressed)3309 else if (keyb.leftAltPressed)
3312 {3310 {
3313 if (input.keyb.repeatCounter >= 4)3311 if (keyb.repeatCounter >= 4)
3314 {3312 {
3315 input.keyb.repeatCounter = 0;3313 keyb.repeatCounter = 0;
3316 incPatt();3314 incPatt();
3317 }3315 }
3318 }3316 }
3319 else3317 else
3320 {3318 {
3321 if (input.keyb.repeatCounter >= 6)3319 if (keyb.repeatCounter >= 6)
3322 {3320 {
3323 input.keyb.repeatCounter = 0;3321 keyb.repeatCounter = 0;
3324 if (!input.keyb.shiftPressed && !input.keyb.leftAltPressed && !input.keyb.leftCtrlPressed)3322 if (!keyb.shiftPressed && !keyb.leftAltPressed && !keyb.leftCtrlPressed)
3325 movePatCurRight();3323 movePatCurRight();
3326 }3324 }
3327 }3325 }
@@ -3333,12 +3331,12 @@ void handleKeyRepeat(SDL_Scancode scancode) · 5 unmodified lines
3333 {3331 {
3334 if (editor.ui.diskOpScreenShown)3332 if (editor.ui.diskOpScreenShown)
3335 {3333 {
3336 if (input.keyb.repeatCounter >= 1)3334 if (keyb.repeatCounter >= 1)
3337 {3335 {
3338 input.keyb.repeatCounter = 0;3336 keyb.repeatCounter = 0;
3339 3337
3340 editor.diskop.scrollOffset--;3338 editor.diskop.scrollOffset--;
3341 if (input.mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN3339 if (mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN
3342 editor.diskop.scrollOffset -= 3;3340 editor.diskop.scrollOffset -= 3;
3343 3341
3344 if (editor.diskop.scrollOffset < 0)3342 if (editor.diskop.scrollOffset < 0)
@@ -3349,9 +3347,9 @@ void handleKeyRepeat(SDL_Scancode scancode) · 4 unmodified lines
3349 }3347 }
3350 else if (editor.ui.posEdScreenShown)3348 else if (editor.ui.posEdScreenShown)
3351 {3349 {
3352 if (input.keyb.repeatCounter >= 3)3350 if (keyb.repeatCounter >= 3)
3353 {3351 {
3354 input.keyb.repeatCounter = 0;3352 keyb.repeatCounter = 0;
3355 if (modEntry->currOrder > 0)3353 if (modEntry->currOrder > 0)
3356 {3354 {
3357 modSetPos(modEntry->currOrder - 1, DONT_SET_ROW);3355 modSetPos(modEntry->currOrder - 1, DONT_SET_ROW);
@@ -3364,14 +3362,14 @@ void handleKeyRepeat(SDL_Scancode scancode) · 6 unmodified lines
3364 if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD)3362 if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD)
3365 {3363 {
3366 repeatNum = 6;3364 repeatNum = 6;
3367 if (input.keyb.leftAltPressed)3365 if (keyb.leftAltPressed)
3368 repeatNum = 1;3366 repeatNum = 1;
3369 else if (input.keyb.shiftPressed)3367 else if (keyb.shiftPressed)
3370 repeatNum = 3;3368 repeatNum = 3;
3371 3369
3372 if (input.keyb.repeatCounter >= repeatNum)3370 if (keyb.repeatCounter >= repeatNum)
3373 {3371 {
3374 input.keyb.repeatCounter = 0;3372 keyb.repeatCounter = 0;
3375 modSetPos(DONT_SET_ORDER, (modEntry->currRow - 1) & 0x3F);3373 modSetPos(DONT_SET_ORDER, (modEntry->currRow - 1) & 0x3F);
3376 }3374 }
3377 }3375 }
@@ -3383,14 +3381,14 @@ void handleKeyRepeat(SDL_Scancode scancode) · 5 unmodified lines
3383 {3381 {
3384 if (editor.ui.diskOpScreenShown)3382 if (editor.ui.diskOpScreenShown)
3385 {3383 {
3386 if (input.keyb.repeatCounter >= 1)3384 if (keyb.repeatCounter >= 1)
3387 {3385 {
3388 input.keyb.repeatCounter = 0;3386 keyb.repeatCounter = 0;
3389 3387
3390 if (editor.diskop.numEntries > DISKOP_LINES)3388 if (editor.diskop.numEntries > DISKOP_LINES)
3391 {3389 {
3392 editor.diskop.scrollOffset++;3390 editor.diskop.scrollOffset++;
3393 if (input.mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN3391 if (mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN
3394 editor.diskop.scrollOffset += 3;3392 editor.diskop.scrollOffset += 3;
3395 3393
3396 if (editor.diskop.scrollOffset > editor.diskop.numEntries-DISKOP_LINES)3394 if (editor.diskop.scrollOffset > editor.diskop.numEntries-DISKOP_LINES)
@@ -3402,9 +3400,9 @@ void handleKeyRepeat(SDL_Scancode scancode) · 5 unmodified lines
3402 }3400 }
3403 else if (editor.ui.posEdScreenShown)3401 else if (editor.ui.posEdScreenShown)
3404 {3402 {
3405 if (input.keyb.repeatCounter >= 3)3403 if (keyb.repeatCounter >= 3)
3406 {3404 {
3407 input.keyb.repeatCounter = 0;3405 keyb.repeatCounter = 0;
3408 3406
3409 if (modEntry->currOrder != modEntry->head.orderCount-1)3407 if (modEntry->currOrder != modEntry->head.orderCount-1)
3410 {3408 {
@@ -3421,14 +3419,14 @@ void handleKeyRepeat(SDL_Scancode scancode) · 10 unmodified lines
3421 if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD)3419 if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD)
3422 {3420 {
3423 repeatNum = 6;3421 repeatNum = 6;
3424 if (input.keyb.leftAltPressed)3422 if (keyb.leftAltPressed)
3425 repeatNum = 1;3423 repeatNum = 1;
3426 else if (input.keyb.shiftPressed)3424 else if (keyb.shiftPressed)
3427 repeatNum = 3;3425 repeatNum = 3;
3428 3426
3429 if (input.keyb.repeatCounter >= repeatNum)3427 if (keyb.repeatCounter >= repeatNum)
3430 {3428 {
3431 input.keyb.repeatCounter = 0;3429 keyb.repeatCounter = 0;
3432 modSetPos(DONT_SET_ORDER, (modEntry->currRow + 1) & 0x3F);3430 modSetPos(DONT_SET_ORDER, (modEntry->currRow + 1) & 0x3F);
3433 }3431 }
3434 }3432 }
@@ -3441,9 +3439,9 @@ void handleKeyRepeat(SDL_Scancode scancode) · 6 unmodified lines
3441 if (editor.ui.editTextFlag)3439 if (editor.ui.editTextFlag)
3442 {3440 {
3443 // only repeat backspace while editing texts3441 // only repeat backspace while editing texts
3444 if (input.keyb.repeatCounter >= 3)3442 if (keyb.repeatCounter >= 3)
3445 {3443 {
3446 input.keyb.repeatCounter = 0;3444 keyb.repeatCounter = 0;
3447 keyDownHandler(scancode, 0);3445 keyDownHandler(scancode, 0);
3448 }3446 }
3449 }3447 }
@@ -3456,9 +3454,9 @@ void handleKeyRepeat(SDL_Scancode scancode) · 6 unmodified lines
3456 3454
3457 default:3455 default:
3458 {3456 {
3459 if (input.keyb.repeatCounter >= 3)3457 if (keyb.repeatCounter >= 3)
3460 {3458 {
3461 input.keyb.repeatCounter = 0;3459 keyb.repeatCounter = 0;
3462 keyDownHandler(scancode, 0);3460 keyDownHandler(scancode, 0);
3463 }3461 }
3464 }3462 }
@@ -3469,11 +3467,11 @@ void handleKeyRepeat(SDL_Scancode scancode) · 4 unmodified lines
3469 3467
3470 const uint64_t keyRepeatDelta = ((uint64_t)AMIGA_PAL_VBLANK_HZ << 32) / VBLANK_HZ;3468 const uint64_t keyRepeatDelta = ((uint64_t)AMIGA_PAL_VBLANK_HZ << 32) / VBLANK_HZ;
3471 3469
3472 input.keyb.repeatFrac += keyRepeatDelta; // 32.32 fixed-point counter3470 keyb.repeatFrac += keyRepeatDelta; // 32.32 fixed-point counter
3473 if (input.keyb.repeatFrac > 0xFFFFFFFF)3471 if (keyb.repeatFrac > 0xFFFFFFFF)
3474 {3472 {
3475 input.keyb.repeatFrac &= 0xFFFFFFFF;3473 keyb.repeatFrac &= 0xFFFFFFFF;
3476 input.keyb.repeatCounter++;3474 keyb.repeatCounter++;
3477 }3475 }
3478}3476}
3479 3477
@@ -4064,11 +4062,11 @@ void handleTextEditInputChar(char textChar) · 584 unmodified lines
4064 4062
4065 updateTextObject(editor.ui.editObject);4063 updateTextObject(editor.ui.editObject);
4066 4064
4067 if (!input.keyb.repeatKey)4065 if (!keyb.repeatKey)
4068 input.keyb.delayCounter = 0;4066 keyb.delayCounter = 0;
4069 4067
4070 input.keyb.repeatKey = true;4068 keyb.repeatKey = true;
4071 input.keyb.delayKey = true;4069 keyb.delayKey = true;
4072}4070}
4073 4071
4074bool handleTextEditMode(SDL_Scancode scancode)4072bool handleTextEditMode(SDL_Scancode scancode)
@@ -4119,16 +4117,16 @@ bool handleTextEditMode(SDL_Scancode scancode) · 44 unmodified lines
4119 if (editor.ui.editTextFlag)4117 if (editor.ui.editTextFlag)
4120 {4118 {
4121 textCharPrevious();4119 textCharPrevious();
4122 if (!input.keyb.repeatKey)4120 if (!keyb.repeatKey)
4123 input.keyb.delayCounter = 0;4121 keyb.delayCounter = 0;
4124 4122
4125 input.keyb.repeatKey = true;4123 keyb.repeatKey = true;
4126 input.keyb.delayKey = false;4124 keyb.delayKey = false;
4127 }4125 }
4128 else4126 else
4129 {4127 {
4130 input.keyb.delayKey = false;4128 keyb.delayKey = false;
4131 input.keyb.repeatKey = true;4129 keyb.repeatKey = true;
4132 }4130 }
4133 }4131 }
4134 break;4132 break;
@@ -4138,16 +4136,16 @@ bool handleTextEditMode(SDL_Scancode scancode) · 3 unmodified lines
4138 if (editor.ui.editTextFlag)4136 if (editor.ui.editTextFlag)
4139 {4137 {
4140 textCharNext();4138 textCharNext();
4141 if (!input.keyb.repeatKey)4139 if (!keyb.repeatKey)
4142 input.keyb.delayCounter = 0;4140 keyb.delayCounter = 0;
4143 4141
4144 input.keyb.repeatKey = true;4142 keyb.repeatKey = true;
4145 input.keyb.delayKey = false;4143 keyb.delayKey = false;
4146 }4144 }
4147 else4145 else
4148 {4146 {
4149 input.keyb.delayKey = false;4147 keyb.delayKey = false;
4150 input.keyb.repeatKey = true;4148 keyb.repeatKey = true;
4151 }4149 }
4152 }4150 }
4153 break;4151 break;
@@ -4170,11 +4168,11 @@ bool handleTextEditMode(SDL_Scancode scancode) · 16 unmodified lines
4170 if (editor.ui.editObject == PTB_SONGNAME || editor.ui.editObject == PTB_SAMPLENAME)4168 if (editor.ui.editObject == PTB_SONGNAME || editor.ui.editObject == PTB_SAMPLENAME)
4171 *editor.ui.textEndPtr = '\0';4169 *editor.ui.textEndPtr = '\0';
4172 4170
4173 if (!input.keyb.repeatKey)4171 if (!keyb.repeatKey)
4174 input.keyb.delayCounter = 0;4172 keyb.delayCounter = 0;
4175 4173
4176 input.keyb.repeatKey = true;4174 keyb.repeatKey = true;
4177 input.keyb.delayKey = false;4175 keyb.delayKey = false;
4178 4176
4179 updateTextObject(editor.ui.editObject);4177 updateTextObject(editor.ui.editObject);
4180 }4178 }
@@ -4207,11 +4205,11 @@ bool handleTextEditMode(SDL_Scancode scancode) · 26 unmodified lines
4207 updateTextObject(editor.ui.editObject);4205 updateTextObject(editor.ui.editObject);
4208 }4206 }
4209 4207
4210 if (!input.keyb.repeatKey)4208 if (!keyb.repeatKey)
4211 input.keyb.delayCounter = 0;4209 keyb.delayCounter = 0;
4212 4210
4213 input.keyb.repeatKey = true;4211 keyb.repeatKey = true;
4214 input.keyb.delayKey = false;4212 keyb.delayKey = false;
4215 }4213 }
4216 else4214 else
4217 {4215 {
@@ -4223,10 +4221,10 @@ bool handleTextEditMode(SDL_Scancode scancode) · 5 unmodified lines
4223 diskOpSetPath("..", DISKOP_CACHE);4221 diskOpSetPath("..", DISKOP_CACHE);
4224#endif4222#endif
4225 }4223 }
4226 else if (input.keyb.shiftPressed || input.keyb.leftAltPressed || input.keyb.leftCtrlPressed)4224 else if (keyb.shiftPressed || keyb.leftAltPressed || keyb.leftCtrlPressed)
4227 {4225 {
4228 saveUndo();4226 saveUndo();
4229 if (input.keyb.leftAltPressed && !input.keyb.leftCtrlPressed)4227 if (keyb.leftAltPressed && !keyb.leftCtrlPressed)
4230 {4228 {
4231 if (modEntry->currRow > 0)4229 if (modEntry->currRow > 0)
4232 {4230 {
@@ -4259,7 +4257,7 @@ bool handleTextEditMode(SDL_Scancode scancode) · 26 unmodified lines
4259 noteSrc = &modEntry->patterns[modEntry->currPattern][((i + 1) * AMIGA_VOICES) + editor.cursor.channel];4257 noteSrc = &modEntry->patterns[modEntry->currPattern][((i + 1) * AMIGA_VOICES) + editor.cursor.channel];
4260 noteDst = &modEntry->patterns[modEntry->currPattern][(i * AMIGA_VOICES) + editor.cursor.channel];4258 noteDst = &modEntry->patterns[modEntry->currPattern][(i * AMIGA_VOICES) + editor.cursor.channel];
4261 4259
4262 if (input.keyb.leftCtrlPressed)4260 if (keyb.leftCtrlPressed)
4263 {4261 {
4264 noteDst->command = noteSrc->command;4262 noteDst->command = noteSrc->command;
4265 noteDst->param = noteSrc->param;4263 noteDst->param = noteSrc->param;
src/pt2_main.c+48−44
@@ -40,13 +40,6 @@ · 39 unmodified lines
40 40
41module_t *modEntry = NULL; // globalized41module_t *modEntry = NULL; // globalized
42 42
43// accessed by pt_visuals.c
44uint32_t *pixelBuffer = NULL;
45SDL_Window *window = NULL;
46SDL_Renderer *renderer = NULL;
47SDL_Texture *texture = NULL;
48// -----------------------------
49
50static bool backupMadeAfterCrash;43static bool backupMadeAfterCrash;
51 44
52#ifdef _WIN3245#ifdef _WIN32
@@ -73,9 +66,6 @@ static void exceptionHandler(int32_t signal); · 20 unmodified lines
73#endif66#endif
74#endif67#endif
75 68
76extern bool forceMixerOff; // pt_audio.c
77extern uint32_t palette[PALETTE_NUM]; // pt_palette.c
78
79#ifdef _WIN3269#ifdef _WIN32
80static void makeSureDirIsProgramDir(void);70static void makeSureDirIsProgramDir(void);
81static void disableWasapi(void);71static void disableWasapi(void);
@@ -110,9 +100,6 @@ int main(int argc, char *argv[]) · 28 unmodified lines
110 #pragma message("WARNING: The SDL2 dev lib is older than ver 2.0.5. You'll get fullscreen mode issues.")100 #pragma message("WARNING: The SDL2 dev lib is older than ver 2.0.5. You'll get fullscreen mode issues.")
111#endif101#endif
112 102
113 cpu.hasSSE = SDL_HasSSE();
114 cpu.hasSSE2 = SDL_HasSSE2();
115
116 // set up crash handler103 // set up crash handler
117#ifndef _DEBUG104#ifndef _DEBUG
118#ifdef _WIN32105#ifdef _WIN32
@@ -154,14 +141,14 @@ int main(int argc, char *argv[]) · 35 unmodified lines
154#endif141#endif
155 142
156#ifdef _WIN32143#ifdef _WIN32
157 if (!cpu.hasSSE)144 if (!SDL_HasSSE())
158 {145 {
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" \
160 "which is needed for this program to run. Sorry!");147 "which is needed for this program to run. Sorry!");
161 return 0;148 return 0;
162 }149 }
163 150
164 if (!cpu.hasSSE2)151 if (!SDL_HasSSE2())
165 {152 {
166 showErrorMsgBox("Your computer's processor doesn't have the SSE2 instruction set\n" \153 showErrorMsgBox("Your computer's processor doesn't have the SSE2 instruction set\n" \
167 "which is needed for this program to run. Sorry!");154 "which is needed for this program to run. Sorry!");
@@ -170,12 +157,14 @@ int main(int argc, char *argv[]) · 2 unmodified lines
170 157
171 setupWin32Usleep();158 setupWin32Usleep();
172 disableWasapi(); // disable problematic WASAPI SDL2 audio driver on Windows (causes clicks/pops sometimes...)159 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...
173#endif161#endif
174 162
175 /* SDL 2.0.9 for Windows has a serious bug where you need to initialize the joystick subsystem163 /* SDL 2.0.9 for Windows has a serious bug where you need to initialize the joystick subsystem
176 ** (even if you don't use it) or else weird things happen like random stutters, keyboard (rarely) being164 ** (even if you don't use it) or else weird things happen like random stutters, keyboard (rarely) being
177 ** reinitialized in Windows and what not.165 ** 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 */
179#if defined _WIN32 && SDL_PATCHLEVEL == 9168#if defined _WIN32 && SDL_PATCHLEVEL == 9
180 if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0)169 if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0)
181#else170#else
@@ -190,7 +179,8 @@ int main(int argc, char *argv[]) · 8 unmodified lines
190 179
191 /* Text input is started by default in SDL2, turn it off to remove ~2ms spikes per key press.180 /* Text input is started by default in SDL2, turn it off to remove ~2ms spikes per key press.
192 ** We manuallay start it again when someone clicks on a text edit box, and stop it when done.181 ** 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 */
194 SDL_StopTextInput();184 SDL_StopTextInput();
195 185
196 #ifdef __APPLE__186 #ifdef __APPLE__
@@ -299,7 +289,7 @@ int main(int argc, char *argv[]) · 102 unmodified lines
299 fillToVuMetersBgBuffer();289 fillToVuMetersBgBuffer();
300 updateCursorPos();290 updateCursorPos();
301 291
302 SDL_ShowWindow(window);292 SDL_ShowWindow(video.window);
303 293
304 changePathToHome(); // set path to home/user-dir now294 changePathToHome(); // set path to home/user-dir now
305 diskOpSetInitPath(); // set path to custom path in config (if present)295 diskOpSetInitPath(); // set path to custom path in config (if present)
@@ -313,9 +303,9 @@ int main(int argc, char *argv[]) · 7 unmodified lines
313 readKeyModifiers(); // set/clear CTRL/ALT/SHIFT/AMIGA key states303 readKeyModifiers(); // set/clear CTRL/ALT/SHIFT/AMIGA key states
314 handleInput();304 handleInput();
315 updateMouseCounters();305 updateMouseCounters();
316 handleKeyRepeat(input.keyb.lastRepKey);306 handleKeyRepeat(keyb.lastRepKey);
317 307
318 if (!input.mouse.buttonWaiting && editor.ui.sampleMarkingPos == -1 &&308 if (!mouse.buttonWaiting && editor.ui.sampleMarkingPos == -1 &&
319 !editor.ui.forceSampleDrag && !editor.ui.forceVolDrag && !editor.ui.forceSampleEdit)309 !editor.ui.forceSampleDrag && !editor.ui.forceVolDrag && !editor.ui.forceSampleEdit)
320 {310 {
321 handleGUIButtonRepeat();311 handleGUIButtonRepeat();
@@ -339,17 +329,27 @@ static void handleInput(void) · 17 unmodified lines
339 329
340 while (SDL_PollEvent(&event))330 while (SDL_PollEvent(&event))
341 {331 {
342 if (editor.ui.vsync60HzPresent)332 if (event.type == SDL_WINDOWEVENT)
343 {333 {
344 /* if we minimize the window and vsync is present, vsync is temporarily turned off.334 if (event.window.event == SDL_WINDOWEVENT_HIDDEN)
345 ** recalc waitVBL() vars so that it can sleep properly in said mode. */335 video.windowHidden = true;
346 if (event.type == SDL_WINDOWEVENT &&336 else if (event.window.event == SDL_WINDOWEVENT_SHOWN)
347 (event.window.event == SDL_WINDOWEVENT_MINIMIZED || event.window.event == SDL_WINDOWEVENT_FOCUS_LOST))337 video.windowHidden = false;
338
339 if (video.vsync60HzPresent)
348 {340 {
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 }
350 }349 }
351 }350 }
352 351
352
353#ifdef _WIN32353#ifdef _WIN32
354 handleSysMsg(event);354 handleSysMsg(event);
355#endif355#endif
@@ -373,7 +373,7 @@ static void handleInput(void) · 17 unmodified lines
373 {373 {
374 loadDroppedFile(event.drop.file, (uint32_t)strlen(event.drop.file), false, true);374 loadDroppedFile(event.drop.file, (uint32_t)strlen(event.drop.file), false, true);
375 SDL_free(event.drop.file);375 SDL_free(event.drop.file);
376 SDL_RaiseWindow(window); // set window focus376 SDL_RaiseWindow(video.window); // set window focus
377 }377 }
378 if (event.type == SDL_QUIT)378 if (event.type == SDL_QUIT)
379 {379 {
@@ -385,7 +385,7 @@ static void handleInput(void) · 5 unmodified lines
385 }385 }
386 else if (event.type == SDL_KEYDOWN)386 else if (event.type == SDL_KEYDOWN)
387 {387 {
388 if (editor.repeatKeyFlag || input.keyb.lastRepKey != event.key.keysym.scancode)388 if (editor.repeatKeyFlag || keyb.lastRepKey != event.key.keysym.scancode)
389 keyDownHandler(event.key.keysym.scancode, event.key.keysym.sym);389 keyDownHandler(event.key.keysym.scancode, event.key.keysym.sym);
390 }390 }
391 else if (event.type == SDL_MOUSEBUTTONUP)391 else if (event.type == SDL_MOUSEBUTTONUP)
@@ -435,9 +435,13 @@ static void handleInput(void) · 43 unmodified lines
435static bool initializeVars(void)435static bool initializeVars(void)
436{436{
437 // clear common structs437 // 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));
439 memset(&editor, 0, sizeof (editor));441 memset(&editor, 0, sizeof (editor));
440 memset(&ptConfig, 0, sizeof (ptConfig));442 memset(&config, 0, sizeof (config));
443
444 setDefaultPalette();
441 445
442 editor.repeatKeyFlag = (SDL_GetModState() & KMOD_CAPS) ? true : false;446 editor.repeatKeyFlag = (SDL_GetModState() & KMOD_CAPS) ? true : false;
443 447
@@ -450,17 +454,17 @@ static bool initializeVars(void) · 6 unmodified lines
450 if (!allocSamplerVars() || !allocDiskOpVars())454 if (!allocSamplerVars() || !allocDiskOpVars())
451 goto oom;455 goto oom;
452 456
453 ptConfig.defModulesDir = (char *)calloc(PATH_MAX + 1, sizeof (char));457 config.defModulesDir = (char *)calloc(PATH_MAX + 1, sizeof (char));
454 ptConfig.defSamplesDir = (char *)calloc(PATH_MAX + 1, sizeof (char));458 config.defSamplesDir = (char *)calloc(PATH_MAX + 1, sizeof (char));
455 editor.tempSample = (int8_t *)calloc(MAX_SAMPLE_LEN, 1);459 editor.tempSample = (int8_t *)calloc(MAX_SAMPLE_LEN, 1);
456 460
457 if (ptConfig.defModulesDir == NULL || ptConfig.defSamplesDir == NULL ||461 if (config.defModulesDir == NULL || config.defSamplesDir == NULL ||
458 editor.tempSample == NULL)462 editor.tempSample == NULL)
459 {463 {
460 goto oom;464 goto oom;
461 }465 }
462 466
463 clearPaulaAndScopes();467 turnOffVoices();
464 468
465 // set various non-zero values469 // set various non-zero values
466 editor.vol1 = 100;470 editor.vol1 = 100;
@@ -519,7 +523,7 @@ static bool initializeVars(void) · 52 unmodified lines
519 editor.sampleFromDisp = &editor.sampleFrom;523 editor.sampleFromDisp = &editor.sampleFrom;
520 editor.chordLengthDisp = &editor.chordLength;524 editor.chordLengthDisp = &editor.chordLength;
521 editor.metroChannelDisp = &editor.metroChannel;525 editor.metroChannelDisp = &editor.metroChannel;
522 editor.quantizeValueDisp = &ptConfig.quantizeValue;526 editor.quantizeValueDisp = &config.quantizeValue;
523 527
524 editor.programRunning = true;528 editor.programRunning = true;
525 return true;529 return true;
@@ -535,11 +539,11 @@ static void handleSigTerm(void) · 9 unmodified lines
535 {539 {
536 resetAllScreens();540 resetAllScreens();
537 541
538 if (!editor.fullscreen)542 if (!video.fullscreen)
539 {543 {
540 // de-minimize window and set focus so that the user sees the message box544 // de-minimize window and set focus so that the user sees the message box
541 SDL_RestoreWindow(window);545 SDL_RestoreWindow(video.window);
542 SDL_RaiseWindow(window);546 SDL_RaiseWindow(video.window);
543 }547 }
544 548
545 editor.ui.askScreenShown = true;549 editor.ui.askScreenShown = true;
@@ -725,7 +729,7 @@ static bool instanceAlreadyOpen(void) · 179 unmodified lines
725 sharedMemBuf = (LPTSTR)MapViewOfFile(oneInstHandle, FILE_MAP_ALL_ACCESS, 0, 0, sizeof (HWND));729 sharedMemBuf = (LPTSTR)MapViewOfFile(oneInstHandle, FILE_MAP_ALL_ACCESS, 0, 0, sizeof (HWND));
726 if (sharedMemBuf != NULL)730 if (sharedMemBuf != NULL)
727 {731 {
728 CopyMemory((PVOID)sharedMemBuf, &editor.ui.hWnd, sizeof (HWND));732 CopyMemory((PVOID)sharedMemBuf, &video.hWnd, sizeof (HWND));
729 UnmapViewOfFile(sharedMemBuf);733 UnmapViewOfFile(sharedMemBuf);
730 sharedMemBuf = NULL;734 sharedMemBuf = NULL;
731 }735 }
@@ -739,10 +743,10 @@ static bool handleSingleInstancing(int32_t argc, char **argv) · 7 unmodified lines
739 SDL_SysWMinfo wmInfo;743 SDL_SysWMinfo wmInfo;
740 744
741 SDL_VERSION(&wmInfo.version);745 SDL_VERSION(&wmInfo.version);
742 if (!SDL_GetWindowWMInfo(window, &wmInfo))746 if (!SDL_GetWindowWMInfo(video.window, &wmInfo))
743 return false;747 return false;
744 748
745 editor.ui.hWnd = wmInfo.info.win.window;749 video.hWnd = wmInfo.info.win.window;
746 if (instanceAlreadyOpen() && argc >= 2 && argv[1][0] != '\0')750 if (instanceAlreadyOpen() && argc >= 2 && argv[1][0] != '\0')
747 {751 {
748 sharedMemBuf = (LPTSTR)MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof (HWND));752 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
864 videoClose();868 videoClose();
865 freeSprites();869 freeSprites();
866 870
867 if (ptConfig.defModulesDir != NULL) free(ptConfig.defModulesDir);871 if (config.defModulesDir != NULL) free(config.defModulesDir);
868 if (ptConfig.defSamplesDir != NULL) free(ptConfig.defSamplesDir);872 if (config.defSamplesDir != NULL) free(config.defSamplesDir);
869 if (editor.tempSample != NULL) free(editor.tempSample);873 if (editor.tempSample != NULL) free(editor.tempSample);
870 874
871#ifdef _WIN32875#ifdef _WIN32
src/pt2_modloader.c+5−6
@@ -39,8 +39,6 @@ static char oldFullPath[(PATH_MAX * 2) + 2]; · 38 unmodified lines
39static uint32_t oldFullPathLen;39static uint32_t oldFullPathLen;
40static module_t *tempMod;40static module_t *tempMod;
41 41
42extern SDL_Window *window;
43
44static MEMFILE *mopen(const uint8_t *src, uint32_t length);42static MEMFILE *mopen(const uint8_t *src, uint32_t length);
45static void mclose(MEMFILE **buf);43static void mclose(MEMFILE **buf);
46static int32_t mgetc(MEMFILE *buf);44static int32_t mgetc(MEMFILE *buf);
@@ -656,6 +654,7 @@ module_t *modLoad(UNICHAR *fileName) · 609 unmodified lines
656 {654 {
657 // "DFJ SoundTracker II" or later655 // "DFJ SoundTracker II" or later
658 656
657 // TODO: This needs more detection and is NOT correct!
659 if (note->command == 0xD)658 if (note->command == 0xD)
660 {659 {
661 if (veryLateSTKVerFlag) // "DFJ SoundTracker III" or later660 if (veryLateSTKVerFlag) // "DFJ SoundTracker III" or later
@@ -806,7 +805,7 @@ bool saveModule(bool checkIfFileExist, bool giveNewFreeFilename) · 144 unmodified lines
806 805
807 memset(fileName, 0, sizeof (fileName));806 memset(fileName, 0, sizeof (fileName));
808 807
809 if (ptConfig.modDot)808 if (config.modDot)
810 {809 {
811 // extension.filename810 // extension.filename
812 if (*modEntry->head.moduleTitle == '\0')811 if (*modEntry->head.moduleTitle == '\0')
@@ -848,7 +847,7 @@ bool saveModule(bool checkIfFileExist, bool giveNewFreeFilename) · 35 unmodified lines
848 for (uint16_t j = 1; j <= 9999; j++)847 for (uint16_t j = 1; j <= 9999; j++)
849 {848 {
850 memset(fileName, 0, sizeof (fileName));849 memset(fileName, 0, sizeof (fileName));
851 if (ptConfig.modDot)850 if (config.modDot)
852 {851 {
853 // extension.filename852 // extension.filename
854 if (*modEntry->head.moduleTitle == '\0')853 if (*modEntry->head.moduleTitle == '\0')
@@ -1326,8 +1325,8 @@ void loadDroppedFile(char *fullPath, uint32_t fullPathLen, bool autoPlay, bool s · 471 unmodified lines
1326 oldAutoPlay = autoPlay;1325 oldAutoPlay = autoPlay;
1327 1326
1328 // de-minimize window and set focus so that the user sees the message box1327 // de-minimize window and set focus so that the user sees the message box
1329 SDL_RestoreWindow(window);1328 SDL_RestoreWindow(video.window);
1330 SDL_RaiseWindow(window);1329 SDL_RaiseWindow(video.window);
1331 1330
1332 showSongUnsavedAskBox(ASK_DISCARD_SONG_DRAGNDROP);1331 showSongUnsavedAskBox(ASK_DISCARD_SONG_DRAGNDROP);
1333 return;1332 return;
src/pt2_modplayer.c+16−16
@@ -24,8 +24,6 @@ · 23 unmodified lines
24#include "pt2_textout.h"24#include "pt2_textout.h"
25#include "pt2_scopes.h"25#include "pt2_scopes.h"
26 26
27extern bool forceMixerOff; // pt_audio.c
28
29static bool posJumpAssert, pBreakFlag, updateUIPositions, modHasBeenPlayed;27static bool posJumpAssert, pBreakFlag, updateUIPositions, modHasBeenPlayed;
30static int8_t pBreakPosition, oldRow, modPattern;28static int8_t pBreakPosition, oldRow, modPattern;
31static uint8_t pattDelTime, setBPMFlag, lowMask = 0xFF, pattDelTime2, oldSpeed;29static uint8_t pattDelTime, setBPMFlag, lowMask = 0xFF, pattDelTime2, oldSpeed;
@@ -63,13 +61,14 @@ void doStopIt(void) · 31 unmodified lines
63 moduleChannel_t *c;61 moduleChannel_t *c;
64 uint8_t i;62 uint8_t i;
65 63
64 editor.songPlaying = false;
65
66 resetCachedMixerPeriod();66 resetCachedMixerPeriod();
67 67
68 pattDelTime = 0;68 pattDelTime = 0;
69 pattDelTime2 = 0;69 pattDelTime2 = 0;
70 editor.playMode = PLAY_MODE_NORMAL;70 editor.playMode = PLAY_MODE_NORMAL;
71 editor.currMode = MODE_IDLE;71 editor.currMode = MODE_IDLE;
72 editor.songPlaying = false;
73 72
74 pointerSetMode(POINTER_MODE_IDLE, DO_CARRY);73 pointerSetMode(POINTER_MODE_IDLE, DO_CARRY);
75 74
@@ -919,7 +918,7 @@ static void nextPosition(void) · 843 unmodified lines
919 modOrder = 0;918 modOrder = 0;
920 modHasBeenPlayed = true;919 modHasBeenPlayed = true;
921 920
922 if (ptConfig.compoMode) // stop song for music competitions playing921 if (config.compoMode) // stop song for music competitions playing
923 {922 {
924 doStopIt();923 doStopIt();
925 turnOffVoices();924 turnOffVoices();
@@ -1249,6 +1248,10 @@ void modPlay(int16_t patt, int16_t order, int8_t row) · 323 unmodified lines
1249{1248{
1250 uint8_t oldPlayMode, oldMode;1249 uint8_t oldPlayMode, oldMode;
1251 1250
1251 doStopIt();
1252 turnOffVoices();
1253 mixerClearSampleCounter();
1254
1252 if (row != -1)1255 if (row != -1)
1253 {1256 {
1254 if (row >= 0 && row <= 63)1257 if (row >= 0 && row <= 63)
@@ -1301,9 +1304,6 @@ void modPlay(int16_t patt, int16_t order, int8_t row) · 46 unmodified lines
1301 oldPlayMode = editor.playMode;1304 oldPlayMode = editor.playMode;
1302 oldMode = editor.currMode;1305 oldMode = editor.currMode;
1303 1306
1304 doStopIt();
1305 turnOffVoices();
1306
1307 editor.playMode = oldPlayMode;1307 editor.playMode = oldPlayMode;
1308 editor.currMode = oldMode;1308 editor.currMode = oldMode;
1309 1309
@@ -1320,8 +1320,6 @@ void modPlay(int16_t patt, int16_t order, int8_t row) · 10 unmodified lines
1320 editor.ui.updateSongPattern = true;1320 editor.ui.updateSongPattern = true;
1321 editor.ui.updateCurrPattText = true;1321 editor.ui.updateCurrPattText = true;
1322 }1322 }
1323
1324 mixerClearSampleCounter();
1325}1323}
1326 1324
1327void clearSong(void)1325void clearSong(void)
@@ -1438,7 +1436,11 @@ void modFree(void) · 110 unmodified lines
1438 if (modEntry == NULL)1436 if (modEntry == NULL)
1439 return; // not allocated1437 return; // not allocated
1440 1438
1441 lockAudio();1439 const bool wasLocked = audio.locked;
1440 if (!wasLocked)
1441 lockAudio();
1442
1443 turnOffVoices();
1442 1444
1443 for (i = 0; i < MAX_PATTERNS; i++)1445 for (i = 0; i < MAX_PATTERNS; i++)
1444 {1446 {
@@ -1447,15 +1449,13 @@ void modFree(void) · 2 unmodified lines
1447 }1449 }
1448 1450
1449 if (modEntry->sampleData != NULL)1451 if (modEntry->sampleData != NULL)
1450 {
1451 clearPaulaAndScopes();
1452 free(modEntry->sampleData);1452 free(modEntry->sampleData);
1453 }
1454 1453
1455 free(modEntry);1454 free(modEntry);
1456 modEntry = NULL;1455 modEntry = NULL;
1457 1456
1458 unlockAudio();1457 if (!wasLocked)
1458 unlockAudio();
1459}1459}
1460 1460
1461void restartSong(void) // for the beginning of MOD2WAV/PAT2SMP1461void restartSong(void) // for the beginning of MOD2WAV/PAT2SMP
@@ -1465,7 +1465,7 @@ void restartSong(void) // for the beginning of MOD2WAV/PAT2SMP · 3 unmodified lines
1465 1465
1466 editor.playMode = PLAY_MODE_NORMAL;1466 editor.playMode = PLAY_MODE_NORMAL;
1467 editor.blockMarkFlag = false;1467 editor.blockMarkFlag = false;
1468 forceMixerOff = true;1468 audio.forceMixerOff = true;
1469 1469
1470 modEntry->row = 0;1470 modEntry->row = 0;
1471 modEntry->currRow = 0;1471 modEntry->currRow = 0;
@@ -1528,5 +1528,5 @@ void resetSong(void) // only call this after storeTempVariables() has been calle · 56 unmodified lines
1528 1528
1529 editor.modTick = 0;1529 editor.modTick = 0;
1530 modHasBeenPlayed = false;1530 modHasBeenPlayed = false;
1531 forceMixerOff = false;1531 audio.forceMixerOff = false;
1532}1532}
src/pt2_mouse.c+353−344
@@ -25,13 +25,11 @@ · 24 unmodified lines
25#include "pt2_keyboard.h"25#include "pt2_keyboard.h"
26 26
27/* TODO: Move irrelevant routines outta here! Disgusting design!27/* 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**/
29 30
30SDL_Cursor *cursors[NUM_CURSORS];31SDL_Cursor *cursors[NUM_CURSORS];
31 32
32extern SDL_Renderer *renderer;
33extern SDL_Window *window;
34
35void edNote1UpButton(void);33void edNote1UpButton(void);
36void edNote1DownButton(void);34void edNote1DownButton(void);
37void edNote2UpButton(void);35void edNote2UpButton(void);
@@ -80,11 +78,11 @@ static void pointerSetColor(uint8_t cursorColorIndex) · 42 unmodified lines
80{78{
81 assert(cursorColorIndex <= 5);79 assert(cursorColorIndex <= 5);
82 80
83 palette[PAL_MOUSE_1] = cursorColors[cursorColorIndex][0];81 video.palette[PAL_MOUSE_1] = cursorColors[cursorColorIndex][0];
84 palette[PAL_MOUSE_2] = cursorColors[cursorColorIndex][1];82 video.palette[PAL_MOUSE_2] = cursorColors[cursorColorIndex][1];
85 palette[PAL_MOUSE_3] = cursorColors[cursorColorIndex][2];83 video.palette[PAL_MOUSE_3] = cursorColors[cursorColorIndex][2];
86 84
87 if (ptConfig.hwMouse)85 if (config.hwMouse)
88 setSystemCursor(cursors[cursorColorIndex]);86 setSystemCursor(cursors[cursorColorIndex]);
89}87}
90 88
@@ -155,14 +153,15 @@ bool createMouseCursors(void) // creates scaled SDL surfaces for current mouse p · 64 unmodified lines
155{153{
156 freeMouseCursors();154 freeMouseCursors();
157 155
158 uint8_t scaling = editor.ui.yScale;156 uint8_t scaleFactor = video.yScale;
157
159 for (uint32_t i = 0; i < NUM_CURSORS; i++)158 for (uint32_t i = 0; i < NUM_CURSORS; i++)
160 {159 {
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);
162 if (surface == NULL)161 if (surface == NULL)
163 {162 {
164 freeMouseCursors();163 freeMouseCursors();
165 ptConfig.hwMouse = false; // enable software mouse164 config.hwMouse = false; // enable software mouse
166 return false;165 return false;
167 }166 }
168 167
@@ -171,9 +170,9 @@ bool createMouseCursors(void) // creates scaled SDL surfaces for current mouse p · 2 unmodified lines
171 uint32_t color3 = cursorColors[i][2];170 uint32_t color3 = cursorColors[i][2];
172 uint32_t colorkey = 0x12345678;171 uint32_t colorkey = 0x12345678;
173 172
174 color1 = SDL_MapRGB(surface->format, R24(color1), G24(color1), B24(color1));173 color1 = SDL_MapRGB(surface->format, R24(color1), G24(color1), B24(color1));
175 color2 = SDL_MapRGB(surface->format, R24(color2), G24(color2), B24(color2));174 color2 = SDL_MapRGB(surface->format, R24(color2), G24(color2), B24(color2));
176 color3 = SDL_MapRGB(surface->format, R24(color3), G24(color3), B24(color3));175 color3 = SDL_MapRGB(surface->format, R24(color3), G24(color3), B24(color3));
177 colorkey = SDL_MapRGB(surface->format, R24(colorkey), G24(colorkey), B24(colorkey));176 colorkey = SDL_MapRGB(surface->format, R24(colorkey), G24(colorkey), B24(colorkey));
178 177
179 SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);178 SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
@@ -190,8 +189,8 @@ bool createMouseCursors(void) // creates scaled SDL surfaces for current mouse p · 10 unmodified lines
190 // blit upscaled cursor to surface189 // blit upscaled cursor to surface
191 for (uint32_t y = 0; y < POINTER_H; y++)190 for (uint32_t y = 0; y < POINTER_H; y++)
192 {191 {
193 uint32_t *outX = &dstPixels32[(y * scaling) * surface->w];192 uint32_t *outX = &dstPixels32[(y * scaleFactor) * surface->w];
194 for (uint32_t yScale = 0; yScale < scaling; yScale++)193 for (uint32_t yScale = 0; yScale < scaleFactor; yScale++)
195 {194 {
196 for (uint32_t x = 0; x < POINTER_W; x++)195 for (uint32_t x = 0; x < POINTER_W; x++)
197 {196 {
@@ -204,11 +203,11 @@ bool createMouseCursors(void) // creates scaled SDL surfaces for current mouse p · 6 unmodified lines
204 else if (srcPix == PAL_MOUSE_2) pixel = color2;203 else if (srcPix == PAL_MOUSE_2) pixel = color2;
205 else if (srcPix == PAL_MOUSE_3) pixel = color3;204 else if (srcPix == PAL_MOUSE_3) pixel = color3;
206 205
207 for (uint32_t xScale = 0; xScale < scaling; xScale++)206 for (uint32_t xScale = 0; xScale < scaleFactor; xScale++)
208 outX[xScale] = pixel;207 outX[xScale] = pixel;
209 }208 }
210 209
211 outX += scaling;210 outX += scaleFactor;
212 }211 }
213 }212 }
214 }213 }
@@ -220,7 +219,7 @@ bool createMouseCursors(void) // creates scaled SDL surfaces for current mouse p · 5 unmodified lines
220 {219 {
221 SDL_FreeSurface(surface);220 SDL_FreeSurface(surface);
222 freeMouseCursors();221 freeMouseCursors();
223 ptConfig.hwMouse = false; // enable software mouse222 config.hwMouse = false; // enable software mouse
224 return false;223 return false;
225 }224 }
226 225
@@ -233,102 +232,112 @@ bool createMouseCursors(void) // creates scaled SDL surfaces for current mouse p · 6 unmodified lines
233 232
234void updateMouseScaling(void)233void updateMouseScaling(void)
235{234{
236 if (editor.ui.renderW > 0) editor.ui.dMouseXMul = (double)SCREEN_W / editor.ui.renderW;235 if (video.renderW > 0) video.dMouseXMul = (double)SCREEN_W / video.renderW;
237 if (editor.ui.renderH > 0) editor.ui.dMouseYMul = (double)SCREEN_H / editor.ui.renderH;236 if (video.renderH > 0) video.dMouseYMul = (double)SCREEN_H / video.renderH;
238}237}
239 238
240void readMouseXY(void)239void readMouseXY(void)
241{240{
242 int32_t mx, my;241 int32_t mx, my, windowX, windowY;
243 242
244 if (input.mouse.setPosFlag)243 if (mouse.setPosFlag)
245 {244 {
246 input.mouse.setPosFlag = false;245 if (!video.windowHidden)
247 246 SDL_WarpMouseInWindow(video.window, mouse.setPosX, mouse.setPosY);
248 if (SDL_GetWindowFlags(window) & SDL_WINDOW_SHOWN)
249 SDL_WarpMouseInWindow(window, input.mouse.setPosX, input.mouse.setPosY);
250 247
248 mouse.setPosFlag = false;
251 return;249 return;
252 }250 }
253 251
254 SDL_PumpEvents(); // gathers all pending input from devices into the event queue (less mouse lag)252 mouse.buttonState = SDL_GetGlobalMouseState(&mx, &my);
255 SDL_GetMouseState(&mx, &my);
256 253
257 /* in centered fullscreen mode, trap the mouse inside the framed image254 if (video.fullscreen)
258 * and subtract the coords to match the OS mouse position (fixes touch from touchscreens) */
259 if (editor.fullscreen && !ptConfig.fullScreenStretch)
260 {255 {
261 if (mx < editor.ui.renderX)256 /* If fullscreen without filtering mode, translate coords and warp mouse
262 {257 ** inside the render space.
263 mx = editor.ui.renderX;258 ** Fullscreen + filtering mode takes up 100% of the screen area used, so no
264 SDL_WarpMouseInWindow(window, mx, my);259 ** need to translate coords in that mode.
265 }260 */
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 }
271 261
272 if (my < editor.ui.renderY)262 if (!config.fullScreenStretch)
273 {263 {
274 my = editor.ui.renderY;264 if (!config.hwMouse)
275 SDL_WarpMouseInWindow(window, mx, my);265 {
276 }266 bool warpMouse = false;
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 }
282 267
283 mx -= editor.ui.renderX;268 if (mx < video.renderX)
284 my -= editor.ui.renderY;269 {
285 }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 }
286 278
287 if (mx < 0) mx = 0;279 if (my < video.renderY)
288 if (my < 0) my = 0;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 }
289 289
290 // multiply coords by video scaling factors (do not round)290 if (warpMouse)
291 mx = (int32_t)(mx * editor.ui.dMouseXMul);291 SDL_WarpMouseInWindow(video.window, mx, my);
292 my = (int32_t)(my * editor.ui.dMouseYMul);292 }
293 293
294 if (mx >= SCREEN_W) mx = SCREEN_W - 1;294 // convert fullscreen coords to window (centered image) coords
295 if (my >= SCREEN_H) my = SCREEN_H - 1;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 }
296 309
297 input.mouse.x = (int16_t)mx;310 // multiply coords by video upscaling factors (don't round)
298 input.mouse.y = (int16_t)my;311 mouse.x = (int32_t)(mx * video.dMouseXMul);
312 mouse.y = (int32_t)(my * video.dMouseYMul);
299 313
300 if (ptConfig.hwMouse)314 if (config.hwMouse)
301 {315 {
302 // hardware mouse316 // hardware mouse mode (OS)
303 hideSprite(SPRITE_MOUSE_POINTER);317 hideSprite(SPRITE_MOUSE_POINTER);
304 }318 }
305 else319 else
306 {320 {
307 // software mouse321 // software mouse mode (PT mouse)
308 setSpritePos(SPRITE_MOUSE_POINTER, input.mouse.x, input.mouse.y);322 setSpritePos(SPRITE_MOUSE_POINTER, mouse.x, mouse.y);
309 }323 }
310}324}
311 325
312void mouseButtonUpHandler(uint8_t mouseButton)326void mouseButtonUpHandler(uint8_t mouseButton)
313{327{
314#ifndef __APPLE__328 mouse.buttonWaitCounter = 0;
315 if (!editor.fullscreen)329 mouse.buttonWaiting = false;
316 SDL_SetWindowGrab(window, SDL_FALSE);
317#endif
318
319 input.mouse.buttonWaitCounter = 0;
320 input.mouse.buttonWaiting = false;
321 330
322 if (mouseButton == SDL_BUTTON_LEFT)331 if (mouseButton == SDL_BUTTON_LEFT)
323 {332 {
324 input.mouse.leftButtonPressed = false;333 mouse.leftButtonPressed = false;
325 editor.ui.forceSampleDrag = false;334 editor.ui.forceSampleDrag = false;
326 editor.ui.forceVolDrag = false;335 editor.ui.forceVolDrag = false;
327 editor.ui.leftLoopPinMoving = false;336 editor.ui.leftLoopPinMoving = false;
328 editor.ui.rightLoopPinMoving = false;337 editor.ui.rightLoopPinMoving = false;
329 editor.ui.sampleMarkingPos = -1;338 editor.ui.sampleMarkingPos = -1;
330 339
331 switch (input.mouse.lastGUIButton)340 switch (mouse.lastGUIButton)
332 {341 {
333 case PTB_SLENGTHU:342 case PTB_SLENGTHU:
334 case PTB_SLENGTHD:343 case PTB_SLENGTHD:
@@ -358,32 +367,27 @@ void mouseButtonUpHandler(uint8_t mouseButton) · 23 unmodified lines
358 break;367 break;
359 }368 }
360 369
361 input.mouse.lastGUIButton = -1;370 mouse.lastGUIButton = -1;
362 input.mouse.lastSmpFilterButton = -1;371 mouse.lastSmpFilterButton = -1;
363 }372 }
364 373
365 if (mouseButton == SDL_BUTTON_RIGHT)374 if (mouseButton == SDL_BUTTON_RIGHT)
366 {375 {
367 input.mouse.rightButtonPressed = false;376 mouse.rightButtonPressed = false;
368 editor.ui.forceSampleEdit = false;377 editor.ui.forceSampleEdit = false;
369 }378 }
370}379}
371 380
372void mouseButtonDownHandler(uint8_t mouseButton)381void mouseButtonDownHandler(uint8_t mouseButton)
373{382{
374#ifndef __APPLE__
375 if (!editor.fullscreen)
376 SDL_SetWindowGrab(window, SDL_TRUE);
377#endif
378
379 if (mouseButton == SDL_BUTTON_LEFT)383 if (mouseButton == SDL_BUTTON_LEFT)
380 {384 {
381 input.mouse.leftButtonPressed = true;385 mouse.leftButtonPressed = true;
382 input.mouse.buttonWaiting = true;386 mouse.buttonWaiting = true;
383 }387 }
384 388
385 if (mouseButton == SDL_BUTTON_RIGHT)389 if (mouseButton == SDL_BUTTON_RIGHT)
386 input.mouse.rightButtonPressed = true;390 mouse.rightButtonPressed = true;
387 391
388 // when red mouse pointer (error), block further input for a while392 // when red mouse pointer (error), block further input for a while
389 if (editor.errorMsgActive && editor.errorMsgBlock)393 if (editor.errorMsgActive && editor.errorMsgBlock)
@@ -397,10 +401,10 @@ void mouseButtonDownHandler(uint8_t mouseButton) · 7 unmodified lines
397 401
398void handleGUIButtonRepeat(void)402void handleGUIButtonRepeat(void)
399{403{
400 if (!input.mouse.leftButtonPressed)404 if (!mouse.leftButtonPressed)
401 {405 {
402 // left mouse button released, stop repeating buttons406 // left mouse button released, stop repeating buttons
403 input.mouse.repeatCounter = 0;407 mouse.repeatCounter = 0;
404 return;408 return;
405 }409 }
406 410
@@ -410,20 +414,20 @@ void handleGUIButtonRepeat(void) · 3 unmodified lines
410 return;414 return;
411 }415 }
412 416
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!
414 {418 {
415 // only repeat the button that was first clicked (e.g. if you hold and move mouse to another button)419 // 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;
417 return;421 return;
418 }422 }
419 423
420 handleRepeatedGUIButtons();424 handleRepeatedGUIButtons();
421 input.mouse.repeatCounter++;425 mouse.repeatCounter++;
422}426}
423 427
424void edNote1UpButton(void)428void edNote1UpButton(void)
425{429{
426 if (input.mouse.rightButtonPressed)430 if (mouse.rightButtonPressed)
427 editor.note1 += 12;431 editor.note1 += 12;
428 else432 else
429 editor.note1++;433 editor.note1++;
@@ -437,7 +441,7 @@ void edNote1UpButton(void) · 7 unmodified lines
437 441
438void edNote1DownButton(void)442void edNote1DownButton(void)
439{443{
440 if (input.mouse.rightButtonPressed)444 if (mouse.rightButtonPressed)
441 editor.note1 -= 12;445 editor.note1 -= 12;
442 else446 else
443 editor.note1--;447 editor.note1--;
@@ -451,7 +455,7 @@ void edNote1DownButton(void) · 7 unmodified lines
451 455
452void edNote2UpButton(void)456void edNote2UpButton(void)
453{457{
454 if (input.mouse.rightButtonPressed)458 if (mouse.rightButtonPressed)
455 editor.note2 += 12;459 editor.note2 += 12;
456 else460 else
457 editor.note2++;461 editor.note2++;
@@ -465,7 +469,7 @@ void edNote2UpButton(void) · 7 unmodified lines
465 469
466void edNote2DownButton(void)470void edNote2DownButton(void)
467{471{
468 if (input.mouse.rightButtonPressed)472 if (mouse.rightButtonPressed)
469 editor.note2 -= 12;473 editor.note2 -= 12;
470 else474 else
471 editor.note2--;475 editor.note2--;
@@ -479,7 +483,7 @@ void edNote2DownButton(void) · 7 unmodified lines
479 483
480void edNote3UpButton(void)484void edNote3UpButton(void)
481{485{
482 if (input.mouse.rightButtonPressed)486 if (mouse.rightButtonPressed)
483 editor.note3 += 12;487 editor.note3 += 12;
484 else488 else
485 editor.note3++;489 editor.note3++;
@@ -493,7 +497,7 @@ void edNote3UpButton(void) · 7 unmodified lines
493 497
494void edNote3DownButton(void)498void edNote3DownButton(void)
495{499{
496 if (input.mouse.rightButtonPressed)500 if (mouse.rightButtonPressed)
497 editor.note3 -= 12;501 editor.note3 -= 12;
498 else502 else
499 editor.note3--;503 editor.note3--;
@@ -507,7 +511,7 @@ void edNote3DownButton(void) · 7 unmodified lines
507 511
508void edNote4UpButton(void)512void edNote4UpButton(void)
509{513{
510 if (input.mouse.rightButtonPressed)514 if (mouse.rightButtonPressed)
511 editor.note4 += 12;515 editor.note4 += 12;
512 else516 else
513 editor.note4++;517 editor.note4++;
@@ -521,7 +525,7 @@ void edNote4UpButton(void) · 7 unmodified lines
521 525
522void edNote4DownButton(void)526void edNote4DownButton(void)
523{527{
524 if (input.mouse.rightButtonPressed)528 if (mouse.rightButtonPressed)
525 editor.note4 -= 12;529 editor.note4 -= 12;
526 else530 else
527 editor.note4--;531 editor.note4--;
@@ -535,7 +539,7 @@ void edNote4DownButton(void) · 7 unmodified lines
535 539
536void edPosUpButton(bool fast)540void edPosUpButton(bool fast)
537{541{
538 if (input.mouse.rightButtonPressed)542 if (mouse.rightButtonPressed)
539 {543 {
540 if (fast)544 if (fast)
541 {545 {
@@ -578,7 +582,7 @@ void edPosUpButton(bool fast) · 36 unmodified lines
578 582
579void edPosDownButton(bool fast)583void edPosDownButton(bool fast)
580{584{
581 if (input.mouse.rightButtonPressed)585 if (mouse.rightButtonPressed)
582 {586 {
583 if (fast)587 if (fast)
584 {588 {
@@ -618,7 +622,7 @@ void edPosDownButton(bool fast) · 33 unmodified lines
618 622
619void edModUpButton(void)623void edModUpButton(void)
620{624{
621 if (input.mouse.rightButtonPressed)625 if (mouse.rightButtonPressed)
622 editor.modulateSpeed += 10;626 editor.modulateSpeed += 10;
623 else627 else
624 editor.modulateSpeed++;628 editor.modulateSpeed++;
@@ -631,7 +635,7 @@ void edModUpButton(void) · 6 unmodified lines
631 635
632void edModDownButton(void)636void edModDownButton(void)
633{637{
634 if (input.mouse.rightButtonPressed)638 if (mouse.rightButtonPressed)
635 {639 {
636 editor.modulateSpeed -= 10;640 editor.modulateSpeed -= 10;
637 }641 }
@@ -648,7 +652,7 @@ void edModDownButton(void) · 10 unmodified lines
648 652
649void edVolUpButton(void)653void edVolUpButton(void)
650{654{
651 if (input.mouse.rightButtonPressed)655 if (mouse.rightButtonPressed)
652 {656 {
653 if (editor.sampleVol <= 999-10)657 if (editor.sampleVol <= 999-10)
654 editor.sampleVol += 10;658 editor.sampleVol += 10;
@@ -666,7 +670,7 @@ void edVolUpButton(void) · 11 unmodified lines
666 670
667void edVolDownButton(void)671void edVolDownButton(void)
668{672{
669 if (input.mouse.rightButtonPressed)673 if (mouse.rightButtonPressed)
670 {674 {
671 if (editor.sampleVol >= 10)675 if (editor.sampleVol >= 10)
672 editor.sampleVol -= 10;676 editor.sampleVol -= 10;
@@ -712,7 +716,7 @@ void sampleFineTuneUpButton(void) · 39 unmodified lines
712 if (finetune != 7)716 if (finetune != 7)
713 modEntry->samples[editor.currSample].fineTune = (finetune + 1) & 0xF;717 modEntry->samples[editor.currSample].fineTune = (finetune + 1) & 0xF;
714 718
715 if (input.mouse.rightButtonPressed)719 if (mouse.rightButtonPressed)
716 modEntry->samples[editor.currSample].fineTune = 0;720 modEntry->samples[editor.currSample].fineTune = 0;
717 721
718 recalcChordLength();722 recalcChordLength();
@@ -725,7 +729,7 @@ void sampleFineTuneDownButton(void) · 6 unmodified lines
725 if (finetune != 8)729 if (finetune != 8)
726 modEntry->samples[editor.currSample].fineTune = (finetune - 1) & 0xF;730 modEntry->samples[editor.currSample].fineTune = (finetune - 1) & 0xF;
727 731
728 if (input.mouse.rightButtonPressed)732 if (mouse.rightButtonPressed)
729 modEntry->samples[editor.currSample].fineTune = 0;733 modEntry->samples[editor.currSample].fineTune = 0;
730 734
731 recalcChordLength();735 recalcChordLength();
@@ -736,7 +740,7 @@ void sampleVolumeUpButton(void) · 4 unmodified lines
736{740{
737 int8_t val = modEntry->samples[editor.currSample].volume;741 int8_t val = modEntry->samples[editor.currSample].volume;
738 742
739 if (input.mouse.rightButtonPressed)743 if (mouse.rightButtonPressed)
740 val += 16;744 val += 16;
741 else745 else
742 val++;746 val++;
@@ -752,7 +756,7 @@ void sampleVolumeDownButton(void) · 9 unmodified lines
752{756{
753 int8_t val = modEntry->samples[editor.currSample].volume;757 int8_t val = modEntry->samples[editor.currSample].volume;
754 758
755 if (input.mouse.rightButtonPressed)759 if (mouse.rightButtonPressed)
756 val -= 16;760 val -= 16;
757 else761 else
758 val--;762 val--;
@@ -772,7 +776,7 @@ void sampleLengthUpButton(bool fast) · 13 unmodified lines
772 return;776 return;
773 777
774 val = modEntry->samples[editor.currSample].length;778 val = modEntry->samples[editor.currSample].length;
775 if (input.mouse.rightButtonPressed)779 if (mouse.rightButtonPressed)
776 {780 {
777 if (fast)781 if (fast)
778 val += 64;782 val += 64;
@@ -812,7 +816,7 @@ void sampleLengthDownButton(bool fast) · 33 unmodified lines
812 }816 }
813 817
814 val = modEntry->samples[editor.currSample].length;818 val = modEntry->samples[editor.currSample].length;
815 if (input.mouse.rightButtonPressed)819 if (mouse.rightButtonPressed)
816 {820 {
817 if (fast)821 if (fast)
818 val -= 64;822 val -= 64;
@@ -855,7 +859,7 @@ void sampleRepeatUpButton(bool fast) · 36 unmodified lines
855 return;859 return;
856 }860 }
857 861
858 if (input.mouse.rightButtonPressed)862 if (mouse.rightButtonPressed)
859 {863 {
860 if (fast)864 if (fast)
861 val += 64;865 val += 64;
@@ -898,7 +902,7 @@ void sampleRepeatDownButton(bool fast) · 36 unmodified lines
898 return;902 return;
899 }903 }
900 904
901 if (input.mouse.rightButtonPressed)905 if (mouse.rightButtonPressed)
902 {906 {
903 if (fast)907 if (fast)
904 val -= 64;908 val -= 64;
@@ -942,7 +946,7 @@ void sampleRepeatLengthUpButton(bool fast) · 37 unmodified lines
942 return;946 return;
943 }947 }
944 948
945 if (input.mouse.rightButtonPressed)949 if (mouse.rightButtonPressed)
946 {950 {
947 if (fast)951 if (fast)
948 val += 64;952 val += 64;
@@ -985,7 +989,7 @@ void sampleRepeatLengthDownButton(bool fast) · 36 unmodified lines
985 return;989 return;
986 }990 }
987 991
988 if (input.mouse.rightButtonPressed)992 if (mouse.rightButtonPressed)
989 {993 {
990 if (fast)994 if (fast)
991 val -= 64;995 val -= 64;
@@ -1023,7 +1027,7 @@ void tempoUpButton(void) · 31 unmodified lines
1023 return;1027 return;
1024 1028
1025 val = modEntry->currBPM;1029 val = modEntry->currBPM;
1026 if (input.mouse.rightButtonPressed)1030 if (mouse.rightButtonPressed)
1027 val += 10;1031 val += 10;
1028 else1032 else
1029 val++;1033 val++;
@@ -1044,7 +1048,7 @@ void tempoDownButton(void) · 14 unmodified lines
1044 return;1048 return;
1045 1049
1046 val = modEntry->currBPM;1050 val = modEntry->currBPM;
1047 if (input.mouse.rightButtonPressed)1051 if (mouse.rightButtonPressed)
1048 val -= 10;1052 val -= 10;
1049 else1053 else
1050 val--;1054 val--;
@@ -1062,7 +1066,7 @@ void songLengthUpButton(void) · 11 unmodified lines
1062 int16_t val;1066 int16_t val;
1063 1067
1064 val = modEntry->head.orderCount;1068 val = modEntry->head.orderCount;
1065 if (input.mouse.rightButtonPressed)1069 if (mouse.rightButtonPressed)
1066 val += 10;1070 val += 10;
1067 else1071 else
1068 val++;1072 val++;
@@ -1084,7 +1088,7 @@ void songLengthDownButton(void) · 15 unmodified lines
1084{1088{
1085 int16_t val = modEntry->head.orderCount;1089 int16_t val = modEntry->head.orderCount;
1086 1090
1087 if (input.mouse.rightButtonPressed)1091 if (mouse.rightButtonPressed)
1088 val -= 10;1092 val -= 10;
1089 else1093 else
1090 val--;1094 val--;
@@ -1106,7 +1110,7 @@ void patternUpButton(void) · 15 unmodified lines
1106{1110{
1107 int16_t val = modEntry->head.order[modEntry->currOrder];1111 int16_t val = modEntry->head.order[modEntry->currOrder];
1108 1112
1109 if (input.mouse.rightButtonPressed)1113 if (mouse.rightButtonPressed)
1110 val += 10;1114 val += 10;
1111 else1115 else
1112 val++;1116 val++;
@@ -1126,7 +1130,7 @@ void patternDownButton(void) · 13 unmodified lines
1126{1130{
1127 int16_t val = modEntry->head.order[modEntry->currOrder];1131 int16_t val = modEntry->head.order[modEntry->currOrder];
1128 1132
1129 if (input.mouse.rightButtonPressed)1133 if (mouse.rightButtonPressed)
1130 val -= 10;1134 val -= 10;
1131 else1135 else
1132 val--;1136 val--;
@@ -1146,7 +1150,7 @@ void positionUpButton(void) · 13 unmodified lines
1146{1150{
1147 int16_t val = modEntry->currOrder;1151 int16_t val = modEntry->currOrder;
1148 1152
1149 if (input.mouse.rightButtonPressed)1153 if (mouse.rightButtonPressed)
1150 val += 10;1154 val += 10;
1151 else1155 else
1152 val++;1156 val++;
@@ -1161,7 +1165,7 @@ void positionDownButton(void) · 8 unmodified lines
1161{1165{
1162 int16_t val = modEntry->currOrder;1166 int16_t val = modEntry->currOrder;
1163 1167
1164 if (input.mouse.rightButtonPressed)1168 if (mouse.rightButtonPressed)
1165 val -= 10;1169 val -= 10;
1166 else1170 else
1167 val--;1171 val--;
@@ -1181,7 +1185,7 @@ void handleSamplerVolumeBox(void) · 13 unmodified lines
1181 double dSmp;1185 double dSmp;
1182 moduleSample_t *s;1186 moduleSample_t *s;
1183 1187
1184 if (input.mouse.rightButtonPressed)1188 if (mouse.rightButtonPressed)
1185 {1189 {
1186 if (editor.ui.editTextFlag)1190 if (editor.ui.editTextFlag)
1187 {1191 {
@@ -1200,14 +1204,14 @@ void handleSamplerVolumeBox(void) · 12 unmodified lines
1200 return;1204 return;
1201 1205
1202 // check buttons1206 // check buttons
1203 if (input.mouse.leftButtonPressed)1207 if (mouse.leftButtonPressed)
1204 {1208 {
1205 // restore sample ask dialog1209 // restore sample ask dialog
1206 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_RESTORE_SAMPLE)1210 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_RESTORE_SAMPLE)
1207 {1211 {
1208 if (input.mouse.y >= 71 && input.mouse.y <= 81)1212 if (mouse.y >= 71 && mouse.y <= 81)
1209 {1213 {
1210 if (input.mouse.x >= 171 && input.mouse.x <= 196)1214 if (mouse.x >= 171 && mouse.x <= 196)
1211 {1215 {
1212 // YES button1216 // YES button
1213 editor.ui.askScreenShown = false;1217 editor.ui.askScreenShown = false;
@@ -1215,7 +1219,7 @@ void handleSamplerVolumeBox(void) · 1 unmodified line
1215 editor.ui.answerYes = true;1219 editor.ui.answerYes = true;
1216 handleAskYes();1220 handleAskYes();
1217 }1221 }
1218 else if (input.mouse.x >= 234 && input.mouse.x <= 252)1222 else if (mouse.x >= 234 && mouse.x <= 252)
1219 {1223 {
1220 // NO button1224 // NO button
1221 editor.ui.askScreenShown = false;1225 editor.ui.askScreenShown = false;
@@ -1231,31 +1235,31 @@ void handleSamplerVolumeBox(void) · 9 unmodified lines
1231 // MAIN SCREEN STOP1235 // MAIN SCREEN STOP
1232 if (!editor.ui.diskOpScreenShown && !editor.ui.posEdScreenShown)1236 if (!editor.ui.diskOpScreenShown && !editor.ui.posEdScreenShown)
1233 {1237 {
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)
1235 {1239 {
1236 modStop();1240 modStop();
1237 return;1241 return;
1238 }1242 }
1239 }1243 }
1240 1244
1241 if (input.mouse.x >= 32 && input.mouse.x <= 95)1245 if (mouse.x >= 32 && mouse.x <= 95)
1242 {1246 {
1243 // SAMPLER SCREEN PLAY WAVEFORM1247 // SAMPLER SCREEN PLAY WAVEFORM
1244 if (input.mouse.y >= 211 && input.mouse.y <= 221)1248 if (mouse.y >= 211 && mouse.y <= 221)
1245 {1249 {
1246 samplerPlayWaveform();1250 samplerPlayWaveform();
1247 return;1251 return;
1248 }1252 }
1249 1253
1250 // SAMPLER SCREEN PLAY DISPLAY1254 // SAMPLER SCREEN PLAY DISPLAY
1251 else if (input.mouse.y >= 222 && input.mouse.y <= 232)1255 else if (mouse.y >= 222 && mouse.y <= 232)
1252 {1256 {
1253 samplerPlayDisplay();1257 samplerPlayDisplay();
1254 return;1258 return;
1255 }1259 }
1256 1260
1257 // SAMPLER SCREEN PLAY RANGE1261 // SAMPLER SCREEN PLAY RANGE
1258 else if (input.mouse.y >= 233 && input.mouse.y <= 243)1262 else if (mouse.y >= 233 && mouse.y <= 243)
1259 {1263 {
1260 samplerPlayRange();1264 samplerPlayRange();
1261 return;1265 return;
@@ -1263,7 +1267,7 @@ void handleSamplerVolumeBox(void) · 1 unmodified line
1263 }1267 }
1264 1268
1265 // SAMPLER SCREEN STOP1269 // 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)
1267 {1271 {
1268 for (i = 0; i < AMIGA_VOICES; i++)1272 for (i = 0; i < AMIGA_VOICES; i++)
1269 mixerKillVoice(i);1273 mixerKillVoice(i);
@@ -1271,7 +1275,7 @@ void handleSamplerVolumeBox(void) · 1 unmodified line
1271 }1275 }
1272 1276
1273 // VOLUME button (toggle)1277 // 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)
1275 {1279 {
1276 editor.ui.samplerVolBoxShown = false;1280 editor.ui.samplerVolBoxShown = false;
1277 removeSamplerVolBox();1281 removeSamplerVolBox();
@@ -1279,16 +1283,16 @@ void handleSamplerVolumeBox(void) · 1 unmodified line
1279 }1283 }
1280 1284
1281 // DRAG BOXES1285 // 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)
1283 {1287 {
1284 volBoxBarPressed(MOUSE_BUTTON_NOT_HELD);1288 volBoxBarPressed(MOUSE_BUTTON_NOT_HELD);
1285 return;1289 return;
1286 }1290 }
1287 1291
1288 if (input.mouse.x >= 174 && input.mouse.x <= 207)1292 if (mouse.x >= 174 && mouse.x <= 207)
1289 {1293 {
1290 // FROM NUM1294 // FROM NUM
1291 if (input.mouse.y >= 154 && input.mouse.y <= 164)1295 if (mouse.y >= 154 && mouse.y <= 164)
1292 {1296 {
1293 editor.ui.tmpDisp16 = editor.vol1;1297 editor.ui.tmpDisp16 = editor.vol1;
1294 editor.vol1Disp = &editor.ui.tmpDisp16;1298 editor.vol1Disp = &editor.ui.tmpDisp16;
@@ -1300,7 +1304,7 @@ void handleSamplerVolumeBox(void) · 5 unmodified lines
1300 }1304 }
1301 1305
1302 // TO NUM1306 // TO NUM
1303 else if (input.mouse.y >= 165 && input.mouse.y <= 175)1307 else if (mouse.y >= 165 && mouse.y <= 175)
1304 {1308 {
1305 editor.ui.tmpDisp16 = editor.vol2;1309 editor.ui.tmpDisp16 = editor.vol2;
1306 editor.vol2Disp = &editor.ui.tmpDisp16;1310 editor.vol2Disp = &editor.ui.tmpDisp16;
@@ -1312,10 +1316,10 @@ void handleSamplerVolumeBox(void) · 5 unmodified lines
1312 }1316 }
1313 }1317 }
1314 1318
1315 if (input.mouse.y >= 176 && input.mouse.y <= 186)1319 if (mouse.y >= 176 && mouse.y <= 186)
1316 {1320 {
1317 // NORMALIZE1321 // NORMALIZE
1318 if (input.mouse.x >= 101 && input.mouse.x <= 143)1322 if (mouse.x >= 101 && mouse.x <= 143)
1319 {1323 {
1320 s = &modEntry->samples[editor.currSample];1324 s = &modEntry->samples[editor.currSample];
1321 if (s->length == 0)1325 if (s->length == 0)
@@ -1374,7 +1378,7 @@ void handleSamplerVolumeBox(void) · 52 unmodified lines
1374 }1378 }
1375 1379
1376 // RAMP DOWN1380 // RAMP DOWN
1377 else if (input.mouse.x >= 144 && input.mouse.x <= 153)1381 else if (mouse.x >= 144 && mouse.x <= 153)
1378 {1382 {
1379 editor.vol1 = 100;1383 editor.vol1 = 100;
1380 editor.vol2 = 0;1384 editor.vol2 = 0;
@@ -1386,7 +1390,7 @@ void handleSamplerVolumeBox(void) · 5 unmodified lines
1386 }1390 }
1387 1391
1388 // RAMP UP1392 // RAMP UP
1389 else if (input.mouse.x >= 154 && input.mouse.x <= 163)1393 else if (mouse.x >= 154 && mouse.x <= 163)
1390 {1394 {
1391 editor.vol1 = 0;1395 editor.vol1 = 0;
1392 editor.vol2 = 100;1396 editor.vol2 = 100;
@@ -1398,7 +1402,7 @@ void handleSamplerVolumeBox(void) · 5 unmodified lines
1398 }1402 }
1399 1403
1400 // RAMP UNITY1404 // RAMP UNITY
1401 else if (input.mouse.x >= 164 && input.mouse.x <= 173)1405 else if (mouse.x >= 164 && mouse.x <= 173)
1402 {1406 {
1403 editor.vol1 = 100;1407 editor.vol1 = 100;
1404 editor.vol2 = 100;1408 editor.vol2 = 100;
@@ -1410,7 +1414,7 @@ void handleSamplerVolumeBox(void) · 5 unmodified lines
1410 }1414 }
1411 1415
1412 // CANCEL1416 // CANCEL
1413 else if (input.mouse.x >= 174 && input.mouse.x <= 207)1417 else if (mouse.x >= 174 && mouse.x <= 207)
1414 {1418 {
1415 editor.ui.samplerVolBoxShown = false;1419 editor.ui.samplerVolBoxShown = false;
1416 removeSamplerVolBox();1420 removeSamplerVolBox();
@@ -1418,7 +1422,7 @@ void handleSamplerVolumeBox(void) · 1 unmodified line
1418 }1422 }
1419 1423
1420 // RAMP1424 // RAMP
1421 else if (input.mouse.x >= 72 && input.mouse.x <= 100)1425 else if (mouse.x >= 72 && mouse.x <= 100)
1422 {1426 {
1423 s = &modEntry->samples[editor.currSample];1427 s = &modEntry->samples[editor.currSample];
1424 if (s->length == 0)1428 if (s->length == 0)
@@ -1478,14 +1482,14 @@ void handleSamplerVolumeBox(void) · 53 unmodified lines
1478 1482
1479static void handleRepeatedSamplerFilterButtons(void)1483static void handleRepeatedSamplerFilterButtons(void)
1480{1484{
1481 if (!input.mouse.leftButtonPressed || input.mouse.lastSmpFilterButton == -1)1485 if (!mouse.leftButtonPressed || mouse.lastSmpFilterButton == -1)
1482 return;1486 return;
1483 1487
1484 switch (input.mouse.lastSmpFilterButton)1488 switch (mouse.lastSmpFilterButton)
1485 {1489 {
1486 case 0: // low-pass cutoff up1490 case 0: // low-pass cutoff up
1487 {1491 {
1488 if (input.mouse.rightButtonPressed)1492 if (mouse.rightButtonPressed)
1489 {1493 {
1490 if (editor.lpCutOff <= 0xFFFF-50)1494 if (editor.lpCutOff <= 0xFFFF-50)
1491 editor.lpCutOff += 50;1495 editor.lpCutOff += 50;
@@ -1509,7 +1513,7 @@ static void handleRepeatedSamplerFilterButtons(void) · 17 unmodified lines
1509 1513
1510 case 1: // low-pass cutoff down1514 case 1: // low-pass cutoff down
1511 {1515 {
1512 if (input.mouse.rightButtonPressed)1516 if (mouse.rightButtonPressed)
1513 {1517 {
1514 if (editor.lpCutOff >= 50)1518 if (editor.lpCutOff >= 50)
1515 editor.lpCutOff -= 50;1519 editor.lpCutOff -= 50;
@@ -1530,7 +1534,7 @@ static void handleRepeatedSamplerFilterButtons(void) · 14 unmodified lines
1530 1534
1531 case 2: // high-pass cutoff up1535 case 2: // high-pass cutoff up
1532 {1536 {
1533 if (input.mouse.rightButtonPressed)1537 if (mouse.rightButtonPressed)
1534 {1538 {
1535 if (editor.hpCutOff <= 0xFFFF-50)1539 if (editor.hpCutOff <= 0xFFFF-50)
1536 editor.hpCutOff += 50;1540 editor.hpCutOff += 50;
@@ -1554,7 +1558,7 @@ static void handleRepeatedSamplerFilterButtons(void) · 17 unmodified lines
1554 1558
1555 case 3: // high-pass cutoff down1559 case 3: // high-pass cutoff down
1556 {1560 {
1557 if (input.mouse.rightButtonPressed)1561 if (mouse.rightButtonPressed)
1558 {1562 {
1559 if (editor.hpCutOff >= 50)1563 if (editor.hpCutOff >= 50)
1560 editor.hpCutOff -= 50;1564 editor.hpCutOff -= 50;
@@ -1582,21 +1586,21 @@ void handleSamplerFiltersBox(void) · 21 unmodified lines
1582 uint8_t i;1586 uint8_t i;
1583 moduleSample_t *s;1587 moduleSample_t *s;
1584 1588
1585 if (input.mouse.rightButtonPressed && editor.ui.editTextFlag)1589 if (mouse.rightButtonPressed && editor.ui.editTextFlag)
1586 {1590 {
1587 exitGetTextLine(EDIT_TEXT_NO_UPDATE);1591 exitGetTextLine(EDIT_TEXT_NO_UPDATE);
1588 return;1592 return;
1589 }1593 }
1590 1594
1591 if (editor.ui.editTextFlag || input.mouse.lastSmpFilterButton > -1 || !input.mouse.leftButtonPressed)1595 if (editor.ui.editTextFlag || mouse.lastSmpFilterButton > -1 || !mouse.leftButtonPressed)
1592 return;1596 return;
1593 1597
1594 // restore sample ask dialog1598 // restore sample ask dialog
1595 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_RESTORE_SAMPLE)1599 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_RESTORE_SAMPLE)
1596 {1600 {
1597 if (input.mouse.y >= 71 && input.mouse.y <= 81)1601 if (mouse.y >= 71 && mouse.y <= 81)
1598 {1602 {
1599 if (input.mouse.x >= 171 && input.mouse.x <= 196)1603 if (mouse.x >= 171 && mouse.x <= 196)
1600 {1604 {
1601 // YES button1605 // YES button
1602 editor.ui.askScreenShown = false;1606 editor.ui.askScreenShown = false;
@@ -1604,7 +1608,7 @@ void handleSamplerFiltersBox(void) · 1 unmodified line
1604 editor.ui.answerYes = true;1608 editor.ui.answerYes = true;
1605 handleAskYes();1609 handleAskYes();
1606 }1610 }
1607 else if ((input.mouse.x >= 234) && (input.mouse.x <= 252))1611 else if ((mouse.x >= 234) && (mouse.x <= 252))
1608 {1612 {
1609 // NO button1613 // NO button
1610 editor.ui.askScreenShown = false;1614 editor.ui.askScreenShown = false;
@@ -1618,7 +1622,7 @@ void handleSamplerFiltersBox(void) · 7 unmodified lines
1618 }1622 }
1619 1623
1620 // FILTERS button (toggle)1624 // 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)
1622 {1626 {
1623 editor.ui.samplerFiltersBoxShown = false;1627 editor.ui.samplerFiltersBoxShown = false;
1624 removeSamplerFiltersBox();1628 removeSamplerFiltersBox();
@@ -1628,31 +1632,31 @@ void handleSamplerFiltersBox(void) · 3 unmodified lines
1628 // MAIN SCREEN STOP1632 // MAIN SCREEN STOP
1629 if (!editor.ui.diskOpScreenShown && !editor.ui.posEdScreenShown)1633 if (!editor.ui.diskOpScreenShown && !editor.ui.posEdScreenShown)
1630 {1634 {
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)
1632 {1636 {
1633 modStop();1637 modStop();
1634 return;1638 return;
1635 }1639 }
1636 }1640 }
1637 1641
1638 if (input.mouse.x >= 32 && input.mouse.x <= 95)1642 if (mouse.x >= 32 && mouse.x <= 95)
1639 {1643 {
1640 // SAMPLER SCREEN PLAY WAVEFORM1644 // SAMPLER SCREEN PLAY WAVEFORM
1641 if (input.mouse.y >= 211 && input.mouse.y <= 221)1645 if (mouse.y >= 211 && mouse.y <= 221)
1642 {1646 {
1643 samplerPlayWaveform();1647 samplerPlayWaveform();
1644 return;1648 return;
1645 }1649 }
1646 1650
1647 // SAMPLER SCREEN PLAY DISPLAY1651 // SAMPLER SCREEN PLAY DISPLAY
1648 else if (input.mouse.y >= 222 && input.mouse.y <= 232)1652 else if (mouse.y >= 222 && mouse.y <= 232)
1649 {1653 {
1650 samplerPlayDisplay();1654 samplerPlayDisplay();
1651 return;1655 return;
1652 }1656 }
1653 1657
1654 // SAMPLER SCREEN PLAY RANGE1658 // SAMPLER SCREEN PLAY RANGE
1655 else if (input.mouse.y >= 233 && input.mouse.y <= 243)1659 else if (mouse.y >= 233 && mouse.y <= 243)
1656 {1660 {
1657 samplerPlayRange();1661 samplerPlayRange();
1658 return;1662 return;
@@ -1660,7 +1664,7 @@ void handleSamplerFiltersBox(void) · 1 unmodified line
1660 }1664 }
1661 1665
1662 // SAMPLER SCREEN STOP1666 // 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)
1664 {1668 {
1665 for (i = 0; i < AMIGA_VOICES; i++)1669 for (i = 0; i < AMIGA_VOICES; i++)
1666 mixerKillVoice(i);1670 mixerKillVoice(i);
@@ -1668,7 +1672,7 @@ void handleSamplerFiltersBox(void) · 1 unmodified line
1668 }1672 }
1669 1673
1670 // UNDO1674 // 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)
1672 {1676 {
1673 s = &modEntry->samples[editor.currSample];1677 s = &modEntry->samples[editor.currSample];
1674 if (s->length == 0)1678 if (s->length == 0)
@@ -1686,10 +1690,10 @@ void handleSamplerFiltersBox(void) · 11 unmodified lines
1686 return;1690 return;
1687 }1691 }
1688 1692
1689 if (input.mouse.y >= 154 && input.mouse.y <= 164)1693 if (mouse.y >= 154 && mouse.y <= 164)
1690 {1694 {
1691 // DO LOW-PASS FILTER1695 // DO LOW-PASS FILTER
1692 if (input.mouse.x >= 76 && input.mouse.x <= 165)1696 if (mouse.x >= 76 && mouse.x <= 165)
1693 {1697 {
1694 lowPassSample(editor.lpCutOff);1698 lowPassSample(editor.lpCutOff);
1695 renderSamplerFiltersBox();1699 renderSamplerFiltersBox();
@@ -1697,9 +1701,9 @@ void handleSamplerFiltersBox(void) · 1 unmodified line
1697 }1701 }
1698 1702
1699 // LOW-PASS CUTOFF1703 // LOW-PASS CUTOFF
1700 else if (input.mouse.x >= 166 && input.mouse.x <= 217)1704 else if (mouse.x >= 166 && mouse.x <= 217)
1701 {1705 {
1702 if (input.mouse.rightButtonPressed)1706 if (mouse.rightButtonPressed)
1703 {1707 {
1704 editor.lpCutOff = 0;1708 editor.lpCutOff = 0;
1705 editor.ui.updateLPText = true;1709 editor.ui.updateLPText = true;
@@ -1718,10 +1722,10 @@ void handleSamplerFiltersBox(void) · 12 unmodified lines
1718 }1722 }
1719 1723
1720 // LOW-PASS CUTOFF UP1724 // LOW-PASS CUTOFF UP
1721 else if (input.mouse.x >= 218 && input.mouse.x <= 228)1725 else if (mouse.x >= 218 && mouse.x <= 228)
1722 {1726 {
1723 input.mouse.lastSmpFilterButton = 0;1727 mouse.lastSmpFilterButton = 0;
1724 if (input.mouse.rightButtonPressed)1728 if (mouse.rightButtonPressed)
1725 {1729 {
1726 if (editor.lpCutOff <= 0xFFFF-100)1730 if (editor.lpCutOff <= 0xFFFF-100)
1727 editor.lpCutOff += 100;1731 editor.lpCutOff += 100;
@@ -1744,10 +1748,10 @@ void handleSamplerFiltersBox(void) · 16 unmodified lines
1744 }1748 }
1745 1749
1746 // LOW-PASS CUTOFF DOWN1750 // LOW-PASS CUTOFF DOWN
1747 else if (input.mouse.x >= 229 && input.mouse.x <= 239)1751 else if (mouse.x >= 229 && mouse.x <= 239)
1748 {1752 {
1749 input.mouse.lastSmpFilterButton = 1;1753 mouse.lastSmpFilterButton = 1;
1750 if (input.mouse.rightButtonPressed)1754 if (mouse.rightButtonPressed)
1751 {1755 {
1752 if (editor.lpCutOff >= 100)1756 if (editor.lpCutOff >= 100)
1753 editor.lpCutOff -= 100;1757 editor.lpCutOff -= 100;
@@ -1767,10 +1771,10 @@ void handleSamplerFiltersBox(void) · 13 unmodified lines
1767 }1771 }
1768 }1772 }
1769 1773
1770 if (input.mouse.y >= 164 && input.mouse.y <= 174)1774 if (mouse.y >= 164 && mouse.y <= 174)
1771 {1775 {
1772 // DO HIGH-PASS FILTER1776 // DO HIGH-PASS FILTER
1773 if (input.mouse.x >= 76 && input.mouse.x <= 165)1777 if (mouse.x >= 76 && mouse.x <= 165)
1774 {1778 {
1775 highPassSample(editor.hpCutOff);1779 highPassSample(editor.hpCutOff);
1776 renderSamplerFiltersBox();1780 renderSamplerFiltersBox();
@@ -1778,9 +1782,9 @@ void handleSamplerFiltersBox(void) · 1 unmodified line
1778 }1782 }
1779 1783
1780 // HIGH-PASS CUTOFF1784 // HIGH-PASS CUTOFF
1781 else if (input.mouse.x >= 166 && input.mouse.x <= 217)1785 else if (mouse.x >= 166 && mouse.x <= 217)
1782 {1786 {
1783 if (input.mouse.rightButtonPressed)1787 if (mouse.rightButtonPressed)
1784 {1788 {
1785 editor.hpCutOff = 0;1789 editor.hpCutOff = 0;
1786 editor.ui.updateHPText = true;1790 editor.ui.updateHPText = true;
@@ -1799,10 +1803,10 @@ void handleSamplerFiltersBox(void) · 12 unmodified lines
1799 }1803 }
1800 1804
1801 // HIGH-PASS CUTOFF UP1805 // HIGH-PASS CUTOFF UP
1802 else if (input.mouse.x >= 218 && input.mouse.x <= 228)1806 else if (mouse.x >= 218 && mouse.x <= 228)
1803 {1807 {
1804 input.mouse.lastSmpFilterButton = 2;1808 mouse.lastSmpFilterButton = 2;
1805 if (input.mouse.rightButtonPressed)1809 if (mouse.rightButtonPressed)
1806 {1810 {
1807 if (editor.hpCutOff <= 0xFFFF-100)1811 if (editor.hpCutOff <= 0xFFFF-100)
1808 editor.hpCutOff += 100;1812 editor.hpCutOff += 100;
@@ -1825,10 +1829,10 @@ void handleSamplerFiltersBox(void) · 16 unmodified lines
1825 }1829 }
1826 1830
1827 // HIGH-PASS CUTOFF DOWN1831 // HIGH-PASS CUTOFF DOWN
1828 else if (input.mouse.x >= 229 && input.mouse.x <= 239)1832 else if (mouse.x >= 229 && mouse.x <= 239)
1829 {1833 {
1830 input.mouse.lastSmpFilterButton = 3;1834 mouse.lastSmpFilterButton = 3;
1831 if (input.mouse.rightButtonPressed)1835 if (mouse.rightButtonPressed)
1832 {1836 {
1833 if (editor.hpCutOff >= 100)1837 if (editor.hpCutOff >= 100)
1834 editor.hpCutOff -= 100;1838 editor.hpCutOff -= 100;
@@ -1849,7 +1853,7 @@ void handleSamplerFiltersBox(void) · 14 unmodified lines
1849 }1853 }
1850 1854
1851 // NORMALIZE SAMPLE FLAG1855 // 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)
1853 {1857 {
1854 editor.normalizeFiltersFlag ^= 1;1858 editor.normalizeFiltersFlag ^= 1;
1855 editor.ui.updateNormFlag = true;1859 editor.ui.updateNormFlag = true;
@@ -1857,7 +1861,7 @@ void handleSamplerFiltersBox(void) · 1 unmodified line
1857 }1861 }
1858 1862
1859 // EXIT1863 // 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)
1861 {1865 {
1862 editor.ui.samplerFiltersBoxShown = false;1866 editor.ui.samplerFiltersBoxShown = false;
1863 removeSamplerFiltersBox();1867 removeSamplerFiltersBox();
@@ -1866,7 +1870,7 @@ void handleSamplerFiltersBox(void) · 2 unmodified lines
1866 1870
1867static bool withinButtonRect(const guiButton_t *b)1871static bool withinButtonRect(const guiButton_t *b)
1868{1872{
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)
1870 return true;1874 return true;
1871 1875
1872 return false;1876 return false;
@@ -1900,7 +1904,7 @@ int32_t checkGUIButtons(void) · 27 unmodified lines
1900 }1904 }
1901 1905
1902 // QUIT (xy 0,0) works on all screens except for ask/clear screen1906 // 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)
1904 return PTB_QUIT;1908 return PTB_QUIT;
1905 1909
1906 // top screen buttons1910 // top screen buttons
@@ -1960,10 +1964,10 @@ void handleTextEditing(uint8_t mouseButton) · 53 unmodified lines
1960 }1964 }
1961 else if (mouseButton == SDL_BUTTON_LEFT && !editor.mixFlag)1965 else if (mouseButton == SDL_BUTTON_LEFT && !editor.mixFlag)
1962 {1966 {
1963 tmp16 = input.mouse.y - editor.ui.lineCurY;1967 tmp16 = mouse.y - editor.ui.lineCurY;
1964 if (tmp16 <= 2 && tmp16 >= -9)1968 if (tmp16 <= 2 && tmp16 >= -9)
1965 {1969 {
1966 tmp16 = (uint16_t)((input.mouse.x - editor.ui.lineCurX) + 4) >> 3;1970 tmp16 = (uint16_t)((mouse.x - editor.ui.lineCurX) + 4) >> 3;
1967 while (tmp16 != 0) // 0 = pos we want1971 while (tmp16 != 0) // 0 = pos we want
1968 {1972 {
1969 if (tmp16 > 0)1973 if (tmp16 > 0)
@@ -2038,7 +2042,7 @@ void mouseWheelUpHandler(void) · 68 unmodified lines
2038 if (editor.ui.editTextFlag || editor.ui.askScreenShown || editor.ui.clearScreenShown || editor.swapChannelFlag)2042 if (editor.ui.editTextFlag || editor.ui.askScreenShown || editor.ui.clearScreenShown || editor.swapChannelFlag)
2039 return;2043 return;
2040 2044
2041 if (input.mouse.y < 121)2045 if (mouse.y < 121)
2042 {2046 {
2043 // upper part of screen2047 // upper part of screen
2044 if (editor.ui.diskOpScreenShown)2048 if (editor.ui.diskOpScreenShown)
@@ -2069,7 +2073,7 @@ void mouseWheelDownHandler(void) · 24 unmodified lines
2069 if (editor.ui.editTextFlag || editor.ui.askScreenShown || editor.ui.clearScreenShown || editor.swapChannelFlag)2073 if (editor.ui.editTextFlag || editor.ui.askScreenShown || editor.ui.clearScreenShown || editor.swapChannelFlag)
2070 return;2074 return;
2071 2075
2072 if (input.mouse.y < 121)2076 if (mouse.y < 121)
2073 {2077 {
2074 // upper part of screen2078 // upper part of screen
2075 if (editor.ui.diskOpScreenShown)2079 if (editor.ui.diskOpScreenShown)
@@ -2097,7 +2101,7 @@ void mouseWheelDownHandler(void) · 21 unmodified lines
2097 2101
2098bool handleRightMouseButton(void)2102bool handleRightMouseButton(void)
2099{2103{
2100 if (!input.mouse.rightButtonPressed)2104 if (!mouse.rightButtonPressed)
2101 return false;2105 return false;
2102 2106
2103 // exit sample swap mode with right mouse button (if present)2107 // exit sample swap mode with right mouse button (if present)
@@ -2136,23 +2140,23 @@ bool handleRightMouseButton(void) · 32 unmodified lines
2136 }2140 }
2137 2141
2138 // toggle channel muting with right mouse button2142 // 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)
2140 {2144 {
2141 if (!editor.ui.posEdScreenShown && !editor.ui.editOpScreenShown && !editor.ui.diskOpScreenShown &&2145 if (!editor.ui.posEdScreenShown && !editor.ui.editOpScreenShown && !editor.ui.diskOpScreenShown &&
2142 !editor.ui.aboutScreenShown && !editor.ui.samplerVolBoxShown &&2146 !editor.ui.aboutScreenShown && !editor.ui.samplerVolBoxShown &&
2143 !editor.ui.samplerFiltersBoxShown && !editor.isWAVRendering)2147 !editor.ui.samplerFiltersBoxShown && !editor.isWAVRendering)
2144 {2148 {
2145 if (input.mouse.x > 127 && input.mouse.x <= 167) editor.muted[0] ^= 1;2149 if (mouse.x > 127 && mouse.x <= 167) editor.muted[0] ^= 1;
2146 else if (input.mouse.x > 175 && input.mouse.x <= 215) editor.muted[1] ^= 1;2150 else if (mouse.x > 175 && mouse.x <= 215) editor.muted[1] ^= 1;
2147 else if (input.mouse.x > 223 && input.mouse.x <= 263) editor.muted[2] ^= 1;2151 else if (mouse.x > 223 && mouse.x <= 263) editor.muted[2] ^= 1;
2148 else if (input.mouse.x > 271 && input.mouse.x <= 311) editor.muted[3] ^= 1;2152 else if (mouse.x > 271 && mouse.x <= 311) editor.muted[3] ^= 1;
2149 2153
2150 renderMuteButtons();2154 renderMuteButtons();
2151 }2155 }
2152 }2156 }
2153 2157
2154 // sample hand drawing2158 // 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 &&
2156 !editor.ui.samplerVolBoxShown && !editor.ui.samplerFiltersBoxShown)2160 !editor.ui.samplerVolBoxShown && !editor.ui.samplerFiltersBoxShown)
2157 {2161 {
2158 samplerEditSample(false);2162 samplerEditSample(false);
@@ -2185,9 +2189,9 @@ bool handleLeftMouseButton(void) · 26 unmodified lines
2185 // "downsample before loading sample" ask dialog2189 // "downsample before loading sample" ask dialog
2186 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_LOAD_DOWNSAMPLE)2190 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_LOAD_DOWNSAMPLE)
2187 {2191 {
2188 if (input.mouse.y >= 83 && input.mouse.y <= 93)2192 if (mouse.y >= 83 && mouse.y <= 93)
2189 {2193 {
2190 if (input.mouse.x >= 179 && input.mouse.x <= 204)2194 if (mouse.x >= 179 && mouse.x <= 204)
2191 {2195 {
2192 // YES button2196 // YES button
2193 editor.ui.askScreenShown = false;2197 editor.ui.askScreenShown = false;
@@ -2196,7 +2200,7 @@ bool handleLeftMouseButton(void) · 2 unmodified lines
2196 handleAskYes();2200 handleAskYes();
2197 return true;2201 return true;
2198 }2202 }
2199 else if (input.mouse.x >= 242 && input.mouse.x <= 260)2203 else if (mouse.x >= 242 && mouse.x <= 260)
2200 {2204 {
2201 // NO button2205 // NO button
2202 editor.ui.askScreenShown = false;2206 editor.ui.askScreenShown = false;
@@ -2213,7 +2217,7 @@ bool handleLeftMouseButton(void) · 10 unmodified lines
2213 // cancel note input gadgets with left/right mouse button2217 // cancel note input gadgets with left/right mouse button
2214 if (editor.ui.changingSmpResample || editor.ui.changingChordNote || editor.ui.changingDrumPadNote)2218 if (editor.ui.changingSmpResample || editor.ui.changingChordNote || editor.ui.changingDrumPadNote)
2215 {2219 {
2216 if (input.mouse.leftButtonPressed || input.mouse.rightButtonPressed)2220 if (mouse.leftButtonPressed || mouse.rightButtonPressed)
2217 {2221 {
2218 editor.ui.changingSmpResample = false;2222 editor.ui.changingSmpResample = false;
2219 editor.ui.changingChordNote = false;2223 editor.ui.changingChordNote = false;
@@ -2232,7 +2236,7 @@ bool handleLeftMouseButton(void) · 12 unmodified lines
2232 return true;2236 return true;
2233 }2237 }
2234 2238
2235 if (!input.mouse.leftButtonPressed)2239 if (!mouse.leftButtonPressed)
2236 return false;2240 return false;
2237 2241
2238 // handle QUIT ask dialog while Disk Op. filling is ongoing2242 // handle QUIT ask dialog while Disk Op. filling is ongoing
@@ -2240,9 +2244,9 @@ bool handleLeftMouseButton(void) · 1 unmodified line
2240 {2244 {
2241 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_QUIT)2245 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_QUIT)
2242 {2246 {
2243 if (input.mouse.y >= 71 && input.mouse.y <= 81)2247 if (mouse.y >= 71 && mouse.y <= 81)
2244 {2248 {
2245 if (input.mouse.x >= 171 && input.mouse.x <= 196)2249 if (mouse.x >= 171 && mouse.x <= 196)
2246 {2250 {
2247 // YES button2251 // YES button
2248 editor.ui.askScreenShown = false;2252 editor.ui.askScreenShown = false;
@@ -2250,7 +2254,7 @@ bool handleLeftMouseButton(void) · 1 unmodified line
2250 editor.ui.answerYes = true;2254 editor.ui.answerYes = true;
2251 handleAskYes();2255 handleAskYes();
2252 }2256 }
2253 else if (input.mouse.x >= 234 && input.mouse.x <= 252)2257 else if (mouse.x >= 234 && mouse.x <= 252)
2254 {2258 {
2255 // NO button2259 // NO button
2256 editor.ui.askScreenShown = false;2260 editor.ui.askScreenShown = false;
@@ -2269,7 +2273,7 @@ bool handleLeftMouseButton(void) · 12 unmodified lines
2269 {2273 {
2270 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_QUIT)2274 if (editor.ui.askScreenShown && editor.ui.askScreenType == ASK_QUIT)
2271 {2275 {
2272 if (input.mouse.x >= 171 && input.mouse.x <= 196)2276 if (mouse.x >= 171 && mouse.x <= 196)
2273 {2277 {
2274 // YES button2278 // YES button
2275 editor.isWAVRendering = false;2279 editor.isWAVRendering = false;
@@ -2280,7 +2284,7 @@ bool handleLeftMouseButton(void) · 4 unmodified lines
2280 editor.ui.answerYes = true;2284 editor.ui.answerYes = true;
2281 handleAskYes();2285 handleAskYes();
2282 }2286 }
2283 else if (input.mouse.x >= 234 && input.mouse.x <= 252)2287 else if (mouse.x >= 234 && mouse.x <= 252)
2284 {2288 {
2285 // NO button2289 // NO button
2286 editor.ui.askScreenShown = false;2290 editor.ui.askScreenShown = false;
@@ -2292,7 +2296,7 @@ bool handleLeftMouseButton(void) · 5 unmodified lines
2292 setStatusMessage("RENDERING MOD...", NO_CARRY);2296 setStatusMessage("RENDERING MOD...", NO_CARRY);
2293 }2297 }
2294 }2298 }
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)
2296 {2300 {
2297 // CANCEL button2301 // CANCEL button
2298 editor.abortMod2Wav = true;2302 editor.abortMod2Wav = true;
@@ -2310,12 +2314,12 @@ bool handleLeftMouseButton(void) · 11 unmodified lines
2310 2314
2311void updateMouseCounters(void)2315void updateMouseCounters(void)
2312{2316{
2313 if (input.mouse.buttonWaiting)2317 if (mouse.buttonWaiting)
2314 {2318 {
2315 if (++input.mouse.buttonWaitCounter > VBLANK_HZ/4) // quarter of a second2319 if (++mouse.buttonWaitCounter > VBLANK_HZ/4) // quarter of a second
2316 {2320 {
2317 input.mouse.buttonWaitCounter = 0;2321 mouse.buttonWaitCounter = 0;
2318 input.mouse.buttonWaiting = false;2322 mouse.buttonWaiting = false;
2319 }2323 }
2320 }2324 }
2321 2325
@@ -2465,7 +2469,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 143 unmodified lines
2465 2469
2466 case PTB_EO_QUANTIZE:2470 case PTB_EO_QUANTIZE:
2467 {2471 {
2468 editor.ui.tmpDisp16 = ptConfig.quantizeValue;2472 editor.ui.tmpDisp16 = config.quantizeValue;
2469 editor.quantizeValueDisp = &editor.ui.tmpDisp16;2473 editor.quantizeValueDisp = &editor.ui.tmpDisp16;
2470 editor.ui.numPtr16 = &editor.ui.tmpDisp16;2474 editor.ui.numPtr16 = &editor.ui.tmpDisp16;
2471 editor.ui.numLen = 2;2475 editor.ui.numLen = 2;
@@ -2573,7 +2577,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 101 unmodified lines
2573 2577
2574 case PTB_EO_MIX:2578 case PTB_EO_MIX:
2575 {2579 {
2576 if (!input.mouse.rightButtonPressed)2580 if (!mouse.rightButtonPressed)
2577 {2581 {
2578 editor.mixFlag = true;2582 editor.mixFlag = true;
2579 editor.ui.showTextPtr = editor.mixText;2583 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
2729 2733
2730 case PTB_EO_POS_NUM:2734 case PTB_EO_POS_NUM:
2731 {2735 {
2732 if (input.mouse.rightButtonPressed)2736 if (mouse.rightButtonPressed)
2733 {2737 {
2734 editor.samplePos = 0;2738 editor.samplePos = 0;
2735 editor.ui.updatePosText = true;2739 editor.ui.updatePosText = true;
@@ -2786,7 +2790,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 50 unmodified lines
2786 2790
2787 case PTB_EO_MOD_NUM:2791 case PTB_EO_MOD_NUM:
2788 {2792 {
2789 if (input.mouse.rightButtonPressed)2793 if (mouse.rightButtonPressed)
2790 {2794 {
2791 editor.modulateSpeed = 0;2795 editor.modulateSpeed = 0;
2792 editor.ui.updateModText = true;2796 editor.ui.updateModText = true;
@@ -3089,7 +3093,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 296 unmodified lines
3089 3093
3090 case PTB_EO_VOL_NUM:3094 case PTB_EO_VOL_NUM:
3091 {3095 {
3092 if (input.mouse.rightButtonPressed)3096 if (mouse.rightButtonPressed)
3093 {3097 {
3094 editor.sampleVol = 100;3098 editor.sampleVol = 100;
3095 editor.ui.updateVolText = true;3099 editor.ui.updateVolText = true;
@@ -3212,7 +3216,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 116 unmodified lines
3212 3216
3213 case PTB_EO_NOTE1:3217 case PTB_EO_NOTE1:
3214 {3218 {
3215 if (input.mouse.rightButtonPressed)3219 if (mouse.rightButtonPressed)
3216 {3220 {
3217 editor.note1 = 36;3221 editor.note1 = 36;
3218 }3222 }
@@ -3231,7 +3235,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 12 unmodified lines
3231 3235
3232 case PTB_EO_NOTE2:3236 case PTB_EO_NOTE2:
3233 {3237 {
3234 if (input.mouse.rightButtonPressed)3238 if (mouse.rightButtonPressed)
3235 {3239 {
3236 editor.note2 = 36;3240 editor.note2 = 36;
3237 }3241 }
@@ -3250,7 +3254,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 12 unmodified lines
3250 3254
3251 case PTB_EO_NOTE3:3255 case PTB_EO_NOTE3:
3252 {3256 {
3253 if (input.mouse.rightButtonPressed)3257 if (mouse.rightButtonPressed)
3254 {3258 {
3255 editor.note3 = 36;3259 editor.note3 = 36;
3256 }3260 }
@@ -3269,7 +3273,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 12 unmodified lines
3269 3273
3270 case PTB_EO_NOTE4:3274 case PTB_EO_NOTE4:
3271 {3275 {
3272 if (input.mouse.rightButtonPressed)3276 if (mouse.rightButtonPressed)
3273 {3277 {
3274 editor.note4 = 36;3278 editor.note4 = 36;
3275 }3279 }
@@ -3440,7 +3444,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 164 unmodified lines
3440 {3444 {
3441 if (modEntry->samples[editor.currSample].loopLength == 2 && modEntry->samples[editor.currSample].loopStart == 0)3445 if (modEntry->samples[editor.currSample].loopLength == 2 && modEntry->samples[editor.currSample].loopStart == 0)
3442 {3446 {
3443 editor.chordLengthMin = input.mouse.rightButtonPressed ? true : false;3447 editor.chordLengthMin = mouse.rightButtonPressed ? true : false;
3444 recalcChordLength();3448 recalcChordLength();
3445 }3449 }
3446 }3450 }
@@ -3563,7 +3567,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 116 unmodified lines
3563 {3567 {
3564 if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT)3568 if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT)
3565 {3569 {
3566 if (input.mouse.rightButtonPressed)3570 if (mouse.rightButtonPressed)
3567 {3571 {
3568 modEntry->currOrder = 0;3572 modEntry->currOrder = 0;
3569 editor.currPatternDisp = &modEntry->head.order[modEntry->currOrder];3573 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
3588 {3592 {
3589 if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT)3593 if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT)
3590 {3594 {
3591 if (input.mouse.rightButtonPressed)3595 if (mouse.rightButtonPressed)
3592 {3596 {
3593 modEntry->head.order[modEntry->currOrder] = 0;3597 modEntry->head.order[modEntry->currOrder] = 0;
3594 3598
@@ -3615,7 +3619,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 20 unmodified lines
3615 {3619 {
3616 if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT)3620 if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT)
3617 {3621 {
3618 if (input.mouse.rightButtonPressed)3622 if (mouse.rightButtonPressed)
3619 {3623 {
3620 modEntry->head.orderCount = 1;3624 modEntry->head.orderCount = 1;
3621 3625
@@ -3674,7 +3678,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 52 unmodified lines
3674 3678
3675 case PTB_SVOLUMES:3679 case PTB_SVOLUMES:
3676 {3680 {
3677 if (input.mouse.rightButtonPressed)3681 if (mouse.rightButtonPressed)
3678 {3682 {
3679 modEntry->samples[editor.currSample].volume = 0;3683 modEntry->samples[editor.currSample].volume = 0;
3680 }3684 }
@@ -3693,7 +3697,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 12 unmodified lines
3693 3697
3694 case PTB_SLENGTHS:3698 case PTB_SLENGTHS:
3695 {3699 {
3696 if (input.mouse.rightButtonPressed)3700 if (mouse.rightButtonPressed)
3697 {3701 {
3698 s = &modEntry->samples[editor.currSample];3702 s = &modEntry->samples[editor.currSample];
3699 3703
@@ -3730,7 +3734,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 30 unmodified lines
3730 3734
3731 case PTB_SREPEATS:3735 case PTB_SREPEATS:
3732 {3736 {
3733 if (input.mouse.rightButtonPressed)3737 if (mouse.rightButtonPressed)
3734 {3738 {
3735 s = &modEntry->samples[editor.currSample];3739 s = &modEntry->samples[editor.currSample];
3736 3740
@@ -3770,7 +3774,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 33 unmodified lines
3770 3774
3771 case PTB_SREPLENS:3775 case PTB_SREPLENS:
3772 {3776 {
3773 if (input.mouse.rightButtonPressed)3777 if (mouse.rightButtonPressed)
3774 {3778 {
3775 s = &modEntry->samples[editor.currSample];3779 s = &modEntry->samples[editor.currSample];
3776 3780
@@ -3813,12 +3817,17 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 36 unmodified lines
3813 3817
3814 case PTB_EDITOP:3818 case PTB_EDITOP:
3815 {3819 {
3816 if (editor.ui.editOpScreen == 3) // chord screen3820 if (editor.ui.editOpScreenShown)
3817 editor.ui.editOpScreen = 0;3821 {
3818 else if (editor.ui.editOpScreenShown)3822 if (editor.ui.editOpScreen == 3)
3819 editor.ui.editOpScreen = (editor.ui.editOpScreen + 1) % 3;3823 editor.ui.editOpScreen = 0;
3824 else
3825 editor.ui.editOpScreen = (editor.ui.editOpScreen + 1) % 3;
3826 }
3820 else3827 else
3828 {
3821 editor.ui.editOpScreenShown = true;3829 editor.ui.editOpScreenShown = true;
3830 }
3822 3831
3823 renderEditOpScreen();3832 renderEditOpScreen();
3824 }3833 }
@@ -3927,7 +3936,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 102 unmodified lines
3927 3936
3928 case PTB_SA_ZOOMBARAREA:3937 case PTB_SA_ZOOMBARAREA:
3929 {3938 {
3930 input.mouse.lastGUIButton = button;3939 mouse.lastGUIButton = button;
3931 if (!editor.ui.forceSampleDrag)3940 if (!editor.ui.forceSampleDrag)
3932 {3941 {
3933 samplerBarPressed(MOUSE_BUTTON_NOT_HELD);3942 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
4083 4092
4084 case PTB_DO_DATAPATH:4093 case PTB_DO_DATAPATH:
4085 {4094 {
4086 if (input.mouse.rightButtonPressed)4095 if (mouse.rightButtonPressed)
4087 {4096 {
4088 memset(editor.currPath, 0, PATH_MAX + 1);4097 memset(editor.currPath, 0, PATH_MAX + 1);
4089 editor.ui.updateDiskOpPathText = true;4098 editor.ui.updateDiskOpPathText = true;
@@ -4101,7 +4110,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 11 unmodified lines
4101 4110
4102 case PTB_SONGNAME:4111 case PTB_SONGNAME:
4103 {4112 {
4104 if (input.mouse.rightButtonPressed)4113 if (mouse.rightButtonPressed)
4105 {4114 {
4106 memset(modEntry->head.moduleTitle, 0, sizeof (modEntry->head.moduleTitle));4115 memset(modEntry->head.moduleTitle, 0, sizeof (modEntry->head.moduleTitle));
4107 editor.ui.updateSongName = true;4116 editor.ui.updateSongName = true;
@@ -4122,7 +4131,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 14 unmodified lines
4122 4131
4123 case PTB_SAMPLENAME:4132 case PTB_SAMPLENAME:
4124 {4133 {
4125 if (input.mouse.rightButtonPressed)4134 if (mouse.rightButtonPressed)
4126 {4135 {
4127 memset(modEntry->samples[editor.currSample].text, 0, sizeof (modEntry->samples[editor.currSample].text));4136 memset(modEntry->samples[editor.currSample].text, 0, sizeof (modEntry->samples[editor.currSample].text));
4128 editor.ui.updateCurrSampleName = true;4137 editor.ui.updateCurrSampleName = true;
@@ -4186,7 +4195,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 57 unmodified lines
4186 {4195 {
4187 editor.ui.aboutScreenShown = false;4196 editor.ui.aboutScreenShown = false;
4188 }4197 }
4189 else if (!input.mouse.rightButtonPressed)4198 else if (!mouse.rightButtonPressed)
4190 {4199 {
4191 editor.ui.visualizerMode = (editor.ui.visualizerMode + 1) % 2;4200 editor.ui.visualizerMode = (editor.ui.visualizerMode + 1) % 2;
4192 if (editor.ui.visualizerMode == VISUAL_SPECTRUM)4201 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
4212 4221
4213 case PTB_CHAN1:4222 case PTB_CHAN1:
4214 {4223 {
4215 if (input.mouse.rightButtonPressed)4224 if (mouse.rightButtonPressed)
4216 {4225 {
4217 editor.muted[0] = false;4226 editor.muted[0] = false;
4218 editor.muted[1] = true;4227 editor.muted[1] = true;
@@ -4230,7 +4239,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 11 unmodified lines
4230 4239
4231 case PTB_CHAN2:4240 case PTB_CHAN2:
4232 {4241 {
4233 if (input.mouse.rightButtonPressed)4242 if (mouse.rightButtonPressed)
4234 {4243 {
4235 editor.muted[0] = true;4244 editor.muted[0] = true;
4236 editor.muted[1] = false;4245 editor.muted[1] = false;
@@ -4248,7 +4257,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 11 unmodified lines
4248 4257
4249 case PTB_CHAN3:4258 case PTB_CHAN3:
4250 {4259 {
4251 if (input.mouse.rightButtonPressed)4260 if (mouse.rightButtonPressed)
4252 {4261 {
4253 editor.muted[0] = true;4262 editor.muted[0] = true;
4254 editor.muted[1] = true;4263 editor.muted[1] = true;
@@ -4266,7 +4275,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 11 unmodified lines
4266 4275
4267 case PTB_CHAN4:4276 case PTB_CHAN4:
4268 {4277 {
4269 if (input.mouse.rightButtonPressed)4278 if (mouse.rightButtonPressed)
4270 {4279 {
4271 editor.muted[0] = true;4280 editor.muted[0] = true;
4272 editor.muted[1] = true;4281 editor.muted[1] = true;
@@ -4285,7 +4294,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 12 unmodified lines
4285 case PTB_SAMPLER: samplerScreen(); break;4294 case PTB_SAMPLER: samplerScreen(); break;
4286 case PTB_SA_EXIT: exitFromSam(); break;4295 case PTB_SA_EXIT: exitFromSam(); break;
4287 4296
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;
4289 case PTB_DO_PARENT:4298 case PTB_DO_PARENT:
4290 {4299 {
4291#ifdef _WIN324300#ifdef _WIN32
@@ -4366,7 +4375,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 74 unmodified lines
4366 {4375 {
4367 editor.playMode = PLAY_MODE_NORMAL;4376 editor.playMode = PLAY_MODE_NORMAL;
4368 4377
4369 if (input.mouse.rightButtonPressed)4378 if (mouse.rightButtonPressed)
4370 modPlay(DONT_SET_PATTERN, modEntry->currOrder, modEntry->currRow);4379 modPlay(DONT_SET_PATTERN, modEntry->currOrder, modEntry->currRow);
4371 else4380 else
4372 modPlay(DONT_SET_PATTERN, modEntry->currOrder, DONT_SET_ROW);4381 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
4381 {4390 {
4382 editor.playMode = PLAY_MODE_PATTERN;4391 editor.playMode = PLAY_MODE_PATTERN;
4383 4392
4384 if (input.mouse.rightButtonPressed)4393 if (mouse.rightButtonPressed)
4385 modPlay(modEntry->currPattern, DONT_SET_ORDER, modEntry->currRow);4394 modPlay(modEntry->currPattern, DONT_SET_ORDER, modEntry->currRow);
4386 else4395 else
4387 modPlay(modEntry->currPattern, DONT_SET_ORDER, DONT_SET_ROW);4396 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
4411 {4420 {
4412 editor.playMode = PLAY_MODE_PATTERN;4421 editor.playMode = PLAY_MODE_PATTERN;
4413 4422
4414 if (input.mouse.rightButtonPressed)4423 if (mouse.rightButtonPressed)
4415 modPlay(modEntry->currPattern, DONT_SET_ORDER, modEntry->currRow);4424 modPlay(modEntry->currPattern, DONT_SET_ORDER, modEntry->currRow);
4416 else4425 else
4417 modPlay(modEntry->currPattern, DONT_SET_ORDER, DONT_SET_ROW);4426 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
4486 4495
4487 case PTB_SAMPLEU:4496 case PTB_SAMPLEU:
4488 {4497 {
4489 if (input.mouse.rightButtonPressed)4498 if (mouse.rightButtonPressed)
4490 {4499 {
4491 editor.sampleZero = true;4500 editor.sampleZero = true;
4492 editor.ui.updateCurrSampleNum = true;4501 editor.ui.updateCurrSampleNum = true;
@@ -4500,7 +4509,7 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 7 unmodified lines
4500 4509
4501 case PTB_SAMPLED:4510 case PTB_SAMPLED:
4502 {4511 {
4503 if (input.mouse.rightButtonPressed)4512 if (mouse.rightButtonPressed)
4504 {4513 {
4505 editor.sampleZero = true;4514 editor.sampleZero = true;
4506 editor.ui.updateCurrSampleNum = true;4515 editor.ui.updateCurrSampleNum = true;
@@ -4658,20 +4667,20 @@ static bool handleGUIButtons(int32_t button) // are you prepared to enter the ju · 151 unmodified lines
4658 default: displayErrorMsg("NOT IMPLEMENTED"); return false; // button not mapped4667 default: displayErrorMsg("NOT IMPLEMENTED"); return false; // button not mapped
4659 }4668 }
4660 4669
4661 input.mouse.lastGUIButton = button;4670 mouse.lastGUIButton = button;
4662 return false;4671 return false;
4663}4672}
4664 4673
4665static void handleRepeatedGUIButtons(void)4674static void handleRepeatedGUIButtons(void)
4666{4675{
4667 // repeat button4676 // repeat button
4668 switch (input.mouse.lastGUIButton)4677 switch (mouse.lastGUIButton)
4669 {4678 {
4670 case PTB_EO_NOTE1_UP:4679 case PTB_EO_NOTE1_UP:
4671 {4680 {
4672 if (input.mouse.repeatCounter >= 4)4681 if (mouse.repeatCounter >= 4)
4673 {4682 {
4674 input.mouse.repeatCounter = 0;4683 mouse.repeatCounter = 0;
4675 edNote1UpButton();4684 edNote1UpButton();
4676 }4685 }
4677 }4686 }
@@ -4679,9 +4688,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4679 4688
4680 case PTB_EO_NOTE1_DOWN:4689 case PTB_EO_NOTE1_DOWN:
4681 {4690 {
4682 if (input.mouse.repeatCounter >= 4)4691 if (mouse.repeatCounter >= 4)
4683 {4692 {
4684 input.mouse.repeatCounter = 0;4693 mouse.repeatCounter = 0;
4685 edNote1DownButton();4694 edNote1DownButton();
4686 }4695 }
4687 }4696 }
@@ -4689,9 +4698,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4689 4698
4690 case PTB_EO_NOTE2_UP:4699 case PTB_EO_NOTE2_UP:
4691 {4700 {
4692 if (input.mouse.repeatCounter >= 4)4701 if (mouse.repeatCounter >= 4)
4693 {4702 {
4694 input.mouse.repeatCounter = 0;4703 mouse.repeatCounter = 0;
4695 edNote2UpButton();4704 edNote2UpButton();
4696 }4705 }
4697 }4706 }
@@ -4699,9 +4708,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4699 4708
4700 case PTB_EO_NOTE2_DOWN:4709 case PTB_EO_NOTE2_DOWN:
4701 {4710 {
4702 if (input.mouse.repeatCounter >= 4)4711 if (mouse.repeatCounter >= 4)
4703 {4712 {
4704 input.mouse.repeatCounter = 0;4713 mouse.repeatCounter = 0;
4705 edNote2DownButton();4714 edNote2DownButton();
4706 }4715 }
4707 }4716 }
@@ -4709,9 +4718,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4709 4718
4710 case PTB_EO_NOTE3_UP:4719 case PTB_EO_NOTE3_UP:
4711 {4720 {
4712 if (input.mouse.repeatCounter >= 4)4721 if (mouse.repeatCounter >= 4)
4713 {4722 {
4714 input.mouse.repeatCounter = 0;4723 mouse.repeatCounter = 0;
4715 edNote3UpButton();4724 edNote3UpButton();
4716 }4725 }
4717 }4726 }
@@ -4719,9 +4728,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4719 4728
4720 case PTB_EO_NOTE3_DOWN:4729 case PTB_EO_NOTE3_DOWN:
4721 {4730 {
4722 if (input.mouse.repeatCounter >= 4)4731 if (mouse.repeatCounter >= 4)
4723 {4732 {
4724 input.mouse.repeatCounter = 0;4733 mouse.repeatCounter = 0;
4725 edNote3DownButton();4734 edNote3DownButton();
4726 }4735 }
4727 }4736 }
@@ -4729,9 +4738,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4729 4738
4730 case PTB_EO_NOTE4_UP:4739 case PTB_EO_NOTE4_UP:
4731 {4740 {
4732 if (input.mouse.repeatCounter >= 4)4741 if (mouse.repeatCounter >= 4)
4733 {4742 {
4734 input.mouse.repeatCounter = 0;4743 mouse.repeatCounter = 0;
4735 edNote4UpButton();4744 edNote4UpButton();
4736 }4745 }
4737 }4746 }
@@ -4739,9 +4748,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4739 4748
4740 case PTB_EO_NOTE4_DOWN:4749 case PTB_EO_NOTE4_DOWN:
4741 {4750 {
4742 if (input.mouse.repeatCounter >= 4)4751 if (mouse.repeatCounter >= 4)
4743 {4752 {
4744 input.mouse.repeatCounter = 0;4753 mouse.repeatCounter = 0;
4745 edNote4DownButton();4754 edNote4DownButton();
4746 }4755 }
4747 }4756 }
@@ -4749,9 +4758,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4749 4758
4750 case PTB_EO_VOL_UP:4759 case PTB_EO_VOL_UP:
4751 {4760 {
4752 if (input.mouse.repeatCounter >= 2)4761 if (mouse.repeatCounter >= 2)
4753 {4762 {
4754 input.mouse.repeatCounter = 0;4763 mouse.repeatCounter = 0;
4755 edVolUpButton();4764 edVolUpButton();
4756 }4765 }
4757 }4766 }
@@ -4759,9 +4768,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4759 4768
4760 case PTB_EO_VOL_DOWN:4769 case PTB_EO_VOL_DOWN:
4761 {4770 {
4762 if (input.mouse.repeatCounter >= 2)4771 if (mouse.repeatCounter >= 2)
4763 {4772 {
4764 input.mouse.repeatCounter = 0;4773 mouse.repeatCounter = 0;
4765 edVolDownButton();4774 edVolDownButton();
4766 }4775 }
4767 }4776 }
@@ -4769,9 +4778,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4769 4778
4770 case PTB_EO_MOD_UP:4779 case PTB_EO_MOD_UP:
4771 {4780 {
4772 if (input.mouse.repeatCounter >= 2)4781 if (mouse.repeatCounter >= 2)
4773 {4782 {
4774 input.mouse.repeatCounter = 0;4783 mouse.repeatCounter = 0;
4775 edModUpButton();4784 edModUpButton();
4776 }4785 }
4777 }4786 }
@@ -4779,9 +4788,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4779 4788
4780 case PTB_EO_MOD_DOWN:4789 case PTB_EO_MOD_DOWN:
4781 {4790 {
4782 if (input.mouse.repeatCounter >= 2)4791 if (mouse.repeatCounter >= 2)
4783 {4792 {
4784 input.mouse.repeatCounter = 0;4793 mouse.repeatCounter = 0;
4785 edModDownButton();4794 edModDownButton();
4786 }4795 }
4787 }4796 }
@@ -4789,9 +4798,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4789 4798
4790 case PTB_EO_POS_UP:4799 case PTB_EO_POS_UP:
4791 {4800 {
4792 if (input.mouse.repeatCounter >= 1)4801 if (mouse.repeatCounter >= 1)
4793 {4802 {
4794 input.mouse.repeatCounter = 0;4803 mouse.repeatCounter = 0;
4795 edPosUpButton(INCREMENT_FAST);4804 edPosUpButton(INCREMENT_FAST);
4796 }4805 }
4797 }4806 }
@@ -4799,9 +4808,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4799 4808
4800 case PTB_EO_POS_DOWN:4809 case PTB_EO_POS_DOWN:
4801 {4810 {
4802 if (input.mouse.repeatCounter >= 1)4811 if (mouse.repeatCounter >= 1)
4803 {4812 {
4804 input.mouse.repeatCounter = 0;4813 mouse.repeatCounter = 0;
4805 edPosDownButton(INCREMENT_FAST);4814 edPosDownButton(INCREMENT_FAST);
4806 }4815 }
4807 }4816 }
@@ -4809,9 +4818,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4809 4818
4810 case PTB_EO_FROM_UP:4819 case PTB_EO_FROM_UP:
4811 {4820 {
4812 if (input.mouse.repeatCounter >= 2)4821 if (mouse.repeatCounter >= 2)
4813 {4822 {
4814 input.mouse.repeatCounter = 0;4823 mouse.repeatCounter = 0;
4815 if (editor.sampleFrom < 0x1F)4824 if (editor.sampleFrom < 0x1F)
4816 {4825 {
4817 editor.sampleFrom++;4826 editor.sampleFrom++;
@@ -4823,9 +4832,9 @@ static void handleRepeatedGUIButtons(void) · 5 unmodified lines
4823 4832
4824 case PTB_EO_FROM_DOWN:4833 case PTB_EO_FROM_DOWN:
4825 {4834 {
4826 if (input.mouse.repeatCounter >= 2)4835 if (mouse.repeatCounter >= 2)
4827 {4836 {
4828 input.mouse.repeatCounter = 0;4837 mouse.repeatCounter = 0;
4829 if (editor.sampleFrom > 0x00)4838 if (editor.sampleFrom > 0x00)
4830 {4839 {
4831 editor.sampleFrom--;4840 editor.sampleFrom--;
@@ -4837,9 +4846,9 @@ static void handleRepeatedGUIButtons(void) · 5 unmodified lines
4837 4846
4838 case PTB_EO_TO_UP:4847 case PTB_EO_TO_UP:
4839 {4848 {
4840 if (input.mouse.repeatCounter >= 2)4849 if (mouse.repeatCounter >= 2)
4841 {4850 {
4842 input.mouse.repeatCounter = 0;4851 mouse.repeatCounter = 0;
4843 if (editor.sampleTo < 0x1F)4852 if (editor.sampleTo < 0x1F)
4844 {4853 {
4845 editor.sampleTo++;4854 editor.sampleTo++;
@@ -4851,9 +4860,9 @@ static void handleRepeatedGUIButtons(void) · 5 unmodified lines
4851 4860
4852 case PTB_EO_TO_DOWN:4861 case PTB_EO_TO_DOWN:
4853 {4862 {
4854 if (input.mouse.repeatCounter >= 2)4863 if (mouse.repeatCounter >= 2)
4855 {4864 {
4856 input.mouse.repeatCounter = 0;4865 mouse.repeatCounter = 0;
4857 if (editor.sampleTo > 0x00)4866 if (editor.sampleTo > 0x00)
4858 {4867 {
4859 editor.sampleTo--;4868 editor.sampleTo--;
@@ -4865,10 +4874,10 @@ static void handleRepeatedGUIButtons(void) · 5 unmodified lines
4865 4874
4866 case PTB_SAMPLEU:4875 case PTB_SAMPLEU:
4867 {4876 {
4868 if (input.mouse.repeatCounter >= 5)4877 if (mouse.repeatCounter >= 5)
4869 {4878 {
4870 input.mouse.repeatCounter = 0;4879 mouse.repeatCounter = 0;
4871 if (!input.mouse.rightButtonPressed)4880 if (!mouse.rightButtonPressed)
4872 sampleUpButton();4881 sampleUpButton();
4873 else4882 else
4874 editor.ui.updateCurrSampleNum = true;4883 editor.ui.updateCurrSampleNum = true;
@@ -4878,10 +4887,10 @@ static void handleRepeatedGUIButtons(void) · 3 unmodified lines
4878 4887
4879 case PTB_SAMPLED:4888 case PTB_SAMPLED:
4880 {4889 {
4881 if (input.mouse.repeatCounter >= 5)4890 if (mouse.repeatCounter >= 5)
4882 {4891 {
4883 input.mouse.repeatCounter = 0;4892 mouse.repeatCounter = 0;
4884 if (!input.mouse.rightButtonPressed)4893 if (!mouse.rightButtonPressed)
4885 sampleDownButton();4894 sampleDownButton();
4886 else4895 else
4887 editor.ui.updateCurrSampleNum = true;4896 editor.ui.updateCurrSampleNum = true;
@@ -4891,9 +4900,9 @@ static void handleRepeatedGUIButtons(void) · 3 unmodified lines
4891 4900
4892 case PTB_FTUNEU:4901 case PTB_FTUNEU:
4893 {4902 {
4894 if (input.mouse.repeatCounter >= 5)4903 if (mouse.repeatCounter >= 5)
4895 {4904 {
4896 input.mouse.repeatCounter = 0;4905 mouse.repeatCounter = 0;
4897 sampleFineTuneUpButton();4906 sampleFineTuneUpButton();
4898 }4907 }
4899 }4908 }
@@ -4901,9 +4910,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4901 4910
4902 case PTB_FTUNED:4911 case PTB_FTUNED:
4903 {4912 {
4904 if (input.mouse.repeatCounter >= 5)4913 if (mouse.repeatCounter >= 5)
4905 {4914 {
4906 input.mouse.repeatCounter = 0;4915 mouse.repeatCounter = 0;
4907 sampleFineTuneDownButton();4916 sampleFineTuneDownButton();
4908 }4917 }
4909 }4918 }
@@ -4911,9 +4920,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4911 4920
4912 case PTB_SVOLUMEU:4921 case PTB_SVOLUMEU:
4913 {4922 {
4914 if (input.mouse.repeatCounter >= 5)4923 if (mouse.repeatCounter >= 5)
4915 {4924 {
4916 input.mouse.repeatCounter = 0;4925 mouse.repeatCounter = 0;
4917 sampleVolumeUpButton();4926 sampleVolumeUpButton();
4918 }4927 }
4919 }4928 }
@@ -4921,9 +4930,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4921 4930
4922 case PTB_SVOLUMED:4931 case PTB_SVOLUMED:
4923 {4932 {
4924 if (input.mouse.repeatCounter >= 5)4933 if (mouse.repeatCounter >= 5)
4925 {4934 {
4926 input.mouse.repeatCounter = 0;4935 mouse.repeatCounter = 0;
4927 sampleVolumeDownButton();4936 sampleVolumeDownButton();
4928 }4937 }
4929 }4938 }
@@ -4931,9 +4940,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4931 4940
4932 case PTB_SLENGTHU:4941 case PTB_SLENGTHU:
4933 {4942 {
4934 if (input.mouse.rightButtonPressed || input.mouse.repeatCounter >= 1)4943 if (mouse.rightButtonPressed || mouse.repeatCounter >= 1)
4935 {4944 {
4936 input.mouse.repeatCounter = 0;4945 mouse.repeatCounter = 0;
4937 sampleLengthUpButton(INCREMENT_FAST);4946 sampleLengthUpButton(INCREMENT_FAST);
4938 }4947 }
4939 }4948 }
@@ -4941,9 +4950,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4941 4950
4942 case PTB_SLENGTHD:4951 case PTB_SLENGTHD:
4943 {4952 {
4944 if (input.mouse.rightButtonPressed || input.mouse.repeatCounter >= 1)4953 if (mouse.rightButtonPressed || mouse.repeatCounter >= 1)
4945 {4954 {
4946 input.mouse.repeatCounter = 0;4955 mouse.repeatCounter = 0;
4947 sampleLengthDownButton(INCREMENT_FAST);4956 sampleLengthDownButton(INCREMENT_FAST);
4948 }4957 }
4949 }4958 }
@@ -4951,9 +4960,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4951 4960
4952 case PTB_SREPEATU:4961 case PTB_SREPEATU:
4953 {4962 {
4954 if (input.mouse.rightButtonPressed || input.mouse.repeatCounter >= 1)4963 if (mouse.rightButtonPressed || mouse.repeatCounter >= 1)
4955 {4964 {
4956 input.mouse.repeatCounter = 0;4965 mouse.repeatCounter = 0;
4957 sampleRepeatUpButton(INCREMENT_FAST);4966 sampleRepeatUpButton(INCREMENT_FAST);
4958 }4967 }
4959 }4968 }
@@ -4961,9 +4970,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4961 4970
4962 case PTB_SREPEATD:4971 case PTB_SREPEATD:
4963 {4972 {
4964 if (input.mouse.rightButtonPressed || input.mouse.repeatCounter >= 1)4973 if (mouse.rightButtonPressed || mouse.repeatCounter >= 1)
4965 {4974 {
4966 input.mouse.repeatCounter = 0;4975 mouse.repeatCounter = 0;
4967 sampleRepeatDownButton(INCREMENT_FAST);4976 sampleRepeatDownButton(INCREMENT_FAST);
4968 }4977 }
4969 }4978 }
@@ -4971,9 +4980,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4971 4980
4972 case PTB_SREPLENU:4981 case PTB_SREPLENU:
4973 {4982 {
4974 if (input.mouse.rightButtonPressed || input.mouse.repeatCounter >= 1)4983 if (mouse.rightButtonPressed || mouse.repeatCounter >= 1)
4975 {4984 {
4976 input.mouse.repeatCounter = 0;4985 mouse.repeatCounter = 0;
4977 sampleRepeatLengthUpButton(INCREMENT_FAST);4986 sampleRepeatLengthUpButton(INCREMENT_FAST);
4978 }4987 }
4979 }4988 }
@@ -4981,9 +4990,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4981 4990
4982 case PTB_SREPLEND:4991 case PTB_SREPLEND:
4983 {4992 {
4984 if (input.mouse.rightButtonPressed || input.mouse.repeatCounter >= 1)4993 if (mouse.rightButtonPressed || mouse.repeatCounter >= 1)
4985 {4994 {
4986 input.mouse.repeatCounter = 0;4995 mouse.repeatCounter = 0;
4987 sampleRepeatLengthDownButton(INCREMENT_FAST);4996 sampleRepeatLengthDownButton(INCREMENT_FAST);
4988 }4997 }
4989 }4998 }
@@ -4991,9 +5000,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
4991 5000
4992 case PTB_TEMPOU:5001 case PTB_TEMPOU:
4993 {5002 {
4994 if (input.mouse.repeatCounter >= 3)5003 if (mouse.repeatCounter >= 3)
4995 {5004 {
4996 input.mouse.repeatCounter = 0;5005 mouse.repeatCounter = 0;
4997 tempoUpButton();5006 tempoUpButton();
4998 }5007 }
4999 }5008 }
@@ -5001,9 +5010,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
5001 5010
5002 case PTB_TEMPOD:5011 case PTB_TEMPOD:
5003 {5012 {
5004 if (input.mouse.repeatCounter >= 3)5013 if (mouse.repeatCounter >= 3)
5005 {5014 {
5006 input.mouse.repeatCounter = 0;5015 mouse.repeatCounter = 0;
5007 tempoDownButton();5016 tempoDownButton();
5008 }5017 }
5009 }5018 }
@@ -5011,9 +5020,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
5011 5020
5012 case PTB_LENGTHU:5021 case PTB_LENGTHU:
5013 {5022 {
5014 if (input.mouse.repeatCounter >= 7)5023 if (mouse.repeatCounter >= 7)
5015 {5024 {
5016 input.mouse.repeatCounter = 0;5025 mouse.repeatCounter = 0;
5017 songLengthUpButton();5026 songLengthUpButton();
5018 }5027 }
5019 }5028 }
@@ -5021,9 +5030,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
5021 5030
5022 case PTB_LENGTHD:5031 case PTB_LENGTHD:
5023 {5032 {
5024 if (input.mouse.repeatCounter >= 7)5033 if (mouse.repeatCounter >= 7)
5025 {5034 {
5026 input.mouse.repeatCounter = 0;5035 mouse.repeatCounter = 0;
5027 songLengthDownButton();5036 songLengthDownButton();
5028 }5037 }
5029 }5038 }
@@ -5031,9 +5040,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
5031 5040
5032 case PTB_PATTERNU:5041 case PTB_PATTERNU:
5033 {5042 {
5034 if (input.mouse.repeatCounter >= 7)5043 if (mouse.repeatCounter >= 7)
5035 {5044 {
5036 input.mouse.repeatCounter = 0;5045 mouse.repeatCounter = 0;
5037 patternUpButton();5046 patternUpButton();
5038 }5047 }
5039 }5048 }
@@ -5041,9 +5050,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
5041 5050
5042 case PTB_PATTERND:5051 case PTB_PATTERND:
5043 {5052 {
5044 if (input.mouse.repeatCounter >= 7)5053 if (mouse.repeatCounter >= 7)
5045 {5054 {
5046 input.mouse.repeatCounter = 0;5055 mouse.repeatCounter = 0;
5047 patternDownButton();5056 patternDownButton();
5048 }5057 }
5049 }5058 }
@@ -5051,9 +5060,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
5051 5060
5052 case PTB_POSU:5061 case PTB_POSU:
5053 {5062 {
5054 if (input.mouse.repeatCounter >= 7)5063 if (mouse.repeatCounter >= 7)
5055 {5064 {
5056 input.mouse.repeatCounter = 0;5065 mouse.repeatCounter = 0;
5057 positionUpButton();5066 positionUpButton();
5058 }5067 }
5059 }5068 }
@@ -5061,9 +5070,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
5061 5070
5062 case PTB_POSD:5071 case PTB_POSD:
5063 {5072 {
5064 if (input.mouse.repeatCounter >= 7)5073 if (mouse.repeatCounter >= 7)
5065 {5074 {
5066 input.mouse.repeatCounter = 0;5075 mouse.repeatCounter = 0;
5067 positionDownButton();5076 positionDownButton();
5068 }5077 }
5069 }5078 }
@@ -5071,9 +5080,9 @@ static void handleRepeatedGUIButtons(void) · 1 unmodified line
5071 5080
5072 case PTB_PE_SCROLLUP:5081 case PTB_PE_SCROLLUP:
5073 {5082 {
5074 if (input.mouse.repeatCounter >= 2)5083 if (mouse.repeatCounter >= 2)
5075 {5084 {
5076 input.mouse.repeatCounter = 0;5085 mouse.repeatCounter = 0;
5077 if (modEntry->currOrder > 0)5086 if (modEntry->currOrder > 0)
5078 modSetPos(modEntry->currOrder - 1, DONT_SET_ROW);5087 modSetPos(modEntry->currOrder - 1, DONT_SET_ROW);
5079 }5088 }
@@ -5082,9 +5091,9 @@ static void handleRepeatedGUIButtons(void) · 2 unmodified lines
5082 5091
5083 case PTB_PE_SCROLLDOWN:5092 case PTB_PE_SCROLLDOWN:
5084 {5093 {
5085 if (input.mouse.repeatCounter >= 2)5094 if (mouse.repeatCounter >= 2)
5086 {5095 {
5087 input.mouse.repeatCounter = 0;5096 mouse.repeatCounter = 0;
5088 if (modEntry->currOrder < modEntry->head.orderCount-1)5097 if (modEntry->currOrder < modEntry->head.orderCount-1)
5089 modSetPos(modEntry->currOrder + 1, DONT_SET_ROW);5098 modSetPos(modEntry->currOrder + 1, DONT_SET_ROW);
5090 }5099 }
@@ -5093,12 +5102,12 @@ static void handleRepeatedGUIButtons(void) · 2 unmodified lines
5093 5102
5094 case PTB_DO_SCROLLUP:5103 case PTB_DO_SCROLLUP:
5095 {5104 {
5096 if (input.mouse.repeatCounter >= 1)5105 if (mouse.repeatCounter >= 1)
5097 {5106 {
5098 input.mouse.repeatCounter = 0;5107 mouse.repeatCounter = 0;
5099 5108
5100 editor.diskop.scrollOffset--;5109 editor.diskop.scrollOffset--;
5101 if (input.mouse.rightButtonPressed)5110 if (mouse.rightButtonPressed)
5102 editor.diskop.scrollOffset -= 3;5111 editor.diskop.scrollOffset -= 3;
5103 5112
5104 if (editor.diskop.scrollOffset < 0)5113 if (editor.diskop.scrollOffset < 0)
@@ -5111,14 +5120,14 @@ static void handleRepeatedGUIButtons(void) · 6 unmodified lines
5111 5120
5112 case PTB_DO_SCROLLDOWN:5121 case PTB_DO_SCROLLDOWN:
5113 {5122 {
5114 if (input.mouse.repeatCounter >= 1)5123 if (mouse.repeatCounter >= 1)
5115 {5124 {
5116 input.mouse.repeatCounter = 0;5125 mouse.repeatCounter = 0;
5117 5126
5118 if (editor.diskop.numEntries > DISKOP_LINES)5127 if (editor.diskop.numEntries > DISKOP_LINES)
5119 {5128 {
5120 editor.diskop.scrollOffset++;5129 editor.diskop.scrollOffset++;
5121 if (input.mouse.rightButtonPressed)5130 if (mouse.rightButtonPressed)
5122 editor.diskop.scrollOffset += 3;5131 editor.diskop.scrollOffset += 3;
5123 5132
5124 if (editor.diskop.scrollOffset > editor.diskop.numEntries-DISKOP_LINES)5133 if (editor.diskop.scrollOffset > editor.diskop.numEntries-DISKOP_LINES)
@@ -5132,9 +5141,9 @@ static void handleRepeatedGUIButtons(void) · 7 unmodified lines
5132 5141
5133 case PTB_SA_ZOOMBARAREA:5142 case PTB_SA_ZOOMBARAREA:
5134 {5143 {
5135 if (input.mouse.repeatCounter >= 4)5144 if (mouse.repeatCounter >= 4)
5136 {5145 {
5137 input.mouse.repeatCounter = 0;5146 mouse.repeatCounter = 0;
5138 if (!editor.ui.forceSampleDrag)5147 if (!editor.ui.forceSampleDrag)
5139 samplerBarPressed(MOUSE_BUTTON_NOT_HELD);5148 samplerBarPressed(MOUSE_BUTTON_NOT_HELD);
5140 }5149 }
src/pt2_palette.c+17−24
@@ -1,28 +1,21 @@
1#include <stdint.h>
2#include "pt2_palette.h"1#include "pt2_palette.h"
3#include "pt2_header.h"2#include "pt2_header.h"
4#include "pt2_helpers.h"
5#include "pt2_tables.h"
6 3
7uint32_t palette[PALETTE_NUM] =4void setDefaultPalette(void)
8{5{
9 // -----------------------------6 video.palette[PAL_BACKGRD] = 0x000000;
10 0x000000, // 00- PAL_BACKGRD7 video.palette[PAL_BORDER] = 0xBBBBBB;
11 0xBBBBBB, // 01- PAL_BORDER8 video.palette[PAL_GENBKG] = 0x888888;
12 0x888888, // 02- PAL_GENBKG9 video.palette[PAL_GENBKG2] = 0x555555;
13 0x555555, // 03- PAL_GENBKG210 video.palette[PAL_QADSCP] = 0xFFDD00;
14 0xFFDD00, // 04- PAL_QADSCP11 video.palette[PAL_PATCURSOR] = 0xDD0044;
15 0xDD0044, // 05- PAL_PATCURSOR12 video.palette[PAL_GENTXT] = 0x000000;
16 0x000000, // 06- PAL_GENTXT13 video.palette[PAL_PATTXT] = 0x3344FF;
17 0x3344FF, // 07- PAL_PATTXT14 video.palette[PAL_SAMPLLINE] = 0x00FFFF;
18 // -----------------------------15 video.palette[PAL_LOOPPIN] = 0x0000FF;
19 0x00FFFF, // 08- PAL_SAMPLLINE16 video.palette[PAL_TEXTMARK] = 0x770077;
20 0x0000FF, // 09- PAL_LOOPPIN17 video.palette[PAL_MOUSE_1] = 0x444444;
21 0x770077, // 10- PAL_TEXTMARK18 video.palette[PAL_MOUSE_2] = 0x777777;
22 0x444444, // 11- PAL_MOUSE_119 video.palette[PAL_MOUSE_3] = 0xAAAAAA;
23 0x777777, // 12- PAL_MOUSE_220 video.palette[PAL_COLORKEY] = 0xC0FFEE;
24 0xAAAAAA, // 13- PAL_MOUSE_321}
25 // -----------------------------
26 0xC0FFEE // 14- PAL_COLORKEY
27 // -----------------------------
28};
src/pt2_palette.h+2−3
@@ -1,8 +1,5 @@
1#pragma once1#pragma once
2 2
3#include <stdint.h>
4#include <stdbool.h>
5
6enum3enum
7{4{
8 // -----------------------------5 // -----------------------------
@@ -26,3 +23,5 @@ enum · 17 unmodified lines
26 // -----------------------------23 // -----------------------------
27 PALETTE_NUM24 PALETTE_NUM
28};25};
26
27void setDefaultPalette(void);
src/pt2_patternviewer.c+74−74
@@ -33,11 +33,11 @@ static uint8_t periodToNote(int16_t period) · 32 unmodified lines
33 return 255; // illegal period33 return 255; // illegal period
34}34}
35 35
36void drawPatternNormal(uint32_t *frameBuffer)36static void drawPatternNormal(void)
37{37{
38 int8_t rowMiddlePos;38 int8_t rowMiddlePos;
39 uint8_t j, h, tempNote, rowDispCheck;39 uint8_t j, h, tempNote, rowDispCheck;
40 uint16_t putXOffset, putYOffset, rowData;40 uint16_t x, y, rowData;
41 const uint32_t *srcPtr;41 const uint32_t *srcPtr;
42 uint32_t bufferOffset, *dstPtr;42 uint32_t bufferOffset, *dstPtr;
43 note_t note;43 note_t note;
@@ -50,93 +50,93 @@ void drawPatternNormal(uint32_t *frameBuffer) · 6 unmodified lines
50 if (rowDispCheck < MOD_ROWS)50 if (rowDispCheck < MOD_ROWS)
51 {51 {
52 rowData = rowDispCheck * 4;52 rowData = rowDispCheck * 4;
53 putYOffset = 140 + (i * 7);53 y = 140 + (i * 7);
54 54
55 if (i == 7) // are we on the play row (middle)?55 if (i == 7) // are we on the play row (middle)?
56 {56 {
57 putYOffset++; // align font to play row (middle)57 y++; // align font to play row (middle)
58 58
59 // put current row number59 // 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]);
61 61
62 // pattern data62 // pattern data
63 for (j = 0; j < AMIGA_VOICES; j++)63 for (j = 0; j < AMIGA_VOICES; j++)
64 {64 {
65 note = modEntry->patterns[modEntry->currPattern][rowData + j];65 note = modEntry->patterns[modEntry->currPattern][rowData + j];
66 putXOffset = 26 + (j * 72);66 x = 26 + (j * 72);
67 67
68 if (note.period == 0)68 if (note.period == 0)
69 {69 {
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]);
71 }71 }
72 else72 else
73 {73 {
74 tempNote = periodToNote(note.period);74 tempNote = periodToNote(note.period);
75 if (tempNote == 255)75 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]);
77 else77 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]);
79 }79 }
80 80
81 if (ptConfig.blankZeroFlag)81 if (config.blankZeroFlag)
82 {82 {
83 if (note.sample & 0xF0)83 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]);
85 else85 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]);
87 }87 }
88 else88 else
89 {89 {
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]);
91 }91 }
92 92
93 printOneHexBigBg(frameBuffer, putXOffset + 38, putYOffset, note.sample & 0x0F, palette[PAL_GENTXT], palette[PAL_GENBKG]);93 printOneHexBigBg(x + 38, y, note.sample & 0x0F, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
94 printOneHexBigBg(frameBuffer, putXOffset + 46, putYOffset, note.command, palette[PAL_GENTXT], palette[PAL_GENBKG]);94 printOneHexBigBg(x + 46, y, note.command, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
95 printTwoHexBigBg(frameBuffer, putXOffset + 54, putYOffset, note.param, palette[PAL_GENTXT], palette[PAL_GENBKG]);95 printTwoHexBigBg(x + 54, y, note.param, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
96 }96 }
97 }97 }
98 else98 else
99 {99 {
100 if (i > 7)100 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)
102 102
103 // put current row number103 // 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]);
105 105
106 // pattern data106 // pattern data
107 for (j = 0; j < AMIGA_VOICES; j++)107 for (j = 0; j < AMIGA_VOICES; j++)
108 {108 {
109 note = modEntry->patterns[modEntry->currPattern][rowData + j];109 note = modEntry->patterns[modEntry->currPattern][rowData + j];
110 putXOffset = 26 + (j * 72);110 x = 26 + (j * 72);
111 111
112 if (note.period == 0)112 if (note.period == 0)
113 {113 {
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]);
115 }115 }
116 else116 else
117 {117 {
118 tempNote = periodToNote(note.period);118 tempNote = periodToNote(note.period);
119 if (tempNote == 255)119 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]);
121 else121 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]);
123 }123 }
124 124
125 if (ptConfig.blankZeroFlag)125 if (config.blankZeroFlag)
126 {126 {
127 if (note.sample & 0xF0)127 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]);
129 else129 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]);
131 }131 }
132 else132 else
133 {133 {
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]);
135 }135 }
136 136
137 printOneHexBg(frameBuffer, putXOffset + 38, putYOffset, note.sample & 0x0F, palette[PAL_PATTXT], palette[PAL_BACKGRD]);137 printOneHexBg(x + 38, y, note.sample & 0x0F, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
138 printOneHexBg(frameBuffer, putXOffset + 46, putYOffset, note.command, palette[PAL_PATTXT], palette[PAL_BACKGRD]);138 printOneHexBg(x + 46, y, note.command, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
139 printTwoHexBg(frameBuffer, putXOffset + 54, putYOffset, note.param, palette[PAL_PATTXT], palette[PAL_BACKGRD]);139 printTwoHexBg(x + 54, y, note.param, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
140 }140 }
141 }141 }
142 }142 }
@@ -147,7 +147,7 @@ void drawPatternNormal(uint32_t *frameBuffer) · 4 unmodified lines
147 if (modEntry->currRow <= 6)147 if (modEntry->currRow <= 6)
148 {148 {
149 srcPtr = &trackerFrameBMP[140 * SCREEN_W];149 srcPtr = &trackerFrameBMP[140 * SCREEN_W];
150 dstPtr = &frameBuffer[140 * SCREEN_W];150 dstPtr = &video.frameBuffer[140 * SCREEN_W];
151 memcpy(dstPtr, srcPtr, (SCREEN_W * sizeof (int32_t)) * ((7 - modEntry->currRow) * 7));151 memcpy(dstPtr, srcPtr, (SCREEN_W * sizeof (int32_t)) * ((7 - modEntry->currRow) * 7));
152 }152 }
153 else if (modEntry->currRow >= 57)153 else if (modEntry->currRow >= 57)
@@ -156,16 +156,16 @@ void drawPatternNormal(uint32_t *frameBuffer) · 2 unmodified lines
156 bufferOffset = (250 - h) * SCREEN_W;156 bufferOffset = (250 - h) * SCREEN_W;
157 157
158 srcPtr = &trackerFrameBMP[bufferOffset];158 srcPtr = &trackerFrameBMP[bufferOffset];
159 dstPtr = &frameBuffer[bufferOffset];159 dstPtr = &video.frameBuffer[bufferOffset];
160 memcpy(dstPtr, srcPtr, (SCREEN_W * sizeof (int32_t)) * h);160 memcpy(dstPtr, srcPtr, (SCREEN_W * sizeof (int32_t)) * h);
161 }161 }
162}162}
163 163
164void drawPatternDotted(uint32_t *frameBuffer)164static void drawPatternDotted(void)
165{165{
166 int8_t rowMiddlePos;166 int8_t rowMiddlePos;
167 uint8_t j, h, tempNote, rowDispCheck;167 uint8_t j, h, tempNote, rowDispCheck;
168 uint16_t putXOffset, putYOffset, rowData;168 uint16_t x, y, rowData;
169 const uint32_t *srcPtr;169 const uint32_t *srcPtr;
170 uint32_t bufferOffset, *dstPtr;170 uint32_t bufferOffset, *dstPtr;
171 note_t note;171 note_t note;
@@ -178,110 +178,110 @@ void drawPatternDotted(uint32_t *frameBuffer) · 6 unmodified lines
178 if (rowDispCheck < MOD_ROWS)178 if (rowDispCheck < MOD_ROWS)
179 {179 {
180 rowData = rowDispCheck * 4;180 rowData = rowDispCheck * 4;
181 putYOffset = 140 + (i * 7);181 y = 140 + (i * 7);
182 182
183 if (i == 7) // are we on the play row (middle)?183 if (i == 7) // are we on the play row (middle)?
184 {184 {
185 putYOffset++; // align font to play row (middle)185 y++; // align font to play row (middle)
186 186
187 // put current row number187 // 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]);
189 189
190 // pattern data190 // pattern data
191 for (j = 0; j < AMIGA_VOICES; j++)191 for (j = 0; j < AMIGA_VOICES; j++)
192 {192 {
193 note = modEntry->patterns[modEntry->currPattern][rowData + j];193 note = modEntry->patterns[modEntry->currPattern][rowData + j];
194 putXOffset = 26 + (j * 72);194 x = 26 + (j * 72);
195 195
196 if (note.period == 0)196 if (note.period == 0)
197 {197 {
198 charOutBigBg(frameBuffer, putXOffset + 6, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);198 charOutBigBg(x + 6, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
199 charOutBigBg(frameBuffer, putXOffset + 14, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);199 charOutBigBg(x + 14, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
200 charOutBigBg(frameBuffer, putXOffset + 22, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);200 charOutBigBg(x + 22, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
201 }201 }
202 else202 else
203 {203 {
204 tempNote = periodToNote(note.period);204 tempNote = periodToNote(note.period);
205 if (tempNote == 255)205 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]);
207 else207 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]);
209 }209 }
210 210
211 if (note.sample)211 if (note.sample)
212 {212 {
213 printOneHexBigBg(frameBuffer, putXOffset + 30, putYOffset, note.sample >> 4, palette[PAL_GENTXT], palette[PAL_GENBKG]);213 printOneHexBigBg(x + 30, y, note.sample >> 4, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
214 printOneHexBigBg(frameBuffer, putXOffset + 38, putYOffset, note.sample & 0x0F, palette[PAL_GENTXT], palette[PAL_GENBKG]);214 printOneHexBigBg(x + 38, y, note.sample & 0x0F, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
215 }215 }
216 else216 else
217 {217 {
218 charOutBigBg(frameBuffer, putXOffset + 30, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);218 charOutBigBg(x + 30, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
219 charOutBigBg(frameBuffer, putXOffset + 38, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);219 charOutBigBg(x + 38, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
220 }220 }
221 221
222 if ((note.command | note.param) == 0)222 if ((note.command | note.param) == 0)
223 {223 {
224 charOutBigBg(frameBuffer, putXOffset + 46, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);224 charOutBigBg(x + 46, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
225 charOutBigBg(frameBuffer, putXOffset + 54, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);225 charOutBigBg(x + 54, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
226 charOutBigBg(frameBuffer, putXOffset + 62, putYOffset, -128, palette[PAL_GENTXT], palette[PAL_GENBKG]);226 charOutBigBg(x + 62, y, -128, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
227 }227 }
228 else228 else
229 {229 {
230 printOneHexBigBg(frameBuffer, putXOffset + 46, putYOffset, note.command, palette[PAL_GENTXT], palette[PAL_GENBKG]);230 printOneHexBigBg(x + 46, y, note.command, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
231 printTwoHexBigBg(frameBuffer, putXOffset + 54, putYOffset, note.param, palette[PAL_GENTXT], palette[PAL_GENBKG]);231 printTwoHexBigBg(x + 54, y, note.param, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
232 }232 }
233 }233 }
234 }234 }
235 else235 else
236 {236 {
237 if (i > 7)237 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)
239 239
240 // put current row number240 // 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]);
242 242
243 // pattern data243 // pattern data
244 for (j = 0; j < AMIGA_VOICES; j++)244 for (j = 0; j < AMIGA_VOICES; j++)
245 {245 {
246 note = modEntry->patterns[modEntry->currPattern][rowData + j];246 note = modEntry->patterns[modEntry->currPattern][rowData + j];
247 putXOffset = 26 + (j * 72);247 x = 26 + (j * 72);
248 248
249 if (note.period == 0)249 if (note.period == 0)
250 {250 {
251 charOutBg(frameBuffer, putXOffset + 6, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);251 charOutBg(x + 6, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
252 charOutBg(frameBuffer, putXOffset + 14, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);252 charOutBg(x + 14, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
253 charOutBg(frameBuffer, putXOffset + 22, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);253 charOutBg(x + 22, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
254 }254 }
255 else255 else
256 {256 {
257 tempNote = periodToNote(note.period);257 tempNote = periodToNote(note.period);
258 if (tempNote == 255)258 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]);
260 else260 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]);
262 }262 }
263 263
264 if (note.sample)264 if (note.sample)
265 {265 {
266 printOneHexBg(frameBuffer, putXOffset + 30, putYOffset, note.sample >> 4, palette[PAL_PATTXT], palette[PAL_BACKGRD]);266 printOneHexBg(x + 30, y, note.sample >> 4, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
267 printOneHexBg(frameBuffer, putXOffset + 38, putYOffset, note.sample & 0x0F, palette[PAL_PATTXT], palette[PAL_BACKGRD]);267 printOneHexBg(x + 38, y, note.sample & 0x0F, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
268 }268 }
269 else269 else
270 {270 {
271 charOutBg(frameBuffer, putXOffset + 30, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);271 charOutBg(x + 30, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
272 charOutBg(frameBuffer, putXOffset + 38, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);272 charOutBg(x + 38, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
273 }273 }
274 274
275 if ((note.command | note.param) == 0)275 if ((note.command | note.param) == 0)
276 {276 {
277 charOutBg(frameBuffer, putXOffset + 46, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);277 charOutBg(x + 46, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
278 charOutBg(frameBuffer, putXOffset + 54, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);278 charOutBg(x + 54, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
279 charOutBg(frameBuffer, putXOffset + 62, putYOffset, -128, palette[PAL_PATTXT], palette[PAL_BACKGRD]);279 charOutBg(x + 62, y, -128, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
280 }280 }
281 else281 else
282 {282 {
283 printOneHexBg(frameBuffer, putXOffset + 46, putYOffset, note.command, palette[PAL_PATTXT], palette[PAL_BACKGRD]);283 printOneHexBg(x + 46, y, note.command, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
284 printTwoHexBg(frameBuffer, putXOffset + 54, putYOffset, note.param, palette[PAL_PATTXT], palette[PAL_BACKGRD]);284 printTwoHexBg(x + 54, y, note.param, video.palette[PAL_PATTXT], video.palette[PAL_BACKGRD]);
285 }285 }
286 }286 }
287 }287 }
@@ -293,7 +293,7 @@ void drawPatternDotted(uint32_t *frameBuffer) · 5 unmodified lines
293 if (modEntry->currRow <= 6)293 if (modEntry->currRow <= 6)
294 {294 {
295 srcPtr = &trackerFrameBMP[140 * SCREEN_W];295 srcPtr = &trackerFrameBMP[140 * SCREEN_W];
296 dstPtr = &frameBuffer[140 * SCREEN_W];296 dstPtr = &video.frameBuffer[140 * SCREEN_W];
297 memcpy(dstPtr, srcPtr, (SCREEN_W * sizeof (int32_t)) * ((7 - modEntry->currRow) * 7));297 memcpy(dstPtr, srcPtr, (SCREEN_W * sizeof (int32_t)) * ((7 - modEntry->currRow) * 7));
298 }298 }
299 else if (modEntry->currRow >= 57)299 else if (modEntry->currRow >= 57)
@@ -302,15 +302,15 @@ void drawPatternDotted(uint32_t *frameBuffer) · 2 unmodified lines
302 bufferOffset = (250 - h) * SCREEN_W;302 bufferOffset = (250 - h) * SCREEN_W;
303 303
304 srcPtr = &trackerFrameBMP[bufferOffset];304 srcPtr = &trackerFrameBMP[bufferOffset];
305 dstPtr = &frameBuffer[bufferOffset];305 dstPtr = &video.frameBuffer[bufferOffset];
306 memcpy(dstPtr, srcPtr, (SCREEN_W * sizeof (int32_t)) * h);306 memcpy(dstPtr, srcPtr, (SCREEN_W * sizeof (int32_t)) * h);
307 }307 }
308}308}
309 309
310void redrawPattern(uint32_t *frameBuffer)310void redrawPattern(void)
311{311{
312 if (ptConfig.pattDots)312 if (config.pattDots)
313 drawPatternDotted(frameBuffer);313 drawPatternDotted();
314 else314 else
315 drawPatternNormal(frameBuffer);315 drawPatternNormal();
316}316}
src/pt2_patternviewer.h+1−3
@@ -1,5 +1,3 @@
1#pragma once1#pragma once
2 2
3#include <stdint.h>3void redrawPattern(void);
4
5void redrawPattern(uint32_t *frameBuffer);
src/pt2_sampleloader.c+10−10
@@ -289,7 +289,7 @@ bool loadWAVSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling) · 288 unmodified lines
289 // 2x downsampling - remove every other sample (if needed)289 // 2x downsampling - remove every other sample (if needed)
290 if (forceDownSampling)290 if (forceDownSampling)
291 {291 {
292 if (ptConfig.sampleLowpass)292 if (config.sampleLowpass)
293 lowPassSample8BitUnsigned(audioDataU8, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);293 lowPassSample8BitUnsigned(audioDataU8, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
294 294
295 sampleLength /= 2;295 sampleLength /= 2;
@@ -348,7 +348,7 @@ bool loadWAVSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling) · 52 unmodified lines
348 // 2x downsampling - remove every other sample (if needed)348 // 2x downsampling - remove every other sample (if needed)
349 if (forceDownSampling)349 if (forceDownSampling)
350 {350 {
351 if (ptConfig.sampleLowpass)351 if (config.sampleLowpass)
352 lowPassSample16Bit(audioDataS16, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);352 lowPassSample16Bit(audioDataS16, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
353 353
354 sampleLength /= 2;354 sampleLength /= 2;
@@ -410,7 +410,7 @@ bool loadWAVSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling) · 55 unmodified lines
410 // 2x downsampling - remove every other sample (if needed)410 // 2x downsampling - remove every other sample (if needed)
411 if (forceDownSampling)411 if (forceDownSampling)
412 {412 {
413 if (ptConfig.sampleLowpass)413 if (config.sampleLowpass)
414 lowPassSample32Bit(audioDataS32, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);414 lowPassSample32Bit(audioDataS32, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
415 415
416 sampleLength /= 2;416 sampleLength /= 2;
@@ -473,7 +473,7 @@ bool loadWAVSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling) · 56 unmodified lines
473 // 2x downsampling - remove every other sample (if needed)473 // 2x downsampling - remove every other sample (if needed)
474 if (forceDownSampling)474 if (forceDownSampling)
475 {475 {
476 if (ptConfig.sampleLowpass)476 if (config.sampleLowpass)
477 lowPassSample32Bit(audioDataS32, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);477 lowPassSample32Bit(audioDataS32, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
478 478
479 sampleLength /= 2;479 sampleLength /= 2;
@@ -536,7 +536,7 @@ bool loadWAVSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling) · 56 unmodified lines
536 // 2x downsampling - remove every other sample (if needed)536 // 2x downsampling - remove every other sample (if needed)
537 if (forceDownSampling)537 if (forceDownSampling)
538 {538 {
539 if (ptConfig.sampleLowpass)539 if (config.sampleLowpass)
540 lowPassSampleFloat(fAudioDataFloat, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);540 lowPassSampleFloat(fAudioDataFloat, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
541 541
542 sampleLength /= 2;542 sampleLength /= 2;
@@ -605,7 +605,7 @@ bool loadWAVSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling) · 62 unmodified lines
605 // 2x downsampling - remove every other sample (if needed)605 // 2x downsampling - remove every other sample (if needed)
606 if (forceDownSampling)606 if (forceDownSampling)
607 {607 {
608 if (ptConfig.sampleLowpass)608 if (config.sampleLowpass)
609 lowPassSampleDouble(dAudioDataDouble, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);609 lowPassSampleDouble(dAudioDataDouble, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
610 610
611 sampleLength /= 2;611 sampleLength /= 2;
@@ -1295,7 +1295,7 @@ bool loadAIFFSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling · 683 unmodified lines
1295 // 2x downsampling - remove every other sample (if needed)1295 // 2x downsampling - remove every other sample (if needed)
1296 if (forceDownSampling)1296 if (forceDownSampling)
1297 {1297 {
1298 if (ptConfig.sampleLowpass)1298 if (config.sampleLowpass)
1299 lowPassSample8Bit(audioDataS8, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);1299 lowPassSample8Bit(audioDataS8, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
1300 1300
1301 sampleLength /= 2;1301 sampleLength /= 2;
@@ -1358,7 +1358,7 @@ bool loadAIFFSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling · 56 unmodified lines
1358 // 2x downsampling - remove every other sample (if needed)1358 // 2x downsampling - remove every other sample (if needed)
1359 if (forceDownSampling)1359 if (forceDownSampling)
1360 {1360 {
1361 if (ptConfig.sampleLowpass)1361 if (config.sampleLowpass)
1362 lowPassSample16Bit(audioDataS16, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);1362 lowPassSample16Bit(audioDataS16, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
1363 1363
1364 sampleLength /= 2;1364 sampleLength /= 2;
@@ -1428,7 +1428,7 @@ bool loadAIFFSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling · 63 unmodified lines
1428 // 2x downsampling - remove every other sample (if needed)1428 // 2x downsampling - remove every other sample (if needed)
1429 if (forceDownSampling)1429 if (forceDownSampling)
1430 {1430 {
1431 if (ptConfig.sampleLowpass)1431 if (config.sampleLowpass)
1432 lowPassSample32Bit(audioDataS32, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);1432 lowPassSample32Bit(audioDataS32, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
1433 1433
1434 sampleLength /= 2;1434 sampleLength /= 2;
@@ -1495,7 +1495,7 @@ bool loadAIFFSample(UNICHAR *fileName, char *entryName, int8_t forceDownSampling · 60 unmodified lines
1495 // 2x downsampling - remove every other sample (if needed)1495 // 2x downsampling - remove every other sample (if needed)
1496 if (forceDownSampling)1496 if (forceDownSampling)
1497 {1497 {
1498 if (ptConfig.sampleLowpass)1498 if (config.sampleLowpass)
1499 lowPassSample32Bit(audioDataS32, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);1499 lowPassSample32Bit(audioDataS32, sampleLength, sampleRate, sampleRate / DOWNSAMPLE_CUTOFF_FACTOR);
1500 1500
1501 sampleLength /= 2;1501 sampleLength /= 2;
src/pt2_sampler.c+149−151
@@ -32,7 +32,7 @@ typedef struct sampleMixer_t · 31 unmodified lines
32 uint32_t posFrac, delta;32 uint32_t posFrac, delta;
33} sampleMixer_t;33} sampleMixer_t;
34 34
35static int32_t samOffsetScaled;35static int32_t samOffsetScaled, lastDrawX, lastDrawY;
36static uint32_t waveInvertTable[8];36static uint32_t waveInvertTable[8];
37 37
38static const int8_t tuneToneData[32] = // Tuning Tone (Sine Wave)38static 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
43 -127,-126,-118,-106, -91, -71, -49, -2543 -127,-126,-118,-106, -91, -71, -49, -25
44};44};
45 45
46extern uint32_t *pixelBuffer; // pt_main.c
47
48void setLoopSprites(void);46void setLoopSprites(void);
49 47
50void createSampleMarkTable(void)48void createSampleMarkTable(void)
51{49{
52 // used for invertRange() (sample data marking)50 // used for invertRange() (sample data marking)
53 51
54 waveInvertTable[0] = 0x00000000 | palette[PAL_BACKGRD];52 waveInvertTable[0] = 0x00000000 | video.palette[PAL_BACKGRD];
55 waveInvertTable[1] = 0x01000000 | palette[PAL_QADSCP];53 waveInvertTable[1] = 0x01000000 | video.palette[PAL_QADSCP];
56 waveInvertTable[2] = 0x02000000 | CENTER_LINE_COLOR;54 waveInvertTable[2] = 0x02000000 | CENTER_LINE_COLOR;
57 waveInvertTable[3] = 0x03000000; // spacer, not used55 waveInvertTable[3] = 0x03000000; // spacer, not used
58 waveInvertTable[4] = 0x04000000 | MARK_COLOR_1;56 waveInvertTable[4] = 0x04000000 | MARK_COLOR_1;
@@ -106,10 +104,10 @@ void fillSampleFilterUndoBuffer(void) · 47 unmodified lines
106 }104 }
107}105}
108 106
109static void sampleLine(uint32_t *frameBuffer, int16_t line_x1, int16_t line_x2, int16_t line_y1, int16_t line_y2)107static void sampleLine(int16_t line_x1, int16_t line_x2, int16_t line_y1, int16_t line_y2)
110{108{
111 int16_t d, x, y, ax, ay, sx, sy, dx, dy;109 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];
113 111
114 assert(line_x1 >= 0 || line_x2 >= 0 || line_x1 < SCREEN_W || line_x2 < SCREEN_W);112 assert(line_x1 >= 0 || line_x2 >= 0 || line_x1 < SCREEN_W || line_x2 < SCREEN_W);
115 assert(line_y1 >= 0 || line_y2 >= 0 || line_y1 < SCREEN_H || line_y2 < SCREEN_H);113 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
130 {128 {
131 assert(y >= 0 || x >= 0 || y < SCREEN_H || x < SCREEN_W);129 assert(y >= 0 || x >= 0 || y < SCREEN_H || x < SCREEN_W);
132 130
133 frameBuffer[(y * SCREEN_W) + x] = color;131 video.frameBuffer[(y * SCREEN_W) + x] = color;
134 132
135 if (x == line_x2)133 if (x == line_x2)
136 break;134 break;
@@ -152,7 +150,7 @@ static void sampleLine(uint32_t *frameBuffer, int16_t line_x1, int16_t line_x2, · 15 unmodified lines
152 {150 {
153 assert(y >= 0 || x >= 0 || y < SCREEN_H || x < SCREEN_W);151 assert(y >= 0 || x >= 0 || y < SCREEN_H || x < SCREEN_W);
154 152
155 frameBuffer[(y * SCREEN_W) + x] = color;153 video.frameBuffer[(y * SCREEN_W) + x] = color;
156 154
157 if (y == line_y2)155 if (y == line_y2)
158 break;156 break;
@@ -192,9 +190,9 @@ static void setDragBar(void) · 33 unmodified lines
192 190
193 // draw drag bar191 // draw drag bar
194 192
195 dstPtr = &pixelBuffer[206 * SCREEN_W];193 dstPtr = &video.frameBuffer[206 * SCREEN_W];
196 pixel = palette[PAL_QADSCP];194 pixel = video.palette[PAL_QADSCP];
197 bgPixel = palette[PAL_BACKGRD];195 bgPixel = video.palette[PAL_BACKGRD];
198 196
199 for (int32_t y = 0; y < 4; y++)197 for (int32_t y = 0; y < 4; y++)
200 {198 {
@@ -213,8 +211,8 @@ static void setDragBar(void) · 12 unmodified lines
213 {211 {
214 // clear drag bar background212 // clear drag bar background
215 213
216 dstPtr = &pixelBuffer[(206 * SCREEN_W) + 4];214 dstPtr = &video.frameBuffer[(206 * SCREEN_W) + 4];
217 pixel = palette[PAL_BACKGRD];215 pixel = video.palette[PAL_BACKGRD];
218 216
219 for (int32_t y = 0; y < 4; y++)217 for (int32_t y = 0; y < 4; y++)
220 {218 {
@@ -264,6 +262,9 @@ int32_t scr2SmpPos(int32_t x) // screen x pos -> sample pos · 43 unmodified lines
264 x += samOffsetScaled;262 x += samOffsetScaled;
265 x = (uint32_t)(x * editor.sampler.samDisplay) / SAMPLE_AREA_WIDTH; // truncate here263 x = (uint32_t)(x * editor.sampler.samDisplay) / SAMPLE_AREA_WIDTH; // truncate here
266 264
265 if (x > editor.sampler.samLength)
266 x = editor.sampler.samLength;
267
267 return x;268 return x;
268}269}
269 270
@@ -297,8 +298,8 @@ static void renderSampleData(void) · 27 unmodified lines
297 298
298 // clear sample data background299 // clear sample data background
299 300
300 dstPtr = &pixelBuffer[(138 * SCREEN_W) + 3];301 dstPtr = &video.frameBuffer[(138 * SCREEN_W) + 3];
301 pixel = palette[PAL_BACKGRD];302 pixel = video.palette[PAL_BACKGRD];
302 303
303 for (y = 0; y < SAMPLE_VIEW_HEIGHT; y++)304 for (y = 0; y < SAMPLE_VIEW_HEIGHT; y++)
304 {305 {
@@ -309,9 +310,9 @@ static void renderSampleData(void) · 4 unmodified lines
309 }310 }
310 311
311 // display center line312 // display center line
312 if (ptConfig.dottedCenterFlag)313 if (config.dottedCenterFlag)
313 {314 {
314 dstPtr = &pixelBuffer[(SAMPLE_AREA_Y_CENTER * SCREEN_W) + 3];315 dstPtr = &video.frameBuffer[(SAMPLE_AREA_Y_CENTER * SCREEN_W) + 3];
315 for (x = 0; x < SAMPLE_AREA_WIDTH; x++)316 for (x = 0; x < SAMPLE_AREA_WIDTH; x++)
316 dstPtr[x] = 0x02000000 | CENTER_LINE_COLOR;317 dstPtr[x] = 0x02000000 | CENTER_LINE_COLOR;
317 }318 }
@@ -327,7 +328,7 @@ static void renderSampleData(void) · 9 unmodified lines
327 for (x = 1; x < SAMPLE_AREA_WIDTH; x++)328 for (x = 1; x < SAMPLE_AREA_WIDTH; x++)
328 {329 {
329 y2 = SAMPLE_AREA_Y_CENTER - getScaledSample(scr2SmpPos(x));330 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);
331 y1 = y2;332 y1 = y2;
332 }333 }
333 }334 }
@@ -355,11 +356,11 @@ static void renderSampleData(void) · 21 unmodified lines
355 356
356 if (x > 0)357 if (x > 0)
357 {358 {
358 if (min > oldMax) sampleLine(pixelBuffer, x + 2, x + 3, oldMax, min);359 if (min > oldMax) sampleLine(x + 2, x + 3, oldMax, min);
359 if (max < oldMin) sampleLine(pixelBuffer, x + 2, x + 3, oldMin, max);360 if (max < oldMin) sampleLine(x + 2, x + 3, oldMin, max);
360 }361 }
361 362
362 sampleLine(pixelBuffer, x + 3, x + 3, max, min);363 sampleLine(x + 3, x + 3, max, min);
363 364
364 oldMin = min;365 oldMin = min;
365 oldMax = max;366 oldMax = max;
@@ -369,9 +370,9 @@ static void renderSampleData(void) · 3 unmodified lines
369 370
370 // render "sample display" text371 // render "sample display" text
371 if (editor.sampler.samStart == editor.sampler.blankSample)372 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]);
373 else374 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]);
375 376
376 setDragBar();377 setDragBar();
377 setLoopSprites();378 setLoopSprites();
@@ -398,7 +399,7 @@ void invertRange(void) · 20 unmodified lines
398 if (rangeLen < 1)399 if (rangeLen < 1)
399 rangeLen = 1;400 rangeLen = 1;
400 401
401 dstPtr = &pixelBuffer[(138 * SCREEN_W) + (start + 3)];402 dstPtr = &video.frameBuffer[(138 * SCREEN_W) + (start + 3)];
402 for (y = 0; y < 64; y++)403 for (y = 0; y < 64; y++)
403 {404 {
404 for (x = 0; x < rangeLen; x++)405 for (x = 0; x < rangeLen; x++)
@@ -1435,7 +1436,7 @@ void sampleMarkerToBeg(void) · 1030 unmodified lines
1435 else1436 else
1436 {1437 {
1437 invertRange();1438 invertRange();
1438 if (input.keyb.shiftPressed && editor.markStartOfs != -1)1439 if (keyb.shiftPressed && editor.markStartOfs != -1)
1439 {1440 {
1440 editor.markStartOfs = editor.sampler.samOffset;1441 editor.markStartOfs = editor.sampler.samOffset;
1441 }1442 }
@@ -1471,7 +1472,7 @@ void sampleMarkerToCenter(void) · 29 unmodified lines
1471 middlePos = editor.sampler.samOffset + ((editor.sampler.samDisplay + 1) / 2);1472 middlePos = editor.sampler.samOffset + ((editor.sampler.samDisplay + 1) / 2);
1472 1473
1473 invertRange();1474 invertRange();
1474 if (input.keyb.shiftPressed && editor.markStartOfs != -1)1475 if (keyb.shiftPressed && editor.markStartOfs != -1)
1475 {1476 {
1476 if (editor.markStartOfs < middlePos)1477 if (editor.markStartOfs < middlePos)
1477 editor.markEndOfs = middlePos;1478 editor.markEndOfs = middlePos;
@@ -1507,7 +1508,7 @@ void sampleMarkerToEnd(void) · 29 unmodified lines
1507 else1508 else
1508 {1509 {
1509 invertRange();1510 invertRange();
1510 if (input.keyb.shiftPressed && editor.markStartOfs != -1)1511 if (keyb.shiftPressed && editor.markStartOfs != -1)
1511 {1512 {
1512 editor.markEndOfs = s->length;1513 editor.markEndOfs = s->length;
1513 }1514 }
@@ -1995,7 +1996,7 @@ void setLoopSprites(void) · 481 unmodified lines
1995 hideSprite(SPRITE_LOOP_PIN_RIGHT);1996 hideSprite(SPRITE_LOOP_PIN_RIGHT);
1996 }1997 }
1997 1998
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]);
1999}2000}
2000 2001
2001void samplerShowAll(void)2002void samplerShowAll(void)
@@ -2081,12 +2082,12 @@ static void samplerZoomOut(int32_t step, int16_t x) · 79 unmodified lines
2081 2082
2082void samplerZoomInMouseWheel(void)2083void samplerZoomInMouseWheel(void)
2083{2084{
2084 samplerZoomIn((editor.sampler.samDisplay + 5) / 10, input.mouse.x);2085 samplerZoomIn((editor.sampler.samDisplay + 5) / 10, mouse.x);
2085}2086}
2086 2087
2087void samplerZoomOutMouseWheel(void)2088void samplerZoomOutMouseWheel(void)
2088{2089{
2089 samplerZoomOut((editor.sampler.samDisplay + 5) / 10, input.mouse.x);2090 samplerZoomOut((editor.sampler.samDisplay + 5) / 10, mouse.x);
2090}2091}
2091 2092
2092void samplerZoomOut2x(void)2093void samplerZoomOut2x(void)
@@ -2158,22 +2159,19 @@ void volBoxBarPressed(bool mouseButtonHeld) · 65 unmodified lines
2158{2159{
2159 int32_t mouseX;2160 int32_t mouseX;
2160 2161
2161 if (input.mouse.y < 0 || input.mouse.x < 0 || input.mouse.y >= SCREEN_H || input.mouse.x >= SCREEN_W)
2162 return;
2163
2164 if (!mouseButtonHeld)2162 if (!mouseButtonHeld)
2165 {2163 {
2166 if (input.mouse.x >= 72 && input.mouse.x <= 173)2164 if (mouse.x >= 72 && mouse.x <= 173)
2167 {2165 {
2168 if (input.mouse.y >= 154 && input.mouse.y <= 174) editor.ui.forceVolDrag = 1;2166 if (mouse.y >= 154 && mouse.y <= 174) editor.ui.forceVolDrag = 1;
2169 if (input.mouse.y >= 165 && input.mouse.y <= 175) editor.ui.forceVolDrag = 2;2167 if (mouse.y >= 165 && mouse.y <= 175) editor.ui.forceVolDrag = 2;
2170 }2168 }
2171 }2169 }
2172 else2170 else
2173 {2171 {
2174 if (editor.sampler.lastMouseX != input.mouse.x)2172 if (editor.sampler.lastMouseX != mouse.x)
2175 {2173 {
2176 editor.sampler.lastMouseX = input.mouse.x;2174 editor.sampler.lastMouseX = mouse.x;
2177 mouseX = CLAMP(editor.sampler.lastMouseX - 107, 0, 60);2175 mouseX = CLAMP(editor.sampler.lastMouseX - 107, 0, 60);
2178 2176
2179 if (editor.ui.forceVolDrag == 1)2177 if (editor.ui.forceVolDrag == 1)
@@ -2196,14 +2194,11 @@ void samplerBarPressed(bool mouseButtonHeld) · 16 unmodified lines
2196{2194{
2197 int32_t tmp32;2195 int32_t tmp32;
2198 2196
2199 if (input.mouse.y < 0 || input.mouse.x < 0 || input.mouse.y >= SCREEN_H || input.mouse.x >= SCREEN_W)
2200 return;
2201
2202 if (!mouseButtonHeld)2197 if (!mouseButtonHeld)
2203 {2198 {
2204 if (input.mouse.x >= 4 && input.mouse.x <= 315)2199 if (mouse.x >= 4 && mouse.x <= 315)
2205 {2200 {
2206 if (input.mouse.x < editor.sampler.dragStart)2201 if (mouse.x < editor.sampler.dragStart)
2207 {2202 {
2208 tmp32 = editor.sampler.samOffset - editor.sampler.samDisplay;2203 tmp32 = editor.sampler.samOffset - editor.sampler.samDisplay;
2209 if (tmp32 < 0)2204 if (tmp32 < 0)
@@ -2219,7 +2214,7 @@ void samplerBarPressed(bool mouseButtonHeld) · 9 unmodified lines
2219 return;2214 return;
2220 }2215 }
2221 2216
2222 if (input.mouse.x > editor.sampler.dragEnd)2217 if (mouse.x > editor.sampler.dragEnd)
2223 {2218 {
2224 tmp32 = editor.sampler.samOffset + editor.sampler.samDisplay;2219 tmp32 = editor.sampler.samOffset + editor.sampler.samDisplay;
2225 if (tmp32+editor.sampler.samDisplay <= editor.sampler.samLength)2220 if (tmp32+editor.sampler.samDisplay <= editor.sampler.samLength)
@@ -2243,22 +2238,21 @@ void samplerBarPressed(bool mouseButtonHeld) · 17 unmodified lines
2243 return;2238 return;
2244 }2239 }
2245 2240
2246 editor.sampler.lastSamPos = (uint16_t)input.mouse.x;2241 editor.sampler.lastSamPos = mouse.x;
2247 editor.sampler.saveMouseX = editor.sampler.lastSamPos - editor.sampler.dragStart;2242 editor.sampler.saveMouseX = editor.sampler.lastSamPos - editor.sampler.dragStart;
2248 2243
2249 editor.ui.forceSampleDrag = true;2244 editor.ui.forceSampleDrag = true;
2250 }2245 }
2251 }2246 }
2252 2247
2253 if (input.mouse.x != editor.sampler.lastSamPos)2248 if (mouse.x != editor.sampler.lastSamPos)
2254 {2249 {
2255 editor.sampler.lastSamPos = (uint16_t)input.mouse.x;2250 editor.sampler.lastSamPos = mouse.x;
2256 2251
2257 tmp32 = editor.sampler.lastSamPos - editor.sampler.saveMouseX - 4;2252 tmp32 = editor.sampler.lastSamPos - editor.sampler.saveMouseX - 4;
2258 if (tmp32 < 0)2253 tmp32 = CLAMP(tmp32, 0, SAMPLE_AREA_WIDTH);
2259 tmp32 = 0;
2260 2254
2261 tmp32 = (int32_t)(((tmp32 * editor.sampler.samLength) + (311/2)) / 311); // rounded2255 tmp32 = ((tmp32 * editor.sampler.samLength) + (311/2)) / 311; // rounded
2262 if (tmp32+editor.sampler.samDisplay <= editor.sampler.samLength)2256 if (tmp32+editor.sampler.samDisplay <= editor.sampler.samLength)
2263 {2257 {
2264 if (tmp32 == editor.sampler.samOffset)2258 if (tmp32 == editor.sampler.samOffset)
@@ -2280,162 +2274,166 @@ void samplerBarPressed(bool mouseButtonHeld) · 15 unmodified lines
2280 }2274 }
2281}2275}
2282 2276
2283static int32_t x2LoopX(int32_t mouseX)2277static int32_t mouseYToSampleY(int32_t my)
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
2297static int32_t xToSmpX(int32_t x, int32_t smpLen)
2298{2278{
2299 x = scr2SmpPos(x);2279 int32_t tmp32;
2300 x = CLAMP(x, 0, smpLen - 1);
2301
2302 return x;
2303}
2304 2280
2305static int8_t yToSmpY(int32_t mouseY)2281 if (my == SAMPLE_AREA_Y_CENTER) // center
2306{2282 {
2307 mouseY = (SAMPLE_AREA_Y_CENTER - mouseY) * 4;2283 return 128;
2308 CLAMP8(mouseY);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 }
2309 2292
2310 return mouseY;2293 return tmp32;
2311}2294}
2312 2295
2313void samplerEditSample(bool mouseButtonHeld)2296void samplerEditSample(bool mouseButtonHeld)
2314{2297{
2315 int8_t y;2298 int8_t *ptr8;
2316 int32_t mouseY, x, smp_x0, smp_x1, xDistance, smp_y0, smp_y1, yDistance, smp;2299 int32_t mx, my, tmp32, p, vl, tvl, r, rl, rvl, start, end;
2317 moduleSample_t *s;2300 moduleSample_t *s;
2318 2301
2319 assert(editor.currSample >= 0 && editor.currSample <= 30);2302 assert(editor.currSample >= 0 && editor.currSample <= 30);
2303 s = &modEntry->samples[editor.currSample];
2320 2304
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");
2322 return;2308 return;
2309 }
2323 2310
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;
2325 2316
2326 if (!mouseButtonHeld)2317 if (!mouseButtonHeld)
2327 {2318 {
2328 if (input.mouse.x >= 3 && input.mouse.x <= 316 && input.mouse.y >= 138 && input.mouse.y <= 201)2319 lastDrawX = scr2SmpPos(mx);
2329 {2320 lastDrawY = mouseYToSampleY(my);
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 }
2342 2321
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
2344 }2328 }
2345 2329
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;
2347 2339
2348 x = xToSmpX(input.mouse.x - 3, s->length);2340 editor.sampler.lastMouseX = mx;
2349 y = yToSmpY(mouseY);2341 editor.sampler.lastMouseY = my;
2350 2342
2351 modEntry->sampleData[s->offset+x] = y;2343 r = p;
2344 rvl = vl;
2352 2345
2353 // interpolate x gaps2346 // swap x/y if needed
2354 if (input.mouse.x != editor.sampler.lastMouseX)2347 if (p > lastDrawX)
2355 {2348 {
2356 smp_y0 = yToSmpY(editor.sampler.lastMouseY);2349 // swap x
2350 tmp32 = p;
2351 p = lastDrawX;
2352 lastDrawX = tmp32;
2357 2353
2358 smp_y1 = y;2354 // swap y
2359 yDistance = smp_y1 - smp_y0;2355 tmp32 = lastDrawY;
2356 lastDrawY = vl;
2357 vl = tmp32;
2358 }
2360 2359
2361 if (input.mouse.x > editor.sampler.lastMouseX)2360 ptr8 = &modEntry->sampleData[s->offset];
2362 {
2363 smp_x1 = x;
2364 smp_x0 = xToSmpX(editor.sampler.lastMouseX - 3, s->length);
2365 2361
2366 xDistance = smp_x1 - smp_x0;2362 start = p;
2367 if (xDistance > 0)2363 if (start < 0)
2368 {2364 start = 0;
2369 for (x = smp_x0; x < smp_x1; x++)
2370 {
2371 assert(x < s->length);
2372 2365
2373 smp = smp_y0 + (((x - smp_x0) * yDistance) / xDistance);2366 end = lastDrawX+1;
2374 CLAMP8(smp);2367 if (end > s->length)
2375 modEntry->sampleData[s->offset + x] = (int8_t)smp;2368 end = s->length;
2376 }2369
2377 }2370 if (p == lastDrawX)
2378 }2371 {
2379 else if (input.mouse.x < editor.sampler.lastMouseX)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)
2380 {2382 {
2381 smp_x0 = x;2383 double dMul = 1.0 / x;
2382 smp_x1 = xToSmpX(editor.sampler.lastMouseX - 3, s->length);2384 int32_t i = 0;
2383 2385
2384 xDistance = smp_x1 - smp_x0;2386 for (rl = start; rl < end; rl++)
2385 if (xDistance > 0)
2386 {2387 {
2387 for (x = smp_x0; x < smp_x1; x++)2388 tvl = y * i;
2388 {2389 tvl = (int32_t)(tvl * dMul); // tvl /= x
2389 assert(x < s->length);2390 tvl += vl;
2391 tvl ^= 0x80;
2390 2392
2391 smp = smp_y0 + (((smp_x1 - x) * yDistance) / xDistance);2393 ptr8[rl] = (int8_t)tvl;
2392 CLAMP8(smp);2394 i++;
2393 modEntry->sampleData[s->offset + x] = (int8_t)smp;
2394 }
2395 }2395 }
2396 }2396 }
2397
2398 editor.sampler.lastMouseX = input.mouse.x;
2399
2400 if (!input.keyb.shiftPressed)
2401 editor.sampler.lastMouseY = input.mouse.y;
2402 }2397 }
2403 2398
2399 lastDrawY = rvl;
2400 lastDrawX = r;
2401
2404 displaySample();2402 displaySample();
2405}2403}
2406 2404
2407void samplerSamplePressed(bool mouseButtonHeld)2405void samplerSamplePressed(bool mouseButtonHeld)
2408{2406{
2409 int16_t mouseX;2407 int32_t mouseX, tmpPos;
2410 int32_t tmpPos;
2411 moduleSample_t *s;2408 moduleSample_t *s;
2412 2409
2413 assert(editor.currSample >= 0 && editor.currSample <= 30);2410 assert(editor.currSample >= 0 && editor.currSample <= 30);
2414 2411
2415 if (!mouseButtonHeld)2412 if (!mouseButtonHeld)
2416 {2413 {
2417 if (input.mouse.y < 142)2414 if (mouse.y < 142)
2418 {2415 {
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)
2420 {2417 {
2421 editor.ui.leftLoopPinMoving = true;2418 editor.ui.leftLoopPinMoving = true;
2422 editor.ui.rightLoopPinMoving = false;2419 editor.ui.rightLoopPinMoving = false;
2423 editor.ui.sampleMarkingPos = 1;2420 editor.ui.sampleMarkingPos = 1;
2424 editor.sampler.lastMouseX = input.mouse.x;2421 editor.sampler.lastMouseX = mouse.x;
2425 return;2422 return;
2426 }2423 }
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)
2428 {2425 {
2429 editor.ui.rightLoopPinMoving = true;2426 editor.ui.rightLoopPinMoving = true;
2430 editor.ui.leftLoopPinMoving = false;2427 editor.ui.leftLoopPinMoving = false;
2431 editor.ui.sampleMarkingPos = 1;2428 editor.ui.sampleMarkingPos = 1;
2432 editor.sampler.lastMouseX = input.mouse.x;2429 editor.sampler.lastMouseX = mouse.x;
2433 return;2430 return;
2434 }2431 }
2435 }2432 }
2436 }2433 }
2437 2434
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
2439 s = &modEntry->samples[editor.currSample];2437 s = &modEntry->samples[editor.currSample];
2440 2438
2441 if (editor.ui.leftLoopPinMoving)2439 if (editor.ui.leftLoopPinMoving)
@@ -2444,7 +2442,7 @@ void samplerSamplePressed(bool mouseButtonHeld) · 2 unmodified lines
2444 {2442 {
2445 editor.sampler.lastMouseX = mouseX;2443 editor.sampler.lastMouseX = mouseX;
2446 2444
2447 tmpPos = (x2LoopX(mouseX + 2) - s->loopStart) & 0xFFFFFFFE;2445 tmpPos = (scr2SmpPos(mouseX - 1) - s->loopStart) & 0xFFFFFFFE;
2448 if (tmpPos > MAX_SAMPLE_LEN)2446 if (tmpPos > MAX_SAMPLE_LEN)
2449 tmpPos = MAX_SAMPLE_LEN;2447 tmpPos = MAX_SAMPLE_LEN;
2450 2448
@@ -2482,7 +2480,7 @@ void samplerSamplePressed(bool mouseButtonHeld) · 31 unmodified lines
2482 2480
2483 s = &modEntry->samples[editor.currSample];2481 s = &modEntry->samples[editor.currSample];
2484 2482
2485 tmpPos = (x2LoopX(mouseX - 1) - s->loopStart) & 0xFFFFFFFE;2483 tmpPos = (scr2SmpPos(mouseX - 4) - s->loopStart) & 0xFFFFFFFE;
2486 tmpPos = CLAMP(tmpPos, 2, MAX_SAMPLE_LEN);2484 tmpPos = CLAMP(tmpPos, 2, MAX_SAMPLE_LEN);
2487 2485
2488 s->loopLength = tmpPos;2486 s->loopLength = tmpPos;
@@ -2500,7 +2498,7 @@ void samplerSamplePressed(bool mouseButtonHeld) · 11 unmodified lines
2500 2498
2501 if (!mouseButtonHeld)2499 if (!mouseButtonHeld)
2502 {2500 {
2503 if (mouseX < 3 || mouseX > 319)2501 if (mouseX < 3 || mouseX >= SCREEN_W)
2504 return;2502 return;
2505 2503
2506 editor.ui.sampleMarkingPos = (int16_t)mouseX;2504 editor.ui.sampleMarkingPos = (int16_t)mouseX;
@@ -2540,7 +2538,7 @@ void samplerSamplePressed(bool mouseButtonHeld) · 33 unmodified lines
2540 return;2538 return;
2541 }2539 }
2542 2540
2543 mouseX = CLAMP(mouseX, 3, 319);2541 mouseX = CLAMP(mouseX, 3, SCREEN_W);
2544 2542
2545 if (mouseX != editor.sampler.lastSamPos)2543 if (mouseX != editor.sampler.lastSamPos)
2546 {2544 {
@@ -2643,7 +2641,7 @@ void samplerLoopToggle(void) · 96 unmodified lines
2643void exitFromSam(void)2641void exitFromSam(void)
2644{2642{
2645 editor.ui.samplerScreenShown = false;2643 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));
2647 2645
2648 updateCursorPos();2646 updateCursorPos();
2649 setLoopSprites();2647 setLoopSprites();
@@ -2667,7 +2665,7 @@ void samplerScreen(void) · 17 unmodified lines
2667 }2665 }
2668 2666
2669 editor.ui.samplerScreenShown = true;2667 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));
2671 hideSprite(SPRITE_PATTERN_CURSOR);2669 hideSprite(SPRITE_PATTERN_CURSOR);
2672 2670
2673 editor.ui.updateStatusText = true;2671 editor.ui.updateStatusText = true;
src/pt2_scopes.c+34−33
@@ -24,11 +24,8 @@ static uint32_t scopeTimeLen, scopeTimeLenFrac; · 23 unmodified lines
24static uint64_t timeNext64, timeNext64Frac;24static uint64_t timeNext64, timeNext64Frac;
25static SDL_Thread *scopeThread;25static SDL_Thread *scopeThread;
26 26
27scopeChannel_t scope[4]; // global27scopeChannel_t scope[AMIGA_VOICES]; // global
28scopeChannelExt_t scopeExt[4]; // global28scopeChannelExt_t scopeExt[AMIGA_VOICES]; // global
29
30extern bool forceMixerOff; // pt_audio.c
31extern uint32_t *pixelBuffer; // pt_main.c
32 29
33int32_t getSampleReadPos(uint8_t ch, uint8_t smpNum)30int32_t getSampleReadPos(uint8_t ch, uint8_t smpNum)
34{31{
@@ -47,9 +44,10 @@ int32_t getSampleReadPos(uint8_t ch, uint8_t smpNum) · 12 unmodified lines
47 {44 {
48 s = &modEntry->samples[smpNum];45 s = &modEntry->samples[smpNum];
49 46
50 /* get real sampling position regardless of where the scope data points to47 /* Get real sampling position regardless of where the scope data points to
51 ** sc->data changes during loop, offset and so on, so this has to be done48 ** 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 */
53 pos = (int32_t)(&data[pos] - &modEntry->sampleData[s->offset]);51 pos = (int32_t)(&data[pos] - &modEntry->sampleData[s->offset]);
54 if (pos >= s->length)52 if (pos >= s->length)
55 return -1;53 return -1;
@@ -73,7 +71,7 @@ void updateScopes(void) · 17 unmodified lines
73 if (editor.isWAVRendering)71 if (editor.isWAVRendering)
74 return;72 return;
75 73
76 for (uint32_t i = 0; i < AMIGA_VOICES; i++)74 for (int32_t i = 0; i < AMIGA_VOICES; i++)
77 {75 {
78 sc = &scope[i];76 sc = &scope[i];
79 se = &scopeExt[i];77 se = &scopeExt[i];
@@ -93,8 +91,9 @@ void updateScopes(void) · 13 unmodified lines
93 {91 {
94 // sample reached end, simulate Paula register update (sample swapping)92 // sample reached end, simulate Paula register update (sample swapping)
95 93
96 /* wrap pos around one time with current length, then set new length94 /* Wrap pos around one time with current length, then set new length
97 ** and wrap around it (handles one-shot loops and sample swapping) */95 ** and wrap around it (handles one-shot loops and sample swapping).
96 */
98 tmp.pos -= tmp.length;97 tmp.pos -= tmp.length;
99 tmp.length = tmpExt.newLength;98 tmp.length = tmpExt.newLength;
100 99
@@ -114,7 +113,8 @@ void updateScopes(void) · 13 unmodified lines
114 113
115/* This routine gets the average sample peak through the running scope voices.114/* This routine gets the average sample peak through the running scope voices.
116** This gives a much more smooth and stable result than getting the peak from115** 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*/
118static void updateRealVuMeters(void) 118static void updateRealVuMeters(void)
119{119{
120 bool didSwapData;120 bool didSwapData;
@@ -195,7 +195,7 @@ static void updateRealVuMeters(void) · 74 unmodified lines
195 }195 }
196 }196 }
197 197
198 smpPeak = ((smpPeak * 48) + (1 << 12)) >> 13;198 smpPeak = ((smpPeak * 48) + (1 << 12)) >> 13; // rounded
199 if (smpPeak > editor.realVuMeterVolumes[i])199 if (smpPeak > editor.realVuMeterVolumes[i])
200 editor.realVuMeterVolumes[i] = smpPeak;200 editor.realVuMeterVolumes[i] = smpPeak;
201 }201 }
@@ -216,7 +216,7 @@ void drawScopes(void) · 14 unmodified lines
216 {216 {
217 // --- QUADRASCOPE ---217 // --- QUADRASCOPE ---
218 218
219 scopePtr = &pixelBuffer[(71 * SCREEN_W) + 128];219 scopePtr = &video.frameBuffer[(71 * SCREEN_W) + 128];
220 for (i = 0; i < AMIGA_VOICES; i++)220 for (i = 0; i < AMIGA_VOICES; i++)
221 {221 {
222 sc = &scope[i];222 sc = &scope[i];
@@ -226,7 +226,7 @@ void drawScopes(void) · 3 unmodified lines
226 tmpScope = *sc;226 tmpScope = *sc;
227 didSwapData = se->didSwapData;227 didSwapData = se->didSwapData;
228 228
229 volume = -modEntry->channels[i].n_volume; // 0..64 -> -64..0229 volume = -modEntry->channels[i].n_volume; // invert volume
230 230
231 // render scope231 // render scope
232 if (se->active && tmpScope.data != NULL && volume != 0 && tmpScope.length > 0)232 if (se->active && tmpScope.data != NULL && volume != 0 && tmpScope.length > 0)
@@ -237,8 +237,8 @@ void drawScopes(void) · 4 unmodified lines
237 237
238 // draw scope background238 // draw scope background
239 239
240 dstPtr = &pixelBuffer[(55 * SCREEN_W) + (128 + (i * (SCOPE_WIDTH + 8)))];240 dstPtr = &video.frameBuffer[(55 * SCREEN_W) + (128 + (i * (SCOPE_WIDTH + 8)))];
241 scopePixel = palette[PAL_BACKGRD]; // this palette can change241 scopePixel = video.palette[PAL_BACKGRD]; // this palette can change
242 242
243 for (y = 0; y < SCOPE_HEIGHT; y++)243 for (y = 0; y < SCOPE_HEIGHT; y++)
244 {244 {
@@ -250,7 +250,7 @@ void drawScopes(void) · 5 unmodified lines
250 250
251 // render scope data251 // render scope data
252 252
253 scopePixel = palette[PAL_QADSCP];253 scopePixel = video.palette[PAL_QADSCP];
254 254
255 readPos = tmpScope.pos;255 readPos = tmpScope.pos;
256 if (tmpScope.loopFlag)256 if (tmpScope.loopFlag)
@@ -299,8 +299,8 @@ void drawScopes(void) · 42 unmodified lines
299 {299 {
300 // draw scope background300 // draw scope background
301 301
302 dstPtr = &pixelBuffer[(55 * SCREEN_W) + (128 + (i * (SCOPE_WIDTH + 8)))];302 dstPtr = &video.frameBuffer[(55 * SCREEN_W) + (128 + (i * (SCOPE_WIDTH + 8)))];
303 scopePixel = palette[PAL_BACKGRD];303 scopePixel = video.palette[PAL_BACKGRD];
304 304
305 for (y = 0; y < SCOPE_HEIGHT; y++)305 for (y = 0; y < SCOPE_HEIGHT; y++)
306 {306 {
@@ -312,7 +312,7 @@ void drawScopes(void) · 5 unmodified lines
312 312
313 // draw line313 // draw line
314 314
315 scopePixel = palette[PAL_QADSCP];315 scopePixel = video.palette[PAL_QADSCP];
316 for (x = 0; x < SCOPE_WIDTH; x++)316 for (x = 0; x < SCOPE_WIDTH; x++)
317 scopePtr[x] = scopePixel;317 scopePtr[x] = scopePixel;
318 318
@@ -332,8 +332,6 @@ static int32_t SDLCALL scopeThreadFunc(void *ptr) · 13 unmodified lines
332 uint32_t diff32;332 uint32_t diff32;
333 uint64_t time64;333 uint64_t time64;
334 334
335 (void)ptr;
336
337 // this is needed for scope stability (confirmed)335 // this is needed for scope stability (confirmed)
338 SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);336 SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
339 337
@@ -343,7 +341,7 @@ static int32_t SDLCALL scopeThreadFunc(void *ptr) · 3 unmodified lines
343 341
344 while (editor.programRunning)342 while (editor.programRunning)
345 {343 {
346 if (ptConfig.realVuMeters)344 if (config.realVuMeters)
347 updateRealVuMeters();345 updateRealVuMeters();
348 346
349 updateScopes();347 updateScopes();
@@ -372,6 +370,7 @@ static int32_t SDLCALL scopeThreadFunc(void *ptr) · 22 unmodified lines
372 }370 }
373 }371 }
374 372
373 (void)ptr;
375 return true;374 return true;
376}375}
377 376
@@ -383,7 +382,7 @@ bool initScopes(void) · 5 unmodified lines
383 dFrac = modf(editor.dPerfFreq / SCOPE_HZ, &dInt);382 dFrac = modf(editor.dPerfFreq / SCOPE_HZ, &dInt);
384 383
385 // integer part384 // integer part
386 scopeTimeLen = (uint32_t)dInt;385 scopeTimeLen = (int32_t)dInt;
387 386
388 // fractional part scaled to 0..2^32-1387 // fractional part scaled to 0..2^32-1
389 dFrac *= UINT32_MAX;388 dFrac *= UINT32_MAX;
@@ -400,18 +399,20 @@ bool initScopes(void) · 10 unmodified lines
400 return true;399 return true;
401}400}
402 401
403void waitOnScopes(void)402void stopScope(uint8_t ch)
404{403{
405 while (scopesReading);404 while (scopesReading);
406}405 memset(&scopeExt[ch], 0, sizeof (scopeChannelExt_t));
407 406
408void clearScopes(void)407 while (scopesReading);
409{408 memset(&scope[ch], 0, sizeof (scopeChannel_t));
410 waitOnScopes();
411 409
412 memset(scope, 0, sizeof (scope));410 scope[ch].length = scopeExt[ch].newLength = 2;
413 memset(scopeExt, 0, sizeof (scopeExt));411 while (scopesReading); // final wait to make sure scopes are all inactive
412}
414 413
415 for (uint8_t i = 0; i < AMIGA_VOICES; i++)414void stopAllScopes(void)
416 scope[i].length = scopeExt[i].newLength = 2;415{
416 for (int32_t i = 0; i < AMIGA_VOICES; i++)
417 stopScope(i);
417}418}
src/pt2_scopes.h+5−4
@@ -2,6 +2,7 @@ · 1 unmodified line
2 2
3#include <stdint.h>3#include <stdint.h>
4#include <stdbool.h>4#include <stdbool.h>
5#include "pt2_header.h"
5 6
6typedef struct scopeChannel_t // internal scope state7typedef struct scopeChannel_t // internal scope state
7{8{
@@ -24,8 +25,8 @@ int32_t getSampleReadPos(uint8_t ch, uint8_t smpNum); · 16 unmodified lines
24void updateScopes(void);25void updateScopes(void);
25void drawScopes(void);26void drawScopes(void);
26bool initScopes(void);27bool initScopes(void);
27void waitOnScopes(void);28void stopScope(uint8_t ch);
28void clearScopes(void);29void stopAllScopes(void);
29 30
30extern scopeChannel_t scope[4];31extern scopeChannel_t scope[AMIGA_VOICES];
31extern scopeChannelExt_t scopeExt[4];32extern scopeChannelExt_t scopeExt[AMIGA_VOICES];
src/pt2_tables.h+0−3
@@ -70,9 +70,6 @@ extern uint32_t *arrowBMP; · 69 unmodified lines
70extern uint32_t *editOpModeCharsBMP;70extern uint32_t *editOpModeCharsBMP;
71extern uint32_t *pat2SmpDialogBMP;71extern uint32_t *pat2SmpDialogBMP;
72 72
73// PALETTE
74extern uint32_t palette[PALETTE_NUM];
75
76// button tables taken from the ptplay project + modified73// button tables taken from the ptplay project + modified
77 74
78// MODIFY THESE EVERY TIME YOU REMOVE/ADD A BUTTON!75// 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
12 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'12 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
13};13};
14 14
15void charOut(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t color)15void charOut(uint32_t xPos, uint32_t yPos, char ch, uint32_t color)
16{16{
17 const uint8_t *srcPtr;17 const uint8_t *srcPtr;
18 uint32_t *dstPtr;18 uint32_t *dstPtr;
@@ -21,7 +21,7 @@ void charOut(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint3 · 2 unmodified lines
21 return;21 return;
22 22
23 srcPtr = &fontBMP[(uint8_t)ch * (FONT_CHAR_W * FONT_CHAR_H)];23 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];
25 25
26 for (uint32_t y = 0; y < FONT_CHAR_H; y++)26 for (uint32_t y = 0; y < FONT_CHAR_H; y++)
27 {27 {
@@ -36,7 +36,7 @@ void charOut(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint3 · 8 unmodified lines
36 }36 }
37}37}
38 38
39void charOutBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor)39void charOutBg(uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor)
40{40{
41 const uint8_t *srcPtr;41 const uint8_t *srcPtr;
42 uint32_t *dstPtr;42 uint32_t *dstPtr;
@@ -48,7 +48,7 @@ void charOutBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uin · 5 unmodified lines
48 ch = ' ';48 ch = ' ';
49 49
50 srcPtr = &fontBMP[(uint8_t)ch * (FONT_CHAR_W * FONT_CHAR_H)];50 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];
52 52
53 for (uint32_t y = 0; y < FONT_CHAR_H; y++)53 for (uint32_t y = 0; y < FONT_CHAR_H; y++)
54 {54 {
@@ -60,7 +60,7 @@ void charOutBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uin · 5 unmodified lines
60 }60 }
61}61}
62 62
63void charOutBig(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t color)63void charOutBig(uint32_t xPos, uint32_t yPos, char ch, uint32_t color)
64{64{
65 const uint8_t *srcPtr;65 const uint8_t *srcPtr;
66 uint32_t *dstPtr;66 uint32_t *dstPtr;
@@ -69,7 +69,7 @@ void charOutBig(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, ui · 2 unmodified lines
69 return;69 return;
70 70
71 srcPtr = &fontBMP[(uint8_t)ch * (FONT_CHAR_W * FONT_CHAR_H)];71 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];
73 73
74 for (uint32_t y = 0; y < FONT_CHAR_H; y++)74 for (uint32_t y = 0; y < FONT_CHAR_H; y++)
75 {75 {
@@ -87,7 +87,7 @@ void charOutBig(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, ui · 11 unmodified lines
87 }87 }
88}88}
89 89
90void charOutBigBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor)90void charOutBigBg(uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor)
91{91{
92 const uint8_t *srcPtr;92 const uint8_t *srcPtr;
93 uint32_t *dstPtr;93 uint32_t *dstPtr;
@@ -99,7 +99,7 @@ void charOutBigBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, · 5 unmodified lines
99 ch = ' ';99 ch = ' ';
100 100
101 srcPtr = &fontBMP[(uint8_t)ch * (FONT_CHAR_W * FONT_CHAR_H)];101 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];
103 103
104 for (uint32_t y = 0; y < FONT_CHAR_H; y++)104 for (uint32_t y = 0; y < FONT_CHAR_H; y++)
105 {105 {
@@ -122,151 +122,151 @@ void charOutBigBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, · 16 unmodified lines
122 }122 }
123}123}
124 124
125void textOut(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t color)125void textOut(uint32_t xPos, uint32_t yPos, const char *text, uint32_t color)
126{126{
127 uint32_t x = xPos;127 uint32_t x = xPos;
128 while (*text != '\0')128 while (*text != '\0')
129 {129 {
130 charOut(frameBuffer, x, yPos, *text++, color);130 charOut(x, yPos, *text++, color);
131 x += FONT_CHAR_W;131 x += FONT_CHAR_W;
132 }132 }
133}133}
134 134
135void textOutTight(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t color)135void textOutTight(uint32_t xPos, uint32_t yPos, const char *text, uint32_t color)
136{136{
137 uint32_t x = xPos;137 uint32_t x = xPos;
138 while (*text != '\0')138 while (*text != '\0')
139 {139 {
140 charOut(frameBuffer, x, yPos, *text++, color);140 charOut(x, yPos, *text++, color);
141 x += (FONT_CHAR_W - 1);141 x += (FONT_CHAR_W - 1);
142 }142 }
143}143}
144 144
145void textOutBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor)145void textOutBg(uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor)
146{146{
147 uint32_t x = xPos;147 uint32_t x = xPos;
148 while (*text != '\0')148 while (*text != '\0')
149 {149 {
150 charOutBg(frameBuffer, x, yPos, *text++, fgColor, bgColor);150 charOutBg(x, yPos, *text++, fgColor, bgColor);
151 x += FONT_CHAR_W;151 x += FONT_CHAR_W;
152 }152 }
153}153}
154 154
155void textOutBig(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t color)155void textOutBig(uint32_t xPos, uint32_t yPos, const char *text, uint32_t color)
156{156{
157 uint32_t x = xPos;157 uint32_t x = xPos;
158 while (*text != '\0')158 while (*text != '\0')
159 {159 {
160 charOutBig(frameBuffer, x, yPos, *text++, color);160 charOutBig(x, yPos, *text++, color);
161 x += FONT_CHAR_W;161 x += FONT_CHAR_W;
162 }162 }
163}163}
164 164
165void textOutBigBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor)165void textOutBigBg(uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor)
166{166{
167 uint32_t x = xPos;167 uint32_t x = xPos;
168 while (*text != '\0')168 while (*text != '\0')
169 {169 {
170 charOutBigBg(frameBuffer, x, yPos, *text++, fgColor, bgColor);170 charOutBigBg(x, yPos, *text++, fgColor, bgColor);
171 x += FONT_CHAR_W;171 x += FONT_CHAR_W;
172 }172 }
173}173}
174 174
175void printTwoDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)175void printTwoDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
176{176{
177 if (value == 0)177 if (value == 0)
178 {178 {
179 textOut(frameBuffer, x, y, "00", fontColor);179 textOut(x, y, "00", fontColor);
180 }180 }
181 else181 else
182 {182 {
183 if (value > 99)183 if (value > 99)
184 value = 99;184 value = 99;
185 185
186 charOut(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor); value /= 10;186 charOut(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);187 charOut(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
188 }188 }
189}189}
190 190
191void printTwoDecimalsBig(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)191void printTwoDecimalsBig(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
192{192{
193 if (value == 0)193 if (value == 0)
194 {194 {
195 textOutBig(frameBuffer, x, y, "00", fontColor);195 textOutBig(x, y, "00", fontColor);
196 }196 }
197 else197 else
198 {198 {
199 if (value > 99)199 if (value > 99)
200 value = 99;200 value = 99;
201 201
202 charOutBig(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor); value /= 10;202 charOutBig(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);203 charOutBig(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
204 }204 }
205}205}
206 206
207void printThreeDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)207void printThreeDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
208{208{
209 if (value == 0)209 if (value == 0)
210 {210 {
211 textOut(frameBuffer, x, y, "000", fontColor);211 textOut(x, y, "000", fontColor);
212 }212 }
213 else213 else
214 {214 {
215 if (value > 999)215 if (value > 999)
216 value = 999;216 value = 999;
217 217
218 charOut(frameBuffer, x + (FONT_CHAR_W * 2), y, '0' + (value % 10), fontColor); value /= 10;218 charOut(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;219 charOut(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);220 charOut(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
221 }221 }
222}222}
223 223
224void printFourDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)224void printFourDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
225{225{
226 if (value == 0)226 if (value == 0)
227 {227 {
228 textOut(frameBuffer, x, y, "0000", fontColor);228 textOut(x, y, "0000", fontColor);
229 }229 }
230 else230 else
231 {231 {
232 if (value > 9999)232 if (value > 9999)
233 value = 9999;233 value = 9999;
234 234
235 charOut(frameBuffer, x + (FONT_CHAR_W * 3), y, '0' + (value % 10), fontColor); value /= 10;235 charOut(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;236 charOut(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;237 charOut(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);238 charOut(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
239 }239 }
240}240}
241 241
242void printFiveDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)242void printFiveDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
243{243{
244 if (value == 0)244 if (value == 0)
245 {245 {
246 textOut(frameBuffer, x, y, "00000", fontColor);246 textOut(x, y, "00000", fontColor);
247 }247 }
248 else248 else
249 {249 {
250 if (value > 99999)250 if (value > 99999)
251 value = 99999;251 value = 99999;
252 252
253 charOut(frameBuffer, x + (FONT_CHAR_W * 4), y, '0' + (value % 10), fontColor); value /= 10;253 charOut(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;254 charOut(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;255 charOut(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;256 charOut(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);257 charOut(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor);
258 }258 }
259}259}
260 260
261// this one is used for module size and sampler screen display length (zeroes are padded with space)261// this one is used for module size and sampler screen display length (zeroes are padded with space)
262void printSixDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)262void printSixDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
263{263{
264 char numberText[7];264 char numberText[7];
265 uint8_t i;265 uint8_t i;
266 266
267 if (value == 0)267 if (value == 0)
268 {268 {
269 textOut(frameBuffer, x, y, " 0", fontColor);269 textOut(x, y, " 0", fontColor);
270 }270 }
271 else271 else
272 {272 {
@@ -285,177 +285,177 @@ void printSixDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t va · 12 unmodified lines
285 while (numberText[i] == '0')285 while (numberText[i] == '0')
286 numberText[i++] = ' ';286 numberText[i++] = ' ';
287 287
288 textOut(frameBuffer, x, y, numberText, fontColor);288 textOut(x, y, numberText, fontColor);
289 }289 }
290}290}
291 291
292void printOneHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)292void printOneHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
293{293{
294 charOut(frameBuffer, x, y, hexTable[value & 15], fontColor);294 charOut(x, y, hexTable[value & 15], fontColor);
295}295}
296 296
297void printOneHexBig(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)297void printOneHexBig(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
298{298{
299 charOutBig(frameBuffer, x, y, hexTable[value & 15], fontColor);299 charOutBig(x, y, hexTable[value & 15], fontColor);
300}300}
301 301
302void printTwoHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)302void printTwoHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
303{303{
304 if (value == 0)304 if (value == 0)
305 {305 {
306 textOut(frameBuffer, x, y, "00", fontColor);306 textOut(x, y, "00", fontColor);
307 }307 }
308 else308 else
309 {309 {
310 value &= 0xFF;310 value &= 0xFF;
311 311
312 charOut(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor);312 charOut(x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor);
313 charOut(frameBuffer, x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor);313 charOut(x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor);
314 }314 }
315}315}
316 316
317void printTwoHexBig(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)317void printTwoHexBig(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
318{318{
319 if (value == 0)319 if (value == 0)
320 {320 {
321 textOutBig(frameBuffer, x, y, "00", fontColor);321 textOutBig(x, y, "00", fontColor);
322 }322 }
323 else323 else
324 {324 {
325 value &= 0xFF;325 value &= 0xFF;
326 326
327 charOutBig(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor);327 charOutBig(x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor);
328 charOutBig(frameBuffer, x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor);328 charOutBig(x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor);
329 }329 }
330}330}
331 331
332void printThreeHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)332void printThreeHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
333{333{
334 if (value == 0)334 if (value == 0)
335 {335 {
336 textOut(frameBuffer, x, y, "000", fontColor);336 textOut(x, y, "000", fontColor);
337 }337 }
338 else338 else
339 {339 {
340 value &= 0xFFF;340 value &= 0xFFF;
341 341
342 charOut(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 8], fontColor);342 charOut(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);343 charOut(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);344 charOut(x + (FONT_CHAR_W * 2), y, hexTable[value & 15], fontColor);
345 }345 }
346}346}
347 347
348void printFourHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)348void printFourHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
349{349{
350 if (value == 0)350 if (value == 0)
351 {351 {
352 textOut(frameBuffer, x, y, "0000", fontColor);352 textOut(x, y, "0000", fontColor);
353 }353 }
354 else354 else
355 {355 {
356 value &= 0xFFFF;356 value &= 0xFFFF;
357 357
358 charOut(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 12], fontColor);358 charOut(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);359 charOut(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);360 charOut(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);361 charOut(x + (FONT_CHAR_W * 3), y, hexTable[value & 15], fontColor);
362 }362 }
363}363}
364 364
365void printFiveHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)365void printFiveHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor)
366{366{
367 if (value == 0)367 if (value == 0)
368 {368 {
369 textOut(frameBuffer, x, y, "00000", fontColor);369 textOut(x, y, "00000", fontColor);
370 }370 }
371 else371 else
372 {372 {
373 value &= 0xFFFFF;373 value &= 0xFFFFF;
374 374
375 charOut(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 16], fontColor);375 charOut(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);376 charOut(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);377 charOut(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);378 charOut(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);379 charOut(x + (FONT_CHAR_W * 4), y, hexTable[value & 15], fontColor);
380 }380 }
381}381}
382 382
383void printTwoDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)383void printTwoDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
384{384{
385 if (value == 0)385 if (value == 0)
386 {386 {
387 textOutBg(frameBuffer, x, y, "00", fontColor, backColor);387 textOutBg(x, y, "00", fontColor, backColor);
388 }388 }
389 else389 else
390 {390 {
391 if (value > 99)391 if (value > 99)
392 value = 99;392 value = 99;
393 393
394 charOutBg(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor, backColor); value /= 10;394 charOutBg(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);395 charOutBg(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor, backColor);
396 }396 }
397}397}
398 398
399void printTwoDecimalsBigBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)399void printTwoDecimalsBigBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
400{400{
401 if (value == 0)401 if (value == 0)
402 {402 {
403 textOutBigBg(frameBuffer, x, y, "00", fontColor, backColor);403 textOutBigBg(x, y, "00", fontColor, backColor);
404 }404 }
405 else405 else
406 {406 {
407 if (value > 99)407 if (value > 99)
408 value = 99;408 value = 99;
409 409
410 charOutBigBg(frameBuffer, x + (FONT_CHAR_W * 1), y, '0' + (value % 10), fontColor, backColor); value /= 10;410 charOutBigBg(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);411 charOutBigBg(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor, backColor);
412 }412 }
413}413}
414 414
415void printThreeDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)415void printThreeDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
416{416{
417 if (value == 0)417 if (value == 0)
418 {418 {
419 textOutBg(frameBuffer, x, y, "000", fontColor, backColor);419 textOutBg(x, y, "000", fontColor, backColor);
420 }420 }
421 else421 else
422 {422 {
423 if (value > 999)423 if (value > 999)
424 value = 999;424 value = 999;
425 425
426 charOutBg(frameBuffer, x + (FONT_CHAR_W * 2), y, '0' + (value % 10), fontColor, backColor); value /= 10;426 charOutBg(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;427 charOutBg(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);428 charOutBg(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor, backColor);
429 }429 }
430}430}
431 431
432void printFourDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)432void printFourDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
433{433{
434 if (value == 0)434 if (value == 0)
435 {435 {
436 textOutBg(frameBuffer, x, y, "0000", fontColor, backColor);436 textOutBg(x, y, "0000", fontColor, backColor);
437 }437 }
438 else438 else
439 {439 {
440 if (value > 9999)440 if (value > 9999)
441 value = 9999;441 value = 9999;
442 442
443 charOutBg(frameBuffer, x + (FONT_CHAR_W * 3), y, '0' + (value % 10), fontColor, backColor); value /= 10;443 charOutBg(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;444 charOutBg(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;445 charOutBg(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);446 charOutBg(x + (FONT_CHAR_W * 0), y, '0' + (value % 10), fontColor, backColor);
447 }447 }
448}448}
449 449
450// this one is used for "DISP:" in the sampler screen (zeroes are padded with space)450// this one is used for "DISP:" in the sampler screen (zeroes are padded with space)
451void printFiveDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)451void printFiveDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
452{452{
453 char numberText[6];453 char numberText[6];
454 uint8_t i;454 uint8_t i;
455 455
456 if (value == 0)456 if (value == 0)
457 {457 {
458 textOutBg(frameBuffer, x, y, " 0", fontColor, backColor);458 textOutBg(x, y, " 0", fontColor, backColor);
459 }459 }
460 else460 else
461 {461 {
@@ -473,19 +473,19 @@ void printFiveDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t · 11 unmodified lines
473 while (numberText[i] == '0')473 while (numberText[i] == '0')
474 numberText[i++] = ' ';474 numberText[i++] = ' ';
475 475
476 textOutBg(frameBuffer, x, y, numberText, fontColor, backColor);476 textOutBg(x, y, numberText, fontColor, backColor);
477 }477 }
478}478}
479 479
480// this one is used for module size (zeroes are padded with space)480// this one is used for module size (zeroes are padded with space)
481void printSixDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)481void printSixDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
482{482{
483 char numberText[7];483 char numberText[7];
484 uint8_t i;484 uint8_t i;
485 485
486 if (value == 0)486 if (value == 0)
487 {487 {
488 textOutBg(frameBuffer, x, y, " 0", fontColor, backColor);488 textOutBg(x, y, " 0", fontColor, backColor);
489 }489 }
490 else490 else
491 {491 {
@@ -504,98 +504,98 @@ void printSixDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t · 12 unmodified lines
504 while (numberText[i] == '0')504 while (numberText[i] == '0')
505 numberText[i++] = ' ';505 numberText[i++] = ' ';
506 506
507 textOutBg(frameBuffer, x, y, numberText, fontColor, backColor);507 textOutBg(x, y, numberText, fontColor, backColor);
508 }508 }
509}509}
510 510
511void printOneHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)511void printOneHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
512{512{
513 charOutBg(frameBuffer, x, y, hexTable[value & 0xF], fontColor, backColor);513 charOutBg(x, y, hexTable[value & 0xF], fontColor, backColor);
514}514}
515 515
516void printOneHexBigBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)516void printOneHexBigBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
517{517{
518 charOutBigBg(frameBuffer, x, y, hexTable[value & 0xF], fontColor, backColor);518 charOutBigBg(x, y, hexTable[value & 0xF], fontColor, backColor);
519}519}
520 520
521void printTwoHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)521void printTwoHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
522{522{
523 if (value == 0)523 if (value == 0)
524 {524 {
525 textOutBg(frameBuffer, x, y, "00", fontColor, backColor);525 textOutBg(x, y, "00", fontColor, backColor);
526 }526 }
527 else527 else
528 {528 {
529 value &= 0xFF;529 value &= 0xFF;
530 530
531 charOutBg(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor, backColor);531 charOutBg(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);532 charOutBg(x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor, backColor);
533 }533 }
534}534}
535 535
536void printTwoHexBigBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)536void printTwoHexBigBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
537{537{
538 if (value == 0)538 if (value == 0)
539 {539 {
540 textOutBigBg(frameBuffer, x, y, "00", fontColor, backColor);540 textOutBigBg(x, y, "00", fontColor, backColor);
541 }541 }
542 else542 else
543 {543 {
544 value &= 0xFF;544 value &= 0xFF;
545 545
546 charOutBigBg(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 4], fontColor, backColor);546 charOutBigBg(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);547 charOutBigBg(x + (FONT_CHAR_W * 1), y, hexTable[value & 15], fontColor, backColor);
548 }548 }
549}549}
550 550
551void printThreeHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)551void printThreeHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
552{552{
553 if (value == 0)553 if (value == 0)
554 {554 {
555 textOutBg(frameBuffer, x, y, "000", fontColor, backColor);555 textOutBg(x, y, "000", fontColor, backColor);
556 }556 }
557 else557 else
558 {558 {
559 value &= 0xFFF;559 value &= 0xFFF;
560 560
561 charOutBg(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 8], fontColor, backColor);561 charOutBg(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);562 charOutBg(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);563 charOutBg(x + (FONT_CHAR_W * 2), y, hexTable[value & 15], fontColor, backColor);
564 }564 }
565}565}
566 566
567void printFourHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)567void printFourHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
568{568{
569 if (value == 0)569 if (value == 0)
570 {570 {
571 textOutBg(frameBuffer, x, y, "0000", fontColor, backColor);571 textOutBg(x, y, "0000", fontColor, backColor);
572 }572 }
573 else573 else
574 {574 {
575 value &= 0xFFFF;575 value &= 0xFFFF;
576 576
577 charOutBg(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 12], fontColor, backColor);577 charOutBg(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);578 charOutBg(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);579 charOutBg(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);580 charOutBg(x + (FONT_CHAR_W * 3), y, hexTable[value & 15], fontColor, backColor);
581 }581 }
582}582}
583 583
584void printFiveHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)584void printFiveHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor)
585{585{
586 if (value == 0)586 if (value == 0)
587 {587 {
588 textOutBg(frameBuffer, x, y, "00000", fontColor, backColor);588 textOutBg(x, y, "00000", fontColor, backColor);
589 }589 }
590 else590 else
591 {591 {
592 value &= 0xFFFFF;592 value &= 0xFFFFF;
593 593
594 charOutBg(frameBuffer, x + (FONT_CHAR_W * 0), y, hexTable[value >> 16], fontColor, backColor);594 charOutBg(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);595 charOutBg(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);596 charOutBg(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);597 charOutBg(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);598 charOutBg(x + (FONT_CHAR_W * 4), y, hexTable[value & 15], fontColor, backColor);
599 }599 }
600}600}
601 601
src/pt2_textout.h+35−35
@@ -3,41 +3,41 @@ · 2 unmodified lines
3#include <stdint.h>3#include <stdint.h>
4#include <stdbool.h>4#include <stdbool.h>
5 5
6void charOut(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t color);6void charOut(uint32_t xPos, uint32_t yPos, char ch, uint32_t color);
7void charOutBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor);7void charOutBg(uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor);
8void charOutBig(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t color);8void charOutBig(uint32_t xPos, uint32_t yPos, char ch, uint32_t color);
9void charOutBigBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor);9void charOutBigBg(uint32_t xPos, uint32_t yPos, char ch, uint32_t fgColor, uint32_t bgColor);
10void textOut(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t color);10void textOut(uint32_t xPos, uint32_t yPos, const char *text, uint32_t color);
11void textOutTight(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t color);11void textOutTight(uint32_t xPos, uint32_t yPos, const char *text, uint32_t color);
12void textOutBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor);12void textOutBg(uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor);
13void textOutBig(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t color);13void textOutBig(uint32_t xPos, uint32_t yPos, const char *text, uint32_t color);
14void textOutBigBg(uint32_t *frameBuffer, uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor);14void textOutBigBg(uint32_t xPos, uint32_t yPos, const char *text, uint32_t fgColor, uint32_t bgColor);
15void printOneHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);15void printOneHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
16void printTwoHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);16void printTwoHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
17void printThreeHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);17void printThreeHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
18void printFourHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);18void printFourHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
19void printFiveHex(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);19void printFiveHex(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
20void printOneHexBig(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);20void printOneHexBig(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
21void printTwoHexBig(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);21void printTwoHexBig(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
22void printSixDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);22void printSixDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
23void printTwoDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);23void printTwoDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
24void printFourDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);24void printFourDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
25void printFiveDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);25void printFiveDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
26void printThreeDecimals(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);26void printThreeDecimals(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
27void printTwoDecimalsBig(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);27void printTwoDecimalsBig(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor);
28void printOneHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);28void printOneHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
29void printTwoHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);29void printTwoHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
30void printThreeHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);30void printThreeHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
31void printFourHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);31void printFourHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
32void printFiveHexBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);32void printFiveHexBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
33void printOneHexBigBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);33void printOneHexBigBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
34void printTwoHexBigBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);34void printTwoHexBigBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
35void printSixDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);35void printSixDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
36void printTwoDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);36void printTwoDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
37void printFourDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);37void printFourDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
38void printFiveDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);38void printFiveDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
39void printThreeDecimalsBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);39void printThreeDecimalsBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
40void printTwoDecimalsBigBg(uint32_t *frameBuffer, uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);40void printTwoDecimalsBigBg(uint32_t x, uint32_t y, uint32_t value, uint32_t fontColor, uint32_t backColor);
41void setPrevStatusMessage(void);41void setPrevStatusMessage(void);
42void setStatusMessage(const char *msg, bool carry);42void setStatusMessage(const char *msg, bool carry);
43void displayMsg(const char *msg);43void displayMsg(const char *msg);
src/pt2_visuals.c+395−322
@@ -40,24 +40,16 @@ typedef struct sprite_t · 39 unmodified lines
40{40{
41 bool visible;41 bool visible;
42 int8_t pixelType;42 int8_t pixelType;
43 uint16_t newX, newY, x, y, w, h;43 int16_t newX, newY, x, y, w, h;
44 uint32_t colorKey, *refreshBuffer;44 uint32_t colorKey, *refreshBuffer;
45 const void *data;45 const void *data;
46} sprite_t;46} sprite_t;
47 47
48static uint32_t vuMetersBg[4 * (10 * 48)];48static uint32_t vuMetersBg[4 * (10 * 48)];
49static uint64_t timeNext64, timeNext64Frac, _50HzCounter;49static uint64_t timeNext64, timeNext64Frac;
50 50
51sprite_t sprites[SPRITE_NUM]; // globalized51sprite_t sprites[SPRITE_NUM]; // globalized
52 52
53extern bool forceMixerOff; // pt_audio.c
54
55// pt_main.c
56extern uint32_t *pixelBuffer;
57extern SDL_Window *window;
58extern SDL_Renderer *renderer;
59extern SDL_Texture *texture;
60
61static const uint16_t cursorPosTable[24] =53static const uint16_t cursorPosTable[24] =
62{54{
63 30, 54, 62, 70, 78, 86,55 30, 54, 62, 70, 78, 86,
@@ -98,7 +90,7 @@ void setupPerfFreq(void) · 34 unmodified lines
98 dFrac = modf(editor.dPerfFreq / VBLANK_HZ, &dInt);90 dFrac = modf(editor.dPerfFreq / VBLANK_HZ, &dInt);
99 91
100 // integer part92 // integer part
101 editor.vblankTimeLen = (uint32_t)dInt;93 editor.vblankTimeLen = (int32_t)dInt;
102 94
103 // fractional part scaled to 0..2^32-195 // fractional part scaled to 0..2^32-1
104 dFrac *= UINT32_MAX;96 dFrac *= UINT32_MAX;
@@ -156,7 +148,7 @@ void renderFrame(void) · 51 unmodified lines
156 updateSampler();148 updateSampler();
157 updatePosEd();149 updatePosEd();
158 updateVisualizer();150 updateVisualizer();
159 updateDragBars();151 handleLastGUIObjectDown();
160 drawSamplerLine();152 drawSamplerLine();
161}153}
162 154
@@ -203,7 +195,7 @@ void renderAskDialog(void) · 40 unmodified lines
203 // render ask dialog195 // render ask dialog
204 196
205 srcPtr = editor.ui.pat2SmpDialogShown ? pat2SmpDialogBMP : yesNoDialogBMP;197 srcPtr = editor.ui.pat2SmpDialogShown ? pat2SmpDialogBMP : yesNoDialogBMP;
206 dstPtr = &pixelBuffer[(51 * SCREEN_W) + 160];198 dstPtr = &video.frameBuffer[(51 * SCREEN_W) + 160];
207 199
208 for (uint32_t y = 0; y < 39; y++)200 for (uint32_t y = 0; y < 39; y++)
209 {201 {
@@ -225,7 +217,7 @@ void renderBigAskDialog(void) · 15 unmodified lines
225 // render custom big ask dialog217 // render custom big ask dialog
226 218
227 srcPtr = bigYesNoDialogBMP;219 srcPtr = bigYesNoDialogBMP;
228 dstPtr = &pixelBuffer[(44 * SCREEN_W) + 120];220 dstPtr = &video.frameBuffer[(44 * SCREEN_W) + 120];
229 221
230 for (uint32_t y = 0; y < 55; y++)222 for (uint32_t y = 0; y < 55; y++)
231 {223 {
@@ -244,10 +236,10 @@ void showDownsampleAskDialog(void) · 12 unmodified lines
244 setStatusMessage("PLEASE SELECT", NO_CARRY);236 setStatusMessage("PLEASE SELECT", NO_CARRY);
245 renderBigAskDialog();237 renderBigAskDialog();
246 238
247 textOutTight(pixelBuffer, 133, 49, "THE SAMPLE'S FREQUENCY IS", palette[PAL_BACKGRD]);239 textOutTight(133, 49, "THE SAMPLE'S FREQUENCY IS", video.palette[PAL_BACKGRD]);
248 textOutTight(pixelBuffer, 178, 57, "ABOVE 22KHZ.", palette[PAL_BACKGRD]);240 textOutTight(178, 57, "ABOVE 22KHZ.", video.palette[PAL_BACKGRD]);
249 textOutTight(pixelBuffer, 133, 65, "DO YOU WANT TO DOWNSAMPLE", palette[PAL_BACKGRD]);241 textOutTight(133, 65, "DO YOU WANT TO DOWNSAMPLE", video.palette[PAL_BACKGRD]);
250 textOutTight(pixelBuffer, 156, 73, "BEFORE LOADING IT?", palette[PAL_BACKGRD]);242 textOutTight(156, 73, "BEFORE LOADING IT?", video.palette[PAL_BACKGRD]);
251}243}
252 244
253static void fillFromVuMetersBgBuffer(void)245static void fillFromVuMetersBgBuffer(void)
@@ -259,7 +251,7 @@ static void fillFromVuMetersBgBuffer(void) · 5 unmodified lines
259 return;251 return;
260 252
261 srcPtr = vuMetersBg;253 srcPtr = vuMetersBg;
262 dstPtr = &pixelBuffer[(187 * SCREEN_W) + 55];254 dstPtr = &video.frameBuffer[(187 * SCREEN_W) + 55];
263 255
264 for (uint32_t i = 0; i < AMIGA_VOICES; i++)256 for (uint32_t i = 0; i < AMIGA_VOICES; i++)
265 {257 {
@@ -284,7 +276,7 @@ void fillToVuMetersBgBuffer(void) · 18 unmodified lines
284 if (editor.ui.samplerScreenShown || editor.isWAVRendering || editor.isSMPRendering)276 if (editor.ui.samplerScreenShown || editor.isWAVRendering || editor.isSMPRendering)
285 return;277 return;
286 278
287 srcPtr = &pixelBuffer[(187 * SCREEN_W) + 55];279 srcPtr = &video.frameBuffer[(187 * SCREEN_W) + 55];
288 dstPtr = vuMetersBg;280 dstPtr = vuMetersBg;
289 281
290 for (uint32_t i = 0; i < AMIGA_VOICES; i++)282 for (uint32_t i = 0; i < AMIGA_VOICES; i++)
@@ -312,10 +304,10 @@ void renderVuMeters(void) · 21 unmodified lines
312 304
313 fillToVuMetersBgBuffer();305 fillToVuMetersBgBuffer();
314 306
315 dstPtr = &pixelBuffer[(187 * SCREEN_W) + 55];307 dstPtr = &video.frameBuffer[(187 * SCREEN_W) + 55];
316 for (uint32_t i = 0; i < AMIGA_VOICES; i++)308 for (uint32_t i = 0; i < AMIGA_VOICES; i++)
317 {309 {
318 if (ptConfig.realVuMeters)310 if (config.realVuMeters)
319 h = editor.realVuMeterVolumes[i];311 h = editor.realVuMeterVolumes[i];
320 else312 else
321 h = editor.vuMeterVolumes[i];313 h = editor.vuMeterVolumes[i];
@@ -349,20 +341,20 @@ void updateSongInfo1(void) // left side of screen, when Disk Op. is hidden · 27 unmodified lines
349 if (editor.ui.updateSongPos)341 if (editor.ui.updateSongPos)
350 {342 {
351 editor.ui.updateSongPos = false;343 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]);
353 }345 }
354 346
355 if (editor.ui.updateSongPattern)347 if (editor.ui.updateSongPattern)
356 {348 {
357 editor.ui.updateSongPattern = false;349 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]);
359 }351 }
360 352
361 if (editor.ui.updateSongLength)353 if (editor.ui.updateSongLength)
362 {354 {
363 editor.ui.updateSongLength = false;355 editor.ui.updateSongLength = false;
364 if (!editor.isWAVRendering)356 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]);
366 }358 }
367 359
368 if (editor.ui.updateCurrSampleFineTune)360 if (editor.ui.updateCurrSampleFineTune)
@@ -373,18 +365,18 @@ void updateSongInfo1(void) // left side of screen, when Disk Op. is hidden · 4 unmodified lines
373 {365 {
374 if (currSample->fineTune >= 8)366 if (currSample->fineTune >= 8)
375 {367 {
376 charOutBg(pixelBuffer, 80, 36, '-', palette[PAL_GENTXT], palette[PAL_GENBKG]);368 charOutBg(80, 36, '-', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
377 charOutBg(pixelBuffer, 88, 36, '0' + (0x10 - (currSample->fineTune & 0xF)), palette[PAL_GENTXT], palette[PAL_GENBKG]);369 charOutBg(88, 36, '0' + (0x10 - (currSample->fineTune & 0xF)), video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
378 }370 }
379 else if (currSample->fineTune > 0)371 else if (currSample->fineTune > 0)
380 {372 {
381 charOutBg(pixelBuffer, 80, 36, '+', palette[PAL_GENTXT], palette[PAL_GENBKG]);373 charOutBg(80, 36, '+', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
382 charOutBg(pixelBuffer, 88, 36, '0' + (currSample->fineTune & 0xF), palette[PAL_GENTXT], palette[PAL_GENBKG]);374 charOutBg(88, 36, '0' + (currSample->fineTune & 0xF), video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
383 }375 }
384 else376 else
385 {377 {
386 charOutBg(pixelBuffer, 80, 36, ' ', palette[PAL_GENBKG], palette[PAL_GENBKG]);378 charOutBg(80, 36, ' ', video.palette[PAL_GENBKG], video.palette[PAL_GENBKG]);
387 charOutBg(pixelBuffer, 88, 36, '0', palette[PAL_GENTXT], palette[PAL_GENBKG]);379 charOutBg(88, 36, '0', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
388 }380 }
389 }381 }
390 }382 }
@@ -394,8 +386,8 @@ void updateSongInfo1(void) // left side of screen, when Disk Op. is hidden · 3 unmodified lines
394 editor.ui.updateCurrSampleNum = false;386 editor.ui.updateCurrSampleNum = false;
395 if (!editor.isWAVRendering)387 if (!editor.isWAVRendering)
396 {388 {
397 printTwoHexBg(pixelBuffer, 80, 47,389 printTwoHexBg(80, 47,
398 editor.sampleZero ? 0 : ((*editor.currSampleDisp) + 1), palette[PAL_GENTXT], palette[PAL_GENBKG]);390 editor.sampleZero ? 0 : ((*editor.currSampleDisp) + 1), video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
399 }391 }
400 }392 }
401 393
@@ -403,26 +395,26 @@ void updateSongInfo1(void) // left side of screen, when Disk Op. is hidden · 1 unmodified line
403 {395 {
404 editor.ui.updateCurrSampleVolume = false;396 editor.ui.updateCurrSampleVolume = false;
405 if (!editor.isWAVRendering)397 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]);
407 }399 }
408 400
409 if (editor.ui.updateCurrSampleLength)401 if (editor.ui.updateCurrSampleLength)
410 {402 {
411 editor.ui.updateCurrSampleLength = false;403 editor.ui.updateCurrSampleLength = false;
412 if (!editor.isWAVRendering)404 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]);
414 }406 }
415 407
416 if (editor.ui.updateCurrSampleRepeat)408 if (editor.ui.updateCurrSampleRepeat)
417 {409 {
418 editor.ui.updateCurrSampleRepeat = false;410 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]);
420 }412 }
421 413
422 if (editor.ui.updateCurrSampleReplen)414 if (editor.ui.updateCurrSampleReplen)
423 {415 {
424 editor.ui.updateCurrSampleReplen = false;416 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]);
426 }418 }
427}419}
428 420
@@ -437,30 +429,30 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 8 unmodified lines
437 editor.ui.updateStatusText = false;429 editor.ui.updateStatusText = false;
438 430
439 // clear background431 // 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]);
441 433
442 // render status text434 // render status text
443 if (!editor.errorMsgActive && editor.blockMarkFlag && !editor.ui.askScreenShown435 if (!editor.errorMsgActive && editor.blockMarkFlag && !editor.ui.askScreenShown
444 && !editor.ui.clearScreenShown && !editor.swapChannelFlag)436 && !editor.ui.clearScreenShown && !editor.swapChannelFlag)
445 {437 {
446 textOut(pixelBuffer, 88, 127, "MARK BLOCK", palette[PAL_GENTXT]);438 textOut(88, 127, "MARK BLOCK", video.palette[PAL_GENTXT]);
447 charOut(pixelBuffer, 192, 127, '-', palette[PAL_GENTXT]);439 charOut(192, 127, '-', video.palette[PAL_GENTXT]);
448 440
449 editor.blockToPos = modEntry->currRow;441 editor.blockToPos = modEntry->currRow;
450 if (editor.blockFromPos >= editor.blockToPos)442 if (editor.blockFromPos >= editor.blockToPos)
451 {443 {
452 printTwoDecimals(pixelBuffer, 176, 127, editor.blockToPos, palette[PAL_GENTXT]);444 printTwoDecimals(176, 127, editor.blockToPos, video.palette[PAL_GENTXT]);
453 printTwoDecimals(pixelBuffer, 200, 127, editor.blockFromPos, palette[PAL_GENTXT]);445 printTwoDecimals(200, 127, editor.blockFromPos, video.palette[PAL_GENTXT]);
454 }446 }
455 else447 else
456 {448 {
457 printTwoDecimals(pixelBuffer, 176, 127, editor.blockFromPos, palette[PAL_GENTXT]);449 printTwoDecimals(176, 127, editor.blockFromPos, video.palette[PAL_GENTXT]);
458 printTwoDecimals(pixelBuffer, 200, 127, editor.blockToPos, palette[PAL_GENTXT]);450 printTwoDecimals(200, 127, editor.blockToPos, video.palette[PAL_GENTXT]);
459 }451 }
460 }452 }
461 else453 else
462 {454 {
463 textOut(pixelBuffer, 88, 127, editor.ui.statusMessage, palette[PAL_GENTXT]);455 textOut(88, 127, editor.ui.statusMessage, video.palette[PAL_GENTXT]);
464 }456 }
465 }457 }
466 458
@@ -468,62 +460,62 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 1 unmodified line
468 {460 {
469 editor.ui.updateSongBPM = false;461 editor.ui.updateSongBPM = false;
470 if (!editor.ui.samplerScreenShown)462 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]);
472 }464 }
473 465
474 if (editor.ui.updateCurrPattText)466 if (editor.ui.updateCurrPattText)
475 {467 {
476 editor.ui.updateCurrPattText = false;468 editor.ui.updateCurrPattText = false;
477 if (!editor.ui.samplerScreenShown)469 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]);
479 }471 }
480 472
481 if (editor.ui.updateTrackerFlags)473 if (editor.ui.updateTrackerFlags)
482 {474 {
483 editor.ui.updateTrackerFlags = false;475 editor.ui.updateTrackerFlags = false;
484 476
485 charOutBg(pixelBuffer, 1, 113, ' ', palette[PAL_GENTXT], palette[PAL_GENBKG]);477 charOutBg(1, 113, ' ', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
486 charOutBg(pixelBuffer, 8, 113, ' ', palette[PAL_GENTXT], palette[PAL_GENBKG]);478 charOutBg(8, 113, ' ', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
487 479
488 if (editor.autoInsFlag)480 if (editor.autoInsFlag)
489 {481 {
490 charOut(pixelBuffer, 0, 113, 'I', palette[PAL_GENTXT]);482 charOut(0, 113, 'I', video.palette[PAL_GENTXT]);
491 483
492 // in Amiga PT, "auto insert" 9 means 0484 // in Amiga PT, "auto insert" 9 means 0
493 if (editor.autoInsSlot == 9)485 if (editor.autoInsSlot == 9)
494 charOut(pixelBuffer, 8, 113, '0', palette[PAL_GENTXT]);486 charOut(8, 113, '0', video.palette[PAL_GENTXT]);
495 else487 else
496 charOut(pixelBuffer, 8, 113, '1' + editor.autoInsSlot, palette[PAL_GENTXT]);488 charOut(8, 113, '1' + editor.autoInsSlot, video.palette[PAL_GENTXT]);
497 }489 }
498 490
499 charOutBg(pixelBuffer, 1, 102, ' ', palette[PAL_GENTXT], palette[PAL_GENBKG]);491 charOutBg(1, 102, ' ', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
500 if (editor.metroFlag)492 if (editor.metroFlag)
501 charOut(pixelBuffer, 0, 102, 'M', palette[PAL_GENTXT]);493 charOut(0, 102, 'M', video.palette[PAL_GENTXT]);
502 494
503 charOutBg(pixelBuffer, 16, 102, ' ', palette[PAL_GENTXT], palette[PAL_GENBKG]);495 charOutBg(16, 102, ' ', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
504 if (editor.multiFlag)496 if (editor.multiFlag)
505 charOut(pixelBuffer, 16, 102, 'M', palette[PAL_GENTXT]);497 charOut(16, 102, 'M', video.palette[PAL_GENTXT]);
506 498
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]);
508 500
509 charOutBg(pixelBuffer, 311, 128, ' ', palette[PAL_GENBKG], palette[PAL_GENBKG]);501 charOutBg(311, 128, ' ', video.palette[PAL_GENBKG], video.palette[PAL_GENBKG]);
510 if (editor.pNoteFlag == 1)502 if (editor.pNoteFlag == 1)
511 {503 {
512 pixelBuffer[(129 * SCREEN_W) + 314] = palette[PAL_GENTXT];504 video.frameBuffer[(129 * SCREEN_W) + 314] = video.palette[PAL_GENTXT];
513 pixelBuffer[(129 * SCREEN_W) + 315] = palette[PAL_GENTXT];505 video.frameBuffer[(129 * SCREEN_W) + 315] = video.palette[PAL_GENTXT];
514 }506 }
515 else if (editor.pNoteFlag == 2)507 else if (editor.pNoteFlag == 2)
516 {508 {
517 pixelBuffer[(128 * SCREEN_W) + 314] = palette[PAL_GENTXT];509 video.frameBuffer[(128 * SCREEN_W) + 314] = video.palette[PAL_GENTXT];
518 pixelBuffer[(128 * SCREEN_W) + 315] = palette[PAL_GENTXT];510 video.frameBuffer[(128 * SCREEN_W) + 315] = video.palette[PAL_GENTXT];
519 pixelBuffer[(130 * SCREEN_W) + 314] = palette[PAL_GENTXT];511 video.frameBuffer[(130 * SCREEN_W) + 314] = video.palette[PAL_GENTXT];
520 pixelBuffer[(130 * SCREEN_W) + 315] = palette[PAL_GENTXT];512 video.frameBuffer[(130 * SCREEN_W) + 315] = video.palette[PAL_GENTXT];
521 }513 }
522 }514 }
523 515
524 // playback timer516 // playback timer
525 517
526 secs = ((editor.musicTime / 256) * 5) / 512;518 secs = ((editor.musicTime >> 8) * 5) >> 9;
527 secs -= ((secs / 3600) * 3600);519 secs -= ((secs / 3600) * 3600);
528 520
529 if (secs <= 5999) // below 99 minutes 59 seconds521 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
532 MI_TimeS = secs - (MI_TimeM * 60);524 MI_TimeS = secs - (MI_TimeM * 60);
533 525
534 // xx:xx526 // xx:xx
535 printTwoDecimalsBg(pixelBuffer, 272, 102, MI_TimeM, palette[PAL_GENTXT], palette[PAL_GENBKG]);527 printTwoDecimalsBg(272, 102, MI_TimeM, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
536 printTwoDecimalsBg(pixelBuffer, 296, 102, MI_TimeS, palette[PAL_GENTXT], palette[PAL_GENBKG]);528 printTwoDecimalsBg(296, 102, MI_TimeS, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
537 }529 }
538 else530 else
539 {531 {
540 // 99:59532 // 99:59
541 printTwoDecimalsBg(pixelBuffer, 272, 102, 99, palette[PAL_GENTXT], palette[PAL_GENBKG]);533 printTwoDecimalsBg(272, 102, 99, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
542 printTwoDecimalsBg(pixelBuffer, 296, 102, 59, palette[PAL_GENTXT], palette[PAL_GENBKG]);534 printTwoDecimalsBg(296, 102, 59, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
543 }535 }
544 536
545 if (editor.ui.updateSongName)537 if (editor.ui.updateSongName)
@@ -551,7 +543,7 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 5 unmodified lines
551 if (tempChar == '\0')543 if (tempChar == '\0')
552 tempChar = '_';544 tempChar = '_';
553 545
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]);
555 }547 }
556 }548 }
557 549
@@ -566,7 +558,7 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 8 unmodified lines
566 if (tempChar == '\0')558 if (tempChar == '\0')
567 tempChar = '_';559 tempChar = '_';
568 560
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]);
570 }562 }
571 }563 }
572 564
@@ -575,7 +567,7 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 2 unmodified lines
575 editor.ui.updateSongSize = false;567 editor.ui.updateSongSize = false;
576 568
577 // clear background569 // 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]);
579 571
580 // calculate module length572 // calculate module length
581 uint32_t totalSampleDataSize = 0;573 uint32_t totalSampleDataSize = 0;
@@ -592,19 +584,19 @@ void updateSongInfo2(void) // two middle rows of screen, always present · 10 unmodified lines
592 uint32_t moduleSize = 2108 + (totalPatterns * 1024) + totalSampleDataSize;584 uint32_t moduleSize = 2108 + (totalPatterns * 1024) + totalSampleDataSize;
593 if (moduleSize > 999999)585 if (moduleSize > 999999)
594 {586 {
595 charOut(pixelBuffer, 304, 123, 'K', palette[PAL_GENTXT]);587 charOut(304, 123, 'K', video.palette[PAL_GENTXT]);
596 printFourDecimals(pixelBuffer, 272, 123, moduleSize / 1000, palette[PAL_GENTXT]);588 printFourDecimals(272, 123, moduleSize / 1000, video.palette[PAL_GENTXT]);
597 }589 }
598 else590 else
599 {591 {
600 printSixDecimals(pixelBuffer, 264, 123, moduleSize, palette[PAL_GENTXT]);592 printSixDecimals(264, 123, moduleSize, video.palette[PAL_GENTXT]);
601 }593 }
602 }594 }
603 595
604 if (editor.ui.updateSongTiming)596 if (editor.ui.updateSongTiming)
605 {597 {
606 editor.ui.updateSongTiming = false;598 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]);
608 }600 }
609}601}
610 602
@@ -626,11 +618,11 @@ void updateSampler(void) · 15 unmodified lines
626 s = &modEntry->samples[editor.currSample];618 s = &modEntry->samples[editor.currSample];
627 619
628 // update 9xx offset620 // 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)
630 {622 {
631 if (!editor.ui.samplerVolBoxShown && !editor.ui.samplerFiltersBoxShown && s->length > 0)623 if (!editor.ui.samplerVolBoxShown && !editor.ui.samplerFiltersBoxShown && s->length > 0)
632 {624 {
633 tmpSampleOffset = (scr2SmpPos(input.mouse.x-3) + (1 << 7)) >> 8; // rounded625 tmpSampleOffset = (scr2SmpPos(mouse.x-3) + (1 << 7)) >> 8; // rounded
634 tmpSampleOffset = 0x900 + CLAMP(tmpSampleOffset, 0x00, 0xFF);626 tmpSampleOffset = 0x900 + CLAMP(tmpSampleOffset, 0x00, 0xFF);
635 627
636 if (tmpSampleOffset != editor.ui.lastSampleOffset)628 if (tmpSampleOffset != editor.ui.lastSampleOffset)
@@ -645,7 +637,7 @@ void updateSampler(void) · 8 unmodified lines
645 if (editor.ui.update9xxPos)637 if (editor.ui.update9xxPos)
646 {638 {
647 editor.ui.update9xxPos = false;639 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]);
649 }641 }
650 642
651 if (editor.ui.updateResampleNote)643 if (editor.ui.updateResampleNote)
@@ -655,14 +647,14 @@ void updateSampler(void) · 3 unmodified lines
655 // show resample note647 // show resample note
656 if (editor.ui.changingSmpResample)648 if (editor.ui.changingSmpResample)
657 {649 {
658 textOutBg(pixelBuffer, 288, 236, "---", palette[PAL_GENTXT], palette[PAL_GENBKG]);650 textOutBg(288, 236, "---", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
659 }651 }
660 else652 else
661 {653 {
662 assert(editor.resampleNote < 36);654 assert(editor.resampleNote < 36);
663 textOutBg(pixelBuffer, 288, 236,655 textOutBg(288, 236,
664 ptConfig.accidental ? noteNames2[editor.resampleNote] : noteNames1[editor.resampleNote],656 config.accidental ? noteNames2[editor.resampleNote] : noteNames1[editor.resampleNote],
665 palette[PAL_GENTXT], palette[PAL_GENBKG]);657 video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
666 }658 }
667 }659 }
668 660
@@ -671,13 +663,13 @@ void updateSampler(void) · 2 unmodified lines
671 if (editor.ui.updateVolFromText)663 if (editor.ui.updateVolFromText)
672 {664 {
673 editor.ui.updateVolFromText = false;665 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]);
675 }667 }
676 668
677 if (editor.ui.updateVolToText)669 if (editor.ui.updateVolToText)
678 {670 {
679 editor.ui.updateVolToText = false;671 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]);
681 }673 }
682 }674 }
683 else if (editor.ui.samplerFiltersBoxShown)675 else if (editor.ui.samplerFiltersBoxShown)
@@ -685,13 +677,13 @@ void updateSampler(void) · 1 unmodified line
685 if (editor.ui.updateLPText)677 if (editor.ui.updateLPText)
686 {678 {
687 editor.ui.updateLPText = false;679 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]);
689 }681 }
690 682
691 if (editor.ui.updateHPText)683 if (editor.ui.updateHPText)
692 {684 {
693 editor.ui.updateHPText = false;685 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]);
695 }687 }
696 688
697 if (editor.ui.updateNormFlag)689 if (editor.ui.updateNormFlag)
@@ -699,9 +691,9 @@ void updateSampler(void) · 1 unmodified line
699 editor.ui.updateNormFlag = false;691 editor.ui.updateNormFlag = false;
700 692
701 if (editor.normalizeFiltersFlag)693 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]);
703 else695 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]);
705 }697 }
706 }698 }
707}699}
@@ -712,9 +704,9 @@ void showVolFromSlider(void) · 4 unmodified lines
712 704
713 sliderStart = ((editor.vol1 * 3) + 5) / 10;705 sliderStart = ((editor.vol1 * 3) + 5) / 10;
714 sliderEnd = sliderStart + 4;706 sliderEnd = sliderStart + 4;
715 pixel = palette[PAL_QADSCP];707 pixel = video.palette[PAL_QADSCP];
716 bgPixel = palette[PAL_BACKGRD];708 bgPixel = video.palette[PAL_BACKGRD];
717 dstPtr = &pixelBuffer[(158 * SCREEN_W) + 105];709 dstPtr = &video.frameBuffer[(158 * SCREEN_W) + 105];
718 710
719 for (uint32_t y = 0; y < 3; y++)711 for (uint32_t y = 0; y < 3; y++)
720 {712 {
@@ -736,9 +728,9 @@ void showVolToSlider(void) · 15 unmodified lines
736 728
737 sliderStart = ((editor.vol2 * 3) + 5) / 10;729 sliderStart = ((editor.vol2 * 3) + 5) / 10;
738 sliderEnd = sliderStart + 4;730 sliderEnd = sliderStart + 4;
739 pixel = palette[PAL_QADSCP];731 pixel = video.palette[PAL_QADSCP];
740 bgPixel = palette[PAL_BACKGRD];732 bgPixel = video.palette[PAL_BACKGRD];
741 dstPtr = &pixelBuffer[(169 * SCREEN_W) + 105];733 dstPtr = &video.frameBuffer[(169 * SCREEN_W) + 105];
742 734
743 for (uint32_t y = 0; y < 3; y++)735 for (uint32_t y = 0; y < 3; y++)
744 {736 {
@@ -760,7 +752,7 @@ void renderSamplerVolBox(void) · 15 unmodified lines
760 uint32_t *dstPtr;752 uint32_t *dstPtr;
761 753
762 srcPtr = samplerVolumeBMP;754 srcPtr = samplerVolumeBMP;
763 dstPtr = &pixelBuffer[(154 * SCREEN_W) + 72];755 dstPtr = &video.frameBuffer[(154 * SCREEN_W) + 72];
764 756
765 for (uint32_t y = 0; y < 33; y++)757 for (uint32_t y = 0; y < 33; y++)
766 {758 {
@@ -791,7 +783,7 @@ void renderSamplerFiltersBox(void) · 24 unmodified lines
791 uint32_t *dstPtr;783 uint32_t *dstPtr;
792 784
793 srcPtr = samplerFiltersBMP;785 srcPtr = samplerFiltersBMP;
794 dstPtr = &pixelBuffer[(154 * SCREEN_W) + 65];786 dstPtr = &video.frameBuffer[(154 * SCREEN_W) + 65];
795 787
796 for (uint32_t y = 0; y < 33; y++)788 for (uint32_t y = 0; y < 33; y++)
797 {789 {
@@ -801,8 +793,8 @@ void renderSamplerFiltersBox(void) · 3 unmodified lines
801 dstPtr += SCREEN_W;793 dstPtr += SCREEN_W;
802 }794 }
803 795
804 textOut(pixelBuffer, 200, 157, "HZ", palette[PAL_GENTXT]);796 textOut(200, 157, "HZ", video.palette[PAL_GENTXT]);
805 textOut(pixelBuffer, 200, 168, "HZ", palette[PAL_GENTXT]);797 textOut(200, 168, "HZ", video.palette[PAL_GENTXT]);
806 798
807 editor.ui.updateLPText = true;799 editor.ui.updateLPText = true;
808 editor.ui.updateHPText = true;800 editor.ui.updateHPText = true;
@@ -820,7 +812,7 @@ void removeSamplerFiltersBox(void) · 11 unmodified lines
820 812
821void renderDiskOpScreen(void)813void renderDiskOpScreen(void)
822{814{
823 memcpy(pixelBuffer, diskOpScreenBMP, (99 * 320) * sizeof (int32_t));815 memcpy(video.frameBuffer, diskOpScreenBMP, (99 * 320) * sizeof (int32_t));
824 816
825 editor.ui.updateDiskOpPathText = true;817 editor.ui.updateDiskOpPathText = true;
826 editor.ui.updatePackText = true;818 editor.ui.updatePackText = true;
@@ -841,7 +833,7 @@ void updateDiskOp(void) · 14 unmodified lines
841 if (editor.ui.updateDiskOpFileList)833 if (editor.ui.updateDiskOpFileList)
842 {834 {
843 editor.ui.updateDiskOpFileList = false;835 editor.ui.updateDiskOpFileList = false;
844 diskOpRenderFileList(pixelBuffer);836 diskOpRenderFileList();
845 }837 }
846 838
847 if (editor.ui.updateLoadMode)839 if (editor.ui.updateLoadMode)
@@ -849,13 +841,13 @@ void updateDiskOp(void) · 1 unmodified line
849 editor.ui.updateLoadMode = false;841 editor.ui.updateLoadMode = false;
850 842
851 // clear backgrounds843 // clear backgrounds
852 charOutBg(pixelBuffer, 147, 3, ' ', palette[PAL_GENBKG], palette[PAL_GENBKG]);844 charOutBg(147, 3, ' ', video.palette[PAL_GENBKG], video.palette[PAL_GENBKG]);
853 charOutBg(pixelBuffer, 147, 14, ' ', palette[PAL_GENBKG], palette[PAL_GENBKG]);845 charOutBg(147, 14, ' ', video.palette[PAL_GENBKG], video.palette[PAL_GENBKG]);
854 846
855 // draw load mode arrow847 // draw load mode arrow
856 848
857 srcPtr = arrowBMP;849 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];
859 851
860 for (uint32_t y = 0; y < 5; y++)852 for (uint32_t y = 0; y < 5; y++)
861 {853 {
@@ -870,15 +862,15 @@ void updateDiskOp(void) · 8 unmodified lines
870 if (editor.ui.updatePackText)862 if (editor.ui.updatePackText)
871 {863 {
872 editor.ui.updatePackText = false;864 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]);
874 }866 }
875 867
876 if (editor.ui.updateSaveFormatText)868 if (editor.ui.updateSaveFormatText)
877 {869 {
878 editor.ui.updateSaveFormatText = false;870 editor.ui.updateSaveFormatText = false;
879 if (editor.diskop.smpSaveType == DISKOP_SMP_WAV) textOutBg(pixelBuffer, 120, 14, "WAV", 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]);
880 else if (editor.diskop.smpSaveType == DISKOP_SMP_IFF) textOutBg(pixelBuffer, 120, 14, "IFF", palette[PAL_GENTXT], palette[PAL_GENBKG]);872 else if (editor.diskop.smpSaveType == DISKOP_SMP_IFF) textOutBg(120, 14, "IFF", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
881 else if (editor.diskop.smpSaveType == DISKOP_SMP_RAW) textOutBg(pixelBuffer, 120, 14, "RAW", palette[PAL_GENTXT], palette[PAL_GENBKG]);873 else if (editor.diskop.smpSaveType == DISKOP_SMP_RAW) textOutBg(120, 14, "RAW", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
882 }874 }
883 875
884 if (editor.ui.updateDiskOpPathText)876 if (editor.ui.updateDiskOpPathText)
@@ -892,7 +884,7 @@ void updateDiskOp(void) · 7 unmodified lines
892 if (tmpChar == '\0')884 if (tmpChar == '\0')
893 tmpChar = '_';885 tmpChar = '_';
894 886
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]);
896 }888 }
897 }889 }
898}890}
@@ -910,7 +902,7 @@ void updatePosEd(void) · 11 unmodified lines
910 902
911 if (!editor.ui.disablePosEd)903 if (!editor.ui.disablePosEd)
912 {904 {
913 bgPixel = palette[PAL_BACKGRD];905 bgPixel = video.palette[PAL_BACKGRD];
914 906
915 posEdPosition = modEntry->currOrder;907 posEdPosition = modEntry->currOrder;
916 if (posEdPosition > modEntry->head.orderCount-1)908 if (posEdPosition > modEntry->head.orderCount-1)
@@ -921,15 +913,12 @@ void updatePosEd(void) · 4 unmodified lines
921 {913 {
922 if (posEdPosition-(5-y) >= 0)914 if (posEdPosition-(5-y) >= 0)
923 {915 {
924 printThreeDecimalsBg(pixelBuffer, 128, 23+(y*6),916 printThreeDecimalsBg(128, 23+(y*6), posEdPosition-(5-y), video.palette[PAL_QADSCP], video.palette[PAL_BACKGRD]);
925 posEdPosition-(5-y), palette[PAL_QADSCP], palette[PAL_BACKGRD]);917 printTwoDecimalsBg(160, 23+(y*6), modEntry->head.order[posEdPosition-(5-y)], video.palette[PAL_QADSCP], video.palette[PAL_BACKGRD]);
926
927 printTwoDecimalsBg(pixelBuffer, 160, 23+(y*6), modEntry->head.order[posEdPosition-(5-y)],
928 palette[PAL_QADSCP], palette[PAL_BACKGRD]);
929 }918 }
930 else919 else
931 {920 {
932 dstPtr = &pixelBuffer[((23+(y*6)) * SCREEN_W) + 128];921 dstPtr = &video.frameBuffer[((23+(y*6)) * SCREEN_W) + 128];
933 for (y2 = 0; y2 < 5; y2++)922 for (y2 = 0; y2 < 5; y2++)
934 {923 {
935 for (x = 0; x < FONT_CHAR_W*22; x++)924 for (x = 0; x < FONT_CHAR_W*22; x++)
@@ -941,23 +930,20 @@ void updatePosEd(void) · 5 unmodified lines
941 }930 }
942 931
943 // middle932 // middle
944 printThreeDecimalsBg(pixelBuffer, 128, 53, posEdPosition, palette[PAL_GENTXT], palette[PAL_GENBKG]);933 printThreeDecimalsBg(128, 53, posEdPosition, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
945 printTwoDecimalsBg(pixelBuffer, 160, 53, *editor.currPosEdPattDisp, palette[PAL_GENTXT], palette[PAL_GENBKG]);934 printTwoDecimalsBg(160, 53, *editor.currPosEdPattDisp, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
946 935
947 // bottom six936 // bottom six
948 for (y = 0; y < 6; y++)937 for (y = 0; y < 6; y++)
949 {938 {
950 if (posEdPosition+y < modEntry->head.orderCount-1)939 if (posEdPosition+y < modEntry->head.orderCount-1)
951 {940 {
952 printThreeDecimalsBg(pixelBuffer, 128, 59+(y*6), posEdPosition+(y+1),941 printThreeDecimalsBg(128, 59+(y*6), posEdPosition+(y+1), video.palette[PAL_QADSCP], video.palette[PAL_BACKGRD]);
953 palette[PAL_QADSCP], palette[PAL_BACKGRD]);942 printTwoDecimalsBg(160, 59+(y*6), modEntry->head.order[posEdPosition+(y+1)], video.palette[PAL_QADSCP], video.palette[PAL_BACKGRD]);
954
955 printTwoDecimalsBg(pixelBuffer, 160, 59+(y*6), modEntry->head.order[posEdPosition+(y+1)],
956 palette[PAL_QADSCP], palette[PAL_BACKGRD]);
957 }943 }
958 else944 else
959 {945 {
960 dstPtr = &pixelBuffer[((59+(y*6)) * SCREEN_W) + 128];946 dstPtr = &video.frameBuffer[((59+(y*6)) * SCREEN_W) + 128];
961 for (y2 = 0; y2 < 5; y2++)947 for (y2 = 0; y2 < 5; y2++)
962 {948 {
963 for (x = 0; x < FONT_CHAR_W*22; x++)949 for (x = 0; x < FONT_CHAR_W*22; x++)
@@ -980,7 +966,7 @@ void renderPosEdScreen(void) · 16 unmodified lines
980 uint32_t *dstPtr;966 uint32_t *dstPtr;
981 967
982 srcPtr = posEdBMP;968 srcPtr = posEdBMP;
983 dstPtr = &pixelBuffer[120];969 dstPtr = &video.frameBuffer[120];
984 970
985 for (uint32_t y = 0; y < 99; y++)971 for (uint32_t y = 0; y < 99; y++)
986 {972 {
@@ -999,7 +985,7 @@ void renderMuteButtons(void) · 12 unmodified lines
999 if (editor.ui.diskOpScreenShown || editor.ui.posEdScreenShown)985 if (editor.ui.diskOpScreenShown || editor.ui.posEdScreenShown)
1000 return;986 return;
1001 987
1002 dstPtr = &pixelBuffer[(3 * SCREEN_W) + 310];988 dstPtr = &video.frameBuffer[(3 * SCREEN_W) + 310];
1003 for (uint32_t i = 0; i < AMIGA_VOICES; i++)989 for (uint32_t i = 0; i < AMIGA_VOICES; i++)
1004 {990 {
1005 if (editor.muted[i])991 if (editor.muted[i])
@@ -1035,7 +1021,7 @@ void renderClearScreen(void) · 29 unmodified lines
1035 editor.ui.disableVisualizer = true;1021 editor.ui.disableVisualizer = true;
1036 1022
1037 srcPtr = clearDialogBMP;1023 srcPtr = clearDialogBMP;
1038 dstPtr = &pixelBuffer[(51 * SCREEN_W) + 160];1024 dstPtr = &video.frameBuffer[(51 * SCREEN_W) + 160];
1039 1025
1040 for (uint32_t y = 0; y < 39; y++)1026 for (uint32_t y = 0; y < 39; y++)
1041 {1027 {
@@ -1085,7 +1071,7 @@ void updatePatternData(void) · 43 unmodified lines
1085 {1071 {
1086 editor.ui.updatePatternData = false;1072 editor.ui.updatePatternData = false;
1087 if (!editor.ui.samplerScreenShown)1073 if (!editor.ui.samplerScreenShown)
1088 redrawPattern(pixelBuffer);1074 redrawPattern();
1089 }1075 }
1090}1076}
1091 1077
@@ -1096,13 +1082,13 @@ void removeTextEditMarker(void) · 4 unmodified lines
1096 if (!editor.ui.editTextFlag)1082 if (!editor.ui.editTextFlag)
1097 return;1083 return;
1098 1084
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)];
1100 1086
1101 if (editor.ui.editObject == PTB_PE_PATT)1087 if (editor.ui.editObject == PTB_PE_PATT)
1102 {1088 {
1103 // position editor text editing1089 // position editor text editing
1104 1090
1105 pixel = palette[PAL_GENBKG2];1091 pixel = video.palette[PAL_GENBKG2];
1106 for (uint32_t x = 0; x < 7; x++)1092 for (uint32_t x = 0; x < 7; x++)
1107 dstPtr[x] = pixel;1093 dstPtr[x] = pixel;
1108 1094
@@ -1114,7 +1100,7 @@ void removeTextEditMarker(void) · 5 unmodified lines
1114 {1100 {
1115 // all others1101 // all others
1116 1102
1117 pixel = palette[PAL_GENBKG];1103 pixel = video.palette[PAL_GENBKG];
1118 for (uint32_t y = 0; y < 2; y++)1104 for (uint32_t y = 0; y < 2; y++)
1119 {1105 {
1120 for (uint32_t x = 0; x < 7; x++)1106 for (uint32_t x = 0; x < 7; x++)
@@ -1132,8 +1118,8 @@ void renderTextEditMarker(void) · 11 unmodified lines
1132 if (!editor.ui.editTextFlag)1118 if (!editor.ui.editTextFlag)
1133 return;1119 return;
1134 1120
1135 dstPtr = &pixelBuffer[((editor.ui.lineCurY - 1) * SCREEN_W) + (editor.ui.lineCurX - 4)];1121 dstPtr = &video.frameBuffer[((editor.ui.lineCurY - 1) * SCREEN_W) + (editor.ui.lineCurX - 4)];
1136 pixel = palette[PAL_TEXTMARK];1122 pixel = video.palette[PAL_TEXTMARK];
1137 1123
1138 for (uint32_t y = 0; y < 2; y++)1124 for (uint32_t y = 0; y < 2; y++)
1139 {1125 {
@@ -1144,12 +1130,60 @@ void renderTextEditMarker(void) · 4 unmodified lines
1144 }1130 }
1145}1131}
1146 1132
1147void updateDragBars(void)1133static void sendMouseButtonUpEvent(uint8_t button)
1148{1134{
1149 if (editor.ui.sampleMarkingPos >= 0) samplerSamplePressed(MOUSE_BUTTON_HELD);1135 SDL_Event event;
1150 if (editor.ui.forceSampleDrag) samplerBarPressed(MOUSE_BUTTON_HELD);1136
1151 if (editor.ui.forceSampleEdit) samplerEditSample(MOUSE_BUTTON_HELD);1137 memset(&event, 0, sizeof (event));
1152 if (editor.ui.forceVolDrag) volBoxBarPressed(MOUSE_BUTTON_HELD);1138
1139 event.type = SDL_MOUSEBUTTONUP;
1140 event.button.button = button;
1141
1142 SDL_PushEvent(&event);
1143}
1144
1145void 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 }
1153}1187}
1154 1188
1155void updateVisualizer(void)1189void updateVisualizer(void)
@@ -1170,11 +1204,11 @@ void updateVisualizer(void) · 14 unmodified lines
1170 {1204 {
1171 // spectrum analyzer1205 // spectrum analyzer
1172 1206
1173 dstPtr = &pixelBuffer[(59 * SCREEN_W) + 129];1207 dstPtr = &video.frameBuffer[(59 * SCREEN_W) + 129];
1174 for (uint32_t i = 0; i < SPECTRUM_BAR_NUM; i++)1208 for (uint32_t i = 0; i < SPECTRUM_BAR_NUM; i++)
1175 {1209 {
1176 srcPtr = spectrumAnaBMP;1210 srcPtr = spectrumAnaBMP;
1177 pixel = palette[PAL_GENBKG];1211 pixel = video.palette[PAL_GENBKG];
1178 1212
1179 tmpVol = editor.spectrumVolumes[i];1213 tmpVol = editor.spectrumVolumes[i];
1180 if (tmpVol > SPECTRUM_BAR_HEIGHT)1214 if (tmpVol > SPECTRUM_BAR_HEIGHT)
@@ -1206,7 +1240,7 @@ void renderQuadrascopeBg(void) · 25 unmodified lines
1206 uint32_t *dstPtr;1240 uint32_t *dstPtr;
1207 1241
1208 srcPtr = &trackerFrameBMP[(44 * SCREEN_W) + 120];1242 srcPtr = &trackerFrameBMP[(44 * SCREEN_W) + 120];
1209 dstPtr = &pixelBuffer[(44 * SCREEN_W) + 120];1243 dstPtr = &video.frameBuffer[(44 * SCREEN_W) + 120];
1210 1244
1211 for (uint32_t y = 0; y < 55; y++)1245 for (uint32_t y = 0; y < 55; y++)
1212 {1246 {
@@ -1226,7 +1260,7 @@ void renderSpectrumAnalyzerBg(void) · 13 unmodified lines
1226 uint32_t *dstPtr;1260 uint32_t *dstPtr;
1227 1261
1228 srcPtr = spectrumVisualsBMP;1262 srcPtr = spectrumVisualsBMP;
1229 dstPtr = &pixelBuffer[(44 * SCREEN_W) + 120];1263 dstPtr = &video.frameBuffer[(44 * SCREEN_W) + 120];
1230 1264
1231 for (uint32_t y = 0; y < 55; y++)1265 for (uint32_t y = 0; y < 55; y++)
1232 {1266 {
@@ -1247,7 +1281,7 @@ void renderAboutScreen(void) · 14 unmodified lines
1247 return;1281 return;
1248 1282
1249 srcPtr = aboutScreenBMP;1283 srcPtr = aboutScreenBMP;
1250 dstPtr = &pixelBuffer[(44 * SCREEN_W) + 120];1284 dstPtr = &video.frameBuffer[(44 * SCREEN_W) + 120];
1251 1285
1252 for (uint32_t y = 0; y < 55; y++)1286 for (uint32_t y = 0; y < 55; y++)
1253 {1287 {
@@ -1261,7 +1295,7 @@ void renderAboutScreen(void) · 7 unmodified lines
1261 1295
1262 sprintf(verString, "v%s", PROG_VER_STR);1296 sprintf(verString, "v%s", PROG_VER_STR);
1263 verStringX = 260 + (((63 - ((uint32_t)strlen(verString) * (FONT_CHAR_W - 1))) + 1) / 2);1297 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]);
1265}1299}
1266 1300
1267void renderEditOpMode(void)1301void renderEditOpMode(void)
@@ -1297,7 +1331,7 @@ void renderEditOpMode(void) · 29 unmodified lines
1297 1331
1298 // render it...1332 // render it...
1299 1333
1300 dstPtr = &pixelBuffer[(47 * SCREEN_W) + 310];1334 dstPtr = &video.frameBuffer[(47 * SCREEN_W) + 310];
1301 for (uint32_t y = 0; y < 6; y++)1335 for (uint32_t y = 0; y < 6; y++)
1302 {1336 {
1303 for (uint32_t x = 0; x < 7; x++)1337 for (uint32_t x = 0; x < 7; x++)
@@ -1324,7 +1358,7 @@ void renderEditOpScreen(void) · 20 unmodified lines
1324 }1358 }
1325 1359
1326 // render background1360 // render background
1327 dstPtr = &pixelBuffer[(44 * SCREEN_W) + 120];1361 dstPtr = &video.frameBuffer[(44 * SCREEN_W) + 120];
1328 for (uint32_t y = 0; y < 55; y++)1362 for (uint32_t y = 0; y < 55; y++)
1329 {1363 {
1330 memcpy(dstPtr, srcPtr, 200 * sizeof (int32_t));1364 memcpy(dstPtr, srcPtr, 200 * sizeof (int32_t));
@@ -1338,11 +1372,11 @@ void renderEditOpScreen(void) · 7 unmodified lines
1338 // render text and content1372 // render text and content
1339 if (editor.ui.editOpScreen == 0)1373 if (editor.ui.editOpScreen == 0)
1340 {1374 {
1341 textOut(pixelBuffer, 128, 47, " TRACK PATTERN ", palette[PAL_GENTXT]);1375 textOut(128, 47, " TRACK PATTERN ", video.palette[PAL_GENTXT]);
1342 }1376 }
1343 else if (editor.ui.editOpScreen == 1)1377 else if (editor.ui.editOpScreen == 1)
1344 {1378 {
1345 textOut(pixelBuffer, 128, 47, " RECORD SAMPLES ", palette[PAL_GENTXT]);1379 textOut(128, 47, " RECORD SAMPLES ", video.palette[PAL_GENTXT]);
1346 1380
1347 editor.ui.updateRecordText = true;1381 editor.ui.updateRecordText = true;
1348 editor.ui.updateQuantizeText = true;1382 editor.ui.updateQuantizeText = true;
@@ -1354,8 +1388,8 @@ void renderEditOpScreen(void) · 5 unmodified lines
1354 }1388 }
1355 else if (editor.ui.editOpScreen == 2)1389 else if (editor.ui.editOpScreen == 2)
1356 {1390 {
1357 textOut(pixelBuffer, 128, 47, " SAMPLE EDITOR ", palette[PAL_GENTXT]);1391 textOut(128, 47, " SAMPLE EDITOR ", video.palette[PAL_GENTXT]);
1358 charOut(pixelBuffer, 272, 91, '%', palette[PAL_GENTXT]); // for Volume text1392 charOut(272, 91, '%', video.palette[PAL_GENTXT]); // for Volume text
1359 1393
1360 editor.ui.updatePosText = true;1394 editor.ui.updatePosText = true;
1361 editor.ui.updateModText = true;1395 editor.ui.updateModText = true;
@@ -1363,7 +1397,7 @@ void renderEditOpScreen(void) · 1 unmodified line
1363 }1397 }
1364 else if (editor.ui.editOpScreen == 3)1398 else if (editor.ui.editOpScreen == 3)
1365 {1399 {
1366 textOut(pixelBuffer, 128, 47, " SAMPLE CHORD EDITOR ", palette[PAL_GENTXT]);1400 textOut(128, 47, " SAMPLE CHORD EDITOR ", video.palette[PAL_GENTXT]);
1367 1401
1368 editor.ui.updateLengthText = true;1402 editor.ui.updateLengthText = true;
1369 editor.ui.updateNote1Text = true;1403 editor.ui.updateNote1Text = true;
@@ -1379,7 +1413,7 @@ void renderMOD2WAVDialog(void) · 9 unmodified lines
1379 uint32_t *dstPtr;1413 uint32_t *dstPtr;
1380 1414
1381 srcPtr = mod2wavBMP;1415 srcPtr = mod2wavBMP;
1382 dstPtr = &pixelBuffer[(27 * SCREEN_W) + 64];1416 dstPtr = &video.frameBuffer[(27 * SCREEN_W) + 64];
1383 1417
1384 for (uint32_t y = 0; y < 48; y++)1418 for (uint32_t y = 0; y < 48; y++)
1385 {1419 {
@@ -1431,9 +1465,9 @@ void updateMOD2WAVDialog(void) · 45 unmodified lines
1431 percent = 100;1465 percent = 100;
1432 1466
1433 barLength = ((percent * 180) + 50) / 100;1467 barLength = ((percent * 180) + 50) / 100;
1434 dstPtr = &pixelBuffer[(42 * SCREEN_W) + 70];1468 dstPtr = &video.frameBuffer[(42 * SCREEN_W) + 70];
1435 pixel = palette[PAL_GENBKG2];1469 pixel = video.palette[PAL_GENBKG2];
1436 bgPixel = palette[PAL_BORDER];1470 bgPixel = video.palette[PAL_BORDER];
1437 1471
1438 for (int32_t y = 0; y < 11; y++)1472 for (int32_t y = 0; y < 11; y++)
1439 {1473 {
@@ -1450,13 +1484,13 @@ void updateMOD2WAVDialog(void) · 10 unmodified lines
1450 }1484 }
1451 1485
1452 // render percentage1486 // render percentage
1453 pixel = palette[PAL_GENTXT];1487 pixel = video.palette[PAL_GENTXT];
1454 if (percent > 99)1488 if (percent > 99)
1455 printThreeDecimals(pixelBuffer, 144, 45, percent, pixel);1489 printThreeDecimals(144, 45, percent, pixel);
1456 else1490 else
1457 printTwoDecimals(pixelBuffer, 152, 45, percent, pixel);1491 printTwoDecimals(152, 45, percent, pixel);
1458 1492
1459 charOut(pixelBuffer, 168, 45, '%', pixel);1493 charOut(168, 45, '%', pixel);
1460 }1494 }
1461 }1495 }
1462}1496}
@@ -1471,44 +1505,43 @@ void updateEditOp(void) · 8 unmodified lines
1471 if (editor.ui.updateRecordText)1505 if (editor.ui.updateRecordText)
1472 {1506 {
1473 editor.ui.updateRecordText = false;1507 editor.ui.updateRecordText = false;
1474 textOutBg(pixelBuffer, 176, 58, (editor.recordMode == RECORD_PATT) ? "PATT" : "SONG",1508 textOutBg(176, 58, (editor.recordMode == RECORD_PATT) ? "PATT" : "SONG", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
1475 palette[PAL_GENTXT], palette[PAL_GENBKG]);
1476 }1509 }
1477 1510
1478 if (editor.ui.updateQuantizeText)1511 if (editor.ui.updateQuantizeText)
1479 {1512 {
1480 editor.ui.updateQuantizeText = false;1513 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]);
1482 }1515 }
1483 1516
1484 if (editor.ui.updateMetro1Text)1517 if (editor.ui.updateMetro1Text)
1485 {1518 {
1486 editor.ui.updateMetro1Text = false;1519 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]);
1488 }1521 }
1489 1522
1490 if (editor.ui.updateMetro2Text)1523 if (editor.ui.updateMetro2Text)
1491 {1524 {
1492 editor.ui.updateMetro2Text = false;1525 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]);
1494 }1527 }
1495 1528
1496 if (editor.ui.updateFromText)1529 if (editor.ui.updateFromText)
1497 {1530 {
1498 editor.ui.updateFromText = false;1531 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]);
1500 }1533 }
1501 1534
1502 if (editor.ui.updateKeysText)1535 if (editor.ui.updateKeysText)
1503 {1536 {
1504 editor.ui.updateKeysText = false;1537 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]);
1506 }1539 }
1507 1540
1508 if (editor.ui.updateToText)1541 if (editor.ui.updateToText)
1509 {1542 {
1510 editor.ui.updateToText = false;1543 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]);
1512 }1545 }
1513 }1546 }
1514 else if (editor.ui.editOpScreen == 2)1547 else if (editor.ui.editOpScreen == 2)
@@ -1518,38 +1551,38 @@ void updateEditOp(void) · 3 unmodified lines
1518 editor.ui.updateMixText = false;1551 editor.ui.updateMixText = false;
1519 if (editor.mixFlag)1552 if (editor.mixFlag)
1520 {1553 {
1521 textOutBg(pixelBuffer, 128, 47, editor.mixText, palette[PAL_GENTXT], palette[PAL_GENBKG]);1554 textOutBg(128, 47, editor.mixText, video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
1522 textOutBg(pixelBuffer, 248, 47, " ", palette[PAL_GENTXT], palette[PAL_GENBKG]);1555 textOutBg(248, 47, " ", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
1523 }1556 }
1524 else1557 else
1525 {1558 {
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]);
1527 }1560 }
1528 }1561 }
1529 1562
1530 if (editor.ui.updatePosText)1563 if (editor.ui.updatePosText)
1531 {1564 {
1532 editor.ui.updatePosText = false;1565 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]);
1534 }1567 }
1535 1568
1536 if (editor.ui.updateModText)1569 if (editor.ui.updateModText)
1537 {1570 {
1538 editor.ui.updateModText = false;1571 editor.ui.updateModText = false;
1539 printThreeDecimalsBg(pixelBuffer, 256, 69,1572 printThreeDecimalsBg(256, 69,
1540 (editor.modulateSpeed < 0) ? (0 - editor.modulateSpeed) : editor.modulateSpeed,1573 (editor.modulateSpeed < 0) ? (0 - editor.modulateSpeed) : editor.modulateSpeed,
1541 palette[PAL_GENTXT], palette[PAL_GENBKG]);1574 video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
1542 1575
1543 if (editor.modulateSpeed < 0)1576 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]);
1545 else1578 else
1546 charOutBg(pixelBuffer, 248, 69, ' ', palette[PAL_GENTXT], palette[PAL_GENBKG]);1579 charOutBg(248, 69, ' ', video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
1547 }1580 }
1548 1581
1549 if (editor.ui.updateVolText)1582 if (editor.ui.updateVolText)
1550 {1583 {
1551 editor.ui.updateVolText = false;1584 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]);
1553 }1586 }
1554 }1587 }
1555 else if (editor.ui.editOpScreen == 3)1588 else if (editor.ui.editOpScreen == 3)
@@ -1559,17 +1592,17 @@ void updateEditOp(void) · 3 unmodified lines
1559 editor.ui.updateLengthText = false;1592 editor.ui.updateLengthText = false;
1560 1593
1561 // clear background1594 // clear background
1562 textOutBg(pixelBuffer, 168, 91, " ", palette[PAL_GENTXT], palette[PAL_GENBKG]);1595 textOutBg(168, 91, " ", video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
1563 charOut(pixelBuffer, 198, 91, ':', palette[PAL_GENBKG]);1596 charOut(198, 91, ':', video.palette[PAL_GENBKG]);
1564 1597
1565 if (modEntry->samples[editor.currSample].loopLength > 2 || modEntry->samples[editor.currSample].loopStart >= 2)1598 if (modEntry->samples[editor.currSample].loopLength > 2 || modEntry->samples[editor.currSample].loopStart >= 2)
1566 {1599 {
1567 textOut(pixelBuffer, 168, 91, "LOOP", palette[PAL_GENTXT]);1600 textOut(168, 91, "LOOP", video.palette[PAL_GENTXT]);
1568 }1601 }
1569 else1602 else
1570 {1603 {
1571 printFourHex(pixelBuffer, 168, 91, *editor.chordLengthDisp, palette[PAL_GENTXT]); // CHORD MAX LENGTH1604 printFourHex(168, 91, *editor.chordLengthDisp, video.palette[PAL_GENTXT]); // chord max length
1572 charOut(pixelBuffer, 198, 91, (editor.chordLengthMin) ? '.' : ':', palette[PAL_GENTXT]); // MIN/MAX FLAG1605 charOut(198, 91, (editor.chordLengthMin) ? '.' : ':', video.palette[PAL_GENTXT]); // min/max flag
1573 }1606 }
1574 }1607 }
1575 1608
@@ -1577,40 +1610,40 @@ void updateEditOp(void) · 1 unmodified line
1577 {1610 {
1578 editor.ui.updateNote1Text = false;1611 editor.ui.updateNote1Text = false;
1579 if (editor.note1 > 35)1612 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]);
1581 else1614 else
1582 textOutBg(pixelBuffer, 256, 58, ptConfig.accidental ? noteNames2[editor.note1] : noteNames1[editor.note1],1615 textOutBg(256, 58, config.accidental ? noteNames2[editor.note1] : noteNames1[editor.note1],
1583 palette[PAL_GENTXT], palette[PAL_GENBKG]);1616 video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
1584 }1617 }
1585 1618
1586 if (editor.ui.updateNote2Text)1619 if (editor.ui.updateNote2Text)
1587 {1620 {
1588 editor.ui.updateNote2Text = false;1621 editor.ui.updateNote2Text = false;
1589 if (editor.note2 > 35)1622 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]);
1591 else1624 else
1592 textOutBg(pixelBuffer, 256, 69, ptConfig.accidental ? noteNames2[editor.note2] : noteNames1[editor.note2],1625 textOutBg(256, 69, config.accidental ? noteNames2[editor.note2] : noteNames1[editor.note2],
1593 palette[PAL_GENTXT], palette[PAL_GENBKG]);1626 video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
1594 }1627 }
1595 1628
1596 if (editor.ui.updateNote3Text)1629 if (editor.ui.updateNote3Text)
1597 {1630 {
1598 editor.ui.updateNote3Text = false;1631 editor.ui.updateNote3Text = false;
1599 if (editor.note3 > 35)1632 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]);
1601 else1634 else
1602 textOutBg(pixelBuffer, 256, 80, ptConfig.accidental ? noteNames2[editor.note3] : noteNames1[editor.note3],1635 textOutBg(256, 80, config.accidental ? noteNames2[editor.note3] : noteNames1[editor.note3],
1603 palette[PAL_GENTXT], palette[PAL_GENBKG]);1636 video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
1604 }1637 }
1605 1638
1606 if (editor.ui.updateNote4Text)1639 if (editor.ui.updateNote4Text)
1607 {1640 {
1608 editor.ui.updateNote4Text = false;1641 editor.ui.updateNote4Text = false;
1609 if (editor.note4 > 35)1642 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]);
1611 else1644 else
1612 textOutBg(pixelBuffer, 256, 91, ptConfig.accidental ? noteNames2[editor.note4] : noteNames1[editor.note4],1645 textOutBg(256, 91, config.accidental ? noteNames2[editor.note4] : noteNames1[editor.note4],
1613 palette[PAL_GENTXT], palette[PAL_GENBKG]);1646 video.palette[PAL_GENTXT], video.palette[PAL_GENBKG]);
1614 }1647 }
1615 }1648 }
1616}1649}
@@ -1640,14 +1673,14 @@ void displayMainScreen(void) · 23 unmodified lines
1640 if (editor.ui.samplerScreenShown)1673 if (editor.ui.samplerScreenShown)
1641 {1674 {
1642 if (!editor.ui.diskOpScreenShown)1675 if (!editor.ui.diskOpScreenShown)
1643 memcpy(pixelBuffer, trackerFrameBMP, 320 * 121 * sizeof (int32_t));1676 memcpy(video.frameBuffer, trackerFrameBMP, 320 * 121 * sizeof (int32_t));
1644 }1677 }
1645 else1678 else
1646 {1679 {
1647 if (!editor.ui.diskOpScreenShown)1680 if (!editor.ui.diskOpScreenShown)
1648 memcpy(pixelBuffer, trackerFrameBMP, 320 * 255 * sizeof (int32_t));1681 memcpy(video.frameBuffer, trackerFrameBMP, 320 * 255 * sizeof (int32_t));
1649 else1682 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));
1651 1684
1652 editor.ui.updateSongBPM = true;1685 editor.ui.updateSongBPM = true;
1653 editor.ui.updateCurrPattText = true;1686 editor.ui.updateCurrPattText = true;
@@ -1665,14 +1698,14 @@ void displayMainScreen(void) · 11 unmodified lines
1665 editor.ui.updateSongLength = true;1698 editor.ui.updateSongLength = true;
1666 1699
1667 // zeroes (can't integrate zeroes in the graphics, the palette entry is above the 2-bit range)1700 // 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]);1701 charOut(64, 3, '0', video.palette[PAL_GENTXT]);
1669 textOut(pixelBuffer, 64, 14, "00", palette[PAL_GENTXT]);1702 textOut(64, 14, "00", video.palette[PAL_GENTXT]);
1670 1703
1671 if (!editor.isWAVRendering)1704 if (!editor.isWAVRendering)
1672 {1705 {
1673 charOut(pixelBuffer, 64, 25, '0', palette[PAL_GENTXT]);1706 charOut(64, 25, '0', video.palette[PAL_GENTXT]);
1674 textOut(pixelBuffer, 64, 47, "00", palette[PAL_GENTXT]);1707 textOut(64, 47, "00", video.palette[PAL_GENTXT]);
1675 textOut(pixelBuffer, 64, 58, "00", palette[PAL_GENTXT]);1708 textOut(64, 58, "00", video.palette[PAL_GENTXT]);
1676 }1709 }
1677 1710
1678 if (editor.ui.posEdScreenShown)1711 if (editor.ui.posEdScreenShown)
@@ -2167,7 +2200,7 @@ void createBitmaps(void) · 488 unmodified lines
2167 uint16_t pixel12;2200 uint16_t pixel12;
2168 uint32_t i, j, x, y, pixel24;2201 uint32_t i, j, x, y, pixel24;
2169 2202
2170 pixel24 = palette[PAL_PATCURSOR];2203 pixel24 = video.palette[PAL_PATCURSOR];
2171 for (y = 0; y < 14; y++)2204 for (y = 0; y < 14; y++)
2172 {2205 {
2173 // top two rows have a lighter color2206 // top two rows have a lighter color
@@ -2202,7 +2235,7 @@ void createBitmaps(void) · 28 unmodified lines
2202 patternCursorBMP[(y * 11) + 0] = pixel24;2235 patternCursorBMP[(y * 11) + 0] = pixel24;
2203 2236
2204 for (x = 1; x < 10; x++)2237 for (x = 1; x < 10; x++)
2205 patternCursorBMP[(y * 11) + x] = palette[PAL_COLORKEY];2238 patternCursorBMP[(y * 11) + x] = video.palette[PAL_COLORKEY];
2206 2239
2207 patternCursorBMP[(y * 11) + 10] = pixel24;2240 patternCursorBMP[(y * 11) + 10] = pixel24;
2208 }2241 }
@@ -2299,7 +2332,7 @@ void createBitmaps(void) · 90 unmodified lines
2299 vuMeterBMP[(i * 10) + 9] = pixel24;2332 vuMeterBMP[(i * 10) + 9] = pixel24;
2300 }2333 }
2301 2334
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]];
2303 for (i = 0; i < 64; i++) samplingPosBMP[i] = samplingPosBMP[i];2336 for (i = 0; i < 64; i++) samplingPosBMP[i] = samplingPosBMP[i];
2304 for (i = 0; i < 512; i++) loopPinsBMP[i] = loopPinsBMP[i];2337 for (i = 0; i < 512; i++) loopPinsBMP[i] = loopPinsBMP[i];
2305}2338}
@@ -2379,19 +2412,19 @@ uint32_t *unpackBMP(const uint8_t *src, uint32_t packedLen) · 73 unmodified lines
2379 {2412 {
2380 byteIn = (tmpBuffer[i] & 0xC0) >> 6;2413 byteIn = (tmpBuffer[i] & 0xC0) >> 6;
2381 assert(byteIn < PALETTE_NUM);2414 assert(byteIn < PALETTE_NUM);
2382 dst[(i * 4) + 0] = palette[byteIn];2415 dst[(i * 4) + 0] = video.palette[byteIn];
2383 2416
2384 byteIn = (tmpBuffer[i] & 0x30) >> 4;2417 byteIn = (tmpBuffer[i] & 0x30) >> 4;
2385 assert(byteIn < PALETTE_NUM);2418 assert(byteIn < PALETTE_NUM);
2386 dst[(i * 4) + 1] = palette[byteIn];2419 dst[(i * 4) + 1] = video.palette[byteIn];
2387 2420
2388 byteIn = (tmpBuffer[i] & 0x0C) >> 2;2421 byteIn = (tmpBuffer[i] & 0x0C) >> 2;
2389 assert(byteIn < PALETTE_NUM);2422 assert(byteIn < PALETTE_NUM);
2390 dst[(i * 4) + 2] = palette[byteIn];2423 dst[(i * 4) + 2] = video.palette[byteIn];
2391 2424
2392 byteIn = (tmpBuffer[i] & 0x03) >> 0;2425 byteIn = (tmpBuffer[i] & 0x03) >> 0;
2393 assert(byteIn < PALETTE_NUM);2426 assert(byteIn < PALETTE_NUM);
2394 dst[(i * 4) + 3] = palette[byteIn];2427 dst[(i * 4) + 3] = video.palette[byteIn];
2395 }2428 }
2396 2429
2397 free(tmpBuffer);2430 free(tmpBuffer);
@@ -2440,10 +2473,10 @@ bool unpackBMPs(void) · 42 unmodified lines
2440 2473
2441void videoClose(void)2474void videoClose(void)
2442{2475{
2443 SDL_DestroyTexture(texture);2476 SDL_DestroyTexture(video.texture);
2444 SDL_DestroyRenderer(renderer);2477 SDL_DestroyRenderer(video.renderer);
2445 SDL_DestroyWindow(window);2478 SDL_DestroyWindow(video.window);
2446 free(pixelBuffer);2479 free(video.frameBufferUnaligned);
2447}2480}
2448 2481
2449void setupSprites(void)2482void setupSprites(void)
@@ -2459,28 +2492,28 @@ void setupSprites(void) · 9 unmodified lines
2459 2492
2460 sprites[SPRITE_PATTERN_CURSOR].data = patternCursorBMP;2493 sprites[SPRITE_PATTERN_CURSOR].data = patternCursorBMP;
2461 sprites[SPRITE_PATTERN_CURSOR].pixelType = SPRITE_TYPE_RGB;2494 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];
2463 sprites[SPRITE_PATTERN_CURSOR].w = 11;2496 sprites[SPRITE_PATTERN_CURSOR].w = 11;
2464 sprites[SPRITE_PATTERN_CURSOR].h = 14;2497 sprites[SPRITE_PATTERN_CURSOR].h = 14;
2465 hideSprite(SPRITE_PATTERN_CURSOR);2498 hideSprite(SPRITE_PATTERN_CURSOR);
2466 2499
2467 sprites[SPRITE_LOOP_PIN_LEFT].data = loopPinsBMP;2500 sprites[SPRITE_LOOP_PIN_LEFT].data = loopPinsBMP;
2468 sprites[SPRITE_LOOP_PIN_LEFT].pixelType = SPRITE_TYPE_RGB;2501 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];
2470 sprites[SPRITE_LOOP_PIN_LEFT].w = 4;2503 sprites[SPRITE_LOOP_PIN_LEFT].w = 4;
2471 sprites[SPRITE_LOOP_PIN_LEFT].h = 64;2504 sprites[SPRITE_LOOP_PIN_LEFT].h = 64;
2472 hideSprite(SPRITE_LOOP_PIN_LEFT);2505 hideSprite(SPRITE_LOOP_PIN_LEFT);
2473 2506
2474 sprites[SPRITE_LOOP_PIN_RIGHT].data = &loopPinsBMP[4 * 64];2507 sprites[SPRITE_LOOP_PIN_RIGHT].data = &loopPinsBMP[4 * 64];
2475 sprites[SPRITE_LOOP_PIN_RIGHT].pixelType = SPRITE_TYPE_RGB;2508 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];
2477 sprites[SPRITE_LOOP_PIN_RIGHT].w = 4;2510 sprites[SPRITE_LOOP_PIN_RIGHT].w = 4;
2478 sprites[SPRITE_LOOP_PIN_RIGHT].h = 64;2511 sprites[SPRITE_LOOP_PIN_RIGHT].h = 64;
2479 hideSprite(SPRITE_LOOP_PIN_RIGHT);2512 hideSprite(SPRITE_LOOP_PIN_RIGHT);
2480 2513
2481 sprites[SPRITE_SAMPLING_POS_LINE].data = samplingPosBMP;2514 sprites[SPRITE_SAMPLING_POS_LINE].data = samplingPosBMP;
2482 sprites[SPRITE_SAMPLING_POS_LINE].pixelType = SPRITE_TYPE_RGB;2515 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];
2484 sprites[SPRITE_SAMPLING_POS_LINE].w = 1;2517 sprites[SPRITE_SAMPLING_POS_LINE].w = 1;
2485 sprites[SPRITE_SAMPLING_POS_LINE].h = 64;2518 sprites[SPRITE_SAMPLING_POS_LINE].h = 64;
2486 hideSprite(SPRITE_SAMPLING_POS_LINE);2519 hideSprite(SPRITE_SAMPLING_POS_LINE);
@@ -2509,7 +2542,7 @@ void hideSprite(uint8_t sprite) · 22 unmodified lines
2509 2542
2510void eraseSprites(void)2543void eraseSprites(void)
2511{2544{
2512 int32_t sw, sh, srcPitch, dstPitch;2545 int32_t sx, sy, x, y, sw, sh, srcPitch, dstPitch;
2513 const uint32_t *src32;2546 const uint32_t *src32;
2514 uint32_t *dst32;2547 uint32_t *dst32;
2515 sprite_t *s;2548 sprite_t *s;
@@ -2517,26 +2550,43 @@ void eraseSprites(void) · 1 unmodified line
2517 for (int32_t i = SPRITE_NUM-1; i >= 0; i--) // erasing must be done in reverse order2550 for (int32_t i = SPRITE_NUM-1; i >= 0; i--) // erasing must be done in reverse order
2518 {2551 {
2519 s = &sprites[i];2552 s = &sprites[i];
2520 if (s->x >= SCREEN_W) // sprite is hidden, don't erase2553 if (s->x >= SCREEN_W || s->y >= SCREEN_H) // sprite is hidden, don't draw nor fill clear buffer
2521 continue;2554 continue;
2522 2555
2523 assert(s->x >= 0 && s->y >= 0 && s->refreshBuffer != NULL);2556 assert(s->refreshBuffer != NULL);
2524 2557
2525 sw = s->w;2558 sw = s->w;
2526 sh = s->h;2559 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];
2528 src32 = s->refreshBuffer;2578 src32 = s->refreshBuffer;
2529 2579
2530 // handle xy clipping2580 // handle x/y clipping
2531 if (s->y+sh >= SCREEN_H) sh = SCREEN_H - s->y;2581 if (sx+sw >= SCREEN_W) sw = SCREEN_W - sx;
2532 if (s->x+sw >= SCREEN_W) sw = SCREEN_W - s->x;2582 if (sy+sh >= SCREEN_H) sh = SCREEN_H - sy;
2533 2583
2534 srcPitch = s->w - sw;2584 srcPitch = s->w - sw;
2535 dstPitch = SCREEN_W - sw;2585 dstPitch = SCREEN_W - sw;
2536 2586
2537 for (int32_t y = 0; y < sh; y++)2587 for (y = 0; y < sh; y++)
2538 {2588 {
2539 for (int32_t x = 0; x < sw; x++)2589 for (x = 0; x < sw; x++)
2540 *dst32++ = *src32++;2590 *dst32++ = *src32++;
2541 2591
2542 src32 += srcPitch;2592 src32 += srcPitch;
@@ -2550,10 +2600,9 @@ void eraseSprites(void) · 7 unmodified lines
2550void renderSprites(void)2600void renderSprites(void)
2551{2601{
2552 const uint8_t *src8;2602 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;
2554 const uint32_t *src32;2604 const uint32_t *src32;
2555 uint32_t *dst32, *clr32;2605 uint32_t *dst32, *clr32, colorKey;
2556 register uint32_t colorKey;
2557 sprite_t *s;2606 sprite_t *s;
2558 2607
2559 renderVuMeters(); // let's put it here even though it's not sprite-based2608 renderVuMeters(); // let's put it here even though it's not sprite-based
@@ -2566,19 +2615,39 @@ void renderSprites(void) · 6 unmodified lines
2566 s->x = s->newX;2615 s->x = s->newX;
2567 s->y = s->newY;2616 s->y = s->newY;
2568 2617
2569 if (s->x >= SCREEN_W) // sprite is hidden, don't draw nor fill clear buffer2618 if (s->x >= SCREEN_W || s->y >= SCREEN_H) // sprite is hidden, don't draw nor fill clear buffer
2570 continue;2619 continue;
2571 2620
2572 assert(s->x >= 0 && s->y >= 0 && s->data != NULL && s->refreshBuffer != NULL);2621 assert(s->data != NULL && s->refreshBuffer != NULL);
2573 2622
2574 sw = s->w;2623 sw = s->w;
2575 sh = s->h;2624 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];
2577 clr32 = s->refreshBuffer;2646 clr32 = s->refreshBuffer;
2578 2647
2579 // handle xy clipping2648 // handle x/y clipping
2580 if (s->y+sh >= SCREEN_H) sh = SCREEN_H - s->y;2649 if (sx+sw >= SCREEN_W) sw = SCREEN_W - sx;
2581 if (s->x+sw >= SCREEN_W) sw = SCREEN_W - s->x;2650 if (sy+sh >= SCREEN_H) sh = SCREEN_H - sy;
2582 2651
2583 srcPitch = s->w - sw;2652 srcPitch = s->w - sw;
2584 dstPitch = SCREEN_W - sw;2653 dstPitch = SCREEN_W - sw;
@@ -2587,7 +2656,7 @@ void renderSprites(void) · 2 unmodified lines
2587 if (sprites[i].pixelType == SPRITE_TYPE_RGB)2656 if (sprites[i].pixelType == SPRITE_TYPE_RGB)
2588 {2657 {
2589 // 24-bit RGB sprite2658 // 24-bit RGB sprite
2590 src32 = (uint32_t *)sprites[i].data;2659 src32 = ((uint32_t *)sprites[i].data) + srcPtrBias;
2591 for (y = 0; y < sh; y++)2660 for (y = 0; y < sh; y++)
2592 {2661 {
2593 for (x = 0; x < sw; x++)2662 for (x = 0; x < sw; x++)
@@ -2608,7 +2677,7 @@ void renderSprites(void) · 14 unmodified lines
2608 else2677 else
2609 {2678 {
2610 // 8-bit paletted sprite2679 // 8-bit paletted sprite
2611 src8 = (uint8_t *)sprites[i].data;2680 src8 = ((uint8_t *)sprites[i].data) + srcPtrBias;
2612 for (y = 0; y < sh; y++)2681 for (y = 0; y < sh; y++)
2613 {2682 {
2614 for (x = 0; x < sw; x++)2683 for (x = 0; x < sw; x++)
@@ -2617,7 +2686,7 @@ void renderSprites(void) · 2 unmodified lines
2617 if (*src8 != colorKey)2686 if (*src8 != colorKey)
2618 {2687 {
2619 assert(*src8 < PALETTE_NUM);2688 assert(*src8 < PALETTE_NUM);
2620 *dst32 = palette[*src8];2689 *dst32 = video.palette[*src8];
2621 }2690 }
2622 2691
2623 dst32++;2692 dst32++;
@@ -2634,21 +2703,21 @@ void renderSprites(void) · 10 unmodified lines
2634 2703
2635void flipFrame(void)2704void flipFrame(void)
2636{2705{
2637 uint32_t windowFlags = SDL_GetWindowFlags(window);
2638
2639 renderSprites();2706 renderSprites();
2640 SDL_UpdateTexture(texture, NULL, pixelBuffer, SCREEN_W * sizeof (int32_t));2707 SDL_UpdateTexture(video.texture, NULL, video.frameBuffer, SCREEN_W * sizeof (int32_t));
2641 SDL_RenderClear(renderer);2708 SDL_RenderClear(video.renderer);
2642 SDL_RenderCopy(renderer, texture, NULL, NULL);2709 SDL_RenderCopy(video.renderer, video.texture, NULL, NULL);
2643 SDL_RenderPresent(renderer);2710 SDL_RenderPresent(video.renderer);
2644 eraseSprites();2711 eraseSprites();
2645 2712
2646 if (!editor.ui.vsync60HzPresent)2713 if (!video.vsync60HzPresent)
2647 {2714 {
2648 waitVBL(); // we have no VSync, do crude thread sleeping to sync to ~60Hz2715 waitVBL(); // we have no VSync, do crude thread sleeping to sync to ~60Hz
2649 }2716 }
2650 else2717 else
2651 {2718 {
2719 uint32_t windowFlags = SDL_GetWindowFlags(video.window);
2720
2652 /* We have VSync, but it can unexpectedly get inactive in certain scenarios.2721 /* We have VSync, but it can unexpectedly get inactive in certain scenarios.
2653 ** We have to force thread sleeping (to ~60Hz) if so.2722 ** We have to force thread sleeping (to ~60Hz) if so.
2654 */2723 */
@@ -2658,7 +2727,7 @@ void flipFrame(void) · 3 unmodified lines
2658 waitVBL();2727 waitVBL();
2659#elif __unix__2728#elif __unix__
2660 // *NIX: VSync gets disabled in fullscreen mode (at least on some distros/systems). Let's add a fix:2729 // *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)
2662 waitVBL();2731 waitVBL();
2663#else2732#else
2664 if (windowFlags & SDL_WINDOW_MINIMIZED)2733 if (windowFlags & SDL_WINDOW_MINIMIZED)
@@ -2670,20 +2739,18 @@ void flipFrame(void) · 5 unmodified lines
2670void updateSpectrumAnalyzer(int8_t vol, int16_t period)2739void updateSpectrumAnalyzer(int8_t vol, int16_t period)
2671{2740{
2672 const uint8_t maxHeight = SPECTRUM_BAR_HEIGHT + 1; // +1 because of audio latency - allows full height to be seen2741 const uint8_t maxHeight = SPECTRUM_BAR_HEIGHT + 1; // +1 because of audio latency - allows full height to be seen
2673 int16_t scaledVol;2742 int32_t scaledVol, scaledNote;
2674 int32_t scaledNote;
2675 2743
2676 if (editor.ui.visualizerMode != VISUAL_SPECTRUM || vol <= 0)2744 if (editor.ui.visualizerMode != VISUAL_SPECTRUM || vol <= 0)
2677 return;2745 return;
2678 2746
2679 scaledVol = (vol * 256) / ((64 * 256) / (SPECTRUM_BAR_NUM+1)); // 64 = max sample vol2747 scaledVol = (vol * 24600L) >> 16; // scaledVol = (vol << 8) / 682
2680 2748
2681 period = CLAMP(period, 113, 856);2749 period = CLAMP(period, 113, 856);
2682 2750
2683 // 856 = C-1 period, 113 = B-3 period2751 scaledNote = 856 - period;
2684 scaledNote = (856-113) - (period - 113);
2685 scaledNote *= scaledNote;2752 scaledNote *= scaledNote;
2686 scaledNote /= ((856 - 113) * (856 - 113)) / (SPECTRUM_BAR_NUM-1);2753 scaledNote = ((int64_t)scaledNote * 171162) >> 32; // scaledNote /= 25093
2687 2754
2688 // scaledNote now ranges 0..22, no need to clamp2755 // scaledNote now ranges 0..22, no need to clamp
2689 2756
@@ -2711,24 +2778,27 @@ void updateSpectrumAnalyzer(int8_t vol, int16_t period) · 21 unmodified lines
2711 2778
2712void sinkVisualizerBars(void)2779void sinkVisualizerBars(void)
2713{2780{
2781 int32_t i;
2782
2714 // sink stuff @ 50Hz rate2783 // sink stuff @ 50Hz rate
2715 2784
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;
2717 2787
2718 _50HzCounter += _50HzCounterDelta; // 32.32 fixed-point counter2788 counter50Hz += counter50HzDelta; // 32.32 fixed-point counter
2719 if (_50HzCounter > 0xFFFFFFFF)2789 if (counter50Hz > 0xFFFFFFFF)
2720 {2790 {
2721 _50HzCounter &= 0xFFFFFFFF;2791 counter50Hz &= 0xFFFFFFFF;
2722 2792
2723 // sink VU-meters2793 // sink VU-meters
2724 for (uint32_t i = 0; i < AMIGA_VOICES; i++)2794 for (i = 0; i < AMIGA_VOICES; i++)
2725 {2795 {
2726 if (editor.vuMeterVolumes[i] > 0)2796 if (editor.vuMeterVolumes[i] > 0)
2727 editor.vuMeterVolumes[i]--;2797 editor.vuMeterVolumes[i]--;
2728 }2798 }
2729 2799
2730 // sink "spectrum analyzer" bars2800 // sink "spectrum analyzer" bars
2731 for (uint32_t i = 0; i < SPECTRUM_BAR_NUM; i++)2801 for (i = 0; i < SPECTRUM_BAR_NUM; i++)
2732 {2802 {
2733 if (editor.spectrumVolumes[i] > 0)2803 if (editor.spectrumVolumes[i] > 0)
2734 editor.spectrumVolumes[i]--;2804 editor.spectrumVolumes[i]--;
@@ -2746,57 +2816,57 @@ void updateRenderSizeVars(void) · 11 unmodified lines
2746 float fXScale, fYScale;2816 float fXScale, fYScale;
2747 SDL_DisplayMode dm;2817 SDL_DisplayMode dm;
2748 2818
2749 di = SDL_GetWindowDisplayIndex(window);2819 di = SDL_GetWindowDisplayIndex(video.window);
2750 if (di < 0)2820 if (di < 0)
2751 di = 0; /* return display index 0 (default) on error */2821 di = 0; /* return display index 0 (default) on error */
2752 2822
2753 SDL_GetDesktopDisplayMode(di, &dm);2823 SDL_GetDesktopDisplayMode(di, &dm);
2754 editor.ui.displayW = dm.w;2824 video.displayW = dm.w;
2755 editor.ui.displayH = dm.h;2825 video.displayH = dm.h;
2756 2826
2757 if (editor.fullscreen)2827 if (video.fullscreen)
2758 {2828 {
2759 if (ptConfig.fullScreenStretch)2829 if (config.fullScreenStretch)
2760 {2830 {
2761 editor.ui.renderW = editor.ui.displayW;2831 video.renderW = video.displayW;
2762 editor.ui.renderH = editor.ui.displayH;2832 video.renderH = video.displayH;
2763 editor.ui.renderX = 0;2833 video.renderX = 0;
2764 editor.ui.renderY = 0;2834 video.renderY = 0;
2765 }2835 }
2766 else2836 else
2767 {2837 {
2768 SDL_RenderGetScale(renderer, &fXScale, &fYScale);2838 SDL_RenderGetScale(video.renderer, &fXScale, &fYScale);
2769 2839
2770 editor.ui.renderW = (int32_t)(SCREEN_W * fXScale);2840 video.renderW = (int32_t)(SCREEN_W * fXScale);
2771 editor.ui.renderH = (int32_t)(SCREEN_H * fYScale);2841 video.renderH = (int32_t)(SCREEN_H * fYScale);
2772 2842
2773#ifdef __APPLE__2843#ifdef __APPLE__
2774 // retina high-DPI hackery (SDL2 is bad at reporting actual rendering sizes on macOS w/ high-DPI)2844 // 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);
2776 SDL_GetDesktopDisplayMode(0, &dm);2846 SDL_GetDesktopDisplayMode(0, &dm);
2777 2847
2778 dXUpscale = ((double)actualScreenW / editor.ui.displayW);2848 dXUpscale = ((double)actualScreenW / video.displayW);
2779 dYUpscale = ((double)actualScreenH / editor.ui.displayH);2849 dYUpscale = ((double)actualScreenH / video.displayH);
2780 2850
2781 // downscale back to correct sizes2851 // downscale back to correct sizes
2782 if (dXUpscale != 0.0) editor.ui.renderW = (int32_t)(editor.ui.renderW / dXUpscale);2852 if (dXUpscale != 0.0) video.renderW = (int32_t)(video.renderW / dXUpscale);
2783 if (dYUpscale != 0.0) editor.ui.renderH = (int32_t)(editor.ui.renderH / dYUpscale);2853 if (dYUpscale != 0.0) video.renderH = (int32_t)(video.renderH / dYUpscale);
2784#endif2854#endif
2785 editor.ui.renderX = (editor.ui.displayW - editor.ui.renderW) / 2;2855 video.renderX = (video.displayW - video.renderW) >> 1;
2786 editor.ui.renderY = (editor.ui.displayH - editor.ui.renderH) / 2;2856 video.renderY = (video.displayH - video.renderH) >> 1;
2787 }2857 }
2788 }2858 }
2789 else2859 else
2790 {2860 {
2791 SDL_GetWindowSize(window, &editor.ui.renderW, &editor.ui.renderH);2861 SDL_GetWindowSize(video.window, &video.renderW, &video.renderH);
2792 2862
2793 editor.ui.renderX = 0;2863 video.renderX = 0;
2794 editor.ui.renderY = 0;2864 video.renderY = 0;
2795 }2865 }
2796 2866
2797 // for mouse cursor creation2867 // for mouse cursor creation
2798 editor.ui.xScale = (int32_t)((editor.ui.renderW / (double)SCREEN_W) + 0.5);2868 video.xScale = (int32_t)((video.renderW * (1.0 / SCREEN_W)) + 0.5);
2799 editor.ui.yScale = (int32_t)((editor.ui.renderH / (double)SCREEN_H) + 0.5);2869 video.yScale = (int32_t)((video.renderH * (1.0 / SCREEN_H)) + 0.5);
2800 createMouseCursors();2870 createMouseCursors();
2801}2871}
2802 2872
@@ -2804,47 +2874,47 @@ void toggleFullScreen(void) · 1 unmodified line
2804{2874{
2805 SDL_DisplayMode dm;2875 SDL_DisplayMode dm;
2806 2876
2807 editor.fullscreen ^= 1;2877 video.fullscreen ^= 1;
2808 if (editor.fullscreen)2878 if (video.fullscreen)
2809 {2879 {
2810 if (ptConfig.fullScreenStretch)2880 if (config.fullScreenStretch)
2811 {2881 {
2812 SDL_GetDesktopDisplayMode(0, &dm);2882 SDL_GetDesktopDisplayMode(0, &dm);
2813 SDL_RenderSetLogicalSize(renderer, dm.w, dm.h);2883 SDL_RenderSetLogicalSize(video.renderer, dm.w, dm.h);
2814 }2884 }
2815 else2885 else
2816 {2886 {
2817 SDL_RenderSetLogicalSize(renderer, SCREEN_W, SCREEN_H);2887 SDL_RenderSetLogicalSize(video.renderer, SCREEN_W, SCREEN_H);
2818 }2888 }
2819 2889
2820 SDL_SetWindowSize(window, SCREEN_W, SCREEN_H);2890 SDL_SetWindowSize(video.window, SCREEN_W, SCREEN_H);
2821 SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);2891 SDL_SetWindowFullscreen(video.window, SDL_WINDOW_FULLSCREEN_DESKTOP);
2822 SDL_SetWindowGrab(window, SDL_TRUE);2892 SDL_SetWindowGrab(video.window, SDL_TRUE);
2823 }2893 }
2824 else2894 else
2825 {2895 {
2826 SDL_SetWindowFullscreen(window, 0);2896 SDL_SetWindowFullscreen(video.window, 0);
2827 SDL_RenderSetLogicalSize(renderer, SCREEN_W, SCREEN_H);2897 SDL_RenderSetLogicalSize(video.renderer, SCREEN_W, SCREEN_H);
2828 SDL_SetWindowSize(window, SCREEN_W * ptConfig.videoScaleFactor, SCREEN_H * ptConfig.videoScaleFactor);2898 SDL_SetWindowSize(video.window, SCREEN_W * config.videoScaleFactor, SCREEN_H * config.videoScaleFactor);
2829 SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);2899 SDL_SetWindowPosition(video.window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
2830 SDL_SetWindowGrab(window, SDL_FALSE);2900 SDL_SetWindowGrab(video.window, SDL_FALSE);
2831 }2901 }
2832 2902
2833 updateRenderSizeVars();2903 updateRenderSizeVars();
2834 updateMouseScaling();2904 updateMouseScaling();
2835 2905
2836 if (editor.fullscreen)2906 if (video.fullscreen)
2837 {2907 {
2838 input.mouse.setPosX = editor.ui.displayW / 2;2908 mouse.setPosX = video.displayW >> 1;
2839 input.mouse.setPosY = editor.ui.displayH / 2;2909 mouse.setPosY = video.displayH >> 1;
2840 }2910 }
2841 else2911 else
2842 {2912 {
2843 input.mouse.setPosX = editor.ui.renderW / 2;2913 mouse.setPosX = video.renderW >> 1;
2844 input.mouse.setPosY = editor.ui.renderH / 2;2914 mouse.setPosY = video.renderH >> 1;
2845 }2915 }
2846 2916
2847 input.mouse.setPosFlag = true;2917 mouse.setPosFlag = true;
2848}2918}
2849 2919
2850bool setupVideo(void)2920bool setupVideo(void)
@@ -2853,8 +2923,8 @@ bool setupVideo(void) · 2 unmodified lines
2853 uint32_t rendererFlags;2923 uint32_t rendererFlags;
2854 SDL_DisplayMode dm;2924 SDL_DisplayMode dm;
2855 2925
2856 screenW = SCREEN_W * ptConfig.videoScaleFactor;2926 screenW = SCREEN_W * config.videoScaleFactor;
2857 screenH = SCREEN_H * ptConfig.videoScaleFactor;2927 screenH = SCREEN_H * config.videoScaleFactor;
2858 2928
2859 rendererFlags = 0;2929 rendererFlags = 0;
2860 2930
@@ -2868,38 +2938,38 @@ bool setupVideo(void) · 7 unmodified lines
2868 SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");2938 SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
2869#endif2939#endif
2870 2940
2871 editor.ui.vsync60HzPresent = false;2941 video.vsync60HzPresent = false;
2872 if (!ptConfig.vsyncOff)2942 if (!config.vsyncOff)
2873 {2943 {
2874 SDL_GetDesktopDisplayMode(0, &dm);2944 SDL_GetDesktopDisplayMode(0, &dm);
2875 if (dm.refresh_rate >= 59 && dm.refresh_rate <= 61)2945 if (dm.refresh_rate >= 59 && dm.refresh_rate <= 61)
2876 {2946 {
2877 editor.ui.vsync60HzPresent = true;2947 video.vsync60HzPresent = true;
2878 rendererFlags |= SDL_RENDERER_PRESENTVSYNC;2948 rendererFlags |= SDL_RENDERER_PRESENTVSYNC;
2879 }2949 }
2880 }2950 }
2881 2951
2882 window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED,2952 video.window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED,
2883 SDL_WINDOWPOS_CENTERED, screenW, screenH,2953 SDL_WINDOWPOS_CENTERED, screenW, screenH,
2884 SDL_WINDOW_HIDDEN | SDL_WINDOW_ALLOW_HIGHDPI);2954 SDL_WINDOW_HIDDEN | SDL_WINDOW_ALLOW_HIGHDPI);
2885 2955
2886 if (window == NULL)2956 if (video.window == NULL)
2887 {2957 {
2888 showErrorMsgBox("Couldn't create SDL window:\n%s", SDL_GetError());2958 showErrorMsgBox("Couldn't create SDL window:\n%s", SDL_GetError());
2889 return false;2959 return false;
2890 }2960 }
2891 2961
2892 renderer = SDL_CreateRenderer(window, -1, rendererFlags);2962 video.renderer = SDL_CreateRenderer(video.window, -1, rendererFlags);
2893 if (renderer == NULL)2963 if (video.renderer == NULL)
2894 {2964 {
2895 if (editor.ui.vsync60HzPresent) // try again without vsync flag2965 if (video.vsync60HzPresent) // try again without vsync flag
2896 {2966 {
2897 editor.ui.vsync60HzPresent = false;2967 video.vsync60HzPresent = false;
2898 rendererFlags &= ~SDL_RENDERER_PRESENTVSYNC;2968 rendererFlags &= ~SDL_RENDERER_PRESENTVSYNC;
2899 renderer = SDL_CreateRenderer(window, -1, rendererFlags);2969 video.renderer = SDL_CreateRenderer(video.window, -1, rendererFlags);
2900 }2970 }
2901 2971
2902 if (renderer == NULL)2972 if (video.renderer == NULL)
2903 {2973 {
2904 showErrorMsgBox("Couldn't create SDL renderer:\n%s\n\n" \2974 showErrorMsgBox("Couldn't create SDL renderer:\n%s\n\n" \
2905 "Is your GPU (+ driver) too old?", SDL_GetError());2975 "Is your GPU (+ driver) too old?", SDL_GetError());
@@ -2907,38 +2977,41 @@ bool setupVideo(void) · 1 unmodified line
2907 }2977 }
2908 }2978 }
2909 2979
2910 SDL_RenderSetLogicalSize(renderer, SCREEN_W, SCREEN_H);2980 SDL_RenderSetLogicalSize(video.renderer, SCREEN_W, SCREEN_H);
2911 2981
2912#if SDL_PATCHLEVEL >= 52982#if SDL_PATCHLEVEL >= 5
2913 SDL_RenderSetIntegerScale(renderer, SDL_TRUE);2983 SDL_RenderSetIntegerScale(video.renderer, SDL_TRUE);
2914#endif2984#endif
2915 2985
2916 SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);2986 SDL_SetRenderDrawBlendMode(video.renderer, SDL_BLENDMODE_NONE);
2917 2987
2918 SDL_SetHint("SDL_RENDER_SCALE_QUALITY", "nearest");2988 SDL_SetHint("SDL_RENDER_SCALE_QUALITY", "nearest");
2919 2989
2920 texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, SCREEN_W, SCREEN_H);2990 video.texture = SDL_CreateTexture(video.renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, SCREEN_W, SCREEN_H);
2921 if (texture == NULL)2991 if (video.texture == NULL)
2922 {2992 {
2923 showErrorMsgBox("Couldn't create %dx%d GPU texture:\n%s\n\n" \2993 showErrorMsgBox("Couldn't create %dx%d GPU texture:\n%s\n\n" \
2924 "Is your GPU (+ driver) too old?", SCREEN_W, SCREEN_H, SDL_GetError());2994 "Is your GPU (+ driver) too old?", SCREEN_W, SCREEN_H, SDL_GetError());
2925 return false;2995 return false;
2926 }2996 }
2927 2997
2928 SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE);2998 SDL_SetTextureBlendMode(video.texture, SDL_BLENDMODE_NONE);
2929 2999
2930 // frame buffer used by SDL (for texture)3000 // frame buffer used by SDL (for texture)
2931 pixelBuffer = (uint32_t *)malloc(SCREEN_W * SCREEN_H * sizeof (int32_t));3001 video.frameBufferUnaligned = (uint32_t *)MALLOC_PAD(SCREEN_W * SCREEN_H * sizeof (int32_t), 256);
2932 if (pixelBuffer == NULL)3002 if (video.frameBufferUnaligned == NULL)
2933 {3003 {
2934 showErrorMsgBox("Out of memory!");3004 showErrorMsgBox("Out of memory!");
2935 return false;3005 return false;
2936 }3006 }
2937 3007
3008 // we want an aligned pointer
3009 video.frameBuffer = (uint32_t *)ALIGN_PTR(video.frameBufferUnaligned, 256);
3010
2938 updateRenderSizeVars();3011 updateRenderSizeVars();
2939 updateMouseScaling();3012 updateMouseScaling();
2940 3013
2941 if (ptConfig.hwMouse)3014 if (config.hwMouse)
2942 SDL_ShowCursor(SDL_TRUE);3015 SDL_ShowCursor(SDL_TRUE);
2943 else3016 else
2944 SDL_ShowCursor(SDL_FALSE);3017 SDL_ShowCursor(SDL_FALSE);
src/pt2_visuals.h+1−1
@@ -68,7 +68,7 @@ void showVolToSlider(void); · 67 unmodified lines
68void updateCurrSample(void);68void updateCurrSample(void);
69void eraseSprites(void);69void eraseSprites(void);
70void renderSprites(void);70void renderSprites(void);
71void updateDragBars(void);71void handleLastGUIObjectDown(void);
72void invertRange(void);72void invertRange(void);
73void updateCursorPos(void);73void updateCursorPos(void);
74void renderVuMeters(void);74void renderVuMeters(void);
vs2019_project/pt2-clone/pt2-clone.vcxproj+3−0
@@ -206,6 +206,7 @@ · 205 unmodified lines
206 <OpenMPSupport>false</OpenMPSupport>206 <OpenMPSupport>false</OpenMPSupport>
207 <LanguageStandard>stdcpplatest</LanguageStandard>207 <LanguageStandard>stdcpplatest</LanguageStandard>
208 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>208 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
209 <Optimization>Disabled</Optimization>
209 </ClCompile>210 </ClCompile>
210 <Link>211 <Link>
211 <SubSystem>Windows</SubSystem>212 <SubSystem>Windows</SubSystem>
@@ -247,6 +248,8 @@ · 35 unmodified lines
247 <OpenMPSupport>false</OpenMPSupport>248 <OpenMPSupport>false</OpenMPSupport>
248 <LanguageStandard>stdcpplatest</LanguageStandard>249 <LanguageStandard>stdcpplatest</LanguageStandard>
249 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>250 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
251 <Optimization>Disabled</Optimization>
252 <OmitFramePointers>false</OmitFramePointers>
250 </ClCompile>253 </ClCompile>
251 <Link>254 <Link>
252 <SubSystem>Windows</SubSystem>255 <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