home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c011 / 1.ddi / SOURCE / FXDK.ASM next >
Encoding:
Assembly Source File  |  1989-06-01  |  7.8 KB  |  262 lines

  1.   PAGE    60,132
  2.   TITLE   fxDK.ASM -- PCX Effects
  3.   SUBTTL  Copyright (c) Genus Microprogramming, Inc. 1988-89
  4.  
  5. ; fxDK.ASM                                                                   ;
  6. ; Copyright (c) Genus Microprogramming, Inc. 1988-89  All Rights Reserved.   ;
  7.  
  8. ;****************************************************************************;
  9. ;                                                                            ;
  10. ; This file contains procedures for timing and keyboard delays while         ;
  11. ; an effect is in progress.                                                  ;
  12. ;                                                                            ;
  13. ; Procedures: fxCalibrateDelay                                               ;
  14. ;             fxEffectDelay                                                  ;
  15. ;                                                                            ;
  16. ;                                                                            ;
  17. ;                                                                            ;
  18. ; Microsoft ASM 5.x version.              Programmer: Chris Howard  3/15/89  ;
  19. ;                                                                            ;
  20. ;****************************************************************************;
  21.  
  22. ; Include files
  23.   INCLUDE ..\inc\pcxDefs.inc
  24.   INCLUDE ..\inc\pcxMacs.inc
  25.   INCLUDE ..\inc\pcxErrs.inc
  26.  
  27.   INCLUDE ..\inc\fxDefs.inc
  28.   INCLUDE ..\inc\fxMacs.inc
  29.   INCLUDE ..\inc\fxErrs.inc
  30.  
  31.   @SetModel
  32.  
  33.   @BegData
  34.  
  35.           EXTRN     fx100th                 : WORD
  36.           EXTRN     fxKeyChk                : WORD
  37.  
  38.   @EndData
  39.  
  40.   @BegCode
  41.  
  42.           PUBLIC    fxLoopDelay
  43.           PUBLIC    fxCalibrateDelay
  44.           PUBLIC    fxEffectDelay   
  45.           PUBLIC    fxKeyCheck
  46.  
  47. ;**********
  48.  
  49. ;
  50. ; This procedure delays for the specified number of loops. 
  51. ; It is called both externally and internally.                        
  52. ;
  53. ;
  54.  
  55. ;Define variable locations on the stack  (pascal model)
  56. lddelay   equ       <[bp+ 6]>               ;Time Delay    
  57. ldparm    equ       2
  58.  
  59. ;Define local variables
  60. ldret     equ       <[bp- 2]>               ;Time Delay    
  61. ldlocal   equ       2                       ;Total local space needed
  62.  
  63. fxLoopDelay         PROC FAR
  64.  
  65.           @Entry    ldlocal                 ;Set up frame and save regs
  66.  
  67.           push      cx                      ;Save regs
  68.  
  69.           mov       cx,lddelay              ;Get the delay
  70.           cmp       cx,0                    ;If it is zero, skip
  71.           je        fxLD_exit
  72.  
  73. fxLD_loop:
  74.  
  75.           xor       ax,ax                   ;Do any instructions for a
  76.           xor       ax,ax                   ; delay ...
  77.  
  78.           loop      fxLD_loop
  79.  
  80. fxLD_exit:
  81.  
  82.           pop       cx                      ;Restore regs
  83.  
  84.           @SetRet   ldret,fxSUCCESS         ;Set return code
  85.  
  86.           @Exit     ldret,ldparm            ;Return
  87.  
  88. fxLoopDelay         ENDP
  89.  
  90. ;**********
  91.  
  92. ;
  93. ; This procedure calibrates the effect delay procedure, so that effects
  94. ; are speed independent of the hardware.  It is an internal procedure.
  95. ;
  96. ;
  97.  
  98. ;Define variable locations on the stack  (pascal model)
  99. cdparm    equ       0
  100.  
  101. ;Define local variables
  102. cdret     equ       <[bp- 2]>               ;Return code   
  103. cdhicount equ       <[bp- 4]>               ;Return code   
  104. cdlocount equ       <[bp- 6]>               ;Return code   
  105. cdlocal   equ       6                       ;Total local space needed
  106.  
  107. fxCalibrateDelay    PROC FAR
  108.  
  109.           @Entry    cdlocal                 ;Set up frame and save regs
  110.  
  111.           @@LoadSeg es,0H                   ;Point to click address
  112.           mov       di,046CH                ; in low memory
  113.  
  114.           mov       bx,WORD PTR es:[di]     ;Read the value
  115.           mov       dx,WORD PTR es:[di+2]
  116.  
  117.           add       bx,18                   ;Add a delay of about 1 second
  118.           adc       dx,0                    ; (approx. 18.2 = 1 second)
  119.  
  120.           xor       cx,cx
  121.           mov       si,500                  ;Set the loop delay arbitrarily
  122.  
  123. fxCD_loop:
  124.  
  125.           push      si                      ;Delay
  126.           call      fxLoopDelay
  127.  
  128.           inc       cx                      ;Count
  129.  
  130.           cmp       dx,WORD PTR es:[di+2]   ;Now loop, until a second has
  131.           ja        fxCD_loop               ; passed
  132.  
  133.           cmp       bx,WORD PTR es:[di]     ;Check the high word also
  134.           ja        fxCD_loop
  135.  
  136.           mov       ax,si                   ;Get loop count
  137.           mul       cx                      ; and multiply to get total
  138.  
  139.           mov       cx,100                  ;Now determine loops necessary
  140.           div       cx                      ; for 1/100th second
  141.  
  142.           mov       fx100th,ax              ;Store it (ignore high word)
  143.  
  144. fxCD_exit:
  145.  
  146.           @SetRet   cdret,fxSUCCESS
  147.  
  148.           @Exit     cdret,cdparm            ;Return
  149.  
  150. fxCalibrateDelay    ENDP
  151.  
  152. ;**********
  153.  
  154. ;
  155. ; This procedure controls the delays for the effect routines.
  156. ;
  157. ;
  158.  
  159. ;Define variable locations on the stack  (pascal model)
  160. eddelay   equ       <[bp+ 6]>               ;Time Delay, in 100ths
  161. edparm    equ       2
  162.  
  163. ;Define local variables
  164. edret     equ       <[bp- 2]>               ;Time Delay    
  165. edlocal   equ       2                       ;Total local space needed
  166.  
  167. fxEffectDelay       PROC FAR
  168.  
  169.           @Entry    edlocal                 ;Set up frame and save regs
  170.  
  171.           push      cx                      ;Save regs
  172.  
  173.           mov       cx,eddelay              ;Get delay requested
  174.           cmp       cx,0                    ;Is it zero?
  175.           je        fxED_keycheck           ;If so, skip to key check
  176.  
  177.           mov       si,fx100th              ;Get 1/100th loop value
  178.  
  179. fxED_loop:
  180.  
  181.           push      si                      ;Push loop value
  182.           call      fxLoopDelay             ; and delay
  183.  
  184.           loop      fxED_loop
  185.  
  186. fxED_keycheck:
  187.  
  188.           cmp       fxKeyChk,pcxFALSE       ;Check for a key?
  189.           je        fxED_ok  
  190.  
  191.           @BIOSKEY  CHECKKEY                ;Check if there is a waiting key
  192.           jz        fxED_ok
  193.  
  194.           @BIOSKEY  GETKEY                  ;Get the key
  195.  
  196.           cmp       al,ESCAPE               ;Is it the ESCAPE key?
  197.           jne       fxED_ok                 ;If not, continue
  198.  
  199.           stc                               ;Set the carry flag
  200.  
  201.           @SetRet   edret,fxERR_ESCAPE      ;Indicate escape was pressed
  202.           jmp       SHORT fxED_exit
  203.  
  204. fxED_ok:
  205.  
  206.           clc                               ;Clear the carry flag
  207.  
  208.           @SetRet   edret,fxSUCCESS
  209.  
  210. fxED_exit:
  211.  
  212.           pop       cx                      ;Restore used regs
  213.  
  214.           @Exit     edret,edparm            ;Return
  215.  
  216. fxEffectDelay       ENDP
  217.  
  218. ;**********
  219.  
  220. ;
  221. ; This procedure enables or disables checking for the ESC key after 
  222. ; effect delays.
  223. ;
  224. ; Calling: retcode = fxKeyCheck(int flag)
  225. ;
  226. ;
  227.  
  228. ;Define variable locations on the stack  (pascal model)
  229. kcflag    equ       <[bp+6]>
  230. kcparm    equ       2
  231.  
  232. ;Define local variables
  233. kcret     equ       <[bp-2]>                ;return code
  234. kclocal   equ       2                       ;Total local space needed
  235.  
  236. fxKeyCheck          PROC FAR
  237.  
  238.           @Entry    kclocal                 ;Set up frame and save regs
  239.  
  240.           mov       ax,kcflag               ;Get the keycheck flag
  241.           cmp       ax,pcxTRUE              ;Enable it?
  242.           je        fxKC_true
  243.  
  244.           mov       fxKeyChk,pcxFALSE       ;If not, set to false
  245.           jmp       SHORT fxKC_exit
  246.  
  247. fxKC_true:
  248.  
  249.           mov       fxKeyChk,pcxTRUE        ;Enable key checking
  250.  
  251. fxKC_exit:
  252.  
  253.           @SetRet   kcret,fxSUCCESS         ; and set successful code
  254.           @Exit     kcret,kcparm            ;Return
  255.  
  256. fxKeyCheck          ENDP
  257.  
  258.   @EndCode
  259.  
  260.           END
  261.  
  262.