home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c011 / 1.ddi / SOURCE / FXVE.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-06-01  |  12.3 KB  |  368 lines

  1.   PAGE    60,132
  2.   TITLE   fxVE.ASM -- PCX Effects
  3.   SUBTTL  Copyright (c) Genus Microprogramming, Inc. 1988-89
  4.  
  5. ; fxVE.ASM                                                                   ;
  6. ; Copyright (c) Genus Microprogramming, Inc. 1988-89  All Rights Reserved.   ;
  7.  
  8. ;****************************************************************************;
  9. ;                                                                            ;
  10. ; This file contains procedures for taking a pcx virtual buffer and          ;
  11. ; displaying it with a special effect on the current adapter configuration.  ;
  12. ;                                                                            ;
  13. ; Procedures: fxVirtualEffect                                                ;
  14. ;                                                                            ;
  15. ;                                                                            ;
  16. ;                                                                            ;
  17. ; Microsoft ASM 5.x version.              Programmer: Chris Howard  3/15/89  ;
  18. ;                                                                            ;
  19. ;****************************************************************************;
  20.  
  21. ; Include files
  22.   INCLUDE ..\inc\pcxDefs.inc
  23.   INCLUDE ..\inc\pcxMacs.inc
  24.   INCLUDE ..\inc\pcxErrs.inc
  25.  
  26.   INCLUDE ..\inc\fxDefs.inc
  27.   INCLUDE ..\inc\fxMacs.inc
  28.   INCLUDE ..\inc\fxErrs.inc
  29.  
  30.   @SetModel
  31.  
  32.   @BegData
  33.  
  34.           EXTRN     fxVinit                 : BYTE
  35.  
  36.   @EndData
  37.  
  38.   @BegCode
  39.  
  40.           EXTRN     pcxGetDisplay           : FAR
  41.           EXTRN     pcxGetDispStruc         : FAR
  42.  
  43.           EXTRN     fxGetEffect             : FAR
  44.           EXTRN     fxGetEffectStruc        : FAR
  45.           EXTRN     fxGetGrain              : FAR
  46.           EXTRN     fxGetDelay              : FAR
  47.  
  48.           EXTRN     fxVirtualWipe           : FAR
  49.           EXTRN     fxVirtualSplit          : FAR
  50.           EXTRN     fxVirtualCrush          : FAR
  51.           EXTRN     fxVirtualSlide          : FAR
  52.           EXTRN     fxVirtualSand           : FAR
  53.           EXTRN     fxVirtualDrip           : FAR
  54.           EXTRN     fxVirtualExplode        : FAR
  55.           EXTRN     fxVirtualDiag           : FAR
  56.           EXTRN     fxVirtualSpiral         : FAR
  57.           EXTRN     fxVirtualRandom         : FAR
  58.  
  59.           PUBLIC    fxVirtualEffect 
  60.  
  61. ;**********
  62.  
  63. ;
  64. ; This procedure is the main entry point for the virtual effect functions.
  65. ; It determines the appropriate parameters, and passes them off to the
  66. ; correct effect routine.
  67. ;
  68. ;
  69.  
  70. ;Define variable locations on the stack  (pascal model)
  71.  
  72. ; (defined in fxdefs.inc ...)
  73.  
  74. ;Define local variables
  75.  
  76. ; (defined in fxdefs.inc ...)
  77.  
  78. fxVirtualEffect     PROC FAR
  79.  
  80.           @Entry    velocal                 ;Set up frame and save regs
  81.  
  82.           cmp       fxVinit,TRUE            ;Have we initialized jump table?
  83.           je        fxVE_start
  84.  
  85.           call      FAR PTR fxVirtualInit   ;If not, do it
  86.  
  87. fxVE_start:
  88.  
  89.           mov       ax,vevseg               ;Get the virtual memory type
  90.           cmp       ax,pcxEMM               ;Is it an expanded memory buffer?
  91.           je        fxVE_EMM
  92.  
  93.           jmp       SHORT fxVE_CMM          ;Assume conventional memory
  94.  
  95. fxVE_EMM:
  96.  
  97.           mov       dx,vevofs               ;Virtual ofs is really EMM handle
  98.           mov       vehandle,dx
  99.  
  100.           @EMM      EMMhpages               ;Get the number of handle pages
  101.  
  102.           or        ah,ah                   ;See if successful
  103.           jz        fxVE_pages
  104.  
  105.           @SetRet   veret,fxERR_EMMFAIL     ;EMM failed
  106.           jmp       fxVE_exit
  107.  
  108. fxVE_pages:
  109.  
  110.           mov       vehpages,bx             ;Store total handle pages
  111.           xor       ax,ax
  112.           mov       velpage,ax              ;And set the logical page to 0
  113.  
  114.           mov       cx,vehpages             ;Put page count in cx
  115.           mov       ax,-1                   ;Use ax as physical page
  116.  
  117.           cmp       cx,4                    ;Are there less than 4 pages?
  118.           jbe       fxVE_mappages           ;If so, map them
  119.  
  120.           mov       cx,4                    ;Otherwise, map four
  121.  
  122. fxVE_mappages:
  123.  
  124.           mov       dx,vehandle             ;Get the handle
  125.           mov       bx,velpage              ;Get the logical page
  126.           inc       WORD PTR velpage        ; and bump it
  127.           inc       ax                      ;Bump physical page
  128.  
  129.           push      ax                      ; and save it
  130.           @EMM      EMMmpages               ;Map this page
  131.           or        ah,ah                   ;Successful?
  132.           pop       ax                      ; (retrieve physical ...)
  133.  
  134.           loope     fxVE_mappages           ;If so, map the next one
  135.           je        fxVE_frame              ;If done, continue
  136.  
  137.           @SetRet   veret,fxERR_EMMFAIL     ;EMM failed
  138.           jmp       fxVE_exit
  139.  
  140. fxVE_frame:
  141.  
  142.           @EMM      EMMpframe               ;Get the EMM page frame address
  143.  
  144.           or        ah,ah                   ;Successful?
  145.           jz        fxVE_loadseg
  146.  
  147.           @SetRet   veret,fxERR_EMMFAIL     ;EMM failed
  148.           jmp       fxVE_exit
  149.  
  150. fxVE_loadseg:
  151.  
  152.           @@LoadSeg ds,bx                   ;Frame segment returned in BX
  153.           xor       si,si                   ; (offset is always zero)
  154.  
  155.           jmp       SHORT fxVE_getdisp      ;Get the display type
  156.  
  157. fxVE_CMM:
  158.  
  159.           @@LoadSeg ds,vevseg               ;Point to the buffer
  160.           mov       si,vevofs
  161.  
  162. fxVE_getdisp:
  163.  
  164.           call      pcxGetDisplay           ;Get the current display type
  165.           cmp       ax,0
  166.           jge       fxVE_getstruc           ;If no error, continue
  167.  
  168.           @SetRet   veret,ax                ;Bad Display type
  169.           jmp       fxVE_exit               ; so exit
  170.  
  171. fxVE_getstruc:
  172.  
  173.           push      ax                      ;Argument is display type
  174.           call      pcxGetDispStruc         ;Get the display structure (dx:ax)
  175.           cmp       ax,0
  176.           jae       fxVE_getres             ;Successful?
  177.  
  178.           @SetRet   veret,fxERR_GENERAL     ;General error,
  179.           jmp       fxVE_exit               ; so exit
  180.  
  181. fxVE_getres:
  182.  
  183.           mov       di,ax                   ;Put returned pointer into regs
  184.           @@LoadSeg es,dx
  185.  
  186.           mov       ax,es:[di].dhres        ;Store the horizontal res
  187.           dec       ax
  188.           mov       vehres,ax
  189.  
  190.           mov       ax,es:[di].dvres        ; and vertical res locally
  191.           dec       ax
  192.           mov       vevres,ax
  193.  
  194. fxVE_calc:
  195.  
  196.           mov       ax,vex                  ;Get the X location
  197.           mov       bl,ds:[si].bitpx        ; and the bits per pixel
  198.           xor       bh,bh
  199.           mul       bx                      ; multiply
  200.           mov       bl,8                    ; and divide by bits per byte
  201.           div       bx
  202.           cmp       dx,0                    ;Are we at a byte boundary?
  203.           je        fxVE_width              ;If so, we are all set
  204.  
  205.           xor       dh,dh                   ;Clear high byte
  206.           sub       vex,dx                  ; and adjust X location
  207.  
  208. fxVE_width:
  209.  
  210.           mov       ax,ds:[si].x2           ;Calculate the image width
  211.           sub       ax,ds:[si].x1
  212.           inc       ax
  213.           mov       vewidth,ax
  214.  
  215.           mov       bl,ds:[si].bitpx        ;Get the bits per pixel
  216.           xor       bh,bh
  217.           mul       bx                      ; multiply
  218.           mov       bl,8                    ; and divide by bits per byte
  219.           div       bx
  220.           cmp       dx,0                    ;Is there an exact # of bytes?
  221.           je        fxVE_edge               ;If so, we are all set
  222.  
  223.           sub       bl,dl                   ;Otherwise, get the difference
  224.           xor       bh,bh                   ; and clear high byte
  225.  
  226.           add       ds:[si].x2,bx           ;Increase image width in header
  227.           add       vewidth,bx              ; and locally
  228.  
  229. fxVE_edge:
  230.  
  231.           mov       ax,vewidth              ;Put width back into AX
  232.           add       ax,vex                  ;Calculate window edge
  233.           dec       ax
  234.           mov       vex2,ax                 ; and store
  235.  
  236.           cmp       ax,vehres               ;Is it beyond the screen edge?
  237.           jle       fxVE_depth              ;If not, calc depth
  238.  
  239.           mov       ax,vehres               ;If so, truncate at screen
  240.           mov       vex2,ax
  241.  
  242.           sub       ax,vex                  ;Recalc the image width
  243.           inc       ax                      
  244.           mov       vewidth,ax
  245.  
  246. fxVE_depth:
  247.  
  248.           mov       ax,ds:[si].y2           ;Calculate the image depth
  249.           sub       ax,ds:[si].y1
  250.           inc       ax
  251.           mov       vedepth,ax
  252.  
  253.           add       ax,vey                  ;Calculate the window edge
  254.           dec       ax
  255.           mov       vey2,ax
  256.  
  257.           cmp       ax,vevres               ;Is it beyond the screen edge?
  258.           jle       fxVE_gethalf            ;If not, get the half marks
  259.  
  260.           mov       ax,vevres               ;If so, truncate at screen
  261.           mov       vey2,ax
  262.  
  263.           sub       ax,vey                  ;Recalc the image depth
  264.           inc       ax                      
  265.           mov       vedepth,ax
  266.  
  267. fxVE_gethalf:
  268.  
  269.           mov       ax,vewidth              ;Get the width
  270.           shr       ax,1                    ; and divide by two
  271.           mov       vevhalf,ax              ; and store as half mark
  272.  
  273.           mov       ax,vedepth              ;Get the depth
  274.           shr       ax,1                    ; and divide by two
  275.           mov       vehhalf,ax              ; and store as half mark
  276.  
  277. fxVE_getgrain:
  278.  
  279.           call      fxGetGrain              ;Get the effect granularity
  280.           mov       vegrain,ax              ; and store locally
  281.  
  282.           cmp       BYTE PTR ds:[si].bitpx,8  ;Is this a 256-color mode?
  283.           je        fxVE_setvgrain
  284.  
  285.           and       ax,11111000B            ;Mask to a byte boundary
  286.           jnz       fxVE_setvgrain
  287.  
  288.           mov       ax,8                    ;Bump to at least 8
  289.  
  290. fxVE_setvgrain:
  291.  
  292.           mov       vevgrain,ax             ;Store the vertical grain
  293.  
  294. fxVE_getdelay:
  295.  
  296.           call      fxGetDelay              ;Get the effect delay
  297.           mov       vedelay,ax              ; and store locally
  298.  
  299.           @BIOS     GETMODE                 ;Get the current page
  300.           xchg      bh,bl
  301.           xor       bh,bh
  302.           mov       vepage,bh               ; and store locally
  303.  
  304. fxVE_geteffect:
  305.  
  306.           call      fxGetEffect             ;Get the current effect type
  307.           cmp       ax,0
  308.           jge       fxVE_getfxstruc         ;If no error, continue
  309.  
  310.           @SetRet   veret,ax                ;Bad Effect type
  311.           jmp       SHORT fxVE_exit         ; so exit
  312.  
  313. fxVE_getfxstruc:
  314.  
  315.           push      ax                      ;Argument is effect type
  316.           call      fxGetEffectStruc        ;Get the effect struc (dx:ax)
  317.           cmp       ax,0
  318.           jae       fxVE_callproc           ;Successful?
  319.  
  320.           @SetRet   veret,fxERR_GENERAL     ;General error,
  321.           jmp       SHORT fxVE_exit         ; so exit
  322.  
  323. fxVE_callproc:
  324.  
  325.           mov       di,ax                   ;Put returned pointer into regs
  326.           @@LoadSeg es,dx
  327.  
  328.           @@Data    ds                      ;Point to our own data
  329.  
  330.           jmp       es:[di].fxfunc          ;Jump to effect function
  331.  
  332. fxVE_exit:
  333.  
  334.           @Exit     veret,veparm            ;Return
  335.  
  336. fxVirtualEffect     ENDP
  337.  
  338. ;**********
  339.  
  340. ;
  341. ; This procedure is called only once, when the first VirtualEffect function
  342. ; call is made.
  343. ;
  344.  
  345. fxVirtualInit       PROC FAR
  346.  
  347.           @InitFX   fxWIPE,fxVirtualWipe    ;Initialize jump tables
  348.           @InitFX   fxSPLIT,fxVirtualSplit
  349.           @InitFX   fxCRUSH,fxVirtualCrush
  350.           @InitFX   fxSLIDE,fxVirtualSlide
  351.           @InitFX   fxSAND,fxVirtualSand
  352.           @InitFX   fxDRIP,fxVirtualDrip
  353.           @InitFX   fxEXPLODE,fxVirtualExplode
  354.           @InitFX   fxDIAG,fxVirtualDiag
  355.           @InitFX   fxSPIRAL,fxVirtualSpiral
  356.           @InitFX   fxRANDOM,fxVirtualRandom
  357.  
  358.           mov       fxVinit,TRUE            ;And indicate we are initialized
  359.  
  360.           ret
  361.  
  362. fxVirtualInit       ENDP
  363.  
  364.   @EndCode
  365.  
  366.           END
  367.  
  368.