home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TASMSWAN.ZIP / SCREEN.ASM < prev    next >
Assembly Source File  |  1989-07-14  |  8KB  |  277 lines

  1. %TITLE  "Memory-Mapped Video Screen output routines"
  2.  
  3. ;----------NOTE: you must call ScInit before calling anything else here !!
  4.     IDEAL
  5.     DOSSEG
  6.     MODEL    small
  7.  
  8. MaxRow        EQU    25
  9. MaxCol        EQU    80
  10. MonoBase    EQU    0b000h
  11. DefaultBase    EQU    0b800h
  12.  
  13. RECORD attrByte Blink:1, Background:3, Intensity:1, Foreground:3
  14.  
  15. BlinkMask    EQU    MASK    Blink
  16. BackMask    EQU    MASK    Background
  17. IntensityMask    EQU    MASK    Intensity
  18. ForeMask    EQU    MASK    Foreground
  19.  
  20.  
  21.     DATASEG
  22.  
  23. attribute    attrByte <0,0,7>
  24. vBase         DW    DefaultBASE
  25. BytesPerRow = MaxCol * 2
  26. row = 0
  27. LABEL    ScRow    Word
  28. REPT    MaxRow
  29.     dw (row * BytesPerRow)
  30.     row = row + 1
  31. ENDM
  32.  
  33.     CODESEG
  34.  
  35.     PUBLIC    ScGotoXY, ScReadXY, ScPokeChar, ScPokeStr, ScClrRect
  36.     PUBLIC  ScSetBack, ScSetFore, ScBright, ScDim, ScBlink
  37.     PUBLIC  ScNoBlink, ScGetAttribute, ScSetAttribute, ScInit
  38. %NEWPAGE
  39. ;---------------------------------------------------------------------
  40. ;  SetVidAddr - prepare video-RAM address
  41. ;---------------------------------------------------------------------
  42. ;    NOTE: private subroutine for ScPokeChr & ScPokeStr
  43. ;     Input:    dh = row (0 is top line)
  44. ;        dl = column (0 is at far left)
  45. ;    Output: es:di = video RAM buffer address for (row,column)
  46. ;        NOTE: dh & dl are not checked!!
  47. ;    Registers:  bx,dx,di, es changed
  48. ;---------------------------------------------------------------------
  49. PROC    SetVidAddr
  50.     mov    es,[vBase]
  51.     xor    bh,bh
  52.     mov    bl,dh
  53.     shl    bx,1
  54.     mov    di, [scRow + bx]
  55.     xor    dh,dh
  56.     shl    dx,1
  57.     add    di,dx
  58.     ret
  59. ENDP    SetVidAddr
  60. %NEWPAGE
  61. ;---------------------------------------------------------------------
  62. ;  ScGotoXY - set cursor position
  63. ;---------------------------------------------------------------------
  64. ;     Input:    dh = row (0 is top line)
  65. ;        dl = column (0 is at far left)
  66. ;    Output:    cursor in page 0 repositioned to (row,column)
  67. ;    Registers:  none
  68. ;---------------------------------------------------------------------
  69. PROC    ScGotoXY
  70.     push    ax
  71.     push    bx
  72.     mov    ah,15
  73.     int    10h
  74.     mov    ah,2
  75.     int    10h
  76.     pop    bx
  77.     pop    ax
  78.     ret
  79. ENDP    ScGotoXY
  80. %NEWPAGE
  81. ;---------------------------------------------------------------------
  82. ;  ScReadXY - get cursor position
  83. ;---------------------------------------------------------------------
  84. ;     Input:  none
  85. ;    Output:    dh = row (0 is top line)
  86. ;        dl = column (0 is at far left)
  87. ;    Registers:  dx changed
  88. ;---------------------------------------------------------------------
  89. PROC    ScReadXY
  90.     push    ax
  91.     push    bx
  92.     push    cx
  93.     mov    ah,15
  94.     int    10h
  95.     mov    ah,3
  96.     int    10h
  97.     pop    cx
  98.     pop    bx
  99.     pop    ax
  100.     ret
  101. ENDP    ScReadXY
  102. %NEWPAGE
  103. ;---------------------------------------------------------------------
  104. ;  ScPokeChar - poke a character into the display
  105. ;---------------------------------------------------------------------
  106. ;     Input:  al = ASCII character code
  107. ;        dh = row (0 is top line)        *
  108. ;        dl = column (0 is at far left)  *
  109. ;    Output:    character in al displayed at position (row,column)
  110. ;            *NOTE:Row & column values NOT Checked!!
  111. ;    Registers:  ax,bx,dx, di changed
  112. ;---------------------------------------------------------------------
  113. PROC    ScPokeChar
  114.     push    es
  115.     call    SetVidAddr
  116.     mov    ah,[attribute]
  117.     stosw
  118.     pop    es
  119.     ret
  120. ENDP    ScPokeChar
  121. %NEWPAGE
  122. ;---------------------------------------------------------------------
  123. ;  ScPokeStr - poke a string into the display
  124. ;---------------------------------------------------------------------
  125. ;     Input:  cx = number of characters to write
  126. ;        dh = row (0 is top line)        *
  127. ;        dl = column (0 is at far left)  *
  128. ;        ds:di = address of ASCII string (any format)
  129. ;    Output:      *NOTE:Row & column values NOT Checked!!
  130. ;          NOTE: any string terminator is ignored
  131. ;    Registers:  ax,bx,cx,dx, di,si changed
  132. ;---------------------------------------------------------------------
  133. PROC    ScPokeStr
  134.     push    es
  135.     call    SetVidAddr
  136.     mov    ah,[attribute]
  137.     cld
  138. @@10:
  139.     lodsb
  140.     stosw
  141.     loop    @@10
  142.     pop    es
  143.     ret
  144. ENDP    ScPokeStr
  145. %NEWPAGE
  146. ;---------------------------------------------------------------------
  147. ;  ScClrRect - clear rectangular area on display
  148. ;---------------------------------------------------------------------
  149. ;     Input:  ch,cl = row & column of upper left corner
  150. ;        dh,dl = row & column of lower left corner
  151. ;    Output:      rectangle defined by ch,cl & dh,dl cleared
  152. ;             to current attributes
  153. ;    Registers:  ax
  154. ;---------------------------------------------------------------------
  155. PROC    ScClrRect
  156.     mov    ah,6
  157.     mov    al,0
  158.     mov    bh,[attribute]
  159.     int    10h
  160.     ret
  161. ENDP    ScClrRect
  162.  
  163. %NEWPAGE
  164. ;---------------------------------------------------------------------
  165. ;  ScSetBack - set background color (attribute)
  166. ;---------------------------------------------------------------------
  167. ;     Input:  al = background color
  168. ;    Output:    background color set for ScPokeChar & ScPokeStr
  169. ;    Registers:  al
  170. ;---------------------------------------------------------------------
  171. PROC    ScSetBack
  172. IF Background GT 0
  173.     push    cx
  174.     mov    cl,Background
  175.     shl    al,cl
  176.     pop    cx
  177. ENDIF
  178.     and    al,BackMask
  179.     and    [attribute], NOT BackMask
  180.     or    [attribute],al
  181.     ret
  182. ENDP    ScSetBack
  183. %NEWPAGE
  184. ;---------------------------------------------------------------------
  185. ;  ScSetFore - set foreground color (attribute)
  186. ;---------------------------------------------------------------------
  187. ;     Input:  al = foreground color
  188. ;    Output:    foreground color set for ScPokeChar & ScPokeStr
  189. ;    Registers:  al
  190. ;---------------------------------------------------------------------
  191. PROC    ScSetFore
  192. IF Foreground GT 0
  193.     push    cx
  194.     mov    cl,Foreground
  195.     shl    al,cl
  196.     pop    cx
  197. ENDIF
  198.     and    al,ForeMask
  199.     and    [attribute], NOT ForeMask
  200.     or    [attribute],al
  201.     ret
  202. ENDP    ScSetFore
  203. %NEWPAGE
  204. ;---------------------------------------------------------------------
  205. ;  ScBright  -    Turn on intensity bit
  206. ;  ScDim     -    Turn off intensity bit
  207. ;  ScBlink   -    Turn on blink bit
  208. ;  ScNoBlink -    Turn off blink bit
  209. ;---------------------------------------------------------------------
  210. ;     Input:  none
  211. ;    Output:    attribute's intensity & blink bits modified
  212. ;    Registers:  none
  213. ;---------------------------------------------------------------------
  214. PROC    ScBright
  215.     or    [attribute], IntensityMask
  216.     ret
  217. ENDP    ScBright
  218. PROC    ScDim
  219.     and    [attribute], NOT IntensityMask
  220.     ret
  221. ENDP    ScDim
  222. PROC    ScBlink
  223.     or    [attribute], BlinkMask
  224.     ret
  225. ENDP    ScBlink
  226. PROC    ScNoBlink
  227.     or    [attribute], NOT BlinkMask
  228.     ret
  229. ENDP    ScNoBlink
  230. %NEWPAGE
  231. ;---------------------------------------------------------------------
  232. ;  ScGetAttribute  -    get current attribute value
  233. ;---------------------------------------------------------------------
  234. ;     Input:  none
  235. ;    Output:     dl = current attribute value
  236. ;    Registers:  dl
  237. ;---------------------------------------------------------------------
  238. PROC    ScGetAttribute
  239.     mov    dl,[attribute]
  240.     ret
  241. ENDP    ScGetAttribute
  242. %NEWPAGE
  243. ;---------------------------------------------------------------------
  244. ;  ScSetAttribute  - change attribute value
  245. ;---------------------------------------------------------------------
  246. ;     Input:   al = new attribute value
  247. ;    Output:      none: attribute value stored for later use
  248. ;    Registers:  none
  249. ;---------------------------------------------------------------------
  250. PROC    ScSetAttribute
  251.     mov    [attribute],al
  252.     ret
  253. ENDP    ScSetAttribute
  254. %NEWPAGE
  255. ;---------------------------------------------------------------------
  256. ;  ScInit  -  initialize OUTPUT package
  257. ;---------------------------------------------------------------------
  258. ;     Input:   none
  259. ;    Output:      vBase initialized
  260. ;    Registers:  none
  261. ;---------------------------------------------------------------------
  262. PROC    ScInit
  263.     push    ax
  264.     push    bx
  265.     mov    ah,15
  266.     int    10h
  267.     cmp    al,7
  268.     jne    @@10
  269.     mov    [vBase],MonoBase
  270. @@10:
  271.     pop    bx
  272.     pop    ax
  273.     ret
  274. ENDP    ScInit
  275.  
  276.     END
  277.