home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / SAVEATT.ASM < prev    next >
Assembly Source File  |  1992-10-03  |  6KB  |  165 lines

  1. ; File......: SAVEATT.ASM
  2. ; Author....: Ted Means
  3. ; Date......: $Date:   03 Oct 1992 14:35:14  $
  4. ; Revision..: $Revision:   1.2  $
  5. ; Log file..: $Logfile:   C:/nanfor/src/saveatt.asv  $
  6. ; This is an original work by Ted Means and is placed in the
  7. ; public domain.
  8. ;
  9. ; Modification history:
  10. ; ---------------------
  11. ;
  12. ; $Log:   C:/nanfor/src/saveatt.asv  $
  13. ;  
  14. ;     Rev 1.2   03 Oct 1992 14:35:14   GLENN
  15. ;  Ted Means made modifications to support use of dispBegin()/dispEnd().
  16. ;  
  17. ;     Rev 1.1   15 Aug 1991 23:07:58   GLENN
  18. ;  Forest Belt proofread/edited/cleaned up doc
  19. ;  
  20. ;     Rev 1.0   12 Jun 1991 01:30:20   GLENN
  21. ;  Initial revision.
  22. ;
  23.  
  24.  
  25. ;  $DOC$
  26. ;  $FUNCNAME$
  27. ;     FT_SAVEATT()
  28. ;  $CATEGORY$
  29. ;     Video
  30. ;  $ONELINER$
  31. ;     Save the attribute bytes of a specified screen region.
  32. ;  $SYNTAX$
  33. ;     FT_SAVEATT( <nTop>, <nLeft>, <nBottom>, <nRight>  ) -> cAttributes
  34. ;  $ARGUMENTS$
  35. ;     <nTop>, <nLeft>, <nBottom>, and <nRight> define the screen region.
  36. ;  $RETURNS$
  37. ;     A character string containing the screen attribute bytes for the
  38. ;     specified region.  If the memory to store the return value could
  39. ;     not be allocated, the function returns NIL.
  40. ;  $DESCRIPTION$
  41. ;     This function is similar to Clipper's SaveScreen(), except that it only
  42. ;     saves the attribute bytes.  This is useful if you want to change the
  43. ;     screen color without affecting the text.
  44. ;
  45. ;     *** INTERNALS ALERT ***
  46. ;
  47. ;     This function calls the Clipper internal __gtMaxCol to obtain the
  48. ;     maximum column value for the current video mode.  If you're too gutless
  49. ;     to use internals, then this function isn't for you.
  50. ;  $EXAMPLES$
  51. ;     // Save attributes of row 4
  52. ;     cBuffer := FT_SAVEATT( 4, 0, 4, maxcol())
  53. ;
  54. ;     // Save attributes from middle of screen
  55. ;     cBuffer := FT_SAVEATT(10,20,14,59)
  56. ;  $SEEALSO$
  57. ;     FT_RESTATT()
  58. ;  $END$
  59. ;
  60.  
  61. IDEAL
  62.  
  63. Public   FT_SaveAtt
  64.  
  65. Extrn    __ParNI:Far
  66. Extrn    __RetCLen:Far
  67. Extrn    __xGrab:Far
  68. Extrn    __xFree:Far
  69. Extrn    __gtSave:Far                        ; ** INTERNAL **
  70.  
  71. nTop     EQU       Word Ptr BP - 2
  72. nLeft    EQU       Word Ptr BP - 4
  73. nBottom  EQU       Word Ptr BP - 6
  74. nRight   EQU       Word Ptr BP - 8
  75. nAttr    EQU       Byte Ptr BP - 10
  76. nBufLen  EQU       Word Ptr BP - 12
  77.  
  78. cBuffer  EQU       DWord Ptr BP - 16
  79. nBufOfs  EQU       Word Ptr BP - 16
  80. nBufSeg  EQU       Word Ptr BP - 14
  81.  
  82. Segment  _NanFor   Word      Public    "CODE"
  83.          Assume    CS:_NanFor
  84.  
  85. Proc     FT_SaveAtt          Far
  86.  
  87.          Push      BP                        ; Save BP
  88.          Mov       BP,SP                     ; Set up stack reference
  89.          Sub       SP,16                     ; Allocate locals
  90.  
  91.          Mov       CX,4                      ; Set param count
  92. @@Coord: Push      CX                        ; Put on stack
  93.          Call      __ParNI                   ; Retrieve param
  94.          Pop       CX                        ; Get count back
  95.          Push      AX                        ; Put value on stack
  96.          Loop      @@Coord                   ; Get next value
  97.  
  98.          Pop       [nTop]                    ; Store top coordinate
  99.          Pop       [nLeft]                   ; Store left coordinate
  100.          Pop       [nBottom]                 ; Store bottom coordinate
  101.          Pop       [nRight]                  ; Store right coordinate
  102.  
  103.          Mov       AX,[nBottom]              ; Load bottom coordinate
  104.          Sub       AX,[nTop]                 ; Subtract top
  105.          Inc       AX                        ; Calc length
  106.  
  107.          Mov       CX,[nRight]               ; Load right coordinate
  108.          Sub       CX,[nLeft]                ; Subtract left
  109.          Inc       CX                        ; Calc width
  110.          Mul       CX                        ; Multiply length by width
  111.          SHL       AX,1                      ; Calc buffer size
  112.          Mov       [nBufLen],AX              ; Store buffer size
  113.  
  114. @@Alloc: Push      AX                        ; Put size on stack
  115.          Call      __xGrab                   ; Allocate memory
  116.          Add       SP,2                      ; Realign stack
  117.          Mov       [nBufSeg],DX              ; Store segment
  118.          Mov       [nBufOfs],AX              ; Store offset
  119.  
  120.          Push      DX                        ; Load parameters for __gtSave
  121.          Push      AX                        ; onto stack
  122.          Push      [nRight]
  123.          Push      [nBottom]
  124.          Push      [nLeft]
  125.          Push      [nTop]
  126.          Call      __gtSave                  ; Grab screen image
  127.  
  128.          Push      DS                        ; Save required registers
  129.          Push      SI
  130.          Push      DI
  131.  
  132.          Mov       DS,[nBufSeg]              ; Load pointer to buffer
  133.          Mov       SI,[nBufOfs]              ; into DS:SI
  134.  
  135.          Push      DS                        ; Duplicate pointer in ES:DI
  136.          Push      SI
  137.          Pop       DI
  138.          Pop       ES
  139.          Inc       SI                        ; Start with attribute byte
  140.  
  141.          Mov       CX,[nBufLen]              ; Load buffer length
  142.          SHR       CX,1                      ; Divide by two
  143. @@Attr:  Lodsw                               ; Grab a screen word
  144.          Stosb                               ; Store attribute only
  145.          Loop      @@Attr                    ; Do next
  146.  
  147.          Pop       DI                        ; Restore registers
  148.          Pop       SI
  149.          Pop       DS
  150.  
  151. Done:    Mov       AX,[nBufLen]              ; Load buffer length
  152.          SHR       AX,1                      ; Divide by 2
  153.          Push      AX                        ; Put length on stack
  154.          Push      [nBufSeg]                 ; Put segment on stack
  155.          Push      [nBufOfs]                 ; Put offset on stack
  156.          Call      __RetClen                 ; Return attribute string
  157.          Call      __xFree                   ; Free memory
  158.          Mov       SP,BP                     ; Realign stack
  159.          Pop       BP                        ; Restore BP
  160.          Ret
  161. Endp     FT_SaveAtt
  162. Ends     _NanFor
  163. End
  164.