shithub: ft²

Download patch

ref: 7ddfd10a646f7ad195a2fe447f65f0572471f545
parent: fbb1532692e9b723dbdf40cb60a0c153342855d4
author: Olav Sørensen <olav.sorensen@live.no>
date: Mon Jan 8 14:24:31 EST 2024

Fix block mark issues on selection inside last track

--- a/src/ft2_edit.c
+++ b/src/ft2_edit.c
@@ -931,12 +931,15 @@
 			if (markY1 == markY2 || markY1 > markY2)
 				return 0;
 
-			if (markX1 >= song.numChannels-1)
-				markX1 = song.numChannels-2;
+			if (markX1 > song.numChannels-1)
+				markX1 = song.numChannels-1;
 
-			if (markX2 >= song.numChannels)
-				markX2 = (song.numChannels-1)-markX1;
+			if (markX2 > song.numChannels-1)
+				markX2 = song.numChannels-1;
 
+			if (markX2 < markX1)
+				markX2 = markX1;
+
 			if (markY1 >= numRows)
 				markY1 = numRows-1;
 
@@ -1075,12 +1078,15 @@
 			if (markY1 == markY2 || markY1 > markY2)
 				return;
 
-			if (markX1 >= song.numChannels-1)
-				markX1 = song.numChannels-2;
+			if (markX1 > song.numChannels-1)
+				markX1 = song.numChannels-1;
 
-			if (markX2 >= song.numChannels)
-				markX2 = (song.numChannels-1)-markX1;
+			if (markX2 > song.numChannels-1)
+				markX2 = song.numChannels-1;
 
+			if (markX2 < markX1)
+				markX2 = markX1;
+
 			if (markY1 >= numRows)
 				markY1 = numRows-1;
 
@@ -1503,12 +1509,15 @@
 	if (markY1 == markY2 || markY1 > markY2)
 		return;
 
-	if (markX1 >= song.numChannels-1)
-		markX1 = song.numChannels-2;
+	if (markX1 > song.numChannels-1)
+		markX1 = song.numChannels-1;
 
-	if (markX2 >= song.numChannels)
-		markX2 = (song.numChannels-1)-markX1;
+	if (markX2 > song.numChannels-1)
+		markX2 = song.numChannels-1;
 
+	if (markX2 < markX1)
+		markX2 = markX1;
+
 	if (markY1 >= numRows)
 		markY1 = numRows-1;
 
@@ -1562,12 +1571,15 @@
 	if (markY1 == markY2 || markY1 > markY2)
 		return;
 
-	if (markX1 >= song.numChannels-1)
-		markX1 = song.numChannels-2;
+	if (markX1 > song.numChannels-1)
+		markX1 = song.numChannels-1;
 
-	if (markX2 >= song.numChannels)
-		markX2 = (song.numChannels-1)-markX1;
+	if (markX2 > song.numChannels-1)
+		markX2 = song.numChannels-1;
 
+	if (markX2 < markX1)
+		markX2 = markX1;
+
 	if (markY1 >= numRows)
 		markY1 = numRows-1;
 
@@ -1642,11 +1654,14 @@
 	if (pattPtr == NULL)
 		return;
 
-	if (x1 >= song.numChannels-1)
-		x1 = song.numChannels-2;
+	if (x1 > song.numChannels-1)
+		x1 = song.numChannels-1;
 
-	if (x2 >= song.numChannels)
-		x2 = (song.numChannels-1)-x1;
+	if (x2 > song.numChannels-1)
+		x2 = song.numChannels-1;
+
+	if (x2 < x1)
+		x2 = x1;
 
 	const int16_t numRows = patternNumRows[pattNum];
 	if (y1 >= numRows)
--- a/src/ft2_header.h
+++ b/src/ft2_header.h
@@ -12,7 +12,7 @@
 #endif
 #include "ft2_replayer.h"
 
-#define PROG_VER_STR "1.74"
+#define PROG_VER_STR "1.75"
 
 // do NOT change these! It will only mess things up...