home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Low Level Languages / Rm Cobol V2.2 / TIVIDEO.ASM < prev    next >
Encoding:
Assembly Source File  |  1985-11-07  |  13.7 KB  |  367 lines

  1.     page    63, 132
  2.     title    Texas Instruments Video Bios Driver for version 2.1A
  3. ;****************************************************************************
  4. ;*****        Title:  Texas Intruments Video Bios Driver        *****
  5. ;*****    Program written by: John S. Kent        Date: 84.07.15    *****
  6. ;*****    Description:  This module must perform 10 functions on the TI    *****
  7. ;*****        video display.  The functions are:            *****
  8. ;*****    al = 0    set crt mode        al = 1    set screen attribute    *****
  9. ;*****    al = 2    display chr & advance    al = 3    position cursor        *****
  10. ;*****    al = 4    clear screen        al = 5    erase to end of line    *****
  11. ;*****    al = 6    erase to end of screen    al = 7    cursor to new line    *****
  12. ;*****    al = 8    move cursor backwards    al = 9    cursor on        *****
  13. ;*****    al = A    cursor off                        *****
  14. ;*****                                    *****
  15. ;*****    Modifications:                    Date:        *****
  16. ;*****        Description:                        *****
  17. ;*****                                    *****
  18. ;****************************************************************************
  19. ; SCCS information:
  20. ;@(#) tivideo.asm  ver. 1.2 last update 85/11/06 16:35:56
  21. ;@(#) This source obtained from the s file on 85/11/06 at 16:36:24
  22. bs    equ    08H           
  23. lf    equ    0AH
  24. cr    equ    0DH
  25. spc    equ    20H
  26.  
  27. max_line    equ    24D
  28. max_column    equ    80D
  29.  
  30. set_cursor_type    equ    01H        ;TI ROM bios function #'s
  31. set_cursor_pos    equ    02H
  32. get_cursor_pos    equ    03H
  33. write_tty    equ    0EH
  34. write_block    equ    11H
  35. clr_text_scrn    equ    13H
  36. clr_graphics    equ    14H
  37. set_scrn_attr    equ    16H
  38.  
  39. crt_rom_bios    equ    49H
  40.  
  41. normal_attr    equ    00001100B    ;TI attributes, green in low intensity
  42. reverse_attr    equ    00010000B
  43. blink_attr    equ    01000000B
  44. hi_inten_attr    equ    00000111B
  45. cursor_mask    equ    01100000B
  46. cursor_off_attr    equ    00100000B
  47. cursor_on_mask    equ    01000000B
  48. cursor_off_mask    equ    10011111B
  49.  
  50. intensity_bit    equ    00000001B    ;rmc attributes
  51. reverse_bit    equ    00000010B
  52. blink_bit    equ    00000100B
  53.  
  54.  
  55. ;    Having only one segment, CODE, greatly simplifies matters
  56. ;
  57. cgroup    group    code
  58.  
  59. code    segment    byte    public    'code'
  60.     assume    cs:cgroup, ds:cgroup, es:cgroup, ss:cgroup
  61. ;  Must be a .COM type of file to link with the runtime using RMCLNK
  62. ;    Hence, there must be an org 0100H and the first location
  63. ;    must be the first instruction to execute
  64.     org    0100H
  65. ;
  66. ;
  67. ;    Must be a far routine when linked using RMCLNK and the runtime
  68. ;    is configured to call this instead of its own bios driver.
  69. ;
  70. bios_ifc    proc    far
  71.     mov    bl, al        ;get function request #
  72.     xor    bh, bh        ;clear out hi order
  73.     add    bx, bx        ;convert to word offset
  74.     call    word ptr cs:[bx + jmp_tbl]    ;call function
  75.     ret
  76. bios_ifc    endp
  77. ;
  78. ;  Have the data stuff next to ease the assembler's calculation
  79. ;    of addresses.
  80. ;
  81.  
  82. cursor_save_pos    dw    ?
  83. clr_line    db    max_column dup(spc)
  84. ;
  85.  
  86.  
  87. ;----------------------------------------------------------------------------
  88. ;-----    Routine:  bios_ifc                (John S. Kent)    -----
  89. ;-----    Function: Parses command (in al) to correct function request.    -----
  90. ;-----    Entry:    al = function request # (0 - 0AH)            -----
  91. ;-----    Exit:    None.                            -----
  92. ;-----    Calls:    functions indirectly via a table.            -----
  93. ;-----    Registers: All presumed to be destroyed.            -----
  94. ;-----    Notes:                                -----
  95. ;----------------------------------------------------------------------------
  96. jmp_tbl        dw    offset cgroup:set_mode, offset cgroup:set_attr
  97.         dw    offset cgroup:display_chr, offset cgroup:pos_cursor
  98.         dw    offset cgroup:clr_scrn, offset cgroup:erase_eol
  99.         dw    offset cgroup:clr_eos, offset cgroup:new_line
  100.         dw    offset cgroup:backspace, offset cgroup:cursor_on
  101.         dw    offset cgroup:cursor_off
  102. ;----------------------------------------------------------------------------
  103. ;-----    Routine:  set_mode                (John S. Kent)    -----
  104. ;-----    Function: Sets screen size to various line & column sizes,    -----
  105. ;-----        color or black and white, border color, and default    -----
  106. ;-----        display page. (all of these are ignored since the TI    -----
  107. ;-----        does not support variable line & column sizes and does    -----
  108. ;-----        not distinguish between color & black & white and does    -----
  109. ;-----        not have a border color and has only 1 avtive page.    -----
  110. ;-----    Entry:    al = 0, ah = 0 (40X25 bw), 1 (80X25 color),        -----
  111. ;-----        2 (80X25 bw), 3 (80X25 color).    dl = default display    -----
  112. ;-----        page & dh = default border color.            -----
  113. ;-----    Exit:    None.                            -----
  114. ;-----    Calls:                                -----
  115. ;-----    Registers: All are assumed destroyed.                -----
  116. ;-----    Notes:                                -----
  117. ;----------------------------------------------------------------------------
  118. set_mode:
  119.     ret
  120.  
  121. ;----------------------------------------------------------------------------
  122. ;-----    Routine:  set_attr                (John S. Kent)    -----
  123. ;-----    Function: Sets crt attribute for all characters to be displayed    -----
  124. ;-----        until this function is called again.            -----
  125. ;-----    Entry:    al = 1, ah = attribute (XXXXXbri)            -----
  126. ;-----        b = blink, r = reverse, & i = alternate intensity.    -----
  127. ;-----        dh = background color, dl = foreground color, ch =    -----
  128. ;-----        border color. (dx & ch are ignored since TI does not    -----
  129. ;-----        support these attributes)                -----
  130. ;-----    Exit:    None.                            -----
  131. ;-----    Calls:                                -----
  132. ;-----    Registers: All registers are assumed to be destroyed.        -----
  133. ;-----    Notes:                                -----
  134. ;----------------------------------------------------------------------------
  135. set_attr:
  136.     mov    bl, normal_attr        ;TI attribute
  137.     test    ah, intensity_bit    ;RMC attribute
  138.     jnz    set_attr_rev        ;skip if normal intensity
  139.  
  140.     or    bl, hi_inten_attr    ;set hi intensity
  141.  
  142. set_attr_rev:
  143.     test    ah, reverse_bit        ;check for reverse
  144.     jz    set_attr_blnk        ;skip if no reverse
  145.  
  146.     or    bl, reverse_attr    ;set reverse
  147.  
  148. set_attr_blnk:
  149.     test    ah, blink_bit        ;check for blink
  150.     jz    set_attr_bios        ;skip if no 
  151.     
  152.     or    bl, blink_attr        ;set blink
  153.  
  154. set_attr_bios:
  155.     mov    ah, set_scrn_attr    ;get bios function # (set attributes)
  156.     int    crt_rom_bios        ;call ROM bios
  157.     ret
  158.  
  159. ;----------------------------------------------------------------------------
  160. ;-----    Routine:  display_chr                (John S. Kent)    -----
  161. ;-----    Function: Display character on screen & advance cursor.        -----
  162. ;-----    Entry:    al = 2, ah = character.                    -----
  163. ;-----    Exit:    None.                            -----
  164. ;-----    Calls:                                -----
  165. ;-----    Registers: All presumed to be destroyed.            -----
  166. ;-----    Notes: cr, lf, bs, and bell are implemented (cause action).    -----
  167. ;----------------------------------------------------------------------------
  168. display_chr:
  169.     xchg    ah, al        ;get character into al
  170.     mov    ah, write_tty    ;write ascii teletype function #
  171.     int    crt_rom_bios    ;call ROM bios
  172.     ret
  173.  
  174. ;----------------------------------------------------------------------------
  175. ;-----    Routine:  pos_cursor                (John S. Kent)    -----
  176. ;-----    Function: move cursor location to specified line & column.    -----
  177. ;-----    Entry:    al = 3, ah = active page (ignored), dh = line,        -----
  178. ;-----        dl = column.                        -----
  179. ;-----    Exit:    None.                            -----
  180. ;-----    Calls:                                -----
  181. ;-----    Registers: All presummed to be destroyed.            -----
  182. ;-----    Notes:    line & column are assumed to be 0 relative.        -----
  183. ;----------------------------------------------------------------------------
  184. pos_cursor:
  185.     mov    ah, set_cursor_pos    ;get set cursor position function #
  186.     xchg    dh, dl            ;TI needs line in dl
  187.     int    crt_rom_bios        ;call ROM bios
  188.     ret
  189.  
  190. ;----------------------------------------------------------------------------
  191. ;-----    Routine:  clr_scrn                (John S. Kent)    -----
  192. ;-----    Function: Clears then screen to spaces and "homes" the cursor.    -----
  193. ;-----    Entry:    al = 4, ah = background color.                -----
  194. ;-----    Exit:    None.                            -----
  195. ;-----    Calls:                                -----
  196. ;-----    Registers: All presumed to be destroyed.            -----
  197. ;-----    Notes:                                -----
  198. ;----------------------------------------------------------------------------
  199. clr_scrn:
  200.     mov    ah, get_cursor_pos    ;save cursor position
  201.     int    crt_rom_bios        ;call ROM bios, returns current in DX
  202.     mov    ah, clr_text_scrn    ;get clear test screen function #
  203.     push    dx            ;save dx, current position
  204.     int    crt_rom_bios        ;call ROM bios
  205.     mov    ah, clr_graphics    ;get clear graphics screen function #
  206.     int    crt_rom_bios        ;call ROM bios
  207.     pop    dx            ;restore dx
  208.     mov    ah, set_cursor_pos    ;restore cursor position
  209.     int    crt_rom_bios        ;call ROM bios
  210.     ret
  211.  
  212. ;----------------------------------------------------------------------------
  213. ;-----    Routine:  erase_eol                (John S. Kent)    -----
  214. ;-----    Function: Erase to end of line.                    -----
  215. ;-----    Entry:    al = 5, ah = background color.                -----
  216. ;-----    Exit:    dx = column & line of cursor.                -----
  217. ;-----    Calls:                                -----
  218. ;-----    Registers: All presumed to de destroyed.            -----
  219. ;-----    Notes:                                -----
  220. ;----------------------------------------------------------------------------
  221. erase_eol:
  222.     mov    ah, get_cursor_pos    ;get read cursor position function #
  223.     int    crt_rom_bios        ;call ROM bios (returns dh = column, dl = line)
  224.     push    dx            ;save column (dh) & row (dl)
  225.     mov    bx, offset clr_line    ;point to blank line
  226.     mov    cx, length clr_line    ;get blank line length
  227.     xchg    dh, dl            ;put column in low order
  228.     xor    dh, dh            ;clear out high order
  229.     sub    cx, dx            ;reset length to just to end of line
  230.     dec    cx            ;make count 1 relative
  231.     mov    dx, DS            ;pass segment of block
  232.     mov    ah, write_block        ;get write blk of chrs only func. #
  233.     int    crt_rom_bios        ;call ROM, bios
  234.     pop    dx            ;restore cursor column & row (dh, dl)
  235.     ret
  236.     
  237. ;----------------------------------------------------------------------------
  238. ;-----    Routine:  clr_eos                (John S. Kent)    -----
  239. ;-----    Function: Clear to end of screen.  Clears text screen only.    -----
  240. ;-----    Entry:    al = 6, ah = background color (ignored).        -----
  241. ;-----    Exit:    None.                            -----
  242. ;-----    Calls:                                -----
  243. ;-----    Registers: All presumed to be destroyed.            -----
  244. ;-----    Notes:                                -----
  245. ;----------------------------------------------------------------------------
  246. clr_eos:
  247.     mov    ah, get_cursor_pos    ;set up to save cursor position
  248.     int    crt_rom_bios        ;call ROM bios
  249.     push    dx            ;save cursor position
  250.  
  251. clr_eos_lop:
  252.     call    erase_eol        ;clear current line (rets dx = col, ln)
  253.     cmp    dl, max_line        ;check for end of screen
  254.     jae    clr_ret            ;return if done
  255.  
  256.     mov    ah, set_cursor_pos    ;get set cursor position function #
  257.     inc    dl            ;point to next row
  258.     xor    dh, dh            ;clear entire line (column = 0)
  259.     int    crt_rom_bios        ;call ROM bios
  260.     jmp    clr_eos_lop        ;clear this new line
  261.  
  262. clr_ret:
  263.     mov    ah, set_cursor_pos    ;set up to reposition cursor
  264.     pop    dx            ;restore cursor position
  265.     int    crt_rom_bios        ;call ROM bios
  266.     ret
  267.  
  268. ;----------------------------------------------------------------------------
  269. ;-----    Routine:  new_line                (John S. Kent)    -----
  270. ;-----    Function: Advance cursor to new line, scroll screen if         -----
  271. ;-----        necessary.                        -----
  272. ;-----    Entry:    al = 7.                            -----
  273. ;-----    Exit:    None.                            -----
  274. ;-----    Calls:                                -----
  275. ;-----    Registers: All presumed to be destroyed.            -----
  276. ;-----    Notes:                                -----
  277. ;----------------------------------------------------------------------------
  278. new_line:
  279.     mov    ax, write_tty shl 8 + cr ;set up to output carriage return
  280.     int    crt_rom_bios        ;call ROM bios
  281.     mov    ax, write_tty shl 8 + lf ;set up to output line feed
  282.     int    crt_rom_bios        ;call ROM bios
  283.     ret
  284.  
  285. ;----------------------------------------------------------------------------
  286. ;-----    Routine:  backspace                (John S. Kent)    -----
  287. ;-----    Function: Move cursor back on column on the screen, if @ column    -----
  288. ;-----        0 then move to column 80 of previous line, if @ line 0    -----
  289. ;-----        then cursor remains on this line. (?????)        -----
  290. ;-----    Entry:    al = 8                            -----
  291. ;-----    Exit:    None.                            -----
  292. ;-----    Calls:                                -----
  293. ;-----    Registers: All presumed to be destroyed.            -----
  294. ;-----    Notes:                                -----
  295. ;----------------------------------------------------------------------------
  296. backspace:
  297.     mov    ax, write_tty shl 8 + bs    ;set up to do back space
  298.     int    crt_rom_bios
  299.     ret
  300.  
  301. ;----------------------------------------------------------------------------
  302. ;-----    Routine:  cursor_on                (John S. Kent)    -----
  303. ;-----    Function: Turns the cursor on (makes visable).            -----
  304. ;-----    Entry:    al = 9                            -----
  305. ;-----    Exit:    None.                            -----
  306. ;-----    Calls:                                -----
  307. ;-----    Registers: All presumed to be destroyed.            -----
  308. ;-----    Notes:    Destroys the blink attribute of cursor.            -----
  309. ;----------------------------------------------------------------------------
  310. cursor_on:
  311.     mov    ah, get_cursor_pos    ;get read cursor position function #
  312.     int    crt_rom_bios        ;returns cx = cursor type
  313.     mov    bx, cx            ;get cursor attributes into tmp reg
  314.     and    bh, cursor_mask        ;mask out unwanted bits
  315.     cmp    bh, cursor_off_attr    ;check for cursor off
  316.     jne    cursor_on_ret        ;return if already on
  317.  
  318.     mov    ch, cursor_on_mask    ;else turn on with no blink (how else?)
  319.     mov    ah, set_cursor_type    ;get set cursor type function #
  320.     int    crt_rom_bios        ;call ROM bios
  321.  
  322. cursor_on_ret:
  323.     ret
  324.  
  325. ;----------------------------------------------------------------------------
  326. ;-----    Routine:  cursor_off                (John S. Kent)    -----
  327. ;-----    Function: turn cursor off (make cursor invisiable).        -----
  328. ;-----    Entry:    al = 0AH.                        -----
  329. ;-----    Exit:    None.                            -----
  330. ;-----    Calls:                                -----
  331. ;-----    Registers: All presumed to be destroyed.            -----
  332. ;-----    Notes:    Destroys last cursor blink attributes.            -----
  333. ;----------------------------------------------------------------------------
  334. cursor_off:
  335.     mov    ah, get_cursor_pos    ;get read cursor position
  336.     int    crt_rom_bios        ;call ROM bios
  337.     and    ch, cursor_off_mask    ;turn cursor off
  338.     or    ch, cursor_off_attr    ;
  339.     mov    ah, set_cursor_type    ;get set cursor type
  340.     int    crt_rom_bios
  341.     ret
  342. ;
  343. bios_patch    equ    this byte
  344. ;  Adjust the following db so code ends is in same place as in the ibm bios
  345.         db    175 dup (90H)
  346. ;
  347. ;  Sccs information :
  348.         db    '@ #( ) (@)#@(#)'    ;SCCS id.
  349.         db    'tivideo.asm'        ;Program name % M %.
  350.         db    ' ver. '
  351.         db    '1.2'        ;version % I %.
  352.         db    ' 85/11/06 '        ;date % E %.
  353.         db    '16:35:56'        ;time % U %.
  354.         db    '>'        ;Ending indicator.
  355. ;align to same length as ibmvideo
  356. ;  Should have an address value here of 01B1
  357. code    ends
  358.  
  359. stack    segment    byte    stack    'stack'
  360.  
  361. stack    ends
  362.  
  363. ;  Entry point is bios_ifc
  364.     end bios_ifc
  365. s
  366.  
  367.