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

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