home *** CD-ROM | disk | FTP | other *** search
- PAGE 60,132
- TITLE fxDK.ASM -- PCX Effects
- SUBTTL Copyright (c) Genus Microprogramming, Inc. 1988-89
-
- ; fxDK.ASM ;
- ; Copyright (c) Genus Microprogramming, Inc. 1988-89 All Rights Reserved. ;
-
- ;****************************************************************************;
- ; ;
- ; This file contains procedures for timing and keyboard delays while ;
- ; an effect is in progress. ;
- ; ;
- ; Procedures: fxCalibrateDelay ;
- ; fxEffectDelay ;
- ; ;
- ; ;
- ; ;
- ; Microsoft ASM 5.x version. Programmer: Chris Howard 3/15/89 ;
- ; ;
- ;****************************************************************************;
-
- ; Include files
- INCLUDE ..\inc\pcxDefs.inc
- INCLUDE ..\inc\pcxMacs.inc
- INCLUDE ..\inc\pcxErrs.inc
-
- INCLUDE ..\inc\fxDefs.inc
- INCLUDE ..\inc\fxMacs.inc
- INCLUDE ..\inc\fxErrs.inc
-
- @SetModel
-
- @BegData
-
- EXTRN fx100th : WORD
- EXTRN fxKeyChk : WORD
-
- @EndData
-
- @BegCode
-
- PUBLIC fxLoopDelay
- PUBLIC fxCalibrateDelay
- PUBLIC fxEffectDelay
- PUBLIC fxKeyCheck
-
- ;**********
-
- ;
- ; This procedure delays for the specified number of loops.
- ; It is called both externally and internally.
- ;
- ;
-
- ;Define variable locations on the stack (pascal model)
- lddelay equ <[bp+ 6]> ;Time Delay
- ldparm equ 2
-
- ;Define local variables
- ldret equ <[bp- 2]> ;Time Delay
- ldlocal equ 2 ;Total local space needed
-
- fxLoopDelay PROC FAR
-
- @Entry ldlocal ;Set up frame and save regs
-
- push cx ;Save regs
-
- mov cx,lddelay ;Get the delay
- cmp cx,0 ;If it is zero, skip
- je fxLD_exit
-
- fxLD_loop:
-
- xor ax,ax ;Do any instructions for a
- xor ax,ax ; delay ...
-
- loop fxLD_loop
-
- fxLD_exit:
-
- pop cx ;Restore regs
-
- @SetRet ldret,fxSUCCESS ;Set return code
-
- @Exit ldret,ldparm ;Return
-
- fxLoopDelay ENDP
-
- ;**********
-
- ;
- ; This procedure calibrates the effect delay procedure, so that effects
- ; are speed independent of the hardware. It is an internal procedure.
- ;
- ;
-
- ;Define variable locations on the stack (pascal model)
- cdparm equ 0
-
- ;Define local variables
- cdret equ <[bp- 2]> ;Return code
- cdhicount equ <[bp- 4]> ;Return code
- cdlocount equ <[bp- 6]> ;Return code
- cdlocal equ 6 ;Total local space needed
-
- fxCalibrateDelay PROC FAR
-
- @Entry cdlocal ;Set up frame and save regs
-
- @@LoadSeg es,0H ;Point to click address
- mov di,046CH ; in low memory
-
- mov bx,WORD PTR es:[di] ;Read the value
- mov dx,WORD PTR es:[di+2]
-
- add bx,18 ;Add a delay of about 1 second
- adc dx,0 ; (approx. 18.2 = 1 second)
-
- xor cx,cx
- mov si,500 ;Set the loop delay arbitrarily
-
- fxCD_loop:
-
- push si ;Delay
- call fxLoopDelay
-
- inc cx ;Count
-
- cmp dx,WORD PTR es:[di+2] ;Now loop, until a second has
- ja fxCD_loop ; passed
-
- cmp bx,WORD PTR es:[di] ;Check the high word also
- ja fxCD_loop
-
- mov ax,si ;Get loop count
- mul cx ; and multiply to get total
-
- mov cx,100 ;Now determine loops necessary
- div cx ; for 1/100th second
-
- mov fx100th,ax ;Store it (ignore high word)
-
- fxCD_exit:
-
- @SetRet cdret,fxSUCCESS
-
- @Exit cdret,cdparm ;Return
-
- fxCalibrateDelay ENDP
-
- ;**********
-
- ;
- ; This procedure controls the delays for the effect routines.
- ;
- ;
-
- ;Define variable locations on the stack (pascal model)
- eddelay equ <[bp+ 6]> ;Time Delay, in 100ths
- edparm equ 2
-
- ;Define local variables
- edret equ <[bp- 2]> ;Time Delay
- edlocal equ 2 ;Total local space needed
-
- fxEffectDelay PROC FAR
-
- @Entry edlocal ;Set up frame and save regs
-
- push cx ;Save regs
-
- mov cx,eddelay ;Get delay requested
- cmp cx,0 ;Is it zero?
- je fxED_keycheck ;If so, skip to key check
-
- mov si,fx100th ;Get 1/100th loop value
-
- fxED_loop:
-
- push si ;Push loop value
- call fxLoopDelay ; and delay
-
- loop fxED_loop
-
- fxED_keycheck:
-
- cmp fxKeyChk,pcxFALSE ;Check for a key?
- je fxED_ok
-
- @BIOSKEY CHECKKEY ;Check if there is a waiting key
- jz fxED_ok
-
- @BIOSKEY GETKEY ;Get the key
-
- cmp al,ESCAPE ;Is it the ESCAPE key?
- jne fxED_ok ;If not, continue
-
- stc ;Set the carry flag
-
- @SetRet edret,fxERR_ESCAPE ;Indicate escape was pressed
- jmp SHORT fxED_exit
-
- fxED_ok:
-
- clc ;Clear the carry flag
-
- @SetRet edret,fxSUCCESS
-
- fxED_exit:
-
- pop cx ;Restore used regs
-
- @Exit edret,edparm ;Return
-
- fxEffectDelay ENDP
-
- ;**********
-
- ;
- ; This procedure enables or disables checking for the ESC key after
- ; effect delays.
- ;
- ; Calling: retcode = fxKeyCheck(int flag)
- ;
- ;
-
- ;Define variable locations on the stack (pascal model)
- kcflag equ <[bp+6]>
- kcparm equ 2
-
- ;Define local variables
- kcret equ <[bp-2]> ;return code
- kclocal equ 2 ;Total local space needed
-
- fxKeyCheck PROC FAR
-
- @Entry kclocal ;Set up frame and save regs
-
- mov ax,kcflag ;Get the keycheck flag
- cmp ax,pcxTRUE ;Enable it?
- je fxKC_true
-
- mov fxKeyChk,pcxFALSE ;If not, set to false
- jmp SHORT fxKC_exit
-
- fxKC_true:
-
- mov fxKeyChk,pcxTRUE ;Enable key checking
-
- fxKC_exit:
-
- @SetRet kcret,fxSUCCESS ; and set successful code
- @Exit kcret,kcparm ;Return
-
- fxKeyCheck ENDP
-
- @EndCode
-
- END
-
-