home *** CD-ROM | disk | FTP | other *** search
- PAGE 60,132
- TITLE fxVN.ASM -- PCX Effects
- SUBTTL Copyright (c) Genus Microprogramming, Inc. 1988-89
-
- ; fxVN.ASM ;
- ; Copyright (c) Genus Microprogramming, Inc. 1988-89 All Rights Reserved. ;
-
- ;****************************************************************************;
- ; ;
- ; This file contains procedures for taking a pcx virtual buffer and ;
- ; 'randomizing' it on the display. ;
- ; ;
- ; Procedures: fxVirtualRandom ;
- ; ;
- ; ;
- ; ;
- ; Microsoft ASM 5.x version. Programmer: Chris Howard 5/04/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 pcxFBuff : BYTE
- EXTRN pcxbufmax : WORD
- EXTRN pcxbufseg : WORD
- EXTRN pcxbufofs : WORD
-
- @EndData
-
- @BegCode
-
- EXTRN pcxVirtualDisplay : FAR
- EXTRN fxEffectDelay : FAR
- EXTRN fxVirtualGrid : FAR
- EXTRN fxVirtualBox : FAR
- EXTRN fxGetRand : FAR
-
- PUBLIC fxVirtualRandom
-
- ;**********
-
- ;
- ; This is the Virtual Random effect procedure, for the fxVirtualEffect
- ; interface. It is an INTERNAL routine only.
- ;
- ; On Entry: SS:BP points to pcxVirtualEffect frame
- ; ES:DI points to display structure
- ;
- ; On Exit: retcode contains error code, if any
- ;
-
- fxVirtualRandom PROC FAR
-
- fxVR_getgrid:
-
- call fxVirtualGrid ;Break up the image into a grid
-
- mov ax,veimax ;Now get the width and depth
- inc ax ; (make them 1 based)
- mov bx,vejmax
- inc bx
-
- mul bx ;Multiply, to get total squares
-
- cmp ax,pcxbufmax ;Is there room in our buffer?
- jb fxVR_max ;If so, set the maximum
-
- shl WORD PTR vevgrain,1 ;Multiply grain by two
- jmp SHORT fxVR_getgrid ; and get another grid
-
- fxVR_max:
-
- mov veloopmax,ax ;Store the total grid number
-
- @@Data es ;Point to the buffer (ES:DI)
- mov di,OFFSET pcxFBuff
-
- cmp pcxbufseg,unknown ;Has another buffer been defined?
- je fxVR_zero ;If not, we're all set
-
- @@LoadSeg es,pcxbufseg ;If so, point to it
- mov di,pcxbufofs
-
- fxVR_zero:
-
- push di ;Save our buffer pointer
-
- mov cx,veloopmax ;Get the array maximum
- shr cx,1 ; and get total words
- xor ax,ax ;Clear to zero
- rep stosw ; the entire array
-
- pop di ;Restore buffer pointer
- mov cx,veloopmax ; and set the loop count
-
- fxVR_loop:
-
- mov ax,veloopmax ;Use the grid total
- push ax ; and get a random number
- call fxGetRand
-
- xor bx,bx ;Clear pointer
-
- cmp ax,0 ;If zero,
- jne fxVR_search
-
- inc ax ; bump to one
-
- fxVR_search:
-
- cmp BYTE PTR es:[di][bx],0 ;Is this entry available?
- je fxVR_count ;If so, count it
- jmp SHORT fxVR_skip ;If not, skip it
-
- fxVR_count:
-
- dec ax ;Count this one
- jz fxVR_set ;Have we counted enough?
-
- fxVR_skip:
-
- inc bx ;Bump to next entry
- jmp SHORT fxVR_search ; and continue our search
-
- fxVR_set:
-
- mov BYTE PTR es:[di][bx],1 ;Mark this entry as used
-
- mov ax,bx ;Put into AX for divide
- xor dx,dx ; and clear high word
-
- mov bx,veimax ;Get the number of columns
- inc bx ; and make 1 based
- div bx ;Divide
-
- push di ;Save array pointer
- mov di,ax ; and store row
-
- dec dx ;Adjust for zero base
- cmp dx,0 ;Is remainder zero?
- jge fxVR_col
-
- mov dx,veimax ;If so, set to max row
-
- fxVR_col:
-
- mov si,dx ;Store col
-
- call fxVirtualBox ;Display this box
-
- pop di ;Restore array pointer
-
- mov ax,vedelay ;Get the delay count
- push ax
-
- call fxEffectDelay ; and delay
-
- jnc fxVR_chkloop ;If no error, continue
- jmp SHORT fxVR_error
-
- fxVR_chkloop:
-
- dec WORD PTR veloopmax ;Dec number of grids left
- loop fxVR_loop
-
- fxVR_done:
-
- @SetRet veret,fxSUCCESS ;Set the return code
- jmp SHORT fxVR_exit ; and exit
-
- fxVR_error:
-
- @SetRet veret,ax ;Set the return code
-
- fxVR_exit:
-
- @Exit veret,veparm ;Return
-
- fxVirtualRandom ENDP
-
- @EndCode
-
- END
-