ft2-clone

Fasttracker 2 clone
Log | Files | Refs | README | LICENSE

commit ad661101834900d7e42456d4f125344760739112
parent f7f05c3ee025affd1d3194de810ff31b0fd23491
Author: Olav Sørensen <olav.sorensen@live.no>
Date:   Sat, 11 May 2024 13:14:55 +0200

Fix sample jamming not working if the pattern editor was hidden

Diffstat:
Msrc/ft2_edit.c | 31++++++++++++++++++++-----------
Msrc/ft2_header.h | 2+-
Msrc/ft2_keyboard.c | 4++--
3 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/src/ft2_edit.c b/src/ft2_edit.c @@ -43,8 +43,10 @@ static bool testNoteKeys(SDL_Scancode scancode) const int8_t noteNum = scancodeKeyToNote(scancode); if (noteNum == NOTE_OFF) { + bool editmode = ui.patternEditorShown && (playMode == PLAYMODE_EDIT); + // inserts "note off" if editing song - if (playMode == PLAYMODE_EDIT || playMode == PLAYMODE_RECPATT || playMode == PLAYMODE_RECSONG) + if (editmode || playMode == PLAYMODE_RECPATT || playMode == PLAYMODE_RECSONG) { pauseMusic(); const volatile uint16_t curPattern = editor.editPattern; @@ -88,20 +90,21 @@ static bool testEditKeys(SDL_Scancode scancode, SDL_Keycode keycode) { int8_t i; + bool editmode = ui.patternEditorShown && (playMode == PLAYMODE_EDIT); + if (cursor.object == CURSOR_NOTE) { // the edit cursor is at the note slot if (testNoteKeys(scancode)) { - keyb.keyRepeat = (playMode == PLAYMODE_EDIT); // repeat keys only if in edit mode + keyb.keyRepeat = editmode; // repeat keys only if in edit mode return true; // we jammed an instrument } return false; // no note key pressed, test other keys } - - if (playMode != PLAYMODE_EDIT && playMode != PLAYMODE_RECSONG && playMode != PLAYMODE_RECPATT) + if (!editmode && playMode != PLAYMODE_RECSONG && playMode != PLAYMODE_RECPATT) return false; // we're not editing, test other keys // convert key to slot data @@ -348,7 +351,7 @@ void recordNote(uint8_t noteNum, int8_t vol) // directly ported from the origina tick = 0; } - bool editmode = (playMode == PLAYMODE_EDIT); + bool editmode = ui.patternEditorShown && (playMode == PLAYMODE_EDIT); bool recmode = (playMode == PLAYMODE_RECSONG) || (playMode == PLAYMODE_RECPATT); if (noteNum == NOTE_OFF) @@ -564,7 +567,8 @@ bool handleEditKeys(SDL_Keycode keycode, SDL_Scancode scancode) // special case for delete - manipulate note data if (keycode == SDLK_DELETE) { - if (playMode != PLAYMODE_EDIT && playMode != PLAYMODE_RECSONG && playMode != PLAYMODE_RECPATT) + bool editmode = ui.patternEditorShown && (playMode == PLAYMODE_EDIT); + if (!editmode && playMode != PLAYMODE_RECSONG && playMode != PLAYMODE_RECPATT) return false; // we're not editing, test other keys pauseMusic(); @@ -663,7 +667,8 @@ void writeFromMacroSlot(uint8_t slot) int16_t row = editor.row; resumeMusic(); - if (playMode != PLAYMODE_EDIT && playMode != PLAYMODE_RECSONG && playMode != PLAYMODE_RECPATT) + bool editmode = ui.patternEditorShown && (playMode == PLAYMODE_EDIT); + if (!editmode && playMode != PLAYMODE_RECSONG && playMode != PLAYMODE_RECPATT) return; if (!allocatePattern(curPattern)) @@ -707,7 +712,8 @@ void insertPatternNote(void) int16_t row = editor.row; resumeMusic(); - if (playMode != PLAYMODE_EDIT && playMode != PLAYMODE_RECPATT && playMode != PLAYMODE_RECSONG) + bool editmode = ui.patternEditorShown && (playMode == PLAYMODE_EDIT); + if (!editmode && playMode != PLAYMODE_RECPATT && playMode != PLAYMODE_RECSONG) return; note_t *p = pattern[curPattern]; @@ -737,7 +743,8 @@ void insertPatternLine(void) int16_t row = editor.row; resumeMusic(); - if (playMode != PLAYMODE_EDIT && playMode != PLAYMODE_RECPATT && playMode != PLAYMODE_RECSONG) + bool editmode = ui.patternEditorShown && (playMode == PLAYMODE_EDIT); + if (!editmode && playMode != PLAYMODE_RECPATT && playMode != PLAYMODE_RECSONG) return; setPatternLen(curPattern, patternNumRows[curPattern] + config.recTrueInsert); // config.recTrueInsert is 0 or 1 @@ -772,7 +779,8 @@ void deletePatternNote(void) int16_t row = editor.row; resumeMusic(); - if (playMode != PLAYMODE_EDIT && playMode != PLAYMODE_RECPATT && playMode != PLAYMODE_RECSONG) + bool editmode = ui.patternEditorShown && (playMode == PLAYMODE_EDIT); + if (!editmode && playMode != PLAYMODE_RECPATT && playMode != PLAYMODE_RECSONG) return; const int16_t numRows = patternNumRows[curPattern]; @@ -813,7 +821,8 @@ void deletePatternLine(void) int16_t row = editor.row; resumeMusic(); - if (playMode != PLAYMODE_EDIT && playMode != PLAYMODE_RECPATT && playMode != PLAYMODE_RECSONG) + bool editmode = ui.patternEditorShown && (playMode == PLAYMODE_EDIT); + if (!editmode && playMode != PLAYMODE_RECPATT && playMode != PLAYMODE_RECSONG) return; const int16_t numRows = patternNumRows[curPattern]; diff --git a/src/ft2_header.h b/src/ft2_header.h @@ -12,7 +12,7 @@ #endif #include "ft2_replayer.h" -#define PROG_VER_STR "1.83" +#define PROG_VER_STR "1.84" // do NOT change these! It will only mess things up... diff --git a/src/ft2_keyboard.c b/src/ft2_keyboard.c @@ -91,7 +91,7 @@ void keyUpHandler(SDL_Scancode scancode, SDL_Keycode keycode) return; } - if (ui.patternEditorShown && cursor.object == CURSOR_NOTE && !keyb.keyModifierDown) + if (cursor.object == CURSOR_NOTE && !keyb.keyModifierDown) testNoteKeysRelease(scancode); if (scancode == SDL_SCANCODE_KP_PLUS) @@ -157,7 +157,7 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode, bool keyWasRepea if (scancode == SDL_SCANCODE_KP_PLUS) keyb.numPadPlusPressed = true; - if (ui.patternEditorShown && handleEditKeys(keycode, scancode)) + if (handleEditKeys(keycode, scancode)) return; if (keyb.keyModifierDown && checkModifiedKeys(keycode))