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

  1.   PAGE    60,132
  2.   TITLE   fxVD.ASM -- PCX Effects
  3.   SUBTTL  Copyright (c) Genus Microprogramming, Inc. 1988-89
  4.  
  5. ; fxVD.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. ; 'wiping' it on the display, diagonally.                                    ;
  12. ;                                                                            ;
  13. ; Procedures: fxVirtualGrid                                                  ;
  14. ;             fxVirtualBox                                                   ;
  15. ;             fxVirtualDiag                                                  ;
  16. ;                                                                            ;
  17. ;                                                                            ;
  18. ; Microsoft ASM 5.x version.              Programmer: Chris Howard  3/15/89  ;
  19. ;                                                                            ;
  20. ;****************************************************************************;
  21.  
  22. ; Include files
  23.   INCLUDE ..\inc\pcxDefs.inc
  24.   INCLUDE ..\inc\pcxMacs.inc
  25.   INCLUDE ..\inc\pcxErrs.inc
  26.  
  27.   INCLUDE ..\inc\fxDefs.inc
  28.   INCLUDE ..\inc\fxMacs.inc
  29.   INCLUDE ..\inc\fxErrs.inc
  30.  
  31.   @SetModel
  32.  
  33.   @BegData
  34.   @EndData
  35.  
  36.   @BegCode
  37.  
  38.           EXTRN     pcxVirtualDisplay       : FAR
  39.           EXTRN     fxEffectDelay           : FAR
  40.  
  41.           PUBLIC    fxVirtualGrid
  42.           PUBLIC    fxVirtualBox
  43.           PUBLIC    fxVirtualDiag       
  44.  
  45. ;**********
  46.  
  47. ;
  48. ; This is a short procedure that initializes the box grid for the diagonal
  49. ; and spiral type effects.
  50. ;
  51.  
  52. fxVirtualGrid       PROC FAR
  53.  
  54.           mov       ax,vedepth              ;Calc number of grids down
  55.           xor       dx,dx                   ; (We actually divide, then
  56.           mov       bx,vevgrain             ;  add one for remainder, and
  57.           div       bx                      ;  sub one to make it zero based) 
  58.           cmp       dx,0                    
  59.           jne       fxVG_jmax
  60.  
  61.           dec       ax                      ;Adjust for even number of grids
  62.  
  63. fxVG_jmax:
  64.  
  65.           mov       vejmax,ax               ;Store it
  66.           
  67.           mov       ax,vewidth              ;Calc number of grids across
  68.           xor       dx,dx
  69.           div       bx
  70.           cmp       dx,0
  71.           jne       fxVG_imax
  72.  
  73.           dec       ax                      ;Adjust for even number of grids
  74.  
  75. fxVG_imax:
  76.  
  77.           mov       veimax,ax               ;Store it
  78.  
  79.           mov       ax,vevgrain             ;Get the grain
  80.           sub       vewidth,ax              ; and modify the width and
  81.           sub       vedepth,ax              ; depth
  82.  
  83.           ret
  84.  
  85. fxVirtualGrid       ENDP
  86.  
  87. ;**********
  88.  
  89. ;
  90. ; This is a short procedure that displays a box of a given size, located
  91. ; on a (row,col) grid.
  92. ;
  93.  
  94. fxVirtualBox        PROC FAR
  95.  
  96.           push      cx
  97.  
  98.           mov       ax,vevseg               ;vptr
  99.           push      ax
  100.           mov       ax,vevofs
  101.           push      ax
  102.  
  103.           mov       ax,si                   ;vx   = row*grain
  104.           mov       bx,vevgrain
  105.           mul       bx
  106.  
  107.           cmp       ax,vewidth              ;Make sure within bounds
  108.           jb        fxVB_vx
  109.  
  110.           mov       ax,vewidth
  111.  
  112. fxVB_vx:
  113.  
  114.           mov       cx,ax                   ;Save this value 
  115.           push      ax
  116.  
  117.           mov       ax,di                   ;vy   = col*grain
  118.           mul       bx
  119.  
  120.           cmp       ax,vedepth              ;Make sure within bounds
  121.           jb        fxVB_vy
  122.  
  123.           mov       ax,vedepth
  124.  
  125. fxVB_vy:
  126.  
  127.           mov       dx,ax                   ;Save this value
  128.           push      ax
  129.  
  130.           add       cx,vex                  ;x    = x+vx
  131.           push      cx
  132.           add       dx,vey                  ;y    = y+vy
  133.           push      dx
  134.  
  135. fxVB_grain:
  136.  
  137.           add       cx,vevgrain             ;x2   = x+grain
  138.           dec       cx
  139.           push      cx                           
  140.           add       dx,vevgrain             ;y2   = y+grain
  141.           dec       dx
  142.           push      dx
  143.           mov       ax,vepage               ;page = current
  144.           push      ax                      
  145.  
  146.           call      pcxVirtualDisplay       ;Display this part
  147.  
  148.           pop       cx
  149.  
  150.           ret
  151.  
  152. fxVirtualBox        ENDP
  153.  
  154. ;**********
  155.  
  156. ;
  157. ; This is the Virtual Diag effect procedure, for the fxVirtualEffect
  158. ; interface.  It is an INTERNAL routine only.
  159. ;
  160. ; On Entry:  SS:BP    points to pcxVirtualEffect frame
  161. ;            ES:DI    points to display structure
  162. ;            DS:SI    points to buffer
  163. ;
  164. ; On Exit:   retcode  contains error code, if any
  165. ;
  166.  
  167. fxVirtualDiag       PROC FAR
  168.  
  169.           mov       ax,vedepth              ;Get the depth
  170.           add       ax,vewidth
  171.           mov       bx,vevgrain             ; and sub the grain
  172.           xor       dx,dx
  173.           div       bx
  174.           mov       veloopmax,ax            ;Store as the loop maximum
  175.  
  176.           call      fxVirtualGrid
  177.  
  178. fxVD_dir:
  179.  
  180.           mov       ax,vedir                ;What direction?
  181.           cmp       ax,fxRIGHT+fxUP         ;Right and up  
  182.           jne       fxVD_lefttest
  183.  
  184.           jmp       fxVD_right
  185.  
  186. fxVD_lefttest:
  187.  
  188.           cmp       ax,fxLEFT+fxDOWN        ;Left and down
  189.           jne       fxVD_uptest
  190.  
  191.           jmp       fxVD_left
  192.  
  193. fxVD_uptest:
  194.  
  195.           cmp       ax,fxLEFT+fxUP          ;Left and up
  196.           jne       fxVD_down
  197.  
  198.           jmp       SHORT fxVD_up
  199.  
  200. fxVD_down:
  201.  
  202.           mov       si,0                    ;Initialize loop counters
  203.           mov       di,0
  204.  
  205.           mov       vei,si                  ;Store index
  206.  
  207.           mov       cx,veloopmax            ;Loop set number of times
  208.  
  209. fxVD_downloop:
  210.  
  211.           call      fxVirtualBox            ;Display this box
  212.  
  213.           cmp       si,0                    ;Have we reached the left edge?
  214.           je        fxVD_downcol            ;If so, bump down
  215.  
  216.           cmp       di,vejmax               ;Have we reached the bottom edge?
  217.           je        fxVD_downcol            ;If so, bump down
  218.  
  219.           dec       si                      ;Otherwise, shift left a column
  220.           inc       di                      ; and down a row
  221.  
  222.           jmp       fxVD_downloop           ;Loop
  223.  
  224. fxVD_downcol:
  225.           
  226.           mov       ax,vedelay              ;Get the delay count
  227.           push      ax
  228.  
  229.           call      fxEffectDelay           ; and delay
  230.  
  231.           jnc       fxVD_downbump           ;If no error, continue
  232.           jmp       fxVD_error  
  233.  
  234. fxVD_downbump:
  235.  
  236.           mov       si,vei                  ;Get the current index
  237.           inc       si                      ; bump
  238.           mov       vei,si                  ; and store again
  239.  
  240.           xor       di,di                   ;Clear row index
  241.  
  242.           cmp       si,veimax               ;Are we past the right edge?
  243.           jle       fxVD_downchk            ;If not, loop
  244.  
  245.           mov       di,si                   ;We are, so reposition
  246.           sub       di,veimax               
  247.  
  248.           mov       si,veimax
  249.  
  250. fxVD_downchk:
  251.  
  252.           loop      fxVD_downloop           ;If not, loop
  253.  
  254.           @SetRet   veret,fxSUCCESS         ;Set the return code
  255.           jmp       fxVD_exit               ; and exit
  256.  
  257. fxVD_up:
  258.  
  259.           mov       si,veimax               ;Initialize loop counters
  260.           mov       di,vejmax
  261.  
  262.           mov       vei,si                  ;Store index
  263.  
  264.           mov       cx,veloopmax            ;Loop set number of times
  265.  
  266. fxVD_uploop:
  267.  
  268.           call      fxVirtualBox            ;Display this box
  269.  
  270.           cmp       si,veimax               ;Have we reached the right edge?
  271.           je        fxVD_upcol              ;If so, bump up
  272.  
  273.           cmp       di,0                    ;Have we reached the top edge?
  274.           je        fxVD_upcol              ;If so, bump up
  275.  
  276.           inc       si                      ;Otherwise, shift left a column
  277.           dec       di                      ; and up a row
  278.  
  279.           jmp       fxVD_uploop             ;Loop
  280.  
  281. fxVD_upcol:
  282.           
  283.           mov       ax,vedelay              ;Get the delay count
  284.           push      ax
  285.  
  286.           call      fxEffectDelay           ; and delay
  287.  
  288.           jnc       fxVD_upbump             ;If no error, continue
  289.           jmp       fxVD_error  
  290.  
  291. fxVD_upbump:
  292.  
  293.           mov       si,vei                  ;Get the current index
  294.           dec       si                      ; bump
  295.           mov       vei,si                  ; and store again
  296.  
  297.           mov       di,vejmax               ;Clear row index
  298.  
  299.           cmp       si,0                    ;Are we past the left edge?
  300.           jge       fxVD_upchk              ;If not, loop
  301.  
  302.           add       di,si                   ;We are, so reposition
  303.           mov       si,0         
  304.  
  305. fxVD_upchk:
  306.  
  307.           loop      fxVD_uploop             ;If not, loop
  308.  
  309.           @SetRet   veret,fxSUCCESS         ;Set the return code
  310.           jmp       fxVD_exit               ; and exit
  311.  
  312. fxVD_right:
  313.  
  314.           mov       si,0                    ;Initialize loop counters
  315.           mov       di,vejmax
  316.  
  317.           mov       vei,si                  ;Store index
  318.  
  319.           mov       cx,veloopmax            ;Loop set number of times
  320.  
  321. fxVD_rightloop:
  322.  
  323.           call      fxVirtualBox            ;Display this box
  324.  
  325.           cmp       si,0                    ;Have we reached the left edge?
  326.           je        fxVD_rightcol           ;If so, bump down
  327.  
  328.           cmp       di,0                    ;Have we reached the top edge?
  329.           je        fxVD_rightcol           ;If so, bump down
  330.  
  331.           dec       si                      ;Otherwise, shift left a column
  332.           dec       di                      ; and down a row
  333.  
  334.           jmp       fxVD_rightloop          ;Loop
  335.  
  336. fxVD_rightcol:
  337.           
  338.           mov       ax,vedelay              ;Get the delay count
  339.           push      ax
  340.  
  341.           call      fxEffectDelay           ; and delay
  342.  
  343.           jnc       fxVD_rightbump          ;If no error, continue
  344.           jmp       SHORT fxVD_error  
  345.  
  346. fxVD_rightbump:
  347.  
  348.           mov       si,vei                  ;Get the current index
  349.           inc       si                      ; bump
  350.           mov       vei,si                  ; and store again
  351.  
  352.           mov       di,vejmax               ;Reset row index
  353.  
  354.           cmp       si,veimax               ;Are we past the right edge?
  355.           jle       fxVD_rightchk           ;If not, loop
  356.  
  357.           sub       si,veimax               ;We are, so reposition
  358.           sub       di,si                   
  359.  
  360.           mov       si,veimax
  361.  
  362. fxVD_rightchk:
  363.  
  364.           loop      fxVD_rightloop          ;If not, loop
  365.  
  366.           @SetRet   veret,fxSUCCESS         ;Set the return code
  367.           jmp       SHORT fxVD_exit         ; and exit
  368.  
  369. fxVD_left:
  370.  
  371.           mov       si,veimax               ;Initialize loop counters
  372.           mov       di,0          
  373.  
  374.           mov       vei,si                  ;Store index
  375.  
  376.           mov       cx,veloopmax            ;Loop set number of times
  377.  
  378. fxVD_leftloop:
  379.  
  380.           call      fxVirtualBox            ;Display this box
  381.  
  382.           cmp       si,veimax               ;Have we reached the right edge?
  383.           je        fxVD_leftcol            ;If so, bump down
  384.  
  385.           cmp       di,vejmax               ;Have we reached the bottom edge?
  386.           je        fxVD_leftcol            ;If so, bump down
  387.  
  388.           inc       si                      ;Otherwise, shift left a column
  389.           inc       di                      ; and down a row
  390.  
  391.           jmp       fxVD_leftloop           ;Loop
  392.  
  393. fxVD_leftcol:
  394.           
  395.           mov       ax,vedelay              ;Get the delay count
  396.           push      ax
  397.  
  398.           call      fxEffectDelay           ; and delay
  399.  
  400.           jnc       fxVD_leftbump           ;If no error, continue
  401.           jmp       SHORT fxVD_error  
  402.  
  403. fxVD_leftbump:
  404.  
  405.           mov       si,vei                  ;Get the current index
  406.           dec       si                      ; bump
  407.           mov       vei,si                  ; and store again
  408.  
  409.           mov       di,0                    ;Reset row index
  410.  
  411.           cmp       si,0                    ;Are we past the left edge?
  412.           jge       fxVD_leftchk            ;If not, loop
  413.  
  414.           neg       si                      ;We are, so reposition
  415.           add       di,si
  416.  
  417.           mov       si,0        
  418.  
  419. fxVD_leftchk:
  420.  
  421.           loop      fxVD_leftloop           ;If not, loop
  422.  
  423.           @SetRet   veret,fxSUCCESS         ;Set the return code
  424.           jmp       SHORT fxVD_exit         ; and exit
  425.  
  426. fxVD_error:
  427.  
  428.           @SetRet   veret,ax                ;Set the return code
  429.  
  430. fxVD_exit:
  431.                     
  432.           @Exit     veret,veparm            ;Return
  433.  
  434. fxVirtualDiag       ENDP
  435.  
  436.   @EndCode
  437.  
  438.           END
  439.