- Fixed possible crash when starting the program on M1 Macs (thanks kode54) - Fixed possible mouse cursor corruption when hovering over text boxes on Linux - Fixed possibly buggy string operations - Refactored some code that was doing unnecessary/wrong stuff - Minor code cleanup - Updated help text
Unified · Split
| @@ -20,6 +20,11 @@ · 19 unmodified lines | ||
| 20 | 20 | #include "mixer/ft2_silence_mix.h" |
| 21 | 21 | // -------------------------------- |
| 22 | 22 | |
| 23 | +// hide POSIX warnings | |
| 24 | +#ifdef _MSC_VER | |
| 25 | +#pragma warning(disable: 4996) | |
| 26 | +#endif | |
| 27 | + | |
| 23 | 28 | #define INITIAL_DITHER_SEED 0x12345000 |
| 24 | 29 | |
| 25 | 30 | static int8_t pmpCountDiv, pmpChannels = 2; |
| @@ -87,14 +92,7 @@ bool setNewAudioSettings(void) // only call this from the main input/video threa · 61 unmodified lines | ||
| 87 | 92 | audio.currOutputDevice = NULL; |
| 88 | 93 | } |
| 89 | 94 | |
| 90 | − const uint32_t stringLen = (uint32_t)strlen(audio.lastWorkingAudioDeviceName); | |
| 91 | − | |
| 92 | − audio.currOutputDevice = (char *)malloc(stringLen + 2); | |
| 93 | − if (audio.currOutputDevice != NULL) | |
| 94 | − { | |
| 95 | − strcpy(audio.currOutputDevice, audio.lastWorkingAudioDeviceName); | |
| 96 | − audio.currOutputDevice[stringLen + 1] = '\0'; // UTF-8 needs double null termination | |
| 97 | − } | |
| 95 | + audio.currOutputDevice = strdup(audio.lastWorkingAudioDeviceName); | |
| 98 | 96 | } |
| 99 | 97 | |
| 100 | 98 | // also update config audio radio buttons if we're on that screen at the moment |
| @@ -1050,17 +1048,7 @@ static void setLastWorkingAudioDevName(void) · 949 unmodified lines | ||
| 1050 | 1048 | } |
| 1051 | 1049 | |
| 1052 | 1050 | if (audio.currOutputDevice != NULL) |
| 1053 | − { | |
| 1054 | − const uint32_t stringLen = (uint32_t)strlen(audio.currOutputDevice); | |
| 1055 | − | |
| 1056 | − audio.lastWorkingAudioDeviceName = (char *)malloc(stringLen + 2); | |
| 1057 | − if (audio.lastWorkingAudioDeviceName != NULL) | |
| 1058 | − { | |
| 1059 | − if (stringLen > 0) | |
| 1060 | − strcpy(audio.lastWorkingAudioDeviceName, audio.currOutputDevice); | |
| 1061 | − audio.lastWorkingAudioDeviceName[stringLen + 1] = '\0'; // UTF-8 needs double null termination | |
| 1062 | − } | |
| 1063 | − } | |
| 1051 | + audio.lastWorkingAudioDeviceName = strdup(audio.currOutputDevice); | |
| 1064 | 1052 | } |
| 1065 | 1053 | |
| 1066 | 1054 | bool setupAudio(bool showErrorMsg) |
| @@ -13,53 +13,75 @@ · 12 unmodified lines | ||
| 13 | 13 | #include "ft2_audioselector.h" |
| 14 | 14 | #include "ft2_structs.h" |
| 15 | 15 | |
| 16 | −char *getAudioOutputDeviceFromConfig(void) | |
| 16 | +enum | |
| 17 | 17 | { |
| 18 | + INPUT_DEVICE = 0, | |
| 19 | + OUTPUT_DEVICE = 1 | |
| 20 | +}; | |
| 21 | + | |
| 18 | 22 | #define MAX_DEV_STR_LEN 256 |
| 19 | 23 | |
| 20 | − char *devString = (char *)calloc(MAX_DEV_STR_LEN + 1, sizeof (char)); | |
| 21 | − if (devString == NULL) | |
| 24 | +// hide POSIX warnings | |
| 25 | +#ifdef _MSC_VER | |
| 26 | +#pragma warning(disable: 4996) | |
| 27 | +#endif | |
| 28 | + | |
| 29 | +static char *getReasonableAudioDevice(int32_t iscapture) // can and will return NULL | |
| 30 | +{ | |
| 31 | + int32_t numAudioDevs = SDL_GetNumAudioDevices(iscapture); | |
| 32 | + if (numAudioDevs == 0 || numAudioDevs > 1) | |
| 33 | + return NULL; // we don't know which audio output device is the default device | |
| 34 | + | |
| 35 | + const char *devName = SDL_GetAudioDeviceName(0, iscapture); | |
| 36 | + if (devName == NULL) | |
| 22 | 37 | return NULL; |
| 23 | 38 | |
| 24 | − FILE *f = UNICHAR_FOPEN(editor.audioDevConfigFileLocation, "r"); | |
| 25 | − if (f == NULL) | |
| 39 | + return strdup(devName); | |
| 40 | +} | |
| 41 | + | |
| 42 | +char *getAudioOutputDeviceFromConfig(void) | |
| 43 | +{ | |
| 44 | + bool audioDeviceRead = false; | |
| 45 | + char *devString = NULL; | |
| 46 | + | |
| 47 | + FILE *f = UNICHAR_FOPEN(editor.audioDevConfigFileLocationU, "r"); | |
| 48 | + if (f != NULL) | |
| 26 | 49 | { |
| 27 | −#if defined(__APPLE__) | |
| 28 | − return NULL; // SDL doesn't return devices in any appreciable order, and device 0 is most certainly not guaranteed to be the current default device | |
| 29 | −#else | |
| 30 | − const char *devStringTmp = SDL_GetAudioDeviceName(0, false); | |
| 31 | − if (devStringTmp == NULL) | |
| 50 | + devString = (char *)malloc(MAX_DEV_STR_LEN+1); | |
| 51 | + if (devString == NULL) | |
| 32 | 52 | { |
| 33 | − free(devString); | |
| 34 | − return NULL; | |
| 53 | + fclose(f); | |
| 54 | + return NULL; // out of memory | |
| 35 | 55 | } |
| 36 | 56 | |
| 37 | − const uint32_t devStringLen = (uint32_t)strlen(devStringTmp); | |
| 57 | + devString[0] = '\0'; | |
| 58 | + fgets(devString, MAX_DEV_STR_LEN, f); | |
| 59 | + fclose(f); | |
| 60 | + | |
| 61 | + const int32_t devStringLen = (int32_t)strlen(devString); | |
| 38 | 62 | if (devStringLen > 0) |
| 39 | − strncpy(devString, devStringTmp, MAX_DEV_STR_LEN); | |
| 40 | − devString[devStringLen+1] = '\0'; // UTF-8 needs double null termination | |
| 41 | −#endif | |
| 42 | − } | |
| 43 | − else | |
| 44 | − { | |
| 45 | − if (fgets(devString, MAX_DEV_STR_LEN, f) == NULL) | |
| 46 | 63 | { |
| 47 | − free(devString); | |
| 48 | − fclose(f); | |
| 49 | − return NULL; | |
| 64 | + if (devString[devStringLen-1] == '\n') | |
| 65 | + devString[devStringLen-1] = ' '; | |
| 66 | + | |
| 67 | + if (!(devStringLen == 1 && devString[0] == ' ')) // space only = no device | |
| 68 | + audioDeviceRead = true; | |
| 50 | 69 | } |
| 70 | + } | |
| 51 | 71 | |
| 52 | − const uint32_t devStringLen = (uint32_t)strlen(devString); | |
| 53 | − if (devString[devStringLen-1] == '\n') | |
| 54 | − devString[devStringLen-1] = '\0'; | |
| 55 | − devString[devStringLen+1] = '\0'; // UTF-8 needs double null termination | |
| 72 | + if (!audioDeviceRead) | |
| 73 | + { | |
| 74 | + if (devString != NULL) | |
| 75 | + free(devString); | |
| 56 | 76 | |
| 57 | −#if defined(__APPLE__) | |
| 58 | − if (devString[0] == '\0') | |
| 59 | − return NULL; // macOS SDL2 locks up indefinitely if fed an empty string for device name | |
| 60 | −#endif | |
| 77 | + devString = getReasonableAudioDevice(OUTPUT_DEVICE); | |
| 78 | + } | |
| 61 | 79 | |
| 62 | − fclose(f); | |
| 80 | + // SDL_OpenAudioDevice() doesn't seem to like an empty audio device string | |
| 81 | + if (devString != NULL && devString[0] == '\0') | |
| 82 | + { | |
| 83 | + free(devString); | |
| 84 | + return NULL; | |
| 63 | 85 | } |
| 64 | 86 | |
| 65 | 87 | return devString; |
| @@ -67,50 +89,48 @@ char *getAudioOutputDeviceFromConfig(void) · 1 unmodified line | ||
| 67 | 89 | |
| 68 | 90 | char *getAudioInputDeviceFromConfig(void) |
| 69 | 91 | { |
| 70 | −#define MAX_DEV_STR_LEN 256 | |
| 92 | + bool audioDeviceRead = false; | |
| 93 | + char *devString = NULL; | |
| 71 | 94 | |
| 72 | − char *devString = (char *)calloc(MAX_DEV_STR_LEN + 1, sizeof (char)); | |
| 73 | − if (devString == NULL) | |
| 74 | − return NULL; | |
| 75 | − | |
| 76 | − FILE *f = UNICHAR_FOPEN(editor.audioDevConfigFileLocation, "r"); | |
| 77 | − if (f == NULL) | |
| 95 | + FILE *f = UNICHAR_FOPEN(editor.audioDevConfigFileLocationU, "r"); | |
| 96 | + if (f != NULL) | |
| 78 | 97 | { |
| 79 | − const char *devStringTmp = SDL_GetAudioDeviceName(0, true); | |
| 80 | − if (devStringTmp == NULL) | |
| 98 | + devString = (char *)malloc(MAX_DEV_STR_LEN+1); | |
| 99 | + if (devString == NULL) | |
| 81 | 100 | { |
| 82 | − free(devString); | |
| 83 | − return NULL; | |
| 101 | + fclose(f); | |
| 102 | + return NULL; // out of memory | |
| 84 | 103 | } |
| 85 | 104 | |
| 86 | − const uint32_t devStringLen = (uint32_t)strlen(devStringTmp); | |
| 105 | + devString[0] = '\0'; | |
| 106 | + fgets(devString, MAX_DEV_STR_LEN, f); // skip first line (we want the input device) | |
| 107 | + fgets(devString, MAX_DEV_STR_LEN, f); | |
| 108 | + fclose(f); | |
| 109 | + | |
| 110 | + const int32_t devStringLen = (int32_t)strlen(devString); | |
| 87 | 111 | if (devStringLen > 0) |
| 88 | − strncpy(devString, devStringTmp, MAX_DEV_STR_LEN); | |
| 89 | − devString[devStringLen+1] = '\0'; // UTF-8 needs double null termination | |
| 90 | − } | |
| 91 | − else | |
| 92 | − { | |
| 93 | − if (fgets(devString, MAX_DEV_STR_LEN, f) == NULL) | |
| 94 | 112 | { |
| 95 | − free(devString); | |
| 96 | − fclose(f); | |
| 97 | − return NULL; | |
| 113 | + if (devString[devStringLen-1] == '\n') | |
| 114 | + devString[devStringLen-1] = ' '; | |
| 115 | + | |
| 116 | + if (!(devStringLen == 1 && devString[0] == ' ')) // space only = no device | |
| 117 | + audioDeviceRead = true; | |
| 98 | 118 | } |
| 119 | + } | |
| 99 | 120 | |
| 100 | − // do it one more time (next line) | |
| 101 | − if (fgets(devString, MAX_DEV_STR_LEN, f) == NULL) | |
| 102 | − { | |
| 121 | + if (!audioDeviceRead) | |
| 122 | + { | |
| 123 | + if (devString != NULL) | |
| 103 | 124 | free(devString); |
| 104 | − fclose(f); | |
| 105 | − return NULL; | |
| 106 | − } | |
| 107 | 125 | |
| 108 | − const uint32_t devStringLen = (uint32_t)strlen(devString); | |
| 109 | − if (devString[devStringLen-1] == '\n') | |
| 110 | − devString[devStringLen-1] = '\0'; | |
| 111 | − devString[devStringLen+1] = '\0'; // UTF-8 needs double null termination | |
| 126 | + devString = getReasonableAudioDevice(INPUT_DEVICE); | |
| 127 | + } | |
| 112 | 128 | |
| 113 | − fclose(f); | |
| 129 | + // SDL_OpenAudioDevice() doesn't seem to like an empty audio device string | |
| 130 | + if (devString != NULL && devString[0] == '\0') | |
| 131 | + { | |
| 132 | + free(devString); | |
| 133 | + return NULL; | |
| 114 | 134 | } |
| 115 | 135 | |
| 116 | 136 | return devString; |
| @@ -118,15 +138,21 @@ char *getAudioInputDeviceFromConfig(void) · 1 unmodified line | ||
| 118 | 138 | |
| 119 | 139 | bool saveAudioDevicesToConfig(const char *outputDevice, const char *inputDevice) |
| 120 | 140 | { |
| 121 | − FILE *f = UNICHAR_FOPEN(editor.audioDevConfigFileLocation, "w"); | |
| 141 | + FILE *f = UNICHAR_FOPEN(editor.audioDevConfigFileLocationU, "w"); | |
| 122 | 142 | if (f == NULL) |
| 123 | 143 | return false; |
| 124 | 144 | |
| 125 | 145 | if (outputDevice != NULL) |
| 126 | 146 | fputs(outputDevice, f); |
| 147 | + else | |
| 148 | + fputc(' ', f); | |
| 149 | + | |
| 127 | 150 | fputc('\n', f); |
| 151 | + | |
| 128 | 152 | if (inputDevice != NULL) |
| 129 | 153 | fputs(inputDevice, f); |
| 154 | + else | |
| 155 | + fputc(' ', f); | |
| 130 | 156 | |
| 131 | 157 | fclose(f); |
| 132 | 158 | return true; |
| @@ -231,13 +257,14 @@ bool testAudioDeviceListsMouseDown(void) · 98 unmodified lines | ||
| 231 | 257 | |
| 232 | 258 | const uint32_t devStringLen = (uint32_t)strlen(devString); |
| 233 | 259 | |
| 234 | − audio.currOutputDevice = (char *)malloc(devStringLen + 2); | |
| 260 | + audio.currOutputDevice = (char *)malloc(devStringLen+1); | |
| 235 | 261 | if (audio.currOutputDevice == NULL) |
| 236 | 262 | return true; |
| 237 | 263 | |
| 264 | + audio.currOutputDevice[0] = '\0'; | |
| 265 | + | |
| 238 | 266 | if (devStringLen > 0) |
| 239 | 267 | strcpy(audio.currOutputDevice, devString); |
| 240 | − audio.currOutputDevice[devStringLen+1] = '\0'; // UTF-8 needs double null termination | |
| 241 | 268 | |
| 242 | 269 | if (!setNewAudioSettings()) |
| 243 | 270 | okBox(0, "System message", "Couldn't open audio input device!"); |
| @@ -263,13 +290,14 @@ bool testAudioDeviceListsMouseDown(void) · 19 unmodified lines | ||
| 263 | 290 | |
| 264 | 291 | const uint32_t devStringLen = (uint32_t)strlen(devString); |
| 265 | 292 | |
| 266 | − audio.currInputDevice = (char *)malloc(devStringLen + 2); | |
| 293 | + audio.currInputDevice = (char *)malloc(devStringLen+1); | |
| 267 | 294 | if (audio.currInputDevice == NULL) |
| 268 | 295 | return true; |
| 269 | 296 | |
| 297 | + audio.currInputDevice[0] = '\0'; | |
| 298 | + | |
| 270 | 299 | if (devStringLen > 0) |
| 271 | 300 | strcpy(audio.currInputDevice, devString); |
| 272 | − audio.currInputDevice[devStringLen+1] = '\0'; // UTF-8 needs double null termination | |
| 273 | 301 | |
| 274 | 302 | drawAudioInputList(); |
| 275 | 303 | } |
| @@ -303,10 +331,10 @@ void freeAudioDeviceLists(void) · 27 unmodified lines | ||
| 303 | 331 | |
| 304 | 332 | void freeAudioDeviceSelectorBuffers(void) |
| 305 | 333 | { |
| 306 | − if (editor.audioDevConfigFileLocation != NULL) | |
| 334 | + if (editor.audioDevConfigFileLocationU != NULL) | |
| 307 | 335 | { |
| 308 | − free(editor.audioDevConfigFileLocation); | |
| 309 | − editor.audioDevConfigFileLocation = NULL; | |
| 336 | + free(editor.audioDevConfigFileLocationU); | |
| 337 | + editor.audioDevConfigFileLocationU = NULL; | |
| 310 | 338 | } |
| 311 | 339 | |
| 312 | 340 | if (audio.currOutputDevice != NULL) |
| @@ -352,14 +380,12 @@ void setToDefaultAudioOutputDevice(void) · 39 unmodified lines | ||
| 352 | 380 | audio.currOutputDevice = NULL; |
| 353 | 381 | } |
| 354 | 382 | |
| 355 | − audio.currOutputDevice = (char *)malloc(stringLen + 2); | |
| 383 | + audio.currOutputDevice = (char *)malloc(stringLen + 1); | |
| 356 | 384 | if (audio.currOutputDevice == NULL) |
| 357 | 385 | return; |
| 358 | 386 | |
| 359 | 387 | if (stringLen > 0) |
| 360 | 388 | strcpy(audio.currOutputDevice, devString); |
| 361 | − | |
| 362 | − audio.currOutputDevice[stringLen+1] = '\0'; // UTF-8 needs double null termination | |
| 363 | 389 | } |
| 364 | 390 | |
| 365 | 391 | void setToDefaultAudioInputDevice(void) |
| @@ -384,14 +410,12 @@ void setToDefaultAudioInputDevice(void) · 18 unmodified lines | ||
| 384 | 410 | audio.currInputDevice = NULL; |
| 385 | 411 | } |
| 386 | 412 | |
| 387 | − audio.currInputDevice = (char *)malloc(stringLen + 2); | |
| 413 | + audio.currInputDevice = (char *)malloc(stringLen + 1); | |
| 388 | 414 | if (audio.currInputDevice == NULL) |
| 389 | 415 | return; |
| 390 | 416 | |
| 391 | 417 | if (stringLen > 0) |
| 392 | 418 | strcpy(audio.currInputDevice, devString); |
| 393 | − | |
| 394 | − audio.currInputDevice[stringLen+1] = '\0'; // UTF-8 needs double null termination | |
| 395 | 419 | } |
| 396 | 420 | |
| 397 | 421 | void rescanAudioDevices(void) |
| @@ -417,14 +441,12 @@ void rescanAudioDevices(void) · 19 unmodified lines | ||
| 417 | 441 | |
| 418 | 442 | const uint32_t stringLen = (uint32_t)strlen(deviceName); |
| 419 | 443 | |
| 420 | − audio.outputDeviceNames[i] = (char *)malloc(stringLen + 2); | |
| 444 | + audio.outputDeviceNames[i] = (char *)malloc(stringLen + 1); | |
| 421 | 445 | if (audio.outputDeviceNames[i] == NULL) |
| 422 | 446 | break; |
| 423 | 447 | |
| 424 | 448 | if (stringLen > 0) |
| 425 | 449 | strcpy(audio.outputDeviceNames[i], deviceName); |
| 426 | − | |
| 427 | − audio.outputDeviceNames[i][stringLen+1] = '\0'; // UTF-8 needs double null termination | |
| 428 | 450 | } |
| 429 | 451 | |
| 430 | 452 | // GET AUDIO INPUT DEVICES |
| @@ -444,14 +466,12 @@ void rescanAudioDevices(void) · 13 unmodified lines | ||
| 444 | 466 | |
| 445 | 467 | const uint32_t stringLen = (uint32_t)strlen(deviceName); |
| 446 | 468 | |
| 447 | − audio.inputDeviceNames[i] = (char *)malloc(stringLen + 2); | |
| 469 | + audio.inputDeviceNames[i] = (char *)malloc(stringLen + 1); | |
| 448 | 470 | if (audio.inputDeviceNames[i] == NULL) |
| 449 | 471 | break; |
| 450 | 472 | |
| 451 | 473 | if (stringLen > 0) |
| 452 | 474 | strcpy(audio.inputDeviceNames[i], deviceName); |
| 453 | − | |
| 454 | − audio.inputDeviceNames[i][stringLen+1] = '\0'; // UTF-8 needs double null termination | |
| 455 | 475 | } |
| 456 | 476 | |
| 457 | 477 | setScrollBarEnd(SB_AUDIO_OUTPUT_SCROLL, audio.outputDeviceNum); |
| @@ -264,7 +264,7 @@ bool loadConfig(bool showErrorFlag) · 263 unmodified lines | ||
| 264 | 264 | } |
| 265 | 265 | #endif |
| 266 | 266 | |
| 267 | − if (editor.configFileLocation == NULL) | |
| 267 | + if (editor.configFileLocationU == NULL) | |
| 268 | 268 | { |
| 269 | 269 | if (showErrorFlag) |
| 270 | 270 | okBox(0, "System message", "Error opening config file for reading!"); |
| @@ -272,7 +272,7 @@ bool loadConfig(bool showErrorFlag) · 1 unmodified line | ||
| 272 | 272 | return false; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | − FILE *f = UNICHAR_FOPEN(editor.configFileLocation, "rb"); | |
| 275 | + FILE *f = UNICHAR_FOPEN(editor.configFileLocationU, "rb"); | |
| 276 | 276 | if (f == NULL) |
| 277 | 277 | { |
| 278 | 278 | if (showErrorFlag) |
| @@ -353,7 +353,7 @@ void loadConfig2(void) // called by "Load config" button · 74 unmodified lines | ||
| 353 | 353 | |
| 354 | 354 | bool saveConfig(bool showErrorFlag) |
| 355 | 355 | { |
| 356 | − if (editor.configFileLocation == NULL) | |
| 356 | + if (editor.configFileLocationU == NULL) | |
| 357 | 357 | { |
| 358 | 358 | if (showErrorFlag) |
| 359 | 359 | okBox(0, "System message", "General I/O error during saving! Is the file in use?"); |
| @@ -366,7 +366,7 @@ bool saveConfig(bool showErrorFlag) · 6 unmodified lines | ||
| 366 | 366 | saveMidiInputDeviceToConfig(); |
| 367 | 367 | #endif |
| 368 | 368 | |
| 369 | − FILE *f = UNICHAR_FOPEN(editor.configFileLocation, "wb"); | |
| 369 | + FILE *f = UNICHAR_FOPEN(editor.configFileLocationU, "wb"); | |
| 370 | 370 | if (f == NULL) |
| 371 | 371 | { |
| 372 | 372 | if (showErrorFlag) |
| @@ -410,14 +410,14 @@ void saveConfig2(void) // called by "Save config" button · 37 unmodified lines | ||
| 410 | 410 | saveConfig(CONFIG_SHOW_ERRORS); |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | −static UNICHAR *getFullAudDevConfigPath(void) // kinda hackish | |
| 413 | +static UNICHAR *getFullAudDevConfigPathU(void) // kinda hackish | |
| 414 | 414 | { |
| 415 | 415 | int32_t audiodevDotIniStrLen, ft2DotCfgStrLen; |
| 416 | 416 | |
| 417 | − if (editor.configFileLocation == NULL) | |
| 417 | + if (editor.configFileLocationU == NULL) | |
| 418 | 418 | return NULL; |
| 419 | 419 | |
| 420 | − const int32_t ft2ConfPathLen = (int32_t)UNICHAR_STRLEN(editor.configFileLocation); | |
| 420 | + const int32_t ft2ConfPathLen = (int32_t)UNICHAR_STRLEN(editor.configFileLocationU); | |
| 421 | 421 | |
| 422 | 422 | #ifdef _WIN32 |
| 423 | 423 | audiodevDotIniStrLen = (int32_t)UNICHAR_STRLEN(L"audiodev.ini"); |
| @@ -427,31 +427,29 @@ static UNICHAR *getFullAudDevConfigPath(void) // kinda hackish · 3 unmodified lines | ||
| 427 | 427 | ft2DotCfgStrLen = (int32_t)UNICHAR_STRLEN("FT2.CFG"); |
| 428 | 428 | #endif |
| 429 | 429 | |
| 430 | − UNICHAR *filePath = (UNICHAR *)calloc(ft2ConfPathLen + audiodevDotIniStrLen + 2, sizeof (UNICHAR)); | |
| 430 | + UNICHAR *filePathU = (UNICHAR *)malloc((ft2ConfPathLen + audiodevDotIniStrLen + 1) * sizeof (UNICHAR)); | |
| 431 | + filePathU[0] = 0; | |
| 431 | 432 | |
| 432 | − UNICHAR_STRCPY(filePath, editor.configFileLocation); | |
| 433 | − | |
| 434 | − const int32_t stringOffset = ft2ConfPathLen - ft2DotCfgStrLen; | |
| 435 | − filePath[stringOffset+0] = '\0'; | |
| 436 | − filePath[stringOffset+1] = '\0'; | |
| 433 | + UNICHAR_STRCPY(filePathU, editor.configFileLocationU); | |
| 434 | + filePathU[ft2ConfPathLen-ft2DotCfgStrLen] = 0; | |
| 437 | 435 | |
| 438 | 436 | #ifdef _WIN32 |
| 439 | − UNICHAR_STRCAT(filePath, L"audiodev.ini"); | |
| 437 | + UNICHAR_STRCAT(filePathU, L"audiodev.ini"); | |
| 440 | 438 | #else |
| 441 | − UNICHAR_STRCAT(filePath, "audiodev.ini"); | |
| 439 | + UNICHAR_STRCAT(filePathU, "audiodev.ini"); | |
| 442 | 440 | #endif |
| 443 | 441 | |
| 444 | − return filePath; | |
| 442 | + return filePathU; | |
| 445 | 443 | } |
| 446 | 444 | |
| 447 | −static UNICHAR *getFullMidiDevConfigPath(void) // kinda hackish | |
| 445 | +static UNICHAR *getFullMidiDevConfigPathU(void) // kinda hackish | |
| 448 | 446 | { |
| 449 | 447 | int32_t mididevDotIniStrLen, ft2DotCfgStrLen; |
| 450 | 448 | |
| 451 | − if (editor.configFileLocation == NULL) | |
| 449 | + if (editor.configFileLocationU == NULL) | |
| 452 | 450 | return NULL; |
| 453 | 451 | |
| 454 | − const int32_t ft2ConfPathLen = (int32_t)UNICHAR_STRLEN(editor.configFileLocation); | |
| 452 | + const int32_t ft2ConfPathLen = (int32_t)UNICHAR_STRLEN(editor.configFileLocationU); | |
| 455 | 453 | |
| 456 | 454 | #ifdef _WIN32 |
| 457 | 455 | mididevDotIniStrLen = (int32_t)UNICHAR_STRLEN(L"mididev.ini"); |
| @@ -461,21 +459,19 @@ static UNICHAR *getFullMidiDevConfigPath(void) // kinda hackish · 3 unmodified lines | ||
| 461 | 459 | ft2DotCfgStrLen = (int32_t)UNICHAR_STRLEN("FT2.CFG"); |
| 462 | 460 | #endif |
| 463 | 461 | |
| 464 | − UNICHAR *filePath = (UNICHAR *)calloc(ft2ConfPathLen + mididevDotIniStrLen + 2, sizeof (UNICHAR)); | |
| 465 | − | |
| 466 | − UNICHAR_STRCPY(filePath, editor.configFileLocation); | |
| 462 | + UNICHAR *filePathU = (UNICHAR *)malloc((ft2ConfPathLen + mididevDotIniStrLen + 1) * sizeof (UNICHAR)); | |
| 463 | + filePathU[0] = 0; | |
| 467 | 464 | |
| 468 | − const int32_t stringOffset = ft2ConfPathLen - ft2DotCfgStrLen; | |
| 469 | − filePath[stringOffset+0] = '\0'; | |
| 470 | − filePath[stringOffset+1] = '\0'; | |
| 465 | + UNICHAR_STRCPY(filePathU, editor.configFileLocationU); | |
| 466 | + filePathU[ft2ConfPathLen-ft2DotCfgStrLen] = 0; | |
| 471 | 467 | |
| 472 | 468 | #ifdef _WIN32 |
| 473 | − UNICHAR_STRCAT(filePath, L"mididev.ini"); | |
| 469 | + UNICHAR_STRCAT(filePathU, L"mididev.ini"); | |
| 474 | 470 | #else |
| 475 | − UNICHAR_STRCAT(filePath, "mididev.ini"); | |
| 471 | + UNICHAR_STRCAT(filePathU, "mididev.ini"); | |
| 476 | 472 | #endif |
| 477 | 473 | |
| 478 | − return filePath; | |
| 474 | + return filePathU; | |
| 479 | 475 | } |
| 480 | 476 | |
| 481 | 477 | static void setConfigFileLocation(void) // kinda hackish |
| @@ -484,41 +480,44 @@ static void setConfigFileLocation(void) // kinda hackish · 2 unmodified lines | ||
| 484 | 480 | #ifdef _WIN32 |
| 485 | 481 | int32_t ft2DotCfgStrLen = (int32_t)UNICHAR_STRLEN(L"FT2.CFG"); |
| 486 | 482 | |
| 487 | − UNICHAR *oldPath = (UNICHAR *)calloc(PATH_MAX + 8 + 2, sizeof (UNICHAR)); | |
| 488 | − UNICHAR *tmpPath = (UNICHAR *)calloc(PATH_MAX + 8 + 2, sizeof (UNICHAR)); | |
| 489 | − editor.configFileLocation = (UNICHAR *)calloc(PATH_MAX + ft2DotCfgStrLen + 2, sizeof (UNICHAR)); | |
| 483 | + UNICHAR *oldPathU = (UNICHAR *)malloc((PATH_MAX + 8 + 1) * sizeof (UNICHAR)); | |
| 484 | + UNICHAR *tmpPathU = (UNICHAR *)malloc((PATH_MAX + 8 + 1) * sizeof (UNICHAR)); | |
| 485 | + editor.configFileLocationU = (UNICHAR *)malloc((PATH_MAX + ft2DotCfgStrLen + 1) * sizeof (UNICHAR)); | |
| 490 | 486 | |
| 491 | − if (oldPath == NULL || tmpPath == NULL || editor.configFileLocation == NULL) | |
| 487 | + if (oldPathU == NULL || tmpPathU == NULL || editor.configFileLocationU == NULL) | |
| 492 | 488 | { |
| 493 | − if (oldPath != NULL) free(oldPath); | |
| 494 | − if (tmpPath != NULL) free(tmpPath); | |
| 495 | − if (editor.configFileLocation != NULL) free(editor.configFileLocation); | |
| 489 | + if (oldPathU != NULL) free(oldPathU); | |
| 490 | + if (tmpPathU != NULL) free(tmpPathU); | |
| 491 | + if (editor.configFileLocationU != NULL) free(editor.configFileLocationU); | |
| 496 | 492 | |
| 497 | − editor.configFileLocation = NULL; | |
| 493 | + editor.configFileLocationU = NULL; | |
| 498 | 494 | showErrorMsgBox("Error: Couldn't set config file location. You can't load/save the config!"); |
| 499 | 495 | return; |
| 500 | 496 | } |
| 501 | 497 | |
| 502 | − if (GetCurrentDirectoryW(PATH_MAX - ft2DotCfgStrLen - 1, oldPath) == 0) | |
| 498 | + oldPathU[0] = 0; | |
| 499 | + tmpPathU[0] = 0; | |
| 500 | + | |
| 501 | + if (GetCurrentDirectoryW(PATH_MAX - ft2DotCfgStrLen - 1, oldPathU) == 0) | |
| 503 | 502 | { |
| 504 | − free(oldPath); | |
| 505 | − free(tmpPath); | |
| 506 | − free(editor.configFileLocation); | |
| 503 | + free(oldPathU); | |
| 504 | + free(tmpPathU); | |
| 505 | + free(editor.configFileLocationU); | |
| 507 | 506 | |
| 508 | − editor.configFileLocation = NULL; | |
| 507 | + editor.configFileLocationU = NULL; | |
| 509 | 508 | showErrorMsgBox("Error: Couldn't set config file location. You can't load/save the config!"); |
| 510 | 509 | return; |
| 511 | 510 | } |
| 512 | 511 | |
| 513 | − UNICHAR_STRCPY(editor.configFileLocation, oldPath); | |
| 512 | + UNICHAR_STRCPY(editor.configFileLocationU, oldPathU); | |
| 514 | 513 | |
| 515 | 514 | FILE *f = fopen("FT2.CFG", "rb"); |
| 516 | 515 | if (f == NULL) // FT2.CFG not found in current dir, try default config dir |
| 517 | 516 | { |
| 518 | − int32_t result = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, tmpPath); | |
| 517 | + int32_t result = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, tmpPathU); | |
| 519 | 518 | if (result == S_OK) |
| 520 | 519 | { |
| 521 | − if (SetCurrentDirectoryW(tmpPath) != 0) | |
| 520 | + if (SetCurrentDirectoryW(tmpPathU) != 0) | |
| 522 | 521 | { |
| 523 | 522 | result = chdir("FT2 clone"); |
| 524 | 523 | if (result != 0) |
| @@ -528,7 +527,7 @@ static void setConfigFileLocation(void) // kinda hackish · 3 unmodified lines | ||
| 528 | 527 | } |
| 529 | 528 | |
| 530 | 529 | if (result == 0) |
| 531 | − GetCurrentDirectoryW(PATH_MAX - ft2DotCfgStrLen - 1, editor.configFileLocation); // we can, set it | |
| 530 | + GetCurrentDirectoryW(PATH_MAX - ft2DotCfgStrLen - 1, editor.configFileLocationU); // we can, set it | |
| 532 | 531 | } |
| 533 | 532 | } |
| 534 | 533 | } |
| @@ -537,27 +536,29 @@ static void setConfigFileLocation(void) // kinda hackish · 2 unmodified lines | ||
| 537 | 536 | fclose(f); |
| 538 | 537 | } |
| 539 | 538 | |
| 540 | − free(tmpPath); | |
| 541 | − SetCurrentDirectoryW(oldPath); | |
| 542 | − free(oldPath); | |
| 539 | + free(tmpPathU); | |
| 540 | + SetCurrentDirectoryW(oldPathU); | |
| 541 | + free(oldPathU); | |
| 543 | 542 | |
| 544 | − UNICHAR_STRCAT(editor.configFileLocation, L"\\FT2.CFG"); | |
| 543 | + UNICHAR_STRCAT(editor.configFileLocationU, L"\\FT2.CFG"); | |
| 545 | 544 | |
| 546 | 545 | // OS X / macOS |
| 547 | 546 | #elif defined __APPLE__ |
| 548 | 547 | int32_t ft2DotCfgStrLen = (int32_t)UNICHAR_STRLEN("FT2.CFG"); |
| 549 | 548 | |
| 550 | − editor.configFileLocation = (UNICHAR *)calloc(PATH_MAX + ft2DotCfgStrLen + 2, sizeof (UNICHAR)); | |
| 551 | − if (editor.configFileLocation == NULL) | |
| 549 | + editor.configFileLocationU = (UNICHAR *)malloc((PATH_MAX + ft2DotCfgStrLen + 1) * sizeof (UNICHAR)); | |
| 550 | + if (editor.configFileLocationU == NULL) | |
| 552 | 551 | { |
| 553 | 552 | showErrorMsgBox("Error: Couldn't set config file location. You can't load/save the config!"); |
| 554 | 553 | return; |
| 555 | 554 | } |
| 556 | 555 | |
| 557 | − if (getcwd(editor.configFileLocation, PATH_MAX - ft2DotCfgStrLen - 1) == NULL) | |
| 556 | + editor.configFileLocationU[0] = 0; | |
| 557 | + | |
| 558 | + if (getcwd(editor.configFileLocationU, PATH_MAX - ft2DotCfgStrLen - 1) == NULL) | |
| 558 | 559 | { |
| 559 | − free(editor.configFileLocation); | |
| 560 | − editor.configFileLocation = NULL; | |
| 560 | + free(editor.configFileLocationU); | |
| 561 | + editor.configFileLocationU = NULL; | |
| 561 | 562 | showErrorMsgBox("Error: Couldn't set config file location. You can't load/save the config!"); |
| 562 | 563 | return; |
| 563 | 564 | } |
| @@ -578,7 +579,7 @@ static void setConfigFileLocation(void) // kinda hackish · 14 unmodified lines | ||
| 578 | 579 | } |
| 579 | 580 | |
| 580 | 581 | if (result == 0) |
| 581 | − getcwd(editor.configFileLocation, PATH_MAX - ft2DotCfgStrLen - 1); | |
| 582 | + getcwd(editor.configFileLocationU, PATH_MAX - ft2DotCfgStrLen - 1); | |
| 582 | 583 | } |
| 583 | 584 | } |
| 584 | 585 | } |
| @@ -587,23 +588,25 @@ static void setConfigFileLocation(void) // kinda hackish · 2 unmodified lines | ||
| 587 | 588 | fclose(f); |
| 588 | 589 | } |
| 589 | 590 | |
| 590 | − strcat(editor.configFileLocation, "/FT2.CFG"); | |
| 591 | + strcat(editor.configFileLocationU, "/FT2.CFG"); | |
| 591 | 592 | |
| 592 | 593 | // Linux etc |
| 593 | 594 | #else |
| 594 | 595 | int32_t ft2DotCfgStrLen = (int32_t)UNICHAR_STRLEN("FT2.CFG"); |
| 595 | 596 | |
| 596 | − editor.configFileLocation = (UNICHAR *)calloc(PATH_MAX + ft2DotCfgStrLen + 2, sizeof (UNICHAR)); | |
| 597 | − if (editor.configFileLocation == NULL) | |
| 597 | + editor.configFileLocationU = (UNICHAR *)malloc((PATH_MAX + ft2DotCfgStrLen + 1) * sizeof (UNICHAR)); | |
| 598 | + if (editor.configFileLocationU == NULL) | |
| 598 | 599 | { |
| 599 | 600 | showErrorMsgBox("Error: Couldn't set config file location. You can't load/save the config!"); |
| 600 | 601 | return; |
| 601 | 602 | } |
| 602 | 603 | |
| 603 | − if (getcwd(editor.configFileLocation, PATH_MAX - ft2DotCfgStrLen - 1) == NULL) | |
| 604 | + editor.configFileLocationU[0] = 0; | |
| 605 | + | |
| 606 | + if (getcwd(editor.configFileLocationU, PATH_MAX - ft2DotCfgStrLen - 1) == NULL) | |
| 604 | 607 | { |
| 605 | − free(editor.configFileLocation); | |
| 606 | − editor.configFileLocation = NULL; | |
| 608 | + free(editor.configFileLocationU); | |
| 609 | + editor.configFileLocationU = NULL; | |
| 607 | 610 | showErrorMsgBox("Error: Couldn't set config file location. You can't load/save the config!"); |
| 608 | 611 | return; |
| 609 | 612 | } |
| @@ -632,7 +635,7 @@ static void setConfigFileLocation(void) // kinda hackish · 22 unmodified lines | ||
| 632 | 635 | } |
| 633 | 636 | |
| 634 | 637 | if (result == 0) |
| 635 | − getcwd(editor.configFileLocation, PATH_MAX - ft2DotCfgStrLen - 1); | |
| 638 | + getcwd(editor.configFileLocationU, PATH_MAX - ft2DotCfgStrLen - 1); | |
| 636 | 639 | } |
| 637 | 640 | } |
| 638 | 641 | else |
| @@ -640,23 +643,23 @@ static void setConfigFileLocation(void) // kinda hackish · 1 unmodified line | ||
| 640 | 643 | fclose(f); |
| 641 | 644 | } |
| 642 | 645 | |
| 643 | − strcat(editor.configFileLocation, "/FT2.CFG"); | |
| 646 | + strcat(editor.configFileLocationU, "/FT2.CFG"); | |
| 644 | 647 | #endif |
| 645 | 648 | |
| 646 | − editor.midiConfigFileLocation = getFullMidiDevConfigPath(); | |
| 647 | − editor.audioDevConfigFileLocation = getFullAudDevConfigPath(); | |
| 649 | + editor.midiConfigFileLocationU = getFullMidiDevConfigPathU(); | |
| 650 | + editor.audioDevConfigFileLocationU = getFullAudDevConfigPathU(); | |
| 648 | 651 | } |
| 649 | 652 | |
| 650 | 653 | void loadConfigOrSetDefaults(void) |
| 651 | 654 | { |
| 652 | 655 | setConfigFileLocation(); |
| 653 | − if (editor.configFileLocation == NULL) | |
| 656 | + if (editor.configFileLocationU == NULL) | |
| 654 | 657 | { |
| 655 | 658 | setDefaultConfigSettings(); |
| 656 | 659 | return; |
| 657 | 660 | } |
| 658 | 661 | |
| 659 | − FILE *f = UNICHAR_FOPEN(editor.configFileLocation, "rb"); | |
| 662 | + FILE *f = UNICHAR_FOPEN(editor.configFileLocationU, "rb"); | |
| 660 | 663 | if (f == NULL) |
| 661 | 664 | { |
| 662 | 665 | setDefaultConfigSettings(); |
| @@ -72,7 +72,7 @@ typedef struct DirRec · 71 unmodified lines | ||
| 72 | 72 | int32_t filesize; |
| 73 | 73 | } DirRec; |
| 74 | 74 | |
| 75 | −static char FReq_SysReqText[196], *FReq_FileName, *FReq_NameTemp; | |
| 75 | +static char FReq_SysReqText[256], *FReq_FileName, *FReq_NameTemp; | |
| 76 | 76 | static char *modTmpFName, *insTmpFName, *smpTmpFName, *patTmpFName, *trkTmpFName; |
| 77 | 77 | static char *modTmpFNameUTF8; // for window title |
| 78 | 78 | static uint8_t FReq_Item; |
| @@ -84,6 +84,18 @@ static SDL_Thread *thread; · 5 unmodified lines | ||
| 84 | 84 | |
| 85 | 85 | static void setDiskOpItem(uint8_t item); |
| 86 | 86 | |
| 87 | +bool setupExecutablePath(void) | |
| 88 | +{ | |
| 89 | + editor.binaryPathU = (UNICHAR *)malloc((PATH_MAX + 1) * sizeof (UNICHAR)); | |
| 90 | + if (editor.binaryPathU == NULL) | |
| 91 | + return false; | |
| 92 | + | |
| 93 | + editor.binaryPathU[0] = 0; | |
| 94 | + UNICHAR_GETCWD(editor.binaryPathU, PATH_MAX); | |
| 95 | + | |
| 96 | + return true; | |
| 97 | +} | |
| 98 | + | |
| 87 | 99 | int32_t getFileSize(UNICHAR *fileNameU) // returning -1 = filesize over 2GB |
| 88 | 100 | { |
| 89 | 101 | int64_t fSize; |
| @@ -173,56 +185,70 @@ static void setupInitialPaths(void) · 83 unmodified lines | ||
| 173 | 185 | |
| 174 | 186 | #ifdef _WIN32 |
| 175 | 187 | if (config.modulesPath[0] != '\0') |
| 188 | + { | |
| 176 | 189 | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, config.modulesPath, -1, FReq_ModCurPathU, 80); |
| 190 | + FReq_ModCurPathU[80] = 0; | |
| 191 | + } | |
| 177 | 192 | |
| 178 | 193 | if (config.instrPath[0] != '\0') |
| 179 | 194 | { |
| 180 | 195 | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, config.instrPath, -1, FReq_InsCurPathU, 80); |
| 196 | + FReq_InsCurPathU[80] = 0; | |
| 181 | 197 | insPathSet = true; |
| 182 | 198 | } |
| 183 | 199 | |
| 184 | 200 | if (config.samplesPath[0] != '\0') |
| 185 | 201 | { |
| 186 | 202 | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, config.samplesPath, -1, FReq_SmpCurPathU, 80); |
| 203 | + FReq_SmpCurPathU[80] = 0; | |
| 187 | 204 | smpPathSet = true; |
| 188 | 205 | } |
| 189 | 206 | |
| 190 | 207 | if (config.patternsPath[0] != '\0') |
| 191 | 208 | { |
| 192 | 209 | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, config.patternsPath, -1, FReq_PatCurPathU, 80); |
| 210 | + FReq_PatCurPathU[80] = 0; | |
| 193 | 211 | patPathSet = true; |
| 194 | 212 | } |
| 195 | 213 | |
| 196 | 214 | if (config.tracksPath[0] != '\0') |
| 197 | 215 | { |
| 198 | 216 | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, config.tracksPath, -1, FReq_TrkCurPathU, 80); |
| 217 | + FReq_TrkCurPathU[80] = 0; | |
| 199 | 218 | trkPathSet = true; |
| 200 | 219 | } |
| 201 | 220 | #else |
| 202 | 221 | if (config.modulesPath[0] != '\0') |
| 222 | + { | |
| 203 | 223 | strncpy(FReq_ModCurPathU, config.modulesPath, 80); |
| 224 | + FReq_ModCurPathU[80] = 0; | |
| 225 | + } | |
| 204 | 226 | |
| 205 | 227 | if (config.instrPath[0] != '\0') |
| 206 | 228 | { |
| 207 | 229 | strncpy(FReq_InsCurPathU, config.instrPath, 80); |
| 230 | + FReq_InsCurPathU[80] = 0; | |
| 208 | 231 | insPathSet = true; |
| 209 | 232 | } |
| 210 | 233 | |
| 211 | 234 | if (config.samplesPath[0] != '\0') |
| 212 | 235 | { |
| 213 | 236 | strncpy(FReq_SmpCurPathU, config.samplesPath, 80); |
| 237 | + FReq_SmpCurPathU[80] = 0; | |
| 214 | 238 | smpPathSet = true; |
| 215 | 239 | } |
| 216 | 240 | |
| 217 | 241 | if (config.patternsPath[0] != '\0') |
| 218 | 242 | { |
| 219 | 243 | strncpy(FReq_PatCurPathU, config.patternsPath, 80); |
| 244 | + FReq_PatCurPathU[80] = 0; | |
| 220 | 245 | patPathSet = true; |
| 221 | 246 | } |
| 222 | 247 | |
| 223 | 248 | if (config.tracksPath[0] != '\0') |
| 224 | 249 | { |
| 225 | 250 | strncpy(FReq_TrkCurPathU, config.tracksPath, 80); |
| 251 | + FReq_TrkCurPathU[80] = 0; | |
| 226 | 252 | trkPathSet = true; |
| 227 | 253 | } |
| 228 | 254 | #endif |
| @@ -277,28 +303,42 @@ void freeDiskOp(void) · 48 unmodified lines | ||
| 277 | 303 | |
| 278 | 304 | bool setupDiskOp(void) |
| 279 | 305 | { |
| 280 | − modTmpFName = (char *)calloc(PATH_MAX + 1, sizeof (char)); | |
| 281 | − insTmpFName = (char *)calloc(PATH_MAX + 1, sizeof (char)); | |
| 282 | − smpTmpFName = (char *)calloc(PATH_MAX + 1, sizeof (char)); | |
| 283 | − patTmpFName = (char *)calloc(PATH_MAX + 1, sizeof (char)); | |
| 284 | − trkTmpFName = (char *)calloc(PATH_MAX + 1, sizeof (char)); | |
| 285 | − FReq_NameTemp = (char *)calloc(PATH_MAX + 1, sizeof (char)); | |
| 286 | − FReq_ModCurPathU = (UNICHAR *)calloc(PATH_MAX + 2, sizeof (UNICHAR)); | |
| 287 | − FReq_InsCurPathU = (UNICHAR *)calloc(PATH_MAX + 2, sizeof (UNICHAR)); | |
| 288 | − FReq_SmpCurPathU = (UNICHAR *)calloc(PATH_MAX + 2, sizeof (UNICHAR)); | |
| 289 | − FReq_PatCurPathU = (UNICHAR *)calloc(PATH_MAX + 2, sizeof (UNICHAR)); | |
| 290 | − FReq_TrkCurPathU = (UNICHAR *)calloc(PATH_MAX + 2, sizeof (UNICHAR)); | |
| 291 | − | |
| 292 | − if (modTmpFName == NULL || insTmpFName == NULL || smpTmpFName == NULL || patTmpFName == NULL || | |
| 293 | − trkTmpFName == NULL || FReq_NameTemp == NULL || FReq_ModCurPathU == NULL || | |
| 294 | − FReq_InsCurPathU == NULL || FReq_SmpCurPathU == NULL || FReq_PatCurPathU == NULL || | |
| 295 | − FReq_TrkCurPathU == NULL) | |
| 306 | + modTmpFName = (char *)malloc((PATH_MAX + 1) * sizeof (char)); | |
| 307 | + insTmpFName = (char *)malloc((PATH_MAX + 1) * sizeof (char)); | |
| 308 | + smpTmpFName = (char *)malloc((PATH_MAX + 1) * sizeof (char)); | |
| 309 | + patTmpFName = (char *)malloc((PATH_MAX + 1) * sizeof (char)); | |
| 310 | + trkTmpFName = (char *)malloc((PATH_MAX + 1) * sizeof (char)); | |
| 311 | + FReq_NameTemp = (char *)malloc((PATH_MAX + 1) * sizeof (char)); | |
| 312 | + | |
| 313 | + FReq_ModCurPathU = (UNICHAR *)malloc((PATH_MAX + 1) * sizeof (UNICHAR)); | |
| 314 | + FReq_InsCurPathU = (UNICHAR *)malloc((PATH_MAX + 1) * sizeof (UNICHAR)); | |
| 315 | + FReq_SmpCurPathU = (UNICHAR *)malloc((PATH_MAX + 1) * sizeof (UNICHAR)); | |
| 316 | + FReq_PatCurPathU = (UNICHAR *)malloc((PATH_MAX + 1) * sizeof (UNICHAR)); | |
| 317 | + FReq_TrkCurPathU = (UNICHAR *)malloc((PATH_MAX + 1) * sizeof (UNICHAR)); | |
| 318 | + | |
| 319 | + if (modTmpFName == NULL || insTmpFName == NULL || smpTmpFName == NULL || | |
| 320 | + patTmpFName == NULL || trkTmpFName == NULL || FReq_NameTemp == NULL || | |
| 321 | + FReq_ModCurPathU == NULL || FReq_InsCurPathU == NULL || FReq_SmpCurPathU == NULL || | |
| 322 | + FReq_PatCurPathU == NULL || FReq_TrkCurPathU == NULL) | |
| 296 | 323 | { |
| 297 | 324 | // allocated memory is free'd lateron |
| 298 | 325 | showErrorMsgBox("Not enough memory!"); |
| 299 | 326 | return false; |
| 300 | 327 | } |
| 301 | 328 | |
| 329 | + // clear first entry of strings | |
| 330 | + modTmpFName[0] = '\0'; | |
| 331 | + insTmpFName[0] = '\0'; | |
| 332 | + smpTmpFName[0] = '\0'; | |
| 333 | + patTmpFName[0] = '\0'; | |
| 334 | + trkTmpFName[0] = '\0'; | |
| 335 | + FReq_NameTemp[0] = '\0'; | |
| 336 | + FReq_ModCurPathU[0] = 0; | |
| 337 | + FReq_InsCurPathU[0] = 0; | |
| 338 | + FReq_SmpCurPathU[0] = 0; | |
| 339 | + FReq_PatCurPathU[0] = 0; | |
| 340 | + FReq_TrkCurPathU[0] = 0; | |
| 341 | + | |
| 302 | 342 | strcpy(modTmpFName, "untitled.xm"); |
| 303 | 343 | strcpy(insTmpFName, "untitled.xi"); |
| 304 | 344 | strcpy(smpTmpFName, "untitled.wav"); |
| @@ -602,7 +642,7 @@ void diskOpSetFilename(uint8_t type, UNICHAR *pathU) · 297 unmodified lines | ||
| 602 | 642 | char *filename = getFilenameFromPath(ansiPath); |
| 603 | 643 | uint32_t filenameLen = (uint32_t)strlen(filename); |
| 604 | 644 | |
| 605 | − if (filenameLen > PATH_MAX-1) | |
| 645 | + if (filenameLen > PATH_MAX) | |
| 606 | 646 | { |
| 607 | 647 | free(ansiPath); |
| 608 | 648 | return; // filename is too long, don't bother to copy it over |
| @@ -693,9 +733,9 @@ static void openFile(UNICHAR *filenameU, bool songModifiedCheck) · 84 unmodified lines | ||
| 693 | 733 | { |
| 694 | 734 | if (songModifiedCheck && song.isModified) |
| 695 | 735 | { |
| 696 | − // remove file selection | |
| 736 | + // remove file selection before okBox() opens up | |
| 697 | 737 | FReq_EntrySelected = -1; |
| 698 | − diskOp_DrawDirectory(); | |
| 738 | + diskOp_DrawFilelist(); | |
| 699 | 739 | |
| 700 | 740 | if (okBox(2, "System request", "You have unsaved changes in your song. Load new song and lose all changes?") != 1) |
| 701 | 741 | return; |
| @@ -758,8 +798,6 @@ void changeFilenameExt(char *name, char *ext, int32_t nameMaxLen) · 56 unmodified lines | ||
| 758 | 798 | void diskOpChangeFilenameExt(char *ext) |
| 759 | 799 | { |
| 760 | 800 | changeFilenameExt(FReq_FileName, ext, PATH_MAX); |
| 761 | − if (ui.diskOpShown) | |
| 762 | − diskOp_DrawDirectory(); | |
| 763 | 801 | } |
| 764 | 802 | |
| 765 | 803 | void trimEntryName(char *name, bool isDir) |
| @@ -1011,7 +1049,7 @@ static void fileListPressed(int32_t index) · 245 unmodified lines | ||
| 1011 | 1049 | |
| 1012 | 1050 | // remove file selection |
| 1013 | 1051 | FReq_EntrySelected = -1; |
| 1014 | − diskOp_DrawDirectory(); | |
| 1052 | + diskOp_DrawFilelist(); | |
| 1015 | 1053 | |
| 1016 | 1054 | DirRec *dirEntry = &FReq_Buffer[entryIndex]; |
| 1017 | 1055 | switch (mode) |
| @@ -1077,15 +1115,16 @@ static void fileListPressed(int32_t index) · 59 unmodified lines | ||
| 1077 | 1115 | if (nameTmp == NULL) |
| 1078 | 1116 | break; |
| 1079 | 1117 | |
| 1080 | − strncpy(FReq_NameTemp, nameTmp, PATH_MAX - 1); | |
| 1118 | + strncpy(FReq_NameTemp, nameTmp, PATH_MAX); | |
| 1119 | + FReq_NameTemp[PATH_MAX] = '\0'; | |
| 1081 | 1120 | free(nameTmp); |
| 1082 | 1121 | |
| 1083 | 1122 | // in case of UTF8 -> CP437 encoding failure, there can be question marks. Remove them... |
| 1084 | 1123 | removeQuestionmarksFromString(FReq_NameTemp); |
| 1085 | 1124 | |
| 1086 | − if (inputBox(1, dirEntry->isDir ? "Enter new directory name:" : "Enter new filename:", FReq_NameTemp, PATH_MAX - 1) == 1) | |
| 1125 | + if (inputBox(1, dirEntry->isDir ? "Enter new directory name:" : "Enter new filename:", FReq_NameTemp, PATH_MAX) == 1) | |
| 1087 | 1126 | { |
| 1088 | − if ((FReq_NameTemp == NULL) || (FReq_NameTemp[0] == '\0')) | |
| 1127 | + if (FReq_NameTemp == NULL || FReq_NameTemp[0] == '\0') | |
| 1089 | 1128 | { |
| 1090 | 1129 | okBox(0, "System message", "New name can't be empty!"); |
| 1091 | 1130 | break; |
| @@ -1120,7 +1159,7 @@ bool testDiskOpMouseDown(bool mouseHeldDlown) · 28 unmodified lines | ||
| 1120 | 1159 | if (max > DISKOP_ENTRY_NUM) // needed kludge when mouse-scrolling |
| 1121 | 1160 | max = DISKOP_ENTRY_NUM; |
| 1122 | 1161 | |
| 1123 | − if (!mouseHeldDlown) | |
| 1162 | + if (!mouseHeldDlown) // select file | |
| 1124 | 1163 | { |
| 1125 | 1164 | FReq_EntrySelected = -1; |
| 1126 | 1165 | |
| @@ -1130,7 +1169,7 @@ bool testDiskOpMouseDown(bool mouseHeldDlown) · 3 unmodified lines | ||
| 1130 | 1169 | if (tmpEntry >= 0 && tmpEntry < max) |
| 1131 | 1170 | { |
| 1132 | 1171 | FReq_EntrySelected = tmpEntry; |
| 1133 | − diskOp_DrawDirectory(); | |
| 1172 | + diskOp_DrawFilelist(); | |
| 1134 | 1173 | } |
| 1135 | 1174 | |
| 1136 | 1175 | mouse.lastUsedObjectType = OBJECT_DISKOPLIST; |
| @@ -1161,7 +1200,7 @@ bool testDiskOpMouseDown(bool mouseHeldDlown) · 24 unmodified lines | ||
| 1161 | 1200 | if (mouse.x < 169 || mouse.x > 331 || mouse.y < 4 || tmpEntry < 0 || tmpEntry >= max) |
| 1162 | 1201 | { |
| 1163 | 1202 | FReq_EntrySelected = -1; |
| 1164 | − diskOp_DrawDirectory(); | |
| 1203 | + diskOp_DrawFilelist(); | |
| 1165 | 1204 | |
| 1166 | 1205 | return true; |
| 1167 | 1206 | } |
| @@ -1169,7 +1208,7 @@ bool testDiskOpMouseDown(bool mouseHeldDlown) · 1 unmodified line | ||
| 1169 | 1208 | if (tmpEntry != FReq_EntrySelected) |
| 1170 | 1209 | { |
| 1171 | 1210 | FReq_EntrySelected = tmpEntry; |
| 1172 | − diskOp_DrawDirectory(); | |
| 1211 | + diskOp_DrawFilelist(); | |
| 1173 | 1212 | } |
| 1174 | 1213 | |
| 1175 | 1214 | return true; |
| @@ -1183,7 +1222,7 @@ void testDiskOpMouseRelease(void) · 7 unmodified lines | ||
| 1183 | 1222 | fileListPressed((mouse.y - 4) / (FONT1_CHAR_H + 1)); |
| 1184 | 1223 | |
| 1185 | 1224 | FReq_EntrySelected = -1; |
| 1186 | − diskOp_DrawDirectory(); | |
| 1225 | + diskOp_DrawFilelist(); | |
| 1187 | 1226 | } |
| 1188 | 1227 | } |
| 1189 | 1228 | |
| @@ -1537,7 +1576,7 @@ static char *ach(int32_t rad) // used for sortDirectory() · 347 unmodified lines | ||
| 1537 | 1576 | return NULL; |
| 1538 | 1577 | } |
| 1539 | 1578 | |
| 1540 | − char *p = (char *)malloc(nameLen + 2); | |
| 1579 | + char *p = (char *)malloc(nameLen+1+1); | |
| 1541 | 1580 | if (p == NULL) |
| 1542 | 1581 | { |
| 1543 | 1582 | free(name); |
| @@ -1701,6 +1740,9 @@ static void displayCurrPath(void) · 157 unmodified lines | ||
| 1701 | 1740 | { |
| 1702 | 1741 | fillRect(4, 145, 162, 10, PAL_DESKTOP); |
| 1703 | 1742 | |
| 1743 | + if (FReq_CurPathU == NULL) | |
| 1744 | + return; | |
| 1745 | + | |
| 1704 | 1746 | const uint32_t pathLen = (uint32_t)UNICHAR_STRLEN(FReq_CurPathU); |
| 1705 | 1747 | if (pathLen == 0) |
| 1706 | 1748 | return; |
| @@ -1722,11 +1764,14 @@ static void displayCurrPath(void) · 15 unmodified lines | ||
| 1722 | 1764 | { |
| 1723 | 1765 | // path doesn't fit, print drive + ".." + last directory |
| 1724 | 1766 | |
| 1725 | − memset(FReq_NameTemp, 0, PATH_MAX + 1); | |
| 1726 | 1767 | #ifdef _WIN32 |
| 1727 | − strncpy(FReq_NameTemp, p, 3); | |
| 1768 | + memcpy(FReq_NameTemp, p, 3); // get drive (f.ex. C:\) | |
| 1769 | + FReq_NameTemp[3] = '\0'; | |
| 1770 | + | |
| 1728 | 1771 | strcat(FReq_NameTemp, ".\001"); // special character in font |
| 1772 | + FReq_NameTemp[5] = '\0'; | |
| 1729 | 1773 | #else |
| 1774 | + FReq_NameTemp[0] = '\0'; | |
| 1730 | 1775 | strcpy(FReq_NameTemp, "/"); |
| 1731 | 1776 | strcat(FReq_NameTemp, ".."); |
| 1732 | 1777 | #endif |
| @@ -1735,7 +1780,7 @@ static void displayCurrPath(void) · 2 unmodified lines | ||
| 1735 | 1780 | if (delimiter != NULL) |
| 1736 | 1781 | { |
| 1737 | 1782 | #ifdef _WIN32 |
| 1738 | − strcat(FReq_NameTemp, delimiter + 1); | |
| 1783 | + strcat(FReq_NameTemp, delimiter+1); | |
| 1739 | 1784 | #else |
| 1740 | 1785 | strcat(FReq_NameTemp, delimiter); |
| 1741 | 1786 | #endif |
| @@ -1749,9 +1794,9 @@ static void displayCurrPath(void) · 7 unmodified lines | ||
| 1749 | 1794 | p = FReq_NameTemp; |
| 1750 | 1795 | while (j >= 6 && textWidth(p) >= 162) |
| 1751 | 1796 | { |
| 1752 | − p[j - 2] = '.'; | |
| 1753 | − p[j - 1] = '.'; | |
| 1754 | − p[j - 0] = '\0'; | |
| 1797 | + p[j-2] = '.'; | |
| 1798 | + p[j-1] = '.'; | |
| 1799 | + p[j-0] = '\0'; | |
| 1755 | 1800 | j--; |
| 1756 | 1801 | } |
| 1757 | 1802 | } |
| @@ -1762,25 +1807,20 @@ static void displayCurrPath(void) · 4 unmodified lines | ||
| 1762 | 1807 | free(asciiPath); |
| 1763 | 1808 | } |
| 1764 | 1809 | |
| 1765 | −void diskOp_DrawDirectory(void) | |
| 1810 | +void diskOp_DrawFilelist(void) | |
| 1766 | 1811 | { |
| 1767 | − clearRect(FILENAME_TEXT_X - 1, 4, 162, 164); | |
| 1768 | − drawTextBox(TB_DISKOP_FILENAME); | |
| 1812 | + clearRect(FILENAME_TEXT_X-1, 4, 162, 164); | |
| 1769 | 1813 | |
| 1814 | + if (FReq_FileCount == 0) | |
| 1815 | + return; | |
| 1816 | + | |
| 1817 | + // draw "selected file" rectangle | |
| 1770 | 1818 | if (FReq_EntrySelected != -1) |
| 1771 | 1819 | { |
| 1772 | 1820 | const uint16_t y = 4 + (uint16_t)((FONT1_CHAR_H + 1) * FReq_EntrySelected); |
| 1773 | 1821 | fillRect(FILENAME_TEXT_X - 1, y, 162, FONT1_CHAR_H, PAL_PATTEXT); |
| 1774 | 1822 | } |
| 1775 | 1823 | |
| 1776 | − displayCurrPath(); | |
| 1777 | −#ifdef _WIN32 | |
| 1778 | − setupDiskOpDrives(); | |
| 1779 | −#endif | |
| 1780 | − | |
| 1781 | − if (FReq_FileCount == 0) | |
| 1782 | − return; | |
| 1783 | − | |
| 1784 | 1824 | for (uint16_t i = 0; i < DISKOP_ENTRY_NUM; i++) |
| 1785 | 1825 | { |
| 1786 | 1826 | const int32_t bufEntry = FReq_DirPos + i; |
| @@ -1817,9 +1857,21 @@ void diskOp_DrawDirectory(void) · 30 unmodified lines | ||
| 1817 | 1857 | if (!FReq_Buffer[bufEntry].isDir) |
| 1818 | 1858 | printFormattedFilesize(FILESIZE_TEXT_X, y, bufEntry); |
| 1819 | 1859 | } |
| 1860 | +} | |
| 1861 | + | |
| 1862 | +void diskOp_DrawDirectory(void) | |
| 1863 | +{ | |
| 1864 | + drawTextBox(TB_DISKOP_FILENAME); | |
| 1865 | + | |
| 1866 | + displayCurrPath(); | |
| 1867 | +#ifdef _WIN32 | |
| 1868 | + setupDiskOpDrives(); | |
| 1869 | +#endif | |
| 1820 | 1870 | |
| 1821 | − setScrollBarPos(SB_DISKOP_LIST, FReq_DirPos, true); | |
| 1822 | 1871 | setScrollBarEnd(SB_DISKOP_LIST, FReq_FileCount); |
| 1872 | + setScrollBarPos(SB_DISKOP_LIST, FReq_DirPos, false); | |
| 1873 | + | |
| 1874 | + diskOp_DrawFilelist(); | |
| 1823 | 1875 | } |
| 1824 | 1876 | |
| 1825 | 1877 | static DirRec *bufferCreateEmptyDir(void) // special case: creates a dir entry with a ".." directory |
| @@ -2035,7 +2087,7 @@ static void setDiskOpItem(uint8_t item) · 209 unmodified lines | ||
| 2035 | 2087 | // FReq_ModCurPathU is always set at this point |
| 2036 | 2088 | |
| 2037 | 2089 | FReq_CurPathU = FReq_ModCurPathU; |
| 2038 | − if (FReq_CurPathU != NULL) | |
| 2090 | + if (FReq_CurPathU != NULL && FReq_CurPathU[0] != '\0') | |
| 2039 | 2091 | UNICHAR_CHDIR(FReq_CurPathU); |
| 2040 | 2092 | } |
| 2041 | 2093 | break; |
| @@ -2044,7 +2096,7 @@ static void setDiskOpItem(uint8_t item) · 2 unmodified lines | ||
| 2044 | 2096 | { |
| 2045 | 2097 | FReq_FileName = insTmpFName; |
| 2046 | 2098 | |
| 2047 | − if (!insPathSet) | |
| 2099 | + if (!insPathSet && FReq_CurPathU != NULL && FReq_CurPathU[0] != '\0') | |
| 2048 | 2100 | { |
| 2049 | 2101 | UNICHAR_STRCPY(FReq_InsCurPathU, FReq_CurPathU); |
| 2050 | 2102 | insPathSet = true; |
| @@ -2060,7 +2112,7 @@ static void setDiskOpItem(uint8_t item) · 9 unmodified lines | ||
| 2060 | 2112 | { |
| 2061 | 2113 | FReq_FileName = smpTmpFName; |
| 2062 | 2114 | |
| 2063 | − if (!smpPathSet) | |
| 2115 | + if (!smpPathSet && FReq_CurPathU != NULL && FReq_CurPathU[0] != '\0') | |
| 2064 | 2116 | { |
| 2065 | 2117 | UNICHAR_STRCPY(FReq_SmpCurPathU, FReq_CurPathU); |
| 2066 | 2118 | smpPathSet = true; |
| @@ -2076,7 +2128,7 @@ static void setDiskOpItem(uint8_t item) · 9 unmodified lines | ||
| 2076 | 2128 | { |
| 2077 | 2129 | FReq_FileName = patTmpFName; |
| 2078 | 2130 | |
| 2079 | − if (!patPathSet) | |
| 2131 | + if (!patPathSet && FReq_CurPathU != NULL && FReq_CurPathU[0] != '\0') | |
| 2080 | 2132 | { |
| 2081 | 2133 | UNICHAR_STRCPY(FReq_PatCurPathU, FReq_CurPathU); |
| 2082 | 2134 | patPathSet = true; |
| @@ -2092,7 +2144,7 @@ static void setDiskOpItem(uint8_t item) · 9 unmodified lines | ||
| 2092 | 2144 | { |
| 2093 | 2145 | FReq_FileName = trkTmpFName; |
| 2094 | 2146 | |
| 2095 | − if (!trkPathSet) | |
| 2147 | + if (!trkPathSet && FReq_CurPathU != NULL && FReq_CurPathU[0] != '\0') | |
| 2096 | 2148 | { |
| 2097 | 2149 | UNICHAR_STRCPY(FReq_TrkCurPathU, FReq_CurPathU); |
| 2098 | 2150 | trkPathSet = true; |
| @@ -2105,15 +2157,13 @@ static void setDiskOpItem(uint8_t item) · 6 unmodified lines | ||
| 2105 | 2157 | break; |
| 2106 | 2158 | } |
| 2107 | 2159 | |
| 2108 | − const int32_t pathLen = (int32_t)UNICHAR_STRLEN(FReq_CurPathU); | |
| 2109 | − if (pathLen == 0 && FReq_ModCurPathU[0] != '\0') | |
| 2160 | + if (FReq_CurPathU != NULL && FReq_ModCurPathU != NULL) | |
| 2110 | 2161 | { |
| 2111 | − memset(FReq_CurPathU, 0, (PATH_MAX + 2) * sizeof (UNICHAR)); | |
| 2112 | − UNICHAR_STRCPY(FReq_CurPathU, FReq_ModCurPathU); | |
| 2162 | + if (FReq_CurPathU[0] == '\0' && FReq_ModCurPathU[0] != '\0') | |
| 2163 | + UNICHAR_STRCPY(FReq_CurPathU, FReq_ModCurPathU); | |
| 2113 | 2164 | } |
| 2114 | 2165 | |
| 2115 | 2166 | textBoxes[TB_DISKOP_FILENAME].textPtr = FReq_FileName; |
| 2116 | − | |
| 2117 | 2167 | FReq_ShowAllFiles = false; |
| 2118 | 2168 | |
| 2119 | 2169 | if (ui.diskOpShown) |
| @@ -2199,14 +2249,15 @@ void showDiskOpScreen(void) · 79 unmodified lines | ||
| 2199 | 2249 | assert(FReq_ModCurPathU != NULL); |
| 2200 | 2250 | |
| 2201 | 2251 | // first test if we can change the dir to the one stored in the config (if present) |
| 2202 | − if (UNICHAR_STRLEN(FReq_ModCurPathU) == 0 || UNICHAR_CHDIR(FReq_ModCurPathU) != 0) | |
| 2252 | + if (FReq_ModCurPathU[0] == '\0' || UNICHAR_CHDIR(FReq_ModCurPathU) != 0) | |
| 2203 | 2253 | { |
| 2204 | 2254 | // nope, couldn't do that, set Disk Op. path to user/home directory |
| 2205 | 2255 | #ifdef _WIN32 |
| 2206 | 2256 | SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, FReq_ModCurPathU); |
| 2207 | 2257 | #else |
| 2208 | − if (getenv("HOME") != NULL) | |
| 2209 | − UNICHAR_STRCPY(FReq_ModCurPathU, getenv("HOME")); | |
| 2258 | + char *home = getenv("HOME"); | |
| 2259 | + if (home != NULL) | |
| 2260 | + UNICHAR_STRCPY(FReq_ModCurPathU, home); | |
| 2210 | 2261 | #endif |
| 2211 | 2262 | UNICHAR_CHDIR(FReq_ModCurPathU); |
| 2212 | 2263 | } |
| @@ -2285,7 +2336,7 @@ void sbDiskOpSetPos(uint32_t pos) · 72 unmodified lines | ||
| 2285 | 2336 | if ((int32_t)pos != FReq_DirPos && FReq_FileCount > DISKOP_ENTRY_NUM) |
| 2286 | 2337 | { |
| 2287 | 2338 | FReq_DirPos = (int32_t)pos; |
| 2288 | − diskOp_DrawDirectory(); | |
| 2339 | + diskOp_DrawFilelist(); | |
| 2289 | 2340 | } |
| 2290 | 2341 | } |
| 2291 | 2342 | |
| @@ -2345,7 +2396,7 @@ void pbDiskOpRename(void) · 53 unmodified lines | ||
| 2345 | 2396 | void pbDiskOpMakeDir(void) |
| 2346 | 2397 | { |
| 2347 | 2398 | FReq_NameTemp[0] = '\0'; |
| 2348 | − if (inputBox(1, "Enter directory name:", FReq_NameTemp, PATH_MAX - 1) == 1) | |
| 2399 | + if (inputBox(1, "Enter directory name:", FReq_NameTemp, PATH_MAX) == 1) | |
| 2349 | 2400 | { |
| 2350 | 2401 | if (FReq_NameTemp[0] == '\0') |
| 2351 | 2402 | { |
| @@ -2371,7 +2422,7 @@ void pbDiskOpRefresh(void) · 19 unmodified lines | ||
| 2371 | 2422 | void pbDiskOpSetPath(void) |
| 2372 | 2423 | { |
| 2373 | 2424 | FReq_NameTemp[0] = '\0'; |
| 2374 | − if (inputBox(1, "Enter new directory path:", FReq_NameTemp, PATH_MAX - 1) == 1) | |
| 2425 | + if (inputBox(1, "Enter new directory path:", FReq_NameTemp, PATH_MAX) == 1) | |
| 2375 | 2426 | { |
| 2376 | 2427 | if (FReq_NameTemp[0] == '\0') |
| 2377 | 2428 | { |
| @@ -21,6 +21,7 @@ enum · 20 unmodified lines | ||
| 21 | 21 | SMP_SAVE_MODE_WAV = 2 |
| 22 | 22 | }; |
| 23 | 23 | |
| 24 | +bool setupExecutablePath(void); | |
| 24 | 25 | int32_t getFileSize(UNICHAR *fileNameU); |
| 25 | 26 | uint8_t getDiskOpItem(void); |
| 26 | 27 | void updateCurrSongFilename(void); // for window title |
| @@ -41,6 +42,7 @@ int32_t getExtOffset(char *s, int32_t stringLen); // get byte offset of file ext · 14 unmodified lines | ||
| 41 | 42 | bool testDiskOpMouseDown(bool mouseHeldDown); |
| 42 | 43 | void testDiskOpMouseRelease(void); |
| 43 | 44 | void diskOp_StartDirReadThread(void); |
| 45 | +void diskOp_DrawFilelist(void); | |
| 44 | 46 | void diskOp_DrawDirectory(void); |
| 45 | 47 | void showDiskOpScreen(void); |
| 46 | 48 | void hideDiskOpScreen(void); |
| @@ -35,13 +35,14 @@ · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | #define CRASH_TEXT "Oh no!\nThe Fasttracker II clone has crashed...\n\nA backup .xm was hopefully " \ |
| 37 | 37 | "saved to the current module directory.\n\nPlease report this bug if you can.\n" \ |
| 38 | − "Try to mention what you did before the crash happened." | |
| 38 | + "Try to mention what you did before the crash happened.\n" \ | |
| 39 | + "My email can be found at the bottom of 16-bits.org." | |
| 39 | 40 | |
| 40 | 41 | static bool backupMadeAfterCrash; |
| 41 | 42 | |
| 42 | 43 | #ifdef _WIN32 |
| 43 | −#define SYSMSG_FILE_ARG (WM_USER + 1) | |
| 44 | −#define ARGV_SHARED_MEM_MAX_LEN ((MAX_PATH * 2) + 2) | |
| 44 | +#define SYSMSG_FILE_ARG (WM_USER+1) | |
| 45 | +#define ARGV_SHARED_MEM_MAX_LEN ((PATH_MAX+1) * sizeof (WCHAR)) | |
| 45 | 46 | #define SHARED_HWND_NAME TEXT("Local\\FT2CloneHwnd") |
| 46 | 47 | #define SHARED_FILENAME TEXT("Local\\FT2CloneFilename") |
| 47 | 48 | static HWND hWnd; |
| @@ -127,20 +127,21 @@ void unstuckLastUsedGUIElement(void) · 126 unmodified lines | ||
| 127 | 127 | |
| 128 | 128 | bool setupGUI(void) |
| 129 | 129 | { |
| 130 | − int32_t i; | |
| 131 | − | |
| 132 | 130 | // all memory will be NULL-tested and free'd if we return false somewhere in this function |
| 133 | 131 | |
| 134 | − editor.tmpFilenameU = (UNICHAR *)calloc(PATH_MAX + 1, sizeof (UNICHAR)); | |
| 135 | − editor.tmpInstrFilenameU = (UNICHAR *)calloc(PATH_MAX + 1, sizeof (UNICHAR)); | |
| 132 | + editor.tmpFilenameU = (UNICHAR *)malloc((PATH_MAX + 1) * sizeof (UNICHAR)); | |
| 133 | + editor.tmpInstrFilenameU = (UNICHAR *)malloc((PATH_MAX + 1) * sizeof (UNICHAR)); | |
| 136 | 134 | |
| 137 | 135 | if (editor.tmpFilenameU == NULL || editor.tmpInstrFilenameU == NULL) |
| 138 | 136 | goto setupGUI_OOM; |
| 139 | 137 | |
| 138 | + editor.tmpFilenameU[0] = 0; | |
| 139 | + editor.tmpInstrFilenameU[0] = 0; | |
| 140 | + | |
| 140 | 141 | // set uninitialized GUI struct entries |
| 141 | 142 | |
| 142 | 143 | textBox_t *t = &textBoxes[1]; // skip first entry, it's reserved for inputBox()) |
| 143 | − for (i = 1; i < NUM_TEXTBOXES; i++, t++) | |
| 144 | + for (int32_t i = 1; i < NUM_TEXTBOXES; i++, t++) | |
| 144 | 145 | { |
| 145 | 146 | t->visible = false; |
| 146 | 147 | t->bufOffset = 0; |
| @@ -156,7 +157,7 @@ bool setupGUI(void) · 9 unmodified lines | ||
| 156 | 157 | } |
| 157 | 158 | |
| 158 | 159 | pushButton_t *p = pushButtons; |
| 159 | − for (i = 0; i < NUM_PUSHBUTTONS; i++, p++) | |
| 160 | + for (int32_t i = 0; i < NUM_PUSHBUTTONS; i++, p++) | |
| 160 | 161 | { |
| 161 | 162 | p->state = 0; |
| 162 | 163 | p->visible = false; |
| @@ -174,7 +175,7 @@ bool setupGUI(void) · 11 unmodified lines | ||
| 174 | 175 | } |
| 175 | 176 | |
| 176 | 177 | checkBox_t *c = checkBoxes; |
| 177 | − for (i = 0; i < NUM_CHECKBOXES; i++, c++) | |
| 178 | + for (int32_t i = 0; i < NUM_CHECKBOXES; i++, c++) | |
| 178 | 179 | { |
| 179 | 180 | c->state = 0; |
| 180 | 181 | c->checked = false; |
| @@ -182,14 +183,14 @@ bool setupGUI(void) · 1 unmodified line | ||
| 182 | 183 | } |
| 183 | 184 | |
| 184 | 185 | radioButton_t *r = radioButtons; |
| 185 | − for (i = 0; i < NUM_RADIOBUTTONS; i++, r++) | |
| 186 | + for (int32_t i = 0; i < NUM_RADIOBUTTONS; i++, r++) | |
| 186 | 187 | { |
| 187 | 188 | r->state = 0; |
| 188 | 189 | r->visible = false; |
| 189 | 190 | } |
| 190 | 191 | |
| 191 | 192 | scrollBar_t *s = scrollBars; |
| 192 | − for (i = 0; i < NUM_SCROLLBARS; i++, s++) | |
| 193 | + for (int32_t i = 0; i < NUM_SCROLLBARS; i++, s++) | |
| 193 | 194 | { |
| 194 | 195 | s->visible = false; |
| 195 | 196 | s->state = 0; |
| @@ -122,7 +122,8 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode, bool keyWasRepea · 121 unmodified lines | ||
| 122 | 122 | return; // do NOT repeat keys in Nibbles or if keyRepeat is disabled |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | − keyb.keyRepeat = true; | |
| 125 | + if (scancode != SDL_SCANCODE_ESCAPE) | |
| 126 | + keyb.keyRepeat = true; | |
| 126 | 127 | |
| 127 | 128 | // handle certain keys (home/end/left/right etc) when editing text |
| 128 | 129 | if (editor.editTextFlag) |
| @@ -669,6 +670,7 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 540 unmodified lines | ||
| 669 | 670 | |
| 670 | 671 | case SDLK_KP_ENTER: |
| 671 | 672 | case SDLK_RETURN: |
| 673 | + { | |
| 672 | 674 | if (keyb.leftAltPressed) |
| 673 | 675 | { |
| 674 | 676 | toggleFullScreen(); |
| @@ -679,9 +681,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 4 unmodified lines | ||
| 679 | 681 | #endif |
| 680 | 682 | return true; |
| 681 | 683 | } |
| 682 | − break; | |
| 684 | + } | |
| 685 | + break; | |
| 683 | 686 | |
| 684 | 687 | case SDLK_F9: |
| 688 | + { | |
| 685 | 689 | if (keyb.leftCtrlPressed) |
| 686 | 690 | { |
| 687 | 691 | startPlaying(PLAYMODE_PATT, editor.ptnJumpPos[0]); |
| @@ -692,9 +696,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 4 unmodified lines | ||
| 692 | 696 | editor.ptnJumpPos[0] = (uint8_t)editor.pattPos; |
| 693 | 697 | return true; |
| 694 | 698 | } |
| 695 | − break; | |
| 699 | + } | |
| 700 | + break; | |
| 696 | 701 | |
| 697 | 702 | case SDLK_F10: |
| 703 | + { | |
| 698 | 704 | if (keyb.leftCtrlPressed) |
| 699 | 705 | { |
| 700 | 706 | startPlaying(PLAYMODE_PATT, editor.ptnJumpPos[1]); |
| @@ -705,9 +711,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 4 unmodified lines | ||
| 705 | 711 | editor.ptnJumpPos[1] = (uint8_t)editor.pattPos; |
| 706 | 712 | return true; |
| 707 | 713 | } |
| 708 | − break; | |
| 714 | + } | |
| 715 | + break; | |
| 709 | 716 | |
| 710 | 717 | case SDLK_F11: |
| 718 | + { | |
| 711 | 719 | if (keyb.leftCtrlPressed) |
| 712 | 720 | { |
| 713 | 721 | startPlaying(PLAYMODE_PATT, editor.ptnJumpPos[2]); |
| @@ -718,9 +726,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 4 unmodified lines | ||
| 718 | 726 | editor.ptnJumpPos[2] = (uint8_t)editor.pattPos; |
| 719 | 727 | return true; |
| 720 | 728 | } |
| 721 | − break; | |
| 729 | + } | |
| 730 | + break; | |
| 722 | 731 | |
| 723 | 732 | case SDLK_F12: |
| 733 | + { | |
| 724 | 734 | if (keyb.leftCtrlPressed) |
| 725 | 735 | { |
| 726 | 736 | startPlaying(PLAYMODE_PATT, editor.ptnJumpPos[3]); |
| @@ -731,9 +741,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 4 unmodified lines | ||
| 731 | 741 | editor.ptnJumpPos[3] = (uint8_t)editor.pattPos; |
| 732 | 742 | return true; |
| 733 | 743 | } |
| 734 | − break; | |
| 744 | + } | |
| 745 | + break; | |
| 735 | 746 | |
| 736 | 747 | case SDLK_a: |
| 748 | + { | |
| 737 | 749 | if (keyb.leftCtrlPressed) |
| 738 | 750 | { |
| 739 | 751 | if (ui.sampleEditorShown) |
| @@ -752,9 +764,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 12 unmodified lines | ||
| 752 | 764 | |
| 753 | 765 | return true; |
| 754 | 766 | } |
| 755 | − break; | |
| 767 | + } | |
| 768 | + break; | |
| 756 | 769 | |
| 757 | 770 | case SDLK_b: |
| 771 | + { | |
| 758 | 772 | if (keyb.leftCtrlPressed) |
| 759 | 773 | { |
| 760 | 774 | if (!ui.aboutScreenShown) |
| @@ -762,9 +776,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 1 unmodified line | ||
| 762 | 776 | |
| 763 | 777 | return true; |
| 764 | 778 | } |
| 765 | − break; | |
| 779 | + } | |
| 780 | + break; | |
| 766 | 781 | |
| 767 | 782 | case SDLK_c: |
| 783 | + { | |
| 768 | 784 | if (keyb.leftAltPressed) |
| 769 | 785 | { |
| 770 | 786 | if (ui.sampleEditorShown) |
| @@ -793,9 +809,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 22 unmodified lines | ||
| 793 | 809 | |
| 794 | 810 | return true; |
| 795 | 811 | } |
| 796 | − break; | |
| 812 | + } | |
| 813 | + break; | |
| 797 | 814 | |
| 798 | 815 | case SDLK_d: |
| 816 | + { | |
| 799 | 817 | if (keyb.leftAltPressed) |
| 800 | 818 | { |
| 801 | 819 | jumpToChannel(10); |
| @@ -808,9 +826,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 6 unmodified lines | ||
| 808 | 826 | |
| 809 | 827 | return true; |
| 810 | 828 | } |
| 811 | − break; | |
| 829 | + } | |
| 830 | + break; | |
| 812 | 831 | |
| 813 | 832 | case SDLK_e: |
| 833 | + { | |
| 814 | 834 | if (keyb.leftAltPressed) |
| 815 | 835 | { |
| 816 | 836 | jumpToChannel(2); |
| @@ -826,9 +846,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 9 unmodified lines | ||
| 826 | 846 | showSampleEditorExt(); |
| 827 | 847 | return true; |
| 828 | 848 | } |
| 829 | − break; | |
| 849 | + } | |
| 850 | + break; | |
| 830 | 851 | |
| 831 | 852 | case SDLK_f: |
| 853 | + { | |
| 832 | 854 | #ifdef __APPLE__ |
| 833 | 855 | if (keyb.leftCommandPressed && keyb.leftCtrlPressed) |
| 834 | 856 | { |
| @@ -854,17 +876,21 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 19 unmodified lines | ||
| 854 | 876 | jumpToChannel(11); |
| 855 | 877 | return true; |
| 856 | 878 | } |
| 857 | − break; | |
| 879 | + } | |
| 880 | + break; | |
| 858 | 881 | |
| 859 | 882 | case SDLK_g: |
| 883 | + { | |
| 860 | 884 | if (keyb.leftAltPressed) |
| 861 | 885 | { |
| 862 | 886 | jumpToChannel(12); |
| 863 | 887 | return true; |
| 864 | 888 | } |
| 865 | − break; | |
| 889 | + } | |
| 890 | + break; | |
| 866 | 891 | |
| 867 | 892 | case SDLK_h: |
| 893 | + { | |
| 868 | 894 | if (keyb.leftAltPressed) |
| 869 | 895 | { |
| 870 | 896 | jumpToChannel(13); |
| @@ -875,9 +901,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 4 unmodified lines | ||
| 875 | 901 | showHelpScreen(); |
| 876 | 902 | return true; |
| 877 | 903 | } |
| 878 | − break; | |
| 904 | + } | |
| 905 | + break; | |
| 879 | 906 | |
| 880 | 907 | case SDLK_i: |
| 908 | + { | |
| 881 | 909 | if (keyb.leftAltPressed) |
| 882 | 910 | { |
| 883 | 911 | jumpToChannel(7); |
| @@ -888,25 +916,31 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 4 unmodified lines | ||
| 888 | 916 | showInstEditor(); |
| 889 | 917 | return true; |
| 890 | 918 | } |
| 891 | − break; | |
| 919 | + } | |
| 920 | + break; | |
| 892 | 921 | |
| 893 | 922 | case SDLK_j: |
| 923 | + { | |
| 894 | 924 | if (keyb.leftAltPressed) |
| 895 | 925 | { |
| 896 | 926 | jumpToChannel(14); |
| 897 | 927 | return true; |
| 898 | 928 | } |
| 899 | − break; | |
| 929 | + } | |
| 930 | + break; | |
| 900 | 931 | |
| 901 | 932 | case SDLK_k: |
| 933 | + { | |
| 902 | 934 | if (keyb.leftAltPressed) |
| 903 | 935 | { |
| 904 | 936 | jumpToChannel(15); |
| 905 | 937 | return true; |
| 906 | 938 | } |
| 907 | − break; | |
| 939 | + } | |
| 940 | + break; | |
| 908 | 941 | |
| 909 | 942 | case SDLK_m: |
| 943 | + { | |
| 910 | 944 | if (keyb.leftCtrlPressed) |
| 911 | 945 | { |
| 912 | 946 | if (ui.aboutScreenShown) hideAboutScreen(); |
| @@ -918,17 +952,21 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 5 unmodified lines | ||
| 918 | 952 | |
| 919 | 953 | return true; |
| 920 | 954 | } |
| 921 | − break; | |
| 955 | + } | |
| 956 | + break; | |
| 922 | 957 | |
| 923 | 958 | case SDLK_n: |
| 959 | + { | |
| 924 | 960 | if (keyb.leftCtrlPressed) |
| 925 | 961 | { |
| 926 | 962 | showNibblesScreen(); |
| 927 | 963 | return true; |
| 928 | 964 | } |
| 929 | − break; | |
| 965 | + } | |
| 966 | + break; | |
| 930 | 967 | |
| 931 | 968 | case SDLK_p: |
| 969 | + { | |
| 932 | 970 | if (keyb.leftCtrlPressed) |
| 933 | 971 | { |
| 934 | 972 | if (!ui.patternEditorShown) |
| @@ -942,17 +980,21 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 7 unmodified lines | ||
| 942 | 980 | |
| 943 | 981 | return true; |
| 944 | 982 | } |
| 945 | − break; | |
| 983 | + } | |
| 984 | + break; | |
| 946 | 985 | |
| 947 | 986 | case SDLK_q: |
| 987 | + { | |
| 948 | 988 | if (keyb.leftAltPressed) |
| 949 | 989 | { |
| 950 | 990 | jumpToChannel(0); |
| 951 | 991 | return true; |
| 952 | 992 | } |
| 953 | − break; | |
| 993 | + } | |
| 994 | + break; | |
| 954 | 995 | |
| 955 | 996 | case SDLK_r: |
| 997 | + { | |
| 956 | 998 | if (keyb.leftAltPressed) |
| 957 | 999 | { |
| 958 | 1000 | if (ui.sampleEditorShown) |
| @@ -967,9 +1009,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 8 unmodified lines | ||
| 967 | 1009 | showTrimScreen(); |
| 968 | 1010 | return true; |
| 969 | 1011 | } |
| 970 | − break; | |
| 1012 | + } | |
| 1013 | + break; | |
| 971 | 1014 | |
| 972 | 1015 | case SDLK_s: |
| 1016 | + { | |
| 973 | 1017 | if (keyb.leftAltPressed) |
| 974 | 1018 | { |
| 975 | 1019 | if (ui.sampleEditorShown) |
| @@ -984,9 +1028,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 8 unmodified lines | ||
| 984 | 1028 | showSampleEditor(); |
| 985 | 1029 | return true; |
| 986 | 1030 | } |
| 987 | − break; | |
| 1031 | + } | |
| 1032 | + break; | |
| 988 | 1033 | |
| 989 | 1034 | case SDLK_t: |
| 1035 | + { | |
| 990 | 1036 | if (keyb.leftAltPressed) |
| 991 | 1037 | { |
| 992 | 1038 | jumpToChannel(4); |
| @@ -997,17 +1043,21 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 4 unmodified lines | ||
| 997 | 1043 | showTranspose(); |
| 998 | 1044 | return true; |
| 999 | 1045 | } |
| 1000 | − break; | |
| 1046 | + } | |
| 1047 | + break; | |
| 1001 | 1048 | |
| 1002 | 1049 | case SDLK_u: |
| 1050 | + { | |
| 1003 | 1051 | if (keyb.leftAltPressed) |
| 1004 | 1052 | { |
| 1005 | 1053 | jumpToChannel(6); |
| 1006 | 1054 | return true; |
| 1007 | 1055 | } |
| 1008 | − break; | |
| 1056 | + } | |
| 1057 | + break; | |
| 1009 | 1058 | |
| 1010 | 1059 | case SDLK_v: |
| 1060 | + { | |
| 1011 | 1061 | if (keyb.leftAltPressed) |
| 1012 | 1062 | { |
| 1013 | 1063 | if (ui.sampleEditorShown) |
| @@ -1036,17 +1086,21 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 22 unmodified lines | ||
| 1036 | 1086 | |
| 1037 | 1087 | return true; |
| 1038 | 1088 | } |
| 1039 | − break; | |
| 1089 | + } | |
| 1090 | + break; | |
| 1040 | 1091 | |
| 1041 | 1092 | case SDLK_w: |
| 1093 | + { | |
| 1042 | 1094 | if (keyb.leftAltPressed) |
| 1043 | 1095 | { |
| 1044 | 1096 | jumpToChannel(1); |
| 1045 | 1097 | return true; |
| 1046 | 1098 | } |
| 1047 | − break; | |
| 1099 | + } | |
| 1100 | + break; | |
| 1048 | 1101 | |
| 1049 | 1102 | case SDLK_x: |
| 1103 | + { | |
| 1050 | 1104 | if (keyb.leftAltPressed) |
| 1051 | 1105 | { |
| 1052 | 1106 | if (ui.sampleEditorShown) |
| @@ -1080,17 +1134,21 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 27 unmodified lines | ||
| 1080 | 1134 | |
| 1081 | 1135 | return true; |
| 1082 | 1136 | } |
| 1083 | − break; | |
| 1137 | + } | |
| 1138 | + break; | |
| 1084 | 1139 | |
| 1085 | 1140 | case SDLK_y: |
| 1141 | + { | |
| 1086 | 1142 | if (keyb.leftAltPressed) |
| 1087 | 1143 | { |
| 1088 | 1144 | jumpToChannel(5); |
| 1089 | 1145 | return true; |
| 1090 | 1146 | } |
| 1091 | − break; | |
| 1147 | + } | |
| 1148 | + break; | |
| 1092 | 1149 | |
| 1093 | 1150 | case SDLK_z: |
| 1151 | + { | |
| 1094 | 1152 | if (keyb.leftAltPressed) |
| 1095 | 1153 | { |
| 1096 | 1154 | if (ui.sampleEditorShown) |
| @@ -1103,9 +1161,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 6 unmodified lines | ||
| 1103 | 1161 | togglePatternEditorExtended(); |
| 1104 | 1162 | return true; |
| 1105 | 1163 | } |
| 1106 | − break; | |
| 1164 | + } | |
| 1165 | + break; | |
| 1107 | 1166 | |
| 1108 | 1167 | case SDLK_1: |
| 1168 | + { | |
| 1109 | 1169 | if (keyb.leftAltPressed) |
| 1110 | 1170 | { |
| 1111 | 1171 | if (keyb.leftShiftPressed) |
| @@ -1123,9 +1183,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 11 unmodified lines | ||
| 1123 | 1183 | |
| 1124 | 1184 | return true; |
| 1125 | 1185 | } |
| 1126 | − break; | |
| 1186 | + } | |
| 1187 | + break; | |
| 1127 | 1188 | |
| 1128 | 1189 | case SDLK_2: |
| 1190 | + { | |
| 1129 | 1191 | if (keyb.leftAltPressed) |
| 1130 | 1192 | { |
| 1131 | 1193 | if (keyb.leftShiftPressed) |
| @@ -1143,9 +1205,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 11 unmodified lines | ||
| 1143 | 1205 | |
| 1144 | 1206 | return true; |
| 1145 | 1207 | } |
| 1146 | − break; | |
| 1208 | + } | |
| 1209 | + break; | |
| 1147 | 1210 | |
| 1148 | 1211 | case SDLK_3: |
| 1212 | + { | |
| 1149 | 1213 | if (keyb.leftAltPressed) |
| 1150 | 1214 | { |
| 1151 | 1215 | if (keyb.leftShiftPressed) |
| @@ -1163,9 +1227,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 11 unmodified lines | ||
| 1163 | 1227 | |
| 1164 | 1228 | return true; |
| 1165 | 1229 | } |
| 1166 | − break; | |
| 1230 | + } | |
| 1231 | + break; | |
| 1167 | 1232 | |
| 1168 | 1233 | case SDLK_4: |
| 1234 | + { | |
| 1169 | 1235 | if (keyb.leftAltPressed) |
| 1170 | 1236 | { |
| 1171 | 1237 | if (keyb.leftShiftPressed) |
| @@ -1185,9 +1251,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 13 unmodified lines | ||
| 1185 | 1251 | return true; |
| 1186 | 1252 | } |
| 1187 | 1253 | #endif |
| 1188 | − break; | |
| 1254 | + } | |
| 1255 | + break; | |
| 1189 | 1256 | |
| 1190 | 1257 | case SDLK_5: |
| 1258 | + { | |
| 1191 | 1259 | if (keyb.leftAltPressed) |
| 1192 | 1260 | { |
| 1193 | 1261 | if (keyb.leftShiftPressed) |
| @@ -1197,9 +1265,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 3 unmodified lines | ||
| 1197 | 1265 | |
| 1198 | 1266 | return true; |
| 1199 | 1267 | } |
| 1200 | − break; | |
| 1268 | + } | |
| 1269 | + break; | |
| 1201 | 1270 | |
| 1202 | 1271 | case SDLK_6: |
| 1272 | + { | |
| 1203 | 1273 | if (keyb.leftAltPressed) |
| 1204 | 1274 | { |
| 1205 | 1275 | if (keyb.leftShiftPressed) |
| @@ -1209,9 +1279,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 3 unmodified lines | ||
| 1209 | 1279 | |
| 1210 | 1280 | return true; |
| 1211 | 1281 | } |
| 1212 | − break; | |
| 1282 | + } | |
| 1283 | + break; | |
| 1213 | 1284 | |
| 1214 | 1285 | case SDLK_7: |
| 1286 | + { | |
| 1215 | 1287 | if (keyb.leftAltPressed) |
| 1216 | 1288 | { |
| 1217 | 1289 | if (keyb.leftShiftPressed) |
| @@ -1221,9 +1293,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 3 unmodified lines | ||
| 1221 | 1293 | |
| 1222 | 1294 | return true; |
| 1223 | 1295 | } |
| 1224 | − break; | |
| 1296 | + } | |
| 1297 | + break; | |
| 1225 | 1298 | |
| 1226 | 1299 | case SDLK_8: |
| 1300 | + { | |
| 1227 | 1301 | if (keyb.leftAltPressed) |
| 1228 | 1302 | { |
| 1229 | 1303 | if (keyb.leftShiftPressed) |
| @@ -1233,9 +1307,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 3 unmodified lines | ||
| 1233 | 1307 | |
| 1234 | 1308 | return true; |
| 1235 | 1309 | } |
| 1236 | − break; | |
| 1310 | + } | |
| 1311 | + break; | |
| 1237 | 1312 | |
| 1238 | 1313 | case SDLK_9: |
| 1314 | + { | |
| 1239 | 1315 | if (keyb.leftAltPressed) |
| 1240 | 1316 | { |
| 1241 | 1317 | if (keyb.leftShiftPressed) |
| @@ -1245,9 +1321,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 3 unmodified lines | ||
| 1245 | 1321 | |
| 1246 | 1322 | return true; |
| 1247 | 1323 | } |
| 1248 | − break; | |
| 1324 | + } | |
| 1325 | + break; | |
| 1249 | 1326 | |
| 1250 | 1327 | case SDLK_0: |
| 1328 | + { | |
| 1251 | 1329 | if (keyb.leftAltPressed) |
| 1252 | 1330 | { |
| 1253 | 1331 | if (keyb.leftShiftPressed) |
| @@ -1257,9 +1335,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 3 unmodified lines | ||
| 1257 | 1335 | |
| 1258 | 1336 | return true; |
| 1259 | 1337 | } |
| 1260 | − break; | |
| 1338 | + } | |
| 1339 | + break; | |
| 1261 | 1340 | |
| 1262 | 1341 | case SDLK_LEFT: |
| 1342 | + { | |
| 1263 | 1343 | if (keyb.leftShiftPressed) |
| 1264 | 1344 | { |
| 1265 | 1345 | decSongPos(); |
| @@ -1275,9 +1355,11 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 9 unmodified lines | ||
| 1275 | 1355 | keybPattMarkLeft(); |
| 1276 | 1356 | return true; |
| 1277 | 1357 | } |
| 1278 | − break; | |
| 1358 | + } | |
| 1359 | + break; | |
| 1279 | 1360 | |
| 1280 | 1361 | case SDLK_RIGHT: |
| 1362 | + { | |
| 1281 | 1363 | if (keyb.leftShiftPressed) |
| 1282 | 1364 | { |
| 1283 | 1365 | incSongPos(); |
| @@ -1293,7 +1375,8 @@ static bool checkModifiedKeys(SDL_Keycode keycode) · 9 unmodified lines | ||
| 1293 | 1375 | keybPattMarkRight(); |
| 1294 | 1376 | return true; |
| 1295 | 1377 | } |
| 1296 | − break; | |
| 1378 | + } | |
| 1379 | + break; | |
| 1297 | 1380 | } |
| 1298 | 1381 | |
| 1299 | 1382 | return false; |
| @@ -147,9 +147,7 @@ int main(int argc, char *argv[]) · 146 unmodified lines | ||
| 147 | 147 | #ifdef __APPLE__ |
| 148 | 148 | osxSetDirToProgramDirFromArgs(argv); |
| 149 | 149 | #endif |
| 150 | − UNICHAR_GETCWD(editor.binaryPathU, PATH_MAX); | |
| 151 | − | |
| 152 | − if (!loadBMPs()) | |
| 150 | + if (!setupExecutablePath() || !loadBMPs()) | |
| 153 | 151 | { |
| 154 | 152 | cleanUpAndExit(); |
| 155 | 153 | return 1; |
| @@ -351,22 +349,28 @@ static void cleanUpAndExit(void) // never call this inside the main loop! · 195 unmodified lines | ||
| 351 | 349 | } |
| 352 | 350 | #endif |
| 353 | 351 | |
| 354 | − if (editor.audioDevConfigFileLocation != NULL) | |
| 352 | + if (editor.audioDevConfigFileLocationU != NULL) | |
| 353 | + { | |
| 354 | + free(editor.audioDevConfigFileLocationU); | |
| 355 | + editor.audioDevConfigFileLocationU = NULL; | |
| 356 | + } | |
| 357 | + | |
| 358 | + if (editor.configFileLocationU != NULL) | |
| 355 | 359 | { |
| 356 | − free(editor.audioDevConfigFileLocation); | |
| 357 | − editor.audioDevConfigFileLocation = NULL; | |
| 360 | + free(editor.configFileLocationU); | |
| 361 | + editor.configFileLocationU = NULL; | |
| 358 | 362 | } |
| 359 | 363 | |
| 360 | − if (editor.configFileLocation != NULL) | |
| 364 | + if (editor.midiConfigFileLocationU != NULL) | |
| 361 | 365 | { |
| 362 | − free(editor.configFileLocation); | |
| 363 | − editor.configFileLocation = NULL; | |
| 366 | + free(editor.midiConfigFileLocationU); | |
| 367 | + editor.midiConfigFileLocationU = NULL; | |
| 364 | 368 | } |
| 365 | 369 | |
| 366 | − if (editor.midiConfigFileLocation != NULL) | |
| 370 | + if (editor.binaryPathU != NULL) | |
| 367 | 371 | { |
| 368 | − free(editor.midiConfigFileLocation); | |
| 369 | − editor.midiConfigFileLocation = NULL; | |
| 372 | + free(editor.binaryPathU); | |
| 373 | + editor.binaryPathU = NULL; | |
| 370 | 374 | } |
| 371 | 375 | |
| 372 | 376 | #ifdef _WIN32 |
| @@ -18,6 +18,8 @@ · 17 unmodified lines | ||
| 18 | 18 | #include "ft2_structs.h" |
| 19 | 19 | #include "rtmidi/rtmidi_c.h" |
| 20 | 20 | |
| 21 | +#define MAX_DEV_STR_LEN 256 | |
| 22 | + | |
| 21 | 23 | // hide POSIX warnings |
| 22 | 24 | #ifdef _MSC_VER |
| 23 | 25 | #pragma warning(disable: 4996) |
| @@ -265,7 +267,7 @@ bool saveMidiInputDeviceToConfig(void) · 241 unmodified lines | ||
| 265 | 267 | if (midiInStr == NULL) |
| 266 | 268 | return false; |
| 267 | 269 | |
| 268 | − FILE *f = UNICHAR_FOPEN(editor.midiConfigFileLocation, "w"); | |
| 270 | + FILE *f = UNICHAR_FOPEN(editor.midiConfigFileLocationU, "w"); | |
| 269 | 271 | if (f == NULL) |
| 270 | 272 | { |
| 271 | 273 | free(midiInStr); |
| @@ -281,8 +283,6 @@ bool saveMidiInputDeviceToConfig(void) · 9 unmodified lines | ||
| 281 | 283 | |
| 282 | 284 | bool setMidiInputDeviceFromConfig(void) |
| 283 | 285 | { |
| 284 | −#define MAX_DEV_STR_LEN 1024 | |
| 285 | − | |
| 286 | 286 | uint32_t i; |
| 287 | 287 | |
| 288 | 288 | if (midi.inputDeviceName != NULL) |
| @@ -292,17 +292,19 @@ bool setMidiInputDeviceFromConfig(void) · 3 unmodified lines | ||
| 292 | 292 | if (numDevices == 0) |
| 293 | 293 | goto setDefMidiInputDev; |
| 294 | 294 | |
| 295 | − FILE *f = UNICHAR_FOPEN(editor.midiConfigFileLocation, "r"); | |
| 295 | + FILE *f = UNICHAR_FOPEN(editor.midiConfigFileLocationU, "r"); | |
| 296 | 296 | if (f == NULL) |
| 297 | 297 | goto setDefMidiInputDev; |
| 298 | 298 | |
| 299 | − char *devString = (char *)calloc(MAX_DEV_STR_LEN+4, sizeof (char)); | |
| 299 | + char *devString = (char *)malloc((MAX_DEV_STR_LEN+4) * sizeof (char)); | |
| 300 | 300 | if (devString == NULL) |
| 301 | 301 | { |
| 302 | 302 | fclose(f); |
| 303 | 303 | goto setDefMidiInputDev; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | + devString[0] = '\0'; | |
| 307 | + | |
| 306 | 308 | if (fgets(devString, MAX_DEV_STR_LEN, f) == NULL) |
| 307 | 309 | { |
| 308 | 310 | fclose(f); |
| @@ -526,9 +526,7 @@ static void setupLoadedModule(void) · 525 unmodified lines | ||
| 526 | 526 | |
| 527 | 527 | bool handleModuleLoadFromArg(int argc, char **argv) |
| 528 | 528 | { |
| 529 | − UNICHAR tmpPathU[PATH_MAX+2]; | |
| 530 | − | |
| 531 | − // this is crude, we always expect only one parameter, and that it is the module. | |
| 529 | + // we always expect only one parameter, and that it is the module | |
| 532 | 530 | |
| 533 | 531 | if (argc != 2 || argv[1] == NULL || argv[1][0] == '\0') |
| 534 | 532 | return false; |
| @@ -540,15 +538,26 @@ bool handleModuleLoadFromArg(int argc, char **argv) · 5 unmodified lines | ||
| 540 | 538 | |
| 541 | 539 | const uint32_t filenameLen = (const uint32_t)strlen(argv[1]); |
| 542 | 540 | |
| 543 | − UNICHAR *filenameU = (UNICHAR *)calloc(filenameLen+1, sizeof (UNICHAR)); | |
| 541 | + UNICHAR *tmpPathU = (UNICHAR *)malloc((PATH_MAX + 1) * sizeof (UNICHAR)); | |
| 542 | + if (tmpPathU == NULL) | |
| 543 | + { | |
| 544 | + okBox(0, "System message", "Not enough memory!"); | |
| 545 | + return false; | |
| 546 | + } | |
| 547 | + | |
| 548 | + UNICHAR *filenameU = (UNICHAR *)malloc((filenameLen + 1) * sizeof (UNICHAR)); | |
| 544 | 549 | if (filenameU == NULL) |
| 545 | 550 | { |
| 551 | + free(tmpPathU); | |
| 546 | 552 | okBox(0, "System message", "Not enough memory!"); |
| 547 | 553 | return false; |
| 548 | 554 | } |
| 549 | 555 | |
| 556 | + tmpPathU[0] = 0; | |
| 557 | + filenameU[0] = 0; | |
| 558 | + | |
| 550 | 559 | #ifdef _WIN32 |
| 551 | − MultiByteToWideChar(CP_UTF8, 0, argv[1], -1, filenameU, filenameLen); | |
| 560 | + MultiByteToWideChar(CP_UTF8, 0, argv[1], -1, filenameU, filenameLen+1); | |
| 552 | 561 | #else |
| 553 | 562 | strcpy(filenameU, argv[1]); |
| 554 | 563 | #endif |
| @@ -562,9 +571,11 @@ bool handleModuleLoadFromArg(int argc, char **argv) · 7 unmodified lines | ||
| 562 | 571 | const int32_t filesize = getFileSize(filenameU); |
| 563 | 572 | if (filesize == -1 || filesize >= 512L*1024*1024) // 1) >=2GB 2) >=512MB |
| 564 | 573 | { |
| 565 | − okBox(0, "System message", "Error: The module is too big to be loaded!"); | |
| 566 | 574 | free(filenameU); |
| 567 | 575 | UNICHAR_CHDIR(tmpPathU); // set old path back |
| 576 | + free(tmpPathU); | |
| 577 | + | |
| 578 | + okBox(0, "System message", "Error: The module is too big to be loaded!"); | |
| 568 | 579 | return false; |
| 569 | 580 | } |
| 570 | 581 | |
| @@ -572,6 +583,8 @@ bool handleModuleLoadFromArg(int argc, char **argv) · 1 unmodified line | ||
| 572 | 583 | |
| 573 | 584 | free(filenameU); |
| 574 | 585 | UNICHAR_CHDIR(tmpPathU); // set old path back |
| 586 | + free(tmpPathU); | |
| 587 | + | |
| 575 | 588 | return result; |
| 576 | 589 | } |
| 577 | 590 | |
| @@ -642,15 +655,17 @@ void loadDroppedFile(char *fullPathUTF8, bool songModifiedCheck) · 64 unmodified lines | ||
| 642 | 655 | if (fullPathLen == 0) |
| 643 | 656 | return; |
| 644 | 657 | |
| 645 | − UNICHAR *fullPathU = (UNICHAR *)calloc(fullPathLen + 2, sizeof (UNICHAR)); | |
| 658 | + UNICHAR *fullPathU = (UNICHAR *)malloc((fullPathLen + 1) * sizeof (UNICHAR)); | |
| 646 | 659 | if (fullPathU == NULL) |
| 647 | 660 | { |
| 648 | 661 | okBox(0, "System message", "Not enough memory!"); |
| 649 | 662 | return; |
| 650 | 663 | } |
| 651 | 664 | |
| 665 | + fullPathU[0] = 0; | |
| 666 | + | |
| 652 | 667 | #ifdef _WIN32 |
| 653 | − MultiByteToWideChar(CP_UTF8, 0, fullPathUTF8, -1, fullPathU, fullPathLen); | |
| 668 | + MultiByteToWideChar(CP_UTF8, 0, fullPathUTF8, -1, fullPathU, fullPathLen+1); | |
| 654 | 669 | #else |
| 655 | 670 | strcpy(fullPathU, fullPathUTF8); |
| 656 | 671 | #endif |
| @@ -301,7 +301,7 @@ static void changeCursorIfOverTextBoxes(void) · 300 unmodified lines | ||
| 301 | 301 | textBox_t *t = textBoxes; |
| 302 | 302 | for (i = 0; i < NUM_TEXTBOXES; i++, t++) |
| 303 | 303 | { |
| 304 | − if (ui.sysReqShown && i > 0) | |
| 304 | + if (ui.sysReqShown && i != 0) // Sys. Req can only have one (special) text box | |
| 305 | 305 | continue; |
| 306 | 306 | |
| 307 | 307 | if (!t->visible) |
| @@ -313,7 +313,10 @@ static void changeCursorIfOverTextBoxes(void) · 5 unmodified lines | ||
| 313 | 313 | if (my >= t->y && my < t->y+t->h && mx >= t->x && mx < t->x+t->w) |
| 314 | 314 | { |
| 315 | 315 | mouse.mouseOverTextBox = true; |
| 316 | − setTextEditMouse(); | |
| 316 | + | |
| 317 | + if (mouseShape != MOUSE_IDLE_TEXT_EDIT) | |
| 318 | + setTextEditMouse(); | |
| 319 | + | |
| 317 | 320 | return; |
| 318 | 321 | } |
| 319 | 322 | } |
| @@ -11,9 +11,8 @@ typedef struct cpu_t · 10 unmodified lines | ||
| 11 | 11 | |
| 12 | 12 | typedef struct editor_t |
| 13 | 13 | { |
| 14 | − UNICHAR binaryPathU[PATH_MAX + 2]; | |
| 15 | − UNICHAR *tmpFilenameU, *tmpInstrFilenameU; // used by saving/loading threads | |
| 16 | − UNICHAR *configFileLocation, *audioDevConfigFileLocation, *midiConfigFileLocation; | |
| 14 | + UNICHAR *binaryPathU, *tmpFilenameU, *tmpInstrFilenameU; // used by saving/loading threads | |
| 15 | + UNICHAR *configFileLocationU, *audioDevConfigFileLocationU, *midiConfigFileLocationU; | |
| 17 | 16 | |
| 18 | 17 | volatile bool mainLoopOngoing; |
| 19 | 18 | volatile bool busy, scopeThreadMutex, programRunning, wavIsRendering, wavReachedEndFlag; |
| @@ -299,8 +299,11 @@ int16_t okBox(int16_t typ, const char *headline, const char *text) · 298 unmodified lines | ||
| 299 | 299 | { |
| 300 | 300 | if (inputEvent.key.keysym.sym == SDLK_ESCAPE) |
| 301 | 301 | { |
| 302 | − returnVal = 0; | |
| 303 | − ui.sysReqShown = false; | |
| 302 | + if (!inputEvent.key.repeat) // don't let previously held-down ESC immediately close the box | |
| 303 | + { | |
| 304 | + returnVal = 0; | |
| 305 | + ui.sysReqShown = false; | |
| 306 | + } | |
| 304 | 307 | } |
| 305 | 308 | else if (inputEvent.key.keysym.sym == SDLK_RETURN) |
| 306 | 309 | { |
| @@ -52,7 +52,7 @@ textBox_t textBoxes[NUM_TEXTBOXES] = · 51 unmodified lines | ||
| 52 | 52 | |
| 53 | 53 | // ------ DISK OP. TEXTBOXES ------ |
| 54 | 54 | // x, y, w, h, tx,ty, maxc, rmb, cmc |
| 55 | − { 31, 158, 134, 12, 2, 1, PATH_MAX-1, false, true }, | |
| 55 | + { 31, 158, 134, 12, 2, 1, PATH_MAX, false, true }, | |
| 56 | 56 | |
| 57 | 57 | // ------ CONFIG TEXTBOXES ------ |
| 58 | 58 | // x, y, w, h, tx,ty, maxc, rmb, cmc |
| @@ -57,15 +57,14 @@ char *cp437ToUtf8(char *src) · 56 unmodified lines | ||
| 57 | 57 | return NULL; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | − char *x = (char *)malloc((reqSize + 2) * sizeof (char)); | |
| 60 | + char *x = (char *)malloc((reqSize + 1) * sizeof (char)); | |
| 61 | 61 | if (x == NULL) |
| 62 | 62 | { |
| 63 | 63 | free(w); |
| 64 | 64 | return NULL; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | − x[reqSize+0] = '\0'; | |
| 68 | − x[reqSize+1] = '\0'; | |
| 67 | + x[reqSize] = '\0'; | |
| 69 | 68 | |
| 70 | 69 | retVal = WideCharToMultiByte(CP_UTF8, 0, w, srcLen, x, reqSize, 0, 0); |
| 71 | 70 | free(w); |
| @@ -148,7 +147,7 @@ char *utf8ToCp437(char *src, bool removeIllegalChars) · 76 unmodified lines | ||
| 148 | 147 | return NULL; |
| 149 | 148 | } |
| 150 | 149 | |
| 151 | − char *x = (char *)calloc(reqSize + 1, sizeof (char)); | |
| 150 | + char *x = (char *)malloc((reqSize + 1) * sizeof (char)); | |
| 152 | 151 | if (x == NULL) |
| 153 | 152 | { |
| 154 | 153 | free(w); |
| @@ -216,7 +215,7 @@ char *unicharToCp437(UNICHAR *src, bool removeIllegalChars) · 61 unmodified lines | ||
| 216 | 215 | { |
| 217 | 216 | const int8_t ch = (const int8_t)x[i]; |
| 218 | 217 | if (ch < 32 && ch != 0 && ch != -124 && ch != -108 && |
| 219 | − ch != -122 && ch != -114 && ch != -103 && ch != -113) | |
| 218 | + ch != -122 && ch != -114 && ch != -103 && ch != -113) | |
| 220 | 219 | { |
| 221 | 220 | x[i] = ' '; // character not allowed, turn it into space |
| 222 | 221 | } |
| @@ -244,7 +243,7 @@ char *cp437ToUtf8(char *src) · 21 unmodified lines | ||
| 244 | 243 | |
| 245 | 244 | size_t outLen = srcLen * 2; // should be sufficient |
| 246 | 245 | |
| 247 | − char *outBuf = (char *)calloc(outLen + 2, sizeof (char)); | |
| 246 | + char *outBuf = (char *)malloc((outLen + 1) * sizeof (char)); | |
| 248 | 247 | if (outBuf == NULL) |
| 249 | 248 | return NULL; |
| 250 | 249 | |
| @@ -266,6 +265,8 @@ char *cp437ToUtf8(char *src) · 15 unmodified lines | ||
| 266 | 265 | return NULL; |
| 267 | 266 | } |
| 268 | 267 | |
| 268 | + outBuf[outLen] = '\0'; | |
| 269 | + | |
| 269 | 270 | return outBuf; |
| 270 | 271 | } |
| 271 | 272 | |
| @@ -290,7 +291,7 @@ char *utf8ToCp437(char *src, bool removeIllegalChars) · 18 unmodified lines | ||
| 290 | 291 | |
| 291 | 292 | size_t outLen = srcLen * 2; // should be sufficient |
| 292 | 293 | |
| 293 | − char *outBuf = (char *)calloc(outLen + 1, sizeof (char)); | |
| 294 | + char *outBuf = (char *)malloc((outLen + 1) * sizeof (char)); | |
| 294 | 295 | if (outBuf == NULL) |
| 295 | 296 | return NULL; |
| 296 | 297 | |
| @@ -312,6 +313,8 @@ char *utf8ToCp437(char *src, bool removeIllegalChars) · 15 unmodified lines | ||
| 312 | 313 | return NULL; |
| 313 | 314 | } |
| 314 | 315 | |
| 316 | + outBuf[outLen] = '\0'; | |
| 317 | + | |
| 315 | 318 | if (removeIllegalChars) |
| 316 | 319 | { |
| 317 | 320 | // remove illegal characters (only allow certain nordic ones) |
| @@ -319,7 +322,7 @@ char *utf8ToCp437(char *src, bool removeIllegalChars) · 1 unmodified line | ||
| 319 | 322 | { |
| 320 | 323 | const int8_t ch = (const int8_t)outBuf[i]; |
| 321 | 324 | if (ch < 32 && ch != 0 && ch != -124 && ch != -108 && |
| 322 | − ch != -122 && ch != -114 && ch != -103 && ch != -113) | |
| 325 | + ch != -122 && ch != -114 && ch != -103 && ch != -113) | |
| 323 | 326 | { |
| 324 | 327 | outBuf[i] = ' '; // character not allowed, turn it into space |
| 325 | 328 | } |
| @@ -46,7 +46,7 @@ static const uint8_t textCursorData[12] = · 45 unmodified lines | ||
| 46 | 46 | video_t video; // globalized |
| 47 | 47 | |
| 48 | 48 | static bool songIsModified; |
| 49 | −static char wndTitle[128 + PATH_MAX]; | |
| 49 | +static char wndTitle[256]; | |
| 50 | 50 | static uint64_t timeNext64, timeNext64Frac; |
| 51 | 51 | static sprite_t sprites[SPRITE_NUM]; |
| 52 | 52 | |
| @@ -845,10 +845,14 @@ void updateWindowTitle(bool forceUpdate) · 792 unmodified lines | ||
| 845 | 845 | char *songTitle = getCurrSongFilename(); |
| 846 | 846 | if (songTitle != NULL) |
| 847 | 847 | { |
| 848 | + char songTitleTrunc[128]; | |
| 849 | + strncpy(songTitleTrunc, songTitle, sizeof (songTitleTrunc)-1); | |
| 850 | + songTitleTrunc[sizeof (songTitleTrunc)-1] = '\0'; | |
| 851 | + | |
| 848 | 852 | if (song.isModified) |
| 849 | − sprintf(wndTitle, "Fasttracker II clone v%s - \"%s\" (unsaved)", PROG_VER_STR, songTitle); | |
| 853 | + sprintf(wndTitle, "Fasttracker II clone v%s - \"%s\" (unsaved)", PROG_VER_STR, songTitleTrunc); | |
| 850 | 854 | else |
| 851 | − sprintf(wndTitle, "Fasttracker II clone v%s - \"%s\"", PROG_VER_STR, songTitle); | |
| 855 | + sprintf(wndTitle, "Fasttracker II clone v%s - \"%s\"", PROG_VER_STR, songTitleTrunc); | |
| 852 | 856 | } |
| 853 | 857 | else |
| 854 | 858 | { |
| @@ -923,10 +923,6 @@ END · 922 unmodified lines | ||
| 923 | 923 | and you need to press a key or click the mouse to abort the render when you want |
| 924 | 924 | it to. |
| 925 | 925 | >@X010 |
| 926 | −>@C001Mouse / keyboard: | |
| 927 | −> | |
| 928 | −>@C002- Linux: The mouse cursor graphics can be glitchy at times... | |
| 929 | −>@X010 | |
| 930 | 926 | >@C001Video: |
| 931 | 927 | >@C002 |
| 932 | 928 | >@X010- Fullscreen mode can be unbearably slow on a Raspberry Pi (even on RPi 4) |
| @@ -3,9 +3,9 @@ · 2 unmodified lines | ||
| 3 | 3 | |
| 4 | 4 | #include <stdint.h> |
| 5 | 5 | |
| 6 | −#define HELP_DATA_LEN 27486 | |
| 6 | +#define HELP_DATA_LEN 27385 | |
| 7 | 7 | |
| 8 | −const uint8_t helpData[27486] = | |
| 8 | +const uint8_t helpData[27385] = | |
| 9 | 9 | { |
| 10 | 10 | 0x4C,0x3B,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A, |
| 11 | 11 | 0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A, |
| @@ -2258,46 +2258,38 @@ const uint8_t helpData[27486] = · 2246 unmodified lines | ||
| 2258 | 2258 | 0x74,0x6F,0x20,0x61,0x62,0x6F,0x72,0x74,0x20,0x74,0x68,0x65, |
| 2259 | 2259 | 0x20,0x72,0x65,0x6E,0x64,0x65,0x72,0x20,0x77,0x68,0x65,0x6E, |
| 2260 | 2260 | 0x20,0x79,0x6F,0x75,0x20,0x77,0x61,0x6E,0x74,0x06,0x69,0x74, |
| 2261 | − 0x20,0x74,0x6F,0x2E,0x06,0x3E,0x40,0x58,0x30,0x31,0x30,0x17, | |
| 2262 | − 0x3E,0x40,0x43,0x30,0x30,0x31,0x4D,0x6F,0x75,0x73,0x65,0x20, | |
| 2263 | − 0x2F,0x20,0x6B,0x65,0x79,0x62,0x6F,0x61,0x72,0x64,0x3A,0x01, | |
| 2264 | − 0x3E,0x43,0x3E,0x40,0x43,0x30,0x30,0x32,0x2D,0x20,0x4C,0x69, | |
| 2265 | − 0x6E,0x75,0x78,0x3A,0x20,0x54,0x68,0x65,0x20,0x6D,0x6F,0x75, | |
| 2266 | − 0x73,0x65,0x20,0x63,0x75,0x72,0x73,0x6F,0x72,0x20,0x67,0x72, | |
| 2267 | − 0x61,0x70,0x68,0x69,0x63,0x73,0x20,0x63,0x61,0x6E,0x20,0x62, | |
| 2268 | − 0x65,0x20,0x67,0x6C,0x69,0x74,0x63,0x68,0x79,0x20,0x61,0x74, | |
| 2269 | − 0x20,0x74,0x69,0x6D,0x65,0x73,0x2E,0x2E,0x2E,0x06,0x3E,0x40, | |
| 2270 | − 0x58,0x30,0x31,0x30,0x0C,0x3E,0x40,0x43,0x30,0x30,0x31,0x56, | |
| 2271 | − 0x69,0x64,0x65,0x6F,0x3A,0x06,0x3E,0x40,0x43,0x30,0x30,0x32, | |
| 2272 | − 0x50,0x3E,0x40,0x58,0x30,0x31,0x30,0x2D,0x20,0x46,0x75,0x6C, | |
| 2273 | − 0x6C,0x73,0x63,0x72,0x65,0x65,0x6E,0x20,0x6D,0x6F,0x64,0x65, | |
| 2274 | − 0x20,0x63,0x61,0x6E,0x20,0x62,0x65,0x20,0x75,0x6E,0x62,0x65, | |
| 2275 | − 0x61,0x72,0x61,0x62,0x6C,0x79,0x20,0x73,0x6C,0x6F,0x77,0x20, | |
| 2276 | − 0x6F,0x6E,0x20,0x61,0x20,0x52,0x61,0x73,0x70,0x62,0x65,0x72, | |
| 2277 | − 0x72,0x79,0x20,0x50,0x69,0x20,0x28,0x65,0x76,0x65,0x6E,0x20, | |
| 2278 | − 0x6F,0x6E,0x20,0x52,0x50,0x69,0x20,0x34,0x29,0x01,0x3E,0x52, | |
| 2279 | − 0x3E,0x40,0x58,0x30,0x31,0x30,0x2D,0x20,0x4E,0x6F,0x74,0x20, | |
| 2280 | − 0x61,0x20,0x62,0x75,0x67,0x2C,0x20,0x62,0x75,0x74,0x20,0x69, | |
| 2281 | − 0x66,0x20,0x79,0x6F,0x75,0x72,0x20,0x6D,0x6F,0x6E,0x69,0x74, | |
| 2282 | − 0x6F,0x72,0x27,0x73,0x20,0x72,0x65,0x66,0x72,0x65,0x73,0x68, | |
| 2283 | − 0x20,0x72,0x61,0x74,0x65,0x20,0x69,0x73,0x20,0x6E,0x6F,0x74, | |
| 2284 | − 0x20,0x73,0x65,0x74,0x20,0x74,0x6F,0x20,0x36,0x30,0x48,0x7A, | |
| 2285 | − 0x20,0x28,0x6F,0x72,0x20,0x35,0x39,0x48,0x7A,0x29,0x4F,0x3E, | |
| 2286 | − 0x40,0x58,0x30,0x32,0x31,0x79,0x6F,0x75,0x20,0x6D,0x61,0x79, | |
| 2287 | − 0x20,0x65,0x78,0x70,0x65,0x72,0x69,0x65,0x6E,0x63,0x65,0x20, | |
| 2288 | − 0x76,0x69,0x73,0x75,0x61,0x6C,0x20,0x73,0x74,0x75,0x74,0x74, | |
| 2289 | − 0x65,0x72,0x69,0x6E,0x67,0x20,0x62,0x65,0x63,0x61,0x75,0x73, | |
| 2290 | − 0x65,0x20,0x56,0x53,0x79,0x6E,0x63,0x20,0x77,0x69,0x6C,0x6C, | |
| 2291 | − 0x20,0x6E,0x6F,0x74,0x20,0x62,0x65,0x20,0x75,0x73,0x65,0x64, | |
| 2292 | − 0x20,0x74,0x68,0x65,0x6E,0x2E,0x51,0x49,0x20,0x68,0x69,0x67, | |
| 2293 | − 0x68,0x6C,0x79,0x20,0x72,0x65,0x63,0x6F,0x6D,0x6D,0x65,0x6E, | |
| 2294 | − 0x64,0x20,0x72,0x75,0x6E,0x6E,0x69,0x6E,0x67,0x20,0x79,0x6F, | |
| 2295 | − 0x75,0x72,0x20,0x6D,0x6F,0x6E,0x69,0x74,0x6F,0x72,0x20,0x61, | |
| 2296 | − 0x74,0x20,0x36,0x30,0x48,0x7A,0x20,0x69,0x66,0x20,0x79,0x6F, | |
| 2297 | − 0x75,0x27,0x72,0x65,0x20,0x61,0x20,0x68,0x61,0x72,0x64,0x63, | |
| 2298 | − 0x6F,0x72,0x65,0x20,0x75,0x73,0x65,0x72,0x20,0x6F,0x66,0x20, | |
| 2299 | − 0x74,0x68,0x69,0x73,0x08,0x70,0x72,0x6F,0x67,0x72,0x61,0x6D, | |
| 2300 | − 0x2E,0x00,0x03,0x45,0x4E,0x44 | |
| 2261 | + 0x20,0x74,0x6F,0x2E,0x06,0x3E,0x40,0x58,0x30,0x31,0x30,0x0C, | |
| 2262 | + 0x3E,0x40,0x43,0x30,0x30,0x31,0x56,0x69,0x64,0x65,0x6F,0x3A, | |
| 2263 | + 0x06,0x3E,0x40,0x43,0x30,0x30,0x32,0x50,0x3E,0x40,0x58,0x30, | |
| 2264 | + 0x31,0x30,0x2D,0x20,0x46,0x75,0x6C,0x6C,0x73,0x63,0x72,0x65, | |
| 2265 | + 0x65,0x6E,0x20,0x6D,0x6F,0x64,0x65,0x20,0x63,0x61,0x6E,0x20, | |
| 2266 | + 0x62,0x65,0x20,0x75,0x6E,0x62,0x65,0x61,0x72,0x61,0x62,0x6C, | |
| 2267 | + 0x79,0x20,0x73,0x6C,0x6F,0x77,0x20,0x6F,0x6E,0x20,0x61,0x20, | |
| 2268 | + 0x52,0x61,0x73,0x70,0x62,0x65,0x72,0x72,0x79,0x20,0x50,0x69, | |
| 2269 | + 0x20,0x28,0x65,0x76,0x65,0x6E,0x20,0x6F,0x6E,0x20,0x52,0x50, | |
| 2270 | + 0x69,0x20,0x34,0x29,0x01,0x3E,0x52,0x3E,0x40,0x58,0x30,0x31, | |
| 2271 | + 0x30,0x2D,0x20,0x4E,0x6F,0x74,0x20,0x61,0x20,0x62,0x75,0x67, | |
| 2272 | + 0x2C,0x20,0x62,0x75,0x74,0x20,0x69,0x66,0x20,0x79,0x6F,0x75, | |
| 2273 | + 0x72,0x20,0x6D,0x6F,0x6E,0x69,0x74,0x6F,0x72,0x27,0x73,0x20, | |
| 2274 | + 0x72,0x65,0x66,0x72,0x65,0x73,0x68,0x20,0x72,0x61,0x74,0x65, | |
| 2275 | + 0x20,0x69,0x73,0x20,0x6E,0x6F,0x74,0x20,0x73,0x65,0x74,0x20, | |
| 2276 | + 0x74,0x6F,0x20,0x36,0x30,0x48,0x7A,0x20,0x28,0x6F,0x72,0x20, | |
| 2277 | + 0x35,0x39,0x48,0x7A,0x29,0x4F,0x3E,0x40,0x58,0x30,0x32,0x31, | |
| 2278 | + 0x79,0x6F,0x75,0x20,0x6D,0x61,0x79,0x20,0x65,0x78,0x70,0x65, | |
| 2279 | + 0x72,0x69,0x65,0x6E,0x63,0x65,0x20,0x76,0x69,0x73,0x75,0x61, | |
| 2280 | + 0x6C,0x20,0x73,0x74,0x75,0x74,0x74,0x65,0x72,0x69,0x6E,0x67, | |
| 2281 | + 0x20,0x62,0x65,0x63,0x61,0x75,0x73,0x65,0x20,0x56,0x53,0x79, | |
| 2282 | + 0x6E,0x63,0x20,0x77,0x69,0x6C,0x6C,0x20,0x6E,0x6F,0x74,0x20, | |
| 2283 | + 0x62,0x65,0x20,0x75,0x73,0x65,0x64,0x20,0x74,0x68,0x65,0x6E, | |
| 2284 | + 0x2E,0x51,0x49,0x20,0x68,0x69,0x67,0x68,0x6C,0x79,0x20,0x72, | |
| 2285 | + 0x65,0x63,0x6F,0x6D,0x6D,0x65,0x6E,0x64,0x20,0x72,0x75,0x6E, | |
| 2286 | + 0x6E,0x69,0x6E,0x67,0x20,0x79,0x6F,0x75,0x72,0x20,0x6D,0x6F, | |
| 2287 | + 0x6E,0x69,0x74,0x6F,0x72,0x20,0x61,0x74,0x20,0x36,0x30,0x48, | |
| 2288 | + 0x7A,0x20,0x69,0x66,0x20,0x79,0x6F,0x75,0x27,0x72,0x65,0x20, | |
| 2289 | + 0x61,0x20,0x68,0x61,0x72,0x64,0x63,0x6F,0x72,0x65,0x20,0x75, | |
| 2290 | + 0x73,0x65,0x72,0x20,0x6F,0x66,0x20,0x74,0x68,0x69,0x73,0x08, | |
| 2291 | + 0x70,0x72,0x6F,0x67,0x72,0x61,0x6D,0x2E,0x00,0x03,0x45,0x4E, | |
| 2292 | + 0x44 | |
| 2301 | 2293 | }; |
| 2302 | 2294 | |
| 2303 | 2295 | #endif |