shithub: pt2-clone

Download patch

ref: 5aec5052b1d25d7878757d3b32c2165183090dbc
parent: 060ef365fa2b0816f349f4b5616a5ec277929c1a
author: Olav Sørensen <olav.sorensen@live.no>
date: Sat Apr 9 08:20:20 EDT 2022

Config entry for keeping edit mode after step-play

--- a/release/macos/protracker.ini
+++ b/release/macos/protracker.ini
@@ -101,6 +101,14 @@
 HWMOUSE=TRUE
 
 [GENERAL SETTINGS]
+; "Edit mode" + step-play (return/backspace) behavior
+;        Syntax: TRUE or FALSE
+; Default value: FALSE
+;       Comment: If set to true and you use step-play in edit mode, then
+;         edit mode will be kept when the step-play is done.
+;
+STEPPLAY_KEEP_EDITMODE=FALSE
+
 ; Don't show downsample dialog after loading a sample whose frequency is >22kHz.
 ;        Syntax: TRUE or FALSE
 ; Default value: FALSE
--- a/release/other/protracker.ini
+++ b/release/other/protracker.ini
@@ -101,6 +101,14 @@
 HWMOUSE=TRUE
 
 [GENERAL SETTINGS]
+; "Edit mode" + step-play (return/backspace) behavior
+;        Syntax: TRUE or FALSE
+; Default value: FALSE
+;       Comment: If set to true and you use step-play in edit mode, then
+;         edit mode will be kept when the step-play is done.
+;
+STEPPLAY_KEEP_EDITMODE=FALSE
+
 ; Don't show downsample dialog after loading a sample whose frequency is >22kHz.
 ;        Syntax: TRUE or FALSE
 ; Default value: FALSE
--- a/release/win32/protracker.ini
+++ b/release/win32/protracker.ini
@@ -101,6 +101,14 @@
 HWMOUSE=TRUE
 
 [GENERAL SETTINGS]
+; "Edit mode" + step-play (return/backspace) behavior
+;        Syntax: TRUE or FALSE
+; Default value: FALSE
+;       Comment: If set to true and you use step-play in edit mode, then
+;         edit mode will be kept when the step-play is done.
+;
+STEPPLAY_KEEP_EDITMODE=FALSE
+
 ; Don't show downsample dialog after loading a sample whose frequency is >22kHz.
 ;        Syntax: TRUE or FALSE
 ; Default value: FALSE
--- a/release/win64/protracker.ini
+++ b/release/win64/protracker.ini
@@ -101,6 +101,14 @@
 HWMOUSE=TRUE
 
 [GENERAL SETTINGS]
+; "Edit mode" + step-play (return/backspace) behavior
+;        Syntax: TRUE or FALSE
+; Default value: FALSE
+;       Comment: If set to true and you use step-play in edit mode, then
+;         edit mode will be kept when the step-play is done.
+;
+STEPPLAY_KEEP_EDITMODE=FALSE
+
 ; Don't show downsample dialog after loading a sample whose frequency is >22kHz.
 ;        Syntax: TRUE or FALSE
 ; Default value: FALSE
--- a/src/pt2_config.c
+++ b/src/pt2_config.c
@@ -67,6 +67,7 @@
 	config.pixelFilter = PIXELFILTER_NEAREST;
 	config.integerScaling = true;
 	config.audioInputFrequency = 44100;
+	config.keepEditModeAfterStepPlay = false;
 
 	config.maxSampleLength = 65534;
 	config.reservedSampleOffset = (MOD_SAMPLES+1) * config.maxSampleLength;
@@ -195,6 +196,15 @@
 		{
 			configLine = strtok(NULL, "\n");
 			continue;
+		}
+
+		// STEPPLAY_KEEP_EDITMODE
+		else if (!_strnicmp(configLine, "STEPPLAY_KEEP_EDITMODE=", 23))
+		{
+			if (!_strnicmp(&configLine[23], "TRUE", 4))
+				config.keepEditModeAfterStepPlay = true;
+			else if (!_strnicmp(&configLine[23], "FALSE", 5))
+				config.keepEditModeAfterStepPlay = false;
 		}
 
 		// 64K_LIMIT
--- a/src/pt2_config.h
+++ b/src/pt2_config.h
@@ -15,7 +15,7 @@
 	char *defModulesDir, *defSamplesDir;
 	bool waveformCenterLine, pattDots, compoMode, autoCloseDiskOp, hideDiskOpDates, hwMouse;
 	bool transDel, fullScreenStretch, vsyncOff, modDot, blankZeroFlag, realVuMeters, rememberPlayMode;
-	bool startInFullscreen, integerScaling, disableE8xEffect, noDownsampleOnSmpLoad;
+	bool startInFullscreen, integerScaling, disableE8xEffect, noDownsampleOnSmpLoad, keepEditModeAfterStepPlay;
 	int8_t stereoSeparation, videoScaleFactor, accidental;
 	uint8_t pixelFilter, filterModel;
 	uint16_t quantizeValue;
--- a/src/pt2_header.h
+++ b/src/pt2_header.h
@@ -14,7 +14,7 @@
 #include "pt2_unicode.h"
 #include "pt2_palette.h"
 
-#define PROG_VER_STR "1.45"
+#define PROG_VER_STR "1.46"
 
 #ifdef _WIN32
 #define DIR_DELIMITER '\\'
--- a/src/pt2_keyboard.c
+++ b/src/pt2_keyboard.c
@@ -816,8 +816,21 @@
 					editor.stepPlayEnabled = true;
 					editor.stepPlayBackwards = false;
 
-					doStopIt(true);
+					editor.stepPlayLastMode = editor.currMode;
+
+					if (config.keepEditModeAfterStepPlay && editor.stepPlayLastMode == MODE_EDIT)
+						doStopIt(false);
+					else
+						doStopIt(true);
+
 					playPattern(song->currRow);
+
+					if (config.keepEditModeAfterStepPlay && editor.stepPlayLastMode == MODE_EDIT)
+					{
+						pointerSetMode(POINTER_MODE_EDIT, DO_CARRY);
+						editor.playMode = PLAY_MODE_NORMAL;
+						editor.currMode = MODE_EDIT;
+					}
 				}
 			}
 		}
@@ -4334,8 +4347,21 @@
 					editor.stepPlayEnabled = true;
 					editor.stepPlayBackwards = true;
 
-					doStopIt(true);
+					editor.stepPlayLastMode = editor.currMode;
+
+					if (config.keepEditModeAfterStepPlay && editor.stepPlayLastMode == MODE_EDIT)
+						doStopIt(false);
+					else
+						doStopIt(true);
+
 					playPattern((song->currRow - 1) & 0x3F);
+
+					if (config.keepEditModeAfterStepPlay && editor.stepPlayLastMode == MODE_EDIT)
+					{
+						pointerSetMode(POINTER_MODE_EDIT, DO_CARRY);
+						editor.playMode = PLAY_MODE_NORMAL;
+						editor.currMode = MODE_EDIT;
+					}
 				}
 			}
 		}
--- a/src/pt2_replayer.c
+++ b/src/pt2_replayer.c
@@ -964,12 +964,34 @@
 	{
 		if (editor.stepPlayEnabled)
 		{
-			doStopIt(true);
+			if (config.keepEditModeAfterStepPlay && editor.stepPlayLastMode == MODE_EDIT)
+			{
+				doStopIt(false);
 
+				pointerSetMode(POINTER_MODE_EDIT, DO_CARRY);
+				editor.playMode = PLAY_MODE_NORMAL;
+				editor.currMode = MODE_EDIT;
+			}
+			else
+			{
+				doStopIt(true);
+			}
+
 			editor.stepPlayEnabled = false;
 			editor.stepPlayBackwards = false;
 
-			song->currRow = song->row;
+			if (editor.stepPlayLastMode == MODE_EDIT || editor.stepPlayLastMode == MODE_IDLE)
+			{
+				song->row &= 0x3F;
+				song->currRow = song->row;
+			}
+			else
+			{
+				// if we were playing, set replayer row to tracker row (stay in sync)
+				song->currRow &= 0x3F;
+				song->row = song->currRow;
+			}
+
 			return;
 		}
 
@@ -1120,9 +1142,31 @@
 		// step-play handling
 		if (editor.stepPlayEnabled)
 		{
-			doStopIt(true);
+			if (config.keepEditModeAfterStepPlay && editor.stepPlayLastMode == MODE_EDIT)
+			{
+				doStopIt(false);
 
-			song->currRow = song->row & 0x3F;
+				pointerSetMode(POINTER_MODE_EDIT, DO_CARRY);
+				editor.playMode = PLAY_MODE_NORMAL;
+				editor.currMode = MODE_EDIT;
+			}
+			else
+			{
+				doStopIt(true);
+			}
+
+			if (editor.stepPlayLastMode == MODE_EDIT || editor.stepPlayLastMode == MODE_IDLE)
+			{
+				song->row &= 0x3F;
+				song->currRow = song->row;
+			}
+			else
+			{
+				// if we were playing, set replayer row to tracker row (stay in sync)
+				song->currRow &= 0x3F;
+				song->row = song->currRow;
+			}
+
 			editor.stepPlayEnabled = false;
 			editor.stepPlayBackwards = false;
 
--- a/src/pt2_structs.h
+++ b/src/pt2_structs.h
@@ -169,7 +169,7 @@
 
 	int8_t smpRedoFinetunes[MOD_SAMPLES], smpRedoVolumes[MOD_SAMPLES], multiModeNext[4], trackPattFlag;
 	int8_t *smpRedoBuffer[MOD_SAMPLES], *tempSample, currSample, recordMode, sampleFrom, sampleTo, autoInsSlot;
-	int8_t hiLowInstr, note1, note2, note3, note4, oldNote1, oldNote2, oldNote3, oldNote4;
+	int8_t hiLowInstr, note1, note2, note3, note4, oldNote1, oldNote2, oldNote3, oldNote4, stepPlayLastMode;
 	uint8_t playMode, currMode, tuningChan, tuningVol, errorMsgCounter, buffFromPos, buffToPos;
 	uint8_t blockFromPos, blockToPos, timingMode, f6Pos, f7Pos, f8Pos, f9Pos, f10Pos, keyOctave, pNoteFlag;
 	uint8_t tuningNote, resampleNote, initialTempo, initialSpeed, editMoveAdd;
--- a/vs2019_project/pt2-clone/protracker.ini
+++ b/vs2019_project/pt2-clone/protracker.ini
@@ -101,6 +101,14 @@
 HWMOUSE=TRUE
 
 [GENERAL SETTINGS]
+; "Edit mode" + step-play (return/backspace) behavior
+;        Syntax: TRUE or FALSE
+; Default value: FALSE
+;       Comment: If set to true and you use step-play in edit mode, then
+;         edit mode will be kept when the step-play is done.
+;
+STEPPLAY_KEEP_EDITMODE=FALSE
+
 ; Don't show downsample dialog after loading a sample whose frequency is >22kHz.
 ;        Syntax: TRUE or FALSE
 ; Default value: FALSE