Listing of file='GENSND.MAC;01' on disk='vmedia/joystick_sound-sector.ccvf'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; AY-3-8910 SOUND ROUTINE USING TIMER #2 ; ; BECAUSE THE SOUNDS ARE INTERRUPT DRIVEN, THE MAIN ; PROGRAM CAN CONTINUE EXECUTING. ; ; VALUES ON ENTRY: ; A - NO. OF STEPS ; B - STEP 1 ; C - STEP 2 ; D - DURATION ; E - INTERVAL (MILLISEC APPROX) ; HL - PITCH ; ; RETURNS: ; NOTHING - FINFLG IS SET WHEN THE SOUND IS FINISHED. ; ; DESTROYS: ; ALL REGISTERS ; PUBLIC DURN,INTV,NSTEPS,STEP1,STEP2 PUBLIC FINFLG EXTRN SAVE EXTRN SND,SNDOFF,PITCH TM2INT EQU 81C8H TIMER2 EQU 10 TINC EQU 16 ;APPROX 1 MSEC ENTRY GENSND GENSND: DI ;PREVENT INTERRUPTS WHILE RESETTING SHLD PITCH ; THE PARAMETERS XCHG SHLD INTV STA NSTEPS MOV A,B STA STEP1 MOV A,C ORA A ;MAKE STEP2 = STEP1 IF IT IS ZERO JNZ OVER MOV A,B OVER: STA STEP2 MVI A,0C3H ;SETUP JUMP TO INTERRUPT ROUTINE LXI H,PLAY STA TM2INT ; FOR TIMER #2 SHLD TM2INT+1 XRA A ;CLEAR THE "FINISHED" FLAG STA FINFLG LHLD INTV ;MAKE COPY OF INTERVAL AND DURATION SHLD INTSAV MVI A,TINC ;START TIMER #2 OUT TIMER2 ; AND RETURN TO MAIN PROGRAM --- EI ; EVERYTHING WORKS BY INTERRUPTS NOW RET ; ; TIMER #2 INTERRUPT ROUTINE ; PLAY: CALL SAVE ;SAVE REGISTERS LDA INTV ;CHECK IF ONE "TICK" EXPIRED ... DCR A STA INTV JNZ RETIME ;... NO, KEEP TICKING AWAY LDA INTSAV ;RESTORE INTERVAL COUNTER STA INTV LDA DURN ;CHECK DURATION EXPIRED DCR A STA DURN JNZ RETIME ;AND REPEAT IF NOT LDA DURSAV STA DURN LDA NSTEPS ORA A ;SEE IF ANY STEPS LEFT TO GO JZ FINISH DCR A STA NSTEPS LHLD PITCH LDA STEP1 ;CHANGE THE PITCH MOV C,A ORA A ;SIGN EXTEND THE STEP MVI A,0FFH JM PLAY10 XRA A PLAY10: MOV B,A DAD B SHLD PITCH LDA STEP2 ;SWAP STEP1 AND STEP2 FOR NEXT TIME STA STEP1 MOV A,C STA STEP2 CALL SND RETIME: MVI A,TINC ;RESTART THE TIMER FOR NEXT ONE OUT TIMER2 EI RET FINISH: CALL SNDOFF ;TURN OFF SOUND MVI A,0FFH ;SET THE "FINISHED" FLAG STA FINFLG RET ; ; SOUND PARAMETERS ; INTV: DB 1 ;INTERRUPT INTERVAL (MSEC) DURN: DB 15 ;DURATION OF SOUND INTSAV: DB 1 DURSAV: DB 15 NSTEPS: DB 0 STEP1: DB 0 STEP2: DB 0 FINFLG: DB 0FFH END