shithub: ft²

Download patch

ref: ad661101834900d7e42456d4f125344760739112
parent: f7f05c3ee025affd1d3194de810ff31b0fd23491
author: Olav Sørensen <olav.sorensen@live.no>
date: Sat May 11 09:15:22 EDT 2024

Fix sample jamming not working if the pattern editor was hidden

--- a/src/ft2_edit.c
+++ b/src/ft2_edit.c
@@ -43,8 +43,10 @@
 	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,6 +90,8 @@
 {
 	int8_t i;
 
+	bool editmode = ui.patternEditorShown && (playMode == PLAYMODE_EDIT);
+
 	if (cursor.object == CURSOR_NOTE)
 	{
 		// the edit cursor is at the note slot
@@ -94,14 +98,13 @@
 
 		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 @@
 		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 @@
 	// 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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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];
--- 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...
 
--- a/src/ft2_keyboard.c
+++ b/src/ft2_keyboard.c
@@ -91,7 +91,7 @@
 		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 @@
 	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))
--