0 ' ASYNC.BA - By Don Corbitt 1/20/85 Club 100 Library - 415/939-1246 BBS, 937-5039 NEWSLETTER, 932-8856 VOICE 1 'asynchronous sound command machine code written by Don Corbitt 2 '.BA implementation and modifications by Rick Perry 3 'subroutine 100 loads the code, relocating it to any desired End address 4 'lines 20-70 are a simple Piano demo 5 GOSUB14 6 CLEAR256:CLS:DEFINTA-Z:DIMA(11):A$="cCdDefFgGaAbqQ":RESTORE10:FORI=0TO11:READA(I):NEXT:PRINT:PRINT"Use keys c d e f g a b":PRINT:PRINT"SHIFT for sharp, SPACE for rest,":PRINT:PRINT"Q to exit." 7 B$=INKEY$:IFB$=""THEN7 8 I=INSTR(A$,B$)-1:IFI<0THENCALLHIMEM+75ELSEIFI>11THENMENUELSECALLHIMEM,200,A(I)'200*20msec=4 sec default duration 9 GOTO7 10 DATA4697,4433,4184,3950,3718,3516,3321,3134,2959,2793,2636,2484:'Use gosub100 to load the asynchrounous sound code, then CALL HIMEM,D,FR (for new sound without waiting for completion of previous sound) 11 'or CALL HIMEM+9,D,FR (same as SOUND FR,D except it returns immediately to calling routine without waiting for completion of sound) 12 'or CALL HIMEM+75 to reset (cancel) sound. 13 'This subroutine will return to line 20 of main program 14 CLEAR:ONERRORGOTO17:Y=MAXRAM-1:PRINT"End address ("Y") ";:INPUTY:IFY>=MAXRAMTHENERROR6ELSERESTORE21:READZC:X=Y-ZC:CLEAR256,X:DEFINTI-N:DEFSNGP-Z:X=HIMEM:RESTORE21:READZC:Y=X+ZC 15 READA$:CLS:PRINT@92,"Loading "A$" ...":PRINT:FORW=XTOY:GOSUB19:POKEW,Z:NEXT:GOSUB19:FORL=1TOZ:GOSUB19:W=X+Z:R=PEEK(W)+256*PEEK(W+1)+X:P=INT(R/256):POKEW,R-256*P:POKEW+1,P:NEXT 16 READZ:IFZC<>ZTHENSOUND9394,9:PRINT"CHECKSUM IS WRONG":ENDELSEBEEP:GOTO6'SAVEMA$,X,Y'use this SAVEM if .CO is desired 17 SOUND9394,9:IFERR=5ORERR=7THENPRINT"Too low."ELSEPRINT"Too high." 18 PRINT:GOTO14 19 READZ:ZC=ZC+Z:IFZC>65535THENZC=ZC-65536 20 RETURN 21 DATA94,"SOUND",245,243,205,75,0,251,195,18,0,245,58,255,245,254,201,194,10,0,241,50,94,0,62,5,50,93,0,125,211,188,124,246,64,211,189,62,195,211,184,219,186,230,248,246,32,211,186,33,59,0,34,0,246,62,195,50,255,245,201 22 DATA245,229,33,90,0,229,33,93,0,53,192,54,5,35,53,192,62,201,50,255,245,219,186,246,4,211,186,205,131,110,201,225,241,201,5,0,8,3,7,16,20,25,48,62,66,13306