home *** CD-ROM | disk | FTP | other *** search
- PAGE 60,132
- TITLE fxVE.ASM -- PCX Effects
- SUBTTL Copyright (c) Genus Microprogramming, Inc. 1988-89
-
- ; fxVE.ASM ;
- ; Copyright (c) Genus Microprogramming, Inc. 1988-89 All Rights Reserved. ;
-
- ;****************************************************************************;
- ; ;
- ; This file contains procedures for taking a pcx virtual buffer and ;
- ; displaying it with a special effect on the current adapter configuration. ;
- ; ;
- ; Procedures: fxVirtualEffect ;
- ; ;
- ; ;
- ; ;
- ; 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 fxVinit : BYTE
-
- @EndData
-
- @BegCode
-
- EXTRN pcxGetDisplay : FAR
- EXTRN pcxGetDispStruc : FAR
-
- EXTRN fxGetEffect : FAR
- EXTRN fxGetEffectStruc : FAR
- EXTRN fxGetGrain : FAR
- EXTRN fxGetDelay : FAR
-
- EXTRN fxVirtualWipe : FAR
- EXTRN fxVirtualSplit : FAR
- EXTRN fxVirtualCrush : FAR
- EXTRN fxVirtualSlide : FAR
- EXTRN fxVirtualSand : FAR
- EXTRN fxVirtualDrip : FAR
- EXTRN fxVirtualExplode : FAR
- EXTRN fxVirtualDiag : FAR
- EXTRN fxVirtualSpiral : FAR
- EXTRN fxVirtualRandom : FAR
-
- PUBLIC fxVirtualEffect
-
- ;**********
-
- ;
- ; This procedure is the main entry point for the virtual effect functions.
- ; It determines the appropriate parameters, and passes them off to the
- ; correct effect routine.
- ;
- ;
-
- ;Define variable locations on the stack (pascal model)
-
- ; (defined in fxdefs.inc ...)
-
- ;Define local variables
-
- ; (defined in fxdefs.inc ...)
-
- fxVirtualEffect PROC FAR
-
- @Entry velocal ;Set up frame and save regs
-
- cmp fxVinit,TRUE ;Have we initialized jump table?
- je fxVE_start
-
- call FAR PTR fxVirtualInit ;If not, do it
-
- fxVE_start:
-
- mov ax,vevseg ;Get the virtual memory type
- cmp ax,pcxEMM ;Is it an expanded memory buffer?
- je fxVE_EMM
-
- jmp SHORT fxVE_CMM ;Assume conventional memory
-
- fxVE_EMM:
-
- mov dx,vevofs ;Virtual ofs is really EMM handle
- mov vehandle,dx
-
- @EMM EMMhpages ;Get the number of handle pages
-
- or ah,ah ;See if successful
- jz fxVE_pages
-
- @SetRet veret,fxERR_EMMFAIL ;EMM failed
- jmp fxVE_exit
-
- fxVE_pages:
-
- mov vehpages,bx ;Store total handle pages
- xor ax,ax
- mov velpage,ax ;And set the logical page to 0
-
- mov cx,vehpages ;Put page count in cx
- mov ax,-1 ;Use ax as physical page
-
- cmp cx,4 ;Are there less than 4 pages?
- jbe fxVE_mappages ;If so, map them
-
- mov cx,4 ;Otherwise, map four
-
- fxVE_mappages:
-
- mov dx,vehandle ;Get the handle
- mov bx,velpage ;Get the logical page
- inc WORD PTR velpage ; and bump it
- inc ax ;Bump physical page
-
- push ax ; and save it
- @EMM EMMmpages ;Map this page
- or ah,ah ;Successful?
- pop ax ; (retrieve physical ...)
-
- loope fxVE_mappages ;If so, map the next one
- je fxVE_frame ;If done, continue
-
- @SetRet veret,fxERR_EMMFAIL ;EMM failed
- jmp fxVE_exit
-
- fxVE_frame:
-
- @EMM EMMpframe ;Get the EMM page frame address
-
- or ah,ah ;Successful?
- jz fxVE_loadseg
-
- @SetRet veret,fxERR_EMMFAIL ;EMM failed
- jmp fxVE_exit
-
- fxVE_loadseg:
-
- @@LoadSeg ds,bx ;Frame segment returned in BX
- xor si,si ; (offset is always zero)
-
- jmp SHORT fxVE_getdisp ;Get the display type
-
- fxVE_CMM:
-
- @@LoadSeg ds,vevseg ;Point to the buffer
- mov si,vevofs
-
- fxVE_getdisp:
-
- call pcxGetDisplay ;Get the current display type
- cmp ax,0
- jge fxVE_getstruc ;If no error, continue
-
- @SetRet veret,ax ;Bad Display type
- jmp fxVE_exit ; so exit
-
- fxVE_getstruc:
-
- push ax ;Argument is display type
- call pcxGetDispStruc ;Get the display structure (dx:ax)
- cmp ax,0
- jae fxVE_getres ;Successful?
-
- @SetRet veret,fxERR_GENERAL ;General error,
- jmp fxVE_exit ; so exit
-
- fxVE_getres:
-
- mov di,ax ;Put returned pointer into regs
- @@LoadSeg es,dx
-
- mov ax,es:[di].dhres ;Store the horizontal res
- dec ax
- mov vehres,ax
-
- mov ax,es:[di].dvres ; and vertical res locally
- dec ax
- mov vevres,ax
-
- fxVE_calc:
-
- mov ax,vex ;Get the X location
- mov bl,ds:[si].bitpx ; and the bits per pixel
- xor bh,bh
- mul bx ; multiply
- mov bl,8 ; and divide by bits per byte
- div bx
- cmp dx,0 ;Are we at a byte boundary?
- je fxVE_width ;If so, we are all set
-
- xor dh,dh ;Clear high byte
- sub vex,dx ; and adjust X location
-
- fxVE_width:
-
- mov ax,ds:[si].x2 ;Calculate the image width
- sub ax,ds:[si].x1
- inc ax
- mov vewidth,ax
-
- mov bl,ds:[si].bitpx ;Get the bits per pixel
- xor bh,bh
- mul bx ; multiply
- mov bl,8 ; and divide by bits per byte
- div bx
- cmp dx,0 ;Is there an exact # of bytes?
- je fxVE_edge ;If so, we are all set
-
- sub bl,dl ;Otherwise, get the difference
- xor bh,bh ; and clear high byte
-
- add ds:[si].x2,bx ;Increase image width in header
- add vewidth,bx ; and locally
-
- fxVE_edge:
-
- mov ax,vewidth ;Put width back into AX
- add ax,vex ;Calculate window edge
- dec ax
- mov vex2,ax ; and store
-
- cmp ax,vehres ;Is it beyond the screen edge?
- jle fxVE_depth ;If not, calc depth
-
- mov ax,vehres ;If so, truncate at screen
- mov vex2,ax
-
- sub ax,vex ;Recalc the image width
- inc ax
- mov vewidth,ax
-
- fxVE_depth:
-
- mov ax,ds:[si].y2 ;Calculate the image depth
- sub ax,ds:[si].y1
- inc ax
- mov vedepth,ax
-
- add ax,vey ;Calculate the window edge
- dec ax
- mov vey2,ax
-
- cmp ax,vevres ;Is it beyond the screen edge?
- jle fxVE_gethalf ;If not, get the half marks
-
- mov ax,vevres ;If so, truncate at screen
- mov vey2,ax
-
- sub ax,vey ;Recalc the image depth
- inc ax
- mov vedepth,ax
-
- fxVE_gethalf:
-
- mov ax,vewidth ;Get the width
- shr ax,1 ; and divide by two
- mov vevhalf,ax ; and store as half mark
-
- mov ax,vedepth ;Get the depth
- shr ax,1 ; and divide by two
- mov vehhalf,ax ; and store as half mark
-
- fxVE_getgrain:
-
- call fxGetGrain ;Get the effect granularity
- mov vegrain,ax ; and store locally
-
- cmp BYTE PTR ds:[si].bitpx,8 ;Is this a 256-color mode?
- je fxVE_setvgrain
-
- and ax,11111000B ;Mask to a byte boundary
- jnz fxVE_setvgrain
-
- mov ax,8 ;Bump to at least 8
-
- fxVE_setvgrain:
-
- mov vevgrain,ax ;Store the vertical grain
-
- fxVE_getdelay:
-
- call fxGetDelay ;Get the effect delay
- mov vedelay,ax ; and store locally
-
- @BIOS GETMODE ;Get the current page
- xchg bh,bl
- xor bh,bh
- mov vepage,bh ; and store locally
-
- fxVE_geteffect:
-
- call fxGetEffect ;Get the current effect type
- cmp ax,0
- jge fxVE_getfxstruc ;If no error, continue
-
- @SetRet veret,ax ;Bad Effect type
- jmp SHORT fxVE_exit ; so exit
-
- fxVE_getfxstruc:
-
- push ax ;Argument is effect type
- call fxGetEffectStruc ;Get the effect struc (dx:ax)
- cmp ax,0
- jae fxVE_callproc ;Successful?
-
- @SetRet veret,fxERR_GENERAL ;General error,
- jmp SHORT fxVE_exit ; so exit
-
- fxVE_callproc:
-
- mov di,ax ;Put returned pointer into regs
- @@LoadSeg es,dx
-
- @@Data ds ;Point to our own data
-
- jmp es:[di].fxfunc ;Jump to effect function
-
- fxVE_exit:
-
- @Exit veret,veparm ;Return
-
- fxVirtualEffect ENDP
-
- ;**********
-
- ;
- ; This procedure is called only once, when the first VirtualEffect function
- ; call is made.
- ;
-
- fxVirtualInit PROC FAR
-
- @InitFX fxWIPE,fxVirtualWipe ;Initialize jump tables
- @InitFX fxSPLIT,fxVirtualSplit
- @InitFX fxCRUSH,fxVirtualCrush
- @InitFX fxSLIDE,fxVirtualSlide
- @InitFX fxSAND,fxVirtualSand
- @InitFX fxDRIP,fxVirtualDrip
- @InitFX fxEXPLODE,fxVirtualExplode
- @InitFX fxDIAG,fxVirtualDiag
- @InitFX fxSPIRAL,fxVirtualSpiral
- @InitFX fxRANDOM,fxVirtualRandom
-
- mov fxVinit,TRUE ;And indicate we are initialized
-
- ret
-
- fxVirtualInit ENDP
-
- @EndCode
-
- END
-
-