shithub: pt2-clone

Download patch

ref: c131e839c1cea8f9fe2931535a1efeb678d4733e
parent: fd5d4165735a0881ef0ccb9e52f22fb0f4f1bcc4
author: Olav Sørensen <olav.sorensen@live.no>
date: Sun Oct 10 18:41:42 EDT 2021

Pushed v1.36 code

- Fixed clicking issues in v1.35 during sample looping. Sorry!
- Fixed an issue where the quadrascope was not updated properly when a F00 command was triggered before the last channel

--- a/src/pt2_audio.c
+++ b/src/pt2_audio.c
@@ -366,8 +366,13 @@
 	v->location = v->AUD_LC;
 	v->lengthCounter = v->AUD_LEN;
 
-	v->dSample = 0.0;
-	v->sampleCounter = 0; // read new DMA data samples ASAP
+	// pre-fill AUDxDAT buffer
+	v->AUD_DAT[0] = *v->location++;
+	v->AUD_DAT[1] = *v->location++;
+	v->sampleCounter = 2;
+
+	// set current sample point
+	v->dSample = v->AUD_DAT[0] * v->AUD_VOL;
 
 	// set BLEP stuff
 	v->dLastPhase = 0.0;
--- a/src/pt2_audio.h
+++ b/src/pt2_audio.h
@@ -40,8 +40,10 @@
 	double AUD_PER_delta; // delta
 	double AUD_VOL; // volume
 
-	double dBlepOffset, dDelta, dPhase, dLastDelta, dLastPhase;
-	double dScaledVolume, dDeltaMul;
+	double dDelta, dPhase;
+
+	// for BLEP synthesis
+	double dLastDelta, dLastPhase, dBlepOffset, dDeltaMul;
 
 	// period cache
 	int32_t oldPeriod;
--- 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.35"
+#define PROG_VER_STR "1.36"
 
 #ifdef _WIN32
 #define DIR_DELIMITER '\\'
--- a/src/pt2_replayer.c
+++ b/src/pt2_replayer.c
@@ -23,6 +23,7 @@
 #include "pt2_sync.h"
 
 static bool posJumpAssert, pBreakFlag, modRenderDone;
+static bool doStopSong; // from F00 (Set Speed)
 static int8_t pBreakPosition, oldRow, modPattern;
 static uint8_t pattDelTime, lowMask = 0xFF, pattDelTime2;
 static int16_t modOrder, oldPattern, oldOrder;
@@ -88,6 +89,8 @@
 			c->n_loopcount = 0;
 		}
 	}
+
+	doStopSong = false; // just in case this flag was stuck from command F00 (stop song)
 }
 
 void setPattern(int16_t pattern)
@@ -364,12 +367,7 @@
 	else
 	{
 		// F00 - stop song
-
-		editor.songPlaying = false;
-		editor.playMode = PLAY_MODE_NORMAL;
-		editor.currMode = MODE_IDLE;
-
-		pointerResetThreadSafe(); // set normal gray mouse pointer
+		doStopSong = true;
 	}
 }
 
@@ -1149,6 +1147,18 @@
 			nextPosition();
 	}
 
+	// command F00 = stop song, do it here (so that the scopes are updated properly)
+	if (doStopSong)
+	{
+		doStopSong = false;
+
+		editor.songPlaying = false;
+		editor.playMode = PLAY_MODE_NORMAL;
+		editor.currMode = MODE_IDLE;
+
+		pointerResetThreadSafe(); // set normal gray mouse pointer
+	}
+
 	return renderEndCheck(); // MOD2WAV/PAT2SMP listens to the return value (true = not done yet)
 }
 
@@ -1270,6 +1280,8 @@
 	pBreakPosition = 0;
 	posJumpAssert = false;
 	modRenderDone = true;
+
+	doStopSong = false; // just in case this flag was stuck from command F00 (stop song)
 }
 
 void playPattern(int8_t startRow)