/******************************************************************************\
**  Audio demo (uses Extension) for Secal                                     **
**  Requires Kickstart 2                                                      **
\******************************************************************************/


go main;


#-------------------------------------------------------------------------------


include "ext/ext.inc";				# INTERFACE FOR EXTENSION
inclib "ext/ext.lib";					# USE EXTENSION LIB


#*******************************************************************************


obj mymus:ulong;


#*******************************************************************************


main:
x_Init;											# INITIALIZE EXTENSION
if d0 then
	x_AudioStart(%1111);			# START AUDIO SUBSYSTEM
	if d0 then
		x_Mus_Load("data/mod.demomusic",%1111); mymus:=a0;	# LOAD AND INIT MUSIC
		if mymus then
			call demo;
		;
	;
	x_Done;								# SHUT DOWN EXTENSION, LET IT CLEAN UP INSTEAD OF US, TOO
												# (MUSIC, ETC)
;

d0.l:=0;
rts;															# MAIN


#*******************************************************************************


def TITLE="Secal audio demo";



demo:
push d2;

x_WBenchToFront;


x_EasyRequest(0,TITLE,@text1," Let's see it ");


x_EasyRequest(0,TITLE,@text2," Ok ");
x_PlaySound(@sound1,@end_sound1-@sound1,0,0,0,216,64);


x_EasyRequest(0,TITLE,@text3," Come on ");
x_PlaySound(@sound2,@end_sound2-@sound2,@sound2+3610,7650,0,216,64);


x_EasyRequest(0,TITLE,@text4," Do it ");
x_StopSound(0);


x_EasyRequest(0,TITLE,@text5," Okay ");
x_PlaySound(@sound2,@end_sound2-@sound2,@sound2+3610,7650,0,428,64);
x_Delay(10);
x_PlaySound(@sound2,@end_sound2-@sound2,@sound2+3610,7650,1,214,64);
x_Delay(10);
x_PlaySound(@sound2,@end_sound2-@sound2,@sound2+3610,7650,2,170,64);
x_Delay(10);
x_PlaySound(@sound2,@end_sound2-@sound2,@sound2+3610,7650,3,143,64);


x_EasyRequest(0,TITLE,@text6," Nice ");
for d2:=64 downto 0 do
	x_ModifySound(0,64+428-d2,d2);
	x_ModifySound(1,64+214-d2,d2);
	x_ModifySound(2,64+170-d2,d2);
	x_ModifySound(3,64+143-d2,d2);
	x_Delay(3);
;
x_StopSound(0); x_StopSound(1); x_StopSound(2); x_StopSound(3);


x_EasyRequest(0,TITLE,@text7," Play it ");
x_Mus_Play(mymus,0);


x_EasyRequest(0,TITLE,@text8," Stop it ");
x_Mus_Stop(mymus);


x_EasyRequest(0,TITLE,@text9," Do it ");
x_Mus_Continue(mymus);


x_EasyRequest(0,TITLE,@text10," Ok ");
x_Mus_Modify(mymus,5,$ffff);


x_EasyRequest(0,TITLE,@text11," Okay, bye ");
for d2.uw:=$ffff downto $ff step 256 do
	x_Delay(1);
	x_Mus_Modify(mymus,-1,d2);
;															# MASTER VOLUME LOOP


x_Mus_Stop(mymus);

pop d2;
rts;															# DEMO


#-------------------------------------------------------------------------------


text1:
dc.b '   This program tries to demonstrate the
possibilities of the Secal audio extension.',0;


text2:
dc.b 'After initialization, we can
 handle any sound or music.

  Let',39,'s see a simple sound!',0;


text3:
dc.b 'It is possible to have
a looping sound, too...',0;


text4:
dc.b 'We can stop the current sound.',0;


text5:
dc.b 'Let',39,'s see a bit more complex example!',0;


text6:
dc.b 'We can change the parameters
  of the current sounds.',0;


text7:
dc.b 'Well, this much about sounds,
  let',39,'s play now a music!',0;


text8:
dc.b 'We can stop it...',0;


text9:
dc.b '...Continue it...',0;


text10:
dc.b '...Jump to any position...',0;


text11:
dc.b '    And change the master volume.

Well, this will be the last thing to show.
Bye for now!',0;

align 2;


#-------------------------------------------------------------------------------


data_c;

sound1:									incbin "data/demosound1";
end_sound1:

sound2:									incbin "data/demosound2";
end_sound2:


#*******************************************************************************

