home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c011 / 4.ddi / EXAMPLES / ASM / FXSIMPLE.ASM
Encoding:
Assembly Source File  |  1989-06-01  |  6.4 KB  |  212 lines

  1.   PAGE    60,132
  2.   TITLE   fxSimple.ASM -- PCX Effects
  3.   SUBTTL  Copyright (c) Genus Microprogramming, Inc. 1988-89
  4.  
  5. ; fxSimple.ASM                                                               ;
  6. ; Copyright (c) Genus Microprogramming, Inc. 1988-89  All Rights Reserved.   ;
  7.  
  8. ;****************************************************************************;
  9. ;                                                                            ;
  10. ; This program is the simplest example of effect usage. It is an example     ;
  11. ; ASM routine for PCX Effects.                                               ;
  12. ;                                                                            ;
  13. ; To Assemble: masm fxSimple;                                                ;
  14. ;              link /CP:50 fxSimple,,,pcx_cs fx_cs;                          ;
  15. ;                                                                            ;
  16. ; NOTE: REQUIRES A CGA (or compatible) ADAPTER AND DISPLAY!                  ;
  17. ;                                                                            ;
  18. ; Microsoft ASM 5.x version.              Programmer: Chris Howard  5/25/89  ;
  19. ;                                                                            ;
  20. ;****************************************************************************;
  21.  
  22. ; Include the PCX Toolkit defines
  23.   INCLUDE pcxlib.asm
  24.   INCLUDE fxlib.asm
  25.  
  26. ; DOS Functions
  27. WRITE     equ       09H                     ;Write a string (term. by EOM)
  28. EXIT      equ       4CH                     ;Exit (TERMINATE)
  29.  
  30. ; String Constants
  31. CR        equ       13                      ;Carriage return
  32. LF        equ       10                      ;Line feed
  33. EOM       equ       '$'                     ;End of Message
  34. ASCIIZ    equ       0                       ;End of string (ASCIIZ format)
  35.  
  36. ; Macros
  37. @DOS      MACRO     func                    ;;Macro to use DOS function calls
  38.           mov       ah,func
  39.           int       21H
  40.           ENDM
  41.  
  42. @Disp     MACRO     msg                     ;;Macro to display a string
  43.           mov       dx,OFFSET msg           ;; at this location
  44.           @DOS      WRITE
  45.           ENDM
  46.  
  47. ; Start the program (small model)
  48.   .model small
  49.  
  50. ; Set aside some stack space
  51.   .stack 100h
  52.  
  53. ; Program data
  54.   .data
  55.  
  56. pcxtype   dw        pcxCGA_4 
  57. pcximage  db        "fxSimple.PCX",ASCIIZ
  58. vptr      dd        ?
  59.  
  60. header    db        CR,LF
  61.           db        " Simple Example Assembly PCX Effects Program ",CR,LF
  62.           db        CR,LF
  63.           db        "Press a key to run . . ."
  64.           db        EOM
  65.  
  66. errmsg    db        CR,LF,CR,LF
  67.           db        "An error occured ...",CR,LF
  68.           db        CR,LF
  69.           db        "You may not have a CGA, or the image FXSIMPLE.PCX may not",CR,LF
  70.           db        "be in the current directory ...",CR,LF
  71.           db        CR,LF,EOM
  72.  
  73. ; Program code
  74.   .code
  75.  
  76.           EXTRN     pcxSetBuffer            : FAR
  77.           EXTRN     pcxSetDisplay           : FAR
  78.           EXTRN     pcxSetMode              : FAR
  79.  
  80.           EXTRN     fxSetEffect             : FAR
  81.           EXTRN     fxCalibrateDelay        : FAR
  82.           EXTRN     fxFileImage             : FAR
  83.           EXTRN     fxVirtualEffect         : FAR
  84.           EXTRN     fxFreeImage             : FAR
  85.  
  86. ;**********
  87.  
  88. fxSimple:
  89.  
  90. ; Set up data and stack
  91.  
  92.           mov       ax,@data                ;Data
  93.           mov       ds,ax
  94.  
  95.           cli                               ;Stack
  96.           mov       ss,ax
  97.           mov       sp,OFFSET STACK
  98.           sti
  99.  
  100. ; Display program header
  101.  
  102.           @Disp     header
  103.  
  104. ; Get a key, to begin
  105.  
  106.           mov       ah,0                    ;Read Key function
  107.           int       16H
  108.  
  109. ; Set the display type
  110.  
  111.           mov       ax,pcxtype              ;Get the pcx image type
  112.           push      ax                      ; and push it on the stack
  113.           call      pcxSetDisplay           ;Try to set the display type
  114.  
  115.           cmp       ax,pcxSUCCESS           ;Successful?
  116.           je        SETEFFECT
  117.  
  118.           jmp       PCXERR                  ;No, so display error message
  119.  
  120. SETEFFECT:
  121.  
  122. ; Select our effect
  123.  
  124.           mov       ax,fxSAND               ;Use the SAND effect
  125.           push      ax
  126.           call      fxSetEffect
  127.  
  128. ; Calibrate the delay timer
  129.  
  130.           call      fxCalibrateDelay        ;Calibrate the delay timer
  131.  
  132. ; Load the image
  133.  
  134.           mov       ax,pcxCMM               ;Load into conventional memory
  135.           push      ax
  136.           push      ds                      ; point at vptr
  137.           mov       ax,OFFSET vptr
  138.           push      ax
  139.           push      ds
  140.           mov       ax,OFFSET pcximage      ; and filename
  141.           push      ax
  142.           call      fxFileImage
  143.  
  144.           cmp       ax,fxSUCCESS            ;Successful?
  145.           je        SETMODE
  146.  
  147.           jmp       PCXERR                  ;No, so display error
  148.  
  149. SETMODE:
  150.  
  151. ; Now enter graphics mode
  152.  
  153.           mov       ax,pcxGRAPH             ;Use graphics constant
  154.           push      ax
  155.           call      pcxSetMode              ; and set the mode
  156.  
  157.           cmp       ax,pcxSUCCESS           ;Successful?
  158.           je        EFFECT
  159.  
  160.           jmp       PCXERR                  ;No, so error
  161.  
  162. ; and do it
  163.  
  164. EFFECT:
  165.  
  166.           mov       ax,WORD PTR vptr[2]     ;Pass VALUE of vptr
  167.           push      ax
  168.           mov       ax,WORD PTR vptr      
  169.           push      ax
  170.           xor       ax,ax                   ;Get a zero
  171.           push      ax                      ; and set (x,y) to zero
  172.           push      ax
  173.           mov       ax,fxNONE               ;No direction needed for SAND
  174.           push      ax
  175.           call      fxVirtualEffect
  176.  
  177. ; Wait for a key
  178.  
  179. KEY:
  180.  
  181.           mov       ah,0                    ;Read Key function
  182.           int       16H
  183.  
  184. ; Return to text mode
  185.  
  186.           mov       ax,pcxTEXT              ;Use text constant
  187.           push      ax
  188.           call      pcxSetMode              ; and set the mode
  189.  
  190. ; Free the image from memory
  191.         
  192.           mov       ax,WORD PTR vptr[2]     ;Pass the VALUE of vptr
  193.           push      ax
  194.           mov       ax,WORD PTR vptr   
  195.           push      ax
  196.           call      fxFreeImage
  197.  
  198.           jmp       PCXEXIT
  199.  
  200. ; If an error occured, display error message
  201.  
  202. PCXERR:
  203.  
  204.           @Disp     errmsg
  205.  
  206. PCXEXIT:
  207.  
  208.           @DOS      EXIT                    ;Exit back to DOS
  209.  
  210.           END       fxSimple
  211.  
  212.