#include "ScoutDef.h"

#define TASK_MAIN   0
#define SUB_PLAY    0

#define LOCAL_VAR_0 10
#define LOCAL_VAR_1 11

; This subroutine plays a note for half a second,
; the frequency is passed in a local variable
sub SUB_PLAY
  playv   LOCAL_VAR_0, FR_MS_500
  wait    SRC_CON, FR_MS_500 + FR_MS_50 ; the Scout has no sound buffer so put in
                                        ; waits to get the timing right.
ends

task TASK_MAIN
  setv    LOCAL_VAR_1, SRC_CON, 5       ; the number of iterations
  setv    LOCAL_VAR_0, SRC_CON, TONE_A5 ; the note 'A'
startloop_label:
  decvjn  LOCAL_VAR_1, endloop_label    ; decrement the loop variable and 
                                        ; exit the loop if it becomes negative
  calls   SUB_PLAY
  mulv    LOCAL_VAR_0, SRC_CON, 2       ; doubling the frequency equals 
                                        ; raising the note one octave
  jmp     startloop_label
endloop_label:
endt
