wset 4,inst1;
chwave 1,4;
chpitch 1,2.55;

chwave 2,0;
chvolume 2,0.5;
chstart 2;
chpitch 2,0;

mainloop:
  timer r0;
  mul r0,6;
  mov r1,r0;

  fint r0;
  mod r0,16;
  add r0,0;
  mod r1,1;
  currentTick = r0;
  currentTickTime = r1;

  instr1 = patternData1[currentTick];
  instr2 = patternData2[currentTick];
  instr3 = patternData3[currentTick];

  if ((pinstr1 == 0) && (instr1 == 1)) {
    chstart 0;
  } else {
    chstop 0;
  }

  if ((pinstr2 == 0) && (instr2 == 1)) {
    chstart 1;
  } else {
    chstop 1;
  }

  mov r0,currentTickTime; neg r0; add r0,1; fpwr r0,4;
  mul r0,0.6; // add r0,0.64;
  chpitch 0,r0;

  mov r0,instr3;
  mul r0,0.1;
  add r0,0.2;
  chpitch 2,r0;
jmp mainloop;

float currentTick,currentTickTime;
float instr1,instr2,instr3;
float pinstr1,pinstr2;

patternData1: db 1,1,0,0, 1,0,0,0, 1,0,0,1, 0,1,0,0, 1,1,0,0, 1,1,0,0, 1,1,0,1, 1,0,1,0;
patternData2: db 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0;
patternData3: db 0,1,0,2, 0,1,2,2, 0,0,1,1, 1,2,1,2, 2,2,1,2, 2,2,1,1, 1,1,0,0, 0,0,1,2;

string inst1,"synth/pink_noise.wav";
