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

  1.   PAGE    60,132
  2.   TITLE   fxVX.ASM -- PCX Effects
  3.   SUBTTL  Copyright (c) Genus Microprogramming, Inc. 1988-89
  4.  
  5. ; fxVX.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. ; 'exploding' it on the display.                                             ;
  12. ;                                                                            ;
  13. ; Procedures: fxVirtualExplode                                               ;
  14. ;                                                                            ;
  15. ;                                                                            ;
  16. ;                                                                            ;
  17. ; Microsoft ASM 5.x version.              Programmer: Chris Howard  5/02/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.   @EndData
  34.  
  35.   @BegCode
  36.  
  37.           EXTRN     pcxVirtualDisplay       : FAR
  38.           EXTRN     fxEffectDelay           : FAR
  39.  
  40.           PUBLIC    fxVirtualExplode    
  41.  
  42. ;**********
  43.  
  44. ;
  45. ; This is the Virtual Explode effect procedure, for the fxVirtualEffect
  46. ; interface.  It is an INTERNAL routine only.
  47. ;
  48. ; On Entry:  SS:BP    points to pcxVirtualEffect frame
  49. ;            ES:DI    points to display structure
  50. ;            DS:SI    points to buffer
  51. ;
  52. ; On Exit:   retcode  contains error code, if any
  53. ;
  54.  
  55. fxVirtualExplode    PROC FAR
  56.  
  57.           mov       ax,vedir                ;What direction?
  58.           cmp       ax,fxIN                 ;IN? 
  59.           je        fxVX_in 
  60.  
  61.           jmp       fxVX_out                ;Default to OUT ...
  62.  
  63. fxVX_in:
  64.  
  65.           mov       ax,vedepth              ;Get the depth
  66.           sub       ax,vevgrain             ; and sub the grain
  67.           dec       ax
  68.           mov       veloopmax,ax            ;Store as the loop maximum
  69.           
  70.           mov       si,0                    ;Initialize loop counters
  71.           mov       di,vevgrain
  72.           inc       di
  73.  
  74.           mov       ax,veloopmax            ; and get others
  75.           push      ax
  76.           push      di
  77.           push      si
  78.  
  79. fxVX_invert:
  80.  
  81.           mov       ax,vevhalf              ;Get the middle
  82.           sub       ax,vevgrain             ;Sub the grain
  83.           mov       veloopmax,ax            ;Store as the loop maximum
  84.           
  85.           mov       si,0                    ;Initialize left 
  86.           mov       di,vevgrain             ; and right loop counters
  87.  
  88. fxVX_invertloop:
  89.  
  90.           mov       ax,vevseg               ;vptr
  91.           push      ax
  92.           mov       ax,vevofs
  93.           push      ax
  94.  
  95.           mov       dx,si
  96.           cmp       dx,veloopmax            ;Is loop past a grain increment?
  97.           jle       fxVX_inrightvx          ;If not, continue
  98.  
  99.           mov       dx,veloopmax            ;Otherwise, reset
  100.  
  101. fxVX_inrightvx:
  102.  
  103.           push      dx                      ;vx   = loop
  104.           xor       ax,ax                   ;vy   = 0
  105.           push      ax
  106.           mov       bx,vex                  ;x    = x+loop
  107.           add       bx,dx
  108.           push      bx
  109.           mov       ax,vey                  ;y    = y     
  110.           push      ax
  111.           add       bx,vevgrain             ;x2   = x+loop+grain
  112.           push      bx                           
  113.           mov       ax,vey2                 ;y2   = y2
  114.           push      ax
  115.           mov       ax,vepage               ;page = current
  116.           push      ax                      
  117.  
  118.           call      pcxVirtualDisplay       ;Display this part
  119.  
  120.           mov       ax,vevseg               ;vptr
  121.           push      ax
  122.           mov       ax,vevofs
  123.           push      ax
  124.  
  125.           cmp       di,vewidth              ;Is loop past a grain increment?
  126.           jle       fxVX_inleftvx           ;If not, continue
  127.  
  128.           mov       di,vewidth              ;Otherwise, reset
  129.  
  130. fxVX_inleftvx:
  131.  
  132.           mov       ax,vewidth              ;vx   = width-loop
  133.           sub       ax,di
  134.           push      ax
  135.           xor       ax,ax                   ;vy   = 0
  136.           push      ax
  137.           mov       bx,vex2                 ;x    = x2-loop
  138.           inc       bx
  139.           sub       bx,di
  140.           push      bx
  141.           mov       ax,vey                  ;y    = y     
  142.           push      ax
  143.           add       bx,vevgrain             ;x2   = x2-loop+grain
  144.           push      bx                           
  145.           mov       ax,vey2                 ;y2   = y2
  146.           push      ax
  147.           mov       ax,vepage               ;page = current
  148.           push      ax                      
  149.  
  150.           call      pcxVirtualDisplay       ;Display this part
  151.  
  152.           pop       ax                      ;Get previous pointers
  153.           pop       bx
  154.           pop       cx
  155.  
  156.           mov       dx,veloopmax            ; and get others
  157.           push      dx
  158.           push      di
  159.           push      si                      
  160.  
  161.           mov       si,ax                   ;Put into appropriate regs
  162.           mov       di,bx
  163.  
  164.           mov       veloopmax,cx
  165.  
  166. fxVX_inhorizloop:
  167.  
  168.           mov       ax,vevseg               ;vptr
  169.           push      ax
  170.           mov       ax,vevofs
  171.           push      ax
  172.           xor       ax,ax                   ;vx   = 0
  173.           push      ax
  174.  
  175.           mov       dx,si
  176.           cmp       dx,veloopmax            ;Is loop past a grain increment?
  177.           jle       fxVX_indownvy           ;If not, continue
  178.  
  179.           mov       dx,veloopmax            ;Otherwise, reset
  180.  
  181. fxVX_indownvy:
  182.  
  183.           push      dx                      ;vy   = loop
  184.           mov       ax,vex                  ;x    = x
  185.           push      ax
  186.           mov       bx,vey                  ;y    = y+loop
  187.           add       bx,dx
  188.           push      bx
  189.           mov       ax,vex2                 ;x2   = x2
  190.           push      ax                           
  191.           add       bx,vevgrain             ;y2   = y+loop+grain
  192.           push      bx
  193.           mov       ax,vepage               ;page = current
  194.           push      ax                      
  195.  
  196.           call      pcxVirtualDisplay       ;Display this part
  197.  
  198.           mov       ax,vevseg               ;vptr
  199.           push      ax
  200.           mov       ax,vevofs
  201.           push      ax
  202.           xor       ax,ax                   ;vx   = 0
  203.           push      ax
  204.  
  205.           cmp       di,vedepth              ;Is loop past a grain increment?
  206.           jle       fxVX_inupvy             ;If not, continue
  207.  
  208.           mov       di,vedepth              ;Otherwise, reset
  209.  
  210. fxVX_inupvy:
  211.  
  212.           mov       ax,vedepth              ;vy   = depth-loop
  213.           sub       ax,di
  214.           push      ax                      
  215.           mov       ax,vex                  ;x    = x
  216.           push      ax
  217.           mov       bx,vey2                 ;y    = y2-loop
  218.           inc       bx
  219.           sub       bx,di
  220.           push      bx
  221.           mov       ax,vex2                 ;x2   = x2
  222.           push      ax
  223.           add       bx,vevgrain             ;y2   = y2-loop+grain
  224.           push      bx
  225.           mov       ax,vepage               ;page = current
  226.           push      ax
  227.  
  228.           call      pcxVirtualDisplay       ;Display this part
  229.  
  230.           mov       ax,vedelay              ;Get the delay count
  231.           push      ax
  232.  
  233.           call      fxEffectDelay           ; and delay
  234.  
  235.           jnc       fxVX_inhorizbump        ;If no error, continue
  236.           jmp       fxVX_error              
  237.  
  238. fxVX_inhorizbump:
  239.  
  240.           add       di,vevgrain             ;Bump our loop counters
  241.           add       si,vevgrain                                    
  242.           cmp       si,vehhalf              ;Have we done the entire image?
  243.           jl        fxVX_inhorizdone        ;If not, continue
  244.  
  245.           sub       di,vevgrain
  246.           sub       si,vevgrain
  247.  
  248. fxVX_inhorizdone:
  249.  
  250.           pop       ax                      ;Get previous pointers
  251.           pop       bx
  252.           pop       cx
  253.  
  254.           mov       dx,veloopmax            ; and get others
  255.           push      dx
  256.           push      di
  257.           push      si                      
  258.  
  259.           mov       si,ax                   ;Put into appropriate regs
  260.           mov       di,bx
  261.  
  262.           mov       veloopmax,cx
  263.  
  264.           cmp       si,veloopmax            ;Have we done the entire image?
  265.           jge       fxVX_invertdone
  266.  
  267.           add       si,vevgrain             ;Bump our loop counters
  268.           add       di,vevgrain
  269.           jmp       fxVX_invertloop         ; and loop
  270.  
  271. fxVX_invertdone:
  272.  
  273.           pop       dx                      ;Get rid of stack variables
  274.           pop       dx
  275.           pop       dx
  276.  
  277.           @SetRet   veret,fxSUCCESS         ;Set the return code
  278.           jmp       fxVX_exit               ; and exit
  279.  
  280. fxVX_out:
  281.  
  282.           mov       ax,vedepth              ;Get the depth
  283.           sub       ax,vevgrain             ; and sub the grain
  284.           dec       ax
  285.           mov       veloopmax,ax            ;Store as the loop maximum
  286.           
  287.           mov       si,vehhalf              ;Initialize loop counters
  288.           mov       di,vehhalf
  289.           inc       di
  290.  
  291.           mov       ax,veloopmax            ; and get others
  292.           push      ax
  293.           push      di
  294.           push      si
  295.  
  296. fxVX_vert:
  297.  
  298.           mov       ax,vewidth              ;Get the middle
  299.           sub       ax,vevgrain             ;Sub the grain
  300.           mov       veloopmax,ax            ;Store as the loop maximum
  301.           
  302.           mov       si,vevhalf              ;Initialize left 
  303.           mov       di,vevhalf              ; and right loop counters
  304.           add       di,vevgrain
  305.  
  306. fxVX_vertloop:
  307.  
  308.           mov       ax,vevseg               ;vptr
  309.           push      ax
  310.           mov       ax,vevofs
  311.           push      ax
  312.  
  313.           mov       dx,si
  314.           cmp       dx,veloopmax            ;Is loop past a grain increment?
  315.           jle       fxVX_rightvx            ;If not, continue
  316.  
  317.           mov       dx,veloopmax            ;Otherwise, reset
  318.  
  319. fxVX_rightvx:
  320.  
  321.           push      dx                      ;vx   = loop
  322.           xor       ax,ax                   ;vy   = 0
  323.           push      ax
  324.           mov       bx,vex                  ;x    = x+loop
  325.           add       bx,dx
  326.           push      bx
  327.           mov       ax,vey                  ;y    = y     
  328.           push      ax
  329.           add       bx,vevgrain             ;x2   = x+loop+grain
  330.           push      bx                           
  331.           mov       ax,vey2                 ;y2   = y2
  332.           push      ax
  333.           mov       ax,vepage               ;page = current
  334.           push      ax                      
  335.  
  336.           call      pcxVirtualDisplay       ;Display this part
  337.  
  338.           mov       ax,vevseg               ;vptr
  339.           push      ax
  340.           mov       ax,vevofs
  341.           push      ax
  342.  
  343.           cmp       di,vewidth              ;Is loop past a grain increment?
  344.           jle       fxVX_leftvx             ;If not, continue
  345.  
  346.           mov       di,vewidth              ;Otherwise, reset
  347.  
  348. fxVX_leftvx:
  349.  
  350.           mov       ax,vewidth              ;vx   = width-loop
  351.           sub       ax,di
  352.           push      ax
  353.           xor       ax,ax                   ;vy   = 0
  354.           push      ax
  355.           mov       bx,vex2                 ;x    = x2-loop
  356.           inc       bx
  357.           sub       bx,di
  358.           push      bx
  359.           mov       ax,vey                  ;y    = y     
  360.           push      ax
  361.           add       bx,vevgrain             ;x2   = x2-loop+grain
  362.           push      bx                           
  363.           mov       ax,vey2                 ;y2   = y2
  364.           push      ax
  365.           mov       ax,vepage               ;page = current
  366.           push      ax                      
  367.  
  368.           call      pcxVirtualDisplay       ;Display this part
  369.  
  370.           pop       ax                      ;Get previous pointers
  371.           pop       bx
  372.           pop       cx
  373.  
  374.           mov       dx,veloopmax            ; and get others
  375.           push      dx
  376.           push      di
  377.           push      si                      
  378.  
  379.           mov       si,ax                   ;Put into appropriate regs
  380.           mov       di,bx
  381.  
  382.           mov       veloopmax,cx
  383.  
  384. fxVX_horizloop:
  385.  
  386.           mov       ax,vevseg               ;vptr
  387.           push      ax
  388.           mov       ax,vevofs
  389.           push      ax
  390.           xor       ax,ax                   ;vx   = 0
  391.           push      ax
  392.  
  393.           mov       dx,si
  394.           cmp       dx,veloopmax            ;Is loop past a grain increment?
  395.           jle       fxVX_downvy             ;If not, continue
  396.  
  397.           mov       dx,veloopmax            ;Otherwise, reset
  398.  
  399. fxVX_downvy:
  400.  
  401.           push      dx                      ;vy   = loop
  402.           mov       ax,vex                  ;x    = x
  403.           push      ax
  404.           mov       bx,vey                  ;y    = y+loop
  405.           add       bx,dx
  406.           push      bx
  407.           mov       ax,vex2                 ;x2   = x2
  408.           push      ax                           
  409.           add       bx,vevgrain             ;y2   = y+loop+grain
  410.           push      bx
  411.           mov       ax,vepage               ;page = current
  412.           push      ax                      
  413.  
  414.           call      pcxVirtualDisplay       ;Display this part
  415.  
  416.           mov       ax,vevseg               ;vptr
  417.           push      ax
  418.           mov       ax,vevofs
  419.           push      ax
  420.           xor       ax,ax                   ;vx   = 0
  421.           push      ax
  422.  
  423.           cmp       di,vedepth              ;Is loop past a grain increment?
  424.           jle       fxVX_upvy               ;If not, continue
  425.  
  426.           mov       di,vedepth              ;Otherwise, reset
  427.  
  428. fxVX_upvy:
  429.  
  430.           mov       ax,vedepth              ;vy   = depth-loop
  431.           sub       ax,di
  432.           push      ax                      
  433.           mov       ax,vex                  ;x    = x
  434.           push      ax
  435.           mov       bx,vey2                 ;y    = y2-loop
  436.           inc       bx
  437.           sub       bx,di
  438.           push      bx
  439.           mov       ax,vex2                 ;x2   = x2
  440.           push      ax
  441.           add       bx,vevgrain             ;y2   = y2-loop+grain
  442.           push      bx
  443.           mov       ax,vepage               ;page = current
  444.           push      ax
  445.  
  446.           call      pcxVirtualDisplay       ;Display this part
  447.  
  448.           mov       ax,vedelay              ;Get the delay count
  449.           push      ax
  450.  
  451.           call      fxEffectDelay           ; and delay
  452.  
  453.           jnc       fxVX_upbump             ;If no error, continue
  454.           jmp       SHORT fxVX_error              
  455.  
  456. fxVX_upbump:  
  457.  
  458.           cmp       di,vedepth              ;Have we done the entire image?
  459.                                             ; (NOTE: use DI, since SI will
  460.                                             ;        NEVER overrun edge ...)
  461.           jge       fxVX_horizdone
  462.  
  463.           add       di,vevgrain             ;Bump our loop counters
  464.           add       si,vevgrain                                    
  465.  
  466. fxVX_horizdone:
  467.  
  468.           pop       ax                      ;Get previous pointers
  469.           pop       bx
  470.           pop       cx
  471.  
  472.           mov       dx,veloopmax            ; and get others
  473.           push      dx
  474.           push      di
  475.           push      si                      
  476.  
  477.           mov       si,ax                   ;Put into appropriate regs
  478.           mov       di,bx
  479.  
  480.           mov       veloopmax,cx
  481.  
  482. fxVX_leftbump:
  483.  
  484.           cmp       si,veloopmax            ;Have we done the entire image?
  485.           jge       fxVX_vertdone
  486.  
  487.           add       si,vevgrain             ;Bump our loop counters
  488.           add       di,vevgrain
  489.           jmp       fxVX_vertloop           ; and loop
  490.  
  491. fxVX_vertdone:
  492.  
  493.           pop       dx                      ;Get rid of stack variables
  494.           pop       dx
  495.           pop       dx
  496.  
  497.           @SetRet   veret,fxSUCCESS         ;Set the return code
  498.           jmp       SHORT fxVX_exit
  499.  
  500. fxVX_error:
  501.           
  502.           pop       dx                      ;Get rid of stack variables
  503.           pop       dx
  504.           pop       dx
  505.  
  506.           @SetRet   veret,ax                ;Set the error code
  507.  
  508. fxVX_exit:
  509.  
  510.           @Exit     veret,veparm            ;Return
  511.  
  512. fxVirtualExplode    ENDP
  513.  
  514.   @EndCode
  515.  
  516.           END
  517.