home *** CD-ROM | disk | FTP | other *** search
- PAGE 60,132
- TITLE fxFI.ASM -- PCX F/X
- SUBTTL Copyright (c) Genus Microprogramming, Inc. 1988-89
-
- ; fxFI.ASM ;
- ; Copyright (c) Genus Microprogramming, Inc. 1988-89 All Rights Reserved. ;
-
- ;****************************************************************************;
- ; ;
- ; This file contains high-level procedures for creating virtual image ;
- ; buffers and freeing them later. ;
- ; ;
- ; Procedures: fxFileImage ;
- ; fxLibImage ;
- ; fxFreeImage ;
- ; ;
- ; 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 pcxHBuff : BYTE
-
- @EndData
-
- @BegCode
-
- EXTRN pcxGetDisplay : FAR
- EXTRN pcxGetFileHeader : FAR
- EXTRN pcxGetLibHeader : FAR
- EXTRN pcxVirtualFree : FAR
- EXTRN pcxVirtualSize : FAR
- EXTRN pcxCreateVirtual : FAR
- EXTRN pcxFileVirtual : FAR
- EXTRN pcxLibVirtual : FAR
- EXTRN pcxDestroyVirtual : FAR
-
- PUBLIC fxFileImage
- PUBLIC fxLibImage
- PUBLIC fxFreeImage
-
- ;**********
-
- ;
- ; This procedure combines the virtual buffer create and load in one step.
- ;
- ; Calling: retcode = fxFileImage(int vtype,long *vptr,char *filename)
- ;
- ;
-
- ;Define variable locations on the stack (pascal model)
- fitype equ <[bp+14]>
- fivseg equ <[bp+12]>
- fivofs equ <[bp+10]>
- fifseg equ <[bp+ 8]>
- fifofs equ <[bp+ 6]>
- fiparm equ 10
-
- ;Define local variables
- firet equ <[bp- 2]> ;Return code
- fifreehi equ <[bp- 4]> ;Free memory
- fifreelo equ <[bp- 6]>
- fiwidth equ <[bp- 8]>
- fidepth equ <[bp-10]>
- filocal equ 10 ;Total local space needed
-
- fxFileImage PROC FAR
-
- @Entry filocal ;Set up frame and save regs
-
- mov ax,fitype ;Get the amount of free memory
- push ax
- call pcxVirtualFree
-
- mov fifreehi,dx ;Store locally
- mov fifreelo,ax
-
- mov ax,fifseg ;Try to get the file header
- push ax
- mov ax,fifofs
- push ax
- push ds
- mov si,OFFSET pcxHBuff
- push si
- call pcxGetFileHeader
-
- cmp ax,fxSUCCESS ;Were we successful?
- je fxFI_size
-
- @SetRet firet,ax ;Return code
- jmp fxFI_exit
-
- fxFI_size:
-
- mov cx,ds:[si].x2 ;Calc width
- sub cx,ds:[si].x1
- inc cx
- mov fiwidth,cx
-
- mov dx,ds:[si].y2 ; and depth ...
- sub dx,ds:[si].y1
- inc dx
- mov fidepth,dx
-
- mov ax,fitype ;Now calculate required memory
- push ax
- push cx
- push dx
- call pcxVirtualSize
-
- cmp dx,fifreehi ;Make sure we have enough
- jb fxFI_create
- ja fxFI_nomem
-
- cmp ax,fifreelo
- jbe fxFI_create
-
- fxFI_nomem:
-
- @SetRet firet,pcxERR_CMMNOMEM ;We don't, so set error
- cmp WORD PTR fitype,pcxEMM ;Is this EMM?
- jne fxFI_nomemend ;If not, we are all set
-
- @SetRet firet,pcxERR_EMMNOMEM ;Set correct error
-
- fxFI_nomemend:
-
- jmp SHORT fxFI_exit
-
- fxFI_create:
-
- mov ax,fitype ;Create the buffer
- push ax
- mov ax,fivseg
- push ax
- mov ax,fivofs
- push ax
-
- call pcxGetDisplay ;Get the current display
- cmp ds:[si].nplanes,1 ;Is the image B/W?
- jne fxFI_pushtype
- cmp ds:[si].bitpx,1
- jne fxFI_pushtype
- mov ax,pcxCGA_6 ;If yes, save space
-
- fxFI_pushtype:
-
- push ax
- mov ax,fiwidth
- push ax
- mov ax,fidepth
- push ax
-
- call pcxCreateVirtual
-
- cmp ax,pcxSUCCESS ;Successful?
- je fxFI_file
-
- @SetRet firet,ax ;No, so set return code
- jmp SHORT fxFI_exit
-
- fxFI_file:
-
- @@LoadSeg es,fivseg ;Get a pointer to vptr
- mov di,fivofs
-
- mov ax,fifseg ;Load the file
- push ax
- mov ax,fifofs
- push ax
- mov ax,es:[di+2]
- push ax
- mov ax,es:[di]
- push ax
-
- call pcxFileVirtual
-
- @SetRet firet,ax ;Return the code
-
- fxFI_exit:
-
- @Exit firet,fiparm ;Return
-
- fxFileImage ENDP
-
- ;**********
-
- ;
- ; This procedure combines the virtual buffer create and load in one step.
- ;
- ; Calling: retcode = fxLibImage(int vtype,long vptr,char *libname,char *filename)
- ;
- ;
-
- ;Define variable locations on the stack (pascal model)
- litype equ <[bp+18]>
- livseg equ <[bp+16]>
- livofs equ <[bp+14]>
- lilseg equ <[bp+12]>
- lilofs equ <[bp+10]>
- lifseg equ <[bp+ 8]>
- lifofs equ <[bp+ 6]>
- liparm equ 14
-
- ;Define local variables
- liret equ <[bp- 2]> ;Return code
- lifreehi equ <[bp- 4]> ;Free memory
- lifreelo equ <[bp- 6]>
- liwidth equ <[bp- 8]>
- lidepth equ <[bp-10]>
- lilocal equ 10 ;Total local space needed
-
- fxLibImage PROC FAR
-
- @Entry lilocal ;Set up frame and save regs
-
- mov ax,litype ;Get the amount of free memory
- push ax
- call pcxVirtualFree
-
- mov lifreehi,dx ;Store locally
- mov lifreelo,ax
-
- mov ax,lilseg ;Try to get the file header
- push ax
- mov ax,lilofs
- push ax
- mov ax,lifseg
- push ax
- mov ax,lifofs
- push ax
- push ds
- mov si,OFFSET pcxHBuff
- push si
- call pcxGetLibHeader
-
- cmp ax,fxSUCCESS ;Were we successful?
- je fxLI_size
-
- @SetRet liret,ax ;Return code
- jmp fxLI_exit
-
- fxLI_size:
-
- mov cx,ds:[si].x2 ;Calc width
- sub cx,ds:[si].x1
- inc cx
- mov liwidth,cx
-
- mov dx,ds:[si].y2 ; and depth ...
- sub dx,ds:[si].y1
- inc dx
- mov lidepth,dx
-
- mov ax,litype ;Now calculate required memory
- push ax
- push cx
- push dx
- call pcxVirtualSize
-
- cmp dx,lifreehi ;Make sure we have enough
- jb fxLI_create
- ja fxLI_nomem
-
- cmp ax,lifreelo
- jbe fxLI_create
-
- fxLI_nomem:
-
- @SetRet liret,pcxERR_CMMNOMEM ;We don't, so set error
- cmp WORD PTR litype,pcxEMM ;Is this EMM?
- jne fxLI_nomemend ;If not, we are all set
-
- @SetRet liret,pcxERR_EMMNOMEM ;Set correct error
-
- fxLI_nomemend:
-
- jmp SHORT fxLI_exit
-
- fxLI_create:
-
- mov ax,litype ;Create the buffer
- push ax
- mov ax,livseg
- push ax
- mov ax,livofs
- push ax
-
- call pcxGetDisplay ;Get the current display
- cmp ds:[si].nplanes,1 ;Is the image B/W?
- jne fxLI_pushtype
- cmp ds:[si].bitpx,1
- jne fxLI_pushtype
- mov ax,pcxCGA_6 ;If yes, save space
-
- fxLI_pushtype:
-
- push ax
- mov ax,liwidth
- push ax
- mov ax,lidepth
- push ax
-
- call pcxCreateVirtual
-
- cmp ax,pcxSUCCESS ;Successful?
- je fxLI_file
-
- @SetRet liret,ax ;No, so set return code
- jmp SHORT fxLI_exit
-
- fxLI_file:
-
- @@LoadSeg es,livseg ;Get a pointer to vptr
- mov di,livofs
-
- mov ax,lilseg ;Load the library file
- push ax
- mov ax,lilofs
- push ax
- mov ax,lifseg
- push ax
- mov ax,lifofs
- push ax
- mov ax,es:[di+2]
- push ax
- mov ax,es:[di]
- push ax
-
- call pcxLibVirtual
-
- @SetRet liret,ax ;Return the code
-
- fxLI_exit:
-
- @Exit liret,liparm ;Return
-
- fxLibImage ENDP
-
- ;**********
-
- ;
- ; This procedure frees a previously loaded virtual image buffer.
- ;
- ; Calling: retcode = fxFreeImage(vptr)
- ;
- ;
-
- ;Define variable locations on the stack, depending on model
- rivseg equ <[bp+ 8]>
- rivofs equ <[bp+ 6]>
- riparm equ 4
-
- ;Define local variables
- riret equ <[bp-2]> ;return code
- rilocal equ 2 ;Total local space needed
-
- fxFreeImage PROC FAR
-
- @Entry rilocal ;Set up frame and save regs
-
- mov ax,rivseg ;Just chain to DestroyVirtual
- push ax
- mov ax,rivofs
- push ax
- call pcxDestroyVirtual
-
- @SetRet riret,ax ;Get the return code, and return
- ; it as ours
-
- @Exit riret,riparm ;Return
-
- fxFreeImage ENDP
-
- @EndCode
-
- END
-
-