Browse code

[NCSF] Minor code changes to reduce code duplication.

* Made a function in the Override struct to centralize where it
determines whether to use the override value or not.
* Made a function that returns the number of bytes that a command needs,
and used that to remove all the conditionals for processing a command to
instead handle that within the IF command itself.
Thanks to fincs and Henke37 for the suggestions to do this.

Naram Qashat authored on 2014/10/13 21:21:03
Showing 2 changed files
... ...
@@ -8,7 +8,6 @@
8 8
  * https://github.com/fincs/FSS
9 9
  */
10 10
 
11
-#include <functional>
12 11
 #include <cstdlib>
13 12
 #include "Track.h"
14 13
 #include "Player.h"
... ...
@@ -41,7 +40,7 @@ void Track::Zero()
41 40
 	this->stackPos = 0;
42 41
 	memset(this->loopCount, 0, sizeof(this->loopCount));
43 42
 	this->overriding() = false;
44
-	this->lastComparisonResult = this->processCommand = true;
43
+	this->lastComparisonResult = true;
45 44
 
46 45
 	this->wait = 0;
47 46
 	this->patch = 0;
... ...
@@ -320,6 +319,79 @@ enum SseqCommand
320 319
 	SSEQ_CMD_MUTE = 0xD7 // Unsupported
321 320
 };
322 321
 
322
+static const uint8_t VariableByteCount = 1 << 7;
323
+static const uint8_t ExtraByteOnNoteOrVarOrCmp = 1 << 6;
324
+
325
+static inline uint8_t SseqCommandByteCount(int cmd)
326
+{
327
+	if (cmd < 0x80)
328
+		return 1 | VariableByteCount;
329
+	else
330
+		switch (cmd)
331
+		{
332
+			case SSEQ_CMD_REST:
333
+			case SSEQ_CMD_PATCH:
334
+				return VariableByteCount;
335
+
336
+			case SSEQ_CMD_PAN:
337
+			case SSEQ_CMD_VOL:
338
+			case SSEQ_CMD_MASTERVOL:
339
+			case SSEQ_CMD_PRIO:
340
+			case SSEQ_CMD_NOTEWAIT:
341
+			case SSEQ_CMD_TIE:
342
+			case SSEQ_CMD_EXPR:
343
+			case SSEQ_CMD_LOOPSTART:
344
+			case SSEQ_CMD_TRANSPOSE:
345
+			case SSEQ_CMD_PITCHBEND:
346
+			case SSEQ_CMD_PITCHBENDRANGE:
347
+			case SSEQ_CMD_ATTACK:
348
+			case SSEQ_CMD_DECAY:
349
+			case SSEQ_CMD_SUSTAIN:
350
+			case SSEQ_CMD_RELEASE:
351
+			case SSEQ_CMD_PORTAKEY:
352
+			case SSEQ_CMD_PORTAFLAG:
353
+			case SSEQ_CMD_PORTATIME:
354
+			case SSEQ_CMD_MODDEPTH:
355
+			case SSEQ_CMD_MODSPEED:
356
+			case SSEQ_CMD_MODTYPE:
357
+			case SSEQ_CMD_MODRANGE:
358
+			case SSEQ_CMD_PRINTVAR:
359
+			case SSEQ_CMD_MUTE:
360
+				return 1;
361
+
362
+			case SSEQ_CMD_TEMPO:
363
+			case SSEQ_CMD_SWEEPPITCH:
364
+			case SSEQ_CMD_MODDELAY:
365
+				return 2;
366
+
367
+			case SSEQ_CMD_GOTO:
368
+			case SSEQ_CMD_CALL:
369
+			case SSEQ_CMD_SETVAR:
370
+			case SSEQ_CMD_ADDVAR:
371
+			case SSEQ_CMD_SUBVAR:
372
+			case SSEQ_CMD_MULVAR:
373
+			case SSEQ_CMD_DIVVAR:
374
+			case SSEQ_CMD_SHIFTVAR:
375
+			case SSEQ_CMD_RANDVAR:
376
+			case SSEQ_CMD_CMP_EQ:
377
+			case SSEQ_CMD_CMP_GE:
378
+			case SSEQ_CMD_CMP_GT:
379
+			case SSEQ_CMD_CMP_LE:
380
+			case SSEQ_CMD_CMP_LT:
381
+			case SSEQ_CMD_CMP_NE:
382
+				return 3;
383
+
384
+			case SSEQ_CMD_FROMVAR:
385
+				return 1 | ExtraByteOnNoteOrVarOrCmp; // Technically 2 bytes with an additional 1, leaving 1 off because we will be reading it to determine if the additional byte is needed
386
+
387
+			case SSEQ_CMD_RANDOM:
388
+				return 4 | ExtraByteOnNoteOrVarOrCmp; // Technically 5 bytes with an additional 1, leaving 1 off because we will be reading it to determine if the additional byte is needed
389
+
390
+			default:
391
+				return 0;
392
+		}
393
+}
394
+
323 395
 static auto varFuncSet = [](int16_t, int16_t value) { return value; };
324 396
 static auto varFuncAdd = [](int16_t var, int16_t value) -> int16_t { return var + value; };
325 397
 static auto varFuncSub = [](int16_t var, int16_t value) -> int16_t { return var - value; };
... ...
@@ -420,27 +492,14 @@ void Track::Run()
420 492
 		{
421 493
 			// Note on
422 494
 			int key = cmd + this->transpose;
423
-			int vel;
424
-			int len;
425
-			if (this->overriding())
426
-			{
427
-				vel = this->overriding.extraValue;
428
-				len = this->overriding.value;
429
-			}
495
+			int vel = this->overriding.val(pData, read8, true);
496
+			int len = this->overriding.val(pData, readvl);
497
+			if (this->state[TS_NOTEWAIT])
498
+				this->wait = len;
499
+			if (this->state[TS_TIEBIT])
500
+				this->NoteOnTie(key, vel);
430 501
 			else
431
-			{
432
-				vel = read8(pData);
433
-				len = readvl(pData);
434
-			}
435
-			if (this->processCommand)
436
-			{
437
-				if (this->state[TS_NOTEWAIT])
438
-					this->wait = len;
439
-				if (this->state[TS_TIEBIT])
440
-					this->NoteOnTie(key, vel);
441
-				else
442
-					this->NoteOn(key, vel, len);
443
-			}
502
+				this->NoteOn(key, vel, len);
444 503
 		}
445 504
 		else
446 505
 		{
... ...
@@ -452,32 +511,20 @@ void Track::Run()
452 511
 				//-----------------------------------------------------------------
453 512
 
454 513
 				case SSEQ_CMD_REST:
455
-					if (this->overriding())
456
-						value = this->overriding.value;
457
-					else
458
-						value = readvl(pData);
459
-					if (this->processCommand)
460
-						this->wait = value;
514
+					this->wait = this->overriding.val(pData, readvl);
461 515
 					break;
462 516
 
463 517
 				case SSEQ_CMD_PATCH:
464
-					if (this->overriding())
465
-						value = this->overriding.value;
466
-					else
467
-						value = readvl(pData);
468
-					if (this->processCommand)
469
-						this->patch = value;
518
+					this->patch = this->overriding.val(pData, readvl);
470 519
 					break;
471 520
 
472 521
 				case SSEQ_CMD_GOTO:
473
-					value = read24(pData);
474
-					if (this->processCommand)
475
-						*pData = &this->ply->sseq->data[value];
522
+					*pData = &this->ply->sseq->data[read24(pData)];
476 523
 					break;
477 524
 
478 525
 				case SSEQ_CMD_CALL:
479 526
 					value = read24(pData);
480
-					if (this->processCommand && this->stackPos < FSS_TRACKSTACKSIZE)
527
+					if (this->stackPos < FSS_TRACKSTACKSIZE)
481 528
 					{
482 529
 						const uint8_t *dest = &this->ply->sseq->data[value];
483 530
 						this->stack[this->stackPos++] = StackValue(STACKTYPE_CALL, *pData);
... ...
@@ -486,101 +533,56 @@ void Track::Run()
486 533
 					break;
487 534
 
488 535
 				case SSEQ_CMD_RET:
489
-					if (this->processCommand && this->stackPos && this->stack[this->stackPos - 1].type == STACKTYPE_CALL)
536
+					if (this->stackPos && this->stack[this->stackPos - 1].type == STACKTYPE_CALL)
490 537
 						*pData = this->stack[--this->stackPos].dest;
491 538
 					break;
492 539
 
493 540
 				case SSEQ_CMD_PAN:
494
-					if (this->overriding())
495
-						value = this->overriding.value;
496
-					else
497
-						value = read8(pData);
498
-					if (this->processCommand)
499
-					{
500
-						this->pan = value - 64;
501
-						this->updateFlags.set(TUF_PAN);
502
-					}
541
+					this->pan = this->overriding.val(pData, read8) - 64;
542
+					this->updateFlags.set(TUF_PAN);
503 543
 					break;
504 544
 
505 545
 				case SSEQ_CMD_VOL:
506
-					if (this->overriding())
507
-						value = this->overriding.value;
508
-					else
509
-						value = read8(pData);
510
-					if (this->processCommand)
511
-					{
512
-						this->vol = value;
513
-						this->updateFlags.set(TUF_VOL);
514
-					}
546
+					this->vol = this->overriding.val(pData, read8);
547
+					this->updateFlags.set(TUF_VOL);
515 548
 					break;
516 549
 
517 550
 				case SSEQ_CMD_MASTERVOL:
518
-					if (this->overriding())
519
-						value = this->overriding.value;
520
-					else
521
-						value = read8(pData);
522
-					if (this->processCommand)
523
-					{
524
-						this->ply->masterVol = Cnv_Sust(value);
525
-						for (uint8_t i = 0; i < this->ply->nTracks; ++i)
526
-							this->ply->tracks[this->ply->trackIds[i]].updateFlags.set(TUF_VOL);
527
-					}
551
+					this->ply->masterVol = Cnv_Sust(this->overriding.val(pData, read8));
552
+					for (uint8_t i = 0; i < this->ply->nTracks; ++i)
553
+						this->ply->tracks[this->ply->trackIds[i]].updateFlags.set(TUF_VOL);
528 554
 					break;
529 555
 
530 556
 				case SSEQ_CMD_PRIO:
531
-					value = read8(pData);
532
-					if (this->processCommand)
533
-						this->prio = this->ply->prio + value;
557
+					this->prio = this->ply->prio + read8(pData);
534 558
 					// Update here?
535 559
 					break;
536 560
 
537 561
 				case SSEQ_CMD_NOTEWAIT:
538
-					value = read8(pData);
539
-					if (this->processCommand)
540
-						this->state.set(TS_NOTEWAIT, !!value);
562
+					this->state.set(TS_NOTEWAIT, !!read8(pData));
541 563
 					break;
542 564
 
543 565
 				case SSEQ_CMD_TIE:
544
-					value = read8(pData);
545
-					if (this->processCommand)
546
-					{
547
-						this->state.set(TS_TIEBIT, !!value);
548
-						this->ReleaseAllNotes();
549
-					}
566
+					this->state.set(TS_TIEBIT, !!read8(pData));
567
+					this->ReleaseAllNotes();
550 568
 					break;
551 569
 
552 570
 				case SSEQ_CMD_EXPR:
553
-					if (this->overriding())
554
-						value = this->overriding.value;
555
-					else
556
-						value = read8(pData);
557
-					if (this->processCommand)
558
-					{
559
-						this->expr = value;
560
-						this->updateFlags.set(TUF_VOL);
561
-					}
571
+					this->expr = this->overriding.val(pData, read8);
572
+					this->updateFlags.set(TUF_VOL);
562 573
 					break;
563 574
 
564 575
 				case SSEQ_CMD_TEMPO:
565
-					value = read16(pData);
566
-					if (this->processCommand)
567
-						this->ply->tempo = value;
576
+					this->ply->tempo = read16(pData);
568 577
 					break;
569 578
 
570 579
 				case SSEQ_CMD_END:
571
-					if (this->processCommand)
572
-					{
573
-						this->state.set(TS_END);
574
-						return;
575
-					}
576
-					break;
580
+					this->state.set(TS_END);
581
+					return;
577 582
 
578 583
 				case SSEQ_CMD_LOOPSTART:
579
-					if (this->overriding())
580
-						value = this->overriding.value;
581
-					else
582
-						value = read8(pData);
583
-					if (this->processCommand && this->stackPos < FSS_TRACKSTACKSIZE)
584
+					value = this->overriding.val(pData, read8);
585
+					if (this->stackPos < FSS_TRACKSTACKSIZE)
584 586
 					{
585 587
 						this->loopCount[this->stackPos] = value;
586 588
 						this->stack[this->stackPos++] = StackValue(STACKTYPE_LOOP, *pData);
... ...
@@ -588,7 +590,7 @@ void Track::Run()
588 590
 					break;
589 591
 
590 592
 				case SSEQ_CMD_LOOPEND:
591
-					if (this->processCommand && this->stackPos && this->stack[this->stackPos - 1].type == STACKTYPE_LOOP)
593
+					if (this->stackPos && this->stack[this->stackPos - 1].type == STACKTYPE_LOOP)
592 594
 					{
593 595
 						const uint8_t *rPos = this->stack[this->stackPos - 1].dest;
594 596
 						uint8_t &nR = this->loopCount[this->stackPos - 1];
... ...
@@ -610,33 +612,17 @@ void Track::Run()
610 612
 				//-----------------------------------------------------------------
611 613
 
612 614
 				case SSEQ_CMD_TRANSPOSE:
613
-					if (this->overriding())
614
-						value = this->overriding.value;
615
-					else
616
-						value = read8(pData);
617
-					if (this->processCommand)
618
-						this->transpose = value;
615
+					this->transpose = this->overriding.val(pData, read8);
619 616
 					break;
620 617
 
621 618
 				case SSEQ_CMD_PITCHBEND:
622
-					if (this->overriding())
623
-						value = this->overriding.value;
624
-					else
625
-						value = read8(pData);
626
-					if (this->processCommand)
627
-					{
628
-						this->pitchBend = value;
629
-						this->updateFlags.set(TUF_TIMER);
630
-					}
619
+					this->pitchBend = this->overriding.val(pData, read8);
620
+					this->updateFlags.set(TUF_TIMER);
631 621
 					break;
632 622
 
633 623
 				case SSEQ_CMD_PITCHBENDRANGE:
634
-					value = read8(pData);
635
-					if (this->processCommand)
636
-					{
637
-						this->pitchBendRange = value;
638
-						this->updateFlags.set(TUF_TIMER);
639
-					}
624
+					this->pitchBendRange = read8(pData);
625
+					this->updateFlags.set(TUF_TIMER);
640 626
 					break;
641 627
 
642 628
 				//-----------------------------------------------------------------
... ...
@@ -644,39 +630,19 @@ void Track::Run()
644 630
 				//-----------------------------------------------------------------
645 631
 
646 632
 				case SSEQ_CMD_ATTACK:
647
-					if (this->overriding())
648
-						value = this->overriding.value;
649
-					else
650
-						value = read8(pData);
651
-					if (this->processCommand)
652
-						this->a = value;
633
+					this->a = this->overriding.val(pData, read8);
653 634
 					break;
654 635
 
655 636
 				case SSEQ_CMD_DECAY:
656
-					if (this->overriding())
657
-						value = this->overriding.value;
658
-					else
659
-						value = read8(pData);
660
-					if (this->processCommand)
661
-						this->d = value;
637
+					this->d = this->overriding.val(pData, read8);
662 638
 					break;
663 639
 
664 640
 				case SSEQ_CMD_SUSTAIN:
665
-					if (this->overriding())
666
-						value = this->overriding.value;
667
-					else
668
-						value = read8(pData);
669
-					if (this->processCommand)
670
-						this->s = value;
641
+					this->s = this->overriding.val(pData, read8);
671 642
 					break;
672 643
 
673 644
 				case SSEQ_CMD_RELEASE:
674
-					if (this->overriding())
675
-						value = this->overriding.value;
676
-					else
677
-						value = read8(pData);
678
-					if (this->processCommand)
679
-						this->r = value;
645
+					this->r = this->overriding.val(pData, read8);
680 646
 					break;
681 647
 
682 648
 				//-----------------------------------------------------------------
... ...
@@ -684,41 +650,23 @@ void Track::Run()
684 650
 				//-----------------------------------------------------------------
685 651
 
686 652
 				case SSEQ_CMD_PORTAKEY:
687
-					value = read8(pData);
688
-					if (this->processCommand)
689
-					{
690
-						this->portaKey = value + this->transpose;
691
-						this->state.set(TS_PORTABIT);
692
-						// Update here?
693
-					}
653
+					this->portaKey = read8(pData) + this->transpose;
654
+					this->state.set(TS_PORTABIT);
655
+					// Update here?
694 656
 					break;
695 657
 
696 658
 				case SSEQ_CMD_PORTAFLAG:
697
-					value = read8(pData);
698
-					if (this->processCommand)
699
-					{
700
-						this->state.set(TS_PORTABIT, !!value);
701
-						// Update here?
702
-					}
659
+					this->state.set(TS_PORTABIT, !!read8(pData));
660
+					// Update here?
703 661
 					break;
704 662
 
705 663
 				case SSEQ_CMD_PORTATIME:
706
-					if (this->overriding())
707
-						value = this->overriding.value;
708
-					else
709
-						value = read8(pData);
710
-					if (this->processCommand)
711
-						this->portaTime = value;
664
+					this->portaTime = this->overriding.val(pData, read8);
712 665
 					// Update here?
713 666
 					break;
714 667
 
715 668
 				case SSEQ_CMD_SWEEPPITCH:
716
-					if (this->overriding())
717
-						value = this->overriding.value;
718
-					else
719
-						value = read16(pData);
720
-					if (this->processCommand)
721
-						this->sweepPitch = value;
669
+					this->sweepPitch = this->overriding.val(pData, read16);
722 670
 					// Update here?
723 671
 					break;
724 672
 
... ...
@@ -727,57 +675,28 @@ void Track::Run()
727 675
 				//-----------------------------------------------------------------
728 676
 
729 677
 				case SSEQ_CMD_MODDEPTH:
730
-					if (this->overriding())
731
-						value = this->overriding.value;
732
-					else
733
-						value = read8(pData);
734
-					if (this->processCommand)
735
-					{
736
-						this->modDepth = value;
737
-						this->updateFlags.set(TUF_MOD);
738
-					}
678
+					this->modDepth = this->overriding.val(pData, read8);
679
+					this->updateFlags.set(TUF_MOD);
739 680
 					break;
740 681
 
741 682
 				case SSEQ_CMD_MODSPEED:
742
-					if (this->overriding())
743
-						value = this->overriding.value;
744
-					else
745
-						value = read8(pData);
746
-					if (this->processCommand)
747
-					{
748
-						this->modSpeed = value;
749
-						this->updateFlags.set(TUF_MOD);
750
-					}
683
+					this->modSpeed = this->overriding.val(pData, read8);
684
+					this->updateFlags.set(TUF_MOD);
751 685
 					break;
752 686
 
753 687
 				case SSEQ_CMD_MODTYPE:
754
-					value = read8(pData);
755
-					if (this->processCommand)
756
-					{
757
-						this->modType = value;
758
-						this->updateFlags.set(TUF_MOD);
759
-					}
688
+					this->modType = read8(pData);
689
+					this->updateFlags.set(TUF_MOD);
760 690
 					break;
761 691
 
762 692
 				case SSEQ_CMD_MODRANGE:
763
-					value = read8(pData);
764
-					if (this->processCommand)
765
-					{
766
-						this->modRange = value;
767
-						this->updateFlags.set(TUF_MOD);
768
-					}
693
+					this->modRange = read8(pData);
694
+					this->updateFlags.set(TUF_MOD);
769 695
 					break;
770 696
 
771 697
 				case SSEQ_CMD_MODDELAY:
772
-					if (this->overriding())
773
-						value = this->overriding.value;
774
-					else
775
-						value = read16(pData);
776
-					if (this->processCommand)
777
-					{
778
-						this->modDelay = value;
779
-						this->updateFlags.set(TUF_MOD);
780
-					}
698
+					this->modDelay = this->overriding.val(pData, read16);
699
+					this->updateFlags.set(TUF_MOD);
781 700
 					break;
782 701
 
783 702
 				//-----------------------------------------------------------------
... ...
@@ -786,8 +705,7 @@ void Track::Run()
786 705
 
787 706
 				case SSEQ_CMD_RANDOM:
788 707
 				{
789
-					if (this->processCommand)
790
-						this->overriding() = true;
708
+					this->overriding() = true;
791 709
 					this->overriding.cmd = read8(pData);
792 710
 					if ((this->overriding.cmd >= SSEQ_CMD_SETVAR && this->overriding.cmd <= SSEQ_CMD_CMP_NE) || this->overriding.cmd < 0x80)
793 711
 						this->overriding.extraValue = read8(pData);
... ...
@@ -802,8 +720,7 @@ void Track::Run()
802 720
 				//-----------------------------------------------------------------
803 721
 
804 722
 				case SSEQ_CMD_FROMVAR:
805
-					if (this->processCommand)
806
-						this->overriding() = true;
723
+					this->overriding() = true;
807 724
 					this->overriding.cmd = read8(pData);
808 725
 					if ((this->overriding.cmd >= SSEQ_CMD_SETVAR && this->overriding.cmd <= SSEQ_CMD_CMP_NE) || this->overriding.cmd < 0x80)
809 726
 						this->overriding.extraValue = read8(pData);
... ...
@@ -818,21 +735,11 @@ void Track::Run()
818 735
 				case SSEQ_CMD_SHIFTVAR:
819 736
 				case SSEQ_CMD_RANDVAR:
820 737
 				{
821
-					int8_t varNo;
822
-					if (this->overriding())
823
-					{
824
-						varNo = this->overriding.extraValue;
825
-						value = this->overriding.value;
826
-					}
827
-					else
828
-					{
829
-						varNo = read8(pData);
830
-						value = read16(pData);
831
-					}
738
+					int8_t varNo = this->overriding.val(pData, read8, true);
739
+					value = this->overriding.val(pData, read16);
832 740
 					if (cmd == SSEQ_CMD_DIVVAR && !value) // Division by 0, skip it to prevent crashing
833 741
 						break;
834
-					if (this->processCommand)
835
-						this->ply->variables[varNo] = VarFunc(cmd)(this->ply->variables[varNo], value);
742
+					this->ply->variables[varNo] = VarFunc(cmd)(this->ply->variables[varNo], value);
836 743
 					break;
837 744
 				}
838 745
 
... ...
@@ -847,38 +754,38 @@ void Track::Run()
847 754
 				case SSEQ_CMD_CMP_LT:
848 755
 				case SSEQ_CMD_CMP_NE:
849 756
 				{
850
-					int8_t varNo;
851
-					if (this->overriding())
852
-					{
853
-						varNo = this->overriding.extraValue;
854
-						value = this->overriding.value;
855
-					}
856
-					else
857
-					{
858
-						varNo = read8(pData);
859
-						value = read16(pData);
860
-					}
861
-					if (this->processCommand)
862
-						this->lastComparisonResult = CompareFunc(cmd)(this->ply->variables[varNo], value);
757
+					int8_t varNo = this->overriding.val(pData, read8, true);
758
+					value = this->overriding.val(pData, read16);
759
+					this->lastComparisonResult = CompareFunc(cmd)(this->ply->variables[varNo], value);
863 760
 					break;
864 761
 				}
865 762
 
866 763
 				case SSEQ_CMD_IF:
867
-					this->processCommand = this->lastComparisonResult;
868
-					break;
869
-
870
-				case SSEQ_CMD_PRINTVAR:
871
-					++*pData;
764
+					if (!this->lastComparisonResult)
765
+					{
766
+						int nextCmd = read8(pData);
767
+						uint8_t cmdBytes = SseqCommandByteCount(nextCmd);
768
+						bool variableBytes = !!(cmdBytes & VariableByteCount);
769
+						bool extraByte = !!(cmdBytes & ExtraByteOnNoteOrVarOrCmp);
770
+						cmdBytes &= ~(VariableByteCount | ExtraByteOnNoteOrVarOrCmp);
771
+						if (extraByte)
772
+						{
773
+							int extraCmd = read8(pData);
774
+							if ((extraCmd >= SSEQ_CMD_SETVAR && extraCmd <= SSEQ_CMD_CMP_NE) || extraCmd < 0x80)
775
+								++cmdBytes;
776
+						}
777
+						*pData += cmdBytes;
778
+						if (variableBytes)
779
+							readvl(pData);
780
+					}
872 781
 					break;
873 782
 
874
-				case SSEQ_CMD_MUTE: // UNSUPPORTED
875
-					++*pData;
783
+				default:
784
+					*pData += SseqCommandByteCount(cmd);
876 785
 			}
877 786
 		}
878 787
 
879 788
 		if (cmd != SSEQ_CMD_RANDOM && cmd != SSEQ_CMD_FROMVAR)
880 789
 			this->overriding() = false;
881
-		if (cmd != SSEQ_CMD_IF)
882
-			this->processCommand = true;
883 790
 	}
884 791
 }
... ...
@@ -10,6 +10,7 @@
10 10
 
11 11
 #pragma once
12 12
 
13
+#include <functional>
13 14
 #include <bitset>
14 15
 #include "consts.h"
15 16
 
... ...
@@ -40,6 +41,13 @@ struct Override
40 41
 	Override() : overriding(false) { }
41 42
 	bool operator()() const { return this->overriding; }
42 43
 	bool &operator()() { return this->overriding; }
44
+	int val(const uint8_t **pData, std::function<int (const uint8_t **)> reader, bool returnExtra = false)
45
+	{
46
+		if (this->overriding)
47
+			return returnExtra ? this->extraValue : this->value;
48
+		else
49
+			return reader(pData);
50
+	}
43 51
 };
44 52
 
45 53
 struct Track
... ...
@@ -57,7 +65,6 @@ struct Track
57 65
 	uint8_t loopCount[FSS_TRACKSTACKSIZE];
58 66
 	Override overriding;
59 67
 	bool lastComparisonResult;
60
-	bool processCommand;
61 68
 
62 69
 	int wait;
63 70
 	uint16_t patch;