procedure UpdateSounds();


procedure Play(pl_sound, sound_timer:byte);
begin
	
	freq:=20;

	initSound:=1;
	UpdateSounds();
end;


procedure UpdateSounds();
begin
	if (sound_timer=0) then return();
	dec(sound_timer);
	// Reward
	if (pl_sound=1) then begin
		if (initSound=1) then 
		PlaySound(SID_CHANNEL2, 
				12,  // Volume
				freq,  // Hi byte frequency
				0*16+0,  // Attack voice 1
				14*16 + 9,   // Sustain = 16*15 + release=6
				1 +SID_TRI,  // Waveform
				SID_TRI);  // waveform 
		setfrequency(SID_CHANNEL2, freq);

	end;
	// Hurt
	if (pl_sound=2) then begin
		i:=rands[time]/4+60;
		PlaySound(SID_CHANNEL1, 
				15,  // Volume
				i,  // Hi byte frequency
				0*16+0,  // Attack voice 1
				3*16 + 4,   // Sustain = 16*15 + release=6
				1 +SID_NOISE  // Waveform
				SID_NOISE);  // waveform 

	end;
	// Shoot
	if (pl_sound=3) then begin
		PlaySound(SID_CHANNEL1, 
				15,  // Volume
				30, //rands[time]/2+40,  // Hi byte frequency
				0*16+0,  // Attack voice 1
				3*16 + 6,   // Sustain = 16*15 + release=6
				1 +SID_NOISE  // Waveform
				SID_NOISE);  // waveform 

	end;
	// Hit
	if (pl_sound=4) then begin
		PlaySound(SID_CHANNEL3, 
				15,  // Volume
				10, //rands[time]/2+40,  // Hi byte frequency
				0*16+0,  // Attack voice 1
				3*16 + 9,   // Sustain = 16*15 + release=6
				1 +SID_NOISE  // Waveform
				SID_NOISE);  // waveform 

	end;
	// jump
	if (pl_sound=5) then begin
		if (initSound=1) then 
		PlaySound(SID_CHANNEL3, 
				8,  // Volume
				sine[freq]/2, //rands[time]/2+40,  // Hi byte frequency
				0*16+0,  // Attack voice 1
				3*16 + 9,   // Sustain = 16*15 + release=6
				1 +SID_SAW  // Waveform
				SID_SAW);  // waveform 
		setfrequency(SID_CHANNEL3,sine[freq+20]/2);

	end;

	freq:=freq+4;

	initSound:=0;
	

end;

