home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l196 / 2.ddi / UIASM.AS$ / UIASM.bin
Encoding:
Text File  |  1990-06-24  |  11.9 KB  |  332 lines

  1. ;-----------------------------------------------------------------------------
  2. ;-----------------------------------------------------------------------------
  3. ;
  4. ;  UIASM.ASM
  5. ;
  6. ;  Copyright (C) 1989-1990 Microsoft Corporation, All Rights Reserved
  7. ;
  8. ;  GetCopyBox : Gets screen box info and places into string variable
  9. ;  PutCopyBox : Puts screen box info from string variable onto screen
  10. ;  AttrBox    : Changes the color attributes of all characters within a box
  11. ;
  12. ;-----------------------------------------------------------------------------
  13. ;-----------------------------------------------------------------------------
  14.  
  15. ;NOTE: For optimum speed, these routines write directly to screen memory
  16. ;      without waiting for re-trace.  If "snow" is a problem, these routines
  17. ;      will need modification.
  18.  
  19. .model medium
  20.  
  21.         extrn   STRINGADDRESS:far       ;BASIC RTL entry point for string info
  22.  
  23. .data
  24.  
  25. attr    db      ?                       ;destination attribute (AttrBox)
  26. x0      db      ?                       ;x coord of upper-left
  27. y0      db      ?                       ;y coord of upper-left
  28. x1      db      ?                       ;x coord of lower-right
  29. y1      db      ?                       ;y coord of lower-right
  30. bwidth  db      ?                       ;box width
  31. height  db      ?                       ;box height
  32. strdoff dw      ?                       ;string pointer offset
  33. strdseg dw      ?                       ;string pointer segment
  34. scrseg  dw      ?                       ;screen segment
  35. movword dw      ?                       ;word count to move/change
  36.  
  37. .code
  38.  
  39. ;---------------------------------------place segment of screen memory
  40. ;---------------------------------------in SCRSEG
  41. get_scrseg      proc
  42.  
  43.         push    ax                      ;save value of AX
  44.         mov     ah,0Fh
  45.         int     10h                     ;INT 10H fn. 0Fh - Get Video Mode
  46.         mov     dgroup:scrseg,0B800h    ;assume COLOR screen for now
  47.         cmp     al,07h                  ;is it MONOCHROME mode?
  48.         jne     arnd1
  49.         mov     dgroup:scrseg,0B000h    ;yes, set for mono screen seg
  50. arnd1:  pop     ax                      ;restore AX
  51.         ret                             ;and exit
  52.  
  53. get_scrseg      endp
  54.  
  55.  
  56. ;----------------------------------------Given X and Y in AH and AL, find
  57. ;----------------------------------------the offset into screen memory and
  58. ;----------------------------------------return in AX
  59. get_memxy       proc
  60.  
  61.         push    dx                      ;save DX
  62.         push    ax                      ;save coords
  63.         mov     dl,160
  64.         mul     dl                      ;multiply Y by 160
  65.         pop     dx                      ;put coords in DX
  66.         mov     dl,dh
  67.         mov     dh,0
  68.         add     dl,dl                   ;double X
  69.         add     ax,dx                   ;and add to mult. result for final!
  70.         pop     dx                      ;restore DX
  71.         ret
  72.  
  73. get_memxy       endp
  74.  
  75.  
  76. ;-----------------------------------------------------------------------------
  77. ;----------------------------------------This is the routine that copies
  78. ;----------------------------------------screen info to the string variable
  79. ;-----------------------------------------------------------------------------
  80.         public  GETCOPYBOX
  81. getcopybox      proc    far
  82.  
  83.         push    bp
  84.         mov     bp,sp
  85.         push    ds
  86.         push    es
  87.         push    si
  88.         push    di                      ;preserve registers
  89.  
  90. get_start:
  91.         mov     bx,[bp + 14]            ;get y0
  92.         mov     ax,[bx]
  93.         mov     y0,al
  94.         mov     bx,[bp + 12]            ;...x0
  95.         mov     ax,[bx]
  96.         mov     x0,al
  97.         mov     bx,[bp + 10]            ;...y1
  98.         mov     ax,[bx]
  99.         mov     y1,al
  100.         mov     bx,[bp + 8]             ;...x1
  101.         mov     ax,[bx]
  102.         mov     x1,al
  103.         mov     bx,[bp + 6]             ;...and the destination str desc.
  104.  
  105.         push    bx
  106.         call    STRINGADDRESS           ;for both near and far string support
  107.         mov     strdoff, ax
  108.         mov     strdseg, dx
  109.  
  110.         dec     x0                      ;subtract 1 from
  111.         dec     y0                      ;all coordinates
  112.         dec     x1                      ;to reflect BASIC's
  113.         dec     y1                      ;screen base of 1 (not 0)
  114.  
  115. get_chkscr:
  116.         call    get_scrseg              ;set up screen segment
  117.  
  118. get_setstr:
  119.         mov     al,x1
  120.         sub     al,x0                   ;find width of box
  121.         mov     bwidth,al               ;and save
  122.         add     al,1                    ;add one to width
  123.         mov     ah,0                    ;to find # words to move
  124.         mov     movword,ax              ;MovWord = (width+1)
  125.         mov     al,y1
  126.         sub     al,y0                   ;find height of box
  127.         mov     height,al               ;and save
  128.         mov     es,strdseg
  129.         mov     di,strdoff              ;string is the destination
  130.         mov     si,offset bwidth        ;point to width
  131.         movsb                           ;put width in string
  132.         mov     si,offset height
  133.         movsb                           ;and the height, too
  134.  
  135. get_movstr:
  136.         mov     al,y0
  137.         mov     ah,x0                   ;put coords in AH and AL
  138.         call    get_memxy               ;and find offset into screen mem
  139.         mov     si,ax                   ;this will be the source
  140.  
  141. get_domove:
  142.         mov     cx,movword
  143.         push    ds
  144.         mov     ds,scrseg
  145.         rep     movsw                   ;move a row into the string
  146.         pop     ds
  147.         add     si,160
  148.         sub     si,movword              ;Add 160-(movword*2) to si
  149.         sub     si,movword              ;to point to next row
  150.         cmp     height,0                ;was that the last row?
  151.         je      get_done                ;yes, we're done
  152.         dec     height                  ;decrement height
  153.         jmp     get_domove              ;and do another row
  154.  
  155. get_done:
  156.         pop     di
  157.         pop     si
  158.         pop     es
  159.         pop     ds                      ;restore registers
  160.         pop     bp
  161.         ret     10                      ;there were 5 parameters
  162.  
  163. getcopybox      endp
  164.  
  165.  
  166. ;-----------------------------------------------------------------------------
  167. ;----------------------------------------This is the routine that copies the
  168. ;----------------------------------------information stored in the string to
  169. ;----------------------------------------the screen in the specified location
  170. ;-----------------------------------------------------------------------------
  171.         public  PUTCOPYBOX
  172. putcopybox      proc    far
  173.  
  174.         push    bp
  175.         mov     bp,sp
  176.         push    ds
  177.         push    es
  178.         push    si
  179.         push    di                      ;preserve registers
  180.  
  181.  
  182. put_start:
  183.         mov     bx,[bp + 10]            ;get y0
  184.         mov     ax,[bx]
  185.         mov     y0,al
  186.         mov     bx,[bp + 8]             ;...x0
  187.         mov     ax,[bx]
  188.         mov     x0,al
  189.         mov     bx,[bp + 6]             ;...and the destination string
  190.  
  191.         push    bx
  192.         call    STRINGADDRESS           ;for both near and far string support
  193.         mov     strdoff, ax
  194.         mov     strdseg, dx
  195.  
  196.         dec     x0                      ;subtract 1 from
  197.         dec     y0                      ;all coordinates
  198.  
  199. put_chkscr:
  200.         call    get_scrseg              ;set up scrseg
  201.  
  202. put_setstr:
  203.         push    ds
  204.         pop     es                      ;equate ES to DS
  205.  
  206.         mov     si,strdoff              ;point DS:SI to string mem
  207.         push    ds
  208.         mov     ds,strdseg
  209.         mov     di,offset bwidth
  210.         movsb                           ;get width
  211.         mov     di,offset height
  212.         movsb                           ;and height out of string
  213.         pop     ds
  214.  
  215.         mov     al,bwidth
  216.         add     al,1
  217.         mov     ah,0
  218.         mov     movword,ax              ;set movword to (bwidth+1)
  219.  
  220.         mov     ah,x0
  221.         mov     al,y0                   ;get coords
  222.         call    get_memxy               ;and find offset into screen mem
  223.         mov     di,ax
  224.         mov     es,scrseg               ;ES:DI -> screen mem (UL corner)
  225.  
  226. put_domove:
  227.         mov     cx,movword
  228.         push    ds
  229.         mov     ds,strdseg
  230.         rep     movsw                   ;move a row onto the screen
  231.         pop     ds
  232.         add     di,160
  233.         sub     di,movword              ;add 160-(movword*2) to DI
  234.         sub     di,movword              ;to point to next row on screen
  235.         cmp     height,0                ;was that the last row?
  236.         je      put_done                ;yes, we're finished
  237.         dec     height
  238.         jmp     put_domove              ;no, decrement and do again
  239.  
  240. put_done:
  241.         pop     di
  242.         pop     si
  243.         pop     es
  244.         pop     ds                      ;restore registers
  245.         pop     bp
  246.         ret     6                       ;pop off 3 parameters
  247.  
  248. putcopybox      endp
  249.  
  250. ;-----------------------------------------------------------------------------
  251. ;----------------------------------------This is the routine that changes
  252. ;----------------------------------------the colors of the box's characters
  253. ;-----------------------------------------------------------------------------
  254.         public  ATTRBOX
  255. attrbox         proc    far
  256.  
  257.         push    bp
  258.         mov     bp, sp
  259.         push    ds
  260.         push    es
  261.         push    si
  262.         push    di                      ;preserve registers
  263.  
  264. atr_start:
  265.         mov     bx, [bp+14]             ;get y0
  266.         mov     ax, [bx]
  267.         mov     y0, al
  268.         mov     bx, [bp+12]             ;...x0
  269.         mov     ax, [bx]
  270.         mov     x0, al
  271.         mov     bx, [bp+10]             ;...y1
  272.         mov     ax, [bx]
  273.         mov     y1, al
  274.         mov     bx, [bp+8]              ;...x1
  275.         mov     ax, [bx]
  276.         mov     x1, al
  277.         mov     bx, [bp+6]              ;...and finally the new color value
  278.         mov     ax, [bx]
  279.         mov     attr, al
  280.  
  281.         dec     y0                      ;subtract 1 from
  282.         dec     x0                      ;all coordinates
  283.         dec     y1                      ;to reflect BASIC's
  284.         dec     x1                      ;screen base of 1 (not 0)
  285.  
  286. atr_chkscr:
  287.         call    get_scrseg              ;set up screen segment
  288.  
  289. atr_setup:
  290.         mov     al, x1
  291.         sub     al, x0                  ;find width of box
  292.         inc     al
  293.         xor     ah, ah
  294.         mov     movword, ax             ;(width + 1 = movword)
  295.         mov     al, y1
  296.         sub     al, y0                  ;find height of box
  297.         mov     height, al              ;and save
  298.  
  299. atr_chgclr:
  300.         mov     al, y0
  301.         mov     ah, x0                  ;put coords in AH and AL
  302.         call    get_memxy               ;find offset into screen memory
  303.         mov     di, ax                  ;(which is our destination)
  304.         mov     es, scrseg
  305.         mov     al, attr                ;get the color value to store
  306.  
  307. atr_doit:
  308.         mov     cx, movword
  309. atr_loop:
  310.         inc     di                      ;skip the character value
  311.         stosb                           ;write new color value
  312.         loop    atr_loop                ;cx times
  313.         add     di, 160                 ;add 160-(movword*2) to di
  314.         sub     di, movword
  315.         sub     di, movword
  316.         cmp     height, 0               ;was that the last row?
  317.         je      atr_done                ;yes, we be finished
  318.         dec     height                  ;no, decrement height
  319.         jmp     atr_doit
  320.  
  321. atr_done:
  322.         pop     di
  323.         pop     si
  324.         pop     es
  325.         pop     ds
  326.         pop     bp                      ;restore registers
  327.         ret     10                      ;pull off 5 paramters and return
  328.  
  329. attrbox         endp
  330.  
  331.         END
  332.