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
9 9
10// ported from original FT2 code10// ported from original FT2 code
11 11
12#define NUM_STARS 51212#define NUM_STARS 1000
13#define ABOUT_SCREEN_W 62613#define ABOUT_SCREEN_W 626
14#define ABOUT_SCREEN_H 16714#define ABOUT_SCREEN_H 167
15#define ABOUT_LOGO_W 44915#define ABOUT_LOGO_W 449
@@ -53,7 +53,7 @@ static inline int32_t random32(int32_t l) // Turbo Pascal Random() implementatio · 37 unmodified lines
53 randSeed *= 134775813;53 randSeed *= 134775813;
54 randSeed += 1;54 randSeed += 1;
55 55
56 r = (int32_t)(((int64_t)randSeed * l) >> 32);56 r = ((int64_t)randSeed * l) >> 32;
57 return r;57 return r;
58}58}
59 59
@@ -68,13 +68,13 @@ static void fixaMatris(rotate_t a, matrix_t *mat) · 8 unmodified lines
68 sc = sin32767[a.z >> 6];68 sc = sin32767[a.z >> 6];
69 cc = cos32767[a.z >> 6];69 cc = cos32767[a.z >> 6];
70 70
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));
72 mat->y.x = (sa * cb) >> 16;72 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);
74 74
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);
76 mat->y.y = (ca * cb) >> 16;76 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));
78 78
79 mat->x.z = (cb * sc) >> 16;79 mat->x.z = (cb * sc) >> 16;
80 mat->y.z = 0 - (sb >> 1);80 mat->y.z = 0 - (sb >> 1);
@@ -167,8 +167,8 @@ static void aboutInit(void) · 86 unmodified lines
167static void realStars(void)167static void realStars(void)
168{168{
169 uint8_t col;169 uint8_t col;
170 int16_t x, y, z, xx, xy, xz, yx, yy, yz, zx, zy, zz;170 int16_t z, xx, xy, xz, yx, yy, yz, zx, zy, zz;
171 int32_t screenBufferPos;171 int32_t x, y, zMul, screenBufferPos;
172 vector_t *star;172 vector_t *star;
173 173
174 xx = starmat.x.x; xy = starmat.x.y; xz = starmat.x.z;174 xx = starmat.x.x; xy = starmat.x.y; xz = starmat.x.z;
@@ -190,26 +190,27 @@ static void realStars(void) · 15 unmodified lines
190 star = &starcrd[i];190 star = &starcrd[i];
191 star->z += hastighet;191 star->z += hastighet;
192 192
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;
194 z += 9000;194 z += 9000;
195 if (z <= 100)195 if (z <= 100) continue;
196 continue;196 zMul = 0xFFFFFFFF / z; // 8bitbubsy: optimization
197 197
198 y = ((xy * star->x) >> 16) + ((yy * star->y) >> 16) + ((zy * star->z) >> 16);198 y = ((xy * star->x) + (yy * star->y) + (zy * star->z)) >> (16-7);
199 y = (int16_t)((y << 7) / z) + 84;199 y = ((int64_t)y * zMul) >> 32;
200 if ((uint16_t)y >= 173-6)200 y += (2+ABOUT_SCREEN_H)/2;
201 continue;201 if ((uint32_t)y > 2+ABOUT_SCREEN_H) continue;
202 202
203 x = ((xx * star->x) >> 16) + ((yx * star->y) >> 16) + ((zx * star->z) >> 16);203 x = ((xx * star->x) + (yx * star->y) + (zx * star->z)) >> (16-7);
204 x = (int16_t)((((x >> 2) + x) << 7) / z) + (320-8);204 x += x >> 2; // x *= 1.25
205 if ((uint16_t)x >= 640-16)205 x = ((int64_t)x * zMul) >> 32;
206 continue;206 x += (2+ABOUT_SCREEN_W)/2;
207 if ((uint32_t)x > 2+ABOUT_SCREEN_W) continue;
207 208
208 // render star pixel if the pixel under it is the background209 // 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;
210 if ((video.frameBuffer[screenBufferPos] >> 24) == PAL_BCKGRND)211 if ((video.frameBuffer[screenBufferPos] >> 24) == PAL_BCKGRND)
211 {212 {
212 col = ((uint8_t)~(z >> 8) >> 3) - (22 - 8);213 col = ((uint8_t)~(z >> 8) >> 3) - 14;
213 if (col < 24)214 if (col < 24)
214 {215 {
215 video.frameBuffer[screenBufferPos] = video.palette[starColConv[col]] & 0x00FFFFFF;216 video.frameBuffer[screenBufferPos] = video.palette[starColConv[col]] & 0x00FFFFFF;
src/ft2_audio.c+7−7
@@ -20,8 +20,8 @@ · 19 unmodified lines
20static int8_t pmpCountDiv, pmpChannels = 2;20static int8_t pmpCountDiv, pmpChannels = 2;
21static uint16_t smpBuffSize;21static uint16_t smpBuffSize;
22static int32_t masterVol, oldAudioFreq, speedVal, pmpLeft, randSeed = INITIAL_DITHER_SEED;22static int32_t masterVol, oldAudioFreq, speedVal, pmpLeft, randSeed = INITIAL_DITHER_SEED;
23static int32_t prngStateL, prngStateR;23static int32_t prngStateL, prngStateR, oldPeriod, oldSFrq, oldSFrqRev;
24static uint32_t tickTimeLen, tickTimeLenFrac, oldSFrq, oldSFrqRev = 0xFFFFFFFF;24static uint32_t tickTimeLen, tickTimeLenFrac;
25static float fAudioAmpMul;25static float fAudioAmpMul;
26static voice_t voice[MAX_VOICES * 2];26static voice_t voice[MAX_VOICES * 2];
27static void (*sendAudSamplesFunc)(uint8_t *, uint32_t, uint8_t); // "send mixed samples" routines27static void (*sendAudSamplesFunc)(uint8_t *, uint32_t, uint8_t); // "send mixed samples" routines
@@ -31,8 +31,9 @@ chSyncData_t *chSyncEntry; · 3 unmodified lines
31 31
32volatile bool pattQueueReading, pattQueueClearing, chQueueReading, chQueueClearing;32volatile bool pattQueueReading, pattQueueClearing, chQueueReading, chQueueClearing;
33 33
34void resetOldRevFreqs(void)34void resetCachedMixerVars(void)
35{35{
36 oldPeriod = -1;
36 oldSFrq = 0;37 oldSFrq = 0;
37 oldSFrqRev = 0xFFFFFFFF;38 oldSFrqRev = 0xFFFFFFFF;
38}39}
@@ -369,17 +370,16 @@ void mix_UpdateChannelVolPanFrq(void) · 330 unmodified lines
369 // frequency change370 // frequency change
370 if (status & IS_Period)371 if (status & IS_Period)
371 {372 {
372 v->SFrq = getFrequenceValue(ch->finalPeriod);373 if (ch->finalPeriod != oldPeriod) // this value will very often be the same as before
373
374 if (v->SFrq != oldSFrq) // this value will very often be the same as before
375 {374 {
376 oldSFrq = v->SFrq;375 oldSFrq = getFrequenceValue(ch->finalPeriod);
377 376
378 oldSFrqRev = 0xFFFFFFFF;377 oldSFrqRev = 0xFFFFFFFF;
379 if (oldSFrq != 0)378 if (oldSFrq != 0)
380 oldSFrqRev /= oldSFrq;379 oldSFrqRev /= oldSFrq;
381 }380 }
382 381
382 v->SFrq = oldSFrq;
383 v->SFrqRev = oldSFrqRev;383 v->SFrqRev = oldSFrqRev;
384 }384 }
385 385
src/ft2_audio.h+5−3
@@ -45,8 +45,10 @@ typedef struct · 44 unmodified lines
45 bool backwards, isFadeOutVoice;45 bool backwards, isFadeOutVoice;
46 uint8_t SPan;46 uint8_t SPan;
47 uint16_t SVol;47 uint16_t SVol;
48 int32_t SLVol1, SRVol1, SLVol2, SRVol2, SLVolIP, SRVolIP, SVolIPLen, SPos, SLen, SRepS, SRepL;48 int32_t SLVol1, SRVol1, SLVol2, SRVol2, SLVolIP, SRVolIP, SVolIPLen;
49 uint32_t SPosDec, SFrq, SFrqRev;49 int32_t SPos, SLen, SRepS, SRepL, SFrq, SFrqRev;
50 uint32_t SPosDec;
51
50 void (*mixRoutine)(void *, int32_t); // function pointer to mix routine52 void (*mixRoutine)(void *, int32_t); // function pointer to mix routine
51} voice_t;53} voice_t;
52 54
@@ -79,7 +81,7 @@ extern chSyncData_t *chSyncEntry; · 26 unmodified lines
79 81
80extern volatile bool pattQueueReading, pattQueueClearing, chQueueReading, chQueueClearing;82extern volatile bool pattQueueReading, pattQueueClearing, chQueueReading, chQueueClearing;
81 83
82void resetOldRevFreqs(void);84void resetCachedMixerVars(void);
83int32_t pattQueueReadSize(void);85int32_t pattQueueReadSize(void);
84int32_t pattQueueWriteSize(void);86int32_t pattQueueWriteSize(void);
85bool pattQueuePush(pattSyncData_t t);87bool pattQueuePush(pattSyncData_t t);
src/ft2_checkboxes.c+1−1
@@ -79,7 +79,7 @@ checkBox_t checkBoxes[NUM_CHECKBOXES] = · 78 unmodified lines
79 79
80 // ------ CONFIG CHECKBOXES ------80 // ------ CONFIG CHECKBOXES ------
81 //x, y, w, h, funcOnUp81 //x, y, w, h, funcOnUp
82 { 3, 91, 76, 12, cbToggleAutoSaveConfig },82 { 3, 91, 77, 12, cbToggleAutoSaveConfig },
83 { 389, 132, 90, 12, cbConfigInterpolation },83 { 389, 132, 90, 12, cbConfigInterpolation },
84 { 389, 145, 107, 12, cbConfigVolRamp },84 { 389, 145, 107, 12, cbConfigVolRamp },
85 { 389, 158 , 84, 12, cbConfigDither },85 { 389, 158 , 84, 12, cbConfigDither },
src/ft2_config.c+6−6
@@ -1106,14 +1106,14 @@ void showConfigScreen(void) · 1105 unmodified lines
1106 showPushButton(PB_CONFIG_SAVE);1106 showPushButton(PB_CONFIG_SAVE);
1107 showPushButton(PB_CONFIG_EXIT);1107 showPushButton(PB_CONFIG_EXIT);
1108 1108
1109 textOutShadow(5, 4, PAL_FORGRND, PAL_DSKTOP2, "Configuration:");1109 textOutShadow(4, 4, PAL_FORGRND, PAL_DSKTOP2, "Configuration:");
1110 textOutShadow(22, 20, PAL_FORGRND, PAL_DSKTOP2, "I/O devices");1110 textOutShadow(21, 19, PAL_FORGRND, PAL_DSKTOP2, "I/O devices");
1111 textOutShadow(22, 36, PAL_FORGRND, PAL_DSKTOP2, "Layout");1111 textOutShadow(21, 35, PAL_FORGRND, PAL_DSKTOP2, "Layout");
1112 textOutShadow(22, 52, PAL_FORGRND, PAL_DSKTOP2, "Miscellaneous");1112 textOutShadow(21, 51, PAL_FORGRND, PAL_DSKTOP2, "Miscellaneous");
1113#ifdef HAS_MIDI1113#ifdef HAS_MIDI
1114 textOutShadow(22, 68, PAL_FORGRND, PAL_DSKTOP2, "MIDI input");1114 textOutShadow(21, 67, PAL_FORGRND, PAL_DSKTOP2, "MIDI input");
1115#endif1115#endif
1116 textOutShadow(19, 92, PAL_FORGRND, PAL_DSKTOP2, "Auto save");1116 textOutShadow(20, 93, PAL_FORGRND, PAL_DSKTOP2, "Auto save");
1117 1117
1118 switch (editor.currConfigScreen)1118 switch (editor.currConfigScreen)
1119 {1119 {
src/ft2_diskop.c+1−1
@@ -104,7 +104,7 @@ int32_t getFileSize(UNICHAR *fileNameU) // returning -1 = filesize over 2GB · 103 unmodified lines
104 if (stat(fileNameU, &st) != 0)104 if (stat(fileNameU, &st) != 0)
105 return 0;105 return 0;
106 106
107 fSize = (int64_t)(st.st_size);107 fSize = (int64_t)st.st_size;
108#endif108#endif
109 if (fSize < 0)109 if (fSize < 0)
110 fSize = 0;110 fSize = 0;
src/ft2_header.h+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
12#endif12#endif
13#include "ft2_replayer.h"13#include "ft2_replayer.h"
14 14
15#define PROG_VER_STR "1.14"15#define PROG_VER_STR "1.15"
16 16
17// do NOT change these! It will only mess things up...17// do NOT change these! It will only mess things up...
18 18
src/ft2_help.c+7−7
@@ -417,13 +417,13 @@ void showHelpScreen(void) · 416 unmodified lines
417 417
418 showScrollBar(SB_HELP_SCROLL);418 showScrollBar(SB_HELP_SCROLL);
419 419
420 textOutShadow(4, 3, PAL_FORGRND, PAL_DSKTOP2, "Subjects:");420 textOutShadow(4, 4, PAL_FORGRND, PAL_DSKTOP2, "Subjects:");
421 textOutShadow(20, 17, PAL_FORGRND, PAL_DSKTOP2, "Features");421 textOutShadow(21, 19, PAL_FORGRND, PAL_DSKTOP2, "Features");
422 textOutShadow(20, 32, PAL_FORGRND, PAL_DSKTOP2, "Effects");422 textOutShadow(21, 35, PAL_FORGRND, PAL_DSKTOP2, "Effects");
423 textOutShadow(20, 47, PAL_FORGRND, PAL_DSKTOP2, "Keyboard");423 textOutShadow(21, 51, PAL_FORGRND, PAL_DSKTOP2, "Keyboard");
424 textOutShadow(20, 62, PAL_FORGRND, PAL_DSKTOP2, "How to use FT2");424 textOutShadow(21, 67, PAL_FORGRND, PAL_DSKTOP2, "How to use FT2");
425 textOutShadow(20, 77, PAL_FORGRND, PAL_DSKTOP2, "Problems/FAQ");425 textOutShadow(21, 83, PAL_FORGRND, PAL_DSKTOP2, "Problems/FAQ");
426 textOutShadow(20, 92, PAL_FORGRND, PAL_DSKTOP2, "Known bugs");426 textOutShadow(21, 99, PAL_FORGRND, PAL_DSKTOP2, "Known bugs");
427 427
428 writeHelp();428 writeHelp();
429}429}
src/ft2_inst_ed.c+17−17
@@ -397,7 +397,7 @@ static void drawVolEnvRepS(void) · 396 unmodified lines
397 instrTyp *ins = getCurDispInstr();397 instrTyp *ins = getCurDispInstr();
398 398
399 sprintf(str, "%02d", ins->envVRepS);399 sprintf(str, "%02d", ins->envVRepS);
400 textOutFixed(382, 234, PAL_FORGRND, PAL_DESKTOP, str);400 textOutFixed(382, 233, PAL_FORGRND, PAL_DESKTOP, str);
401}401}
402 402
403static void drawVolEnvRepE(void)403static void drawVolEnvRepE(void)
@@ -415,7 +415,7 @@ static void drawPanEnvSus(void) · 11 unmodified lines
415 instrTyp *ins = getCurDispInstr();415 instrTyp *ins = getCurDispInstr();
416 416
417 sprintf(str, "%02d", ins->envPSust);417 sprintf(str, "%02d", ins->envPSust);
418 textOutFixed(382, 294, PAL_FORGRND, PAL_DESKTOP, str);418 textOutFixed(382, 293, PAL_FORGRND, PAL_DESKTOP, str);
419}419}
420 420
421static void drawPanEnvRepS(void)421static void drawPanEnvRepS(void)
@@ -424,7 +424,7 @@ static void drawPanEnvRepS(void) · 2 unmodified lines
424 instrTyp *ins = getCurDispInstr();424 instrTyp *ins = getCurDispInstr();
425 425
426 sprintf(str, "%02d", ins->envPRepS);426 sprintf(str, "%02d", ins->envPRepS);
427 textOutFixed(382, 321, PAL_FORGRND, PAL_DESKTOP, str);427 textOutFixed(382, 320, PAL_FORGRND, PAL_DESKTOP, str);
428}428}
429 429
430static void drawPanEnvRepE(void)430static void drawPanEnvRepE(void)
@@ -433,7 +433,7 @@ static void drawPanEnvRepE(void) · 2 unmodified lines
433 instrTyp *ins = getCurDispInstr();433 instrTyp *ins = getCurDispInstr();
434 434
435 sprintf(str, "%02d", ins->envPRepE);435 sprintf(str, "%02d", ins->envPRepE);
436 textOutFixed(382, 335, PAL_FORGRND, PAL_DESKTOP, str);436 textOutFixed(382, 334, PAL_FORGRND, PAL_DESKTOP, str);
437}437}
438 438
439static void drawVolume(void)439static void drawVolume(void)
@@ -445,7 +445,7 @@ static void drawVolume(void) · 5 unmodified lines
445 else445 else
446 s = &instr[editor.curInstr]->samp[editor.curSmp];446 s = &instr[editor.curInstr]->samp[editor.curSmp];
447 447
448 hexOutBg(505, 178, PAL_FORGRND, PAL_DESKTOP, s->vol, 2);448 hexOutBg(505, 177, PAL_FORGRND, PAL_DESKTOP, s->vol, 2);
449}449}
450 450
451static void drawPanning(void)451static void drawPanning(void)
@@ -457,7 +457,7 @@ static void drawPanning(void) · 5 unmodified lines
457 else457 else
458 s = &instr[editor.curInstr]->samp[editor.curSmp];458 s = &instr[editor.curInstr]->samp[editor.curSmp];
459 459
460 hexOutBg(505, 192, PAL_FORGRND, PAL_DESKTOP, s->pan, 2);460 hexOutBg(505, 191, PAL_FORGRND, PAL_DESKTOP, s->pan, 2);
461}461}
462 462
463static void drawFineTune(void)463static void drawFineTune(void)
@@ -2262,17 +2262,17 @@ void showInstEditor(void) · 1798 unmodified lines
2262 2262
2263 textOutShadow(20, 176, PAL_FORGRND, PAL_DSKTOP2, "Volume envelope:");2263 textOutShadow(20, 176, PAL_FORGRND, PAL_DSKTOP2, "Volume envelope:");
2264 textOutShadow(153, 176, PAL_FORGRND, PAL_DSKTOP2, "Predef.");2264 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:");
2266 textOutShadow(342, 206, PAL_FORGRND, PAL_DSKTOP2, "Point");2266 textOutShadow(342, 206, PAL_FORGRND, PAL_DSKTOP2, "Point");
2267 textOutShadow(358, 219, PAL_FORGRND, PAL_DSKTOP2, "Env.loop:");2267 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");
2269 textOutShadow(342, 247, PAL_FORGRND, PAL_DSKTOP2, "End");2269 textOutShadow(342, 247, PAL_FORGRND, PAL_DSKTOP2, "End");
2270 textOutShadow(20, 263, PAL_FORGRND, PAL_DSKTOP2, "Panning envelope:");2270 textOutShadow(20, 263, PAL_FORGRND, PAL_DSKTOP2, "Panning envelope:");
2271 textOutShadow(152, 263, PAL_FORGRND, PAL_DSKTOP2, "Predef.");2271 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:");
2273 textOutShadow(342, 293, PAL_FORGRND, PAL_DSKTOP2, "Point");2273 textOutShadow(342, 293, PAL_FORGRND, PAL_DSKTOP2, "Point");
2274 textOutShadow(358, 306, PAL_FORGRND, PAL_DSKTOP2, "Env.loop:");2274 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");
2276 textOutShadow(342, 334, PAL_FORGRND, PAL_DSKTOP2, "End");2276 textOutShadow(342, 334, PAL_FORGRND, PAL_DSKTOP2, "End");
2277 textOutShadow(443, 177, PAL_FORGRND, PAL_DSKTOP2, "Volume");2277 textOutShadow(443, 177, PAL_FORGRND, PAL_DSKTOP2, "Volume");
2278 textOutShadow(443, 191, PAL_FORGRND, PAL_DSKTOP2, "Panning");2278 textOutShadow(443, 191, PAL_FORGRND, PAL_DSKTOP2, "Panning");
@@ -2609,8 +2609,8 @@ void drawInstEditorExt(void) · 330 unmodified lines
2609 textOutShadow(4, 96, PAL_FORGRND, PAL_DSKTOP2, "Instrument Editor Extension:");2609 textOutShadow(4, 96, PAL_FORGRND, PAL_DSKTOP2, "Instrument Editor Extension:");
2610 textOutShadow(20, 114, PAL_FORGRND, PAL_DSKTOP2, "Instrument MIDI enable");2610 textOutShadow(20, 114, PAL_FORGRND, PAL_DSKTOP2, "Instrument MIDI enable");
2611 textOutShadow(189, 114, PAL_FORGRND, PAL_DSKTOP2, "Mute computer");2611 textOutShadow(189, 114, PAL_FORGRND, PAL_DSKTOP2, "Mute computer");
2612 textOutShadow(4, 133, PAL_FORGRND, PAL_DSKTOP2, "MIDI transmit channel");2612 textOutShadow(4, 132, PAL_FORGRND, PAL_DSKTOP2, "MIDI transmit channel");
2613 textOutShadow(4, 147, PAL_FORGRND, PAL_DSKTOP2, "MIDI program");2613 textOutShadow(4, 146, PAL_FORGRND, PAL_DSKTOP2, "MIDI program");
2614 textOutShadow(4, 160, PAL_FORGRND, PAL_DSKTOP2, "Bender range (halftones)");2614 textOutShadow(4, 160, PAL_FORGRND, PAL_DSKTOP2, "Bender range (halftones)");
2615 2615
2616 if (ins == NULL)2616 if (ins == NULL)
@@ -3268,9 +3268,9 @@ static int32_t SDLCALL loadInstrThread(void *ptr) · 651 unmodified lines
3268 {3268 {
3269 s->typ &= ~32;3269 s->typ &= ~32;
3270 3270
3271 s->len /= 2;3271 s->len >>= 1;
3272 s->repL /= 2;3272 s->repL >>= 1;
3273 s->repS /= 2;3273 s->repS >>= 1;
3274 3274
3275 newPtr = (int8_t *)realloc(s->origPek, s->len + LOOP_FIX_LEN);3275 newPtr = (int8_t *)realloc(s->origPek, s->len + LOOP_FIX_LEN);
3276 if (newPtr != NULL)3276 if (newPtr != NULL)
@@ -3348,11 +3348,11 @@ static int32_t SDLCALL loadInstrThread(void *ptr) · 71 unmodified lines
3348 {3348 {
3349 ins->vibSweep = ih_PATWave.vibSweep;3349 ins->vibSweep = ih_PATWave.vibSweep;
3350 3350
3351 ins->vibRate = (ih_PATWave.vibRate + 2) / 4;3351 ins->vibRate = (ih_PATWave.vibRate + 2) >> 2;
3352 if (ins->vibRate > 0x3F)3352 if (ins->vibRate > 0x3F)
3353 ins->vibRate = 0x3F;3353 ins->vibRate = 0x3F;
3354 3354
3355 ins->vibDepth = (ih_PATWave.vibDepth + 1) / 2;3355 ins->vibDepth = (ih_PATWave.vibDepth + 1) >> 1;
3356 if (ins->vibDepth > 0x0F)3356 if (ins->vibDepth > 0x0F)
3357 ins->vibDepth = 0x0F;3357 ins->vibDepth = 0x0F;
3358 }3358 }
src/ft2_mix.c+96−168
@@ -36,13 +36,10 @@ · 35 unmodified lines
36 36
37static void mix8bNoLoop(voice_t *v, uint32_t numSamples)37static void mix8bNoLoop(voice_t *v, uint32_t numSamples)
38{38{
39 const int8_t *CDA_LinearAdr;39 const int8_t *CDA_LinearAdr, *smpPtr;
40 bool mixInMono;40 int32_t realPos, sample, *audioMixL, *audioMixR;
41 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;41 int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
42 register const int8_t *smpPtr;42 uint32_t pos;
43 register int32_t CDA_LVol, CDA_RVol;
44 register uint32_t pos, delta;
45 uint32_t i, samplesToMix;
46 43
47 GET_VOL44 GET_VOL
48 45
@@ -103,13 +100,10 @@ static void mix8bNoLoop(voice_t *v, uint32_t numSamples) · 54 unmodified lines
103 100
104static void mix8bLoop(voice_t *v, uint32_t numSamples)101static void mix8bLoop(voice_t *v, uint32_t numSamples)
105{102{
106 const int8_t *CDA_LinearAdr;103 const int8_t *CDA_LinearAdr, *smpPtr;;
107 bool mixInMono;104 int32_t realPos, sample, *audioMixL, *audioMixR;
108 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;105 int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
109 register const int8_t *smpPtr;106 uint32_t pos;
110 register int32_t CDA_LVol, CDA_RVol;
111 register uint32_t pos, delta;
112 uint32_t i, samplesToMix;
113 107
114 GET_VOL108 GET_VOL
115 109
@@ -170,13 +164,10 @@ static void mix8bLoop(voice_t *v, uint32_t numSamples) · 54 unmodified lines
170 164
171static void mix8bBidiLoop(voice_t *v, uint32_t numSamples)165static void mix8bBidiLoop(voice_t *v, uint32_t numSamples)
172{166{
173 bool mixInMono;167 const int8_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
174 const int8_t *CDA_LinearAdr, *CDA_LinAdrRev;168 int32_t realPos, sample, *audioMixL, *audioMixR;
175 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;169 int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
176 register const int8_t *smpPtr;170 uint32_t pos, delta;
177 register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
178 register uint32_t pos;
179 uint32_t delta, i, samplesToMix;
180 171
181 GET_VOL172 GET_VOL
182 173
@@ -237,13 +228,10 @@ static void mix8bBidiLoop(voice_t *v, uint32_t numSamples) · 54 unmodified lines
237 228
238static void mix8bNoLoopIntrp(voice_t *v, uint32_t numSamples)229static void mix8bNoLoopIntrp(voice_t *v, uint32_t numSamples)
239{230{
240 const int8_t *CDA_LinearAdr;231 const int8_t *CDA_LinearAdr, *smpPtr;
241 bool mixInMono;232 int32_t realPos, sample, sample2, *audioMixL, *audioMixR;
242 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;233 int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
243 register const int8_t *smpPtr;234 uint32_t pos;
244 register int32_t CDA_LVol, CDA_RVol;
245 register uint32_t pos, delta;
246 uint32_t i, samplesToMix;
247#ifndef LERPMIX235#ifndef LERPMIX
248 int32_t sample3, sample4;236 int32_t sample3, sample4;
249#endif237#endif
@@ -307,13 +295,10 @@ static void mix8bNoLoopIntrp(voice_t *v, uint32_t numSamples) · 57 unmodified lines
307 295
308static void mix8bLoopIntrp(voice_t *v, uint32_t numSamples)296static void mix8bLoopIntrp(voice_t *v, uint32_t numSamples)
309{297{
310 const int8_t *CDA_LinearAdr;298 const int8_t *CDA_LinearAdr, *smpPtr;
311 bool mixInMono;299 int32_t realPos, sample, sample2, *audioMixL, *audioMixR;
312 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;300 int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
313 register const int8_t *smpPtr;301 uint32_t pos;
314 register int32_t CDA_LVol, CDA_RVol;
315 register uint32_t pos, delta;
316 uint32_t i, samplesToMix;
317#ifndef LERPMIX302#ifndef LERPMIX
318 int32_t sample3, sample4;303 int32_t sample3, sample4;
319#endif304#endif
@@ -377,13 +362,10 @@ static void mix8bLoopIntrp(voice_t *v, uint32_t numSamples) · 57 unmodified lines
377 362
378static void mix8bBidiLoopIntrp(voice_t *v, uint32_t numSamples)363static void mix8bBidiLoopIntrp(voice_t *v, uint32_t numSamples)
379{364{
380 bool mixInMono;365 const int8_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
381 const int8_t *CDA_LinearAdr, *CDA_LinAdrRev;366 int32_t realPos, sample, sample2, *audioMixL, *audioMixR;
382 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;367 int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
383 register const int8_t *smpPtr;368 uint32_t pos, delta;
384 register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
385 register uint32_t pos;
386 uint32_t delta, i, samplesToMix;
387#ifndef LERPMIX369#ifndef LERPMIX
388 int32_t sample3, sample4;370 int32_t sample3, sample4;
389#endif371#endif
@@ -448,13 +430,10 @@ static void mix8bBidiLoopIntrp(voice_t *v, uint32_t numSamples) · 58 unmodified lines
448 430
449static void mix8bRampNoLoop(voice_t *v, uint32_t numSamples)431static void mix8bRampNoLoop(voice_t *v, uint32_t numSamples)
450{432{
451 const int8_t *CDA_LinearAdr;433 const int8_t *CDA_LinearAdr, *smpPtr;
452 bool mixInMono;434 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
453 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;435 int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
454 register const int8_t *smpPtr;436 uint32_t pos;
455 register int32_t CDA_LVol, CDA_RVol;
456 register uint32_t pos, delta;
457 uint32_t i, samplesToMix;
458 437
459 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)438 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)
460 {439 {
@@ -522,13 +501,10 @@ static void mix8bRampNoLoop(voice_t *v, uint32_t numSamples) · 61 unmodified lines
522 501
523static void mix8bRampLoop(voice_t *v, uint32_t numSamples)502static void mix8bRampLoop(voice_t *v, uint32_t numSamples)
524{503{
525 const int8_t *CDA_LinearAdr;504 const int8_t *CDA_LinearAdr, *smpPtr;;
526 bool mixInMono;505 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
527 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;506 int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
528 register const int8_t *smpPtr;507 uint32_t pos;
529 register int32_t CDA_LVol, CDA_RVol;
530 register uint32_t pos, delta;
531 uint32_t i, samplesToMix;
532 508
533 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)509 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)
534 {510 {
@@ -596,13 +572,10 @@ static void mix8bRampLoop(voice_t *v, uint32_t numSamples) · 61 unmodified lines
596 572
597static void mix8bRampBidiLoop(voice_t *v, uint32_t numSamples)573static void mix8bRampBidiLoop(voice_t *v, uint32_t numSamples)
598{574{
599 bool mixInMono;575 const int8_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
600 const int8_t *CDA_LinearAdr, *CDA_LinAdrRev;576 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
601 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;577 int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
602 register const int8_t *smpPtr;578 uint32_t pos, delta;
603 register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
604 register uint32_t pos;
605 uint32_t delta, i, samplesToMix;
606 579
607 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)580 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)
608 {581 {
@@ -671,13 +644,10 @@ static void mix8bRampBidiLoop(voice_t *v, uint32_t numSamples) · 62 unmodified lines
671 644
672static void mix8bRampNoLoopIntrp(voice_t *v, uint32_t numSamples)645static void mix8bRampNoLoopIntrp(voice_t *v, uint32_t numSamples)
673{646{
674 const int8_t *CDA_LinearAdr;647 const int8_t *CDA_LinearAdr, *smpPtr;
675 bool mixInMono;648 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
676 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;649 int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
677 register const int8_t *smpPtr;650 uint32_t pos;
678 register int32_t CDA_LVol, CDA_RVol;
679 register uint32_t pos, delta;
680 uint32_t i, samplesToMix;
681#ifndef LERPMIX651#ifndef LERPMIX
682 int32_t sample3, sample4;652 int32_t sample3, sample4;
683#endif653#endif
@@ -748,13 +718,10 @@ static void mix8bRampNoLoopIntrp(voice_t *v, uint32_t numSamples) · 64 unmodified lines
748 718
749static void mix8bRampLoopIntrp(voice_t *v, uint32_t numSamples)719static void mix8bRampLoopIntrp(voice_t *v, uint32_t numSamples)
750{720{
751 const int8_t *CDA_LinearAdr;721 const int8_t *CDA_LinearAdr, *smpPtr;
752 bool mixInMono;722 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
753 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;723 int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
754 register const int8_t *smpPtr;724 uint32_t pos;
755 register int32_t CDA_LVol, CDA_RVol;
756 register uint32_t pos, delta;
757 uint32_t i, samplesToMix;
758#ifndef LERPMIX725#ifndef LERPMIX
759 int32_t sample3, sample4;726 int32_t sample3, sample4;
760#endif727#endif
@@ -825,13 +792,10 @@ static void mix8bRampLoopIntrp(voice_t *v, uint32_t numSamples) · 64 unmodified lines
825 792
826static void mix8bRampBidiLoopIntrp(voice_t *v, uint32_t numSamples)793static void mix8bRampBidiLoopIntrp(voice_t *v, uint32_t numSamples)
827{794{
828 bool mixInMono;795 const int8_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
829 const int8_t *CDA_LinearAdr, *CDA_LinAdrRev;796 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
830 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;797 int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
831 register const int8_t *smpPtr;798 uint32_t pos, delta;
832 register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
833 register uint32_t pos;
834 uint32_t delta, i, samplesToMix;
835#ifndef LERPMIX799#ifndef LERPMIX
836 int32_t sample3, sample4;800 int32_t sample3, sample4;
837#endif801#endif
@@ -908,13 +872,10 @@ static void mix8bRampBidiLoopIntrp(voice_t *v, uint32_t numSamples) · 70 unmodified lines
908 872
909static void mix16bNoLoop(voice_t *v, uint32_t numSamples)873static void mix16bNoLoop(voice_t *v, uint32_t numSamples)
910{874{
911 bool mixInMono;875 const int16_t *CDA_LinearAdr, *smpPtr;
912 const int16_t *CDA_LinearAdr;876 int32_t realPos, sample, *audioMixL, *audioMixR;
913 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;877 int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
914 register const int16_t *smpPtr;878 uint32_t pos;
915 register int32_t CDA_LVol, CDA_RVol;
916 register uint32_t pos, delta;
917 uint32_t i, samplesToMix;
918 879
919 GET_VOL880 GET_VOL
920 881
@@ -975,13 +936,10 @@ static void mix16bNoLoop(voice_t *v, uint32_t numSamples) · 54 unmodified lines
975 936
976static void mix16bLoop(voice_t *v, uint32_t numSamples)937static void mix16bLoop(voice_t *v, uint32_t numSamples)
977{938{
978 bool mixInMono;939 const int16_t *CDA_LinearAdr, *smpPtr;
979 const int16_t *CDA_LinearAdr;940 int32_t realPos, sample, *audioMixL, *audioMixR;
980 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;941 int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
981 register const int16_t *smpPtr;942 uint32_t pos;
982 register int32_t CDA_LVol, CDA_RVol;
983 register uint32_t pos, delta;
984 uint32_t i, samplesToMix;
985 943
986 GET_VOL944 GET_VOL
987 945
@@ -1042,13 +1000,10 @@ static void mix16bLoop(voice_t *v, uint32_t numSamples) · 54 unmodified lines
1042 1000
1043static void mix16bBidiLoop(voice_t *v, uint32_t numSamples)1001static void mix16bBidiLoop(voice_t *v, uint32_t numSamples)
1044{1002{
1045 bool mixInMono;1003 const int16_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
1046 const int16_t *CDA_LinearAdr, *CDA_LinAdrRev;1004 int32_t realPos, sample, *audioMixL, *audioMixR;
1047 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;1005 int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
1048 register const int16_t *smpPtr;1006 uint32_t pos, delta;
1049 register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
1050 register uint32_t pos;
1051 uint32_t delta, i, samplesToMix;
1052 1007
1053 GET_VOL1008 GET_VOL
1054 1009
@@ -1110,13 +1065,10 @@ static void mix16bBidiLoop(voice_t *v, uint32_t numSamples) · 55 unmodified lines
1110 1065
1111static void mix16bNoLoopIntrp(voice_t *v, uint32_t numSamples)1066static void mix16bNoLoopIntrp(voice_t *v, uint32_t numSamples)
1112{1067{
1113 bool mixInMono;1068 const int16_t *CDA_LinearAdr, *smpPtr;
1114 const int16_t *CDA_LinearAdr;1069 int32_t realPos, sample, sample2, *audioMixL, *audioMixR;
1115 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;1070 int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
1116 register const int16_t *smpPtr;1071 uint32_t pos;
1117 register int32_t CDA_LVol, CDA_RVol;
1118 register uint32_t pos, delta;
1119 uint32_t i, samplesToMix;
1120#ifndef LERPMIX1072#ifndef LERPMIX
1121 int32_t sample3, sample4;1073 int32_t sample3, sample4;
1122#endif1074#endif
@@ -1180,13 +1132,10 @@ static void mix16bNoLoopIntrp(voice_t *v, uint32_t numSamples) · 57 unmodified lines
1180 1132
1181static void mix16bLoopIntrp(voice_t *v, uint32_t numSamples)1133static void mix16bLoopIntrp(voice_t *v, uint32_t numSamples)
1182{1134{
1183 bool mixInMono;1135 const int16_t *CDA_LinearAdr, *smpPtr;
1184 const int16_t *CDA_LinearAdr;1136 int32_t realPos, sample, sample2, *audioMixL, *audioMixR;
1185 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;1137 int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
1186 register const int16_t *smpPtr;1138 uint32_t pos;
1187 register int32_t CDA_LVol, CDA_RVol;
1188 register uint32_t pos, delta;
1189 uint32_t i, samplesToMix;
1190#ifndef LERPMIX1139#ifndef LERPMIX
1191 int32_t sample3, sample4;1140 int32_t sample3, sample4;
1192#endif1141#endif
@@ -1250,13 +1199,10 @@ static void mix16bLoopIntrp(voice_t *v, uint32_t numSamples) · 57 unmodified lines
1250 1199
1251static void mix16bBidiLoopIntrp(voice_t *v, uint32_t numSamples)1200static void mix16bBidiLoopIntrp(voice_t *v, uint32_t numSamples)
1252{1201{
1253 bool mixInMono;1202 const int16_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
1254 const int16_t *CDA_LinearAdr, *CDA_LinAdrRev;1203 int32_t realPos, sample, sample2, *audioMixL, *audioMixR;
1255 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;1204 int32_t CDA_BytesLeft, CDA_LVol, CDA_RVol, i, samplesToMix;
1256 register const int16_t *smpPtr;1205 uint32_t pos, delta;
1257 register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
1258 register uint32_t pos;
1259 uint32_t delta, i, samplesToMix;
1260#ifndef LERPMIX1206#ifndef LERPMIX
1261 int32_t sample3, sample4;1207 int32_t sample3, sample4;
1262#endif1208#endif
@@ -1321,13 +1267,10 @@ static void mix16bBidiLoopIntrp(voice_t *v, uint32_t numSamples) · 58 unmodified lines
1321 1267
1322static void mix16bRampNoLoop(voice_t *v, uint32_t numSamples)1268static void mix16bRampNoLoop(voice_t *v, uint32_t numSamples)
1323{1269{
1324 bool mixInMono;1270 const int16_t *CDA_LinearAdr, *smpPtr;
1325 const int16_t *CDA_LinearAdr;1271 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
1326 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;1272 int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
1327 register const int16_t *smpPtr;1273 uint32_t pos;
1328 register int32_t CDA_LVol, CDA_RVol;
1329 register uint32_t pos, delta;
1330 uint32_t i, samplesToMix;
1331 1274
1332 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)1275 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)
1333 {1276 {
@@ -1395,13 +1338,10 @@ static void mix16bRampNoLoop(voice_t *v, uint32_t numSamples) · 61 unmodified lines
1395 1338
1396static void mix16bRampLoop(voice_t *v, uint32_t numSamples)1339static void mix16bRampLoop(voice_t *v, uint32_t numSamples)
1397{1340{
1398 bool mixInMono;1341 const int16_t *CDA_LinearAdr, *smpPtr;
1399 const int16_t *CDA_LinearAdr;1342 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
1400 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;1343 int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
1401 register const int16_t *smpPtr;1344 uint32_t pos;
1402 register int32_t CDA_LVol, CDA_RVol;
1403 register uint32_t pos, delta;
1404 uint32_t i, samplesToMix;
1405 1345
1406 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)1346 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)
1407 {1347 {
@@ -1469,13 +1409,10 @@ static void mix16bRampLoop(voice_t *v, uint32_t numSamples) · 61 unmodified lines
1469 1409
1470static void mix16bRampBidiLoop(voice_t *v, uint32_t numSamples)1410static void mix16bRampBidiLoop(voice_t *v, uint32_t numSamples)
1471{1411{
1472 bool mixInMono;1412 const int16_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
1473 const int16_t *CDA_LinearAdr, *CDA_LinAdrRev;1413 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft;
1474 int32_t realPos, sample, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;1414 int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
1475 register const int16_t *smpPtr;1415 uint32_t pos, delta;
1476 register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
1477 register uint32_t pos;
1478 uint32_t delta, i, samplesToMix;
1479 1416
1480 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)1417 if ((v->SLVol1 | v->SRVol1 | v->SLVol2 | v->SRVol2) == 0)
1481 {1418 {
@@ -1544,13 +1481,10 @@ static void mix16bRampBidiLoop(voice_t *v, uint32_t numSamples) · 62 unmodified lines
1544 1481
1545static void mix16bRampNoLoopIntrp(voice_t *v, uint32_t numSamples)1482static void mix16bRampNoLoopIntrp(voice_t *v, uint32_t numSamples)
1546{1483{
1547 bool mixInMono;1484 const int16_t *CDA_LinearAdr, *smpPtr;
1548 const int16_t *CDA_LinearAdr;1485 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
1549 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;1486 int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
1550 register const int16_t *smpPtr;1487 uint32_t pos;
1551 register int32_t CDA_LVol, CDA_RVol;
1552 register uint32_t pos, delta;
1553 uint32_t i, samplesToMix;
1554#ifndef LERPMIX1488#ifndef LERPMIX
1555 int32_t sample3, sample4;1489 int32_t sample3, sample4;
1556#endif1490#endif
@@ -1621,13 +1555,10 @@ static void mix16bRampNoLoopIntrp(voice_t *v, uint32_t numSamples) · 64 unmodified lines
1621 1555
1622static void mix16bRampLoopIntrp(voice_t *v, uint32_t numSamples)1556static void mix16bRampLoopIntrp(voice_t *v, uint32_t numSamples)
1623{1557{
1624 bool mixInMono;1558 const int16_t *CDA_LinearAdr, *smpPtr;
1625 const int16_t *CDA_LinearAdr;1559 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
1626 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;1560 int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
1627 register const int16_t *smpPtr;1561 uint32_t pos;
1628 register int32_t CDA_LVol, CDA_RVol;
1629 register uint32_t pos, delta;
1630 uint32_t i, samplesToMix;
1631#ifndef LERPMIX1562#ifndef LERPMIX
1632 int32_t sample3, sample4;1563 int32_t sample3, sample4;
1633#endif1564#endif
@@ -1698,13 +1629,10 @@ static void mix16bRampLoopIntrp(voice_t *v, uint32_t numSamples) · 64 unmodified lines
1698 1629
1699static void mix16bRampBidiLoopIntrp(voice_t *v, uint32_t numSamples)1630static void mix16bRampBidiLoopIntrp(voice_t *v, uint32_t numSamples)
1700{1631{
1701 bool mixInMono;1632 const int16_t *CDA_LinearAdr, *CDA_LinAdrRev, *smpPtr;
1702 const int16_t *CDA_LinearAdr, *CDA_LinAdrRev;1633 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft;
1703 int32_t realPos, sample, sample2, *audioMixL, *audioMixR, CDA_BytesLeft, CDA_LVolIP, CDA_RVolIP;1634 int32_t CDA_LVolIP, CDA_RVolIP, CDA_LVol, CDA_RVol, i, samplesToMix;
1704 register const int16_t *smpPtr;1635 uint32_t pos, delta;
1705 register int32_t CDA_LVol, CDA_RVol, CDA_IPValL, CDA_IPValH;
1706 register uint32_t pos;
1707 uint32_t delta, i, samplesToMix;
1708#ifndef LERPMIX1636#ifndef LERPMIX
1709 int32_t sample3, sample4;1637 int32_t sample3, sample4;
1710#endif1638#endif
src/ft2_mix_macros.h+18−14
@@ -14,21 +14,24 @@ · 13 unmodified lines
14 v->SLVol2 = CDA_LVol; \14 v->SLVol2 = CDA_LVol; \
15 v->SRVol2 = CDA_RVol; \15 v->SRVol2 = CDA_RVol; \
16 16
17#define GET_DELTA delta = v->SFrq;17#define GET_DELTA \
18 const uint32_t delta = v->SFrq;
18 19
19#define GET_MIXER_VARS \20#define GET_MIXER_VARS \
21 const int32_t SFrqRev = v->SFrqRev; \
20 audioMixL = audio.mixBufferL; \22 audioMixL = audio.mixBufferL; \
21 audioMixR = audio.mixBufferR; \23 audioMixR = audio.mixBufferR; \
22 mixInMono = (CDA_LVol == CDA_RVol); \24 const bool mixInMono = (CDA_LVol == CDA_RVol); \
23 realPos = v->SPos; \25 realPos = v->SPos; \
24 pos = v->SPosDec; \26 pos = v->SPosDec; \
25 27
26#define GET_MIXER_VARS_RAMP \28#define GET_MIXER_VARS_RAMP \
29 const int32_t SFrqRev = v->SFrqRev; \
27 audioMixL = audio.mixBufferL; \30 audioMixL = audio.mixBufferL; \
28 audioMixR = audio.mixBufferR; \31 audioMixR = audio.mixBufferR; \
29 CDA_LVolIP = v->SLVolIP; \32 CDA_LVolIP = v->SLVolIP; \
30 CDA_RVolIP = v->SRVolIP; \33 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); \
32 realPos = v->SPos; \35 realPos = v->SPos; \
33 pos = v->SPosDec; \36 pos = v->SPosDec; \
34 37
@@ -240,12 +243,15 @@ · 205 unmodified lines
240/* ----------------------------------------------------------------------- */243/* ----------------------------------------------------------------------- */
241 244
242#define LIMIT_MIX_NUM \245#define LIMIT_MIX_NUM \
243 i = (v->SLen - 1) - realPos; \246 samplesToMix = (v->SLen - 1) - realPos; \
244 if (i > 65535) \247 if (samplesToMix > 65535) \
245 i = 65535; \248 samplesToMix = 65535; \
246 \249 \
247 samplesToMix = (((((uint64_t)i << 16) | (pos ^ 0xFFFF)) * v->SFrqRev) >> 32) + 1; \250 samplesToMix = (samplesToMix << 16) | (pos ^ 0xFFFF); \
248 if (samplesToMix > (uint32_t)CDA_BytesLeft) \251 samplesToMix = ((int64_t)samplesToMix * SFrqRev) >> 32; \
252 samplesToMix++; \
253 \
254 if (samplesToMix > CDA_BytesLeft) \
249 samplesToMix = CDA_BytesLeft; \255 samplesToMix = CDA_BytesLeft; \
250 256
251#define LIMIT_MIX_NUM_RAMP \257#define LIMIT_MIX_NUM_RAMP \
@@ -262,7 +268,7 @@ · 10 unmodified lines
262 } \268 } \
263 else \269 else \
264 { \270 { \
265 if (samplesToMix > (uint32_t)v->SVolIPLen) \271 if (samplesToMix > v->SVolIPLen) \
266 samplesToMix = v->SVolIPLen; \272 samplesToMix = v->SVolIPLen; \
267 \273 \
268 v->SVolIPLen -= samplesToMix; \274 v->SVolIPLen -= samplesToMix; \
@@ -272,7 +278,6 @@ · 3 unmodified lines
272 if (v->backwards) \278 if (v->backwards) \
273 { \279 { \
274 delta = 0 - v->SFrq; \280 delta = 0 - v->SFrq; \
275 CDA_IPValH = (int32_t)delta >> 16; \
276 assert(realPos >= v->SRepS && realPos < v->SLen); \281 assert(realPos >= v->SRepS && realPos < v->SLen); \
277 realPos = ~realPos; \282 realPos = ~realPos; \
278 smpPtr = CDA_LinAdrRev + realPos; \283 smpPtr = CDA_LinAdrRev + realPos; \
@@ -281,19 +286,18 @@ · 2 unmodified lines
281 else \286 else \
282 { \287 { \
283 delta = v->SFrq; \288 delta = v->SFrq; \
284 CDA_IPValH = delta >> 16; \
285 assert(realPos >= 0 && realPos < v->SLen); \289 assert(realPos >= 0 && realPos < v->SLen); \
286 smpPtr = CDA_LinearAdr + realPos; \290 smpPtr = CDA_LinearAdr + realPos; \
287 } \291 } \
288 \292 \
289 CDA_IPValL = delta & 0xFFFF; \293 const int32_t CDA_IPValH = (int32_t)delta >> 16; \
294 const int32_t CDA_IPValL = delta & 0xFFFF; \
290 295
291#define END_BIDI \296#define END_BIDI \
292 if (v->backwards) \297 if (v->backwards) \
293 { \298 { \
294 pos ^= 0xFFFF; \299 pos ^= 0xFFFF; \
295 realPos = (int32_t)(smpPtr - CDA_LinAdrRev); \300 realPos = ~(int32_t)(smpPtr - CDA_LinAdrRev); \
296 realPos = ~realPos; \
297 } \301 } \
298 else \302 else \
299 { \303 { \
src/ft2_module_loader.c+163−298
@@ -184,7 +184,7 @@ static uint8_t getModType(uint8_t *numChannels, const char *id) · 183 unmodified lines
184 184
185 if (IS_ID("M.K.", id) || IS_ID("M!K!", id) || IS_ID("NSMS", id) || IS_ID("LARD", id) || IS_ID("PATT", id))185 if (IS_ID("M.K.", id) || IS_ID("M!K!", id) || IS_ID("NSMS", id) || IS_ID("LARD", id) || IS_ID("PATT", id))
186 {186 {
187 modFormat = FORMAT_MK; // ProTracker or compatible 187 modFormat = FORMAT_MK; // ProTracker or compatible
188 }188 }
189 else if (id[1] == 'C' && id[2] == 'H' && id[3] == 'N')189 else if (id[1] == 'C' && id[2] == 'H' && id[3] == 'N')
190 {190 {
@@ -200,11 +200,6 @@ static uint8_t getModType(uint8_t *numChannels, const char *id) · 9 unmodified lines
200 {200 {
201 modFormat = FORMAT_FLT; // StarTrekker (4-channel modules only)201 modFormat = FORMAT_FLT; // StarTrekker (4-channel modules only)
202 }202 }
203 else if (IS_ID("FLT8", id))
204 {
205 modFormat = FORMAT_FLT; // StarTrekker (4-channel modules only)
206 *numChannels = 8;
207 }
208 else if (IS_ID("N.T.", id))203 else if (IS_ID("N.T.", id))
209 {204 {
210 modFormat = FORMAT_NT; // NoiseTracker205 modFormat = FORMAT_NT; // NoiseTracker
@@ -364,23 +359,23 @@ static bool loadMusicMOD(FILE *f, uint32_t fileLength, bool fromExternalThread) · 153 unmodified lines
364 */359 */
365 modFormat = FORMAT_STK;360 modFormat = FORMAT_STK;
366 361
367 if (h_MOD15.repS == 0)362 if (songTmp.repS == 0)
368 h_MOD15.repS = 120;363 songTmp.repS = 120;
369 364
370 // jjk55.mod by Jesper Kyd has a bogus STK tempo value that should be ignored365 // jjk55.mod by Jesper Kyd has a bogus STK tempo value that should be ignored (hackish!)
371 if (!strcmp("jjk55", h_MOD31.name))366 if (!strcmp("jjk55", h_MOD31.name))
372 h_MOD15.repS = 120;367 songTmp.repS = 120;
373 368
374 // The "restart pos" field in STK is the inital tempo (must be converted to BPM first)369 // 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)
376 {371 {
377 if (h_MOD15.repS > 220)372 if (songTmp.repS > 220)
378 h_MOD15.repS = 220;373 songTmp.repS = 220;
379 374
380 // convert UST tempo to BPM375 // convert UST tempo to BPM
381 uint16_t ciaPeriod = (240 - songTmp.repS) * 122;376 uint16_t ciaPeriod = (240 - songTmp.repS) * 122;
382 double dHz = 709379.0 / ciaPeriod;377 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);
384 379
385 songTmp.speed = (uint16_t)BPM;380 songTmp.speed = (uint16_t)BPM;
386 }381 }
@@ -450,7 +445,7 @@ static bool loadMusicMOD(FILE *f, uint32_t fileLength, bool fromExternalThread) · 63 unmodified lines
450 ton->effTyp = bytes[2] & 0x0F;445 ton->effTyp = bytes[2] & 0x0F;
451 ton->eff = bytes[3];446 ton->eff = bytes[3];
452 447
453 if (mightBeSTK)448 if (modFormat == FORMAT_STK)
454 {449 {
455 if (ton->effTyp == 0xC || ton->effTyp == 0xD || ton->effTyp == 0xE)450 if (ton->effTyp == 0xC || ton->effTyp == 0xD || ton->effTyp == 0xE)
456 {451 {
@@ -519,7 +514,7 @@ static bool loadMusicMOD(FILE *f, uint32_t fileLength, bool fromExternalThread) · 62 unmodified lines
519 }514 }
520 515
521 // pattern command conversion for non-PT formats516 // 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)
523 {518 {
524 for (a = 0; a < b; a++)519 for (a = 0; a < b; a++)
525 {520 {
@@ -690,7 +685,7 @@ static bool loadMusicMOD(FILE *f, uint32_t fileLength, bool fromExternalThread) · 164 unmodified lines
690 /* For Ultimate SoundTracker modules, only the loop area of a looped sample is played.685 /* For Ultimate SoundTracker modules, only the loop area of a looped sample is played.
691 ** Skip loading of eventual data present before loop start.686 ** Skip loading of eventual data present before loop start.
692 */687 */
693 if (modFormat == FORMAT_STK && (s->repS > 0 && s->repL < s->len))688 if (modFormat == FORMAT_STK && s->repS > 0 && s->repL < s->len)
694 {689 {
695 s->len -= s->repS;690 s->len -= s->repS;
696 fseek(f, s->repS, SEEK_CUR);691 fseek(f, s->repS, SEEK_CUR);
@@ -705,7 +700,7 @@ static bool loadMusicMOD(FILE *f, uint32_t fileLength, bool fromExternalThread) · 8 unmodified lines
705 }700 }
706 701
707 // clear repL and repS on non-looping samples...702 // clear repL and repS on non-looping samples...
708 if ((s->typ & 3) == 0)703 if (s->typ == 0)
709 {704 {
710 s->repL = 0;705 s->repL = 0;
711 s->repS = 0;706 s->repS = 0;
@@ -735,18 +730,15 @@ static uint8_t stmTempoToBPM(uint8_t tempo) // ported from original ST2.3 replay · 23 unmodified lines
735 uint16_t hz = 50;730 uint16_t hz = 50;
736 731
737 hz -= ((slowdowns[tempo >> 4] * (tempo & 15)) >> 4); // can and will underflow732 hz -= ((slowdowns[tempo >> 4] * (tempo & 15)) >> 4); // can and will underflow
738 733 bpm = (hz << 1) + (hz >> 1); // BPM = hz * 2.5
739 bpm = (int32_t)((hz * 2.5) + 0.5);
740 return (uint8_t)CLAMP(bpm, 32, 255); // result can be slightly off, but close enough...734 return (uint8_t)CLAMP(bpm, 32, 255); // result can be slightly off, but close enough...
741}735}
742 736
743static bool loadMusicSTM(FILE *f, uint32_t fileLength, bool fromExternalThread)737static bool loadMusicSTM(FILE *f, uint32_t fileLength, bool fromExternalThread)
744{738{
745 bool check3xx;739 uint8_t typ, tempo;
746 uint8_t typ, tmp8, tempo;
747 int16_t i, j, k, ai, ap, tmp;740 int16_t i, j, k, ai, ap, tmp;
748 uint16_t a;741 uint16_t a;
749 int32_t len;
750 tonTyp *ton;742 tonTyp *ton;
751 sampleTyp *s;743 sampleTyp *s;
752 songSTMHeaderTyp h_STM;744 songSTMHeaderTyp h_STM;
@@ -887,19 +879,6 @@ static bool loadMusicSTM(FILE *f, uint32_t fileLength, bool fromExternalThread) · 134 unmodified lines
887 ton->eff = 0;879 ton->eff = 0;
888 }880 }
889 881
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
903 if (ton->effTyp > 35)882 if (ton->effTyp > 35)
904 {883 {
905 ton->effTyp = 0;884 ton->effTyp = 0;
@@ -986,77 +965,6 @@ static bool loadMusicSTM(FILE *f, uint32_t fileLength, bool fromExternalThread) · 80 unmodified lines
986 }965 }
987 }966 }
988 967
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
1060 fclose(f);968 fclose(f);
1061 969
1062 moduleLoaded = true;970 moduleLoaded = true;
@@ -1102,14 +1010,14 @@ static int8_t countS3MChannels(uint16_t antPtn) · 39 unmodified lines
1102static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread)1010static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread)
1103{1011{
1104 int8_t *tmpSmp;1012 int8_t *tmpSmp;
1105 bool check3xx, illegalUxx;1013 bool illegalUxx;
1106 uint8_t ha[2048];1014 uint8_t ha[2048];
1107 uint8_t s3mLastDEff[32], s3mLastEEff[32], s3mLastFEff[32];1015 uint8_t alastnfo[32], alastefx[32], alastvibnfo[32], s3mLastGInstr[32];
1108 uint8_t s3mLastSEff[32], s3mLastJEff[32], s3mLastGInstr[32], typ;1016 uint8_t typ;
1109 int16_t ai, ap, ver, ii, kk, tmp;1017 int16_t ai, ap, ver, ii, kk, tmp;
1110 uint16_t ptnOfs[256];1018 uint16_t ptnOfs[256];
1111 int32_t i, j, k, len;1019 int32_t i, j, k, len;
1112 tonTyp ton, *pattTon;1020 tonTyp ton;
1113 sampleTyp *s;1021 sampleTyp *s;
1114 songS3MHeaderTyp h_S3M;1022 songS3MHeaderTyp h_S3M;
1115 songS3MinstrHeaderTyp h_S3MInstr;1023 songS3MinstrHeaderTyp h_S3MInstr;
@@ -1143,13 +1051,7 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 27 unmodified lines
1143 goto s3mLoadError;1051 goto s3mLoadError;
1144 }1052 }
1145 1053
1146 // count real song table entries1054 songTmp.len = h_S3M.songTabLen;
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;
1153 1055
1154 // remove pattern separators (254)1056 // remove pattern separators (254)
1155 k = 0;1057 k = 0;
@@ -1165,11 +1067,20 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 9 unmodified lines
1165 if (k <= songTmp.len)1067 if (k <= songTmp.len)
1166 songTmp.len -= (uint16_t)k;1068 songTmp.len -= (uint16_t)k;
1167 else1069 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 }
1169 1080
1170 // clear unused song table entries1081 // clear unused song table entries
1171 if (songTmp.len < 255)1082 if (songTmp.len < 255)
1172 memset(&songTmp.songTab[songTmp.len], 0, 256 - songTmp.len);1083 memset(&songTmp.songTab[songTmp.len], 0, 255-songTmp.len);
1173 1084
1174 songTmp.speed = h_S3M.defTempo;1085 songTmp.speed = h_S3M.defTempo;
1175 if (songTmp.speed < 32)1086 if (songTmp.speed < 32)
@@ -1226,11 +1137,9 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 50 unmodified lines
1226 if (ptnOfs[i] == 0)1137 if (ptnOfs[i] == 0)
1227 continue; // empty pattern1138 continue; // empty pattern
1228 1139
1229 memset(s3mLastDEff, 0, sizeof (s3mLastDEff));1140 memset(alastnfo, 0, sizeof (alastnfo));
1230 memset(s3mLastEEff, 0, sizeof (s3mLastEEff));1141 memset(alastefx, 0, sizeof (alastefx));
1231 memset(s3mLastFEff, 0, sizeof (s3mLastFEff));1142 memset(alastvibnfo, 0, sizeof (alastvibnfo));
1232 memset(s3mLastSEff, 0, sizeof (s3mLastSEff));
1233 memset(s3mLastJEff, 0, sizeof (s3mLastJEff));
1234 memset(s3mLastGInstr, 0, sizeof (s3mLastGInstr));1143 memset(s3mLastGInstr, 0, sizeof (s3mLastGInstr));
1235 1144
1236 fseek(f, ptnOfs[i] << 4, SEEK_SET);1145 fseek(f, ptnOfs[i] << 4, SEEK_SET);
@@ -1295,7 +1204,7 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 58 unmodified lines
1295 }1204 }
1296 }1205 }
1297 1206
1298 // volume1207 // volume column
1299 if (typ & 64)1208 if (typ & 64)
1300 {1209 {
1301 ton.vol = pattBuff[k++];1210 ton.vol = pattBuff[k++];
@@ -1312,28 +1221,42 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 10 unmodified lines
1312 ton.effTyp = pattBuff[k++];1221 ton.effTyp = pattBuff[k++];
1313 ton.eff = pattBuff[k++];1222 ton.eff = pattBuff[k++];
1314 1223
1315 if (ton.eff == 0)1224 if (ton.eff > 0)
1316 {1225 {
1317 if (ton.effTyp == 4)1226 alastnfo[ii] = ton.eff;
1318 {1227 if (ton.effTyp == 8 || ton.effTyp == 21)
1319 if ((s3mLastDEff[ii] & 0xF0) == 0xF0 || (s3mLastDEff[ii] & 0x0F) == 0x0F)1228 alastvibnfo[ii] = ton.eff; // H/U
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];
1326 }1229 }
1327 1230
1328 if (ton.eff != 0)1231 // in ST3, a lot of effects directly share the same memory!
1232 if (ton.eff == 0 && ton.effTyp != 7) // G
1329 {1233 {
1330 if (ton.effTyp == 4) s3mLastDEff[ii] = ton.eff;1234 uint8_t efx = ton.effTyp;
1331 else if (ton.effTyp == 5) s3mLastEEff[ii] = ton.eff;1235 if (efx == 8 || efx == 21) // H/U
1332 else if (ton.effTyp == 6) s3mLastFEff[ii] = ton.eff;1236 ton.eff = alastvibnfo[ii];
1333 else if (ton.effTyp == 10) s3mLastJEff[ii] = ton.eff;1237 else if ((efx >= 4 && efx <= 12) || (efx >= 17 && efx <= 19)) // D/E/F/I/J/K/L/Q/R/S
1334 else if (ton.effTyp == 19) s3mLastSEff[ii] = ton.eff;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 }
1335 }1255 }
1336 1256
1257 if (ton.effTyp > 0)
1258 alastefx[ii] = ton.effTyp;
1259
1337 switch (ton.effTyp)1260 switch (ton.effTyp)
1338 {1261 {
1339 case 1: // A1262 case 1: // A
@@ -1351,14 +1274,12 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 11 unmodified lines
1351 case 3: ton.effTyp = 0xD; break; // C1274 case 3: ton.effTyp = 0xD; break; // C
1352 case 4: // D1275 case 4: // D
1353 {1276 {
1354 if ((ton.eff & 0xF0) == 0) ton.effTyp = 0xA;1277 if (ton.eff > 0xF0) // fine slide up
1355 else if ((ton.eff & 0x0F) == 0) ton.effTyp = 0xA;
1356 else if ((ton.eff & 0xF0) == 0xF0)
1357 {1278 {
1358 ton.effTyp = 0xE;1279 ton.effTyp = 0xE;
1359 ton.eff = 0xB0 | (ton.eff & 15);1280 ton.eff = 0xB0 | (ton.eff & 0xF);
1360 }1281 }
1361 else if ((ton.eff & 0x0F) == 0x0F)1282 else if ((ton.eff & 0x0F) == 0x0F && (ton.eff & 0xF0) > 0) // fine slide down
1362 {1283 {
1363 ton.effTyp = 0xE;1284 ton.effTyp = 0xE;
1364 ton.eff = 0xA0 | (ton.eff >> 4);1285 ton.eff = 0xA0 | (ton.eff >> 4);
@@ -1366,10 +1287,8 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 1 unmodified line
1366 else1287 else
1367 {1288 {
1368 ton.effTyp = 0xA;1289 ton.effTyp = 0xA;
1369 if (ton.eff & 0x0F)1290 if (ton.eff & 0x0F) // on D/K, last nybble has first priority in ST3
1370 ton.eff &= 0x0F;1291 ton.eff &= 0x0F;
1371 else
1372 ton.eff &= 0xF0;
1373 }1292 }
1374 }1293 }
1375 break;1294 break;
@@ -1379,6 +1298,7 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 3 unmodified lines
1379 {1298 {
1380 if ((ton.eff & 0xF0) >= 0xE0)1299 if ((ton.eff & 0xF0) >= 0xE0)
1381 {1300 {
1301 // convert to fine slide
1382 if ((ton.eff & 0xF0) == 0xE0)1302 if ((ton.eff & 0xF0) == 0xE0)
1383 tmp = 0x21;1303 tmp = 0x21;
1384 else1304 else
@@ -1392,9 +1312,15 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 7 unmodified lines
1392 ton.eff |= 0x10;1312 ton.eff |= 0x10;
1393 1313
1394 ton.effTyp = (uint8_t)tmp;1314 ton.effTyp = (uint8_t)tmp;
1315
1316 if (ton.effTyp == 0x21 && ton.eff == 0)
1317 {
1318 ton.effTyp = 0;
1319 }
1395 }1320 }
1396 else1321 else
1397 {1322 {
1323 // convert to normal 1xx/2xx slide
1398 ton.effTyp = 7 - ton.effTyp;1324 ton.effTyp = 7 - ton.effTyp;
1399 }1325 }
1400 }1326 }
@@ -1402,18 +1328,46 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 1 unmodified line
1402 1328
1403 case 7: // G1329 case 7: // G
1404 {1330 {
1331 ton.effTyp = 0x03;
1332
1405 // fix illegal slides (to new instruments)1333 // fix illegal slides (to new instruments)
1406 if (ton.instr != 0 && ton.instr != s3mLastGInstr[ii])1334 if (ton.instr != 0 && ton.instr != s3mLastGInstr[ii])
1407 ton.instr = s3mLastGInstr[ii];1335 ton.instr = s3mLastGInstr[ii];
1336 }
1337 break;
1408 1338
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 }
1410 }1365 }
1411 break;1366 break;
1412 1367
1413 case 8: ton.effTyp = 0x04; break; // H1368 case 8: ton.effTyp = 0x04; break; // H
1414 case 9: ton.effTyp = 0x1D; break; // I1369 case 9: ton.effTyp = 0x1D; break; // I
1415 case 10: ton.effTyp = 0x00; break; // J1370 case 10: ton.effTyp = 0x00; break; // J
1416 case 11: ton.effTyp = 0x06; break; // K
1417 case 12: ton.effTyp = 0x05; break; // L1371 case 12: ton.effTyp = 0x05; break; // L
1418 case 15: ton.effTyp = 0x09; break; // O1372 case 15: ton.effTyp = 0x09; break; // O
1419 case 17: ton.effTyp = 0x1B; break; // Q1373 case 17: ton.effTyp = 0x1B; break; // Q
@@ -1429,10 +1383,37 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 9 unmodified lines
1429 else if (tmp == 0x2) ton.eff |= 0x50;1383 else if (tmp == 0x2) ton.eff |= 0x50;
1430 else if (tmp == 0x3) ton.eff |= 0x40;1384 else if (tmp == 0x3) ton.eff |= 0x40;
1431 else if (tmp == 0x4) ton.eff |= 0x70;1385 else if (tmp == 0x4) ton.eff |= 0x70;
1432 // we ignore S8x (set 4-bit pan) becuase it's not compatible with FT2 panning1386 // ignore S8x becuase it's not compatible with FT2 panning
1433 else if (tmp == 0xB) ton.eff |= 0x60;1387 else if (tmp == 0xB) ton.eff |= 0x60;
1434 else if (tmp == 0xC) ton.eff |= 0xC0;1388 else if (tmp == 0xC) // Note Cut
1435 else if (tmp == 0xD) ton.eff |= 0xD0;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 }
1436 else if (tmp == 0xE) ton.eff |= 0xE0;1417 else if (tmp == 0xE) ton.eff |= 0xE0;
1437 else if (tmp == 0xF) ton.eff |= 0xF0;1418 else if (tmp == 0xF) ton.eff |= 0xF0;
1438 else1419 else
@@ -1454,40 +1435,18 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 15 unmodified lines
1454 }1435 }
1455 break;1436 break;
1456 1437
1457 case 21: // U (fine vibrato, doesn't exist in FT2, do a poor conversion to normal vibrato)1438 case 22: // V
1458 {1439 {
1459 if ((ton.eff & 0x0F) != 0)1440 ton.effTyp = 0x10;
1441 if (ton.eff > 0x40)
1460 {1442 {
1461 ton.eff = (ton.eff & 0xF0) | (((ton.eff & 15) + 1) >> 2); // divide depth by 41443 // Vxx > 0x40 does nothing in ST3
1462 if ((ton.eff & 0x0F) == 0) // depth too low, remove effect1444 ton.effTyp = 0;
1463 {1445 ton.eff = 0;
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 }
1485 }1446 }
1486 }1447 }
1487 break;1448 break;
1488 1449
1489 case 22: ton.effTyp = 0x10; break; // V
1490
1491 default:1450 default:
1492 {1451 {
1493 ton.effTyp = 0;1452 ton.effTyp = 0;
@@ -1500,40 +1459,6 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 6 unmodified lines
1500 if (ton.instr != 0 && ton.effTyp != 0x3)1459 if (ton.instr != 0 && ton.effTyp != 0x3)
1501 s3mLastGInstr[ii] = ton.instr;1460 s3mLastGInstr[ii] = ton.instr;
1502 1461
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
1537 if (ton.effTyp > 35)1462 if (ton.effTyp > 35)
1538 {1463 {
1539 ton.effTyp = 0;1464 ton.effTyp = 0;
@@ -1610,10 +1535,10 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 70 unmodified lines
1610 bool is16Bit = (h_S3MInstr.flags >> 2) & 1;1535 bool is16Bit = (h_S3MInstr.flags >> 2) & 1;
1611 1536
1612 if (is16Bit) // 16-bit1537 if (is16Bit) // 16-bit
1613 len *= 2;1538 len <<= 1;
1614 1539
1615 if (stereoSample) // stereo1540 if (stereoSample) // stereo
1616 len *= 2;1541 len <<= 1;
1617 1542
1618 tmpSmp = (int8_t *)malloc(len + LOOP_FIX_LEN);1543 tmpSmp = (int8_t *)malloc(len + LOOP_FIX_LEN);
1619 if (tmpSmp == NULL)1544 if (tmpSmp == NULL)
@@ -1683,9 +1608,9 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 63 unmodified lines
1683 s->origPek = tmpSmp;1608 s->origPek = tmpSmp;
1684 s->pek = s->origPek + SMP_DAT_OFFSET;1609 s->pek = s->origPek + SMP_DAT_OFFSET;
1685 1610
1686 s->len *= 2;1611 s->len <<= 1;
1687 s->repS *= 2;1612 s->repS <<= 1;
1688 s->repL *= 2;1613 s->repL <<= 1;
1689 }1614 }
1690 else1615 else
1691 {1616 {
@@ -1712,74 +1637,6 @@ static bool loadMusicS3M(FILE *f, uint32_t dataLength, bool fromExternalThread) · 20 unmodified lines
1712 }1637 }
1713 }1638 }
1714 1639
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
1783 fclose(f);1640 fclose(f);
1784 1641
1785 songTmp.antChn = countS3MChannels(ap);1642 songTmp.antChn = countS3MChannels(ap);
@@ -2566,30 +2423,37 @@ static void setupLoadedModule(void) · 780 unmodified lines
2566 // support non-even channel numbers2423 // support non-even channel numbers
2567 if (song.antChn & 1)2424 if (song.antChn & 1)
2568 {2425 {
2569 if (++song.antChn > MAX_VOICES)2426 song.antChn++;
2427 if (song.antChn > MAX_VOICES)
2570 song.antChn = MAX_VOICES;2428 song.antChn = MAX_VOICES;
2571 }2429 }
2572 2430
2573 if (song.repS > song.len)2431 if (song.len == 0)
2432 song.len = 1;
2433
2434 if (song.repS >= song.len)
2574 song.repS = 0;2435 song.repS = 0;
2575 2436
2576 song.globVol = 64;2437 song.globVol = 64;
2577 song.timer = 1;
2578 2438
2579 setScrollBarEnd(SB_POS_ED, (song.len - 1) + 5);2439 setScrollBarEnd(SB_POS_ED, (song.len - 1) + 5);
2580 setScrollBarPos(SB_POS_ED, 0, false);2440 setScrollBarPos(SB_POS_ED, 0, false);
2581 2441
2582 resetChannels();2442 resetChannels();
2583 setPos(0, 0, false);2443 setPos(0, 0, true);
2584 setSpeed(song.speed);2444 setSpeed(song.speed);
2585 2445
2586 editor.tmpPattern = editor.editPattern; // set kludge variable2446 editor.tmpPattern = editor.editPattern; // set kludge variable
2587 editor.speed = song.speed;2447 editor.speed = song.speed;
2588 editor.tempo = song.tempo;2448 editor.tempo = song.tempo;
2589 editor.timer = 1;2449 editor.timer = song.timer;
2590 editor.globalVol = song.globVol;2450 editor.globalVol = song.globVol;
2591 2451
2592 setFrqTab((loadedFormat == FORMAT_XM) ? linearFreqTable : false);2452 if (loadedFormat == FORMAT_XM)
2453 setFrqTab(linearFreqTable);
2454 else
2455 setFrqTab(false);
2456
2593 unlockMixerCallback();2457 unlockMixerCallback();
2594 2458
2595 editor.currVolEnvPoint = 0;2459 editor.currVolEnvPoint = 0;
@@ -2602,9 +2466,10 @@ static void setupLoadedModule(void) · 6 unmodified lines
2602 updateChanNums();2466 updateChanNums();
2603 resetWavRenderer();2467 resetWavRenderer();
2604 clearPattMark();2468 clearPattMark();
2605 song.musicTime = 0;
2606 resetTrimSizes();2469 resetTrimSizes();
2607 2470
2471 song.musicTime = 0;
2472
2608 diskOpSetFilename(DISKOP_ITEM_MODULE, editor.tmpFilenameU);2473 diskOpSetFilename(DISKOP_ITEM_MODULE, editor.tmpFilenameU);
2609 2474
2610 // redraw top part of screen2475 // redraw top part of screen
src/ft2_nibbles.c+2−2
@@ -265,7 +265,7 @@ void nibblesHighScore(void) · 264 unmodified lines
265{265{
266 if (editor.NI_Play)266 if (editor.NI_Play)
267 {267 {
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.");
269 return;269 return;
270 }270 }
271 271
@@ -781,7 +781,7 @@ void nibblesPlay(void) · 509 unmodified lines
781{781{
782 if (editor.NI_Play)782 if (editor.NI_Play)
783 {783 {
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)
785 return;785 return;
786 }786 }
787 787
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
307 307
308static void drawChannelNumbering(uint16_t yPos)308static void drawChannelNumbering(uint16_t yPos)
309{309{
310#define CH_NUM_XPOS 29310#define CH_NUM_XPOS 30
311 311
312 uint16_t xPos = CH_NUM_XPOS;312 uint16_t xPos = CH_NUM_XPOS;
313 int32_t ch = editor.ui.channelOffset + 1;313 int32_t ch = editor.ui.channelOffset + 1;
src/ft2_pattern_ed.c+13−13
@@ -183,10 +183,10 @@ void drawAdvEdit(void) · 182 unmodified lines
183 textOutShadow( 4, 126, PAL_FORGRND, PAL_DSKTOP2, "New number");183 textOutShadow( 4, 126, PAL_FORGRND, PAL_DSKTOP2, "New number");
184 textOutShadow(129, 96, PAL_FORGRND, PAL_DSKTOP2, "Masking enable");184 textOutShadow(129, 96, PAL_FORGRND, PAL_DSKTOP2, "Masking enable");
185 textOutShadow(114, 109, PAL_FORGRND, PAL_DSKTOP2, "Note");185 textOutShadow(114, 109, PAL_FORGRND, PAL_DSKTOP2, "Note");
186 textOutShadow(114, 121, PAL_FORGRND, PAL_DSKTOP2, "Instrument number");186 textOutShadow(114, 122, PAL_FORGRND, PAL_DSKTOP2, "Instrument number");
187 textOutShadow(114, 134, PAL_FORGRND, PAL_DSKTOP2, "Volume column");187 textOutShadow(114, 135, PAL_FORGRND, PAL_DSKTOP2, "Volume column");
188 textOutShadow(114, 147, PAL_FORGRND, PAL_DSKTOP2, "Effect digit 1");188 textOutShadow(114, 148, PAL_FORGRND, PAL_DSKTOP2, "Effect digit 1");
189 textOutShadow(114, 160, PAL_FORGRND, PAL_DSKTOP2, "Effect digit 2,3");189 textOutShadow(114, 161, PAL_FORGRND, PAL_DSKTOP2, "Effect digit 2,3");
190 190
191 charOutShadow(239, 95, PAL_FORGRND, PAL_DSKTOP2, 'C');191 charOutShadow(239, 95, PAL_FORGRND, PAL_DSKTOP2, 'C');
192 charOutShadow(258, 95, PAL_FORGRND, PAL_DSKTOP2, 'P');192 charOutShadow(258, 95, PAL_FORGRND, PAL_DSKTOP2, 'P');
@@ -680,8 +680,8 @@ void patternEditorExtended(void) · 487 unmodified lines
680 680
681 textOutShadow(116, 5, PAL_FORGRND, PAL_DSKTOP2, "Sng.len.");681 textOutShadow(116, 5, PAL_FORGRND, PAL_DSKTOP2, "Sng.len.");
682 textOutShadow(116, 19, PAL_FORGRND, PAL_DSKTOP2, "Repst.");682 textOutShadow(116, 19, PAL_FORGRND, PAL_DSKTOP2, "Repst.");
683 textOutShadow(222, 40, PAL_FORGRND, PAL_DSKTOP2, "Ptn.");683 textOutShadow(222, 39, PAL_FORGRND, PAL_DSKTOP2, "Ptn.");
684 textOutShadow(305, 40, PAL_FORGRND, PAL_DSKTOP2, "Ln.");684 textOutShadow(305, 39, PAL_FORGRND, PAL_DSKTOP2, "Ln.");
685 685
686 editor.ui.instrSwitcherShown = true;686 editor.ui.instrSwitcherShown = true;
687 showInstrumentSwitcher();687 showInstrumentSwitcher();
@@ -2150,12 +2150,12 @@ void drawSongLength(void) · 1462 unmodified lines
2150 if (editor.ui.extended)2150 if (editor.ui.extended)
2151 {2151 {
2152 x = 165;2152 x = 165;
2153 y = 6;2153 y = 5;
2154 }2154 }
2155 else2155 else
2156 {2156 {
2157 x = 59;2157 x = 59;
2158 y = 53;2158 y = 52;
2159 }2159 }
2160 2160
2161 hexOutBg(x, y, PAL_FORGRND, PAL_DESKTOP, (uint8_t)song.len, 2);2161 hexOutBg(x, y, PAL_FORGRND, PAL_DESKTOP, (uint8_t)song.len, 2);
@@ -2168,12 +2168,12 @@ void drawSongRepS(void) · 6 unmodified lines
2168 if (editor.ui.extended)2168 if (editor.ui.extended)
2169 {2169 {
2170 x = 165;2170 x = 165;
2171 y = 20;2171 y = 19;
2172 }2172 }
2173 else2173 else
2174 {2174 {
2175 x = 59;2175 x = 59;
2176 y = 65;2176 y = 64;
2177 }2177 }
2178 2178
2179 hexOutBg(x, y, PAL_FORGRND, PAL_DESKTOP, (uint8_t)song.repS, 2);2179 hexOutBg(x, y, PAL_FORGRND, PAL_DESKTOP, (uint8_t)song.repS, 2);
@@ -2207,8 +2207,8 @@ void drawEditPattern(uint16_t editPattern) · 27 unmodified lines
2207 2207
2208 if (editor.ui.extended)2208 if (editor.ui.extended)
2209 {2209 {
2210 x = 251;2210 x = 252;
2211 y = 40;2211 y = 39;
2212 }2212 }
2213 else2213 else
2214 {2214 {
@@ -2226,7 +2226,7 @@ void drawPatternLength(uint16_t editPattern) · 11 unmodified lines
2226 if (editor.ui.extended)2226 if (editor.ui.extended)
2227 {2227 {
2228 x = 326;2228 x = 326;
2229 y = 40;2229 y = 39;
2230 }2230 }
2231 else2231 else
2232 {2232 {
src/ft2_pushbuttons.c+14−14
@@ -146,13 +146,13 @@ pushButton_t pushButtons[NUM_PUSHBUTTONS] = · 145 unmodified lines
146 146
147 // ------ ABOUT SCREEN PUSHBUTTONS ------147 // ------ ABOUT SCREEN PUSHBUTTONS ------
148 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp148 //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 },
150 150
151 // ------ HELP SCREEN PUSHBUTTONS ------151 // ------ HELP SCREEN PUSHBUTTONS ------
152 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp152 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp
153 { 3, 155, 59, 16, 0, 0, "Exit", NULL, NULL, exitHelpScreen },153 { 3, 155, 59, 16, 0, 0, "Exit", NULL, NULL, exitHelpScreen },
154 { 611, 2, 18, 13, 1, 2, ARROW_UP_STRING, NULL, helpScrollUp, NULL },154 { 611, 2, 18, 13, 1, 3, ARROW_UP_STRING, NULL, helpScrollUp, NULL },
155 { 611, 158, 18, 13, 1, 2, ARROW_DOWN_STRING, NULL, helpScrollDown, NULL },155 { 611, 158, 18, 13, 1, 3, ARROW_DOWN_STRING, NULL, helpScrollDown, NULL },
156 156
157 // ------ PATTERN EDITOR PUSHBUTTONS ------157 // ------ PATTERN EDITOR PUSHBUTTONS ------
158 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp158 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp
@@ -196,8 +196,8 @@ pushButton_t pushButtons[NUM_PUSHBUTTONS] = · 37 unmodified lines
196 196
197 // ------ SAMPLE EDITOR PUSHBUTTONS ------197 // ------ SAMPLE EDITOR PUSHBUTTONS ------
198 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp198 //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 },199 { 3, 331, 23, 13, 1, 3, ARROW_LEFT_STRING, NULL, scrollSampleDataLeft, NULL },
200 { 606, 331, 23, 13, 0, 0, ARROW_RIGHT_STRING, NULL, scrollSampleDataRight, NULL },200 { 606, 331, 23, 13, 1, 3, ARROW_RIGHT_STRING, NULL, scrollSampleDataRight, NULL },
201 { 38, 356, 18, 13, 1, 4, ARROW_UP_STRING, NULL, sampPlayNoteUp, NULL },201 { 38, 356, 18, 13, 1, 4, ARROW_UP_STRING, NULL, sampPlayNoteUp, NULL },
202 { 38, 368, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, sampPlayNoteDown, NULL },202 { 38, 368, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, sampPlayNoteDown, NULL },
203 { 3, 382, 53, 16, 0, 0, "Stop", NULL, NULL, smpEdStop},203 { 3, 382, 53, 16, 0, 0, "Stop", NULL, NULL, smpEdStop},
@@ -338,10 +338,10 @@ pushButton_t pushButtons[NUM_PUSHBUTTONS] = · 134 unmodified lines
338 { 113, 155, 93, 16, 0, 0, editor.ui.fullscreenButtonText, NULL, NULL, toggleFullScreen },338 { 113, 155, 93, 16, 0, 0, editor.ui.fullscreenButtonText, NULL, NULL, toggleFullScreen },
339 { 370, 121, 18, 13, 1, 4, ARROW_UP_STRING, NULL, configQuantizeUp, NULL },339 { 370, 121, 18, 13, 1, 4, ARROW_UP_STRING, NULL, configQuantizeUp, NULL },
340 { 387, 121, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, configQuantizeDown, NULL },340 { 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 },341 { 594, 106, 18, 13, 1, 4, ARROW_UP_STRING, NULL, configMIDIChnUp, NULL },
342 { 611, 107, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, configMIDIChnDown, NULL },342 { 611, 106, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, configMIDIChnDown, NULL },
343 { 594, 121, 18, 13, 1, 4, ARROW_UP_STRING, NULL, configMIDITransUp, NULL },343 { 594, 120, 18, 13, 1, 4, ARROW_UP_STRING, NULL, configMIDITransUp, NULL },
344 { 611, 121, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, configMIDITransDown, NULL },344 { 611, 120, 18, 13, 1, 4, ARROW_DOWN_STRING, NULL, configMIDITransDown, NULL },
345 { 556, 158, 22, 13, 1, 4, ARROW_LEFT_STRING, NULL, configMIDISensDown, NULL },345 { 556, 158, 22, 13, 1, 4, ARROW_LEFT_STRING, NULL, configMIDISensDown, NULL },
346 { 607, 158, 22, 13, 1, 4, ARROW_RIGHT_STRING, NULL, configMIDISensUp, NULL },346 { 607, 158, 22, 13, 1, 4, ARROW_RIGHT_STRING, NULL, configMIDISensUp, NULL },
347 347
@@ -377,8 +377,8 @@ pushButton_t pushButtons[NUM_PUSHBUTTONS] = · 29 unmodified lines
377 { 134, 2, 31, 13, 0, 0, "../", NULL, NULL, pbDiskOpParent },377 { 134, 2, 31, 13, 0, 0, "../", NULL, NULL, pbDiskOpParent },
378 { 134, 16, 31, 12, 0, 0, "/", NULL, NULL, pbDiskOpRoot },378 { 134, 16, 31, 12, 0, 0, "/", NULL, NULL, pbDiskOpRoot },
379#endif379#endif
380 { 335, 2, 18, 13, 0, 0, ARROW_UP_STRING, NULL, pbDiskOpListUp, NULL },380 { 335, 2, 18, 13, 1, 3, ARROW_UP_STRING, NULL, pbDiskOpListUp, NULL },
381 { 335, 158, 18, 13, 0, 0, ARROW_DOWN_STRING, NULL, pbDiskOpListDown, NULL },381 { 335, 158, 18, 13, 1, 3, ARROW_DOWN_STRING, NULL, pbDiskOpListDown, NULL },
382 382
383 // ------ WAV RENDERER PUSHBUTTONS ------383 // ------ WAV RENDERER PUSHBUTTONS ------
384 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp384 //x, y, w, h, p, d, text #1, text #2, funcOnDown, funcOnUp
@@ -539,10 +539,10 @@ void handlePushButtonsWhileMouseDown(void) · 154 unmodified lines
539 {539 {
540 // button delay stuff540 // button delay stuff
541 if (mouse.rightButtonPressed)541 if (mouse.rightButtonPressed)
542 buttonDelay = pushButton->delayFrames / 2;542 buttonDelay = pushButton->delayFrames >> 1;
543 else if (pushButton->preDelay == 2 && (!mouse.firstTimePressingButton && ++tmpCounter >= 20)) // special mode543 else if (pushButton->preDelay == 2 && (!mouse.firstTimePressingButton && ++tmpCounter >= 50)) // special mode
544 buttonDelay = 0;544 buttonDelay = 0;
545 else 545 else
546 buttonDelay = pushButton->delayFrames;546 buttonDelay = pushButton->delayFrames;
547 547
548 // main repeat delay548 // main repeat delay
src/ft2_pushbuttons.h+1−1
@@ -342,7 +342,7 @@ enum · 341 unmodified lines
342};342};
343 343
344// amount of frames to wait344// amount of frames to wait
345#define BUTTON_DOWN_DELAY 16345#define BUTTON_DOWN_DELAY 25
346 346
347// font #1/#2 special characters (used for buttons)347// font #1/#2 special characters (used for buttons)
348#define ARROW_UP_STRING "\x05"348#define ARROW_UP_STRING "\x05"
src/ft2_radiobuttons.c+10−11
@@ -30,12 +30,12 @@ radioButton_t radioButtons[NUM_RADIOBUTTONS] = · 29 unmodified lines
30 30
31 // ------ HELP SCREEN RADIOBUTTONS ------31 // ------ HELP SCREEN RADIOBUTTONS ------
32 //x, y, w, group, funcOnUp32 //x, y, w, group, funcOnUp
33 { 5, 16, 68, RB_GROUP_HELP, rbHelpFeatures },33 { 5, 18, 69, RB_GROUP_HELP, rbHelpFeatures },
34 { 5, 31, 59, RB_GROUP_HELP, rbHelpEffects },34 { 5, 34, 60, RB_GROUP_HELP, rbHelpEffects },
35 { 5, 46, 70, RB_GROUP_HELP, rbHelpKeyboard },35 { 5, 50, 71, RB_GROUP_HELP, rbHelpKeyboard },
36 { 5, 61, 108, RB_GROUP_HELP, rbHelpHowToUseFT2 },36 { 5, 66, 109, RB_GROUP_HELP, rbHelpHowToUseFT2 },
37 { 5, 76, 100, RB_GROUP_HELP, rbHelpFAQ },37 { 5, 82, 101, RB_GROUP_HELP, rbHelpFAQ },
38 { 5, 91, 85, RB_GROUP_HELP, rbHelpKnownBugs },38 { 5, 98, 86, RB_GROUP_HELP, rbHelpKnownBugs },
39 39
40 // ------ NIBBLES SCREEN RADIOBUTTONS ------40 // ------ NIBBLES SCREEN RADIOBUTTONS ------
41 //x, y, w, group, funcOnUp41 //x, y, w, group, funcOnUp
@@ -63,12 +63,11 @@ radioButton_t radioButtons[NUM_RADIOBUTTONS] = · 21 unmodified lines
63 63
64 // ------ CONFIG SCREEN LEFT RADIOBUTTONS ------64 // ------ CONFIG SCREEN LEFT RADIOBUTTONS ------
65 //x, y, w, group, funcOnUp65 //x, y, w, group, funcOnUp
66 { 4, 19, 87, RB_GROUP_CONFIG_SELECT, rbConfigIODevices },66 { 5, 18, 85, RB_GROUP_CONFIG_SELECT, rbConfigIODevices },
67 { 4, 35, 59, RB_GROUP_CONFIG_SELECT, rbConfigLayout },67 { 5, 34, 57, RB_GROUP_CONFIG_SELECT, rbConfigLayout },
68 { 4, 51, 99, RB_GROUP_CONFIG_SELECT, rbConfigMiscellaneous },68 { 5, 50, 97, RB_GROUP_CONFIG_SELECT, rbConfigMiscellaneous },
69
70#ifdef HAS_MIDI69#ifdef HAS_MIDI
71 { 4, 67, 74, RB_GROUP_CONFIG_SELECT, rbConfigMidiInput },70 { 5, 66, 72, RB_GROUP_CONFIG_SELECT, rbConfigMidiInput },
72#endif71#endif
73 72
74 // ------ CONFIG AUDIO ------73 // ------ CONFIG AUDIO ------
src/ft2_replayer.c+13−12
@@ -26,8 +26,7 @@ · 25 unmodified lines
26*/26*/
27 27
28static bool bxxOverflow;28static bool bxxOverflow;
29static uint16_t oldPeriod;29static int32_t oldPeriod, oldRate, frequenceDivFactor, frequenceMulFactor;
30static uint32_t oldRate, frequenceDivFactor, frequenceMulFactor;
31static tonTyp nilPatternLine;30static tonTyp nilPatternLine;
32 31
33// globally accessed32// globally accessed
@@ -230,6 +229,8 @@ void setFrqTab(bool linear) · 196 unmodified lines
230 note2Period = amigaPeriods;229 note2Period = amigaPeriods;
231 }230 }
232 231
232 resetCachedFrequencyVars();
233
233 // update "frequency table" radiobutton, if it's shown234 // update "frequency table" radiobutton, if it's shown
234 if (editor.ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES)235 if (editor.ui.configScreenShown && editor.currConfigScreen == CONFIG_SCREEN_IO_DEVICES)
235 setConfigIORadioButtonStates();236 setConfigIORadioButtonStates();
@@ -367,7 +368,7 @@ uint32_t getFrequenceValue(uint16_t period) · 131 unmodified lines
367 indexQuotient = index / 768;368 indexQuotient = index / 768;
368 indexRemainder = index % 768;369 indexRemainder = index % 768;
369 370
370 rate = ((uint64_t)logTab[indexRemainder] * frequenceMulFactor) >> LOG_TABLE_BITS;371 rate = ((int64_t)logTab[indexRemainder] * frequenceMulFactor) >> LOG_TABLE_BITS;
371 372
372 shift = (14 - indexQuotient) & 0x1F;373 shift = (14 - indexQuotient) & 0x1F;
373 if (shift != 0)374 if (shift != 0)
@@ -384,13 +385,13 @@ uint32_t getFrequenceValue(uint16_t period) · 10 unmodified lines
384 return rate;385 return rate;
385}386}
386 387
387void resetOldRates(void)388void resetCachedFrequencyVars(void)
388{389{
389 oldPeriod = 0;390 oldPeriod = -1;
390 oldRate = 0;391 oldRate = 0;
391 392
392 resetOldScopeRates();393 resetCachedScopeVars();
393 resetOldRevFreqs();394 resetCachedMixerVars();
394}395}
395 396
396static void startTone(uint8_t ton, uint8_t effTyp, uint8_t eff, stmTyp *ch)397static 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
1320 ** Also, vol envelope range is now 0..16384 instead of being shifted to 0..641321 ** Also, vol envelope range is now 0..16384 instead of being shifted to 0..64
1321 */1322 */
1322 1323
1323 uint32_t vol1 = song.globVol * ch->outVol * ch->fadeOutAmp; // 0..64 * 0..64 * 0..32768 = 0..1342177281324 int32_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..20971521325 int32_t vol2 = envVal << 7; // 0..16384 * 2^7 = 0..2097152
1325 1326
1326 vol = ((uint64_t)vol1 * vol2) >> 32; // 0..655361327 vol = ((int64_t)vol1 * vol2) >> 32; // 0..65536
1327 1328
1328 ch->status |= IS_Vol;1329 ch->status |= IS_Vol;
1329 }1330 }
1330 else1331 else
1331 {1332 {
1332 // calculate with four times more precision (finalVol = 0..65535)1333 // 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..655361334 vol = ((song.globVol * ch->outVol * ch->fadeOutAmp) + (1 << 10)) >> 11; // 0..64 * 0..64 * 0..32768 -> 0..65536 (rounded)
1334 }1335 }
1335 1336
1336 if (vol > 65535)1337 if (vol > 65535)
@@ -3058,7 +3059,7 @@ void stopVoices(void) · 1721 unmodified lines
3058 3059
3059 stopAllScopes();3060 stopAllScopes();
3060 resetAudioDither();3061 resetAudioDither();
3061 resetOldRates();3062 resetCachedFrequencyVars();
3062 3063
3063 // wait for scope thread to finish, so that we know pointers aren't deprecated3064 // wait for scope thread to finish, so that we know pointers aren't deprecated
3064 while (editor.scopeThreadMutex);3065 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
241void fixSampleName(int16_t nr); // removes spaces from right side of ins/smp names241void fixSampleName(int16_t nr); // removes spaces from right side of ins/smp names
242 242
243void calcReplayRate(int32_t rate);243void calcReplayRate(int32_t rate);
244void resetOldRates(void);244void resetCachedFrequencyVars(void);
245void tuneSample(sampleTyp *s, int32_t midCFreq);245void tuneSample(sampleTyp *s, int32_t midCFreq);
246uint32_t getFrequenceValue(uint16_t period);246uint32_t getFrequenceValue(uint16_t period);
247 247
src/ft2_sample_ed.c+22−33
@@ -1013,7 +1013,7 @@ static void writeWaveform(void) · 1012 unmodified lines
1013 1013
1014 viewSizeSamples = smpEd_ViewSize;1014 viewSizeSamples = smpEd_ViewSize;
1015 if (s->typ & 16)1015 if (s->typ & 16)
1016 viewSizeSamples /= 2;1016 viewSizeSamples >>= 1;
1017 1017
1018 if (viewSizeSamples <= SAMPLE_AREA_WIDTH)1018 if (viewSizeSamples <= SAMPLE_AREA_WIDTH)
1019 {1019 {
@@ -1319,17 +1319,12 @@ void scrollSampleDataLeft(void) · 299 unmodified lines
1319 return;1319 return;
1320 1320
1321 if (mouse.rightButtonPressed)1321 if (mouse.rightButtonPressed)
1322 {
1323 scrollAmount = smpEd_ViewSize / 14; // rounded from 16 (70Hz)1322 scrollAmount = smpEd_ViewSize / 14; // rounded from 16 (70Hz)
1324 if (scrollAmount < 1)
1325 scrollAmount = 1;
1326 }
1327 else1323 else
1328 {
1329 scrollAmount = smpEd_ViewSize / 27; // rounded from 32 (70Hz)1324 scrollAmount = smpEd_ViewSize / 27; // rounded from 32 (70Hz)
1330 if (scrollAmount < 1)1325
1331 scrollAmount = 1;1326 if (scrollAmount < 1)
1332 }1327 scrollAmount = 1;
1333 1328
1334 smpEd_ScrPos -= scrollAmount;1329 smpEd_ScrPos -= scrollAmount;
1335 if (smpEd_ScrPos < 0)1330 if (smpEd_ScrPos < 0)
@@ -1351,17 +1346,12 @@ void scrollSampleDataRight(void) · 15 unmodified lines
1351 return;1346 return;
1352 1347
1353 if (mouse.rightButtonPressed)1348 if (mouse.rightButtonPressed)
1354 {
1355 scrollAmount = smpEd_ViewSize / 14; // was 16 (70Hz->60Hz)1349 scrollAmount = smpEd_ViewSize / 14; // was 16 (70Hz->60Hz)
1356 if (scrollAmount < 1)
1357 scrollAmount = 1;
1358 }
1359 else1350 else
1360 {
1361 scrollAmount = smpEd_ViewSize / 27; // was 32 (70Hz->60Hz)1351 scrollAmount = smpEd_ViewSize / 27; // was 32 (70Hz->60Hz)
1362 if (scrollAmount < 1)1352
1363 scrollAmount = 1;1353 if (scrollAmount < 1)
1364 }1354 scrollAmount = 1;
1365 1355
1366 smpEd_ScrPos += scrollAmount;1356 smpEd_ScrPos += scrollAmount;
1367 if (smpEd_ScrPos+smpEd_ViewSize > sampleLen)1357 if (smpEd_ScrPos+smpEd_ViewSize > sampleLen)
@@ -2694,18 +2684,15 @@ void sampMin(void) · 1326 unmodified lines
2694 if (s == NULL || s->pek == NULL || s->len <= 0)2684 if (s == NULL || s->pek == NULL || s->len <= 0)
2695 return;2685 return;
2696 2686
2697 bool hasLoop = s->typ & 3;2687 if (okBox(1, "System request", "Minimize sample?") != 1)
2698 int32_t loopEnd = s->repS + s->repL;2688 return;
2699 2689
2700 if (!hasLoop || (loopEnd >= s->len || loopEnd == 0))2690 bool hasLoop = s->typ & 3;
2701 {2691 if (hasLoop && s->len > s->repS+s->repL && s->repL < s->len)
2702 okBox(0, "System message", "Sample is already minimized.");
2703 }
2704 else
2705 {2692 {
2706 lockMixerCallback();2693 lockMixerCallback();
2707 2694
2708 s->len = loopEnd;2695 s->len = s->repS + s->repL;
2709 2696
2710 newPtr = (int8_t *)realloc(s->origPek, s->len + LOOP_FIX_LEN);2697 newPtr = (int8_t *)realloc(s->origPek, s->len + LOOP_FIX_LEN);
2711 if (newPtr != NULL)2698 if (newPtr != NULL)
@@ -2714,6 +2701,8 @@ void sampMin(void) · 2 unmodified lines
2714 s->pek = s->origPek + SMP_DAT_OFFSET;2701 s->pek = s->origPek + SMP_DAT_OFFSET;
2715 }2702 }
2716 2703
2704 // Note: we don't need to make a call to fixSample()
2705
2717 unlockMixerCallback();2706 unlockMixerCallback();
2718 2707
2719 updateSampleEditorSample();2708 updateSampleEditorSample();
@@ -2897,9 +2886,9 @@ void showSampleEditor(void) · 177 unmodified lines
2897 textOutShadow(371, 369, PAL_FORGRND, PAL_DSKTOP2, "Forward");2886 textOutShadow(371, 369, PAL_FORGRND, PAL_DSKTOP2, "Forward");
2898 textOutShadow(371, 386, PAL_FORGRND, PAL_DSKTOP2, "Pingpong");2887 textOutShadow(371, 386, PAL_FORGRND, PAL_DSKTOP2, "Pingpong");
2899 textOutShadow(446, 369, PAL_FORGRND, PAL_DSKTOP2, "8-bit");2888 textOutShadow(446, 369, PAL_FORGRND, PAL_DSKTOP2, "8-bit");
2900 textOutShadow(445, 385, PAL_FORGRND, PAL_DSKTOP2, "16-bit");2889 textOutShadow(445, 384, PAL_FORGRND, PAL_DSKTOP2, "16-bit");
2901 textOutShadow(488, 349, PAL_FORGRND, PAL_DSKTOP2, "Display");2890 textOutShadow(488, 350, PAL_FORGRND, PAL_DSKTOP2, "Display");
2902 textOutShadow(488, 361, PAL_FORGRND, PAL_DSKTOP2, "Length");2891 textOutShadow(488, 362, PAL_FORGRND, PAL_DSKTOP2, "Length");
2903 textOutShadow(488, 375, PAL_FORGRND, PAL_DSKTOP2, "Repeat");2892 textOutShadow(488, 375, PAL_FORGRND, PAL_DSKTOP2, "Repeat");
2904 textOutShadow(488, 387, PAL_FORGRND, PAL_DSKTOP2, "Replen.");2893 textOutShadow(488, 387, PAL_FORGRND, PAL_DSKTOP2, "Replen.");
2905 2894
@@ -3233,7 +3222,7 @@ static void editSampleData(bool mouseButtonHeld) · 327 unmodified lines
3233 int32_t y = lastDrawY - vl;3222 int32_t y = lastDrawY - vl;
3234 uint32_t x = lastDrawX - p;3223 uint32_t x = lastDrawX - p;
3235 3224
3236 uint32_t xMul = 0xFFFFFFFF;3225 int32_t xMul = 0xFFFFFFFF;
3237 if (x != 0)3226 if (x != 0)
3238 xMul /= x;3227 xMul /= x;
3239 3228
@@ -3276,7 +3265,7 @@ static void editSampleData(bool mouseButtonHeld) · 36 unmodified lines
3276 int32_t y = lastDrawY - vl;3265 int32_t y = lastDrawY - vl;
3277 uint32_t x = lastDrawX - p;3266 uint32_t x = lastDrawX - p;
3278 3267
3279 uint32_t xMul = 0xFFFFFFFF;3268 int32_t xMul = 0xFFFFFFFF;
3280 if (x != 0)3269 if (x != 0)
3281 xMul /= x;3270 xMul /= x;
3282 3271
@@ -3430,10 +3419,10 @@ void drawSampleEditorExt(void) · 147 unmodified lines
3430 3419
3431 textOutShadow( 4, 96, PAL_FORGRND, PAL_DSKTOP2, "Rng.:");3420 textOutShadow( 4, 96, PAL_FORGRND, PAL_DSKTOP2, "Rng.:");
3432 charOutShadow(91, 95, PAL_FORGRND, PAL_DSKTOP2, '-');3421 charOutShadow(91, 95, PAL_FORGRND, PAL_DSKTOP2, '-');
3433 textOutShadow( 4, 109, PAL_FORGRND, PAL_DSKTOP2, "Range size");3422 textOutShadow( 4, 110, PAL_FORGRND, PAL_DSKTOP2, "Range size");
3434 textOutShadow( 4, 123, PAL_FORGRND, PAL_DSKTOP2, "Copy buf. size");3423 textOutShadow( 4, 124, PAL_FORGRND, PAL_DSKTOP2, "Copy buf. size");
3435 3424
3436 textOutShadow(162, 95, PAL_FORGRND, PAL_DSKTOP2, "Src.instr.");3425 textOutShadow(162, 96, PAL_FORGRND, PAL_DSKTOP2, "Src.instr.");
3437 textOutShadow(245, 96, PAL_FORGRND, PAL_DSKTOP2, "smp.");3426 textOutShadow(245, 96, PAL_FORGRND, PAL_DSKTOP2, "smp.");
3438 textOutShadow(162, 109, PAL_FORGRND, PAL_DSKTOP2, "Dest.instr.");3427 textOutShadow(162, 109, PAL_FORGRND, PAL_DSKTOP2, "Dest.instr.");
3439 textOutShadow(245, 109, PAL_FORGRND, PAL_DSKTOP2, "smp.");3428 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
121 p1 = s->pek;121 p1 = s->pek;
122 122
123 // don't use the potentially clamped newLen value here123 // 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 delta124 delta64 = ((int64_t)s->len << 32) / (int64_t)(s->len * dLenMul); // 32.32 fixed point delta
125 125
126 posFrac64 = 0; // 32.32 fixed point position.fraction126 posFrac64 = 0; // 32.32 fixed point position.fraction
127 127
@@ -660,8 +660,8 @@ static void drawEchoBox(void) · 532 unmodified lines
660 hLine(x + 2, y + h - 3, w - 4, PAL_BUTTON1);660 hLine(x + 2, y + h - 3, w - 4, PAL_BUTTON1);
661 661
662 textOutShadow(177, 226, PAL_FORGRND, PAL_BUTTON2, "Number of echoes");662 textOutShadow(177, 226, PAL_FORGRND, PAL_BUTTON2, "Number of echoes");
663 textOutShadow(177, 239, PAL_FORGRND, PAL_BUTTON2, "Echo distance");663 textOutShadow(177, 240, PAL_FORGRND, PAL_BUTTON2, "Echo distance");
664 textOutShadow(177, 253, PAL_FORGRND, PAL_BUTTON2, "Fade out");664 textOutShadow(177, 254, PAL_FORGRND, PAL_BUTTON2, "Fade out");
665 textOutShadow(192, 270, PAL_FORGRND, PAL_BUTTON2, "Add memory to sample");665 textOutShadow(192, 270, PAL_FORGRND, PAL_BUTTON2, "Add memory to sample");
666 666
667 assert(echo_nEcho <= 1024);667 assert(echo_nEcho <= 1024);
@@ -1510,7 +1510,7 @@ static void drawSampleVolumeBox(void) · 842 unmodified lines
1510 hLine(x + 2, y + h - 3, w - 4, PAL_BUTTON1);1510 hLine(x + 2, y + h - 3, w - 4, PAL_BUTTON1);
1511 1511
1512 textOutShadow(172, 236, PAL_FORGRND, PAL_BUTTON2, "Start volume");1512 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");
1514 charOutShadow(282, 236, PAL_FORGRND, PAL_BUTTON2, '%');1514 charOutShadow(282, 236, PAL_FORGRND, PAL_BUTTON2, '%');
1515 charOutShadow(282, 250, PAL_FORGRND, PAL_BUTTON2, '%');1515 charOutShadow(282, 250, PAL_FORGRND, PAL_BUTTON2, '%');
1516 1516
src/ft2_scopes.c+6−5
@@ -48,9 +48,9 @@ static uint8_t *scopeMuteBMP_Ptrs[16]; · 47 unmodified lines
48 48
49lastChInstr_t lastChInstr[MAX_VOICES]; // global49lastChInstr_t lastChInstr[MAX_VOICES]; // global
50 50
51void resetOldScopeRates(void)51void resetCachedScopeVars(void)
52{52{
53 oldVoiceDelta = 0;53 oldVoiceDelta = 0xFFFFFFFF;
54 oldSFrq = 0;54 oldSFrq = 0;
55}55}
56 56
@@ -126,6 +126,7 @@ static void setChannel(int32_t nr, bool on) · 69 unmodified lines
126 126
127static void drawScopeNumber(uint16_t scopeXOffs, uint16_t scopeYOffs, uint8_t channel, bool outline)127static void drawScopeNumber(uint16_t scopeXOffs, uint16_t scopeYOffs, uint8_t channel, bool outline)
128{128{
129 scopeXOffs++;
129 scopeYOffs++;130 scopeYOffs++;
130 channel++;131 channel++;
131 132
@@ -313,7 +314,7 @@ bool testScopesMouseDown(void) · 181 unmodified lines
313 return false;314 return false;
314}315}
315 316
316static void scopeTrigger(uint8_t ch, sampleTyp *s, int32_t playOffset)317static void scopeTrigger(int32_t ch, sampleTyp *s, int32_t playOffset)
317{318{
318 bool sampleIs16Bit;319 bool sampleIs16Bit;
319 uint8_t loopType;320 uint8_t loopType;
@@ -522,7 +523,7 @@ void drawScopes(void) · 202 unmodified lines
522 523
523 // draw rec. symbol (if enabled)524 // draw rec. symbol (if enabled)
524 if (config.multiRecChn[i])525 if (config.multiRecChn[i])
525 blit(scopeXOffs, scopeYOffs + 31, bmp.scopeRec, 13, 4);526 blit(scopeXOffs + 1, scopeYOffs + 31, bmp.scopeRec, 13, 4);
526 527
527 scopeXOffs += scopeDrawLen + 3; // align x to next scope528 scopeXOffs += scopeDrawLen + 3; // align x to next scope
528 }529 }
@@ -572,7 +573,7 @@ void handleScopesFromChQueue(chSyncData_t *chSyncData, uint8_t *scopeUpdateStatu · 43 unmodified lines
572 if (instr[ch->instrNr] != NULL)573 if (instr[ch->instrNr] != NULL)
573 {574 {
574 smpPtr = &instr[ch->instrNr]->samp[ch->sampleNr];575 smpPtr = &instr[ch->instrNr]->samp[ch->sampleNr];
575 scopeTrigger((uint8_t)i, smpPtr, ch->smpStartPos);576 scopeTrigger(i, smpPtr, ch->smpStartPos);
576 577
577 // set stuff used by Smp. Ed. for sampling position line578 // set stuff used by Smp. Ed. for sampling position line
578 579
src/ft2_scopes.h+1−1
@@ -4,7 +4,7 @@ · 3 unmodified lines
4#include <stdbool.h>4#include <stdbool.h>
5#include "ft2_header.h"5#include "ft2_header.h"
6 6
7void resetOldScopeRates(void);7void resetCachedScopeVars(void);
8int32_t getSamplePosition(uint8_t ch);8int32_t getSamplePosition(uint8_t ch);
9void stopAllScopes(void);9void stopAllScopes(void);
10void refreshScopes(void);10void 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