| 1 | // for finding memory leaks in debug mode with Visual Studio |
| 2 | #if defined _DEBUG && defined _MSC_VER |
| 3 | #include <crtdbg.h> |
| 4 | #endif |
| 5 | |
| 6 | #include <stdio.h> |
| 7 | #include <stdint.h> |
| 8 | #include <stdbool.h> |
| 9 | #include <string.h> |
| 10 | #include <ctype.h> // tolower() |
| 11 | #ifdef _WIN32 |
| 12 | #include <windows.h> |
| 13 | #else |
| 14 | #include <unistd.h> |
| 15 | #endif |
| 16 | #include "pt2_textout.h" |
| 17 | #include "pt2_helpers.h" |
| 18 | #include "pt2_visuals.h" |
| 19 | #include "pt2_diskop.h" |
| 20 | #include "pt2_edit.h" |
| 21 | #include "pt2_sampler.h" |
| 22 | #include "pt2_audio.h" |
| 23 | #include "pt2_tables.h" |
| 24 | #include "pt2_module_saver.h" |
| 25 | #include "pt2_sample_saver.h" |
| 26 | #include "pt2_config.h" |
| 27 | #include "pt2_sampling.h" |
| 28 | #include "pt2_chordmaker.h" |
| 29 | #include "pt2_askbox.h" |
| 30 | #include "pt2_replayer.h" |
| 31 | #include "pt2_posed.h" |
| 32 | #include "pt2_textedit.h" |
| 33 | |
| 34 | #if defined _WIN32 && !defined _DEBUG |
| 35 | extern bool windowsKeyIsDown; |
| 36 | extern HHOOK g_hKeyboardHook; |
| 37 | #endif |
| 38 | |
| 39 | static bool handleGeneralModes(SDL_Scancode scancode); |
| 40 | static void movePatCurPrevCh(void); |
| 41 | static void movePatCurNextCh(void); |
| 42 | static void movePatCurRight(void); |
| 43 | static void movePatCurLeft(void); |
| 44 | |
| 45 | bool handleTextEditMode(SDL_Scancode scancode); |
| 46 | |
| 47 | void readKeyModifiers(void) |
| 48 | { |
| 49 | const SDL_Keymod modState = SDL_GetModState(); |
| 50 | |
| 51 | keyb.leftCtrlPressed = (modState & KMOD_LCTRL) ? true : false; |
| 52 | keyb.leftAltPressed = (modState & KMOD_LALT) ? true : false; |
| 53 | keyb.shiftPressed = (modState & (KMOD_LSHIFT + KMOD_RSHIFT)) ? true : false; |
| 54 | |
| 55 | #ifdef __APPLE__ |
| 56 | keyb.leftCommandPressed = (modState & KMOD_LGUI) ? true : false; |
| 57 | #endif |
| 58 | |
| 59 | #if defined _WIN32 && !defined _DEBUG |
| 60 | keyb.leftAmigaPressed = windowsKeyIsDown; // Windows: handled in lowLevelKeyboardProc |
| 61 | #else |
| 62 | keyb.leftAmigaPressed = (modState & KMOD_LGUI) ? true : false; |
| 63 | #endif |
| 64 | } |
| 65 | |
| 66 | #if defined _WIN32 && !defined _DEBUG |
| 67 | /* For taking control over the windows key if the program has focus. |
| 68 | ** Warning: Don't do this in debug mode, it will completely ruin the keyboard input |
| 69 | ** latency (in the OS in general) when the debugger is breaking. |
| 70 | */ |
| 71 | LRESULT CALLBACK lowLevelKeyboardProc(int32_t nCode, WPARAM wParam, LPARAM lParam) |
| 72 | { |
| 73 | SDL_Window *window = video.window; |
| 74 | |
| 75 | if (nCode == HC_ACTION && window != NULL) |
| 76 | { |
| 77 | switch (wParam) |
| 78 | { |
| 79 | case WM_KEYUP: |
| 80 | case WM_KEYDOWN: |
| 81 | case WM_SYSKEYUP: // needed to prevent stuck Windows key if used with ALT |
| 82 | { |
| 83 | const bool windowHasFocus = SDL_GetWindowFlags(window) & SDL_WINDOW_INPUT_FOCUS; |
| 84 | if (!windowHasFocus) |
| 85 | { |
| 86 | windowsKeyIsDown = false; |
| 87 | break; |
| 88 | } |
| 89 | |
| 90 | if (((KBDLLHOOKSTRUCT *)lParam)->vkCode != VK_LWIN) |
| 91 | break; |
| 92 | |
| 93 | windowsKeyIsDown = (wParam == WM_KEYDOWN); |
| 94 | return 1; // eat keystroke |
| 95 | } |
| 96 | break; |
| 97 | |
| 98 | default: break; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam); |
| 103 | } |
| 104 | #endif |
| 105 | |
| 106 | void keyUpHandler(SDL_Scancode scancode) |
| 107 | { |
| 108 | if (scancode == SDL_SCANCODE_KP_PLUS) |
| 109 | keyb.keypadEnterPressed = false; |
| 110 | |
| 111 | if (scancode == keyb.lastRepKey) |
| 112 | keyb.lastRepKey = SDL_SCANCODE_UNKNOWN; |
| 113 | |
| 114 | switch (scancode) |
| 115 | { |
| 116 | // modifiers shouldn't reset keyb repeat/delay flags & counters |
| 117 | case SDL_SCANCODE_LCTRL: |
| 118 | case SDL_SCANCODE_RCTRL: |
| 119 | case SDL_SCANCODE_LSHIFT: |
| 120 | case SDL_SCANCODE_RSHIFT: |
| 121 | case SDL_SCANCODE_LALT: |
| 122 | case SDL_SCANCODE_RALT: |
| 123 | case SDL_SCANCODE_LGUI: |
| 124 | case SDL_SCANCODE_RGUI: |
| 125 | case SDL_SCANCODE_MENU: |
| 126 | case SDL_SCANCODE_MODE: |
| 127 | case SDL_SCANCODE_CAPSLOCK: |
| 128 | break; |
| 129 | |
| 130 | default: |
| 131 | { |
| 132 | keyb.repeatKey = false; |
| 133 | keyb.delayKey = false; |
| 134 | keyb.repeatFrac = 0; |
| 135 | keyb.delayCounter = 0; |
| 136 | } |
| 137 | break; |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | static void incMulti(uint8_t slot) |
| 142 | { |
| 143 | char str[32]; |
| 144 | |
| 145 | ASSERT(slot < 4); |
| 146 | if (editor.multiModeNext[slot] == 4) |
| 147 | editor.multiModeNext[slot] = 1; |
| 148 | else |
| 149 | editor.multiModeNext[slot]++; |
| 150 | |
| 151 | sprintf(str, "MULTI=%d-%d-%d-%d", editor.multiModeNext[0], editor.multiModeNext[1], |
| 152 | editor.multiModeNext[2], editor.multiModeNext[3]); |
| 153 | displayMsg(str); |
| 154 | } |
| 155 | |
| 156 | void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode) |
| 157 | { |
| 158 | if (scancode == SDL_SCANCODE_CAPSLOCK) |
| 159 | { |
| 160 | editor.repeatKeyFlag ^= 1; |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | // kludge: allow certain specific key combos to be repeated with the ctrl key |
| 165 | const bool nonRepeatAltKeys = keyb.leftAltPressed && scancode != SDL_SCANCODE_DELETE && scancode != SDL_SCANCODE_RETURN |
| 166 | && scancode != SDL_SCANCODE_BACKSPACE && scancode != SDL_SCANCODE_BACKSLASH |
| 167 | && scancode != SDL_SCANCODE_EQUALS && scancode != SDL_SCANCODE_MINUS |
| 168 | && scancode < SDL_SCANCODE_1 && scancode > SDL_SCANCODE_0; |
| 169 | |
| 170 | // kludge: allow certain specific key combos to be repeated with the alt key |
| 171 | const bool nonRepeatCtrlKeys = keyb.leftCtrlPressed && scancode != SDL_SCANCODE_DELETE && scancode != SDL_SCANCODE_RETURN |
| 172 | && scancode != SDL_SCANCODE_BACKSPACE; |
| 173 | |
| 174 | // these keys should not allow to be repeated in keyrepeat mode (caps lock) |
| 175 | const bool dontRepeatReturnAndBackspace = !ui.editTextFlag && (scancode == SDL_SCANCODE_RETURN || scancode == SDL_SCANCODE_BACKSPACE); |
| 176 | const bool nonRepeatKeys = keyb.leftAmigaPressed || nonRepeatAltKeys || nonRepeatCtrlKeys |
| 177 | || scancode == SDL_SCANCODE_LEFT || scancode == SDL_SCANCODE_RIGHT |
| 178 | || scancode == SDL_SCANCODE_UP || scancode == SDL_SCANCODE_DOWN |
| 179 | || dontRepeatReturnAndBackspace; |
| 180 | if (editor.repeatKeyFlag && scancode == keyb.lastRepKey && nonRepeatKeys) |
| 181 | return; |
| 182 | |
| 183 | if (scancode == SDL_SCANCODE_KP_PLUS) |
| 184 | keyb.keypadEnterPressed = true; |
| 185 | |
| 186 | // TOGGLE FULLSCREEN (should always react) |
| 187 | if (scancode == SDL_SCANCODE_F11 && !keyb.leftAltPressed) |
| 188 | { |
| 189 | toggleFullscreen(); |
| 190 | return; |
| 191 | } |
| 192 | |
| 193 | // don't handle input if an error message wait is active or if an unknown key is passed |
| 194 | if ((editor.errorMsgActive && editor.errorMsgBlock) || scancode == SDL_SCANCODE_UNKNOWN) |
| 195 | return; |
| 196 | |
| 197 | // if no ALT/SHIFT/CTRL/AMIGA, update last key for repeat routine |
| 198 | if (scancode != SDL_SCANCODE_LALT && scancode != SDL_SCANCODE_RALT && |
| 199 | scancode != SDL_SCANCODE_LCTRL && scancode != SDL_SCANCODE_RCTRL && |
| 200 | scancode != SDL_SCANCODE_LSHIFT && scancode != SDL_SCANCODE_RSHIFT && |
| 201 | scancode != SDL_SCANCODE_LGUI && scancode != SDL_SCANCODE_RGUI && |
| 202 | scancode != SDL_SCANCODE_MENU && scancode != SDL_SCANCODE_MODE && |
| 203 | scancode != SDL_SCANCODE_CAPSLOCK && scancode != SDL_SCANCODE_ESCAPE) |
| 204 | { |
| 205 | if (editor.repeatKeyFlag) |
| 206 | { |
| 207 | // if Repeat Flag, repeat all keys |
| 208 | if (!keyb.repeatKey) |
| 209 | { |
| 210 | keyb.repeatCounter = 0; |
| 211 | keyb.repeatFrac = 0; |
| 212 | } |
| 213 | |
| 214 | keyb.repeatKey = true; |
| 215 | keyb.delayKey = true; |
| 216 | } |
| 217 | |
| 218 | keyb.repeatCounter = 0; |
| 219 | keyb.repeatFrac = 0; |
| 220 | |
| 221 | keyb.lastRepKey = scancode; |
| 222 | } |
| 223 | |
| 224 | |
| 225 | // ENTRY JUMPING IN DISK OP. FILELIST |
| 226 | if (ui.diskOpScreenShown && keyb.shiftPressed && !ui.editTextFlag) |
| 227 | { |
| 228 | if (keycode >= 32 && keycode <= 126) |
| 229 | { |
| 230 | handleEntryJumping(keycode); |
| 231 | return; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | // XXX: This really needs some refactoring, it's messy and not logical |
| 236 | |
| 237 | if (!handleGeneralModes(scancode)) return; |
| 238 | if (!handleTextEditMode(scancode)) return; |
| 239 | if (ui.samplerVolBoxShown || ui.samplingBoxShown) return; |
| 240 | |
| 241 | if (ui.samplerFiltersBoxShown) |
| 242 | { |
| 243 | handleEditKeys(scancode, EDIT_NORMAL); |
| 244 | return; |
| 245 | } |
| 246 | |
| 247 | // GENERAL KEYS |
| 248 | switch (scancode) |
| 249 | { |
| 250 | case SDL_SCANCODE_NONUSBACKSLASH: turnOffVoices(); break; // magic "kill all voices" button |
| 251 | |
| 252 | case SDL_SCANCODE_APOSTROPHE: |
| 253 | { |
| 254 | if (editor.autoInsFlag) |
| 255 | { |
| 256 | if (keyb.shiftPressed) |
| 257 | editor.autoInsSlot -= 4; |
| 258 | else |
| 259 | editor.autoInsSlot--; |
| 260 | |
| 261 | if (editor.autoInsSlot < 0) |
| 262 | editor.autoInsSlot = 0; |
| 263 | |
| 264 | ui.updateTrackerFlags = true; |
| 265 | } |
| 266 | } |
| 267 | break; |
| 268 | |
| 269 | case SDL_SCANCODE_BACKSLASH: |
| 270 | { |
| 271 | if (keyb.leftAltPressed) |
| 272 | { |
| 273 | if (handleSpecialKeys(scancode) && editor.currMode != MODE_RECORD) |
| 274 | modSetPos(DONT_SET_ORDER, (song->currRow + editor.editMoveAdd) & 63); |
| 275 | } |
| 276 | else |
| 277 | { |
| 278 | if (editor.autoInsFlag) |
| 279 | { |
| 280 | if (keyb.shiftPressed) |
| 281 | editor.autoInsSlot += 4; |
| 282 | else |
| 283 | editor.autoInsSlot++; |
| 284 | |
| 285 | if (editor.autoInsSlot > 9) |
| 286 | editor.autoInsSlot = 9; |
| 287 | } |
| 288 | else |
| 289 | { |
| 290 | editor.pNoteFlag = (editor.pNoteFlag + 1) % 3; |
| 291 | } |
| 292 | |
| 293 | ui.updateTrackerFlags = true; |
| 294 | } |
| 295 | } |
| 296 | break; |
| 297 | |
| 298 | #ifdef __APPLE__ |
| 299 | case SDL_SCANCODE_RGUI: |
| 300 | #else |
| 301 | case SDL_SCANCODE_RALT: |
| 302 | #endif |
| 303 | { |
| 304 | // right Amiga key on Amiga keyb |
| 305 | if (!ui.askBoxShown) |
| 306 | { |
| 307 | editor.playMode = PLAY_MODE_NORMAL; |
| 308 | modPlay(DONT_SET_PATTERN, song->currPos, DONT_SET_ROW); |
| 309 | editor.currMode = MODE_PLAY; |
| 310 | pointerSetMode(POINTER_MODE_PLAY, DO_CARRY); |
| 311 | statusAllRight(); |
| 312 | } |
| 313 | } |
| 314 | break; |
| 315 | |
| 316 | #ifdef __APPLE__ |
| 317 | case SDL_SCANCODE_RALT: |
| 318 | #else |
| 319 | case SDL_SCANCODE_RCTRL: |
| 320 | #endif |
| 321 | { |
| 322 | // right alt on Amiga keyb |
| 323 | if (!ui.askBoxShown) |
| 324 | { |
| 325 | editor.playMode = PLAY_MODE_PATTERN; |
| 326 | modPlay(song->currPattern, DONT_SET_ORDER, DONT_SET_ROW); |
| 327 | editor.currMode = MODE_PLAY; |
| 328 | pointerSetMode(POINTER_MODE_PLAY, DO_CARRY); |
| 329 | statusAllRight(); |
| 330 | } |
| 331 | } |
| 332 | break; |
| 333 | |
| 334 | case SDL_SCANCODE_RSHIFT: |
| 335 | { |
| 336 | // right shift on Amiga keyb |
| 337 | if (!ui.samplerScreenShown && !ui.askBoxShown) |
| 338 | { |
| 339 | editor.playMode = PLAY_MODE_PATTERN; |
| 340 | modPlay(song->currPattern, DONT_SET_ORDER, DONT_SET_ROW); |
| 341 | editor.currMode = MODE_RECORD; |
| 342 | pointerSetMode(POINTER_MODE_EDIT, DO_CARRY); |
| 343 | statusAllRight(); |
| 344 | } |
| 345 | } |
| 346 | break; |
| 347 | |
| 348 | case SDL_SCANCODE_ESCAPE: |
| 349 | { |
| 350 | if (ui.posEdScreenShown) |
| 351 | { |
| 352 | ui.posEdScreenShown = false; |
| 353 | displayMainScreen(); |
| 354 | } |
| 355 | else if (ui.diskOpScreenShown) |
| 356 | { |
| 357 | ui.diskOpScreenShown = false; |
| 358 | displayMainScreen(); |
| 359 | } |
| 360 | else if (ui.samplerScreenShown) |
| 361 | { |
| 362 | exitFromSam(); |
| 363 | } |
| 364 | else if (ui.editOpScreenShown) |
| 365 | { |
| 366 | ui.editOpScreenShown = false; |
| 367 | displayMainScreen(); |
| 368 | } |
| 369 | else |
| 370 | { |
| 371 | if (askBox(ASKBOX_YES_NO, "REALLY QUIT ?")) |
| 372 | { |
| 373 | ui.throwExit = true; |
| 374 | return; |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | pointerSetPreviousMode(); |
| 379 | setPrevStatusMessage(); |
| 380 | } |
| 381 | break; |
| 382 | |
| 383 | case SDL_SCANCODE_INSERT: |
| 384 | { |
| 385 | if (ui.samplerScreenShown) |
| 386 | { |
| 387 | samplerSamPaste(); |
| 388 | return; |
| 389 | } |
| 390 | } |
| 391 | break; |
| 392 | |
| 393 | case SDL_SCANCODE_PAGEUP: |
| 394 | { |
| 395 | if (ui.posEdScreenShown) |
| 396 | { |
| 397 | posEdPageUp(); |
| 398 | } |
| 399 | else if (ui.diskOpScreenShown) |
| 400 | { |
| 401 | diskop.scrollOffset -= DISKOP_LINES - 1; |
| 402 | if (diskop.scrollOffset < 0) |
| 403 | diskop.scrollOffset = 0; |
| 404 | |
| 405 | ui.updateDiskOpFileList = true; |
| 406 | } |
| 407 | else |
| 408 | { |
| 409 | if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT) |
| 410 | { |
| 411 | if (song->currRow == 63) |
| 412 | modSetPos(DONT_SET_ORDER, song->currRow - 15); |
| 413 | else if (song->currRow == 15) |
| 414 | modSetPos(DONT_SET_ORDER, 0); // 15-16 would turn into -1, which is "DON'T SET ROW" flag |
| 415 | else |
| 416 | modSetPos(DONT_SET_ORDER, song->currRow - 16); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | if (!keyb.repeatKey) |
| 421 | keyb.delayCounter = 0; |
| 422 | |
| 423 | keyb.repeatKey = true; |
| 424 | keyb.delayKey = true; |
| 425 | } |
| 426 | break; |
| 427 | |
| 428 | case SDL_SCANCODE_PAGEDOWN: |
| 429 | { |
| 430 | if (ui.posEdScreenShown) |
| 431 | { |
| 432 | posEdPageDown(); |
| 433 | } |
| 434 | else if (ui.diskOpScreenShown) |
| 435 | { |
| 436 | if (diskop.numEntries > DISKOP_LINES) |
| 437 | { |
| 438 | diskop.scrollOffset += DISKOP_LINES-1; |
| 439 | if (diskop.scrollOffset > diskop.numEntries-DISKOP_LINES) |
| 440 | diskop.scrollOffset = diskop.numEntries-DISKOP_LINES; |
| 441 | |
| 442 | ui.updateDiskOpFileList = true; |
| 443 | } |
| 444 | } |
| 445 | else |
| 446 | { |
| 447 | if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT) |
| 448 | modSetPos(DONT_SET_ORDER, song->currRow + 16); |
| 449 | } |
| 450 | |
| 451 | if (!keyb.repeatKey) |
| 452 | keyb.delayCounter = 0; |
| 453 | |
| 454 | keyb.repeatKey = true; |
| 455 | keyb.delayKey = true; |
| 456 | } |
| 457 | break; |
| 458 | |
| 459 | case SDL_SCANCODE_HOME: |
| 460 | { |
| 461 | if (ui.posEdScreenShown) |
| 462 | { |
| 463 | posEdScrollToTop(); |
| 464 | } |
| 465 | else if (ui.diskOpScreenShown) |
| 466 | { |
| 467 | if (diskop.scrollOffset != 0) |
| 468 | { |
| 469 | diskop.scrollOffset = 0; |
| 470 | ui.updateDiskOpFileList = true; |
| 471 | } |
| 472 | } |
| 473 | else |
| 474 | { |
| 475 | if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT) |
| 476 | modSetPos(DONT_SET_ORDER, 0); |
| 477 | } |
| 478 | } |
| 479 | break; |
| 480 | |
| 481 | case SDL_SCANCODE_END: |
| 482 | { |
| 483 | if (ui.posEdScreenShown) |
| 484 | { |
| 485 | posEdScrollToBottom(); |
| 486 | } |
| 487 | else if (ui.diskOpScreenShown) |
| 488 | { |
| 489 | if (diskop.numEntries > DISKOP_LINES) |
| 490 | { |
| 491 | diskop.scrollOffset = diskop.numEntries - DISKOP_LINES; |
| 492 | ui.updateDiskOpFileList = true; |
| 493 | } |
| 494 | } |
| 495 | else |
| 496 | { |
| 497 | if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT) |
| 498 | modSetPos(DONT_SET_ORDER, 63); |
| 499 | } |
| 500 | } |
| 501 | break; |
| 502 | |
| 503 | case SDL_SCANCODE_DELETE: |
| 504 | { |
| 505 | if (ui.samplerScreenShown) |
| 506 | samplerSamDelete(NO_SAMPLE_CUT); |
| 507 | else |
| 508 | handleEditKeys(scancode, EDIT_NORMAL); |
| 509 | } |
| 510 | break; |
| 511 | |
| 512 | case SDL_SCANCODE_F12: |
| 513 | { |
| 514 | if (keyb.leftCtrlPressed) |
| 515 | { |
| 516 | const bool audioWasntLocked = !audio.locked; |
| 517 | if (audioWasntLocked) |
| 518 | lockAudio(); |
| 519 | |
| 520 | editor.timingMode ^= 1; |
| 521 | updateReplayerTimingMode(); |
| 522 | |
| 523 | if (editor.timingMode == TEMPO_MODE_VBLANK) |
| 524 | { |
| 525 | editor.oldTempo = song->currBPM; |
| 526 | modSetTempo(125, false); |
| 527 | } |
| 528 | else |
| 529 | { |
| 530 | modSetTempo(editor.oldTempo, false); |
| 531 | } |
| 532 | |
| 533 | if (audioWasntLocked) |
| 534 | unlockAudio(); |
| 535 | |
| 536 | ui.updateSongTiming = true; |
| 537 | } |
| 538 | else if (keyb.shiftPressed) |
| 539 | { |
| 540 | toggleAmigaPanMode(); |
| 541 | } |
| 542 | else |
| 543 | { |
| 544 | toggleAmigaFilterModel(); |
| 545 | } |
| 546 | } |
| 547 | break; |
| 548 | |
| 549 | case SDL_SCANCODE_RETURN: |
| 550 | { |
| 551 | if (keyb.shiftPressed || keyb.leftAltPressed || keyb.leftCtrlPressed) |
| 552 | { |
| 553 | saveUndo(); |
| 554 | if (keyb.leftAltPressed && !keyb.leftCtrlPressed) |
| 555 | { |
| 556 | if (song->currRow < 63) |
| 557 | { |
| 558 | for (int32_t i = 0; i < PAULA_VOICES; i++) |
| 559 | { |
| 560 | int32_t j; |
| 561 | for (j = 62; j >= song->currRow; j--) |
| 562 | { |
| 563 | note_t *noteSrc = &song->patterns[song->currPattern][(j * PAULA_VOICES) + i]; |
| 564 | song->patterns[song->currPattern][((j + 1) * PAULA_VOICES) + i] = *noteSrc; |
| 565 | } |
| 566 | |
| 567 | note_t *noteDst = &song->patterns[song->currPattern][((j + 1) * PAULA_VOICES) + i]; |
| 568 | |
| 569 | noteDst->period = 0; |
| 570 | noteDst->sample = 0; |
| 571 | noteDst->command = 0; |
| 572 | noteDst->param = 0; |
| 573 | } |
| 574 | |
| 575 | song->currRow++; |
| 576 | |
| 577 | updateWindowTitle(MOD_IS_MODIFIED); |
| 578 | ui.updatePatternData = true; |
| 579 | } |
| 580 | } |
| 581 | else |
| 582 | { |
| 583 | if (song->currRow < 63) |
| 584 | { |
| 585 | int32_t i; |
| 586 | for (i = 62; i >= song->currRow; i--) |
| 587 | { |
| 588 | note_t *noteSrc = &song->patterns[song->currPattern][((i + 0) * PAULA_VOICES) + cursor.channel]; |
| 589 | note_t *noteDst = &song->patterns[song->currPattern][((i + 1) * PAULA_VOICES) + cursor.channel]; |
| 590 | |
| 591 | if (keyb.leftCtrlPressed) |
| 592 | { |
| 593 | noteDst->command = noteSrc->command; |
| 594 | noteDst->param = noteSrc->param; |
| 595 | } |
| 596 | else |
| 597 | { |
| 598 | *noteDst = *noteSrc; |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | note_t *noteDst = &song->patterns[song->currPattern][((i + 1) * PAULA_VOICES) + cursor.channel]; |
| 603 | |
| 604 | if (!keyb.leftCtrlPressed) |
| 605 | { |
| 606 | noteDst->period = 0; |
| 607 | noteDst->sample = 0; |
| 608 | } |
| 609 | |
| 610 | noteDst->command = 0; |
| 611 | noteDst->param = 0; |
| 612 | |
| 613 | song->currRow++; |
| 614 | |
| 615 | updateWindowTitle(MOD_IS_MODIFIED); |
| 616 | ui.updatePatternData = true; |
| 617 | } |
| 618 | } |
| 619 | } |
| 620 | else |
| 621 | { |
| 622 | const bool audioWasntLocked = !audio.locked; |
| 623 | if (audioWasntLocked) |
| 624 | lockAudio(); |
| 625 | |
| 626 | editor.stepPlayEnabled = true; |
| 627 | editor.stepPlayBackwards = false; |
| 628 | |
| 629 | editor.stepPlayLastMode = editor.currMode; |
| 630 | |
| 631 | if (config.keepEditModeAfterStepPlay && editor.stepPlayLastMode == MODE_EDIT) |
| 632 | doStopIt(false); |
| 633 | else |
| 634 | doStopIt(true); |
| 635 | |
| 636 | playPattern(song->currRow); |
| 637 | |
| 638 | if (config.keepEditModeAfterStepPlay && editor.stepPlayLastMode == MODE_EDIT) |
| 639 | { |
| 640 | pointerSetMode(POINTER_MODE_EDIT, DO_CARRY); |
| 641 | editor.playMode = PLAY_MODE_NORMAL; |
| 642 | editor.currMode = MODE_EDIT; |
| 643 | } |
| 644 | |
| 645 | if (audioWasntLocked) |
| 646 | unlockAudio(); |
| 647 | } |
| 648 | } |
| 649 | break; |
| 650 | |
| 651 | // toggle between IDLE and EDIT (IDLE if PLAY) |
| 652 | case SDL_SCANCODE_SPACE: |
| 653 | { |
| 654 | if (editor.currMode == MODE_PLAY) |
| 655 | { |
| 656 | modStop(); |
| 657 | editor.currMode = MODE_IDLE; |
| 658 | pointerSetMode(POINTER_MODE_IDLE, DO_CARRY); |
| 659 | statusAllRight(); |
| 660 | } |
| 661 | else if (editor.currMode == MODE_EDIT || editor.currMode == MODE_RECORD) |
| 662 | { |
| 663 | if (!ui.samplerScreenShown) |
| 664 | { |
| 665 | modStop(); |
| 666 | editor.currMode = MODE_IDLE; |
| 667 | pointerSetMode(POINTER_MODE_IDLE, DO_CARRY); |
| 668 | statusAllRight(); |
| 669 | } |
| 670 | } |
| 671 | else |
| 672 | { |
| 673 | if (!ui.samplerScreenShown) |
| 674 | { |
| 675 | modStop(); |
| 676 | editor.currMode = MODE_EDIT; |
| 677 | pointerSetMode(POINTER_MODE_EDIT, DO_CARRY); |
| 678 | statusAllRight(); |
| 679 | } |
| 680 | } |
| 681 | } |
| 682 | break; |
| 683 | |
| 684 | case SDL_SCANCODE_F1: editor.keyOctave = OCTAVE_LOW; break; |
| 685 | case SDL_SCANCODE_F2: editor.keyOctave = OCTAVE_HIGH; break; |
| 686 | |
| 687 | case SDL_SCANCODE_F3: |
| 688 | { |
| 689 | if (ui.samplerScreenShown) |
| 690 | { |
| 691 | samplerSamDelete(SAMPLE_CUT); |
| 692 | } |
| 693 | else |
| 694 | { |
| 695 | if (keyb.shiftPressed) |
| 696 | { |
| 697 | // cut channel and put in buffer |
| 698 | saveUndo(); |
| 699 | |
| 700 | note_t *noteDst = editor.trackBuffer; |
| 701 | for (int32_t i = 0; i < MOD_ROWS; i++) |
| 702 | { |
| 703 | note_t *noteSrc = &song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel]; |
| 704 | *noteDst++ = *noteSrc; |
| 705 | |
| 706 | noteSrc->period = 0; |
| 707 | noteSrc->sample = 0; |
| 708 | noteSrc->command = 0; |
| 709 | noteSrc->param = 0; |
| 710 | } |
| 711 | |
| 712 | updateWindowTitle(MOD_IS_MODIFIED); |
| 713 | ui.updatePatternData = true; |
| 714 | } |
| 715 | else if (keyb.leftAltPressed) |
| 716 | { |
| 717 | // cut pattern and put in buffer |
| 718 | saveUndo(); |
| 719 | |
| 720 | memcpy(editor.patternBuffer, song->patterns[song->currPattern], |
| 721 | sizeof (note_t) * (PAULA_VOICES * MOD_ROWS)); |
| 722 | |
| 723 | memset(song->patterns[song->currPattern], 0, |
| 724 | sizeof (note_t) * (PAULA_VOICES * MOD_ROWS)); |
| 725 | |
| 726 | updateWindowTitle(MOD_IS_MODIFIED); |
| 727 | ui.updatePatternData = true; |
| 728 | } |
| 729 | else if (keyb.leftCtrlPressed) |
| 730 | { |
| 731 | // cut channel commands and put in buffer |
| 732 | saveUndo(); |
| 733 | |
| 734 | note_t *noteDst = editor.cmdsBuffer; |
| 735 | for (int32_t i = 0; i < MOD_ROWS; i++) |
| 736 | { |
| 737 | note_t *noteSrc = &song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel]; |
| 738 | *noteDst++ = *noteSrc; |
| 739 | |
| 740 | noteSrc->command = 0; |
| 741 | noteSrc->param = 0; |
| 742 | } |
| 743 | |
| 744 | updateWindowTitle(MOD_IS_MODIFIED); |
| 745 | ui.updatePatternData = true; |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | break; |
| 750 | |
| 751 | case SDL_SCANCODE_F4: |
| 752 | { |
| 753 | if (ui.samplerScreenShown) |
| 754 | { |
| 755 | samplerSamCopy(); |
| 756 | } |
| 757 | else |
| 758 | { |
| 759 | if (keyb.shiftPressed) |
| 760 | { |
| 761 | // copy channel to buffer |
| 762 | |
| 763 | note_t *noteDst = editor.trackBuffer; |
| 764 | for (int32_t i = 0; i < MOD_ROWS; i++) |
| 765 | *noteDst++ = song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel]; |
| 766 | } |
| 767 | else if (keyb.leftAltPressed) |
| 768 | { |
| 769 | // copy pattern to buffer |
| 770 | |
| 771 | memcpy(editor.patternBuffer, song->patterns[song->currPattern], |
| 772 | sizeof (note_t) * (PAULA_VOICES * MOD_ROWS)); |
| 773 | } |
| 774 | else if (keyb.leftCtrlPressed) |
| 775 | { |
| 776 | // copy channel commands to buffer |
| 777 | |
| 778 | note_t *noteDst = editor.cmdsBuffer; |
| 779 | for (int32_t i = 0; i < MOD_ROWS; i++) |
| 780 | { |
| 781 | note_t *noteSrc = &song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel]; |
| 782 | noteDst->command = noteSrc->command; |
| 783 | noteDst->param = noteSrc->param; |
| 784 | |
| 785 | noteDst++; |
| 786 | } |
| 787 | } |
| 788 | } |
| 789 | } |
| 790 | break; |
| 791 | |
| 792 | case SDL_SCANCODE_F5: |
| 793 | { |
| 794 | if (ui.samplerScreenShown) |
| 795 | { |
| 796 | samplerSamPaste(); |
| 797 | } |
| 798 | else |
| 799 | { |
| 800 | if (keyb.shiftPressed) |
| 801 | { |
| 802 | // paste channel buffer to channel |
| 803 | saveUndo(); |
| 804 | |
| 805 | note_t *noteSrc = editor.trackBuffer; |
| 806 | for (int32_t i = 0; i < MOD_ROWS; i++) |
| 807 | song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel] = *noteSrc++; |
| 808 | |
| 809 | updateWindowTitle(MOD_IS_MODIFIED); |
| 810 | ui.updatePatternData = true; |
| 811 | } |
| 812 | else if (keyb.leftAltPressed) |
| 813 | { |
| 814 | // paste pattern buffer to pattern |
| 815 | saveUndo(); |
| 816 | |
| 817 | memcpy(song->patterns[song->currPattern], |
| 818 | editor.patternBuffer, sizeof (note_t) * (PAULA_VOICES * MOD_ROWS)); |
| 819 | |
| 820 | updateWindowTitle(MOD_IS_MODIFIED); |
| 821 | ui.updatePatternData = true; |
| 822 | } |
| 823 | else if (keyb.leftCtrlPressed) |
| 824 | { |
| 825 | // paste channel commands buffer to channel |
| 826 | saveUndo(); |
| 827 | |
| 828 | note_t *noteSrc = editor.cmdsBuffer; |
| 829 | for (int32_t i = 0; i < MOD_ROWS; i++) |
| 830 | { |
| 831 | note_t *noteDst = &song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel]; |
| 832 | noteDst->command = noteSrc->command; |
| 833 | noteDst->param = noteSrc->param; |
| 834 | |
| 835 | noteSrc++; |
| 836 | } |
| 837 | |
| 838 | updateWindowTitle(MOD_IS_MODIFIED); |
| 839 | ui.updatePatternData = true; |
| 840 | } |
| 841 | } |
| 842 | } |
| 843 | break; |
| 844 | |
| 845 | case SDL_SCANCODE_F6: |
| 846 | { |
| 847 | if (keyb.shiftPressed) |
| 848 | { |
| 849 | editor.f6Pos = song->currRow; |
| 850 | displayMsg("POSITION SET"); |
| 851 | } |
| 852 | else |
| 853 | { |
| 854 | if (keyb.leftAltPressed) |
| 855 | { |
| 856 | editor.playMode = PLAY_MODE_PATTERN; |
| 857 | modPlay(song->currPattern, DONT_SET_ORDER, editor.f6Pos); |
| 858 | |
| 859 | editor.currMode = MODE_PLAY; |
| 860 | pointerSetMode(POINTER_MODE_PLAY, DO_CARRY); |
| 861 | statusAllRight(); |
| 862 | } |
| 863 | else if (keyb.leftCtrlPressed) |
| 864 | { |
| 865 | if (!ui.samplerScreenShown) |
| 866 | { |
| 867 | editor.playMode = PLAY_MODE_PATTERN; |
| 868 | modPlay(song->currPattern, DONT_SET_ORDER, editor.f6Pos); |
| 869 | |
| 870 | editor.currMode = MODE_RECORD; |
| 871 | pointerSetMode(POINTER_MODE_EDIT, DO_CARRY); |
| 872 | statusAllRight(); |
| 873 | } |
| 874 | } |
| 875 | else if (keyb.leftAmigaPressed) |
| 876 | { |
| 877 | editor.playMode = PLAY_MODE_NORMAL; |
| 878 | modPlay(DONT_SET_PATTERN, song->currPos, editor.f6Pos); |
| 879 | |
| 880 | editor.currMode = MODE_PLAY; |
| 881 | pointerSetMode(POINTER_MODE_PLAY, DO_CARRY); |
| 882 | statusAllRight(); |
| 883 | } |
| 884 | else if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD) |
| 885 | { |
| 886 | modSetPos(DONT_SET_ORDER, editor.f6Pos); |
| 887 | } |
| 888 | } |
| 889 | } |
| 890 | break; |
| 891 | |
| 892 | case SDL_SCANCODE_F7: |
| 893 | { |
| 894 | if (keyb.shiftPressed) |
| 895 | { |
| 896 | editor.f7Pos = song->currRow; |
| 897 | displayMsg("POSITION SET"); |
| 898 | } |
| 899 | else |
| 900 | { |
| 901 | if (keyb.leftAltPressed) |
| 902 | { |
| 903 | editor.playMode = PLAY_MODE_PATTERN; |
| 904 | modPlay(song->currPattern, DONT_SET_ORDER, editor.f7Pos); |
| 905 | |
| 906 | editor.currMode = MODE_PLAY; |
| 907 | pointerSetMode(POINTER_MODE_PLAY, DO_CARRY); |
| 908 | statusAllRight(); |
| 909 | } |
| 910 | else if (keyb.leftCtrlPressed) |
| 911 | { |
| 912 | if (!ui.samplerScreenShown) |
| 913 | { |
| 914 | editor.playMode = PLAY_MODE_PATTERN; |
| 915 | modPlay(song->currPattern, DONT_SET_ORDER, editor.f7Pos); |
| 916 | |
| 917 | editor.currMode = MODE_RECORD; |
| 918 | pointerSetMode(POINTER_MODE_EDIT, DO_CARRY); |
| 919 | statusAllRight(); |
| 920 | } |
| 921 | } |
| 922 | else if (keyb.leftAmigaPressed) |
| 923 | { |
| 924 | editor.playMode = PLAY_MODE_NORMAL; |
| 925 | modPlay(DONT_SET_PATTERN, song->currPos, editor.f7Pos); |
| 926 | |
| 927 | editor.currMode = MODE_PLAY; |
| 928 | pointerSetMode(POINTER_MODE_PLAY, DO_CARRY); |
| 929 | statusAllRight(); |
| 930 | } |
| 931 | else if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD) |
| 932 | { |
| 933 | modSetPos(DONT_SET_ORDER, editor.f7Pos); |
| 934 | } |
| 935 | } |
| 936 | } |
| 937 | break; |
| 938 | |
| 939 | case SDL_SCANCODE_F8: |
| 940 | { |
| 941 | if (keyb.shiftPressed) |
| 942 | { |
| 943 | editor.f8Pos = song->currRow; |
| 944 | displayMsg("POSITION SET"); |
| 945 | } |
| 946 | else |
| 947 | { |
| 948 | if (keyb.leftAltPressed) |
| 949 | { |
| 950 | editor.playMode = PLAY_MODE_PATTERN; |
| 951 | modPlay(song->currPattern, DONT_SET_ORDER, editor.f8Pos); |
| 952 | |
| 953 | editor.currMode = MODE_PLAY; |
| 954 | pointerSetMode(POINTER_MODE_PLAY, DO_CARRY); |
| 955 | statusAllRight(); |
| 956 | } |
| 957 | else if (keyb.leftCtrlPressed) |
| 958 | { |
| 959 | if (!ui.samplerScreenShown) |
| 960 | { |
| 961 | editor.playMode = PLAY_MODE_PATTERN; |
| 962 | modPlay(song->currPattern, DONT_SET_ORDER, editor.f8Pos); |
| 963 | |
| 964 | editor.currMode = MODE_RECORD; |
| 965 | pointerSetMode(POINTER_MODE_EDIT, DO_CARRY); |
| 966 | statusAllRight(); |
| 967 | } |
| 968 | } |
| 969 | else if (keyb.leftAmigaPressed) |
| 970 | { |
| 971 | editor.playMode = PLAY_MODE_NORMAL; |
| 972 | modPlay(DONT_SET_PATTERN, song->currPos, editor.f8Pos); |
| 973 | |
| 974 | editor.currMode = MODE_PLAY; |
| 975 | pointerSetMode(POINTER_MODE_PLAY, DO_CARRY); |
| 976 | statusAllRight(); |
| 977 | } |
| 978 | else if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD) |
| 979 | { |
| 980 | modSetPos(DONT_SET_ORDER, editor.f8Pos); |
| 981 | } |
| 982 | } |
| 983 | } |
| 984 | break; |
| 985 | |
| 986 | case SDL_SCANCODE_F9: |
| 987 | { |
| 988 | if (keyb.shiftPressed) |
| 989 | { |
| 990 | editor.f9Pos = song->currRow; |
| 991 | displayMsg("POSITION SET"); |
| 992 | } |
| 993 | else |
| 994 | { |
| 995 | if (keyb.leftAltPressed) |
| 996 | { |
| 997 | editor.playMode = PLAY_MODE_PATTERN; |
| 998 | modPlay(song->currPattern, DONT_SET_ORDER, editor.f9Pos); |
| 999 | |
| 1000 | editor.currMode = MODE_PLAY; |
| 1001 | pointerSetMode(POINTER_MODE_PLAY, DO_CARRY); |
| 1002 | statusAllRight(); |
| 1003 | } |
| 1004 | else if (keyb.leftCtrlPressed) |
| 1005 | { |
| 1006 | if (!ui.samplerScreenShown) |
| 1007 | { |
| 1008 | editor.playMode = PLAY_MODE_PATTERN; |
| 1009 | modPlay(song->currPattern, DONT_SET_ORDER, editor.f9Pos); |
| 1010 | |
| 1011 | editor.currMode = MODE_RECORD; |
| 1012 | pointerSetMode(POINTER_MODE_EDIT, DO_CARRY); |
| 1013 | statusAllRight(); |
| 1014 | } |
| 1015 | } |
| 1016 | else if (keyb.leftAmigaPressed) |
| 1017 | { |
| 1018 | editor.playMode = PLAY_MODE_NORMAL; |
| 1019 | modPlay(DONT_SET_PATTERN, song->currPos, editor.f9Pos); |
| 1020 | |
| 1021 | editor.currMode = MODE_PLAY; |
| 1022 | pointerSetMode(POINTER_MODE_PLAY, DO_CARRY); |
| 1023 | statusAllRight(); |
| 1024 | } |
| 1025 | else if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD) |
| 1026 | { |
| 1027 | modSetPos(DONT_SET_ORDER, editor.f9Pos); |
| 1028 | } |
| 1029 | } |
| 1030 | } |
| 1031 | break; |
| 1032 | |
| 1033 | case SDL_SCANCODE_F10: |
| 1034 | { |
| 1035 | if (keyb.shiftPressed) |
| 1036 | { |
| 1037 | editor.f10Pos = song->currRow; |
| 1038 | displayMsg("POSITION SET"); |
| 1039 | } |
| 1040 | else |
| 1041 | { |
| 1042 | if (keyb.leftAltPressed) |
| 1043 | { |
| 1044 | editor.playMode = PLAY_MODE_PATTERN; |
| 1045 | modPlay(song->currPattern, DONT_SET_ORDER, editor.f10Pos); |
| 1046 | |
| 1047 | editor.currMode = MODE_PLAY; |
| 1048 | pointerSetMode(POINTER_MODE_PLAY, DO_CARRY); |
| 1049 | statusAllRight(); |
| 1050 | } |
| 1051 | else if (keyb.leftCtrlPressed) |
| 1052 | { |
| 1053 | if (!ui.samplerScreenShown) |
| 1054 | { |
| 1055 | editor.playMode = PLAY_MODE_PATTERN; |
| 1056 | modPlay(song->currPattern, DONT_SET_ORDER, editor.f10Pos); |
| 1057 | |
| 1058 | editor.currMode = MODE_RECORD; |
| 1059 | pointerSetMode(POINTER_MODE_EDIT, DO_CARRY); |
| 1060 | statusAllRight(); |
| 1061 | } |
| 1062 | } |
| 1063 | else if (keyb.leftAmigaPressed) |
| 1064 | { |
| 1065 | editor.playMode = PLAY_MODE_NORMAL; |
| 1066 | modPlay(DONT_SET_PATTERN, song->currPos, editor.f10Pos); |
| 1067 | |
| 1068 | editor.currMode = MODE_PLAY; |
| 1069 | pointerSetMode(POINTER_MODE_PLAY, DO_CARRY); |
| 1070 | statusAllRight(); |
| 1071 | } |
| 1072 | else if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD) |
| 1073 | { |
| 1074 | modSetPos(DONT_SET_ORDER, editor.f10Pos); |
| 1075 | } |
| 1076 | } |
| 1077 | } |
| 1078 | break; |
| 1079 | |
| 1080 | case SDL_SCANCODE_F11: |
| 1081 | { |
| 1082 | if (keyb.leftAltPressed) |
| 1083 | { |
| 1084 | config.realVuMeters ^= 1; |
| 1085 | displayMsg(config.realVuMeters ? "VU-METERS: REAL" : "VU-METERS: FAKE"); |
| 1086 | } |
| 1087 | } |
| 1088 | break; |
| 1089 | |
| 1090 | case SDL_SCANCODE_TAB: |
| 1091 | { |
| 1092 | if (keyb.shiftPressed) |
| 1093 | movePatCurPrevCh(); |
| 1094 | else |
| 1095 | movePatCurNextCh(); |
| 1096 | } |
| 1097 | break; |
| 1098 | |
| 1099 | case SDL_SCANCODE_0: |
| 1100 | { |
| 1101 | if (keyb.leftCtrlPressed) |
| 1102 | { |
| 1103 | editor.editMoveAdd = 0; |
| 1104 | displayMsg("EDITSKIP = 0"); |
| 1105 | ui.updateTrackerFlags = true; |
| 1106 | } |
| 1107 | else if (keyb.shiftPressed) |
| 1108 | { |
| 1109 | note_t *noteSrc = &song->patterns[song->currPattern][(song->currRow * PAULA_VOICES) + cursor.channel]; |
| 1110 | editor.effectMacros[9] = (noteSrc->command << 8) | noteSrc->param; |
| 1111 | displayMsg("COMMAND STORED!"); |
| 1112 | } |
| 1113 | else |
| 1114 | { |
| 1115 | handleEditKeys(scancode, EDIT_NORMAL); |
| 1116 | } |
| 1117 | } |
| 1118 | break; |
| 1119 | |
| 1120 | case SDL_SCANCODE_1: |
| 1121 | { |
| 1122 | if (keyb.leftAmigaPressed) |
| 1123 | { |
| 1124 | trackNoteUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1); |
| 1125 | } |
| 1126 | else if (keyb.leftCtrlPressed) |
| 1127 | { |
| 1128 | editor.editMoveAdd = 1; |
| 1129 | displayMsg("EDITSKIP = 1"); |
| 1130 | ui.updateTrackerFlags = true; |
| 1131 | } |
| 1132 | else if (keyb.shiftPressed) |
| 1133 | { |
| 1134 | note_t *noteSrc = &song->patterns[song->currPattern][(song->currRow * PAULA_VOICES) + cursor.channel]; |
| 1135 | editor.effectMacros[0] = (noteSrc->command << 8) | noteSrc->param; |
| 1136 | displayMsg("COMMAND STORED!"); |
| 1137 | } |
| 1138 | else if (editor.currMode == MODE_IDLE && keyb.leftAltPressed) |
| 1139 | { |
| 1140 | incMulti(0); |
| 1141 | } |
| 1142 | else |
| 1143 | { |
| 1144 | handleEditKeys(scancode, EDIT_NORMAL); |
| 1145 | } |
| 1146 | } |
| 1147 | break; |
| 1148 | |
| 1149 | case SDL_SCANCODE_2: |
| 1150 | { |
| 1151 | if (keyb.leftAmigaPressed) |
| 1152 | { |
| 1153 | pattNoteUp(TRANSPOSE_ALL); |
| 1154 | } |
| 1155 | else if (keyb.leftCtrlPressed) |
| 1156 | { |
| 1157 | editor.editMoveAdd = 2; |
| 1158 | displayMsg("EDITSKIP = 2"); |
| 1159 | ui.updateTrackerFlags = true; |
| 1160 | } |
| 1161 | else if (keyb.shiftPressed) |
| 1162 | { |
| 1163 | note_t *noteSrc = &song->patterns[song->currPattern][(song->currRow * PAULA_VOICES) + cursor.channel]; |
| 1164 | editor.effectMacros[1] = (noteSrc->command << 8) | noteSrc->param; |
| 1165 | displayMsg("COMMAND STORED!"); |
| 1166 | } |
| 1167 | else if (editor.currMode == MODE_IDLE && keyb.leftAltPressed) |
| 1168 | { |
| 1169 | incMulti(1); |
| 1170 | } |
| 1171 | else |
| 1172 | { |
| 1173 | handleEditKeys(scancode, EDIT_NORMAL); |
| 1174 | } |
| 1175 | } |
| 1176 | break; |
| 1177 | |
| 1178 | case SDL_SCANCODE_3: |
| 1179 | { |
| 1180 | if (keyb.leftAmigaPressed) |
| 1181 | { |
| 1182 | trackNoteUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1); |
| 1183 | } |
| 1184 | else if (keyb.leftCtrlPressed) |
| 1185 | { |
| 1186 | editor.editMoveAdd = 3; |
| 1187 | displayMsg("EDITSKIP = 3"); |
| 1188 | ui.updateTrackerFlags = true; |
| 1189 | } |
| 1190 | else if (keyb.shiftPressed) |
| 1191 | { |
| 1192 | note_t *noteSrc = &song->patterns[song->currPattern][(song->currRow * PAULA_VOICES) + cursor.channel]; |
| 1193 | editor.effectMacros[2] = (noteSrc->command << 8) | noteSrc->param; |
| 1194 | displayMsg("COMMAND STORED!"); |
| 1195 | } |
| 1196 | else if (editor.currMode == MODE_IDLE && keyb.leftAltPressed) |
| 1197 | { |
| 1198 | incMulti(2); |
| 1199 | } |
| 1200 | else |
| 1201 | { |
| 1202 | handleEditKeys(scancode, EDIT_NORMAL); |
| 1203 | } |
| 1204 | } |
| 1205 | break; |
| 1206 | |
| 1207 | case SDL_SCANCODE_4: |
| 1208 | { |
| 1209 | if (keyb.leftAmigaPressed) |
| 1210 | { |
| 1211 | pattNoteUp(TRANSPOSE_ALL); |
| 1212 | } |
| 1213 | else if (keyb.leftCtrlPressed) |
| 1214 | { |
| 1215 | editor.editMoveAdd = 4; |
| 1216 | displayMsg("EDITSKIP = 4"); |
| 1217 | ui.updateTrackerFlags = true; |
| 1218 | } |
| 1219 | else if (keyb.shiftPressed) |
| 1220 | { |
| 1221 | note_t *noteSrc = &song->patterns[song->currPattern][(song->currRow * PAULA_VOICES) + cursor.channel]; |
| 1222 | editor.effectMacros[3] = (noteSrc->command << 8) | noteSrc->param; |
| 1223 | displayMsg("COMMAND STORED!"); |
| 1224 | } |
| 1225 | else if (editor.currMode == MODE_IDLE && keyb.leftAltPressed) |
| 1226 | { |
| 1227 | incMulti(3); |
| 1228 | } |
| 1229 | else |
| 1230 | { |
| 1231 | handleEditKeys(scancode, EDIT_NORMAL); |
| 1232 | } |
| 1233 | } |
| 1234 | break; |
| 1235 | |
| 1236 | case SDL_SCANCODE_5: |
| 1237 | { |
| 1238 | if (keyb.leftCtrlPressed) |
| 1239 | { |
| 1240 | editor.editMoveAdd = 5; |
| 1241 | displayMsg("EDITSKIP = 5"); |
| 1242 | ui.updateTrackerFlags = true; |
| 1243 | } |
| 1244 | else if (keyb.shiftPressed) |
| 1245 | { |
| 1246 | note_t *noteSrc = &song->patterns[song->currPattern][(song->currRow * PAULA_VOICES) + cursor.channel]; |
| 1247 | editor.effectMacros[4] = (noteSrc->command << 8) | noteSrc->param; |
| 1248 | displayMsg("COMMAND STORED!"); |
| 1249 | } |
| 1250 | else |
| 1251 | { |
| 1252 | handleEditKeys(scancode, EDIT_NORMAL); |
| 1253 | } |
| 1254 | } |
| 1255 | break; |
| 1256 | |
| 1257 | case SDL_SCANCODE_6: |
| 1258 | { |
| 1259 | if (keyb.leftCtrlPressed) |
| 1260 | { |
| 1261 | editor.editMoveAdd = 6; |
| 1262 | displayMsg("EDITSKIP = 6"); |
| 1263 | ui.updateTrackerFlags = true; |
| 1264 | } |
| 1265 | else if (keyb.shiftPressed) |
| 1266 | { |
| 1267 | note_t *noteSrc = &song->patterns[song->currPattern][(song->currRow * PAULA_VOICES) + cursor.channel]; |
| 1268 | editor.effectMacros[5] = (noteSrc->command << 8) | noteSrc->param; |
| 1269 | displayMsg("COMMAND STORED!"); |
| 1270 | } |
| 1271 | else |
| 1272 | { |
| 1273 | handleEditKeys(scancode, EDIT_NORMAL); |
| 1274 | } |
| 1275 | } |
| 1276 | break; |
| 1277 | |
| 1278 | case SDL_SCANCODE_7: |
| 1279 | { |
| 1280 | if (keyb.leftCtrlPressed) |
| 1281 | { |
| 1282 | editor.editMoveAdd = 7; |
| 1283 | displayMsg("EDITSKIP = 7"); |
| 1284 | ui.updateTrackerFlags = true; |
| 1285 | } |
| 1286 | else if (keyb.shiftPressed) |
| 1287 | { |
| 1288 | note_t *noteSrc = &song->patterns[song->currPattern][(song->currRow * PAULA_VOICES) + cursor.channel]; |
| 1289 | editor.effectMacros[6] = (noteSrc->command << 8) | noteSrc->param; |
| 1290 | displayMsg("COMMAND STORED!"); |
| 1291 | } |
| 1292 | else |
| 1293 | { |
| 1294 | handleEditKeys(scancode, EDIT_NORMAL); |
| 1295 | } |
| 1296 | } |
| 1297 | break; |
| 1298 | |
| 1299 | case SDL_SCANCODE_8: |
| 1300 | { |
| 1301 | if (keyb.leftCtrlPressed) |
| 1302 | { |
| 1303 | editor.editMoveAdd = 8; |
| 1304 | displayMsg("EDITSKIP = 8"); |
| 1305 | ui.updateTrackerFlags = true; |
| 1306 | } |
| 1307 | else if (keyb.shiftPressed) |
| 1308 | { |
| 1309 | note_t *noteSrc = &song->patterns[song->currPattern][(song->currRow * PAULA_VOICES) + cursor.channel]; |
| 1310 | editor.effectMacros[7] = (noteSrc->command << 8) | noteSrc->param; |
| 1311 | displayMsg("COMMAND STORED!"); |
| 1312 | } |
| 1313 | else |
| 1314 | { |
| 1315 | handleEditKeys(scancode, EDIT_NORMAL); |
| 1316 | } |
| 1317 | } |
| 1318 | break; |
| 1319 | |
| 1320 | case SDL_SCANCODE_9: |
| 1321 | { |
| 1322 | if (keyb.leftCtrlPressed) |
| 1323 | { |
| 1324 | editor.editMoveAdd = 9; |
| 1325 | displayMsg("EDITSKIP = 9"); |
| 1326 | ui.updateTrackerFlags = true; |
| 1327 | } |
| 1328 | else if (keyb.shiftPressed) |
| 1329 | { |
| 1330 | note_t *noteSrc = &song->patterns[song->currPattern][(song->currRow * PAULA_VOICES) + cursor.channel]; |
| 1331 | editor.effectMacros[8] = (noteSrc->command << 8) | noteSrc->param; |
| 1332 | displayMsg("COMMAND STORED!"); |
| 1333 | } |
| 1334 | else |
| 1335 | { |
| 1336 | handleEditKeys(scancode, EDIT_NORMAL); |
| 1337 | } |
| 1338 | } |
| 1339 | break; |
| 1340 | |
| 1341 | case SDL_SCANCODE_KP_0: |
| 1342 | { |
| 1343 | if (editor.hiLowInstr >= 0x10) |
| 1344 | { |
| 1345 | editor.sampleZero = false; |
| 1346 | editor.currSample = 0x10-1; |
| 1347 | } |
| 1348 | else |
| 1349 | { |
| 1350 | editor.sampleZero = true; |
| 1351 | editor.currSample = 0x00; |
| 1352 | } |
| 1353 | |
| 1354 | updateCurrSample(); |
| 1355 | } |
| 1356 | break; |
| 1357 | |
| 1358 | case SDL_SCANCODE_KP_1: |
| 1359 | { |
| 1360 | editor.sampleZero = false; |
| 1361 | editor.currSample = editor.hiLowInstr + 12; |
| 1362 | |
| 1363 | updateCurrSample(); |
| 1364 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1365 | { |
| 1366 | ui.changingDrumPadNote = true; |
| 1367 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1368 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1369 | break; |
| 1370 | } |
| 1371 | |
| 1372 | if (editor.pNoteFlag > 0) |
| 1373 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1374 | } |
| 1375 | break; |
| 1376 | |
| 1377 | case SDL_SCANCODE_KP_2: |
| 1378 | { |
| 1379 | editor.sampleZero = false; |
| 1380 | editor.currSample = editor.hiLowInstr + 13; |
| 1381 | |
| 1382 | updateCurrSample(); |
| 1383 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1384 | { |
| 1385 | ui.changingDrumPadNote = true; |
| 1386 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1387 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1388 | break; |
| 1389 | } |
| 1390 | |
| 1391 | if (editor.pNoteFlag > 0) |
| 1392 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1393 | } |
| 1394 | break; |
| 1395 | |
| 1396 | case SDL_SCANCODE_KP_3: |
| 1397 | { |
| 1398 | editor.sampleZero = false; |
| 1399 | editor.currSample = editor.hiLowInstr + 14; |
| 1400 | |
| 1401 | updateCurrSample(); |
| 1402 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1403 | { |
| 1404 | ui.changingDrumPadNote = true; |
| 1405 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1406 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1407 | break; |
| 1408 | } |
| 1409 | |
| 1410 | if (editor.pNoteFlag > 0) |
| 1411 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1412 | } |
| 1413 | break; |
| 1414 | |
| 1415 | case SDL_SCANCODE_KP_4: |
| 1416 | { |
| 1417 | editor.sampleZero = false; |
| 1418 | editor.currSample = editor.hiLowInstr + 8; |
| 1419 | |
| 1420 | updateCurrSample(); |
| 1421 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1422 | { |
| 1423 | ui.changingDrumPadNote = true; |
| 1424 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1425 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1426 | break; |
| 1427 | } |
| 1428 | |
| 1429 | if (editor.pNoteFlag > 0) |
| 1430 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1431 | } |
| 1432 | break; |
| 1433 | |
| 1434 | case SDL_SCANCODE_KP_5: |
| 1435 | { |
| 1436 | editor.sampleZero = false; |
| 1437 | editor.currSample = editor.hiLowInstr + 9; |
| 1438 | |
| 1439 | updateCurrSample(); |
| 1440 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1441 | { |
| 1442 | ui.changingDrumPadNote = true; |
| 1443 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1444 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1445 | break; |
| 1446 | } |
| 1447 | |
| 1448 | if (editor.pNoteFlag > 0) |
| 1449 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1450 | } |
| 1451 | break; |
| 1452 | |
| 1453 | case SDL_SCANCODE_KP_6: |
| 1454 | { |
| 1455 | editor.sampleZero = false; |
| 1456 | editor.currSample = editor.hiLowInstr + 10; |
| 1457 | |
| 1458 | updateCurrSample(); |
| 1459 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1460 | { |
| 1461 | ui.changingDrumPadNote = true; |
| 1462 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1463 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1464 | break; |
| 1465 | } |
| 1466 | |
| 1467 | if (editor.pNoteFlag > 0) |
| 1468 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1469 | } |
| 1470 | break; |
| 1471 | |
| 1472 | case SDL_SCANCODE_KP_7: |
| 1473 | { |
| 1474 | editor.sampleZero = false; |
| 1475 | editor.currSample = editor.hiLowInstr + 4; |
| 1476 | |
| 1477 | updateCurrSample(); |
| 1478 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1479 | { |
| 1480 | ui.changingDrumPadNote = true; |
| 1481 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1482 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1483 | break; |
| 1484 | } |
| 1485 | |
| 1486 | if (editor.pNoteFlag > 0) |
| 1487 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1488 | } |
| 1489 | break; |
| 1490 | |
| 1491 | case SDL_SCANCODE_KP_8: |
| 1492 | { |
| 1493 | editor.sampleZero = false; |
| 1494 | editor.currSample = editor.hiLowInstr + 5; |
| 1495 | |
| 1496 | updateCurrSample(); |
| 1497 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1498 | { |
| 1499 | ui.changingDrumPadNote = true; |
| 1500 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1501 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1502 | break; |
| 1503 | } |
| 1504 | |
| 1505 | if (editor.pNoteFlag > 0) |
| 1506 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1507 | } |
| 1508 | break; |
| 1509 | |
| 1510 | case SDL_SCANCODE_KP_9: |
| 1511 | { |
| 1512 | editor.sampleZero = false; |
| 1513 | editor.currSample = editor.hiLowInstr + 6; |
| 1514 | |
| 1515 | updateCurrSample(); |
| 1516 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1517 | { |
| 1518 | ui.changingDrumPadNote = true; |
| 1519 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1520 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1521 | break; |
| 1522 | } |
| 1523 | |
| 1524 | if (editor.pNoteFlag > 0) |
| 1525 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1526 | } |
| 1527 | break; |
| 1528 | |
| 1529 | case SDL_SCANCODE_KP_ENTER: |
| 1530 | { |
| 1531 | editor.hiLowInstr ^= 0x10; |
| 1532 | |
| 1533 | if (editor.sampleZero) |
| 1534 | { |
| 1535 | editor.currSample = 15; |
| 1536 | editor.sampleZero = false; |
| 1537 | } |
| 1538 | else |
| 1539 | { |
| 1540 | editor.currSample ^= 0x10; |
| 1541 | } |
| 1542 | |
| 1543 | if (editor.currSample == 31) // kludge if sample was 15 (0010 in UI) before key press |
| 1544 | { |
| 1545 | editor.currSample = 15; |
| 1546 | editor.sampleZero ^= 1; |
| 1547 | } |
| 1548 | |
| 1549 | updateCurrSample(); |
| 1550 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1551 | { |
| 1552 | ui.changingDrumPadNote = true; |
| 1553 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1554 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1555 | break; |
| 1556 | } |
| 1557 | |
| 1558 | if (editor.pNoteFlag > 0) |
| 1559 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1560 | } |
| 1561 | break; |
| 1562 | |
| 1563 | case SDL_SCANCODE_KP_PLUS: |
| 1564 | { |
| 1565 | editor.sampleZero = false; |
| 1566 | |
| 1567 | // the Amiga numpad has one more key, so we need to use this key for two sample numbers... |
| 1568 | if (editor.keypadToggle8CFlag) |
| 1569 | editor.currSample = editor.hiLowInstr + (0x0C - 1); |
| 1570 | else |
| 1571 | editor.currSample = editor.hiLowInstr + (0x08 - 1); |
| 1572 | |
| 1573 | updateCurrSample(); |
| 1574 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1575 | displayErrorMsg("INVALID PAD KEY !"); |
| 1576 | |
| 1577 | editor.keypadToggle8CFlag ^= 1; |
| 1578 | } |
| 1579 | break; |
| 1580 | |
| 1581 | case SDL_SCANCODE_KP_MINUS: |
| 1582 | { |
| 1583 | editor.sampleZero = false; |
| 1584 | editor.currSample = editor.hiLowInstr + 3; |
| 1585 | |
| 1586 | updateCurrSample(); |
| 1587 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1588 | { |
| 1589 | ui.changingDrumPadNote = true; |
| 1590 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1591 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1592 | break; |
| 1593 | } |
| 1594 | |
| 1595 | if (editor.pNoteFlag > 0) |
| 1596 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1597 | } |
| 1598 | break; |
| 1599 | |
| 1600 | case SDL_SCANCODE_KP_MULTIPLY: |
| 1601 | { |
| 1602 | editor.sampleZero = false; |
| 1603 | editor.currSample = editor.hiLowInstr + 2; |
| 1604 | |
| 1605 | updateCurrSample(); |
| 1606 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1607 | { |
| 1608 | ui.changingDrumPadNote = true; |
| 1609 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1610 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1611 | break; |
| 1612 | } |
| 1613 | |
| 1614 | if (editor.pNoteFlag > 0) |
| 1615 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1616 | } |
| 1617 | break; |
| 1618 | |
| 1619 | case SDL_SCANCODE_KP_DIVIDE: |
| 1620 | { |
| 1621 | editor.sampleZero = false; |
| 1622 | editor.currSample = editor.hiLowInstr + 1; |
| 1623 | |
| 1624 | updateCurrSample(); |
| 1625 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1626 | { |
| 1627 | ui.changingDrumPadNote = true; |
| 1628 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1629 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1630 | break; |
| 1631 | } |
| 1632 | |
| 1633 | if (editor.pNoteFlag > 0) |
| 1634 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1635 | } |
| 1636 | break; |
| 1637 | |
| 1638 | case SDL_SCANCODE_NUMLOCKCLEAR: |
| 1639 | { |
| 1640 | editor.sampleZero = false; |
| 1641 | editor.currSample = editor.hiLowInstr + 0; |
| 1642 | |
| 1643 | updateCurrSample(); |
| 1644 | if (keyb.leftAltPressed && editor.pNoteFlag > 0) |
| 1645 | { |
| 1646 | ui.changingDrumPadNote = true; |
| 1647 | |
| 1648 | setStatusMessage("SELECT NOTE", NO_CARRY); |
| 1649 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 1650 | |
| 1651 | break; |
| 1652 | } |
| 1653 | |
| 1654 | if (editor.pNoteFlag > 0) |
| 1655 | handleEditKeys(scancode, EDIT_SPECIAL); |
| 1656 | } |
| 1657 | break; |
| 1658 | |
| 1659 | case SDL_SCANCODE_KP_PERIOD: |
| 1660 | { |
| 1661 | if (askBox(ASKBOX_YES_NO, "KILL SAMPLE ?")) |
| 1662 | killSample(); |
| 1663 | } |
| 1664 | break; |
| 1665 | |
| 1666 | case SDL_SCANCODE_DOWN: |
| 1667 | { |
| 1668 | keyb.delayKey = false; |
| 1669 | keyb.repeatKey = false; |
| 1670 | |
| 1671 | if (ui.samplerScreenShown && keyb.shiftPressed) |
| 1672 | { |
| 1673 | if (editor.markStartOfs >= 0 && (keyb.leftCtrlPressed || keyb.leftAltPressed)) |
| 1674 | { |
| 1675 | int32_t end = smpPos2Scr(editor.markEndOfs); |
| 1676 | if (end > 0) |
| 1677 | { |
| 1678 | end--; |
| 1679 | invertRange(); |
| 1680 | editor.markEndOfs = scr2SmpPos(end); |
| 1681 | |
| 1682 | if (editor.markStartOfs > editor.markEndOfs) |
| 1683 | { |
| 1684 | int32_t tmp = editor.markEndOfs; |
| 1685 | editor.markEndOfs = editor.markStartOfs; |
| 1686 | editor.markStartOfs = tmp; |
| 1687 | } |
| 1688 | |
| 1689 | invertRange(); |
| 1690 | } |
| 1691 | |
| 1692 | if (editor.repeatKeyFlag) |
| 1693 | { |
| 1694 | keyb.delayKey = true; |
| 1695 | keyb.repeatKey = true; |
| 1696 | } |
| 1697 | } |
| 1698 | } |
| 1699 | else |
| 1700 | { |
| 1701 | if (ui.diskOpScreenShown) |
| 1702 | { |
| 1703 | if (diskop.numEntries > DISKOP_LINES) |
| 1704 | { |
| 1705 | diskop.scrollOffset++; |
| 1706 | if (mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN |
| 1707 | diskop.scrollOffset += 3; |
| 1708 | |
| 1709 | if (diskop.scrollOffset > diskop.numEntries-DISKOP_LINES) |
| 1710 | diskop.scrollOffset = diskop.numEntries-DISKOP_LINES; |
| 1711 | |
| 1712 | ui.updateDiskOpFileList = true; |
| 1713 | } |
| 1714 | |
| 1715 | if (!keyb.repeatKey) |
| 1716 | keyb.delayCounter = 0; |
| 1717 | |
| 1718 | keyb.repeatKey = true; |
| 1719 | keyb.delayKey = false; |
| 1720 | } |
| 1721 | else if (ui.posEdScreenShown) |
| 1722 | { |
| 1723 | posEdScrollDown(); |
| 1724 | |
| 1725 | if (!keyb.repeatKey) |
| 1726 | keyb.delayCounter = 0; |
| 1727 | |
| 1728 | keyb.repeatKey = true; |
| 1729 | keyb.delayKey = true; |
| 1730 | } |
| 1731 | else if (!ui.samplerScreenShown) |
| 1732 | { |
| 1733 | if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD) |
| 1734 | modSetPos(DONT_SET_ORDER, (song->currRow + 1) & 63); |
| 1735 | |
| 1736 | keyb.repeatKey = true; |
| 1737 | } |
| 1738 | } |
| 1739 | } |
| 1740 | break; |
| 1741 | |
| 1742 | case SDL_SCANCODE_UP: |
| 1743 | { |
| 1744 | keyb.delayKey = false; |
| 1745 | keyb.repeatKey = false; |
| 1746 | |
| 1747 | if (ui.samplerScreenShown && keyb.shiftPressed) |
| 1748 | { |
| 1749 | if (editor.markStartOfs >= 0 && (keyb.leftCtrlPressed || keyb.leftAltPressed)) |
| 1750 | { |
| 1751 | int32_t end = smpPos2Scr(editor.markEndOfs); |
| 1752 | if (end < 313) |
| 1753 | { |
| 1754 | end++; |
| 1755 | invertRange(); |
| 1756 | editor.markEndOfs = scr2SmpPos(end); |
| 1757 | |
| 1758 | if (editor.markStartOfs > editor.markEndOfs) |
| 1759 | { |
| 1760 | int32_t tmp = editor.markEndOfs; |
| 1761 | editor.markEndOfs = editor.markStartOfs; |
| 1762 | editor.markStartOfs = tmp; |
| 1763 | } |
| 1764 | |
| 1765 | invertRange(); |
| 1766 | } |
| 1767 | |
| 1768 | if (editor.repeatKeyFlag) |
| 1769 | { |
| 1770 | keyb.delayKey = true; |
| 1771 | keyb.repeatKey = true; |
| 1772 | } |
| 1773 | } |
| 1774 | } |
| 1775 | else |
| 1776 | { |
| 1777 | if (ui.diskOpScreenShown) |
| 1778 | { |
| 1779 | diskop.scrollOffset--; |
| 1780 | if (mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN |
| 1781 | diskop.scrollOffset -= 3; |
| 1782 | |
| 1783 | if (diskop.scrollOffset < 0) |
| 1784 | diskop.scrollOffset = 0; |
| 1785 | |
| 1786 | ui.updateDiskOpFileList = true; |
| 1787 | |
| 1788 | if (!keyb.repeatKey) |
| 1789 | keyb.delayCounter = 0; |
| 1790 | |
| 1791 | keyb.repeatKey = true; |
| 1792 | keyb.delayKey = false; |
| 1793 | } |
| 1794 | else if (ui.posEdScreenShown) |
| 1795 | { |
| 1796 | posEdScrollUp(); |
| 1797 | |
| 1798 | if (!keyb.repeatKey) |
| 1799 | keyb.delayCounter = 0; |
| 1800 | |
| 1801 | keyb.repeatKey = true; |
| 1802 | keyb.delayKey = true; |
| 1803 | } |
| 1804 | else if (!ui.samplerScreenShown) |
| 1805 | { |
| 1806 | if ((editor.currMode != MODE_PLAY) && (editor.currMode != MODE_RECORD)) |
| 1807 | modSetPos(DONT_SET_ORDER, (song->currRow - 1) & 63); |
| 1808 | |
| 1809 | keyb.repeatKey = true; |
| 1810 | } |
| 1811 | } |
| 1812 | } |
| 1813 | break; |
| 1814 | |
| 1815 | case SDL_SCANCODE_LEFT: |
| 1816 | { |
| 1817 | keyb.delayKey = false; |
| 1818 | keyb.repeatKey = false; |
| 1819 | |
| 1820 | if (ui.samplerScreenShown && keyb.shiftPressed) |
| 1821 | { |
| 1822 | if (editor.markStartOfs >= 0 && (keyb.leftCtrlPressed || keyb.leftAltPressed)) |
| 1823 | { |
| 1824 | int32_t start = smpPos2Scr(editor.markStartOfs); |
| 1825 | if (start > 0) |
| 1826 | { |
| 1827 | start--; |
| 1828 | invertRange(); |
| 1829 | editor.markStartOfs = scr2SmpPos(start); |
| 1830 | invertRange(); |
| 1831 | } |
| 1832 | |
| 1833 | if (editor.repeatKeyFlag) |
| 1834 | { |
| 1835 | keyb.delayKey = true; |
| 1836 | keyb.repeatKey = true; |
| 1837 | } |
| 1838 | } |
| 1839 | } |
| 1840 | else |
| 1841 | { |
| 1842 | if (keyb.leftCtrlPressed) |
| 1843 | { |
| 1844 | sampleDownButton(); |
| 1845 | if (editor.repeatKeyFlag) |
| 1846 | { |
| 1847 | keyb.delayKey = true; |
| 1848 | keyb.repeatKey = true; |
| 1849 | } |
| 1850 | } |
| 1851 | else if (keyb.shiftPressed) |
| 1852 | { |
| 1853 | if (song->currPos > 0) |
| 1854 | { |
| 1855 | modSetPos(song->currPos - 1, DONT_SET_ROW); |
| 1856 | if (editor.repeatKeyFlag) |
| 1857 | { |
| 1858 | keyb.delayKey = true; |
| 1859 | keyb.repeatKey = true; |
| 1860 | } |
| 1861 | } |
| 1862 | } |
| 1863 | else if (keyb.leftAltPressed) |
| 1864 | { |
| 1865 | decPatt(); |
| 1866 | if (editor.repeatKeyFlag) |
| 1867 | { |
| 1868 | keyb.delayKey = true; |
| 1869 | keyb.repeatKey = true; |
| 1870 | } |
| 1871 | } |
| 1872 | else |
| 1873 | { |
| 1874 | movePatCurLeft(); |
| 1875 | keyb.repeatKey = true; |
| 1876 | } |
| 1877 | } |
| 1878 | } |
| 1879 | break; |
| 1880 | |
| 1881 | case SDL_SCANCODE_RIGHT: |
| 1882 | { |
| 1883 | keyb.delayKey = false; |
| 1884 | keyb.repeatKey = false; |
| 1885 | |
| 1886 | if (ui.samplerScreenShown && keyb.shiftPressed) |
| 1887 | { |
| 1888 | if (editor.markStartOfs >= 0 && (keyb.leftCtrlPressed || keyb.leftAltPressed)) |
| 1889 | { |
| 1890 | int32_t start = smpPos2Scr(editor.markStartOfs); |
| 1891 | if (start < 313) |
| 1892 | { |
| 1893 | start++; |
| 1894 | invertRange(); |
| 1895 | editor.markStartOfs = scr2SmpPos(start); |
| 1896 | |
| 1897 | if (editor.markStartOfs > editor.markEndOfs) |
| 1898 | { |
| 1899 | int32_t tmp = editor.markEndOfs; |
| 1900 | editor.markEndOfs = editor.markStartOfs; |
| 1901 | editor.markStartOfs = tmp; |
| 1902 | } |
| 1903 | |
| 1904 | invertRange(); |
| 1905 | } |
| 1906 | |
| 1907 | if (editor.repeatKeyFlag) |
| 1908 | { |
| 1909 | keyb.delayKey = true; |
| 1910 | keyb.repeatKey = true; |
| 1911 | } |
| 1912 | } |
| 1913 | } |
| 1914 | else |
| 1915 | { |
| 1916 | if (keyb.leftCtrlPressed) |
| 1917 | { |
| 1918 | sampleUpButton(); |
| 1919 | if (editor.repeatKeyFlag) |
| 1920 | { |
| 1921 | keyb.delayKey = true; |
| 1922 | keyb.repeatKey = true; |
| 1923 | } |
| 1924 | } |
| 1925 | else if (keyb.shiftPressed) |
| 1926 | { |
| 1927 | if (song->currPos < 126) |
| 1928 | { |
| 1929 | modSetPos(song->currPos + 1, DONT_SET_ROW); |
| 1930 | if (editor.repeatKeyFlag) |
| 1931 | { |
| 1932 | keyb.delayKey = true; |
| 1933 | keyb.repeatKey = true; |
| 1934 | } |
| 1935 | } |
| 1936 | } |
| 1937 | else if (keyb.leftAltPressed) |
| 1938 | { |
| 1939 | incPatt(); |
| 1940 | if (editor.repeatKeyFlag) |
| 1941 | { |
| 1942 | keyb.delayKey = true; |
| 1943 | keyb.repeatKey = true; |
| 1944 | } |
| 1945 | } |
| 1946 | else |
| 1947 | { |
| 1948 | movePatCurRight(); |
| 1949 | keyb.repeatKey = true; |
| 1950 | } |
| 1951 | } |
| 1952 | } |
| 1953 | break; |
| 1954 | |
| 1955 | case SDL_SCANCODE_A: |
| 1956 | { |
| 1957 | if (keyb.leftAmigaPressed) |
| 1958 | { |
| 1959 | trackOctaUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1); |
| 1960 | } |
| 1961 | else if (keyb.leftCtrlPressed) |
| 1962 | { |
| 1963 | if (ui.samplerScreenShown) |
| 1964 | { |
| 1965 | samplerRangeAll(); |
| 1966 | } |
| 1967 | else |
| 1968 | { |
| 1969 | if (keyb.shiftPressed) |
| 1970 | { |
| 1971 | editor.muted[0] = true; |
| 1972 | editor.muted[1] = true; |
| 1973 | editor.muted[2] = true; |
| 1974 | editor.muted[3] = true; |
| 1975 | |
| 1976 | editor.muted[cursor.channel] = false; |
| 1977 | renderMuteButtons(); |
| 1978 | break; |
| 1979 | } |
| 1980 | |
| 1981 | editor.muted[cursor.channel] ^= 1; |
| 1982 | renderMuteButtons(); |
| 1983 | } |
| 1984 | } |
| 1985 | else |
| 1986 | { |
| 1987 | handleEditKeys(scancode, EDIT_NORMAL); |
| 1988 | } |
| 1989 | } |
| 1990 | break; |
| 1991 | |
| 1992 | case SDL_SCANCODE_B: |
| 1993 | { |
| 1994 | if (keyb.leftCtrlPressed) |
| 1995 | { |
| 1996 | if (editor.blockMarkFlag) |
| 1997 | { |
| 1998 | editor.blockMarkFlag = false; |
| 1999 | } |
| 2000 | else |
| 2001 | { |
| 2002 | editor.blockMarkFlag = true; |
| 2003 | editor.blockFromPos = song->currRow; |
| 2004 | editor.blockToPos = song->currRow; |
| 2005 | } |
| 2006 | |
| 2007 | ui.updateStatusText = true; |
| 2008 | } |
| 2009 | else if (keyb.leftAltPressed) |
| 2010 | { |
| 2011 | moduleSample_t *s = &song->samples[editor.currSample]; |
| 2012 | if (s->length == 0) |
| 2013 | { |
| 2014 | statusSampleIsEmpty(); |
| 2015 | break; |
| 2016 | } |
| 2017 | |
| 2018 | boostSample(editor.currSample, true); |
| 2019 | |
| 2020 | if (ui.samplerScreenShown) |
| 2021 | displaySample(); |
| 2022 | } |
| 2023 | else |
| 2024 | { |
| 2025 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2026 | } |
| 2027 | } |
| 2028 | break; |
| 2029 | |
| 2030 | case SDL_SCANCODE_C: |
| 2031 | { |
| 2032 | if (keyb.leftAmigaPressed) |
| 2033 | { |
| 2034 | trackOctaDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1); |
| 2035 | } |
| 2036 | else if (keyb.leftCtrlPressed) |
| 2037 | { |
| 2038 | if (ui.samplerScreenShown) |
| 2039 | { |
| 2040 | samplerSamCopy(); |
| 2041 | return; |
| 2042 | } |
| 2043 | |
| 2044 | if (!editor.blockMarkFlag) |
| 2045 | { |
| 2046 | displayErrorMsg("NO BLOCK MARKED !"); |
| 2047 | return; |
| 2048 | } |
| 2049 | |
| 2050 | editor.blockMarkFlag = false; |
| 2051 | editor.blockBufferFlag = true; |
| 2052 | |
| 2053 | for (int32_t i = 0; i < MOD_ROWS; i++) |
| 2054 | editor.blockBuffer[i] = song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel]; |
| 2055 | |
| 2056 | if (editor.blockFromPos > editor.blockToPos) |
| 2057 | { |
| 2058 | editor.buffFromPos = editor.blockToPos; |
| 2059 | editor.buffToPos = editor.blockFromPos; |
| 2060 | } |
| 2061 | else |
| 2062 | { |
| 2063 | editor.buffFromPos = editor.blockFromPos; |
| 2064 | editor.buffToPos = editor.blockToPos; |
| 2065 | } |
| 2066 | |
| 2067 | statusAllRight(); |
| 2068 | } |
| 2069 | else |
| 2070 | { |
| 2071 | if (keyb.leftAltPressed) |
| 2072 | { |
| 2073 | editor.muted[2] ^= 1; // toggle channel 3 |
| 2074 | renderMuteButtons(); |
| 2075 | } |
| 2076 | else |
| 2077 | { |
| 2078 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2079 | } |
| 2080 | } |
| 2081 | } |
| 2082 | break; |
| 2083 | |
| 2084 | case SDL_SCANCODE_D: |
| 2085 | { |
| 2086 | if (keyb.leftAmigaPressed) |
| 2087 | { |
| 2088 | trackOctaUp(TRANSPOSE_ALL, 0, MOD_ROWS - 1); |
| 2089 | } |
| 2090 | else if (keyb.leftCtrlPressed) |
| 2091 | { |
| 2092 | saveUndo(); |
| 2093 | } |
| 2094 | else |
| 2095 | { |
| 2096 | if (keyb.leftAltPressed) |
| 2097 | { |
| 2098 | if (!ui.posEdScreenShown) |
| 2099 | { |
| 2100 | editor.blockMarkFlag = false; |
| 2101 | |
| 2102 | ui.diskOpScreenShown ^= 1; |
| 2103 | if (!ui.diskOpScreenShown) |
| 2104 | { |
| 2105 | pointerSetPreviousMode(); |
| 2106 | setPrevStatusMessage(); |
| 2107 | displayMainScreen(); |
| 2108 | } |
| 2109 | else |
| 2110 | { |
| 2111 | ui.diskOpScreenShown = true; |
| 2112 | renderDiskOpScreen(); |
| 2113 | } |
| 2114 | } |
| 2115 | } |
| 2116 | else |
| 2117 | { |
| 2118 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2119 | } |
| 2120 | } |
| 2121 | } |
| 2122 | break; |
| 2123 | |
| 2124 | case SDL_SCANCODE_E: |
| 2125 | { |
| 2126 | if (keyb.leftAmigaPressed) |
| 2127 | { |
| 2128 | trackNoteDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1); |
| 2129 | } |
| 2130 | else if (keyb.leftAltPressed) |
| 2131 | { |
| 2132 | if (!ui.diskOpScreenShown && !ui.posEdScreenShown) |
| 2133 | { |
| 2134 | if (ui.editOpScreenShown) |
| 2135 | ui.editOpScreen = (ui.editOpScreen + 1) % 3; |
| 2136 | else |
| 2137 | ui.editOpScreenShown = true; |
| 2138 | |
| 2139 | renderEditOpScreen(); |
| 2140 | } |
| 2141 | } |
| 2142 | else if (keyb.leftCtrlPressed) |
| 2143 | { |
| 2144 | saveUndo(); |
| 2145 | |
| 2146 | int32_t j = song->currRow + 1; |
| 2147 | while (j < MOD_ROWS) |
| 2148 | { |
| 2149 | int32_t i; |
| 2150 | for (i = 62; i >= j; i--) |
| 2151 | { |
| 2152 | note_t *noteSrc = &song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel]; |
| 2153 | song->patterns[song->currPattern][((i + 1) * PAULA_VOICES) + cursor.channel] = *noteSrc; |
| 2154 | } |
| 2155 | |
| 2156 | note_t *noteDst = &song->patterns[song->currPattern][((i + 1) * PAULA_VOICES) + cursor.channel]; |
| 2157 | noteDst->period = 0; |
| 2158 | noteDst->sample = 0; |
| 2159 | noteDst->command = 0; |
| 2160 | noteDst->param = 0; |
| 2161 | |
| 2162 | j += 2; |
| 2163 | } |
| 2164 | |
| 2165 | updateWindowTitle(MOD_IS_MODIFIED); |
| 2166 | ui.updatePatternData = true; |
| 2167 | } |
| 2168 | else |
| 2169 | { |
| 2170 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2171 | } |
| 2172 | } |
| 2173 | break; |
| 2174 | |
| 2175 | case SDL_SCANCODE_F: |
| 2176 | { |
| 2177 | #ifdef __APPLE__ |
| 2178 | if (keyb.leftCommandPressed && keyb.leftCtrlPressed) |
| 2179 | { |
| 2180 | toggleFullscreen(); |
| 2181 | } |
| 2182 | else |
| 2183 | #endif |
| 2184 | if (keyb.leftAmigaPressed) |
| 2185 | { |
| 2186 | pattOctaUp(TRANSPOSE_ALL); |
| 2187 | } |
| 2188 | else if (keyb.leftCtrlPressed) |
| 2189 | { |
| 2190 | if (keyb.shiftPressed) |
| 2191 | { |
| 2192 | resetFPSCounter(); |
| 2193 | |
| 2194 | video.debug ^= 1; |
| 2195 | if (!video.debug) |
| 2196 | displayMainScreen(); |
| 2197 | } |
| 2198 | else |
| 2199 | { |
| 2200 | toggleLEDFilter(); |
| 2201 | |
| 2202 | if (audio.ledFilterEnabled) |
| 2203 | displayMsg("LED FILTER ON"); |
| 2204 | else |
| 2205 | displayMsg("LED FILTER OFF"); |
| 2206 | } |
| 2207 | } |
| 2208 | else if (keyb.leftAltPressed) |
| 2209 | { |
| 2210 | moduleSample_t *s = &song->samples[editor.currSample]; |
| 2211 | if (s->length == 0) |
| 2212 | { |
| 2213 | statusSampleIsEmpty(); |
| 2214 | break; |
| 2215 | } |
| 2216 | |
| 2217 | filterSample(editor.currSample, true); |
| 2218 | if (ui.samplerScreenShown) |
| 2219 | displaySample(); |
| 2220 | } |
| 2221 | else |
| 2222 | { |
| 2223 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2224 | } |
| 2225 | } |
| 2226 | break; |
| 2227 | |
| 2228 | case SDL_SCANCODE_G: |
| 2229 | { |
| 2230 | if (keyb.leftAltPressed) // toggle record mode (PT clone and PT2.3E only) |
| 2231 | { |
| 2232 | editor.recordMode ^= 1; |
| 2233 | if (editor.recordMode == 0) |
| 2234 | displayMsg("REC MODE: PATT"); |
| 2235 | else |
| 2236 | displayMsg("REC MODE: SONG"); |
| 2237 | |
| 2238 | if (ui.editOpScreenShown && ui.editOpScreen == 1) |
| 2239 | ui.updateRecordText = true; |
| 2240 | } |
| 2241 | else |
| 2242 | { |
| 2243 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2244 | } |
| 2245 | } |
| 2246 | break; |
| 2247 | |
| 2248 | case SDL_SCANCODE_H: |
| 2249 | { |
| 2250 | if (keyb.leftCtrlPressed) |
| 2251 | { |
| 2252 | if (!editor.blockMarkFlag) |
| 2253 | { |
| 2254 | displayErrorMsg("NO BLOCK MARKED !"); |
| 2255 | return; |
| 2256 | } |
| 2257 | |
| 2258 | trackNoteUp(TRANSPOSE_ALL, editor.blockFromPos, editor.blockToPos); |
| 2259 | } |
| 2260 | else |
| 2261 | { |
| 2262 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2263 | } |
| 2264 | } |
| 2265 | break; |
| 2266 | |
| 2267 | case SDL_SCANCODE_I: |
| 2268 | { |
| 2269 | if (keyb.leftCtrlPressed) |
| 2270 | { |
| 2271 | if (!editor.blockBufferFlag) |
| 2272 | { |
| 2273 | displayErrorMsg("BUFFER IS EMPTY !"); |
| 2274 | return; |
| 2275 | } |
| 2276 | |
| 2277 | if (song->currRow < 63) |
| 2278 | { |
| 2279 | for (int32_t i = 0; i <= editor.buffToPos-editor.buffFromPos; i++) |
| 2280 | { |
| 2281 | for (int32_t j = 62; j >= song->currRow; j--) |
| 2282 | { |
| 2283 | note_t *noteSrc = &song->patterns[song->currPattern][(j * PAULA_VOICES) + cursor.channel]; |
| 2284 | song->patterns[song->currPattern][((j + 1) * PAULA_VOICES) + cursor.channel] = *noteSrc; |
| 2285 | } |
| 2286 | } |
| 2287 | } |
| 2288 | |
| 2289 | saveUndo(); |
| 2290 | |
| 2291 | int32_t i; |
| 2292 | for (i = 0; i <= editor.buffToPos-editor.buffFromPos; i++) |
| 2293 | { |
| 2294 | if (song->currRow+i > 63) |
| 2295 | break; |
| 2296 | |
| 2297 | song->patterns[song->currPattern][((song->currRow + i) * PAULA_VOICES) + cursor.channel] |
| 2298 | = editor.blockBuffer[editor.buffFromPos + i]; |
| 2299 | } |
| 2300 | |
| 2301 | if (!keyb.shiftPressed) |
| 2302 | { |
| 2303 | song->currRow += i & 0xFF; |
| 2304 | if (song->currRow > 63) |
| 2305 | song->currRow = 0; |
| 2306 | } |
| 2307 | |
| 2308 | updateWindowTitle(MOD_IS_MODIFIED); |
| 2309 | ui.updatePatternData = true; |
| 2310 | } |
| 2311 | else if (keyb.leftAltPressed) |
| 2312 | { |
| 2313 | editor.autoInsFlag ^= 1; |
| 2314 | ui.updateTrackerFlags = true; |
| 2315 | } |
| 2316 | else |
| 2317 | { |
| 2318 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2319 | } |
| 2320 | } |
| 2321 | break; |
| 2322 | |
| 2323 | case SDL_SCANCODE_J: |
| 2324 | { |
| 2325 | if (keyb.leftCtrlPressed) |
| 2326 | { |
| 2327 | if (!editor.blockBufferFlag) |
| 2328 | { |
| 2329 | displayErrorMsg("BUFFER IS EMPTY !"); |
| 2330 | return; |
| 2331 | } |
| 2332 | |
| 2333 | saveUndo(); |
| 2334 | |
| 2335 | int32_t i = editor.buffFromPos; |
| 2336 | int32_t j = song->currRow; |
| 2337 | note_t *patt = song->patterns[song->currPattern]; |
| 2338 | |
| 2339 | while (true) |
| 2340 | { |
| 2341 | note_t *noteDst = &patt[(j * PAULA_VOICES) + cursor.channel]; |
| 2342 | |
| 2343 | if (editor.blockBuffer[i].period == 0 && editor.blockBuffer[i].sample == 0) |
| 2344 | { |
| 2345 | noteDst->command = editor.blockBuffer[i].command; |
| 2346 | noteDst->param = editor.blockBuffer[i].param; |
| 2347 | } |
| 2348 | else |
| 2349 | { |
| 2350 | *noteDst = editor.blockBuffer[i]; |
| 2351 | } |
| 2352 | |
| 2353 | if (i == editor.buffToPos || i == 63 || j == 63) |
| 2354 | break; |
| 2355 | |
| 2356 | i++; |
| 2357 | j++; |
| 2358 | } |
| 2359 | |
| 2360 | if (!keyb.shiftPressed) |
| 2361 | { |
| 2362 | song->currRow += (editor.buffToPos-editor.buffFromPos) + 1; |
| 2363 | if (song->currRow > 63) |
| 2364 | song->currRow = 0; |
| 2365 | } |
| 2366 | |
| 2367 | updateWindowTitle(MOD_IS_MODIFIED); |
| 2368 | ui.updatePatternData = true; |
| 2369 | } |
| 2370 | else |
| 2371 | { |
| 2372 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2373 | } |
| 2374 | } |
| 2375 | break; |
| 2376 | |
| 2377 | case SDL_SCANCODE_K: |
| 2378 | { |
| 2379 | if (keyb.leftAltPressed) |
| 2380 | { |
| 2381 | for (int32_t i = 0; i < MOD_ROWS; i++) |
| 2382 | { |
| 2383 | note_t *noteSrc = &song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel]; |
| 2384 | if (noteSrc->sample == editor.currSample+1) |
| 2385 | { |
| 2386 | noteSrc->period = 0; |
| 2387 | noteSrc->sample = 0; |
| 2388 | noteSrc->command = 0; |
| 2389 | noteSrc->param = 0; |
| 2390 | } |
| 2391 | } |
| 2392 | |
| 2393 | updateWindowTitle(MOD_IS_MODIFIED); |
| 2394 | ui.updatePatternData = true; |
| 2395 | } |
| 2396 | else if (keyb.leftCtrlPressed) |
| 2397 | { |
| 2398 | saveUndo(); |
| 2399 | |
| 2400 | int32_t i = song->currRow; |
| 2401 | if (keyb.shiftPressed) |
| 2402 | { |
| 2403 | // kill to start |
| 2404 | while (i >= 0) |
| 2405 | { |
| 2406 | note_t *noteDst = &song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel]; |
| 2407 | noteDst->period = 0; |
| 2408 | noteDst->sample = 0; |
| 2409 | noteDst->command = 0; |
| 2410 | noteDst->param = 0; |
| 2411 | |
| 2412 | i--; |
| 2413 | } |
| 2414 | } |
| 2415 | else |
| 2416 | { |
| 2417 | // kill to end |
| 2418 | while (i < MOD_ROWS) |
| 2419 | { |
| 2420 | note_t *noteDst = &song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel]; |
| 2421 | noteDst->period = 0; |
| 2422 | noteDst->sample = 0; |
| 2423 | noteDst->command = 0; |
| 2424 | noteDst->param = 0; |
| 2425 | |
| 2426 | i++; |
| 2427 | } |
| 2428 | } |
| 2429 | |
| 2430 | updateWindowTitle(MOD_IS_MODIFIED); |
| 2431 | ui.updatePatternData = true; |
| 2432 | } |
| 2433 | else |
| 2434 | { |
| 2435 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2436 | } |
| 2437 | } |
| 2438 | break; |
| 2439 | |
| 2440 | case SDL_SCANCODE_L: |
| 2441 | { |
| 2442 | if (keyb.leftCtrlPressed) |
| 2443 | { |
| 2444 | if (!editor.blockMarkFlag) |
| 2445 | { |
| 2446 | displayErrorMsg("NO BLOCK MARKED !"); |
| 2447 | return; |
| 2448 | } |
| 2449 | |
| 2450 | trackNoteDown(TRANSPOSE_ALL, editor.blockFromPos, editor.blockToPos); |
| 2451 | } |
| 2452 | else |
| 2453 | { |
| 2454 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2455 | } |
| 2456 | } |
| 2457 | break; |
| 2458 | |
| 2459 | case SDL_SCANCODE_M: |
| 2460 | { |
| 2461 | if (keyb.leftCtrlPressed) |
| 2462 | { |
| 2463 | editor.multiFlag ^= 1; |
| 2464 | ui.updateTrackerFlags = true; |
| 2465 | ui.updateKeysText = true; |
| 2466 | } |
| 2467 | else if (keyb.leftAltPressed) |
| 2468 | { |
| 2469 | if (keyb.shiftPressed) |
| 2470 | { |
| 2471 | editor.metroChannel = cursor.channel + 1; |
| 2472 | |
| 2473 | if (ui.editOpScreenShown && ui.editOpScreen == 1) |
| 2474 | ui.updateMetro2Text = true; |
| 2475 | } |
| 2476 | else |
| 2477 | { |
| 2478 | editor.metroFlag ^= 1; |
| 2479 | ui.updateTrackerFlags = true; |
| 2480 | } |
| 2481 | } |
| 2482 | else |
| 2483 | { |
| 2484 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2485 | } |
| 2486 | } |
| 2487 | break; |
| 2488 | |
| 2489 | case SDL_SCANCODE_N: |
| 2490 | { |
| 2491 | if (keyb.leftCtrlPressed) |
| 2492 | { |
| 2493 | editor.blockMarkFlag = true; |
| 2494 | song->currRow = editor.blockToPos; |
| 2495 | } |
| 2496 | else |
| 2497 | { |
| 2498 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2499 | } |
| 2500 | } |
| 2501 | break; |
| 2502 | |
| 2503 | case SDL_SCANCODE_O: |
| 2504 | { |
| 2505 | if (keyb.leftCtrlPressed) |
| 2506 | { |
| 2507 | // fun fact: this function is broken in PT but I fixed it in my clone |
| 2508 | |
| 2509 | saveUndo(); |
| 2510 | |
| 2511 | int32_t j = song->currRow + 1; |
| 2512 | while (j < MOD_ROWS) |
| 2513 | { |
| 2514 | for (int32_t i = j; i < MOD_ROWS-1; i++) |
| 2515 | { |
| 2516 | note_t *noteSrc = &song->patterns[song->currPattern][((i + 1) * PAULA_VOICES) + cursor.channel]; |
| 2517 | song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel] = *noteSrc; |
| 2518 | } |
| 2519 | |
| 2520 | // clear newly made row on very bottom |
| 2521 | note_t *noteDst = &song->patterns[song->currPattern][(63 * PAULA_VOICES) + cursor.channel]; |
| 2522 | noteDst->period = 0; |
| 2523 | noteDst->sample = 0; |
| 2524 | noteDst->command = 0; |
| 2525 | noteDst->param = 0; |
| 2526 | |
| 2527 | j++; |
| 2528 | } |
| 2529 | |
| 2530 | updateWindowTitle(MOD_IS_MODIFIED); |
| 2531 | ui.updatePatternData = true; |
| 2532 | } |
| 2533 | else |
| 2534 | { |
| 2535 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2536 | } |
| 2537 | } |
| 2538 | break; |
| 2539 | |
| 2540 | case SDL_SCANCODE_P: |
| 2541 | { |
| 2542 | if (keyb.leftCtrlPressed) |
| 2543 | { |
| 2544 | if (!editor.blockBufferFlag) |
| 2545 | { |
| 2546 | displayErrorMsg("BUFFER IS EMPTY !"); |
| 2547 | return; |
| 2548 | } |
| 2549 | |
| 2550 | saveUndo(); |
| 2551 | |
| 2552 | int32_t i = editor.buffFromPos; |
| 2553 | int32_t j = song->currRow; |
| 2554 | note_t *patt = song->patterns[song->currPattern]; |
| 2555 | |
| 2556 | while (true) |
| 2557 | { |
| 2558 | note_t *noteDst = &patt[(j * PAULA_VOICES) + cursor.channel]; |
| 2559 | *noteDst = editor.blockBuffer[i]; |
| 2560 | |
| 2561 | if (i == editor.buffToPos || i == 63 || j == 63) |
| 2562 | break; |
| 2563 | |
| 2564 | i++; |
| 2565 | j++; |
| 2566 | } |
| 2567 | |
| 2568 | if (!keyb.shiftPressed) |
| 2569 | { |
| 2570 | song->currRow += (editor.buffToPos-editor.buffFromPos) + 1; |
| 2571 | if (song->currRow > 63) |
| 2572 | song->currRow = 0; |
| 2573 | } |
| 2574 | |
| 2575 | updateWindowTitle(MOD_IS_MODIFIED); |
| 2576 | ui.updatePatternData = true; |
| 2577 | } |
| 2578 | else if (keyb.leftAltPressed) |
| 2579 | { |
| 2580 | if (!ui.diskOpScreenShown) |
| 2581 | posEdToggle(); |
| 2582 | } |
| 2583 | else |
| 2584 | { |
| 2585 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2586 | } |
| 2587 | } |
| 2588 | break; |
| 2589 | |
| 2590 | case SDL_SCANCODE_Q: |
| 2591 | { |
| 2592 | if (keyb.leftAmigaPressed) |
| 2593 | { |
| 2594 | trackNoteDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1); |
| 2595 | #ifdef __APPLE__ |
| 2596 | /* On Mac, command+Q sends a quit signal to the program. |
| 2597 | ** However, command+Q is also one of the transpose keys in this ProTracker port. |
| 2598 | ** Ignore the signal if command+Q was pressed. |
| 2599 | */ |
| 2600 | editor.macCmdQIssued = true; |
| 2601 | #endif |
| 2602 | } |
| 2603 | else if (keyb.leftCtrlPressed) |
| 2604 | { |
| 2605 | editor.muted[0] = false; |
| 2606 | editor.muted[1] = false; |
| 2607 | editor.muted[2] = false; |
| 2608 | editor.muted[3] = false; |
| 2609 | renderMuteButtons(); |
| 2610 | } |
| 2611 | else if (keyb.leftAltPressed) |
| 2612 | { |
| 2613 | if (askBox(ASKBOX_YES_NO, "REALLY QUIT ?")) |
| 2614 | ui.throwExit = true; |
| 2615 | } |
| 2616 | else |
| 2617 | { |
| 2618 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2619 | } |
| 2620 | } |
| 2621 | break; |
| 2622 | |
| 2623 | case SDL_SCANCODE_R: |
| 2624 | { |
| 2625 | if (keyb.leftAmigaPressed) |
| 2626 | { |
| 2627 | pattNoteDown(TRANSPOSE_ALL); |
| 2628 | } |
| 2629 | else if (keyb.leftCtrlPressed) |
| 2630 | { |
| 2631 | editor.f6Pos = 0; |
| 2632 | editor.f7Pos = 16; |
| 2633 | editor.f8Pos = 32; |
| 2634 | editor.f9Pos = 48; |
| 2635 | editor.f10Pos = 63; |
| 2636 | |
| 2637 | displayMsg("POS RESTORED !"); |
| 2638 | } |
| 2639 | else if (keyb.leftAltPressed) |
| 2640 | { |
| 2641 | if (askBox(ASKBOX_YES_NO, "RESAMPLE?")) |
| 2642 | samplerResample(); |
| 2643 | } |
| 2644 | else |
| 2645 | { |
| 2646 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2647 | } |
| 2648 | } |
| 2649 | break; |
| 2650 | |
| 2651 | case SDL_SCANCODE_S: |
| 2652 | { |
| 2653 | if (keyb.leftCtrlPressed) |
| 2654 | { |
| 2655 | // if we're in sample load/save mode, set current dir to modules path |
| 2656 | if (diskop.mode == DISKOP_MODE_SMP) |
| 2657 | UNICHAR_CHDIR(editor.modulesPathU); |
| 2658 | |
| 2659 | saveModule(DONT_CHECK_IF_FILE_EXIST, DONT_GIVE_NEW_FILENAME); |
| 2660 | |
| 2661 | // set current dir to samples path |
| 2662 | if (diskop.mode == DISKOP_MODE_SMP) |
| 2663 | UNICHAR_CHDIR(editor.samplesPathU); |
| 2664 | } |
| 2665 | else if (keyb.leftAmigaPressed) |
| 2666 | { |
| 2667 | pattOctaUp(TRANSPOSE_ALL); |
| 2668 | } |
| 2669 | else if (keyb.leftAltPressed) |
| 2670 | { |
| 2671 | samplerScreen(); |
| 2672 | } |
| 2673 | else |
| 2674 | { |
| 2675 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2676 | } |
| 2677 | } |
| 2678 | break; |
| 2679 | |
| 2680 | case SDL_SCANCODE_T: |
| 2681 | { |
| 2682 | if (keyb.leftCtrlPressed) |
| 2683 | { |
| 2684 | editor.swapChannelFlag = true; |
| 2685 | pointerSetMode(POINTER_MODE_MSG1, NO_CARRY); |
| 2686 | setStatusMessage("SWAP (1/2/3/4) ?", NO_CARRY); |
| 2687 | } |
| 2688 | else if (keyb.leftAltPressed) |
| 2689 | { |
| 2690 | toggleTuningTone(); |
| 2691 | } |
| 2692 | else |
| 2693 | { |
| 2694 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2695 | } |
| 2696 | } |
| 2697 | break; |
| 2698 | |
| 2699 | case SDL_SCANCODE_U: |
| 2700 | { |
| 2701 | if (keyb.leftCtrlPressed) |
| 2702 | undoLastChange(); |
| 2703 | else |
| 2704 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2705 | } |
| 2706 | break; |
| 2707 | |
| 2708 | case SDL_SCANCODE_V: |
| 2709 | { |
| 2710 | if (keyb.leftAmigaPressed) |
| 2711 | { |
| 2712 | pattOctaDown(TRANSPOSE_ALL); |
| 2713 | } |
| 2714 | else if (keyb.leftCtrlPressed) |
| 2715 | { |
| 2716 | if (ui.samplerScreenShown) |
| 2717 | { |
| 2718 | samplerSamPaste(); |
| 2719 | } |
| 2720 | } |
| 2721 | else if (keyb.leftAltPressed) |
| 2722 | { |
| 2723 | editor.muted[3] ^= 1; // toggle channel 4 |
| 2724 | renderMuteButtons(); |
| 2725 | } |
| 2726 | else |
| 2727 | { |
| 2728 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2729 | } |
| 2730 | } |
| 2731 | break; |
| 2732 | |
| 2733 | case SDL_SCANCODE_W: |
| 2734 | { |
| 2735 | if (keyb.leftAmigaPressed) |
| 2736 | { |
| 2737 | pattNoteDown(TRANSPOSE_ALL); |
| 2738 | } |
| 2739 | else if (keyb.leftCtrlPressed) |
| 2740 | { |
| 2741 | // Polyphonize Block |
| 2742 | if (!editor.blockBufferFlag) |
| 2743 | { |
| 2744 | displayErrorMsg("BUFFER IS EMPTY !"); |
| 2745 | return; |
| 2746 | } |
| 2747 | |
| 2748 | saveUndo(); |
| 2749 | |
| 2750 | int32_t i = editor.buffFromPos; |
| 2751 | int32_t j = song->currRow; |
| 2752 | note_t *patt = song->patterns[song->currPattern]; |
| 2753 | |
| 2754 | while (true) |
| 2755 | { |
| 2756 | note_t *noteDst = &patt[(j * PAULA_VOICES) + cursor.channel]; |
| 2757 | if (editor.blockBuffer[i].period == 0 && editor.blockBuffer[i].sample == 0) |
| 2758 | { |
| 2759 | noteDst->command = editor.blockBuffer[i].command; |
| 2760 | noteDst->param = editor.blockBuffer[i].param; |
| 2761 | } |
| 2762 | else |
| 2763 | { |
| 2764 | *noteDst = editor.blockBuffer[i]; |
| 2765 | } |
| 2766 | |
| 2767 | if (i == editor.buffToPos || i == 63 || j == 63) |
| 2768 | break; |
| 2769 | |
| 2770 | i++; |
| 2771 | j++; |
| 2772 | gotoNextMulti(); |
| 2773 | } |
| 2774 | |
| 2775 | if (!keyb.shiftPressed) |
| 2776 | { |
| 2777 | song->currRow += (editor.buffToPos-editor.buffFromPos) + 1; |
| 2778 | if (song->currRow > 63) |
| 2779 | song->currRow = 0; |
| 2780 | } |
| 2781 | |
| 2782 | updateWindowTitle(MOD_IS_MODIFIED); |
| 2783 | ui.updatePatternData = true; |
| 2784 | } |
| 2785 | else |
| 2786 | { |
| 2787 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2788 | } |
| 2789 | } |
| 2790 | break; |
| 2791 | |
| 2792 | case SDL_SCANCODE_X: |
| 2793 | { |
| 2794 | if (keyb.leftAmigaPressed) |
| 2795 | { |
| 2796 | pattOctaDown(TRANSPOSE_ALL); |
| 2797 | } |
| 2798 | else if (keyb.leftCtrlPressed) |
| 2799 | { |
| 2800 | if (ui.samplerScreenShown) |
| 2801 | { |
| 2802 | samplerSamDelete(SAMPLE_CUT); |
| 2803 | return; |
| 2804 | } |
| 2805 | |
| 2806 | if (!editor.blockMarkFlag) |
| 2807 | { |
| 2808 | displayErrorMsg("NO BLOCK MARKED !"); |
| 2809 | return; |
| 2810 | } |
| 2811 | |
| 2812 | editor.blockMarkFlag = false; |
| 2813 | saveUndo(); |
| 2814 | editor.blockBufferFlag = true; |
| 2815 | |
| 2816 | for (int32_t i = 0; i < MOD_ROWS; i++) |
| 2817 | editor.blockBuffer[i] = song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel]; |
| 2818 | |
| 2819 | if (editor.blockFromPos > editor.blockToPos) |
| 2820 | { |
| 2821 | editor.buffFromPos = editor.blockToPos; |
| 2822 | editor.buffToPos = editor.blockFromPos; |
| 2823 | } |
| 2824 | else |
| 2825 | { |
| 2826 | editor.buffFromPos = editor.blockFromPos; |
| 2827 | editor.buffToPos = editor.blockToPos; |
| 2828 | } |
| 2829 | |
| 2830 | for (int32_t i = editor.buffFromPos; i <= editor.buffToPos; i++) |
| 2831 | { |
| 2832 | note_t *noteDst = &song->patterns[song->currPattern][(i * PAULA_VOICES) + cursor.channel]; |
| 2833 | noteDst->period = 0; |
| 2834 | noteDst->sample = 0; |
| 2835 | noteDst->command = 0; |
| 2836 | noteDst->param = 0; |
| 2837 | } |
| 2838 | |
| 2839 | statusAllRight(); |
| 2840 | updateWindowTitle(MOD_IS_MODIFIED); |
| 2841 | ui.updatePatternData = true; |
| 2842 | } |
| 2843 | else |
| 2844 | { |
| 2845 | if (keyb.leftAltPressed) |
| 2846 | { |
| 2847 | editor.muted[1] ^= 1; // toggle channel 2 |
| 2848 | renderMuteButtons(); |
| 2849 | } |
| 2850 | else |
| 2851 | { |
| 2852 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2853 | } |
| 2854 | } |
| 2855 | } |
| 2856 | break; |
| 2857 | |
| 2858 | case SDL_SCANCODE_Y: |
| 2859 | { |
| 2860 | uint8_t blockFrom, blockTo; |
| 2861 | |
| 2862 | if (keyb.leftCtrlPressed) |
| 2863 | { |
| 2864 | if (!editor.blockMarkFlag) |
| 2865 | { |
| 2866 | displayErrorMsg("NO BLOCK MARKED !"); |
| 2867 | return; |
| 2868 | } |
| 2869 | |
| 2870 | editor.blockMarkFlag = false; |
| 2871 | |
| 2872 | saveUndo(); |
| 2873 | |
| 2874 | if (editor.blockFromPos >= editor.blockToPos) |
| 2875 | { |
| 2876 | blockFrom = editor.blockToPos; |
| 2877 | blockTo = editor.blockFromPos; |
| 2878 | } |
| 2879 | else |
| 2880 | { |
| 2881 | blockFrom = editor.blockFromPos; |
| 2882 | blockTo = editor.blockToPos; |
| 2883 | } |
| 2884 | |
| 2885 | while (blockFrom < blockTo) |
| 2886 | { |
| 2887 | note_t *noteDst = &song->patterns[song->currPattern][(blockFrom * PAULA_VOICES) + cursor.channel]; |
| 2888 | note_t *noteSrc = &song->patterns[song->currPattern][(blockTo * PAULA_VOICES) + cursor.channel]; |
| 2889 | |
| 2890 | note_t noteTmp = *noteDst; |
| 2891 | *noteDst = *noteSrc; |
| 2892 | *noteSrc = noteTmp; |
| 2893 | |
| 2894 | blockFrom += 1; |
| 2895 | blockTo -= 1; |
| 2896 | } |
| 2897 | |
| 2898 | statusAllRight(); |
| 2899 | updateWindowTitle(MOD_IS_MODIFIED); |
| 2900 | ui.updatePatternData = true; |
| 2901 | } |
| 2902 | else if (keyb.leftAltPressed) |
| 2903 | { |
| 2904 | if (askBox(ASKBOX_YES_NO, "SAVE ALL SAMPLES?")) |
| 2905 | { |
| 2906 | int8_t oldSample = editor.currSample; |
| 2907 | for (int32_t i = 0; i < MOD_SAMPLES; i++) |
| 2908 | { |
| 2909 | editor.currSample = (int8_t)i; |
| 2910 | if (song->samples[i].length > 2) |
| 2911 | saveSample(DONT_CHECK_IF_FILE_EXIST, GIVE_NEW_FILENAME); |
| 2912 | } |
| 2913 | editor.currSample = oldSample; |
| 2914 | |
| 2915 | displayMsg("SAMPLES SAVED !"); |
| 2916 | setMsgPointer(); |
| 2917 | } |
| 2918 | } |
| 2919 | else |
| 2920 | { |
| 2921 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2922 | } |
| 2923 | } |
| 2924 | break; |
| 2925 | |
| 2926 | case SDL_SCANCODE_Z: |
| 2927 | { |
| 2928 | if (ui.samplerScreenShown && keyb.shiftPressed) |
| 2929 | { |
| 2930 | if (keyb.leftCtrlPressed || keyb.leftAltPressed) |
| 2931 | samplerPlayRange(); |
| 2932 | } |
| 2933 | else |
| 2934 | { |
| 2935 | if (keyb.leftAmigaPressed) |
| 2936 | { |
| 2937 | trackOctaDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1); |
| 2938 | } |
| 2939 | else if (keyb.leftCtrlPressed) |
| 2940 | { |
| 2941 | if (ui.samplerScreenShown) |
| 2942 | { |
| 2943 | if (askBox(ASKBOX_YES_NO, "RESTORE SAMPLE?")) |
| 2944 | redoSampleData(editor.currSample); |
| 2945 | } |
| 2946 | else |
| 2947 | { |
| 2948 | modSetTempo(125, true); |
| 2949 | modSetSpeed(6); |
| 2950 | |
| 2951 | moduleChannel_t *ch = song->channels; |
| 2952 | for (int32_t i = 0; i < PAULA_VOICES; i++, ch++) |
| 2953 | { |
| 2954 | ch->n_wavecontrol = 0; |
| 2955 | ch->n_glissfunk = 0; |
| 2956 | ch->n_finetune = 0; |
| 2957 | ch->n_loopcount = 0; |
| 2958 | } |
| 2959 | |
| 2960 | displayMsg("EFX RESTORED !"); |
| 2961 | } |
| 2962 | } |
| 2963 | else if (keyb.leftAltPressed) |
| 2964 | { |
| 2965 | editor.muted[0] ^= 1; // toggle channel 1 |
| 2966 | renderMuteButtons(); |
| 2967 | } |
| 2968 | else |
| 2969 | { |
| 2970 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2971 | } |
| 2972 | } |
| 2973 | } |
| 2974 | break; |
| 2975 | |
| 2976 | default: |
| 2977 | handleEditKeys(scancode, EDIT_NORMAL); |
| 2978 | break; |
| 2979 | } |
| 2980 | } |
| 2981 | |
| 2982 | static void movePatCurPrevCh(void) |
| 2983 | { |
| 2984 | int8_t pos = ((cursor.pos + 5) / 6) - 1; |
| 2985 | |
| 2986 | cursor.pos = (pos < 0) ? (3 * 6) : (pos * 6); |
| 2987 | cursor.mode = CURSOR_NOTE; |
| 2988 | |
| 2989 | if (cursor.pos < 6) cursor.channel = 0; |
| 2990 | else if (cursor.pos < 12) cursor.channel = 1; |
| 2991 | else if (cursor.pos < 18) cursor.channel = 2; |
| 2992 | else if (cursor.pos < 24) cursor.channel = 3; |
| 2993 | |
| 2994 | updateCursorPos(); |
| 2995 | } |
| 2996 | |
| 2997 | static void movePatCurNextCh(void) |
| 2998 | { |
| 2999 | int8_t pos = (cursor.pos / 6) + 1; |
| 3000 | |
| 3001 | cursor.pos = (pos == 4) ? 0 : (pos * 6); |
| 3002 | cursor.mode = CURSOR_NOTE; |
| 3003 | |
| 3004 | if (cursor.pos < 6) cursor.channel = 0; |
| 3005 | else if (cursor.pos < 12) cursor.channel = 1; |
| 3006 | else if (cursor.pos < 18) cursor.channel = 2; |
| 3007 | else if (cursor.pos < 24) cursor.channel = 3; |
| 3008 | |
| 3009 | updateCursorPos(); |
| 3010 | } |
| 3011 | |
| 3012 | static void movePatCurRight(void) |
| 3013 | { |
| 3014 | cursor.pos = (cursor.pos == 23) ? 0 : (cursor.pos + 1); |
| 3015 | |
| 3016 | if (cursor.pos < 6) cursor.channel = 0; |
| 3017 | else if (cursor.pos < 12) cursor.channel = 1; |
| 3018 | else if (cursor.pos < 18) cursor.channel = 2; |
| 3019 | else if (cursor.pos < 24) cursor.channel = 3; |
| 3020 | |
| 3021 | cursor.mode = cursor.pos % 6; |
| 3022 | updateCursorPos(); |
| 3023 | } |
| 3024 | |
| 3025 | static void movePatCurLeft(void) |
| 3026 | { |
| 3027 | cursor.pos = (cursor.pos == 0) ? 23 : (cursor.pos - 1); |
| 3028 | |
| 3029 | if (cursor.pos < 6) cursor.channel = 0; |
| 3030 | else if (cursor.pos < 12) cursor.channel = 1; |
| 3031 | else if (cursor.pos < 18) cursor.channel = 2; |
| 3032 | else if (cursor.pos < 24) cursor.channel = 3; |
| 3033 | |
| 3034 | cursor.mode = cursor.pos % 6; |
| 3035 | updateCursorPos(); |
| 3036 | } |
| 3037 | |
| 3038 | void handleKeyRepeat(SDL_Scancode scancode) |
| 3039 | { |
| 3040 | if (keyb.lastRepKey == 0) |
| 3041 | return; |
| 3042 | |
| 3043 | if (!keyb.repeatKey || ui.askBoxShown) |
| 3044 | { |
| 3045 | keyb.repeatFrac = 0; |
| 3046 | keyb.repeatCounter = 0; |
| 3047 | return; |
| 3048 | } |
| 3049 | |
| 3050 | if (keyb.delayKey && keyb.delayCounter < KEYB_REPEAT_DELAY) |
| 3051 | { |
| 3052 | keyb.delayCounter++; |
| 3053 | return; |
| 3054 | } |
| 3055 | |
| 3056 | switch (scancode) // only some buttons have repeat |
| 3057 | { |
| 3058 | case SDL_SCANCODE_PAGEUP: |
| 3059 | { |
| 3060 | if (keyb.repeatCounter >= 3) |
| 3061 | { |
| 3062 | keyb.repeatCounter = 0; |
| 3063 | |
| 3064 | if (ui.posEdScreenShown) |
| 3065 | { |
| 3066 | posEdPageUp(); |
| 3067 | } |
| 3068 | else if (ui.diskOpScreenShown) |
| 3069 | { |
| 3070 | if (ui.diskOpScreenShown) |
| 3071 | { |
| 3072 | diskop.scrollOffset -= DISKOP_LINES-1; |
| 3073 | if (diskop.scrollOffset < 0) |
| 3074 | diskop.scrollOffset = 0; |
| 3075 | |
| 3076 | ui.updateDiskOpFileList = true; |
| 3077 | } |
| 3078 | } |
| 3079 | else if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT) |
| 3080 | { |
| 3081 | if (song->currRow == 63) |
| 3082 | modSetPos(DONT_SET_ORDER, song->currRow - 15); |
| 3083 | else if (song->currRow == 15) |
| 3084 | modSetPos(DONT_SET_ORDER, 0); // 15-16 would turn into -1, which is "DON'T SET ROW" flag |
| 3085 | else |
| 3086 | modSetPos(DONT_SET_ORDER, song->currRow - 16); |
| 3087 | } |
| 3088 | } |
| 3089 | } |
| 3090 | break; |
| 3091 | |
| 3092 | case SDL_SCANCODE_PAGEDOWN: |
| 3093 | { |
| 3094 | if (keyb.repeatCounter >= 3) |
| 3095 | { |
| 3096 | keyb.repeatCounter = 0; |
| 3097 | |
| 3098 | if (ui.posEdScreenShown) |
| 3099 | { |
| 3100 | posEdPageDown(); |
| 3101 | } |
| 3102 | else if (ui.diskOpScreenShown) |
| 3103 | { |
| 3104 | if (diskop.numEntries > DISKOP_LINES) |
| 3105 | { |
| 3106 | diskop.scrollOffset += DISKOP_LINES-1; |
| 3107 | if (diskop.scrollOffset > diskop.numEntries-DISKOP_LINES) |
| 3108 | diskop.scrollOffset = diskop.numEntries-DISKOP_LINES; |
| 3109 | |
| 3110 | ui.updateDiskOpFileList = true; |
| 3111 | } |
| 3112 | } |
| 3113 | else if (editor.currMode == MODE_IDLE || editor.currMode == MODE_EDIT) |
| 3114 | { |
| 3115 | modSetPos(DONT_SET_ORDER, song->currRow + 16); |
| 3116 | } |
| 3117 | } |
| 3118 | } |
| 3119 | break; |
| 3120 | |
| 3121 | case SDL_SCANCODE_LEFT: |
| 3122 | { |
| 3123 | if (ui.samplerScreenShown && keyb.shiftPressed) |
| 3124 | { |
| 3125 | if (editor.markStartOfs >= 0 && (keyb.leftCtrlPressed || keyb.leftAltPressed)) |
| 3126 | { |
| 3127 | if (keyb.delayCounter >= 6) |
| 3128 | { |
| 3129 | if (keyb.repeatCounter >= 2) |
| 3130 | { |
| 3131 | keyb.repeatCounter = 0; |
| 3132 | int32_t start = smpPos2Scr(editor.markStartOfs); |
| 3133 | if (start > 0) |
| 3134 | { |
| 3135 | start--; |
| 3136 | invertRange(); |
| 3137 | editor.markStartOfs = scr2SmpPos(start); |
| 3138 | invertRange(); |
| 3139 | } |
| 3140 | } |
| 3141 | } |
| 3142 | else |
| 3143 | { |
| 3144 | keyb.delayCounter++; |
| 3145 | } |
| 3146 | } |
| 3147 | } |
| 3148 | else |
| 3149 | { |
| 3150 | if (ui.editTextFlag) |
| 3151 | { |
| 3152 | if (keyb.delayCounter >= 6) |
| 3153 | { |
| 3154 | if (keyb.repeatCounter >= 3) |
| 3155 | { |
| 3156 | keyb.repeatCounter = 0; |
| 3157 | editTextPrevChar(); |
| 3158 | } |
| 3159 | } |
| 3160 | else |
| 3161 | { |
| 3162 | keyb.delayCounter++; |
| 3163 | } |
| 3164 | } |
| 3165 | else |
| 3166 | { |
| 3167 | if (keyb.leftCtrlPressed) |
| 3168 | { |
| 3169 | if (keyb.repeatCounter >= 6) |
| 3170 | { |
| 3171 | keyb.repeatCounter = 0; |
| 3172 | sampleDownButton(); |
| 3173 | } |
| 3174 | } |
| 3175 | else if (keyb.shiftPressed) |
| 3176 | { |
| 3177 | if (keyb.repeatCounter >= 6) |
| 3178 | { |
| 3179 | keyb.repeatCounter = 0; |
| 3180 | if (song->currPos > 0) |
| 3181 | modSetPos(song->currPos - 1, DONT_SET_ROW); |
| 3182 | } |
| 3183 | } |
| 3184 | else if (keyb.leftAltPressed) |
| 3185 | { |
| 3186 | if (keyb.repeatCounter >= 4) |
| 3187 | { |
| 3188 | keyb.repeatCounter = 0; |
| 3189 | decPatt(); |
| 3190 | } |
| 3191 | } |
| 3192 | else |
| 3193 | { |
| 3194 | if (keyb.repeatCounter >= 6) |
| 3195 | { |
| 3196 | keyb.repeatCounter = 0; |
| 3197 | if (!keyb.shiftPressed && !keyb.leftAltPressed && !keyb.leftCtrlPressed) |
| 3198 | movePatCurLeft(); |
| 3199 | } |
| 3200 | } |
| 3201 | } |
| 3202 | } |
| 3203 | } |
| 3204 | break; |
| 3205 | |
| 3206 | case SDL_SCANCODE_RIGHT: |
| 3207 | { |
| 3208 | if (ui.samplerScreenShown && keyb.shiftPressed) |
| 3209 | { |
| 3210 | if (editor.markStartOfs >= 0 && (keyb.leftCtrlPressed || keyb.leftAltPressed)) |
| 3211 | { |
| 3212 | if (keyb.delayCounter >= KEYB_REPEAT_DELAY) |
| 3213 | { |
| 3214 | if (keyb.repeatCounter >= 2) |
| 3215 | { |
| 3216 | keyb.repeatCounter = 0; |
| 3217 | int32_t start = smpPos2Scr(editor.markStartOfs); |
| 3218 | if (start < 313) |
| 3219 | { |
| 3220 | start++; |
| 3221 | invertRange(); |
| 3222 | editor.markStartOfs = scr2SmpPos(start); |
| 3223 | |
| 3224 | if (editor.markStartOfs > editor.markEndOfs) |
| 3225 | { |
| 3226 | int32_t tmp = editor.markEndOfs; |
| 3227 | editor.markEndOfs = editor.markStartOfs; |
| 3228 | editor.markStartOfs = tmp; |
| 3229 | } |
| 3230 | |
| 3231 | invertRange(); |
| 3232 | } |
| 3233 | } |
| 3234 | } |
| 3235 | } |
| 3236 | } |
| 3237 | else |
| 3238 | { |
| 3239 | if (ui.editTextFlag) |
| 3240 | { |
| 3241 | if (keyb.delayCounter >= KEYB_REPEAT_DELAY) |
| 3242 | { |
| 3243 | if (keyb.repeatCounter >= 6) |
| 3244 | { |
| 3245 | keyb.repeatCounter = 0; |
| 3246 | editTextNextChar(); |
| 3247 | } |
| 3248 | } |
| 3249 | else |
| 3250 | { |
| 3251 | keyb.delayCounter++; |
| 3252 | } |
| 3253 | } |
| 3254 | else |
| 3255 | { |
| 3256 | if (keyb.leftCtrlPressed) |
| 3257 | { |
| 3258 | if (keyb.repeatCounter >= 6) |
| 3259 | { |
| 3260 | keyb.repeatCounter = 0; |
| 3261 | sampleUpButton(); |
| 3262 | } |
| 3263 | } |
| 3264 | else if (keyb.shiftPressed) |
| 3265 | { |
| 3266 | if (keyb.repeatCounter >= 6) |
| 3267 | { |
| 3268 | keyb.repeatCounter = 0; |
| 3269 | if (song->currPos < 126) |
| 3270 | modSetPos(song->currPos + 1, DONT_SET_ROW); |
| 3271 | } |
| 3272 | } |
| 3273 | else if (keyb.leftAltPressed) |
| 3274 | { |
| 3275 | if (keyb.repeatCounter >= 4) |
| 3276 | { |
| 3277 | keyb.repeatCounter = 0; |
| 3278 | incPatt(); |
| 3279 | } |
| 3280 | } |
| 3281 | else |
| 3282 | { |
| 3283 | if (keyb.repeatCounter >= 6) |
| 3284 | { |
| 3285 | keyb.repeatCounter = 0; |
| 3286 | if (!keyb.shiftPressed && !keyb.leftAltPressed && !keyb.leftCtrlPressed) |
| 3287 | movePatCurRight(); |
| 3288 | } |
| 3289 | } |
| 3290 | } |
| 3291 | } |
| 3292 | } |
| 3293 | break; |
| 3294 | |
| 3295 | case SDL_SCANCODE_UP: |
| 3296 | { |
| 3297 | if (ui.samplerScreenShown && keyb.shiftPressed) |
| 3298 | { |
| 3299 | if (editor.markStartOfs >= 0 && (keyb.leftCtrlPressed || keyb.leftAltPressed)) |
| 3300 | { |
| 3301 | if (keyb.delayCounter >= KEYB_REPEAT_DELAY) |
| 3302 | { |
| 3303 | if (keyb.repeatCounter >= 2) |
| 3304 | { |
| 3305 | keyb.repeatCounter = 0; |
| 3306 | int32_t end = smpPos2Scr(editor.markEndOfs); |
| 3307 | if (end < 313) |
| 3308 | { |
| 3309 | end++; |
| 3310 | invertRange(); |
| 3311 | editor.markEndOfs = scr2SmpPos(end); |
| 3312 | |
| 3313 | if (editor.markStartOfs > editor.markEndOfs) |
| 3314 | { |
| 3315 | int32_t tmp = editor.markEndOfs; |
| 3316 | editor.markEndOfs = editor.markStartOfs; |
| 3317 | editor.markStartOfs = tmp; |
| 3318 | } |
| 3319 | |
| 3320 | invertRange(); |
| 3321 | } |
| 3322 | } |
| 3323 | } |
| 3324 | } |
| 3325 | } |
| 3326 | else |
| 3327 | { |
| 3328 | if (ui.diskOpScreenShown) |
| 3329 | { |
| 3330 | if (keyb.repeatCounter >= 1) |
| 3331 | { |
| 3332 | keyb.repeatCounter = 0; |
| 3333 | |
| 3334 | diskop.scrollOffset--; |
| 3335 | if (mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN |
| 3336 | diskop.scrollOffset -= 3; |
| 3337 | |
| 3338 | if (diskop.scrollOffset < 0) |
| 3339 | diskop.scrollOffset = 0; |
| 3340 | |
| 3341 | ui.updateDiskOpFileList = true; |
| 3342 | } |
| 3343 | } |
| 3344 | else if (ui.posEdScreenShown) |
| 3345 | { |
| 3346 | if (keyb.repeatCounter >= 3) |
| 3347 | { |
| 3348 | keyb.repeatCounter = 0; |
| 3349 | posEdScrollUp(); |
| 3350 | } |
| 3351 | } |
| 3352 | else if (!ui.samplerScreenShown) |
| 3353 | { |
| 3354 | if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD) |
| 3355 | { |
| 3356 | uint8_t repeatNum = 6; |
| 3357 | if (keyb.leftAltPressed) |
| 3358 | repeatNum = 1; |
| 3359 | else if (keyb.shiftPressed) |
| 3360 | repeatNum = 3; |
| 3361 | |
| 3362 | if (keyb.repeatCounter >= repeatNum) |
| 3363 | { |
| 3364 | keyb.repeatCounter = 0; |
| 3365 | modSetPos(DONT_SET_ORDER, (song->currRow - 1) & 63); |
| 3366 | } |
| 3367 | } |
| 3368 | } |
| 3369 | } |
| 3370 | } |
| 3371 | break; |
| 3372 | |
| 3373 | case SDL_SCANCODE_DOWN: |
| 3374 | { |
| 3375 | if (ui.samplerScreenShown && keyb.shiftPressed) |
| 3376 | { |
| 3377 | if (editor.markStartOfs >= 0 && (keyb.leftCtrlPressed || keyb.leftAltPressed)) |
| 3378 | { |
| 3379 | if (keyb.delayCounter >= KEYB_REPEAT_DELAY) |
| 3380 | { |
| 3381 | if (keyb.repeatCounter >= 2) |
| 3382 | { |
| 3383 | keyb.repeatCounter = 0; |
| 3384 | int32_t end = smpPos2Scr(editor.markEndOfs); |
| 3385 | if (end > 0) |
| 3386 | { |
| 3387 | end--; |
| 3388 | invertRange(); |
| 3389 | editor.markEndOfs = scr2SmpPos(end); |
| 3390 | |
| 3391 | if (editor.markStartOfs > editor.markEndOfs) |
| 3392 | { |
| 3393 | int32_t tmp = editor.markEndOfs; |
| 3394 | editor.markEndOfs = editor.markStartOfs; |
| 3395 | editor.markStartOfs = tmp; |
| 3396 | } |
| 3397 | |
| 3398 | invertRange(); |
| 3399 | } |
| 3400 | } |
| 3401 | } |
| 3402 | } |
| 3403 | } |
| 3404 | else |
| 3405 | { |
| 3406 | if (ui.diskOpScreenShown) |
| 3407 | { |
| 3408 | if (keyb.repeatCounter >= 1) |
| 3409 | { |
| 3410 | keyb.repeatCounter = 0; |
| 3411 | |
| 3412 | if (diskop.numEntries > DISKOP_LINES) |
| 3413 | { |
| 3414 | diskop.scrollOffset++; |
| 3415 | if (mouse.rightButtonPressed) // PT quirk: right mouse button speeds up scrolling even on keyb UP/DOWN |
| 3416 | diskop.scrollOffset += 3; |
| 3417 | |
| 3418 | if (diskop.scrollOffset > diskop.numEntries-DISKOP_LINES) |
| 3419 | diskop.scrollOffset = diskop.numEntries-DISKOP_LINES; |
| 3420 | |
| 3421 | ui.updateDiskOpFileList = true; |
| 3422 | } |
| 3423 | } |
| 3424 | } |
| 3425 | else if (ui.posEdScreenShown) |
| 3426 | { |
| 3427 | if (keyb.repeatCounter >= 3) |
| 3428 | { |
| 3429 | keyb.repeatCounter = 0; |
| 3430 | posEdScrollDown(); |
| 3431 | } |
| 3432 | } |
| 3433 | else if (!ui.samplerScreenShown) |
| 3434 | { |
| 3435 | if (editor.currMode != MODE_PLAY && editor.currMode != MODE_RECORD) |
| 3436 | { |
| 3437 | uint8_t repeatNum = 6; |
| 3438 | if (keyb.leftAltPressed) |
| 3439 | repeatNum = 1; |
| 3440 | else if (keyb.shiftPressed) |
| 3441 | repeatNum = 3; |
| 3442 | |
| 3443 | if (keyb.repeatCounter >= repeatNum) |
| 3444 | { |
| 3445 | keyb.repeatCounter = 0; |
| 3446 | modSetPos(DONT_SET_ORDER, (song->currRow + 1) & 63); |
| 3447 | } |
| 3448 | } |
| 3449 | } |
| 3450 | } |
| 3451 | } |
| 3452 | break; |
| 3453 | |
| 3454 | case SDL_SCANCODE_BACKSPACE: |
| 3455 | { |
| 3456 | if (ui.editTextFlag) |
| 3457 | { |
| 3458 | // only repeat backspace while editing texts |
| 3459 | |
| 3460 | if (keyb.delayCounter >= KEYB_REPEAT_DELAY) |
| 3461 | { |
| 3462 | if (keyb.repeatCounter >= 3) |
| 3463 | { |
| 3464 | keyb.repeatCounter = 0; |
| 3465 | keyDownHandler(scancode, 0); |
| 3466 | } |
| 3467 | } |
| 3468 | else |
| 3469 | { |
| 3470 | keyb.delayCounter++; |
| 3471 | } |
| 3472 | } |
| 3473 | } |
| 3474 | break; |
| 3475 | |
| 3476 | case SDL_SCANCODE_KP_ENTER: |
| 3477 | case SDL_SCANCODE_RETURN: |
| 3478 | break; // do NOT repeat enter! |
| 3479 | |
| 3480 | default: |
| 3481 | { |
| 3482 | if (keyb.repeatCounter >= 3) |
| 3483 | { |
| 3484 | keyb.repeatCounter = 0; |
| 3485 | keyDownHandler(scancode, 0); |
| 3486 | } |
| 3487 | } |
| 3488 | break; |
| 3489 | } |
| 3490 | |
| 3491 | // handle key repeating at ~49.92Hz (Amiga PAL vblank rate) |
| 3492 | |
| 3493 | const uint32_t delta31 = (uint32_t)(((INT32_MAX+1.0) / ((double)VBLANK_HZ / AMIGA_PAL_VBLANK_HZ)) + 0.5); |
| 3494 | |
| 3495 | keyb.repeatFrac += delta31; // 0.31fp |
| 3496 | if (keyb.repeatFrac > INT32_MAX) |
| 3497 | { |
| 3498 | keyb.repeatFrac &= INT32_MAX; |
| 3499 | keyb.repeatCounter++; |
| 3500 | } |
| 3501 | } |
| 3502 | |
| 3503 | static void swapChannel(uint8_t srcCh, uint8_t dstCh) |
| 3504 | { |
| 3505 | if (srcCh == dstCh) |
| 3506 | return; |
| 3507 | |
| 3508 | for (int32_t i = 0; i < MOD_ROWS; i++) |
| 3509 | { |
| 3510 | note_t *noteSrc = &song->patterns[song->currPattern][(i * PAULA_VOICES) + dstCh]; |
| 3511 | note_t noteTmp = song->patterns[song->currPattern][(i * PAULA_VOICES) + srcCh]; |
| 3512 | |
| 3513 | song->patterns[song->currPattern][(i * PAULA_VOICES) + srcCh] = *noteSrc; |
| 3514 | *noteSrc = noteTmp; |
| 3515 | } |
| 3516 | |
| 3517 | updateWindowTitle(MOD_IS_MODIFIED); |
| 3518 | ui.updatePatternData = true; |
| 3519 | } |
| 3520 | |
| 3521 | static bool handleGeneralModes(SDL_Scancode scancode) |
| 3522 | { |
| 3523 | // if MOD2WAV is ongoing, only check for ESC key |
| 3524 | if (editor.mod2WavOngoing) |
| 3525 | { |
| 3526 | if (scancode == SDL_SCANCODE_ESCAPE) |
| 3527 | editor.abortMod2Wav = true; |
| 3528 | |
| 3529 | return false; // don't handle other keys |
| 3530 | } |
| 3531 | |
| 3532 | // SAMPLER SCREEN (volume box) |
| 3533 | if (ui.samplerVolBoxShown && !ui.editTextFlag && scancode == SDL_SCANCODE_ESCAPE) |
| 3534 | { |
| 3535 | ui.samplerVolBoxShown = false; |
| 3536 | removeSamplerVolBox(); |
| 3537 | return false; |
| 3538 | } |
| 3539 | |
| 3540 | // SAMPLER SCREEN (filters box) |
| 3541 | if (ui.samplerFiltersBoxShown && !ui.editTextFlag && scancode == SDL_SCANCODE_ESCAPE) |
| 3542 | { |
| 3543 | ui.samplerFiltersBoxShown = false; |
| 3544 | removeSamplerFiltersBox(); |
| 3545 | return false; |
| 3546 | } |
| 3547 | |
| 3548 | // SAMPLER SCREEN (sampling box) |
| 3549 | if (ui.samplingBoxShown) |
| 3550 | { |
| 3551 | if (audio.isSampling) |
| 3552 | { |
| 3553 | stopSampling(); |
| 3554 | return false; |
| 3555 | } |
| 3556 | |
| 3557 | if (scancode == SDL_SCANCODE_F1) |
| 3558 | editor.keyOctave = OCTAVE_LOW; |
| 3559 | else if (scancode == SDL_SCANCODE_F2) |
| 3560 | editor.keyOctave = OCTAVE_HIGH; |
| 3561 | |
| 3562 | if (ui.changingSamplingNote) |
| 3563 | { |
| 3564 | if (scancode == SDL_SCANCODE_ESCAPE) |
| 3565 | { |
| 3566 | ui.changingSamplingNote = false; |
| 3567 | setPrevStatusMessage(); |
| 3568 | pointerSetPreviousMode(); |
| 3569 | } |
| 3570 | |
| 3571 | int8_t rawKey = keyToNote(scancode); |
| 3572 | if (rawKey >= 0) |
| 3573 | { |
| 3574 | ui.changingSamplingNote = false; |
| 3575 | |
| 3576 | setSamplingNote(rawKey); |
| 3577 | |
| 3578 | setPrevStatusMessage(); |
| 3579 | pointerSetPreviousMode(); |
| 3580 | } |
| 3581 | |
| 3582 | return false; |
| 3583 | } |
| 3584 | else |
| 3585 | { |
| 3586 | if (keyb.leftCtrlPressed) |
| 3587 | { |
| 3588 | if (scancode == SDL_SCANCODE_LEFT) |
| 3589 | samplingSampleNumDown(); |
| 3590 | else if (scancode == SDL_SCANCODE_RIGHT) |
| 3591 | samplingSampleNumUp(); |
| 3592 | } |
| 3593 | else |
| 3594 | { |
| 3595 | if (scancode == SDL_SCANCODE_SPACE) |
| 3596 | turnOffVoices(); |
| 3597 | else |
| 3598 | handleSampleJamming(scancode); |
| 3599 | } |
| 3600 | } |
| 3601 | |
| 3602 | if (!ui.editTextFlag && scancode == SDL_SCANCODE_ESCAPE) |
| 3603 | { |
| 3604 | ui.samplingBoxShown = false; |
| 3605 | removeSamplingBox(); |
| 3606 | } |
| 3607 | |
| 3608 | return false; |
| 3609 | } |
| 3610 | |
| 3611 | // EDIT OP. SCREEN #3 |
| 3612 | if (editor.mixFlag && scancode == SDL_SCANCODE_ESCAPE) |
| 3613 | { |
| 3614 | leaveTextEditMode(EDIT_TEXT_UPDATE); |
| 3615 | editor.mixFlag = false; |
| 3616 | ui.updateMixText = true; |
| 3617 | return false; |
| 3618 | } |
| 3619 | |
| 3620 | // EDIT OP. SCREEN #4 |
| 3621 | if (ui.changingChordNote) |
| 3622 | { |
| 3623 | if (scancode == SDL_SCANCODE_ESCAPE) |
| 3624 | { |
| 3625 | ui.changingChordNote = false; |
| 3626 | setPrevStatusMessage(); |
| 3627 | pointerSetPreviousMode(); |
| 3628 | return false; |
| 3629 | } |
| 3630 | |
| 3631 | if (scancode == SDL_SCANCODE_F1) |
| 3632 | editor.keyOctave = OCTAVE_LOW; |
| 3633 | else if (scancode == SDL_SCANCODE_F2) |
| 3634 | editor.keyOctave = OCTAVE_HIGH; |
| 3635 | |
| 3636 | int8_t rawKey = keyToNote(scancode); |
| 3637 | if (rawKey >= 0) |
| 3638 | { |
| 3639 | if (ui.changingChordNote == 1) |
| 3640 | { |
| 3641 | editor.note1 = rawKey; |
| 3642 | ui.updateChordNote1Text = true; |
| 3643 | } |
| 3644 | else if (ui.changingChordNote == 2) |
| 3645 | { |
| 3646 | editor.note2 = rawKey; |
| 3647 | ui.updateChordNote2Text = true; |
| 3648 | } |
| 3649 | else if (ui.changingChordNote == 3) |
| 3650 | { |
| 3651 | editor.note3 = rawKey; |
| 3652 | ui.updateChordNote3Text = true; |
| 3653 | } |
| 3654 | else if (ui.changingChordNote == 4) |
| 3655 | { |
| 3656 | editor.note4 = rawKey; |
| 3657 | ui.updateChordNote4Text = true; |
| 3658 | } |
| 3659 | |
| 3660 | ui.changingChordNote = false; |
| 3661 | recalcChordLength(); |
| 3662 | |
| 3663 | setPrevStatusMessage(); |
| 3664 | pointerSetPreviousMode(); |
| 3665 | } |
| 3666 | |
| 3667 | return false; |
| 3668 | } |
| 3669 | |
| 3670 | // CHANGE DRUMPAD NOTE |
| 3671 | if (ui.changingDrumPadNote) |
| 3672 | { |
| 3673 | if (scancode == SDL_SCANCODE_ESCAPE) |
| 3674 | { |
| 3675 | ui.changingDrumPadNote = false; |
| 3676 | setPrevStatusMessage(); |
| 3677 | pointerSetPreviousMode(); |
| 3678 | return false; |
| 3679 | } |
| 3680 | |
| 3681 | if (scancode == SDL_SCANCODE_F1) |
| 3682 | editor.keyOctave = OCTAVE_LOW; |
| 3683 | else if (scancode == SDL_SCANCODE_F2) |
| 3684 | editor.keyOctave = OCTAVE_HIGH; |
| 3685 | |
| 3686 | int8_t rawKey = keyToNote(scancode); |
| 3687 | if (rawKey >= 0) |
| 3688 | { |
| 3689 | pNoteTable[editor.currSample] = rawKey; |
| 3690 | ui.changingDrumPadNote = false; |
| 3691 | setPrevStatusMessage(); |
| 3692 | pointerSetPreviousMode(); |
| 3693 | } |
| 3694 | |
| 3695 | return false; |
| 3696 | } |
| 3697 | |
| 3698 | // SAMPLER SCREEN |
| 3699 | if (ui.changingSmpResample) |
| 3700 | { |
| 3701 | if (scancode == SDL_SCANCODE_ESCAPE) |
| 3702 | { |
| 3703 | ui.changingSmpResample = false; |
| 3704 | ui.updateResampleNote = true; |
| 3705 | setPrevStatusMessage(); |
| 3706 | pointerSetPreviousMode(); |
| 3707 | return false; |
| 3708 | } |
| 3709 | |
| 3710 | if (scancode == SDL_SCANCODE_F1) |
| 3711 | editor.keyOctave = OCTAVE_LOW; |
| 3712 | else if (scancode == SDL_SCANCODE_F2) |
| 3713 | editor.keyOctave = OCTAVE_HIGH; |
| 3714 | |
| 3715 | int8_t rawKey = keyToNote(scancode); |
| 3716 | if (rawKey >= 0) |
| 3717 | { |
| 3718 | editor.resampleNote = rawKey; |
| 3719 | ui.changingSmpResample = false; |
| 3720 | ui.updateResampleNote = true; |
| 3721 | setPrevStatusMessage(); |
| 3722 | pointerSetPreviousMode(); |
| 3723 | } |
| 3724 | |
| 3725 | return false; |
| 3726 | } |
| 3727 | |
| 3728 | // SWAP CHANNEL (CTRL+T) |
| 3729 | if (editor.swapChannelFlag) |
| 3730 | { |
| 3731 | switch (scancode) |
| 3732 | { |
| 3733 | case SDL_SCANCODE_ESCAPE: |
| 3734 | { |
| 3735 | editor.swapChannelFlag = false; |
| 3736 | pointerSetPreviousMode(); |
| 3737 | setPrevStatusMessage(); |
| 3738 | } |
| 3739 | break; |
| 3740 | |
| 3741 | case SDL_SCANCODE_1: |
| 3742 | { |
| 3743 | swapChannel(0, cursor.channel); |
| 3744 | editor.swapChannelFlag = false; |
| 3745 | |
| 3746 | pointerSetPreviousMode(); |
| 3747 | setPrevStatusMessage(); |
| 3748 | } |
| 3749 | break; |
| 3750 | |
| 3751 | case SDL_SCANCODE_2: |
| 3752 | { |
| 3753 | swapChannel(1, cursor.channel); |
| 3754 | editor.swapChannelFlag = false; |
| 3755 | |
| 3756 | pointerSetPreviousMode(); |
| 3757 | setPrevStatusMessage(); |
| 3758 | } |
| 3759 | break; |
| 3760 | |
| 3761 | case SDL_SCANCODE_3: |
| 3762 | { |
| 3763 | swapChannel(2, cursor.channel); |
| 3764 | editor.swapChannelFlag = false; |
| 3765 | |
| 3766 | pointerSetPreviousMode(); |
| 3767 | setPrevStatusMessage(); |
| 3768 | } |
| 3769 | break; |
| 3770 | |
| 3771 | case SDL_SCANCODE_4: |
| 3772 | { |
| 3773 | swapChannel(3, cursor.channel); |
| 3774 | editor.swapChannelFlag = false; |
| 3775 | |
| 3776 | pointerSetPreviousMode(); |
| 3777 | setPrevStatusMessage(); |
| 3778 | } |
| 3779 | break; |
| 3780 | |
| 3781 | default: break; |
| 3782 | } |
| 3783 | |
| 3784 | return false; |
| 3785 | } |
| 3786 | |
| 3787 | return true; |
| 3788 | } |