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

  1.   PAGE    60,132
  2.   TITLE   fxVN.ASM -- PCX Effects
  3.   SUBTTL  Copyright (c) Genus Microprogramming, Inc. 1988-89
  4.  
  5. ; fxVN.ASM                                                                   ;
  6. ; Copyright (c) Genus Microprogramming, Inc. 1988-89  All Rights Reserved.   ;
  7.  
  8. ;****************************************************************************;
  9. ;                                                                            ;
  10. ; This file contains procedures for taking a pcx virtual buffer and          ;
  11. ; 'randomizing' it on the display.                                           ;
  12. ;                                                                            ;
  13. ; Procedures: fxVirtualRandom                                                ;
  14. ;                                                                            ;
  15. ;                                                                            ;
  16. ;                                                                            ;
  17. ; Microsoft ASM 5.x version.              Programmer: Chris Howard  5/04/89  ;
  18. ;                                                                            ;
  19. ;****************************************************************************;
  20.  
  21. ; Include files
  22.   INCLUDE ..\inc\pcxDefs.inc
  23.   INCLUDE ..\inc\pcxMacs.inc
  24.   INCLUDE ..\inc\pcxErrs.inc
  25.  
  26.   INCLUDE ..\inc\fxDefs.inc
  27.   INCLUDE ..\inc\fxMacs.inc
  28.   INCLUDE ..\inc\fxErrs.inc
  29.  
  30.   @SetModel
  31.  
  32.   @BegData
  33.  
  34.           EXTRN     pcxFBuff                : BYTE
  35.           EXTRN     pcxbufmax               : WORD
  36.           EXTRN     pcxbufseg               : WORD
  37.           EXTRN     pcxbufofs               : WORD
  38.  
  39.   @EndData
  40.  
  41.   @BegCode
  42.  
  43.           EXTRN     pcxVirtualDisplay       : FAR
  44.           EXTRN     fxEffectDelay           : FAR
  45.           EXTRN     fxVirtualGrid           : FAR
  46.           EXTRN     fxVirtualBox            : FAR
  47.           EXTRN     fxGetRand               : FAR
  48.  
  49.           PUBLIC    fxVirtualRandom
  50.  
  51. ;**********
  52.  
  53. ;
  54. ; This is the Virtual Random effect procedure, for the fxVirtualEffect
  55. ; interface.  It is an INTERNAL routine only.
  56. ;
  57. ; On Entry:  SS:BP    points to pcxVirtualEffect frame
  58. ;            ES:DI    points to display structure
  59. ;
  60. ; On Exit:   retcode  contains error code, if any
  61. ;
  62.  
  63. fxVirtualRandom     PROC FAR
  64.  
  65. fxVR_getgrid:
  66.  
  67.           call      fxVirtualGrid           ;Break up the image into a grid
  68.  
  69.           mov       ax,veimax               ;Now get the width and depth
  70.           inc       ax                      ; (make them 1 based)
  71.           mov       bx,vejmax
  72.           inc       bx
  73.  
  74.           mul       bx                      ;Multiply, to get total squares
  75.  
  76.           cmp       ax,pcxbufmax            ;Is there room in our buffer?
  77.           jb        fxVR_max                ;If so, set the maximum
  78.  
  79.           shl       WORD PTR vevgrain,1     ;Multiply grain by two
  80.           jmp       SHORT fxVR_getgrid      ; and get another grid
  81.  
  82. fxVR_max:
  83.  
  84.           mov       veloopmax,ax            ;Store the total grid number
  85.  
  86.           @@Data    es                      ;Point to the buffer (ES:DI)
  87.           mov       di,OFFSET pcxFBuff
  88.  
  89.           cmp       pcxbufseg,unknown       ;Has another buffer been defined?
  90.           je        fxVR_zero               ;If not, we're all set
  91.  
  92.           @@LoadSeg es,pcxbufseg            ;If so, point to it
  93.           mov       di,pcxbufofs
  94.  
  95. fxVR_zero:
  96.  
  97.           push      di                      ;Save our buffer pointer
  98.  
  99.           mov       cx,veloopmax            ;Get the array maximum
  100.           shr       cx,1                    ; and get total words
  101.           xor       ax,ax                   ;Clear to zero
  102.           rep       stosw                   ; the entire array
  103.  
  104.           pop       di                      ;Restore buffer pointer
  105.           mov       cx,veloopmax            ; and set the loop count
  106.  
  107. fxVR_loop:
  108.  
  109.           mov       ax,veloopmax            ;Use the grid total
  110.           push      ax                      ; and get a random number
  111.           call      fxGetRand
  112.  
  113.           xor       bx,bx                   ;Clear pointer
  114.  
  115.           cmp       ax,0                    ;If zero,
  116.           jne       fxVR_search
  117.  
  118.           inc       ax                      ; bump to one
  119.  
  120. fxVR_search:
  121.  
  122.           cmp       BYTE PTR es:[di][bx],0  ;Is this entry available?
  123.           je        fxVR_count              ;If so, count it
  124.           jmp       SHORT fxVR_skip         ;If not, skip it
  125.  
  126. fxVR_count:
  127.  
  128.           dec       ax                      ;Count this one
  129.           jz        fxVR_set                ;Have we counted enough?
  130.  
  131. fxVR_skip:
  132.  
  133.           inc       bx                      ;Bump to next entry
  134.           jmp       SHORT fxVR_search       ; and continue our search
  135.  
  136. fxVR_set:
  137.  
  138.           mov       BYTE PTR es:[di][bx],1  ;Mark this entry as used
  139.  
  140.           mov       ax,bx                   ;Put into AX for divide
  141.           xor       dx,dx                   ; and clear high word
  142.  
  143.           mov       bx,veimax               ;Get the number of columns
  144.           inc       bx                      ; and make 1 based
  145.           div       bx                      ;Divide
  146.  
  147.           push      di                      ;Save array pointer
  148.           mov       di,ax                   ; and store row
  149.  
  150.           dec       dx                      ;Adjust for zero base
  151.           cmp       dx,0                    ;Is remainder zero?
  152.           jge       fxVR_col
  153.  
  154.           mov       dx,veimax               ;If so, set to max row
  155.  
  156. fxVR_col:
  157.  
  158.           mov       si,dx                   ;Store col
  159.  
  160.           call      fxVirtualBox            ;Display this box
  161.  
  162.           pop       di                      ;Restore array pointer
  163.  
  164.           mov       ax,vedelay              ;Get the delay count
  165.           push      ax
  166.  
  167.           call      fxEffectDelay           ; and delay
  168.  
  169.           jnc       fxVR_chkloop            ;If no error, continue
  170.           jmp       SHORT fxVR_error  
  171.  
  172. fxVR_chkloop:
  173.  
  174.           dec       WORD PTR veloopmax      ;Dec number of grids left
  175.           loop      fxVR_loop
  176.  
  177. fxVR_done:
  178.  
  179.           @SetRet   veret,fxSUCCESS         ;Set the return code
  180.           jmp       SHORT fxVR_exit         ; and exit
  181.  
  182. fxVR_error:
  183.  
  184.           @SetRet   veret,ax                ;Set the return code
  185.  
  186. fxVR_exit:
  187.  
  188.           @Exit     veret,veparm            ;Return
  189.  
  190. fxVirtualRandom     ENDP
  191.  
  192.   @EndCode
  193.  
  194.           END
  195.