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

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