home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / NFSRC305.ZIP / ASM / SHADOW.ASM < prev   
Encoding:
Assembly Source File  |  1995-05-01  |  9.0 KB  |  213 lines

  1. ; File......: SHADOW.ASM
  2. ; Author....: Ted Means
  3. ; CIS ID....: 73067,3332
  4. ;
  5. ; This is an original work by Ted Means and is placed in the
  6. ; public domain.
  7. ;
  8. ; Modification history:
  9. ; ---------------------
  10. ;
  11. ;     Rev 1.7   27 Nov 1992 10:39:18   GLENN
  12. ;  Another memory related bug fixed by Ted.
  13. ;
  14. ;     Rev 1.6   21 Nov 1992 11:30:24   GLENN
  15. ;  Ted fixed a bug in which memory was being overwritten if the top and
  16. ;  bottom coordinates were equal.
  17. ;
  18. ;     Rev 1.5   16 Nov 1992 00:10:26   GLENN
  19. ;  An accidental change to the interface was made when ft_shadow() was
  20. ;  rewritten.  This brings it back to the old calling convention.
  21. ;
  22. ;     Rev 1.4   16 Oct 1992 00:07:06   GLENN
  23. ;  Just making sure we had Ted's current revision.
  24. ;
  25. ;     Rev 1.3   28 Sep 1992 21:41:06   GLENN
  26. ;  Ted Means completely and totally rewrote this to compile under TASM's
  27. ;  IDEAL mode, with more features.  See the documentation.  It should be
  28. ;  compatible with the old Reginald Walton function, but is much faster.
  29. ;
  30. ;     Rev 1.2   15 Aug 1991 23:07:26   GLENN
  31. ;  Forest Belt proofread/edited/cleaned up doc
  32. ;
  33. ;     Rev 1.1   11 May 1991 00:29:22   GLENN
  34. ;  Major re-write by Ted Means.  He sped it up.  It will also cooperate
  35. ;  with Clipper's internal _gtmaxrow and _gtmaxcol settings.
  36. ;
  37. ;     Rev 1.0   02 Apr 1991 18:25:40   GLENN
  38. ;  Nanforum Toolkit
  39. ;
  40. ;
  41.  
  42.  
  43. ;  $DOC$
  44. ;  $FUNCNAME$
  45. ;      FT_SHADOW()
  46. ;  $CATEGORY$
  47. ;      Video
  48. ;  $ONELINER$
  49. ;      Draw a non-destructive shadow on the screen
  50. ;  $SYNTAX$
  51. ;     FT_SHADOW( <nTop>, <nLeft>, <nBottom>, <nRight> [ ,<nAttr>] ) -> NIL
  52. ;  $ARGUMENTS$
  53. ;     <nTop>    is the top row of the shadow area.
  54. ;     <nLeft>   is the upper left column of the shadow area.
  55. ;     <nBottom> is the bottom row of the shadow area.
  56. ;     <nRight>  is the lower right column of the shadow area.
  57. ;     <nAttr>   is optional and is the screen attribute to use for drawing
  58. ;               the shadow.  If not specified, the default is 8.
  59. ;  $RETURNS$
  60. ;     NIL
  61. ;  $DESCRIPTION$
  62. ;     This function allows you to implement the popular "shadow effect."  It
  63. ;     draws a shadow using the specified screen coordinates.  The shadow
  64. ;     is drawn along the bottom and right side of the specified region.
  65. ;
  66. ;     The source code is written to TASM IDEAL mode.
  67. ;  $EXAMPLES$
  68. ;     FT_Shadow(10,10,15,50, 8)  // draw a dim shadow
  69. ;
  70. ;     FT_Shadow(10,10,15,40,47)  // draw a green shadow
  71. ;  $END$
  72.  
  73. IDEAL                                        ; Invoke TASM IDEAL mode
  74.  
  75. Public   FT_Shadow
  76.  
  77. Extrn    __ParNI:Far
  78. Extrn    __xGrab:Far
  79. Extrn    __xFree:Far
  80. Extrn    __gtSave:Far
  81. Extrn    __gtRest:Far
  82. Extrn    __gtRectSize:Far
  83.  
  84. nTop     EQU       Word Ptr BP - 2
  85. nLeft    EQU       Word Ptr BP - 4
  86. nBottom  EQU       Word Ptr BP - 6
  87. nRight   EQU       Word Ptr BP - 8
  88. nAttr    EQU       Byte Ptr BP - 10
  89. nSize    EQU       Word Ptr BP - 12
  90.  
  91. Segment  _NanFor   Word      Public    "CODE"
  92.          Assume    CS:_NanFor
  93.  
  94. Proc     FT_Shadow Far
  95.  
  96.          Push      BP                        ; Save BP
  97.          Mov       BP,SP                     ; Set up stack reference
  98.          Sub       SP,12                     ; Allocate locals
  99.  
  100.          Mov       CX,5                      ; Set param count
  101. @@Coord: Push      CX                        ; Put on stack
  102.          Call      __ParNI                   ; Retrieve param
  103.          Pop       CX                        ; Get count back
  104.          Push      AX                        ; Put value on stack
  105.          Loop      @@Coord                   ; Get next value
  106.  
  107.          Pop       [nTop]                    ; Get top coordinate
  108.          Pop       [nLeft]                   ; Get left coordinate
  109.          Pop       [nBottom]                 ; Get bottom coordinate
  110.          Pop       [nRight]                  ; Get right coordinate
  111.          Pop       [Word Ptr BP - 10]        ; Get attribute
  112.          Cmp       [nAttr],0                 ; Is attribute invalid?
  113.          JNE       @@Right                   ; If not, continue
  114.          Mov       [nAttr],8                 ; Default attribute to 8
  115.  
  116. @@Right: Mov       AX,[nBottom]              ; Load bottom coordinate
  117.          Sub       AX,[nTop]                 ; Subtract top
  118.          JZ        @@Bottom                  ; If no room, skip right side
  119.  
  120.          LEA       AX,[nSize]                ; Get size address
  121.          Push      SS                        ; Put segment on stack
  122.          Push      AX                        ; Put offset on stack
  123.  
  124.          Mov       AX,[nTop]                 ; Load top coordinate
  125.          Inc       AX                        ; Drop down a row
  126.          Mov       BX,[nBottom]              ; Load bottom coordinate
  127.          Inc       BX                        ; Drop down a row
  128.          Mov       CX,[nRight]               ; Load right coordinate
  129.          Inc       CX                        ; Move over one
  130.          Mov       DX,CX                     ; Copy to DX
  131.          Inc       DX                        ; Move over another one
  132.  
  133.          Push      DX                        ; Put right coord on stack
  134.          Push      BX                        ; Put bottom coord on stack
  135.          Push      CX                        ; Put left coord on stack
  136.          Push      AX                        ; Put top coord on stack
  137.          Call      __gtRectSize              ; Get size
  138.  
  139.          Push      [nSize]                   ; Put size on stack
  140.          Call      __xGrab                   ; Allocate memory
  141.          Add       SP,2                      ; Realign stack
  142.  
  143.          Mov       [Word Ptr BP - 14],DX     ; Reset segment
  144.          Mov       [Word Ptr BP - 16],AX     ; Reset offset
  145.          Call      __gtSave                  ; Save screen image
  146.  
  147.          Mov       CX,[nSize]                ; Get size
  148.          SHR       CX,1                      ; Divide by 2
  149.          Mov       AL,[nAttr]                ; Load attribute
  150.          LES       BX,[DWord Ptr BP - 16]    ; Load buffer pointer
  151.          Inc       BX                        ; Point to attribute byte
  152. @@RAttr: Mov       [Byte Ptr ES:BX],AL       ; Store attribute
  153.          Add       BX,2                      ; Adjust offset
  154.          Loop      @@RAttr                   ; Do next byte
  155.  
  156.          Call      __gtRest                  ; Put shadowed image onscreen
  157.          Add       SP,8                      ; Remove params from stack
  158.          Call      __xFree                   ; Free buffer
  159.          Add       SP,4                      ; Realign stack
  160.  
  161. @@Bottom:Mov       AX,[nRight]               ; Load right coordinate
  162.          Sub       AX,[nLeft]                ; Subtract top
  163.          Cmp       AX,2                      ; Enough room for shadow?
  164.          JB        @@Done                    ; If not, skip it
  165.  
  166.          LEA       AX,[nSize]                ; Get size address
  167.          Push      SS                        ; Put segment on stack
  168.          Push      AX                        ; Put offset on stack
  169.  
  170.          Mov       AX,[nBottom]              ; Load bottom coordinate
  171.          Inc       AX                        ; Drop down a row
  172.          Mov       BX,AX                     ; Copy to BX
  173.          Mov       CX,[nLeft]                ; Load left coordinate
  174.          Inc       CX                        ; Move over two
  175.          Inc       CX
  176.          Mov       DX,[nRight]               ; Load right coordinate
  177.          Inc       DX                        ; Move over two
  178.          Inc       DX
  179.          Push      DX                        ; Put right coord on stack
  180.          Push      BX                        ; Put bottom coord on stack
  181.          Push      CX                        ; Put left coord on stack
  182.          Push      AX                        ; Put top coord on stack
  183.          Call      __gtRectSize              ; Get size
  184.  
  185.          Push      [nSize]                   ; Put size on stack
  186.          Call      __xGrab                   ; Allocate memory
  187.          Add       SP,2                      ; Realign stack
  188.  
  189.          Mov       [Word Ptr BP - 14],DX     ; Reset segment
  190.          Mov       [Word Ptr BP - 16],AX     ; Reset offset
  191.          Call      __gtSave                  ; Save screen image
  192.  
  193.          Mov       CX,[nSize]                ; Get size
  194.          SHR       CX,1                      ; Divide by 2
  195.          Mov       AL,[nAttr]                ; Load attribute
  196.          LES       BX,[DWord Ptr BP - 16]    ; Load buffer pointer
  197.          Inc       BX                        ; Point to attribute byte
  198. @@BAttr: Mov       [Byte Ptr ES:BX],AL       ; Store attribute
  199.          Add       BX,2                      ; Adjust offset
  200.          Loop      @@BAttr                   ; Do next byte
  201.  
  202.          Call      __gtRest                  ; Put shadowed image onscreen
  203.          Add       SP,8                      ; Remove params from stack
  204.          Call      __xFree                   ; Free buffer
  205.  
  206. @@Done:  Mov       SP,BP                     ; Realign stack
  207.          Pop       BP                        ; Restore BP
  208.          Ret
  209. Endp     FT_Shadow
  210. Ends     _NanFor
  211. End
  212.  
  213.