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