home *** CD-ROM | disk | FTP | other *** search
- PAGE 60,132
- TITLE fxSimple.ASM -- PCX Effects
- SUBTTL Copyright (c) Genus Microprogramming, Inc. 1988-89
-
- ; fxSimple.ASM ;
- ; Copyright (c) Genus Microprogramming, Inc. 1988-89 All Rights Reserved. ;
-
- ;****************************************************************************;
- ; ;
- ; This program is the simplest example of effect usage. It is an example ;
- ; ASM routine for PCX Effects. ;
- ; ;
- ; To Assemble: masm fxSimple; ;
- ; link /CP:50 fxSimple,,,pcx_cs fx_cs; ;
- ; ;
- ; NOTE: REQUIRES A CGA (or compatible) ADAPTER AND DISPLAY! ;
- ; ;
- ; Microsoft ASM 5.x version. Programmer: Chris Howard 5/25/89 ;
- ; ;
- ;****************************************************************************;
-
- ; Include the PCX Toolkit defines
- INCLUDE pcxlib.asm
- INCLUDE fxlib.asm
-
- ; DOS Functions
- WRITE equ 09H ;Write a string (term. by EOM)
- EXIT equ 4CH ;Exit (TERMINATE)
-
- ; String Constants
- CR equ 13 ;Carriage return
- LF equ 10 ;Line feed
- EOM equ '$' ;End of Message
- ASCIIZ equ 0 ;End of string (ASCIIZ format)
-
- ; Macros
- @DOS MACRO func ;;Macro to use DOS function calls
- mov ah,func
- int 21H
- ENDM
-
- @Disp MACRO msg ;;Macro to display a string
- mov dx,OFFSET msg ;; at this location
- @DOS WRITE
- ENDM
-
- ; Start the program (small model)
- .model small
-
- ; Set aside some stack space
- .stack 100h
-
- ; Program data
- .data
-
- pcxtype dw pcxCGA_4
- pcximage db "fxSimple.PCX",ASCIIZ
- vptr dd ?
-
- header db CR,LF
- db " Simple Example Assembly PCX Effects Program ",CR,LF
- db CR,LF
- db "Press a key to run . . ."
- db EOM
-
- errmsg db CR,LF,CR,LF
- db "An error occured ...",CR,LF
- db CR,LF
- db "You may not have a CGA, or the image FXSIMPLE.PCX may not",CR,LF
- db "be in the current directory ...",CR,LF
- db CR,LF,EOM
-
- ; Program code
- .code
-
- EXTRN pcxSetBuffer : FAR
- EXTRN pcxSetDisplay : FAR
- EXTRN pcxSetMode : FAR
-
- EXTRN fxSetEffect : FAR
- EXTRN fxCalibrateDelay : FAR
- EXTRN fxFileImage : FAR
- EXTRN fxVirtualEffect : FAR
- EXTRN fxFreeImage : FAR
-
- ;**********
-
- fxSimple:
-
- ; Set up data and stack
-
- mov ax,@data ;Data
- mov ds,ax
-
- cli ;Stack
- mov ss,ax
- mov sp,OFFSET STACK
- sti
-
- ; Display program header
-
- @Disp header
-
- ; Get a key, to begin
-
- mov ah,0 ;Read Key function
- int 16H
-
- ; Set the display type
-
- mov ax,pcxtype ;Get the pcx image type
- push ax ; and push it on the stack
- call pcxSetDisplay ;Try to set the display type
-
- cmp ax,pcxSUCCESS ;Successful?
- je SETEFFECT
-
- jmp PCXERR ;No, so display error message
-
- SETEFFECT:
-
- ; Select our effect
-
- mov ax,fxSAND ;Use the SAND effect
- push ax
- call fxSetEffect
-
- ; Calibrate the delay timer
-
- call fxCalibrateDelay ;Calibrate the delay timer
-
- ; Load the image
-
- mov ax,pcxCMM ;Load into conventional memory
- push ax
- push ds ; point at vptr
- mov ax,OFFSET vptr
- push ax
- push ds
- mov ax,OFFSET pcximage ; and filename
- push ax
- call fxFileImage
-
- cmp ax,fxSUCCESS ;Successful?
- je SETMODE
-
- jmp PCXERR ;No, so display error
-
- SETMODE:
-
- ; Now enter graphics mode
-
- mov ax,pcxGRAPH ;Use graphics constant
- push ax
- call pcxSetMode ; and set the mode
-
- cmp ax,pcxSUCCESS ;Successful?
- je EFFECT
-
- jmp PCXERR ;No, so error
-
- ; and do it
-
- EFFECT:
-
- mov ax,WORD PTR vptr[2] ;Pass VALUE of vptr
- push ax
- mov ax,WORD PTR vptr
- push ax
- xor ax,ax ;Get a zero
- push ax ; and set (x,y) to zero
- push ax
- mov ax,fxNONE ;No direction needed for SAND
- push ax
- call fxVirtualEffect
-
- ; Wait for a key
-
- KEY:
-
- mov ah,0 ;Read Key function
- int 16H
-
- ; Return to text mode
-
- mov ax,pcxTEXT ;Use text constant
- push ax
- call pcxSetMode ; and set the mode
-
- ; Free the image from memory
-
- mov ax,WORD PTR vptr[2] ;Pass the VALUE of vptr
- push ax
- mov ax,WORD PTR vptr
- push ax
- call fxFreeImage
-
- jmp PCXEXIT
-
- ; If an error occured, display error message
-
- PCXERR:
-
- @Disp errmsg
-
- PCXEXIT:
-
- @DOS EXIT ;Exit back to DOS
-
- END fxSimple
-
-