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

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