home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / ASSEMBLE / GMSRC211 / DISPLAY.ASM < prev    next >
Assembly Source File  |  1993-02-25  |  4KB  |  228 lines

  1. kline           db      "│ xxxk/xxxk",0
  2. kline2        db    " xxxk",0
  3. repstr        db    " ~  ",0
  4.  
  5. OrigMemory      dw      0
  6. CursorType      dw      0
  7. Screen        dw    0B800h
  8. ScreenFix    dw    0
  9. OldMode     db    0
  10. CurMode     db    0
  11.  
  12. proc            HowMuchMemory near
  13.         mov    ah,48h
  14.         mov    bx,0FFFFh
  15.         int    21h
  16.         shr    bx,6
  17.         mov    [cs:OrigMemory],bx
  18.         ret
  19. endp        HowMuchMemory
  20.  
  21. proc        RestoreMode
  22.         xor    ah,ah
  23.         mov    al,[cs:OldMode]
  24.         int    10h
  25.         ret
  26. endp        RestoreMode
  27.  
  28. proc            SetMode near
  29.         xor    ah,ah
  30.         mov    al,[cs:CurMode]
  31.         int    10h
  32.         ret
  33. endp        SetMode
  34.  
  35. proc            DetermineDisplay near
  36.         mov    ax,0f00h
  37.         int    10h
  38.         mov    [cs:OldMode],al
  39.         cmp    al,7            ; Are we in monochrome mode?
  40.         jz    @@Monochrome
  41.         mov    [Word cs:Screen],0B800h
  42.         mov    [Word cs:CursorType],0607h
  43.         mov    [Byte cs:CurMode],3
  44.         ret
  45. @@Monochrome:    mov    [Word cs:Screen],0B000h
  46.                 mov     [Word cs:CursorType],0B0Ch
  47.         mov    [Byte cs:CurMode],7
  48.         ret
  49. endp        DetermineDisplay
  50.  
  51. ; CX - Scan Lines
  52. proc            SetCursor near
  53.         mov    [cs:CursorType],cx
  54.         mov    ax,0100h
  55.         int    10h
  56.         ret
  57. endp        SetCursor
  58.  
  59. ; bx - X
  60. ; dx -Y
  61. ; cx:si - Loc
  62. ; ax - Len
  63. ; di - Attr
  64. proc            WriteChars near
  65.         push    ds si bx cx dx di
  66.         mov    es,[cs:Screen]
  67.         push    ax
  68.         mov    ax,160
  69.         mul    dx
  70.         add    ax,bx
  71.         add    ax,bx
  72.         mov    di,ax
  73.                 mov     ds,cx
  74.         pop    cx
  75.                 push    di
  76.         mov    ax,0
  77.         rep    stosw
  78.         pop    di
  79.         pop    ax
  80.         jmp    ActualWritePart
  81. endp            WriteChars
  82.  
  83. ; bx - X
  84. ; dx - Y
  85. ; cx:si - offset of string in DS
  86. proc            Write near
  87.         push    ds si bx cx dx
  88.         mov    es,[cs:Screen]
  89.         mov    ax,160
  90.         mul    dx
  91.         add    ax,bx
  92.         add    ax,bx
  93.         mov    di,ax
  94.         mov    ds,cx
  95.         lodsb
  96. ActualWritePart:
  97.         mov    ah,al
  98.         xor    cx,cx
  99.         xor    dx,dx
  100. @@MainLoop:    lodsb
  101.         cmp    al,0
  102.         jz    @@Done
  103.         cmp    al,'`'
  104.         jnz    @@CheckRepeat
  105.         lodsb
  106.         mov    ah,al
  107.         jmp    @@MainLoop
  108. @@CheckRepeat:    cmp    al,'~'
  109.         jnz    @@JustStore
  110.         lodsb
  111.         mov    cl,al
  112.         lodsb
  113.         rep    stosw
  114.         add    dx,cx
  115.         jmp    @@MainLoop
  116. @@JustStore:    inc    dx
  117.         stosw
  118.         jmp    @@MainLoop
  119. @@Done:     pop    dx cx bx si ds
  120.         ret
  121. endp        Write
  122.  
  123. ; ax - NumK
  124. ; dx - NumDigits
  125. ; cx:di - String
  126. proc            ConvertKToStr near
  127.         push    es
  128.         mov    es,cx
  129.         mov    cx,dx
  130.         dec    cx
  131.         add    di,cx
  132.         inc    cx
  133. @@NumLoop:    mov    bl,10
  134.         div    bl
  135.         add    ah,'0'
  136.         mov    [es:di],ah
  137.         dec    di
  138.         xor    ah,ah
  139.         loop    @@NumLoop
  140.         pop    es
  141.         ret
  142. endp        ConvertKToStr
  143.  
  144. proc            WriteMemLeft near
  145.         mov    ah,48h
  146.         mov    bx,0FFFFh
  147.         int    21h
  148.         shr    bx,6
  149.         push    bx
  150.         mov    ax,[cs:OrigMemory]
  151.         mov    dx,3
  152.         mov    cx,seg kline
  153.         mov    di,offset kline+8
  154.         call    ConvertKToStr
  155.         pop    ax
  156.         mov    dx,3
  157.         mov    cx,seg kline
  158.         mov    di,offset kline+3
  159.         call    ConvertKToStr
  160.                 mov     bx,freek_Col
  161.                 mov     dx,freek_Line
  162.         mov    cx,seg kline
  163.         mov    si,offset kline
  164.         call    Write
  165.         ret
  166. endp        WriteMemLeft
  167.  
  168. proc            MakeDec near
  169.         push    di
  170.         dec    cx
  171.         add    di,cx
  172.         inc    cx
  173.         xor    ah,ah
  174. @@NumLoop:    mov    bl,10
  175.         div    bl
  176.         add    ah,'0'
  177.         mov    [es:di],ah
  178.         dec    di
  179.         xor    ah,ah
  180.         loop    @@NumLoop
  181. @@Done:     pop    di
  182.         ret
  183. endp        MakeDec
  184.  
  185. HexStuff        db      '0123456789ABCDEF'
  186. proc            MakeHex near
  187.                 push    di
  188.                 push    ax
  189.                 and     al,0F0h
  190.                 shr     al,4
  191.                 mov     bl,al
  192.                 mov     bh,0
  193.                 mov     ah,[cs:bx+HexStuff]
  194.                 mov     [es:di],ah
  195.                 inc     di
  196.                 pop     ax
  197.                 and     al,0Fh
  198.                 mov     bl,al
  199.                 mov     bh,0
  200.                 mov     ah,[cs:bx+HexStuff]
  201.                 mov     [es:di],ah
  202.                 pop     di
  203.                 ret
  204. endp            MakeHex
  205.  
  206. proc            DirectWrite1 near
  207.         push    es
  208.         mov    es,[cs:Screen]
  209. @@1:        lodsb
  210.         inc    di
  211.         stosb
  212.         loop    @@1
  213.         pop    es
  214.         ret
  215. endp        DirectWrite1
  216.  
  217. proc        DirectWrite2 near
  218.         push    es
  219.         mov    es,[cs:Screen]
  220. @@1:        inc    di
  221.         stosb
  222.         loop    @@1
  223.         pop    es
  224.         ret
  225. endp        DirectWrite2
  226.  
  227.  
  228.