board-package-source/libraries/ArduboyPlaytune/src/ArduboyPlaytune.cpp
/* Do score commands until a "wait" is found, or the score is stopped.
This is called initially from playScore(), but then is called
from the interrupt routine when waits expire.

If CMD < 0x80, then the other 7 bits and the next byte are a
15-bit big-endian number of msec to wait
*/
Do score commands until a "wait" is found, or the score is stopped.
This is called initially from playScore(), but then is called
from the interrupt routine when waits expire.

If CMD < 0x80, then the other 7 bits and the next byte are a
15-bit big-endian number of msec to wait
Do score commands until a " wait " is found or the score is stopped . This is called initially from playScore () but then is called from the interrupt routine when waits expire . If CMD < 0x80 then the other 7 bits and the next byte are a 15 - bit big - endian number of msec to wait
void ArduboyPlaytune::step()
{
  byte command, opcode, chan;
  unsigned duration;
  while (1) {
    command = pgm_read_byte(score_cursor++);
    opcode = command & 0xf0;
    chan = command & 0x0f;
    if (opcode == TUNE_OP_STOPNOTE) { 
      stopNote(chan);
    }
    else if (opcode == TUNE_OP_PLAYNOTE) { 
      all_muted = !outputEnabled();
      playNote(chan, pgm_read_byte(score_cursor++));
    }
    else if (opcode < 0x80) { 
      duration = ((unsigned)command << 8) | (pgm_read_byte(score_cursor++));
      wait_toggle_count = ((unsigned long) wait_timer_frequency2 * duration + 500) / 1000;
      if (wait_toggle_count == 0) wait_toggle_count = 1;
      break;
    }
    else if (opcode == TUNE_OP_RESTART) { 
      score_cursor = score_start;
    }
    else if (opcode == TUNE_OP_STOP) { 
      tune_playing = false;
      break;
    }
  }
}
void ArduboyPlaytune :: step ( ) { byte command , opcode , chan ; unsigned duration ; while ( 1 ) { command = pgm_read_byte ( score_cursor ++ ) ; opcode = command & 0xf0 ; chan = command & 0x0f ; if ( opcode == TUNE_OP_STOPNOTE ) { stopNote ( chan ) ; } else if ( opcode == TUNE_OP_PLAYNOTE ) { all_muted = ! outputEnabled ( ) ; playNote ( chan , pgm_read_byte ( score_cursor ++ ) ) ; } else if ( opcode < 0x80 ) { duration = ( ( unsigned ) command << 8 ) | ( pgm_read_byte ( score_cursor ++ ) ) ; wait_toggle_count = ( ( unsigned long ) wait_timer_frequency2 * duration + 500 ) / 1000 ; if ( wait_toggle_count == 0 ) wait_toggle_count = 1 ; break ; } else if ( opcode == TUNE_OP_RESTART ) { score_cursor = score_start ; } else if ( opcode == TUNE_OP_STOP ) { tune_playing = false ; break ; } } }
Do score commands until a "wait" is found, or the score is stopped.
Do score commands until a " wait " is found or the score is stopped .
/* stop note */ /* play note */ /* wait count in msec. */ /* restart score */ /* stop score */