home *** CD-ROM | disk | FTP | other *** search
- PAGE 60,132
- TITLE fxVI.ASM -- PCX Effects
- SUBTTL Copyright (c) Genus Microprogramming, Inc. 1988-89
-
- ; fxVI.ASM ;
- ; Copyright (c) Genus Microprogramming, Inc. 1988-89 All Rights Reserved. ;
-
- ;****************************************************************************;
- ; ;
- ; This file contains procedures for initializing and 'bumping' the virtual ;
- ; pointer, for both conventional and expanded memory. ;
- ; ;
- ; Procedures: fxVirtualInit ;
- ; fxVirtualBump ;
- ; ;
- ; ;
- ; 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 pcxMCheck : WORD
-
- fxvtype dw ?
- fxvhandle dw ?
- fxhpages dw ?
- fxlpage dw ?
-
- @EndData
-
- @BegCode
-
- EXTRN pcxGetDisplay : FAR
- EXTRN pcxGetDispStruc : FAR
-
- PUBLIC fxVirtualInit
- PUBLIC fxVirtualBump
-
- ;**********
-
- ;
- ; This procedure initializes the virtual buffer pointer, whether it is
- ; conventional or expanded.
- ;
- ;
-
- ;Define variable locations on the stack (pascal model)
- vivseg equ <[bp+ 8]> ;Virtual buffer pointer
- vivofs equ <[bp+ 6]> ; or EMM handle
- viparm equ 4
-
- ;Define local variables
- viret equ <[bp- 2]> ;return code
- vimcheck equ <[bp- 4]> ;return code
- vilocal equ 4 ;Total local space needed
-
- fxVirtualInit PROC FAR
-
- @Entry vilocal ;Set up frame and save regs
-
- mov ax,pcxMCheck ;Store mode check flag
- mov vimcheck,ax
-
- mov ax,vivseg ;Get the virtual memory type
- cmp ax,pcxEMM ;Is it an expanded memory buffer?
- je fxVI_EMM
-
- jmp SHORT fxVI_CMM ;Assume conventional memory
-
- fxVI_EMM:
-
- mov WORD PTR fxvtype,pcxEMM ;Set virtual type flag
-
- mov dx,vivofs ;Virtual ofs is really EMM handle
- mov fxvhandle,dx
-
- @EMM EMMhpages ;Get the number of handle pages
-
- or ah,ah ;See if successful
- jz fxVI_pages
-
- @SetRet viret,fxERR_EMMFAIL ;EMM failed
- jmp fxVI_exit
-
- fxVI_pages:
-
- mov fxhpages,bx ;Store total handle pages
- xor ax,ax
- mov fxlpage,ax ;And set the logical page to 0
-
- mov cx,fxhpages ;Put page count in cx
- mov ax,-1 ;Use ax as physical page
-
- cmp cx,4 ;Are there less than 4 pages?
- jbe fxVI_mappages ;If so, map them
-
- mov cx,4 ;Otherwise, map four
-
- fxVI_mappages:
-
- mov dx,fxvhandle ;Get the handle
- mov bx,fxlpage ;Get the logical page
- inc WORD PTR fxlpage ; 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 fxVI_mappages ;If so, map the next one
- je fxVI_frame ;If done, continue
-
- @SetRet viret,fxERR_EMMFAIL ;EMM failed
- jmp fxVI_exit
-
- fxVI_frame:
-
- @EMM EMMpframe ;Get the EMM page frame address
-
- or ah,ah ;Successful?
- jz fxVI_loadseg
-
- @SetRet viret,fxERR_EMMFAIL ;EMM failed
- jmp SHORT fxVI_exit
-
- fxVI_loadseg:
-
- @@LoadSeg ds,bx ;Frame segment returned in BX
- xor si,si ; (offset is always zero)
-
- jmp SHORT fxVI_verify ;Verify this is a PCX buffer
-
- fxVI_CMM:
-
- mov WORD PTR fxvtype,pcxCMM ;Set virtual type flag
-
- @@LoadSeg ds,vivseg ;Point to the buffer
- mov si,vivofs
-
- fxVI_verify:
-
- mov al,ds:[si].manuf ;Check the first byte
- cmp al,pcxmanuf ;Is it the pcx sign?
- je fxVI_getdisp ;If so, continue
-
- @SetRet viret,pcxERR_NOTPCX ;Not a PCX buffer
- jmp SHORT fxVI_exit ; so exit
-
- fxVI_getdisp:
-
- call pcxGetDisplay ;Get the current display type
- cmp ax,0
- jge fxVI_getstruc ;If no error, continue
-
- @SetRet viret,ax ;Bad Display type
- jmp SHORT fxVI_exit ; so exit
-
- fxVI_getstruc:
-
- push ax ;Argument is display type
- call pcxGetDispStruc ;Get the display structure (dx:ax)
- cmp ax,0
- jae fxVI_chkmode ;Successful?
-
- @SetRet viret,fxERR_GENERAL ;General error,
- jmp SHORT fxVI_exit ; so exit
-
- fxVI_chkmode:
-
- mov di,ax ;Put returned pointer into regs
- @@LoadSeg es,dx
-
- cmp WORD PTR vimcheck,TRUE ;Should we check the mode?
- jne fxVI_setptr
-
- cmp es:[di].dtype,pcxHERC ;Is this Hercules?
- je fxVI_setptr
-
- @GetMode ;Get the current display mode
- cmp al,es:[di].dmode ;Is this correct for buffer?
- je fxVI_setptr
-
- @SetRet viret,pcxERR_BADMODE ;Bad display mode
- jmp SHORT fxVI_exit ; so exit
-
- fxVI_setptr:
-
- mov dx,ds ;Return the pointer
- mov bx,si ; in DX:BX
-
- @SetRet viret,fxSUCCESS ;and set return code
-
- fxVI_exit:
-
- @Exit viret,viparm ;Return
-
- fxVirtualInit ENDP
-
- ;**********
-
- ;
- ; This procedure handles the virtual buffer pointer/page logic. For
- ; conventional memory, it simply bumps the segment register by 64K. For
- ; expanded memory, the next set of pages (if available) are swapped in.
- ;
-
- fxVirtualBump PROC FAR
-
- cmp WORD PTR fxvtype,pcxEMM ;Is this expanded?
- je fxVB_EMM
-
- push ax ;Save regs
-
- mov ax,ds ;Bump segment (for total 64K)
- add ax,1000H
- mov ds,ax
-
- pop ax ;Restore regs
-
- clc ;Successful, so clear carry
- jmp SHORT fxVB_ret ; and return
-
- fxVB_EMM:
-
- push ax ;Save regs for EMM mapping
- push bx
- push cx
- push dx
-
- mov cx,fxhpages ;Put page count in cx
- sub cx,fxlpage ; and sub current logical page
-
- cmp cx,0 ;Are there more pages?
- ja fxVB_morepages
-
- @SetRet viret,pcxERR_BUFSMALL ;Buffer was too small
- jmp SHORT fxVB_emmfail ; so exit (where we can pop!)
-
- fxVB_morepages:
-
- mov ax,-1 ;Use ax as physical page
-
- cmp cx,4 ;Are there less than 4 pages?
- jbe fxVB_bumppages ;If so, map them
-
- mov cx,4 ;Otherwise, map four
-
- fxVB_bumppages:
-
- mov dx,fxvhandle ;Get the handle
- mov bx,fxlpage ;Get the logical page
- inc WORD PTR fxlpage ; 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 fxVB_bumppages ;If so, map the next one
- jne fxVB_emmfail ;If error, failed
-
- clc ;Successful, so clear carry
- jmp SHORT fxVB_emmexit ; and exit
-
- fxVB_emmfail:
-
- @SetRet viret,fxERR_EMMFAIL ;EMM failed
- stc ; so set carry to indicate error
-
- fxVB_emmexit:
-
- pop dx ;Restore regs
- pop cx
- pop bx
- pop ax
-
- fxVB_ret:
-
- ret ;Return
-
- fxVirtualBump ENDP
-
- @EndCode
-
- END
-
-