@@ -35,6 +35,14 @@ static const uint8_t funkTable[16] = // EFx (FunkRepeat/InvertLoop)
35
35
0x10 , 0x13 , 0x16 , 0x1A , 0x20 , 0x2B , 0x40 , 0x80
36
36
};
37
37
38
+ void setReplayerPosToTrackerPos (void )
39
+ {
40
+ modPattern = (int8_t )song -> currPattern ;
41
+ modOrder = song -> currOrder ;
42
+ song -> row = song -> currRow ;
43
+ song -> tick = 0 ;
44
+ }
45
+
38
46
int8_t * allocMemForAllSamples (void )
39
47
{
40
48
// allocate memory for all sample data blocks (+ 2 extra, for quirk + safety)
@@ -707,7 +715,7 @@ static void checkMoreEffects(moduleChannel_t *ch)
707
715
switch (cmd )
708
716
{
709
717
case 0x9 : sampleOffset (ch ); return ; // note the returns here, not breaks!
710
- case 0xB : positionJump (ch ); return ;
718
+ case 0xB : positionJump (ch ); return ;
711
719
case 0xD : patternBreak (ch ); return ;
712
720
case 0xE : E_Commands (ch ); return ;
713
721
case 0xF : setSpeed (ch ); return ;
@@ -1270,6 +1278,13 @@ void modStop(void)
1270
1278
posJumpAssert = false;
1271
1279
modRenderDone = true;
1272
1280
1281
+ /* The replayer is one tick ahead (unfortunately), so if the user was to stop the mod at the previous tick
1282
+ ** before a position jump (pattern loop, pattern break, position jump, row 63->0 transition, etc),
1283
+ ** it would be possible for the replayer to be at another order/pattern than the tracker.
1284
+ ** Let's set the replayer state to the tracker state on mod stop, to fix possible confusion.
1285
+ */
1286
+ setReplayerPosToTrackerPos ();
1287
+
1273
1288
doStopSong = false; // just in case this flag was stuck from command F00 (stop song)
1274
1289
}
1275
1290
@@ -1280,8 +1295,9 @@ void playPattern(int8_t startRow)
1280
1295
1281
1296
audio .tickSampleCounter64 = 0 ; // zero tick sample counter so that it will instantly initiate a tick
1282
1297
song -> currRow = song -> row = startRow & 0x3F ;
1283
- song -> tick = song -> speed ;
1284
- ciaSetBPM = -1 ;
1298
+
1299
+ song -> tick = song -> speed - 1 ;
1300
+ ciaSetBPM = -1 ; // fix possibly stuck "set BPM" flag
1285
1301
1286
1302
editor .playMode = PLAY_MODE_PATTERN ;
1287
1303
editor .currMode = MODE_PLAY ;
@@ -1323,8 +1339,6 @@ void modPlay(int16_t patt, int16_t order, int8_t row)
1323
1339
1324
1340
doStopIt (false);
1325
1341
turnOffVoices ();
1326
- audio .tickSampleCounter64 = 0 ; // zero tick sample counter so that it will instantly initiate a tick
1327
- ciaSetBPM = -1 ;
1328
1342
1329
1343
if (row != -1 )
1330
1344
{
@@ -1376,13 +1390,17 @@ void modPlay(int16_t patt, int16_t order, int8_t row)
1376
1390
editor .currMode = oldMode ;
1377
1391
1378
1392
song -> tick = song -> speed - 1 ;
1393
+ ciaSetBPM = -1 ; // fix possibly stuck "set BPM" flag
1394
+
1379
1395
modRenderDone = false;
1380
1396
editor .songPlaying = true;
1381
1397
editor .didQuantize = false;
1382
1398
1383
1399
if (editor .playMode != PLAY_MODE_PATTERN )
1384
1400
editor .musicTime64 = 0 ; // don't reset playback counter in "play/rec pattern" mode
1385
1401
1402
+ audio .tickSampleCounter64 = 0 ; // zero tick sample counter so that it will instantly initiate a tick
1403
+
1386
1404
if (audioWasntLocked )
1387
1405
unlockAudio ();
1388
1406
0 commit comments