home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG094.ARC
/
SOUND.PRO
< prev
next >
Wrap
Text File
|
1979-12-31
|
5KB
|
136 lines
{Modified by R.K.Hallworth of Donvale Christian School
to accept user interupts U+ and simplify use}
procedure PLAY(note : integer; note_length : byte);
{ Procedure developed in Turbo Pascal for the
MicroBee by Bob Burt, using an algorithm
developed by Alan Burt }
{ This procedure is used in conjunction with
the procedure SOUND.PRO }
var
cycles,frequency,duration : integer;
procedure SOUND;
{ Procedure developed in Turbo Pascal for the
MicroBee by Bob Burt
Use in conjunction with procedure PLAY.PRO
to produce selected notes from the normal
scale (simulation of PLAY command in
MicroWorld BASIC )
Note - It is not necessary to include the
comments, which represent the assembly
language instructions from which the
inline code was derived
The inline code may be compacted }
begin
inline (245/213/229/ { START: PUSH AF,DE,HL }
237/91/cycles/ { LD DE,(CYCLES) }
62/184/ { LD A,0B8H }
211/2/ { OUT (2),A }
205/*+18/ { CALL PAUSE }
62/248/ { LD A,0F8H }
211/2/ { OUT (2),A }
205/*+11/ { CALL PAUSE }
27/ { DEC DE }
122/ { LD A,D }
179/ { OR E }
32/237/ { JR NZ,LOOP1 }
225/209/241/ { POP HL,DE,AF }
201/ { RET }
42/duration/ { PAUSE: LD HL,(DELAY) }
43/ { LOOP2: DEC HL }
124/ { LD A,H }
181/ { OR L }
32/251/ { JR NZ,LOOP2 }
201) { RET }
end; {procedure sound}
begin
frequency := round(exp(ln(440)+(note-13)/12*ln(2)));
duration := round(exp(ln(144)+(13-note)/12*ln(2.028)));
cycles := frequency*note_length div 8;
sound
end; {procedure play}
procedure Sound_Effect(Start_tone,End_tone:byte;
Duration :integer;
GoUp,Melodic,Many :boolean);
Var
up_down,timbre,one_many:byte;
procedure GENSND;
{ Procedure developed in Turbo Pascal
for sound routines to operate with
the MicroBee by Bob Burt }
{ Sound generator module to be
operated in conjunction with
procedure INITSND.PRO }
begin
inline(24/14/ { JUMP: JR START }
62/184/ { ONINT: LD A,0B8H }
211/2/ { LOOP0: OUT (2),A }
16/252/ { DJ NZ,LOOP0 }
201/ { RET }
62/248/ { OFFINT: LD A,0F8H }
211/2/ { LOOP1: OUT (2),A }
16/252/ { DJ NZ,LOOP1 }
201/ { RET }
245/ { START: PUSH AF }
197/ { PUSH BC }
229/ { PUSH HL }
$3A/UP_DOWN/{ LD A,UP_DOWN }
$32/*+21 / { LD (POS1),A }
$3A/TIMBRE/ { LD A,TIMBRE }
$32/*+21/ { LD (POS2),A }
$3A/START_TONE/{ LD A,START_TONE }
$47/ { LD B,A }
$3A/ONE_MANY/{ LD A,ONE_MANY }
$32/*+26/ { LD (POS3),A }
$2A/DURATION/{LOOP3: LD HL,DURATION }
5/ { POS1: DEC B (UP_DOWN) }
72/ { LD C,B }
65/ { LOOP2: LD B,C }
205/*-46/ { CALL ONINT }
65/ { LD B,C (TIMBRE) }
205/*-43/ { CALL OFFINT }
43/ { DEC HL }
125/ { LD A,L }
180/ { OR H }
32/243/ { JR NZ,LOOP2 }
65/ { LD B,C }
120/ { LD A,B }
$21/END_TONE/{ LD HL,END_TONE }
$BE/ { CP A,(HL) }
32/$E6/ { ONE_MANY:JR NZ,LOOP3 }
225/ { POP HL }
193/ { POP BC }
241/ { POP AF }
201); { RET }
end; {procedure gensnd}
begin
Start_tone:=255-Start_tone;
End_Tone :=255-End_Tone;
if GoUp then up_down:=5 else up_down:=4;
if Melodic then timbre:=65 else timbre:=69;
if Many then one_many:=32 else one_many:=40;
gensnd;
end;