History

Pushed v1.15 code

- More improvements to S3M loader. Fixes "satellite one.s3m" and other S3Ms. - Up/down pushbutton delay has been increased even more, to prevent accidentally skipping too much. - Some other small miscellaneous changes not worth of a mention

Olav Sørensen committed 6 years ago

Commit 108c3331 parent aaa773b25 files · +435 −644Browse files

Showing the changes to src (24 of 25 files). Show all

Unified · Split

24 files
  1. src/ft2_about.c +24 −23
  2. src/ft2_audio.c +7 −7
  3. src/ft2_audio.h +5 −3
  4. src/ft2_checkboxes.c +1 −1
  5. src/ft2_config.c +6 −6
  6. src/ft2_diskop.c +1 −1
  7. src/ft2_header.h +1 −1
  8. src/ft2_help.c +7 −7
  9. src/ft2_inst_ed.c +17 −17
  10. src/ft2_mix.c +96 −168
  11. src/ft2_mix_macros.h +18 −14
  12. src/ft2_module_loader.c +163 −298
  13. src/ft2_nibbles.c +2 −2
  14. src/ft2_pattern_draw.c +1 −1
  15. src/ft2_pattern_ed.c +13 −13
  16. src/ft2_pushbuttons.c +14 −14
  17. src/ft2_pushbuttons.h +1 −1
  18. src/ft2_radiobuttons.c +10 −11
  19. src/ft2_replayer.c +13 −12
  20. src/ft2_replayer.h +1 −1
  21. src/ft2_sample_ed.c +22 −33
  22. src/ft2_sample_ed_features.c +4 −4
  23. src/ft2_scopes.c +6 −5
  24. src/ft2_scopes.h +1 −1
src/ft2_about.c+24−23
@@ -9,7 +9,7 @@ · 8 unmodified lines
99
1010 // ported from original FT2 code
1111
12−#define NUM_STARS 512
12+#define NUM_STARS 1000
1313 #define ABOUT_SCREEN_W 626
1414 #define ABOUT_SCREEN_H 167
1515 #define ABOUT_LOGO_W 449
@@ -53,7 +53,7 @@ static inline int32_t random32(int32_t l) // Turbo Pascal Random() implementatio · 37 unmodified lines
5353 randSeed *= 134775813;
5454 randSeed += 1;
5555
56− r = (int32_t)(((int64_t)randSeed * l) >> 32);
56+ r = ((int64_t)randSeed * l) >> 32;
5757 return r;
5858 }
5959
@@ -68,13 +68,13 @@ static void fixaMatris(rotate_t a, matrix_t *mat) · 8 unmodified lines
6868 sc = sin32767[a.z >> 6];
6969 cc = cos32767[a.z >> 6];
7070
71− mat->x.x = ((ca * cc) >> 16) + (((sc * ((sa * sb) >> 16)) >> 16) << 1);
71+ mat->x.x = ((ca * cc) >> 16) + ((sc * ((sa * sb) >> 16)) >> (16-1));
7272 mat->y.x = (sa * cb) >> 16;
73− mat->z.x = (((cc * ((sa * sb) >> 16)) >> 16) << 1) - ((ca * sc) >> 16);
73+ mat->z.x = ((cc * ((sa * sb) >> 16)) >> (16-1)) - ((ca * sc) >> 16);
7474
75− mat->x.y = (((sc * ((ca * sb) >> 16)) >> 16) << 1) - ((sa * cc) >> 16);
75+ mat->x.y = ((sc * ((ca * sb) >> 16)) >> (16-1)) - ((sa * cc) >> 16);
7676 mat->y.y = (ca * cb) >> 16;
77− mat->z.y = ((sa * sc) >> 16) + (((cc * ((ca * sb) >> 16)) >> 16) << 1);
77+ mat->z.y = ((sa * sc) >> 16) + ((cc * ((ca * sb) >> 16)) >> (16-1));
7878
7979 mat->x.z = (cb * sc) >> 16;
8080 mat->y.z = 0 - (sb >> 1);
@@ -167,8 +167,8 @@ static void aboutInit(void) · 86 unmodified lines
167167 static void realStars(void)
168168 {
169169 uint8_t col;
170− int16_t x, y, z, xx, xy, xz, yx, yy, yz, zx, zy, zz;
171− int32_t screenBufferPos;
170+ int16_t z, xx, xy, xz, yx, yy, yz, zx, zy, zz;
171+ int32_t x, y, zMul, screenBufferPos;
172172 vector_t *star;
173173
174174 xx = starmat.x.x; xy = starmat.x.y; xz = starmat.x.z;
@@ -190,26 +190,27 @@ static void realStars(void) · 15 unmodified lines
190190 star = &starcrd[i];
191191 star->z += hastighet;
192192
193− z = ((xz * star->x) >> 16) + ((yz * star->y) >> 16) + ((zz * star->z) >> 16);
193+ z = ((xz * star->x) + (yz * star->y) + (zz * star->z)) >> 16;
194194 z += 9000;
195− if (z <= 100)
196− continue;
197−
198− y = ((xy * star->x) >> 16) + ((yy * star->y) >> 16) + ((zy * star->z) >> 16);
199− y = (int16_t)((y << 7) / z) + 84;
200− if ((uint16_t)y >= 173-6)
201− continue;
202−
203− x = ((xx * star->x) >> 16) + ((yx * star->y) >> 16) + ((zx * star->z) >> 16);
204− x = (int16_t)((((x >> 2) + x) << 7) / z) + (320-8);
205− if ((uint16_t)x >= 640-16)
206− continue;
195+ if (z <= 100) continue;
196+ zMul = 0xFFFFFFFF / z; // 8bitbubsy: optimization
197+
198+ y = ((xy * star->x) + (yy * star->y) + (zy * star->z)) >> (16-7);
199+ y = ((int64_t)y * zMul) >> 32;
200+ y += (2+ABOUT_SCREEN_H)/2;
201+ if ((uint32_t)y > 2+ABOUT_SCREEN_H) continue;
202+
203+ x = ((xx * star->x) + (yx * star->y) + (zx * star->z)) >> (16-7);
204+ x += x >> 2; // x *= 1.25
205+ x = ((int64_t)x * zMul) >> 32;
206+ x += (2+ABOUT_SCREEN_W)/2;
207+ if ((uint32_t)x > 2+ABOUT_SCREEN_W) continue;
207208
208209 // render star pixel if the pixel under it is the background
209− screenBufferPos = ((y + 4) * SCREEN_W) + (x + 4);
210+ screenBufferPos = ((uint32_t)y * SCREEN_W) + (uint32_t)x;
210211 if ((video.frameBuffer[screenBufferPos] >> 24) == PAL_BCKGRND)
211212 {
212− col = ((uint8_t)~(z >> 8) >> 3) - (22 - 8);
213+ col = ((uint8_t)~(z >> 8) >> 3) - 14;
213214 if (col < 24)
214215 {
215216 video.frameBuffer[screenBufferPos] = video.palette[starColConv[col]] & 0x00FFFFFF;
src/ft2_audio.c+7−7
@@ -20,8 +20,8 @@ · 19 unmodified lines
2020 static int8_t pmpCountDiv, pmpChannels = 2;
2121 static uint16_t smpBuffSize;
2222 static int32_t masterVol, oldAudioFreq, speedVal, pmpLeft, randSeed = INITIAL_DITHER_SEED;
23−static int32_t prngStateL, prngStateR;
24−static uint32_t tickTimeLen, tickTimeLenFrac, oldSFrq, oldSFrqRev = 0xFFFFFFFF;
23+static int32_t prngStateL, prngStateR, oldPeriod, oldSFrq, oldSFrqRev;
24+static uint32_t tickTimeLen, tickTimeLenFrac;
2525 static float fAudioAmpMul;
2626 static voice_t voice[MAX_VOICES * 2];
2727 static void (*sendAudSamplesFunc)(uint8_t *, uint32_t, uint8_t); // "send mixed samples" routines
@@ -31,8 +31,9 @@ chSyncData_t *chSyncEntry; · 3 unmodified lines
3131
3232 volatile bool pattQueueReading, pattQueueClearing, chQueueReading, chQueueClearing;
3333
34−void resetOldRevFreqs(void)
34+void resetCachedMixerVars(void)
3535 {
36+ oldPeriod = -1;
3637 oldSFrq = 0;
3738 oldSFrqRev = 0xFFFFFFFF;
3839 }
@@ -369,17 +370,16 @@ void mix_UpdateChannelVolPanFrq(void) · 330 unmodified lines
369370 // frequency change
370371 if (status & IS_Period)
371372 {
372− v->SFrq = getFrequenceValue(ch->finalPeriod);
373−
374− if (v->SFrq != oldSFrq) // this value will very often be the same as before
373+ if (ch->finalPeriod != oldPeriod) // this value will very often be the same as before
375374 {
376− oldSFrq = v->SFrq;
375+ oldSFrq = getFrequenceValue(ch->finalPeriod);
377376
378377 oldSFrqRev = 0xFFFFFFFF;
379378 if (oldSFrq != 0)
380379 oldSFrqRev /= oldSFrq;
381380 }
382381
382+ v->SFrq = oldSFrq;
383383 v->SFrqRev = oldSFrqRev;
384384 }
385385
src/ft2_audio.h+5−3
@@ -45,8 +45,10 @@ typedef struct · 44 unmodified lines
4545 bool backwards, isFadeOutVoice;
4646 uint8_t SPan;
4747 uint16_t SVol;
48− int32_t SLVol1, SRVol1, SLVol2, SRVol2, SLVolIP, SRVolIP, SVolIPLen, SPos, SLen, SRepS, SRepL;
49− uint32_t SPosDec, SFrq, SFrqRev;
48+ int32_t SLVol1, SRVol1, SLVol2, SRVol2, SLVolIP, SRVolIP, SVolIPLen;
49+ int32_t SPos, SLen, SRepS, SRepL, SFrq, SFrqRev;
50+ uint32_t SPosDec;
51+
5052 void (*mixRoutine)(void *, int32_t); // function pointer to mix routine
5153 } voice_t;
5254
@@ -79,7 +81,7 @@ extern chSyncData_t *chSyncEntry; · 26 unmodified lines
7981
8082 extern volatile bool pattQueueReading, pattQueueClearing, chQueueReading, chQueueClearing;
8183
82−void resetOldRevFreqs(void);
84+void resetCachedMixerVars(void);
8385 int32_t pattQueueReadSize(void);
8486 int32_t pattQueueWriteSize(void);
8587 bool pattQueuePush(pattSyncData_t t);
src/ft2_checkboxes.c+1−1
@@ -79,7 +79,7 @@ checkBox_t checkBoxes[NUM_CHECKBOXES] = · 78 unmodified lines
7979
8080 // ------ CONFIG CHECKBOXES ------
8181 //x, y, w, h, funcOnUp
82− { 3, 91, 76, 12, cbToggleAutoSaveConfig },
82+ { 3, 91, 77, 12, cbToggleAutoSaveConfig },
8383 { 389, 132, 90, 12, cbConfigInterpolation },
8484 { 389, 145, 107, 12, cbConfigVolRamp },
8585 { 389, 158 , 84, 12, cbConfigDither },
src/ft2_config.c+6−6
@@ -1106,14 +1106,14 @@ void showConfigScreen(void) · 1105 unmodified lines
11061106 showPushButton(PB_CONFIG_SAVE);
11071107 showPushButton(PB_CONFIG_EXIT);
11081108
1109− textOutShadow(5, 4, PAL_FORGRND, PAL_DSKTOP2, "Configuration:");
1110− textOutShadow(22, 20, PAL_FORGRND, PAL_DSKTOP2, "I/O devices");
1111− textOutShadow(22, 36, PAL_FORGRND, PAL_DSKTOP2, "Layout");
1112− textOutShadow(22, 52, PAL_FORGRND, PAL_DSKTOP2, "Miscellaneous");
1109+ textOutShadow(4, 4, PAL_FORGRND, PAL_DSKTOP2, "Configuration:");
1110+ textOutShadow(21, 19, PAL_FORGRND, PAL_DSKTOP2, "I/O devices");
1111+ textOutShadow(21, 35, PAL_FORGRND, PAL_DSKTOP2, "Layout");
1112+ textOutShadow(21, 51, PAL_FORGRND, PAL_DSKTOP2, "Miscellaneous");
11131113 #ifdef HAS_MIDI
1114− textOutShadow(22, 68, PAL_FORGRND, PAL_DSKTOP2, "MIDI input");
1114+ textOutShadow(21, 67, PAL_FORGRND, PAL_DSKTOP2, "MIDI input");
11151115 #endif
1116− textOutShadow(19, 92, PAL_FORGRND, PAL_DSKTOP2, "Auto save");
1116+ textOutShadow(20, 93, PAL_FORGRND, PAL_DSKTOP2, "Auto save");
11171117
11181118 switch (editor.currConfigScreen)
11191119 {
src/ft2_diskop.c+1−1
@@ -104,7 +104,7 @@ int32_t getFileSize(UNICHAR *fileNameU) // returning -1 = filesize over 2GB · 103 unmodified lines
104104 if (stat(fileNameU, &st) != 0)
105105 return 0;
106106
107− fSize = (int64_t)(st.st_size);
107+ fSize = (int64_t)st.st_size;
108108 #endif
109109 if (fSize < 0)
110110 fSize = 0;
src/ft2_header.h+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 #endif
1313 #include "ft2_replayer.h"
1414
15−#define PROG_VER_STR "1.14"
15+#define PROG_VER_STR "1.15"
1616
1717 // do NOT change these! It will only mess things up...
1818
src/ft2_help.c+7−7
@@ -417,13 +417,13 @@ void showHelpScreen(void) · 416 unmodified lines
417417
418418 showScrollBar(SB_HELP_SCROLL);
419419
420− textOutShadow(4, 3, PAL_FORGRND, PAL_DSKTOP2, "Subjects:");
421− textOutShadow(20, 17, PAL_FORGRND, PAL_DSKTOP2, "Features");
422− textOutShadow(20, 32, PAL_FORGRND, PAL_DSKTOP2, "Effects");
423− textOutShadow(20, 47, PAL_FORGRND, PAL_DSKTOP2, "Keyboard");
424− textOutShadow(20, 62, PAL_FORGRND, PAL_DSKTOP2, "How to use FT2");
425− textOutShadow(20, 77, PAL_FORGRND, PAL_DSKTOP2, "Problems/FAQ");
426− textOutShadow(20, 92, PAL_FORGRND, PAL_DSKTOP2, "Known bugs");
420+ textOutShadow(4, 4, PAL_FORGRND, PAL_DSKTOP2, "Subjects:");
421+ textOutShadow(21, 19, PAL_FORGRND, PAL_DSKTOP2, "Features");
422+ textOutShadow(21, 35, PAL_FORGRND, PAL_DSKTOP2, "Effects");
423+ textOutShadow(21, 51, PAL_FORGRND, PAL_DSKTOP2, "Keyboard");
424+ textOutShadow(21, 67, PAL_FORGRND, PAL_DSKTOP2, "How to use FT2");
425+ textOutShadow(21, 83, PAL_FORGRND, PAL_DSKTOP2, "Problems/FAQ");
426+ textOutShadow(21, 99, PAL_FORGRND, PAL_DSKTOP2, "Known bugs");
427427
428428 writeHelp();
429429 }
src/ft2_inst_ed.c+17−17
@@ -397,7 +397,7 @@ static void drawVolEnvRepS(void) · 396 unmodified lines
397397 instrTyp *ins = getCurDispInstr();
398398
399399 sprintf(str, "%02d", ins->envVRepS);
400− textOutFixed(382, 234, PAL_FORGRND, PAL_DESKTOP, str);
400+ textOutFixed(382, 233, PAL_FORGRND, PAL_DESKTOP, str);
401401 }
402402
403403 static void drawVolEnvRepE(void)
@@ -415,7 +415,7 @@ static void drawPanEnvSus(void) · 11 unmodified lines
415415 instrTyp *ins = getCurDispInstr();
416416
417417 sprintf(str, "%02d", ins->envPSust);
418− textOutFixed(382, 294, PAL_FORGRND, PAL_DESKTOP, str);
418+ textOutFixed(382, 293, PAL_FORGRND, PAL_DESKTOP, str);
419419 }
420420
421421 static void drawPanEnvRepS(void)
@@ -424,7 +424,7 @@ static void drawPanEnvRepS(void) · 2 unmodified lines
424424 instrTyp *ins = getCurDispInstr();
425425
426426 sprintf(str, "%02d", ins->envPRepS);
427− textOutFixed(382, 321, PAL_FORGRND, PAL_DESKTOP, str);
427+ textOutFixed(382, 320, PAL_FORGRND, PAL_DESKTOP, str);
428428 }
429429
430430 static void drawPanEnvRepE(void)
@@ -433,7 +433,7 @@ static void drawPanEnvRepE(void) · 2 unmodified lines
433433 instrTyp *ins = getCurDispInstr();
434434
435435 sprintf(str, "%02d", ins->envPRepE);
436− textOutFixed(382, 335, PAL_FORGRND, PAL_DESKTOP, str);
436+ textOutFixed(382, 334, PAL_FORGRND, PAL_DESKTOP, str);
437437 }
438438
439439 static void drawVolume(void)
@@ -445,7 +445,7 @@ static void drawVolume(void) · 5 unmodified lines
445445 else
446446 s = &instr[editor.curInstr]->samp[editor.curSmp];
447447
448− hexOutBg(505, 178, PAL_FORGRND, PAL_DESKTOP, s->vol, 2);
448+ hexOutBg(505, 177, PAL_FORGRND, PAL_DESKTOP, s->vol, 2);
449449 }
450450
451451 static void drawPanning(void)
@@ -457,7 +457,7 @@ static void drawPanning(void) · 5 unmodified lines
457457 else
458458 s = &instr[editor.curInstr]->samp[editor.curSmp];
459459
460− hexOutBg(505, 192, PAL_FORGRND, PAL_DESKTOP, s->pan, 2);
460+ hexOutBg(505, 191, PAL_FORGRND, PAL_DESKTOP, s->pan, 2);
461461 }
462462
463463 static void drawFineTune(void)
@@ -2262,17 +2262,17 @@ void showInstEditor(void) · 1798 unmodified lines
22622262
22632263 textOutShadow(20, 176, PAL_FORGRND, PAL_DSKTOP2, "Volume envelope:");
22642264 textOutShadow(153, 176, PAL_FORGRND, PAL_DSKTOP2, "Predef.");
2265− textOutShadow(358, 193, PAL_FORGRND, PAL_DSKTOP2, "Sustain:");
2265+ textOutShadow(358, 194, PAL_FORGRND, PAL_DSKTOP2, "Sustain:");
22662266 textOutShadow(342, 206, PAL_FORGRND, PAL_DSKTOP2, "Point");
22672267 textOutShadow(358, 219, PAL_FORGRND, PAL_DSKTOP2, "Env.loop:");
2268− textOutShadow(342, 234, PAL_FORGRND, PAL_DSKTOP2, "Start");
2268+ textOutShadow(342, 233, PAL_FORGRND, PAL_DSKTOP2, "Start");
22692269 textOutShadow(342, 247, PAL_FORGRND, PAL_DSKTOP2, "End");
22702270 textOutShadow(20, 263, PAL_FORGRND, PAL_DSKTOP2, "Panning envelope:");
22712271 textOutShadow(152, 263, PAL_FORGRND, PAL_DSKTOP2, "Predef.");
2272− textOutShadow(358, 280, PAL_FORGRND, PAL_DSKTOP2, "Sustain:");
2272+ textOutShadow(358, 281, PAL_FORGRND, PAL_DSKTOP2, "Sustain:");
22732273 textOutShadow(342, 293, PAL_FORGRND, PAL_DSKTOP2, "Point");
22742274 textOutShadow(358, 306, PAL_FORGRND, PAL_DSKTOP2, "Env.loop:");
2275− textOutShadow(342, 321, PAL_FORGRND, PAL_DSKTOP2, "Start");
2275+ textOutShadow(342, 320, PAL_FORGRND, PAL_DSKTOP2, "Start");
22762276 textOutShadow(342, 334, PAL_FORGRND, PAL_DSKTOP2, "End");
22772277 textOutShadow(443, 177, PAL_FORGRND, PAL_DSKTOP2, "Volume");
22782278 textOutShadow(443, 191, PAL_FORGRND, PAL_DSKTOP2, "Panning");
@@ -2609,8 +2609,8 @@ void drawInstEditorExt(void) · 330 unmodified lines
26092609 textOutShadow(4, 96, PAL_FORGRND, PAL_DSKTOP2, "Instrument Editor Extension:");
26102610 textOutShadow(20, 114, PAL_FORGRND, PAL_DSKTOP2, "Instrument MIDI enable");
26112611 textOutShadow(189, 114, PAL_FORGRND, PAL_DSKTOP2, "Mute computer");
2612− textOutShadow(4, 133, PAL_FORGRND, PAL_DSKTOP2, "MIDI transmit channel");
2613− textOutShadow(4, 147, PAL_FORGRND, PAL_DSKTOP2, "MIDI program");
2612+ textOutShadow(4, 132, PAL_FORGRND, PAL_DSKTOP2, "MIDI transmit channel");
2613+ textOutShadow(4, 146, PAL_FORGRND, PAL_DSKTOP2, "MIDI program");
26142614 textOutShadow(4, 160, PAL_FORGRND, PAL_DSKTOP2, "Bender range (halftones)");
26152615
26162616 if (ins == NULL)
@@ -3268,9 +3268,9 @@ static int32_t SDLCALL loadInstrThread(void *ptr) · 651 unmodified lines
32683268 {
32693269 s->typ &= ~32;
32703270
3271− s->len /= 2;
3272− s->repL /= 2;
3273− s->repS /= 2;
3271+ s->len >>= 1;
3272+ s->repL >>= 1;
3273+ s->repS >>= 1;
32743274
32753275 newPtr = (int8_t *)realloc(s->origPek, s->len + LOOP_FIX_LEN);
32763276 if (newPtr != NULL)
@@ -3348,11 +3348,11 @@ static int32_t SDLCALL loadInstrThread(void *ptr) · 71 unmodified lines
33483348 {
33493349 ins->vibSweep = ih_PATWave.vibSweep;
33503350
3351− ins->vibRate = (ih_PATWave.vibRate + 2) / 4;
3351+ ins->vibRate = (ih_PATWave.vibRate + 2) >> 2;
33523352 if (ins->vibRate > 0x3F)
33533353 ins->vibRate = 0x3F;
33543354
3355− ins->vibDepth = (ih_PATWave.vibDepth + 1) / 2;
3355+ ins->vibDepth = (ih_PATWave.vibDepth + 1) >> 1;
33563356 if (ins->vibDepth > 0x0F)
33573357 ins->vibDepth = 0x0F;
33583358 }
src/ft2_mix.c+96−168
@@ -36,13 +36,10 @@ · 35 unmodified lines
3636
3737 static void mix8bNoLoop(voice_t *v, uint32_t numSamples)
3838 {
39− const int8_t *CDA_LinearAdr;
40− bool mixInMono;
41− int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
42− register const int8_t *smpPtr;
43− register int32_t CDA_LVol, CDA_RVol;
44− register uint32_t pos, delta;
45− uint32_t i, samplesToMix;
39+ const int8_t *CDA_LinearAdr, *smpPtr;
40+ int32_t realPos, sample, *audioMixL, *audioMixR;
41+ int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
42+ uint32_t pos;
4643
4744 GET_VOL
4845
@@ -103,13 +100,10 @@ static void mix8bNoLoop(voice_t *v, uint32_t numSamples) · 54 unmodified lines
103100
104101 static void mix8bLoop(voice_t *v, uint32_t numSamples)
105102 {
106− const int8_t *CDA_LinearAdr;
107− bool mixInMono;
108− int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
109− register const int8_t *smpPtr;
110− register int32_t CDA_LVol, CDA_RVol;
111− register uint32_t pos, delta;
112− uint32_t i, samplesToMix;
103+ const int8_t *CDA_LinearAdr, *smpPtr;;
104+ int32_t realPos, sample, *audioMixL, *audioMixR;
105+ int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
106+ uint32_t pos;
113107
114108 GET_VOL
115109
@@ -170,13 +164,10 @@ static void mix8bLoop(voice_t *v, uint32_t numSamples) · 54 unmodified lines
170164
171165 static void mix8bBidiLoop(voice_t *v, uint32_t numSamples)
172166 {
173− bool mixInMono;
174− const int8_t *CDA_LinearAdr, *CDA_LinAdrRev;
175− int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
176− register const int8_t *smpPtr;
177− register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
178− register uint32_t pos;
179− uint32_t delta, i, samplesToMix;
167+ const int8_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
168+ int32_t realPos, sample, *audioMixL, *audioMixR;
169+ int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
170+ uint32_t pos, delta;
180171
181172 GET_VOL
182173
@@ -237,13 +228,10 @@ static void mix8bBidiLoop(voice_t *v, uint32_t numSamples) · 54 unmodified lines
237228
238229 static void mix8bNoLoopIntrp(voice_t *v, uint32_t numSamples)
239230 {
240− const int8_t *CDA_LinearAdr;
241− bool mixInMono;
242− int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
243− register const int8_t *smpPtr;
244− register int32_t CDA_LVol, CDA_RVol;
245− register uint32_t pos, delta;
246− uint32_t i, samplesToMix;
231+ const int8_t *CDA_LinearAdr, *smpPtr;
232+ int32_t realPos, sample, sample2, *audioMixL, *audioMixR;
233+ int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
234+ uint32_t pos;
247235 #ifndef LERPMIX
248236 int32_t sample3, sample4;
249237 #endif
@@ -307,13 +295,10 @@ static void mix8bNoLoopIntrp(voice_t *v, uint32_t numSamples) · 57 unmodified lines
307295
308296 static void mix8bLoopIntrp(voice_t *v, uint32_t numSamples)
309297 {
310− const int8_t *CDA_LinearAdr;
311− bool mixInMono;
312− int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
313− register const int8_t *smpPtr;
314− register int32_t CDA_LVol, CDA_RVol;
315− register uint32_t pos, delta;
316− uint32_t i, samplesToMix;
298+ const int8_t *CDA_LinearAdr, *smpPtr;
299+ int32_t realPos, sample, sample2, *audioMixL, *audioMixR;
300+ int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
301+ uint32_t pos;
317302 #ifndef LERPMIX
318303 int32_t sample3, sample4;
319304 #endif
@@ -377,13 +362,10 @@ static void mix8bLoopIntrp(voice_t *v, uint32_t numSamples) · 57 unmodified lines
377362
378363 static void mix8bBidiLoopIntrp(voice_t *v, uint32_t numSamples)
379364 {
380− bool mixInMono;
381− const int8_t *CDA_LinearAdr, *CDA_LinAdrRev;
382− int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
383− register const int8_t *smpPtr;
384− register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
385− register uint32_t pos;
386− uint32_t delta, i, samplesToMix;
365+ const int8_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
366+ int32_t realPos, sample, sample2, *audioMixL, *audioMixR;
367+ int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
368+ uint32_t pos, delta;
387369 #ifndef LERPMIX
388370 int32_t sample3, sample4;
389371 #endif
@@ -448,13 +430,10 @@ static void mix8bBidiLoopIntrp(voice_t *v, uint32_t numSamples) · 58 unmodified lines
448430
449431 static void mix8bRampNoLoop(voice_t *v, uint32_t numSamples)
450432 {
451− const int8_t *CDA_LinearAdr;
452− bool mixInMono;
453− int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;
454− register const int8_t *smpPtr;
455− register int32_t CDA_LVol, CDA_RVol;
456− register uint32_t pos, delta;
457− uint32_t i, samplesToMix;
433+ const int8_t *CDA_LinearAdr, *smpPtr;
434+ int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
435+ int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
436+ uint32_t pos;
458437
459438 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)
460439 {
@@ -522,13 +501,10 @@ static void mix8bRampNoLoop(voice_t *v, uint32_t numSamples) · 61 unmodified lines
522501
523502 static void mix8bRampLoop(voice_t *v, uint32_t numSamples)
524503 {
525− const int8_t *CDA_LinearAdr;
526− bool mixInMono;
527− int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;
528− register const int8_t *smpPtr;
529− register int32_t CDA_LVol, CDA_RVol;
530− register uint32_t pos, delta;
531− uint32_t i, samplesToMix;
504+ const int8_t *CDA_LinearAdr, *smpPtr;;
505+ int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
506+ int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
507+ uint32_t pos;
532508
533509 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)
534510 {
@@ -596,13 +572,10 @@ static void mix8bRampLoop(voice_t *v, uint32_t numSamples) · 61 unmodified lines
596572
597573 static void mix8bRampBidiLoop(voice_t *v, uint32_t numSamples)
598574 {
599− bool mixInMono;
600− const int8_t *CDA_LinearAdr, *CDA_LinAdrRev;
601− int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;
602− register const int8_t *smpPtr;
603− register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
604− register uint32_t pos;
605− uint32_t delta, i, samplesToMix;
575+ const int8_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
576+ int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
577+ int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
578+ uint32_t pos, delta;
606579
607580 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)
608581 {
@@ -671,13 +644,10 @@ static void mix8bRampBidiLoop(voice_t *v, uint32_t numSamples) · 62 unmodified lines
671644
672645 static void mix8bRampNoLoopIntrp(voice_t *v, uint32_t numSamples)
673646 {
674− const int8_t *CDA_LinearAdr;
675− bool mixInMono;
676− int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;
677− register const int8_t *smpPtr;
678− register int32_t CDA_LVol, CDA_RVol;
679− register uint32_t pos, delta;
680− uint32_t i, samplesToMix;
647+ const int8_t *CDA_LinearAdr, *smpPtr;
648+ int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
649+ int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
650+ uint32_t pos;
681651 #ifndef LERPMIX
682652 int32_t sample3, sample4;
683653 #endif
@@ -748,13 +718,10 @@ static void mix8bRampNoLoopIntrp(voice_t *v, uint32_t numSamples) · 64 unmodified lines
748718
749719 static void mix8bRampLoopIntrp(voice_t *v, uint32_t numSamples)
750720 {
751− const int8_t *CDA_LinearAdr;
752− bool mixInMono;
753− int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;
754− register const int8_t *smpPtr;
755− register int32_t CDA_LVol, CDA_RVol;
756− register uint32_t pos, delta;
757− uint32_t i, samplesToMix;
721+ const int8_t *CDA_LinearAdr, *smpPtr;
722+ int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
723+ int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
724+ uint32_t pos;
758725 #ifndef LERPMIX
759726 int32_t sample3, sample4;
760727 #endif
@@ -825,13 +792,10 @@ static void mix8bRampLoopIntrp(voice_t *v, uint32_t numSamples) · 64 unmodified lines
825792
826793 static void mix8bRampBidiLoopIntrp(voice_t *v, uint32_t numSamples)
827794 {
828− bool mixInMono;
829− const int8_t *CDA_LinearAdr, *CDA_LinAdrRev;
830− int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;
831− register const int8_t *smpPtr;
832− register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
833− register uint32_t pos;
834− uint32_t delta, i, samplesToMix;
795+ const int8_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
796+ int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
797+ int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
798+ uint32_t pos, delta;
835799 #ifndef LERPMIX
836800 int32_t sample3, sample4;
837801 #endif
@@ -908,13 +872,10 @@ static void mix8bRampBidiLoopIntrp(voice_t *v, uint32_t numSamples) · 70 unmodified lines
908872
909873 static void mix16bNoLoop(voice_t *v, uint32_t numSamples)
910874 {
911− bool mixInMono;
912− const int16_t *CDA_LinearAdr;
913− int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
914− register const int16_t *smpPtr;
915− register int32_t CDA_LVol, CDA_RVol;
916− register uint32_t pos, delta;
917− uint32_t i, samplesToMix;
875+ const int16_t *CDA_LinearAdr, *smpPtr;
876+ int32_t realPos, sample, *audioMixL, *audioMixR;
877+ int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
878+ uint32_t pos;
918879
919880 GET_VOL
920881
@@ -975,13 +936,10 @@ static void mix16bNoLoop(voice_t *v, uint32_t numSamples) · 54 unmodified lines
975936
976937 static void mix16bLoop(voice_t *v, uint32_t numSamples)
977938 {
978− bool mixInMono;
979− const int16_t *CDA_LinearAdr;
980− int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
981− register const int16_t *smpPtr;
982− register int32_t CDA_LVol, CDA_RVol;
983− register uint32_t pos, delta;
984− uint32_t i, samplesToMix;
939+ const int16_t *CDA_LinearAdr, *smpPtr;
940+ int32_t realPos, sample, *audioMixL, *audioMixR;
941+ int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
942+ uint32_t pos;
985943
986944 GET_VOL
987945
@@ -1042,13 +1000,10 @@ static void mix16bLoop(voice_t *v, uint32_t numSamples) · 54 unmodified lines
10421000
10431001 static void mix16bBidiLoop(voice_t *v, uint32_t numSamples)
10441002 {
1045− bool mixInMono;
1046− const int16_t *CDA_LinearAdr, *CDA_LinAdrRev;
1047− int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
1048− register const int16_t *smpPtr;
1049− register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
1050− register uint32_t pos;
1051− uint32_t delta, i, samplesToMix;
1003+ const int16_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
1004+ int32_t realPos, sample, *audioMixL, *audioMixR;
1005+ int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
1006+ uint32_t pos, delta;
10521007
10531008 GET_VOL
10541009
@@ -1110,13 +1065,10 @@ static void mix16bBidiLoop(voice_t *v, uint32_t numSamples) · 55 unmodified lines
11101065
11111066 static void mix16bNoLoopIntrp(voice_t *v, uint32_t numSamples)
11121067 {
1113− bool mixInMono;
1114− const int16_t *CDA_LinearAdr;
1115− int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
1116− register const int16_t *smpPtr;
1117− register int32_t CDA_LVol, CDA_RVol;
1118− register uint32_t pos, delta;
1119− uint32_t i, samplesToMix;
1068+ const int16_t *CDA_LinearAdr, *smpPtr;
1069+ int32_t realPos, sample, sample2, *audioMixL, *audioMixR;
1070+ int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
1071+ uint32_t pos;
11201072 #ifndef LERPMIX
11211073 int32_t sample3, sample4;
11221074 #endif
@@ -1180,13 +1132,10 @@ static void mix16bNoLoopIntrp(voice_t *v, uint32_t numSamples) · 57 unmodified lines
11801132
11811133 static void mix16bLoopIntrp(voice_t *v, uint32_t numSamples)
11821134 {
1183− bool mixInMono;
1184− const int16_t *CDA_LinearAdr;
1185− int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
1186− register const int16_t *smpPtr;
1187− register int32_t CDA_LVol, CDA_RVol;
1188− register uint32_t pos, delta;
1189− uint32_t i, samplesToMix;
1135+ const int16_t *CDA_LinearAdr, *smpPtr;
1136+ int32_t realPos, sample, sample2, *audioMixL, *audioMixR;
1137+ int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
1138+ uint32_t pos;
11901139 #ifndef LERPMIX
11911140 int32_t sample3, sample4;
11921141 #endif
@@ -1250,13 +1199,10 @@ static void mix16bLoopIntrp(voice_t *v, uint32_t numSamples) · 57 unmodified lines
12501199
12511200 static void mix16bBidiLoopIntrp(voice_t *v, uint32_t numSamples)
12521201 {
1253− bool mixInMono;
1254− const int16_t *CDA_LinearAdr, *CDA_LinAdrRev;
1255− int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
1256− register const int16_t *smpPtr;
1257− register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
1258− register uint32_t pos;
1259− uint32_t delta, i, samplesToMix;
1202+ const int16_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
1203+ int32_t realPos, sample, sample2, *audioMixL, *audioMixR;
1204+ int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
1205+ uint32_t pos, delta;
12601206 #ifndef LERPMIX
12611207 int32_t sample3, sample4;
12621208 #endif
@@ -1321,13 +1267,10 @@ static void mix16bBidiLoopIntrp(voice_t *v, uint32_t numSamples) · 58 unmodified lines
13211267
13221268 static void mix16bRampNoLoop(voice_t *v, uint32_t numSamples)
13231269 {
1324− bool mixInMono;
1325− const int16_t *CDA_LinearAdr;
1326− int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;
1327− register const int16_t *smpPtr;
1328− register int32_t CDA_LVol, CDA_RVol;
1329− register uint32_t pos, delta;
1330− uint32_t i, samplesToMix;
1270+ const int16_t *CDA_LinearAdr, *smpPtr;
1271+ int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
1272+ int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
1273+ uint32_t pos;
13311274
13321275 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)
13331276 {
@@ -1395,13 +1338,10 @@ static void mix16bRampNoLoop(voice_t *v, uint32_t numSamples) · 61 unmodified lines
13951338
13961339 static void mix16bRampLoop(voice_t *v, uint32_t numSamples)
13971340 {
1398− bool mixInMono;
1399− const int16_t *CDA_LinearAdr;
1400− int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;
1401− register const int16_t *smpPtr;
1402− register int32_t CDA_LVol, CDA_RVol;
1403− register uint32_t pos, delta;
1404− uint32_t i, samplesToMix;
1341+ const int16_t *CDA_LinearAdr, *smpPtr;
1342+ int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
1343+ int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
1344+ uint32_t pos;
14051345
14061346 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)
14071347 {
@@ -1469,13 +1409,10 @@ static void mix16bRampLoop(voice_t *v, uint32_t numSamples) · 61 unmodified lines
14691409
14701410 static void mix16bRampBidiLoop(voice_t *v, uint32_t numSamples)
14711411 {
1472− bool mixInMono;
1473− const int16_t *CDA_LinearAdr, *CDA_LinAdrRev;
1474− int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;
1475− register const int16_t *smpPtr;
1476− register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
1477− register uint32_t pos;
1478− uint32_t delta, i, samplesToMix;
1412+ const int16_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
1413+ int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
1414+ int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
1415+ uint32_t pos, delta;
14791416
14801417 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)
14811418 {
@@ -1544,13 +1481,10 @@ static void mix16bRampBidiLoop(voice_t *v, uint32_t numSamples) · 62 unmodified lines
15441481
15451482 static void mix16bRampNoLoopIntrp(voice_t *v, uint32_t numSamples)
15461483 {
1547− bool mixInMono;
1548− const int16_t *CDA_LinearAdr;
1549− int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;
1550− register const int16_t *smpPtr;
1551− register int32_t CDA_LVol, CDA_RVol;
1552− register uint32_t pos, delta;
1553− uint32_t i, samplesToMix;
1484+ const int16_t *CDA_LinearAdr, *smpPtr;
1485+ int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
1486+ int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
1487+ uint32_t pos;
15541488 #ifndef LERPMIX
15551489 int32_t sample3, sample4;
15561490 #endif
@@ -1621,13 +1555,10 @@ static void mix16bRampNoLoopIntrp(voice_t *v, uint32_t numSamples) · 64 unmodified lines
16211555
16221556 static void mix16bRampLoopIntrp(voice_t *v, uint32_t numSamples)
16231557 {
1624− bool mixInMono;
1625− const int16_t *CDA_LinearAdr;
1626− int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;
1627− register const int16_t *smpPtr;
1628− register int32_t CDA_LVol, CDA_RVol;
1629− register uint32_t pos, delta;
1630− uint32_t i, samplesToMix;
1558+ const int16_t *CDA_LinearAdr, *smpPtr;
1559+ int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
1560+ int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
1561+ uint32_t pos;
16311562 #ifndef LERPMIX
16321563 int32_t sample3, sample4;
16331564 #endif
@@ -1698,13 +1629,10 @@ static void mix16bRampLoopIntrp(voice_t *v, uint32_t numSamples) · 64 unmodified lines
16981629
16991630 static void mix16bRampBidiLoopIntrp(voice_t *v, uint32_t numSamples)
17001631 {
1701− bool mixInMono;
1702− const int16_t *CDA_LinearAdr, *CDA_LinAdrRev;
1703− int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;
1704− register const int16_t *smpPtr;
1705− register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
1706− register uint32_t pos;
1707− uint32_t delta, i, samplesToMix;
1632+ const int16_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
1633+ int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
1634+ int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
1635+ uint32_t pos, delta;
17081636 #ifndef LERPMIX
17091637 int32_t sample3, sample4;
17101638 #endif
src/ft2_mix_macros.h+18−14
@@ -14,21 +14,24 @@ · 13 unmodified lines
1414 v->SLVol2 = CDA_LVol; \
1515 v->SRVol2 = CDA_RVol; \
1616
17−#define GET_DELTA delta = v->SFrq;
17+#define GET_DELTA \
18+ const uint32_t delta = v->SFrq;
1819
1920 #define GET_MIXER_VARS \
21+ const int32_t SFrqRev = v->SFrqRev; \
2022 audioMixL = audio.mixBufferL; \
2123 audioMixR = audio.mixBufferR; \
22− mixInMono = (CDA_LVol == CDA_RVol); \
24+ const bool mixInMono = (CDA_LVol == CDA_RVol); \
2325 realPos = v->SPos; \
2426 pos = v->SPosDec; \
2527
2628 #define GET_MIXER_VARS_RAMP \
29+ const int32_t SFrqRev = v->SFrqRev; \
2730 audioMixL = audio.mixBufferL; \
2831 audioMixR = audio.mixBufferR; \
2932 CDA_LVolIP = v->SLVolIP; \
3033 CDA_RVolIP = v->SRVolIP; \
31− mixInMono = (v->SLVol2 == v->SRVol2) && (CDA_LVolIP == CDA_RVolIP); \
34+ const bool mixInMono = (v->SLVol2 == v->SRVol2) && (CDA_LVolIP == CDA_RVolIP); \
3235 realPos = v->SPos; \
3336 pos = v->SPosDec; \
3437
@@ -240,12 +243,15 @@ · 205 unmodified lines
240243 /* ----------------------------------------------------------------------- */
241244
242245 #define LIMIT_MIX_NUM \
243− i = (v->SLen - 1) - realPos; \
244− if (i > 65535) \
245− i = 65535; \
246+ samplesToMix = (v->SLen - 1) - realPos; \
247+ if (samplesToMix > 65535) \
248+ samplesToMix = 65535; \
246249 \
247− samplesToMix = (((((uint64_t)i << 16) | (pos ^ 0xFFFF)) * v->SFrqRev) >> 32) + 1; \
248− if (samplesToMix > (uint32_t)CDA_BytesLeft) \
250+ samplesToMix = (samplesToMix << 16) | (pos ^ 0xFFFF); \
251+ samplesToMix = ((int64_t)samplesToMix * SFrqRev) >> 32; \
252+ samplesToMix++; \
253+ \
254+ if (samplesToMix > CDA_BytesLeft) \
249255 samplesToMix = CDA_BytesLeft; \
250256
251257 #define LIMIT_MIX_NUM_RAMP \
@@ -262,7 +268,7 @@ · 10 unmodified lines
262268 } \
263269 else \
264270 { \
265− if (samplesToMix > (uint32_t)v->SVolIPLen) \
271+ if (samplesToMix > v->SVolIPLen) \
266272 samplesToMix = v->SVolIPLen; \
267273 \
268274 v->SVolIPLen -= samplesToMix; \
@@ -272,7 +278,6 @@ · 3 unmodified lines
272278 if (v->backwards) \
273279 { \
274280 delta = 0 - v->SFrq; \
275− CDA_IPValH = (int32_t)delta >> 16; \
276281 assert(realPos >= v->SRepS && realPos < v->SLen); \
277282 realPos = ~realPos; \
278283 smpPtr = CDA_LinAdrRev + realPos; \
@@ -281,19 +286,18 @@ · 2 unmodified lines
281286 else \
282287 { \
283288 delta = v->SFrq; \
284− CDA_IPValH = delta >> 16; \
285289 assert(realPos >= 0 && realPos < v->SLen); \
286290 smpPtr = CDA_LinearAdr + realPos; \
287291 } \
288292 \
289− CDA_IPValL = delta & 0xFFFF; \
293+ const int32_t CDA_IPValH = (int32_t)delta >> 16; \
294+ const int32_t CDA_IPValL = delta & 0xFFFF; \
290295
291296 #define END_BIDI \
292297 if (v->backwards) \
293298 { \
294299 pos ^= 0xFFFF; \
295− realPos = (int32_t)(smpPtr - CDA_LinAdrRev); \
296− realPos = ~realPos; \
300+ realPos = ~(int32_t)(smpPtr - CDA_LinAdrRev); \
297301 } \
298302 else \
299303 { \
src/ft2_module_loader.c+163−298
@@ -184,7 +184,7 @@ static uint8_t getModType(uint8_t *numChannels, const char *id) · 183 unmodified lines
184184
185185 if (IS_ID("M.K.", id) || IS_ID("M!K!", id) || IS_ID("NSMS", id) || IS_ID("LARD", id) || IS_ID("PATT", id))
186186 {
187− modFormat = FORMAT_MK; // ProTracker or compatible
187+ modFormat = FORMAT_MK; // ProTracker or compatible
188188 }
189189 else if (id[1] == 'C' && id[2] == 'H' && id[3] == 'N')
190190 {
@@ -200,11 +200,6 @@ static uint8_t getModType(uint8_t *numChannels, const char *id) · 9 unmodified lines
200200 {
201201 modFormat = FORMAT_FLT; // StarTrekker (4-channel modules only)
202202 }
203− else if (IS_ID("FLT8", id))
204− {
205− modFormat = FORMAT_FLT; // StarTrekker (4-channel modules only)
206− *numChannels = 8;
207− }
208203 else if (IS_ID("N.T.", id))
209204 {
210205 modFormat = FORMAT_NT; // NoiseTracker
@@ -364,23 +359,23 @@ static bool loadMusicMOD(FILE *f, uint32_t fileLength, bool fromExternalThread) · 153 unmodified lines
364359 */
365360 modFormat = FORMAT_STK;
366361
367− if (h_MOD15.repS == 0)
368− h_MOD15.repS = 120;
362+ if (songTmp.repS == 0)
363+ songTmp.repS = 120;
369364
370− // jjk55.mod by Jesper Kyd has a bogus STK tempo value that should be ignored
365+ // jjk55.mod by Jesper Kyd has a bogus STK tempo value that should be ignored (hackish!)
371366 if (!strcmp("jjk55", h_MOD31.name))
372− h_MOD15.repS = 120;
367+ songTmp.repS = 120;
373368
374369 // The "restart pos" field in STK is the inital tempo (must be converted to BPM first)
375− if (h_MOD15.repS != 120) // 120 is a special case and means 50Hz (125BPM)
370+ if (songTmp.repS != 120) // 120 is a special case and means 50Hz (125BPM)
376371 {
377− if (h_MOD15.repS > 220)
378− h_MOD15.repS = 220;
372+ if (songTmp.repS > 220)
373+ songTmp.repS = 220;
379374
380375 // convert UST tempo to BPM
381376 uint16_t ciaPeriod = (240 - songTmp.repS) * 122;
382377 double dHz = 709379.0 / ciaPeriod;
383− int32_t BPM = (int32_t)((dHz * (125.0 / 50.0)) + 0.5);
378+ int32_t BPM = (int32_t)((dHz * 2.5) + 0.5);
384379
385380 songTmp.speed = (uint16_t)BPM;
386381 }
@@ -450,7 +445,7 @@ static bool loadMusicMOD(FILE *f, uint32_t fileLength, bool fromExternalThread) · 63 unmodified lines
450445 ton->effTyp = bytes[2] & 0x0F;
451446 ton->eff = bytes[3];
452447
453− if (mightBeSTK)
448+ if (modFormat == FORMAT_STK)
454449 {
455450 if (ton->effTyp == 0xC || ton->effTyp == 0xD || ton->effTyp == 0xE)
456451 {
@@ -519,7 +514,7 @@ static bool loadMusicMOD(FILE *f, uint32_t fileLength, bool fromExternalThread) · 62 unmodified lines
519514 }
520515
521516 // pattern command conversion for non-PT formats
522− if (modFormat == FORMAT_STK || modFormat == FORMAT_FT2 || modFormat == FORMAT_NT || modFormat == FORMAT_HMNT || modFormat == FORMAT_FLT)
517+ if (modFormat == FORMAT_STK || modFormat == FORMAT_NT || modFormat == FORMAT_HMNT || modFormat == FORMAT_FLT)
523518 {
524519 for (a = 0; a < b; a++)
525520 {
@@ -690,7 +685,7 @@ static bool loadMusicMOD(FILE *f, uint32_t fileLength, bool fromExternalThread) · 164 unmodified lines
690685 /* For Ultimate SoundTracker modules, only the loop area of a looped sample is played.
691686 ** Skip loading of eventual data present before loop start.
692687 */
693− if (modFormat == FORMAT_STK && (s->repS > 0 && s->repL < s->len))
688+ if (modFormat == FORMAT_STK && s->repS > 0 && s->repL < s->len)
694689 {
695690 s->len -= s->repS;
696691 fseek(f, s->repS, SEEK_CUR);
@@ -705,7 +700,7 @@ static bool loadMusicMOD(FILE *f, uint32_t fileLength, bool fromExternalThread) · 8 unmodified lines
705700 }
706701
707702 // clear repL and repS on non-looping samples...
708− if ((s->typ & 3) == 0)
703+ if (s->typ == 0)
709704 {
710705 s->repL = 0;
711706 s->repS = 0;
@@ -735,18 +730,15 @@ static uint8_t stmTempoToBPM(uint8_t tempo) // ported from original ST2.3 replay · 23 unmodified lines
735730 uint16_t hz = 50;
736731
737732 hz -= ((slowdowns[tempo >> 4] * (tempo & 15)) >> 4); // can and will underflow
738−
739− bpm = (int32_t)((hz * 2.5) + 0.5);
733+ bpm = (hz << 1) + (hz >> 1); // BPM = hz * 2.5
740734 return (uint8_t)CLAMP(bpm, 32, 255); // result can be slightly off, but close enough...
741735 }
742736
743737 static bool loadMusicSTM(FILE *f, uint32_t fileLength, bool fromExternalThread)
744738 {
745− bool check3xx;
746− uint8_t typ, tmp8, tempo;
739+ uint8_t typ, tempo;
747740 int16_t i, j, k, ai, ap, tmp;
748741 uint16_t a;
749− int32_t len;
750742 tonTyp *ton;
751743 sampleTyp *s;
752744 songSTMHeaderTyp h_STM;
@@ -887,19 +879,6 @@ static bool loadMusicSTM(FILE *f, uint32_t fileLength, bool fromExternalThread) · 134 unmodified lines
887879 ton->eff = 0;
888880 }
889881
890− /* Remove any EDx with no note.
891− ** SDx with no note in ST3 = does nothing
892− ** EDx with no note in FT2 = still retriggers
893− */
894− if (ton->effTyp == 0xE && (ton->eff & 0xF0) == 0xD0)
895− {
896− if (ton->ton == 0 || ton->ton == 97)
897− {
898− ton->eff = 0;
899− ton->effTyp = 0;
900− }
901− }
902−
903882 if (ton->effTyp > 35)
904883 {
905884 ton->effTyp = 0;
@@ -986,77 +965,6 @@ static bool loadMusicSTM(FILE *f, uint32_t fileLength, bool fromExternalThread) · 80 unmodified lines
986965 }
987966 }
988967
989− // non-FT2: fix overflown 9xx and illegal 3xx
990−
991− for (i = 0; i < ap; i++)
992− {
993− if (pattTmp[i] == NULL)
994− continue;
995−
996− for (k = 0; k < songTmp.antChn; k++)
997− {
998− check3xx = false;
999− for (j = 0; j < 64; j++)
1000− {
1001− ton = &pattTmp[i][(j * MAX_VOICES) + k];
1002−
1003− if (ton->ton > 0 && ton->ton < 97 && ton->effTyp != 0x3)
1004− check3xx = true;
1005−
1006− if (ton->ton > 0 && ton->ton < 97 && ton->effTyp == 0x3)
1007− check3xx = false;
1008−
1009− if (check3xx && ton->effTyp == 0x3)
1010− {
1011− if (ton->ton == 0 || ton->ton == 97)
1012− {
1013− ton->effTyp = 0;
1014− ton->eff = 0;
1015− }
1016− }
1017−
1018− if (ton->effTyp == 0x9 && ton->eff > 0)
1019− {
1020− if (ton->instr != 0 && ton->instr <= ai)
1021− {
1022− s = &instrTmp[ton->instr]->samp[0];
1023− len = s->len;
1024−
1025− tmp8 = 0;
1026− if (len > 0)
1027− {
1028− tmp8 = ton->eff;
1029−
1030− int32_t newLen = len >> 8;
1031− if (tmp8 >= newLen)
1032− {
1033− if (newLen < 1)
1034− tmp8 = 0;
1035− else
1036− tmp8 = (uint8_t)(newLen - 1);
1037− }
1038− }
1039−
1040− if (tmp8 > 0)
1041− {
1042− ton->eff = tmp8;
1043− }
1044− else
1045− {
1046− ton->effTyp = 0;
1047− ton->eff = 0;
1048− }
1049− }
1050− else
1051− {
1052− ton->effTyp = 0;
1053− ton->eff = 0;
1054− }
1055− }
1056− }
1057− }
1058− }
1059−
1060968 fclose(f);
1061969
1062970 moduleLoaded = true;
@@ -1102,14 +1010,14 @@ static int8_t countS3MChannels(uint16_t antPtn) · 39 unmodified lines
11021010 static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread)
11031011 {
11041012 int8_t *tmpSmp;
1105− bool check3xx, illegalUxx;
1013+ bool illegalUxx;
11061014 uint8_t ha[2048];
1107− uint8_t s3mLastDEff[32], s3mLastEEff[32], s3mLastFEff[32];
1108− uint8_t s3mLastSEff[32], s3mLastJEff[32], s3mLastGInstr[32], typ;
1015+ uint8_t alastnfo[32], alastefx[32], alastvibnfo[32], s3mLastGInstr[32];
1016+ uint8_t typ;
11091017 int16_t ai, ap, ver, ii, kk, tmp;
11101018 uint16_t ptnOfs[256];
11111019 int32_t i, j, k, len;
1112− tonTyp ton, *pattTon;
1020+ tonTyp ton;
11131021 sampleTyp *s;
11141022 songS3MHeaderTyp h_S3M;
11151023 songS3MinstrHeaderTyp h_S3MInstr;
@@ -1143,13 +1051,7 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 27 unmodified lines
11431051 goto s3mLoadError;
11441052 }
11451053
1146− // count real song table entries
1147− songTmp.len = 256;
1148− while (songTmp.len > 0 && songTmp.songTab[songTmp.len-1] == 255)
1149− songTmp.len--;
1150−
1151− if (songTmp.len == 256)
1152− songTmp.len = 255;
1054+ songTmp.len = h_S3M.songTabLen;
11531055
11541056 // remove pattern separators (254)
11551057 k = 0;
@@ -1165,11 +1067,20 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 9 unmodified lines
11651067 if (k <= songTmp.len)
11661068 songTmp.len -= (uint16_t)k;
11671069 else
1168− songTmp.len = 0;
1070+ songTmp.len = 1;
1071+
1072+ for (i = 1; i < songTmp.len; i++)
1073+ {
1074+ if (songTmp.songTab[i] == 255)
1075+ {
1076+ songTmp.len = (uint16_t)i;
1077+ break;
1078+ }
1079+ }
11691080
11701081 // clear unused song table entries
11711082 if (songTmp.len < 255)
1172− memset(&songTmp.songTab[songTmp.len], 0, 256 - songTmp.len);
1083+ memset(&songTmp.songTab[songTmp.len], 0, 255-songTmp.len);
11731084
11741085 songTmp.speed = h_S3M.defTempo;
11751086 if (songTmp.speed < 32)
@@ -1226,11 +1137,9 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 50 unmodified lines
12261137 if (ptnOfs[i] == 0)
12271138 continue; // empty pattern
12281139
1229− memset(s3mLastDEff, 0, sizeof (s3mLastDEff));
1230− memset(s3mLastEEff, 0, sizeof (s3mLastEEff));
1231− memset(s3mLastFEff, 0, sizeof (s3mLastFEff));
1232− memset(s3mLastSEff, 0, sizeof (s3mLastSEff));
1233− memset(s3mLastJEff, 0, sizeof (s3mLastJEff));
1140+ memset(alastnfo, 0, sizeof (alastnfo));
1141+ memset(alastefx, 0, sizeof (alastefx));
1142+ memset(alastvibnfo, 0, sizeof (alastvibnfo));
12341143 memset(s3mLastGInstr, 0, sizeof (s3mLastGInstr));
12351144
12361145 fseek(f, ptnOfs[i] << 4, SEEK_SET);
@@ -1295,7 +1204,7 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 58 unmodified lines
12951204 }
12961205 }
12971206
1298− // volume
1207+ // volume column
12991208 if (typ & 64)
13001209 {
13011210 ton.vol = pattBuff[k++];
@@ -1312,28 +1221,42 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 10 unmodified lines
13121221 ton.effTyp = pattBuff[k++];
13131222 ton.eff = pattBuff[k++];
13141223
1315− if (ton.eff == 0)
1224+ if (ton.eff > 0)
13161225 {
1317− if (ton.effTyp == 4)
1318− {
1319− if ((s3mLastDEff[ii] & 0xF0) == 0xF0 || (s3mLastDEff[ii] & 0x0F) == 0x0F)
1320− ton.eff = s3mLastDEff[ii];
1321− }
1322− else if (ton.effTyp == 5) ton.eff = s3mLastEEff[ii];
1323− else if (ton.effTyp == 6) ton.eff = s3mLastFEff[ii];
1324− else if (ton.effTyp == 10) ton.eff = s3mLastJEff[ii];
1325− else if (ton.effTyp == 19) ton.eff = s3mLastSEff[ii];
1226+ alastnfo[ii] = ton.eff;
1227+ if (ton.effTyp == 8 || ton.effTyp == 21)
1228+ alastvibnfo[ii] = ton.eff; // H/U
13261229 }
1327−
1328− if (ton.eff != 0)
1230+
1231+ // in ST3, a lot of effects directly share the same memory!
1232+ if (ton.eff == 0 && ton.effTyp != 7) // G
13291233 {
1330− if (ton.effTyp == 4) s3mLastDEff[ii] = ton.eff;
1331− else if (ton.effTyp == 5) s3mLastEEff[ii] = ton.eff;
1332− else if (ton.effTyp == 6) s3mLastFEff[ii] = ton.eff;
1333− else if (ton.effTyp == 10) s3mLastJEff[ii] = ton.eff;
1334− else if (ton.effTyp == 19) s3mLastSEff[ii] = ton.eff;
1234+ uint8_t efx = ton.effTyp;
1235+ if (efx == 8 || efx == 21) // H/U
1236+ ton.eff = alastvibnfo[ii];
1237+ else if ((efx >= 4 && efx <= 12) || (efx >= 17 && efx <= 19)) // D/E/F/I/J/K/L/Q/R/S
1238+ ton.eff = alastnfo[ii];
1239+
1240+ /* If effect data is zero and effect type was the same as last one, clear out
1241+ ** data if it's not J or S (those have no memory in the equivalent XM effects).
1242+ ** Also goes for extra fine pitch slides and fine volume slides,
1243+ ** since they get converted to other effects.
1244+ */
1245+ if (efx == alastefx[ii] && ton.effTyp != 10 && ton.effTyp != 19) // J/S
1246+ {
1247+ uint8_t nfo = ton.eff;
1248+ bool extraFinePitchSlides = (efx == 5 || efx == 6) && ((nfo & 0xF0) == 0xE0);
1249+ bool fineVolSlides = (efx == 4 || efx == 11) &&
1250+ ((nfo > 0xF0) || (((nfo & 0xF) == 0xF) && ((nfo & 0xF0) > 0)));
1251+
1252+ if (!extraFinePitchSlides && !fineVolSlides)
1253+ ton.eff = 0;
1254+ }
13351255 }
13361256
1257+ if (ton.effTyp > 0)
1258+ alastefx[ii] = ton.effTyp;
1259+
13371260 switch (ton.effTyp)
13381261 {
13391262 case 1: // A
@@ -1351,14 +1274,12 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 11 unmodified lines
13511274 case 3: ton.effTyp = 0xD; break; // C
13521275 case 4: // D
13531276 {
1354− if ((ton.eff & 0xF0) == 0) ton.effTyp = 0xA;
1355− else if ((ton.eff & 0x0F) == 0) ton.effTyp = 0xA;
1356− else if ((ton.eff & 0xF0) == 0xF0)
1277+ if (ton.eff > 0xF0) // fine slide up
13571278 {
13581279 ton.effTyp = 0xE;
1359− ton.eff = 0xB0 | (ton.eff & 15);
1280+ ton.eff = 0xB0 | (ton.eff & 0xF);
13601281 }
1361− else if ((ton.eff & 0x0F) == 0x0F)
1282+ else if ((ton.eff & 0x0F) == 0x0F && (ton.eff & 0xF0) > 0) // fine slide down
13621283 {
13631284 ton.effTyp = 0xE;
13641285 ton.eff = 0xA0 | (ton.eff >> 4);
@@ -1366,10 +1287,8 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 1 unmodified line
13661287 else
13671288 {
13681289 ton.effTyp = 0xA;
1369− if (ton.eff & 0x0F)
1290+ if (ton.eff & 0x0F) // on D/K, last nybble has first priority in ST3
13701291 ton.eff &= 0x0F;
1371− else
1372− ton.eff &= 0xF0;
13731292 }
13741293 }
13751294 break;
@@ -1379,6 +1298,7 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 3 unmodified lines
13791298 {
13801299 if ((ton.eff & 0xF0) >= 0xE0)
13811300 {
1301+ // convert to fine slide
13821302 if ((ton.eff & 0xF0) == 0xE0)
13831303 tmp = 0x21;
13841304 else
@@ -1392,9 +1312,15 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 7 unmodified lines
13921312 ton.eff |= 0x10;
13931313
13941314 ton.effTyp = (uint8_t)tmp;
1315+
1316+ if (ton.effTyp == 0x21 && ton.eff == 0)
1317+ {
1318+ ton.effTyp = 0;
1319+ }
13951320 }
13961321 else
13971322 {
1323+ // convert to normal 1xx/2xx slide
13981324 ton.effTyp = 7 - ton.effTyp;
13991325 }
14001326 }
@@ -1402,18 +1328,46 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 1 unmodified line
14021328
14031329 case 7: // G
14041330 {
1331+ ton.effTyp = 0x03;
1332+
14051333 // fix illegal slides (to new instruments)
14061334 if (ton.instr != 0 && ton.instr != s3mLastGInstr[ii])
14071335 ton.instr = s3mLastGInstr[ii];
1336+ }
1337+ break;
14081338
1409− ton.effTyp = 0x03;
1339+ case 11: // K
1340+ {
1341+ if (ton.eff > 0xF0) // fine slide up
1342+ {
1343+ ton.effTyp = 0xE;
1344+ ton.eff = 0xB0 | (ton.eff & 0xF);
1345+
1346+ // if volume column is unoccupied, set to vibrato
1347+ if (ton.vol == 0)
1348+ ton.vol = 0xB0;
1349+ }
1350+ else if ((ton.eff & 0x0F) == 0x0F && (ton.eff & 0xF0) > 0) // fine slide down
1351+ {
1352+ ton.effTyp = 0xE;
1353+ ton.eff = 0xA0 | (ton.eff >> 4);
1354+
1355+ // if volume column is unoccupied, set to vibrato
1356+ if (ton.vol == 0)
1357+ ton.vol = 0xB0;
1358+ }
1359+ else
1360+ {
1361+ ton.effTyp = 0x6;
1362+ if (ton.eff & 0x0F) // on D/K, last nybble has first priority in ST3
1363+ ton.eff &= 0x0F;
1364+ }
14101365 }
14111366 break;
14121367
14131368 case 8: ton.effTyp = 0x04; break; // H
14141369 case 9: ton.effTyp = 0x1D; break; // I
14151370 case 10: ton.effTyp = 0x00; break; // J
1416− case 11: ton.effTyp = 0x06; break; // K
14171371 case 12: ton.effTyp = 0x05; break; // L
14181372 case 15: ton.effTyp = 0x09; break; // O
14191373 case 17: ton.effTyp = 0x1B; break; // Q
@@ -1429,10 +1383,37 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 9 unmodified lines
14291383 else if (tmp == 0x2) ton.eff |= 0x50;
14301384 else if (tmp == 0x3) ton.eff |= 0x40;
14311385 else if (tmp == 0x4) ton.eff |= 0x70;
1432− // we ignore S8x (set 4-bit pan) becuase it's not compatible with FT2 panning
1386+ // ignore S8x becuase it's not compatible with FT2 panning
14331387 else if (tmp == 0xB) ton.eff |= 0x60;
1434− else if (tmp == 0xC) ton.eff |= 0xC0;
1435− else if (tmp == 0xD) ton.eff |= 0xD0;
1388+ else if (tmp == 0xC) // Note Cut
1389+ {
1390+ ton.eff |= 0xC0;
1391+ if (ton.eff == 0xC0)
1392+ {
1393+ // EC0 does nothing in ST3 but cuts voice in FT2, remove effect
1394+ ton.effTyp = 0;
1395+ ton.eff = 0;
1396+ }
1397+ }
1398+ else if (tmp == 0xD) // Note Delay
1399+ {
1400+ ton.eff |= 0xD0;
1401+ if (ton.ton == 0 || ton.ton == 97)
1402+ {
1403+ // EDx without a note does nothing in ST3 but retrigs in FT2, remove effect
1404+ ton.effTyp = 0;
1405+ ton.eff = 0;
1406+ }
1407+ else if (ton.eff == 0xD0)
1408+ {
1409+ // ED0 prevents note/smp/vol from updating in ST3, remove everything
1410+ ton.ton = 0;
1411+ ton.instr = 0;
1412+ ton.vol = 0;
1413+ ton.effTyp = 0;
1414+ ton.eff = 0;
1415+ }
1416+ }
14361417 else if (tmp == 0xE) ton.eff |= 0xE0;
14371418 else if (tmp == 0xF) ton.eff |= 0xF0;
14381419 else
@@ -1454,40 +1435,18 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 15 unmodified lines
14541435 }
14551436 break;
14561437
1457− case 21: // U (fine vibrato, doesn't exist in FT2, do a poor conversion to normal vibrato)
1438+ case 22: // V
14581439 {
1459− if ((ton.eff & 0x0F) != 0)
1440+ ton.effTyp = 0x10;
1441+ if (ton.eff > 0x40)
14601442 {
1461− ton.eff = (ton.eff & 0xF0) | (((ton.eff & 15) + 1) >> 2); // divide depth by 4
1462− if ((ton.eff & 0x0F) == 0) // depth too low, remove effect
1463− {
1464− illegalUxx = true;
1465− ton.effTyp = 0;
1466− ton.eff = 0;
1467− }
1468− else
1469− {
1470− illegalUxx = false;
1471− ton.effTyp = 0x04;
1472− }
1473− }
1474− else
1475− {
1476− if (!illegalUxx)
1477− {
1478− ton.effTyp = 0x04;
1479− }
1480− else
1481− {
1482− ton.effTyp = 0;
1483− ton.eff = 0;
1484− }
1443+ // Vxx > 0x40 does nothing in ST3
1444+ ton.effTyp = 0;
1445+ ton.eff = 0;
14851446 }
14861447 }
14871448 break;
14881449
1489− case 22: ton.effTyp = 0x10; break; // V
1490−
14911450 default:
14921451 {
14931452 ton.effTyp = 0;
@@ -1500,40 +1459,6 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 6 unmodified lines
15001459 if (ton.instr != 0 && ton.effTyp != 0x3)
15011460 s3mLastGInstr[ii] = ton.instr;
15021461
1503− // EDx with no note does nothing in ST3 but retrigs in FT2, remove effect
1504− if (ton.effTyp == 0xE && (ton.eff & 0xF0) == 0xD0)
1505− {
1506− if (ton.ton == 0 || ton.ton == 97)
1507− {
1508− ton.effTyp = 0;
1509− ton.eff = 0;
1510− }
1511− }
1512−
1513− // EDx with a zero will prevent note/instr/vol from updating in ST3, remove everything
1514− if (ton.effTyp == 0xE && ton.eff == 0xD0)
1515− {
1516− ton.ton = 0;
1517− ton.instr = 0;
1518− ton.vol = 0;
1519− ton.effTyp = 0;
1520− ton.eff = 0;
1521− }
1522−
1523− // ECx with a zero does nothing in ST3 but cuts voice in FT2, remove effect
1524− if (ton.effTyp == 0xE && ton.eff == 0xC0)
1525− {
1526− ton.effTyp = 0;
1527− ton.eff = 0;
1528− }
1529−
1530− // Vxx with a value higher than 64 (0x40) does nothing in ST3, remove effect
1531− if (ton.effTyp == 0x10 && ton.eff > 0x40)
1532− {
1533− ton.effTyp = 0;
1534− ton.eff = 0;
1535− }
1536−
15371462 if (ton.effTyp > 35)
15381463 {
15391464 ton.effTyp = 0;
@@ -1610,10 +1535,10 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 70 unmodified lines
16101535 bool is16Bit = (h_S3MInstr.flags >> 2) & 1;
16111536
16121537 if (is16Bit) // 16-bit
1613− len *= 2;
1538+ len <<= 1;
16141539
16151540 if (stereoSample) // stereo
1616− len *= 2;
1541+ len <<= 1;
16171542
16181543 tmpSmp = (int8_t *)malloc(len + LOOP_FIX_LEN);
16191544 if (tmpSmp == NULL)
@@ -1683,9 +1608,9 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 63 unmodified lines
16831608 s->origPek = tmpSmp;
16841609 s->pek = s->origPek + SMP_DAT_OFFSET;
16851610
1686− s->len *= 2;
1687− s->repS *= 2;
1688− s->repL *= 2;
1611+ s->len <<= 1;
1612+ s->repS <<= 1;
1613+ s->repL <<= 1;
16891614 }
16901615 else
16911616 {
@@ -1712,74 +1637,6 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 20 unmodified lines
17121637 }
17131638 }
17141639
1715− // non-FT2: fix overflown 9xx and illegal 3xx slides
1716−
1717− for (i = 0; i < ap; i++)
1718− {
1719− if (pattTmp[i] == NULL)
1720− continue;
1721−
1722− for (k = 0; k < songTmp.antChn; k++)
1723− {
1724− check3xx = false;
1725− for (j = 0; j < 64; j++)
1726− {
1727− pattTon = &pattTmp[i][(j * MAX_VOICES) + k];
1728−
1729− // fix illegal 3xx slides
1730−
1731− if (pattTon->ton > 0 && pattTon->ton < 97)
1732− check3xx = pattTon->effTyp != 0x3;
1733−
1734− if (check3xx && pattTon->effTyp == 0x3)
1735− {
1736− if (pattTon->ton == 0 || pattTon->ton == 97)
1737− {
1738− pattTon->effTyp = 0;
1739− pattTon->eff = 0;
1740− }
1741− }
1742−
1743− /* In ST3 in GUS mode, an overflowed sample offset behaves like this:
1744− ** - Non-looped sample: Cut voice
1745− ** - Looped sample: Wrap around loop point
1746− **
1747− ** What we do here is to change the sample offset value to point to
1748− ** the wrapped sample loop position. This may be off by up to 256 bytes
1749− ** though...
1750− */
1751−
1752− if (pattTon->effTyp == 0x9 && pattTon->eff > 0 && pattTon->instr > 0 && pattTon->instr <= ai && ai <= 128)
1753− {
1754− instrTyp *ins = instrTmp[pattTon->instr];
1755− if (ins == NULL)
1756− continue; // empty instrument (sample)
1757−
1758− s = &ins->samp[0];
1759− if (s->len > 0 && (s->typ & 1)) // only handle non-empty looping samples
1760− {
1761− uint32_t loopEnd = s->repS + s->repL;
1762− uint32_t offset = pattTon->eff * 256;
1763−
1764− if (offset >= loopEnd)
1765− {
1766− if (s->repL >= 2)
1767− offset = s->repS + ((offset - loopEnd) % s->repL);
1768− else
1769− offset = s->repS;
1770−
1771− offset = (offset + (1 << 7)) >> 8; // convert to rounded sample offset value
1772− if (offset > 255)
1773− offset = 255;
1774−
1775− pattTon->eff = (uint8_t)offset;
1776− }
1777− }
1778− }
1779− }
1780− }
1781− }
1782−
17831640 fclose(f);
17841641
17851642 songTmp.antChn = countS3MChannels(ap);
@@ -2566,30 +2423,37 @@ static void setupLoadedModule(void) · 780 unmodified lines
25662423 // support non-even channel numbers
25672424 if (song.antChn & 1)
25682425 {
2569− if (++song.antChn > MAX_VOICES)
2426+ song.antChn++;
2427+ if (song.antChn > MAX_VOICES)
25702428 song.antChn = MAX_VOICES;
25712429 }
25722430
2573− if (song.repS > song.len)
2431+ if (song.len == 0)
2432+ song.len = 1;
2433+
2434+ if (song.repS >= song.len)
25742435 song.repS = 0;
25752436
25762437 song.globVol = 64;
2577− song.timer = 1;
25782438
25792439 setScrollBarEnd(SB_POS_ED, (song.len - 1) + 5);
25802440 setScrollBarPos(SB_POS_ED, 0, false);
25812441
25822442 resetChannels();
2583− setPos(0, 0, false);
2443+ setPos(0, 0, true);
25842444 setSpeed(song.speed);
25852445
25862446 editor.tmpPattern = editor.editPattern; // set kludge variable
25872447 editor.speed = song.speed;
25882448 editor.tempo = song.tempo;
2589− editor.timer = 1;
2449+ editor.timer = song.timer;
25902450 editor.globalVol = song.globVol;
25912451
2592− setFrqTab((loadedFormat == FORMAT_XM) ? linearFreqTable : false);
2452+ if (loadedFormat == FORMAT_XM)
2453+ setFrqTab(linearFreqTable);
2454+ else
2455+ setFrqTab(false);
2456+
25932457 unlockMixerCallback();
25942458
25952459 editor.currVolEnvPoint = 0;
@@ -2602,9 +2466,10 @@ static void setupLoadedModule(void) · 6 unmodified lines
26022466 updateChanNums();
26032467 resetWavRenderer();
26042468 clearPattMark();
2605− song.musicTime = 0;
26062469 resetTrimSizes();
26072470
2471+ song.musicTime = 0;
2472+
26082473 diskOpSetFilename(DISKOP_ITEM_MODULE, editor.tmpFilenameU);
26092474
26102475 // redraw top part of screen
src/ft2_nibbles.c+2−2
@@ -265,7 +265,7 @@ void nibblesHighScore(void) · 264 unmodified lines
265265 {
266266 if (editor.NI_Play)
267267 {
268− okBox(0, "System message", "The highscore table is not available during play.");
268+ okBox(0, "Nibbles message", "The highscore table is not available during play.");
269269 return;
270270 }
271271
@@ -781,7 +781,7 @@ void nibblesPlay(void) · 509 unmodified lines
781781 {
782782 if (editor.NI_Play)
783783 {
784− if (okBox(2, "Nibbles request", "Restart the current game of Nibbles?") != 1)
784+ if (okBox(2, "Nibbles request", "Restart current game of Nibbles?") != 1)
785785 return;
786786 }
787787
src/ft2_pattern_draw.c+1−1
@@ -307,7 +307,7 @@ static void writePatternBlockMark(int32_t currRow, uint32_t rowHeight, const pat · 306 unmodified lines
307307
308308 static void drawChannelNumbering(uint16_t yPos)
309309 {
310−#define CH_NUM_XPOS 29
310+#define CH_NUM_XPOS 30
311311
312312 uint16_t xPos = CH_NUM_XPOS;
313313 int32_t ch = editor.ui.channelOffset + 1;
src/ft2_pattern_ed.c+13−13
@@ -183,10 +183,10 @@ void drawAdvEdit(void) · 182 unmodified lines
183183 textOutShadow( 4, 126, PAL_FORGRND, PAL_DSKTOP2, "New number");
184184 textOutShadow(129, 96, PAL_FORGRND, PAL_DSKTOP2, "Masking enable");
185185 textOutShadow(114, 109, PAL_FORGRND, PAL_DSKTOP2, "Note");
186− textOutShadow(114, 121, PAL_FORGRND, PAL_DSKTOP2, "Instrument number");
187− textOutShadow(114, 134, PAL_FORGRND, PAL_DSKTOP2, "Volume column");
188− textOutShadow(114, 147, PAL_FORGRND, PAL_DSKTOP2, "Effect digit 1");
189− textOutShadow(114, 160, PAL_FORGRND, PAL_DSKTOP2, "Effect digit 2,3");
186+ textOutShadow(114, 122, PAL_FORGRND, PAL_DSKTOP2, "Instrument number");
187+ textOutShadow(114, 135, PAL_FORGRND, PAL_DSKTOP2, "Volume column");
188+ textOutShadow(114, 148, PAL_FORGRND, PAL_DSKTOP2, "Effect digit 1");
189+ textOutShadow(114, 161, PAL_FORGRND, PAL_DSKTOP2, "Effect digit 2,3");
190190
191191 charOutShadow(239, 95, PAL_FORGRND, PAL_DSKTOP2, 'C');
192192 charOutShadow(258, 95, PAL_FORGRND, PAL_DSKTOP2, 'P');
@@ -680,8 +680,8 @@ void patternEditorExtended(void) · 487 unmodified lines
680680
681681 textOutShadow(116, 5, PAL_FORGRND, PAL_DSKTOP2, "Sng.len.");
682682 textOutShadow(116, 19, PAL_FORGRND, PAL_DSKTOP2, "Repst.");
683− textOutShadow(222, 40, PAL_FORGRND, PAL_DSKTOP2, "Ptn.");
684− textOutShadow(305, 40, PAL_FORGRND, PAL_DSKTOP2, "Ln.");
683+ textOutShadow(222, 39, PAL_FORGRND, PAL_DSKTOP2, "Ptn.");
684+ textOutShadow(305, 39, PAL_FORGRND, PAL_DSKTOP2, "Ln.");
685685
686686 editor.ui.instrSwitcherShown = true;
687687 showInstrumentSwitcher();
@@ -2150,12 +2150,12 @@ void drawSongLength(void) · 1462 unmodified lines
21502150 if (editor.ui.extended)
21512151 {
21522152 x = 165;
2153− y = 6;
2153+ y = 5;
21542154 }
21552155 else
21562156 {
21572157 x = 59;
2158− y = 53;
2158+ y = 52;
21592159 }
21602160
21612161 hexOutBg(x, y, PAL_FORGRND, PAL_DESKTOP, (uint8_t)song.len, 2);
@@ -2168,12 +2168,12 @@ void drawSongRepS(void) · 6 unmodified lines
21682168 if (editor.ui.extended)
21692169 {
21702170 x = 165;
2171− y = 20;
2171+ y = 19;
21722172 }
21732173 else
21742174 {
21752175 x = 59;
2176− y = 65;
2176+ y = 64;
21772177 }
21782178
21792179 hexOutBg(x, y, PAL_FORGRND, PAL_DESKTOP, (uint8_t)song.repS, 2);
@@ -2207,8 +2207,8 @@ void drawEditPattern(uint16_t editPattern) · 27 unmodified lines
22072207
22082208 if (editor.ui.extended)
22092209 {
2210− x = 251;
2211− y = 40;
2210+ x = 252;
2211+ y = 39;
22122212 }
22132213 else
22142214 {
@@ -2226,7 +2226,7 @@ void drawPatternLength(uint16_t editPattern) · 11 unmodified lines
22262226 if (editor.ui.extended)
22272227 {
22282228 x = 326;
2229− y = 40;
2229+ y = 39;
22302230 }
22312231 else
22322232 {
src/ft2_pushbuttons.c+14−14
@@ -146,13 +146,13 @@ pushButton_t pushButtons[NUM_PUSHBUTTONS] = · 145 unmodified lines
146146
147147 // ------ ABOUT SCREEN PUSHBUTTONS ------
148148 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp
149− { 5, 153, 59, 16, 0, 0, "Exit", NULL, NULL, exitAboutScreen },
149+ { 4, 153, 59, 16, 0, 0, "Exit", NULL, NULL, exitAboutScreen },
150150
151151 // ------ HELP SCREEN PUSHBUTTONS ------
152152 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp
153153 { 3, 155, 59, 16, 0, 0, "Exit", NULL, NULL, exitHelpScreen },
154− { 611, 2, 18, 13, 1, 2, ARROW_UP_STRING, NULL, helpScrollUp, NULL },
155− { 611, 158, 18, 13, 1, 2, ARROW_DOWN_STRING, NULL, helpScrollDown, NULL },
154+ { 611, 2, 18, 13, 1, 3, ARROW_UP_STRING, NULL, helpScrollUp, NULL },
155+ { 611, 158, 18, 13, 1, 3, ARROW_DOWN_STRING, NULL, helpScrollDown, NULL },
156156
157157 // ------ PATTERN EDITOR PUSHBUTTONS ------
158158 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp
@@ -196,8 +196,8 @@ pushButton_t pushButtons[NUM_PUSHBUTTONS] = · 37 unmodified lines
196196
197197 // ------ SAMPLE EDITOR PUSHBUTTONS ------
198198 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp
199− { 3, 331, 23, 13, 0, 0, ARROW_LEFT_STRING, NULL, scrollSampleDataLeft, NULL },
200− { 606, 331, 23, 13, 0, 0, ARROW_RIGHT_STRING, NULL, scrollSampleDataRight, NULL },
199+ { 3, 331, 23, 13, 1, 3, ARROW_LEFT_STRING, NULL, scrollSampleDataLeft, NULL },
200+ { 606, 331, 23, 13, 1, 3, ARROW_RIGHT_STRING, NULL, scrollSampleDataRight, NULL },
201201 { 38, 356, 18, 13, 1, 4, ARROW_UP_STRING, NULL, sampPlayNoteUp, NULL },
202202 { 38, 368, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, sampPlayNoteDown, NULL },
203203 { 3, 382, 53, 16, 0, 0, "Stop", NULL, NULL, smpEdStop},
@@ -338,10 +338,10 @@ pushButton_t pushButtons[NUM_PUSHBUTTONS] = · 134 unmodified lines
338338 { 113, 155, 93, 16, 0, 0, editor.ui.fullscreenButtonText, NULL, NULL, toggleFullScreen },
339339 { 370, 121, 18, 13, 1, 4, ARROW_UP_STRING, NULL, configQuantizeUp, NULL },
340340 { 387, 121, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, configQuantizeDown, NULL },
341− { 594, 107, 18, 13, 1, 4, ARROW_UP_STRING, NULL, configMIDIChnUp, NULL },
342− { 611, 107, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, configMIDIChnDown, NULL },
343− { 594, 121, 18, 13, 1, 4, ARROW_UP_STRING, NULL, configMIDITransUp, NULL },
344− { 611, 121, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, configMIDITransDown, NULL },
341+ { 594, 106, 18, 13, 1, 4, ARROW_UP_STRING, NULL, configMIDIChnUp, NULL },
342+ { 611, 106, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, configMIDIChnDown, NULL },
343+ { 594, 120, 18, 13, 1, 4, ARROW_UP_STRING, NULL, configMIDITransUp, NULL },
344+ { 611, 120, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, configMIDITransDown, NULL },
345345 { 556, 158, 22, 13, 1, 4, ARROW_LEFT_STRING, NULL, configMIDISensDown, NULL },
346346 { 607, 158, 22, 13, 1, 4, ARROW_RIGHT_STRING, NULL, configMIDISensUp, NULL },
347347
@@ -377,8 +377,8 @@ pushButton_t pushButtons[NUM_PUSHBUTTONS] = · 29 unmodified lines
377377 { 134, 2, 31, 13, 0, 0, "../", NULL, NULL, pbDiskOpParent },
378378 { 134, 16, 31, 12, 0, 0, "/", NULL, NULL, pbDiskOpRoot },
379379 #endif
380− { 335, 2, 18, 13, 0, 0, ARROW_UP_STRING, NULL, pbDiskOpListUp, NULL },
381− { 335, 158, 18, 13, 0, 0, ARROW_DOWN_STRING, NULL, pbDiskOpListDown, NULL },
380+ { 335, 2, 18, 13, 1, 3, ARROW_UP_STRING, NULL, pbDiskOpListUp, NULL },
381+ { 335, 158, 18, 13, 1, 3, ARROW_DOWN_STRING, NULL, pbDiskOpListDown, NULL },
382382
383383 // ------ WAV RENDERER PUSHBUTTONS ------
384384 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp
@@ -539,10 +539,10 @@ void handlePushButtonsWhileMouseDown(void) · 154 unmodified lines
539539 {
540540 // button delay stuff
541541 if (mouse.rightButtonPressed)
542− buttonDelay = pushButton->delayFrames / 2;
543− else if (pushButton->preDelay == 2 && (!mouse.firstTimePressingButton && ++tmpCounter >= 20)) // special mode
542+ buttonDelay = pushButton->delayFrames >> 1;
543+ else if (pushButton->preDelay == 2 && (!mouse.firstTimePressingButton && ++tmpCounter >= 50)) // special mode
544544 buttonDelay = 0;
545− else
545+ else
546546 buttonDelay = pushButton->delayFrames;
547547
548548 // main repeat delay
src/ft2_pushbuttons.h+1−1
@@ -342,7 +342,7 @@ enum · 341 unmodified lines
342342 };
343343
344344 // amount of frames to wait
345−#define BUTTON_DOWN_DELAY 16
345+#define BUTTON_DOWN_DELAY 25
346346
347347 // font #1/#2 special characters (used for buttons)
348348 #define ARROW_UP_STRING "\x05"
src/ft2_radiobuttons.c+10−11
@@ -30,12 +30,12 @@ radioButton_t radioButtons[NUM_RADIOBUTTONS] = · 29 unmodified lines
3030
3131 // ------ HELP SCREEN RADIOBUTTONS ------
3232 //x, y, w, group, funcOnUp
33− { 5, 16, 68, RB_GROUP_HELP, rbHelpFeatures },
34− { 5, 31, 59, RB_GROUP_HELP, rbHelpEffects },
35− { 5, 46, 70, RB_GROUP_HELP, rbHelpKeyboard },
36− { 5, 61, 108, RB_GROUP_HELP, rbHelpHowToUseFT2 },
37− { 5, 76, 100, RB_GROUP_HELP, rbHelpFAQ },
38− { 5, 91, 85, RB_GROUP_HELP, rbHelpKnownBugs },
33+ { 5, 18, 69, RB_GROUP_HELP, rbHelpFeatures },
34+ { 5, 34, 60, RB_GROUP_HELP, rbHelpEffects },
35+ { 5, 50, 71, RB_GROUP_HELP, rbHelpKeyboard },
36+ { 5, 66, 109, RB_GROUP_HELP, rbHelpHowToUseFT2 },
37+ { 5, 82, 101, RB_GROUP_HELP, rbHelpFAQ },
38+ { 5, 98, 86, RB_GROUP_HELP, rbHelpKnownBugs },
3939
4040 // ------ NIBBLES SCREEN RADIOBUTTONS ------
4141 //x, y, w, group, funcOnUp
@@ -63,12 +63,11 @@ radioButton_t radioButtons[NUM_RADIOBUTTONS] = · 21 unmodified lines
6363
6464 // ------ CONFIG SCREEN LEFT RADIOBUTTONS ------
6565 //x, y, w, group, funcOnUp
66− { 4, 19, 87, RB_GROUP_CONFIG_SELECT, rbConfigIODevices },
67− { 4, 35, 59, RB_GROUP_CONFIG_SELECT, rbConfigLayout },
68− { 4, 51, 99, RB_GROUP_CONFIG_SELECT, rbConfigMiscellaneous },
69−
66+ { 5, 18, 85, RB_GROUP_CONFIG_SELECT, rbConfigIODevices },
67+ { 5, 34, 57, RB_GROUP_CONFIG_SELECT, rbConfigLayout },
68+ { 5, 50, 97, RB_GROUP_CONFIG_SELECT, rbConfigMiscellaneous },
7069 #ifdef HAS_MIDI
71− { 4, 67, 74, RB_GROUP_CONFIG_SELECT, rbConfigMidiInput },
70+ { 5, 66, 72, RB_GROUP_CONFIG_SELECT, rbConfigMidiInput },
7271 #endif
7372
7473 // ------ CONFIG AUDIO ------
src/ft2_replayer.c+13−12
@@ -26,8 +26,7 @@ · 25 unmodified lines
2626 */
2727
2828 static bool bxxOverflow;
29−static uint16_t oldPeriod;
30−static uint32_t oldRate, frequenceDivFactor, frequenceMulFactor;
29+static int32_t oldPeriod, oldRate, frequenceDivFactor, frequenceMulFactor;
3130 static tonTyp nilPatternLine;
3231
3332 // globally accessed
@@ -230,6 +229,8 @@ void setFrqTab(bool linear) · 196 unmodified lines
230229 note2Period = amigaPeriods;
231230 }
232231
232+ resetCachedFrequencyVars();
233+
233234 // update "frequency table" radiobutton, if it's shown
234235 if (editor.ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES)
235236 setConfigIORadioButtonStates();
@@ -367,7 +368,7 @@ uint32_t getFrequenceValue(uint16_t period) · 131 unmodified lines
367368 indexQuotient = index / 768;
368369 indexRemainder = index % 768;
369370
370− rate = ((uint64_t)logTab[indexRemainder] * frequenceMulFactor) >> LOG_TABLE_BITS;
371+ rate = ((int64_t)logTab[indexRemainder] * frequenceMulFactor) >> LOG_TABLE_BITS;
371372
372373 shift = (14 - indexQuotient) & 0x1F;
373374 if (shift != 0)
@@ -384,13 +385,13 @@ uint32_t getFrequenceValue(uint16_t period) · 10 unmodified lines
384385 return rate;
385386 }
386387
387−void resetOldRates(void)
388+void resetCachedFrequencyVars(void)
388389 {
389− oldPeriod = 0;
390+ oldPeriod = -1;
390391 oldRate = 0;
391392
392− resetOldScopeRates();
393− resetOldRevFreqs();
393+ resetCachedScopeVars();
394+ resetCachedMixerVars();
394395 }
395396
396397 static void startTone(uint8_t ton, uint8_t effTyp, uint8_t eff, stmTyp *ch)
@@ -1320,17 +1321,17 @@ static void fixaEnvelopeVibrato(stmTyp *ch) · 923 unmodified lines
13201321 ** Also, vol envelope range is now 0..16384 instead of being shifted to 0..64
13211322 */
13221323
1323− uint32_t vol1 = song.globVol * ch->outVol * ch->fadeOutAmp; // 0..64 * 0..64 * 0..32768 = 0..134217728
1324− uint32_t vol2 = envVal << 7; // 0..16384 * 2^7 = 0..2097152
1324+ int32_t vol1 = song.globVol * ch->outVol * ch->fadeOutAmp; // 0..64 * 0..64 * 0..32768 = 0..134217728
1325+ int32_t vol2 = envVal << 7; // 0..16384 * 2^7 = 0..2097152
13251326
1326− vol = ((uint64_t)vol1 * vol2) >> 32; // 0..65536
1327+ vol = ((int64_t)vol1 * vol2) >> 32; // 0..65536
13271328
13281329 ch->status |= IS_Vol;
13291330 }
13301331 else
13311332 {
13321333 // calculate with four times more precision (finalVol = 0..65535)
1333− vol = (song.globVol * ch->outVol * ch->fadeOutAmp) >> 11; // 0..64 * 0..64 * 0..32768 = 0..65536
1334+ vol = ((song.globVol * ch->outVol * ch->fadeOutAmp) + (1 << 10)) >> 11; // 0..64 * 0..64 * 0..32768 -> 0..65536 (rounded)
13341335 }
13351336
13361337 if (vol > 65535)
@@ -3058,7 +3059,7 @@ void stopVoices(void) · 1721 unmodified lines
30583059
30593060 stopAllScopes();
30603061 resetAudioDither();
3061− resetOldRates();
3062+ resetCachedFrequencyVars();
30623063
30633064 // wait for scope thread to finish, so that we know pointers aren't deprecated
30643065 while (editor.scopeThreadMutex);
src/ft2_replayer.h+1−1
@@ -241,7 +241,7 @@ void fixSongName(void); // removes spaces from right side of song name · 240 unmodified lines
241241 void fixSampleName(int16_t nr); // removes spaces from right side of ins/smp names
242242
243243 void calcReplayRate(int32_t rate);
244−void resetOldRates(void);
244+void resetCachedFrequencyVars(void);
245245 void tuneSample(sampleTyp *s, int32_t midCFreq);
246246 uint32_t getFrequenceValue(uint16_t period);
247247
src/ft2_sample_ed.c+22−33
@@ -1013,7 +1013,7 @@ static void writeWaveform(void) · 1012 unmodified lines
10131013
10141014 viewSizeSamples = smpEd_ViewSize;
10151015 if (s->typ & 16)
1016− viewSizeSamples /= 2;
1016+ viewSizeSamples >>= 1;
10171017
10181018 if (viewSizeSamples <= SAMPLE_AREA_WIDTH)
10191019 {
@@ -1319,17 +1319,12 @@ void scrollSampleDataLeft(void) · 299 unmodified lines
13191319 return;
13201320
13211321 if (mouse.rightButtonPressed)
1322− {
13231322 scrollAmount = smpEd_ViewSize / 14; // rounded from 16 (70Hz)
1324− if (scrollAmount < 1)
1325− scrollAmount = 1;
1326− }
13271323 else
1328− {
13291324 scrollAmount = smpEd_ViewSize / 27; // rounded from 32 (70Hz)
1330− if (scrollAmount < 1)
1331− scrollAmount = 1;
1332− }
1325+
1326+ if (scrollAmount < 1)
1327+ scrollAmount = 1;
13331328
13341329 smpEd_ScrPos -= scrollAmount;
13351330 if (smpEd_ScrPos < 0)
@@ -1351,17 +1346,12 @@ void scrollSampleDataRight(void) · 15 unmodified lines
13511346 return;
13521347
13531348 if (mouse.rightButtonPressed)
1354− {
13551349 scrollAmount = smpEd_ViewSize / 14; // was 16 (70Hz->60Hz)
1356− if (scrollAmount < 1)
1357− scrollAmount = 1;
1358− }
13591350 else
1360− {
13611351 scrollAmount = smpEd_ViewSize / 27; // was 32 (70Hz->60Hz)
1362− if (scrollAmount < 1)
1363− scrollAmount = 1;
1364− }
1352+
1353+ if (scrollAmount < 1)
1354+ scrollAmount = 1;
13651355
13661356 smpEd_ScrPos += scrollAmount;
13671357 if (smpEd_ScrPos+smpEd_ViewSize > sampleLen)
@@ -2694,18 +2684,15 @@ void sampMin(void) · 1326 unmodified lines
26942684 if (s == NULL || s->pek == NULL || s->len <= 0)
26952685 return;
26962686
2697− bool hasLoop = s->typ & 3;
2698− int32_t loopEnd = s->repS + s->repL;
2687+ if (okBox(1, "System request", "Minimize sample?") != 1)
2688+ return;
26992689
2700− if (!hasLoop || (loopEnd >= s->len || loopEnd == 0))
2701− {
2702− okBox(0, "System message", "Sample is already minimized.");
2703− }
2704− else
2690+ bool hasLoop = s->typ & 3;
2691+ if (hasLoop && s->len > s->repS+s->repL && s->repL < s->len)
27052692 {
27062693 lockMixerCallback();
27072694
2708− s->len = loopEnd;
2695+ s->len = s->repS + s->repL;
27092696
27102697 newPtr = (int8_t *)realloc(s->origPek, s->len + LOOP_FIX_LEN);
27112698 if (newPtr != NULL)
@@ -2714,6 +2701,8 @@ void sampMin(void) · 2 unmodified lines
27142701 s->pek = s->origPek + SMP_DAT_OFFSET;
27152702 }
27162703
2704+ // Note: we don't need to make a call to fixSample()
2705+
27172706 unlockMixerCallback();
27182707
27192708 updateSampleEditorSample();
@@ -2897,9 +2886,9 @@ void showSampleEditor(void) · 177 unmodified lines
28972886 textOutShadow(371, 369, PAL_FORGRND, PAL_DSKTOP2, "Forward");
28982887 textOutShadow(371, 386, PAL_FORGRND, PAL_DSKTOP2, "Pingpong");
28992888 textOutShadow(446, 369, PAL_FORGRND, PAL_DSKTOP2, "8-bit");
2900− textOutShadow(445, 385, PAL_FORGRND, PAL_DSKTOP2, "16-bit");
2901− textOutShadow(488, 349, PAL_FORGRND, PAL_DSKTOP2, "Display");
2902− textOutShadow(488, 361, PAL_FORGRND, PAL_DSKTOP2, "Length");
2889+ textOutShadow(445, 384, PAL_FORGRND, PAL_DSKTOP2, "16-bit");
2890+ textOutShadow(488, 350, PAL_FORGRND, PAL_DSKTOP2, "Display");
2891+ textOutShadow(488, 362, PAL_FORGRND, PAL_DSKTOP2, "Length");
29032892 textOutShadow(488, 375, PAL_FORGRND, PAL_DSKTOP2, "Repeat");
29042893 textOutShadow(488, 387, PAL_FORGRND, PAL_DSKTOP2, "Replen.");
29052894
@@ -3233,7 +3222,7 @@ static void editSampleData(bool mouseButtonHeld) · 327 unmodified lines
32333222 int32_t y = lastDrawY - vl;
32343223 uint32_t x = lastDrawX - p;
32353224
3236− uint32_t xMul = 0xFFFFFFFF;
3225+ int32_t xMul = 0xFFFFFFFF;
32373226 if (x != 0)
32383227 xMul /= x;
32393228
@@ -3276,7 +3265,7 @@ static void editSampleData(bool mouseButtonHeld) · 36 unmodified lines
32763265 int32_t y = lastDrawY - vl;
32773266 uint32_t x = lastDrawX - p;
32783267
3279− uint32_t xMul = 0xFFFFFFFF;
3268+ int32_t xMul = 0xFFFFFFFF;
32803269 if (x != 0)
32813270 xMul /= x;
32823271
@@ -3430,10 +3419,10 @@ void drawSampleEditorExt(void) · 147 unmodified lines
34303419
34313420 textOutShadow( 4, 96, PAL_FORGRND, PAL_DSKTOP2, "Rng.:");
34323421 charOutShadow(91, 95, PAL_FORGRND, PAL_DSKTOP2, '-');
3433− textOutShadow( 4, 109, PAL_FORGRND, PAL_DSKTOP2, "Range size");
3434− textOutShadow( 4, 123, PAL_FORGRND, PAL_DSKTOP2, "Copy buf. size");
3422+ textOutShadow( 4, 110, PAL_FORGRND, PAL_DSKTOP2, "Range size");
3423+ textOutShadow( 4, 124, PAL_FORGRND, PAL_DSKTOP2, "Copy buf. size");
34353424
3436− textOutShadow(162, 95, PAL_FORGRND, PAL_DSKTOP2, "Src.instr.");
3425+ textOutShadow(162, 96, PAL_FORGRND, PAL_DSKTOP2, "Src.instr.");
34373426 textOutShadow(245, 96, PAL_FORGRND, PAL_DSKTOP2, "smp.");
34383427 textOutShadow(162, 109, PAL_FORGRND, PAL_DSKTOP2, "Dest.instr.");
34393428 textOutShadow(245, 109, PAL_FORGRND, PAL_DSKTOP2, "smp.");
src/ft2_sample_ed_features.c+4−4
@@ -121,7 +121,7 @@ static int32_t SDLCALL resampleThread(void *ptr) · 120 unmodified lines
121121 p1 = s->pek;
122122
123123 // don't use the potentially clamped newLen value here
124− delta64 = ((uint64_t)s->len << 32) / (uint64_t)(s->len * dLenMul); // 32.32 fixed point delta
124+ delta64 = ((int64_t)s->len << 32) / (int64_t)(s->len * dLenMul); // 32.32 fixed point delta
125125
126126 posFrac64 = 0; // 32.32 fixed point position.fraction
127127
@@ -660,8 +660,8 @@ static void drawEchoBox(void) · 532 unmodified lines
660660 hLine(x + 2, y + h - 3, w - 4, PAL_BUTTON1);
661661
662662 textOutShadow(177, 226, PAL_FORGRND, PAL_BUTTON2, "Number of echoes");
663− textOutShadow(177, 239, PAL_FORGRND, PAL_BUTTON2, "Echo distance");
664− textOutShadow(177, 253, PAL_FORGRND, PAL_BUTTON2, "Fade out");
663+ textOutShadow(177, 240, PAL_FORGRND, PAL_BUTTON2, "Echo distance");
664+ textOutShadow(177, 254, PAL_FORGRND, PAL_BUTTON2, "Fade out");
665665 textOutShadow(192, 270, PAL_FORGRND, PAL_BUTTON2, "Add memory to sample");
666666
667667 assert(echo_nEcho <= 1024);
@@ -1510,7 +1510,7 @@ static void drawSampleVolumeBox(void) · 842 unmodified lines
15101510 hLine(x + 2, y + h - 3, w - 4, PAL_BUTTON1);
15111511
15121512 textOutShadow(172, 236, PAL_FORGRND, PAL_BUTTON2, "Start volume");
1513− textOutShadow(172, 249, PAL_FORGRND, PAL_BUTTON2, "End volume");
1513+ textOutShadow(172, 250, PAL_FORGRND, PAL_BUTTON2, "End volume");
15141514 charOutShadow(282, 236, PAL_FORGRND, PAL_BUTTON2, '%');
15151515 charOutShadow(282, 250, PAL_FORGRND, PAL_BUTTON2, '%');
15161516
src/ft2_scopes.c+6−5
@@ -48,9 +48,9 @@ static uint8_t *scopeMuteBMP_Ptrs[16]; · 47 unmodified lines
4848
4949 lastChInstr_t lastChInstr[MAX_VOICES]; // global
5050
51−void resetOldScopeRates(void)
51+void resetCachedScopeVars(void)
5252 {
53− oldVoiceDelta = 0;
53+ oldVoiceDelta = 0xFFFFFFFF;
5454 oldSFrq = 0;
5555 }
5656
@@ -126,6 +126,7 @@ static void setChannel(int32_t nr, bool on) · 69 unmodified lines
126126
127127 static void drawScopeNumber(uint16_t scopeXOffs, uint16_t scopeYOffs, uint8_t channel, bool outline)
128128 {
129+ scopeXOffs++;
129130 scopeYOffs++;
130131 channel++;
131132
@@ -313,7 +314,7 @@ bool testScopesMouseDown(void) · 181 unmodified lines
313314 return false;
314315 }
315316
316−static void scopeTrigger(uint8_t ch, sampleTyp *s, int32_t playOffset)
317+static void scopeTrigger(int32_t ch, sampleTyp *s, int32_t playOffset)
317318 {
318319 bool sampleIs16Bit;
319320 uint8_t loopType;
@@ -522,7 +523,7 @@ void drawScopes(void) · 202 unmodified lines
522523
523524 // draw rec. symbol (if enabled)
524525 if (config.multiRecChn[i])
525− blit(scopeXOffs, scopeYOffs + 31, bmp.scopeRec, 13, 4);
526+ blit(scopeXOffs + 1, scopeYOffs + 31, bmp.scopeRec, 13, 4);
526527
527528 scopeXOffs += scopeDrawLen + 3; // align x to next scope
528529 }
@@ -572,7 +573,7 @@ void handleScopesFromChQueue(chSyncData_t *chSyncData, uint8_t *scopeUpdateStatu · 43 unmodified lines
572573 if (instr[ch->instrNr] != NULL)
573574 {
574575 smpPtr = &instr[ch->instrNr]->samp[ch->sampleNr];
575− scopeTrigger((uint8_t)i, smpPtr, ch->smpStartPos);
576+ scopeTrigger(i, smpPtr, ch->smpStartPos);
576577
577578 // set stuff used by Smp. Ed. for sampling position line
578579
src/ft2_scopes.h+1−1
@@ -4,7 +4,7 @@ · 3 unmodified lines
44 #include <stdbool.h>
55 #include "ft2_header.h"
66
7−void resetOldScopeRates(void);
7+void resetCachedScopeVars(void);
88 int32_t getSamplePosition(uint8_t ch);
99 void stopAllScopes(void);
1010 void refreshScopes(void);

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