home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / misc / tty.asm < prev    next >
Assembly Source File  |  1990-04-17  |  34KB  |  1,043 lines

  1.     Page    58,132
  2.     Title    TTY.ASM     TTY Interface Routines
  3. ;******************************************************************************
  4. ;
  5. ;   Name:    TTY.ASM     TTY Interface Routines
  6. ;
  7. ;   Group:    Emulator
  8. ;
  9. ;   Revision:    1.00
  10. ;
  11. ;   Date:    January 30, 1988
  12. ;
  13. ;   Author:    Randy W. Spurlock
  14. ;
  15. ;******************************************************************************
  16. ;
  17. ;  Module Functional Description:
  18. ;
  19. ;        This module contains all the code for the TTY interface
  20. ;    used by the Apple emulator.
  21. ;
  22. ;******************************************************************************
  23. ;
  24. ;  Changes:
  25. ;
  26. ;    DATE     REVISION                DESCRIPTION
  27. ;  --------   --------    -------------------------------------------------------
  28. ;   1/30/88    1.00    Original
  29. ;
  30. ;******************************************************************************
  31.     Page
  32. ;
  33. ;  Public Declarations
  34. ;
  35.     Public    TTY_Init        ; Initialize TTY mode routine
  36.     Public    TTY_Reset        ; Reset TTY mode routine
  37.     Public    Write_TTY        ; Write TTY routine
  38.     Public    Set_Position        ; Set current position routine
  39.     Public    Set_Row         ; Set current row routine
  40.     Public    Set_Column        ; Set current column routine
  41.     Public    Set_Attribute        ; Set current attribute routine
  42.     Public    Set_Foreground        ; Set current foreground routine
  43.     Public    Set_Background        ; Set current background routine
  44.     Public    Set_Cursor        ; Set cursor position routine
  45.     Public    Set_Type        ; Set cursor type routine
  46.     Public    Get_Position        ; Get current position routine
  47.     Public    Get_Row         ; Get current row routine
  48.     Public    Get_Column        ; Get current column routine
  49.     Public    Get_Attribute        ; Get current attribute routine
  50.     Public    Get_Foreground        ; Get current foreground routine
  51.     Public    Get_Background        ; Get current background routine
  52.     Public    Get_Cursor        ; Get cursor position routine
  53.     Public    Get_Type        ; Get cursor type routine
  54.     Public    Clear_Screen        ; Clear screen routine
  55.     Public    Current_Row        ; Current screen row number
  56.     Public    Current_Col        ; Current screen column number
  57.     Public    Current_Fore        ; Current foreground color value
  58.     Public    Current_Back        ; Current background color value
  59. ;
  60. ;  External Declarations
  61. ;
  62.     Extrn    Clear_Window:Near    ; Clear window routine           (WINDOW)
  63.     Extrn    Cursor_Off:Near     ; Turn cursor off routine    (VIDEO)
  64.     Extrn    Cursor_On:Near        ; Turn cursor on routine    (VIDEO)
  65.     Extrn    Blink_Off:Near        ; Turn blink off routine    (VIDEO)
  66.     Extrn    Blink_On:Near        ; Turn blink on routine     (VIDEO)
  67.     Extrn    CGA_Restore:Near    ; CGA restore screen routine      (CGA)
  68.     Extrn    EGA_Restore:Near    ; EGA restore screen routine      (EGA)
  69.     Extrn    System_Flag:Byte    ; Apple emulator system flag byte(DATA)
  70.     Extrn    Video_Flag:Byte     ; Video system flag byte     (DATA)
  71. ;
  72. ;  LOCAL Equates
  73. ;
  74. TEXT_MODE    Equ    00h        ; Text mode value (40 x 25)
  75. GRAPH_MODE    Equ    04h        ; Graphics mode value (320 x 200)
  76. BACK_SHIFT    Equ    04h        ; Background attribute shift value
  77. MAX_ROW     Equ    19h        ; Maximum row number value (25)
  78. MAX_COLUMN    Equ    28h        ; Maximum column number value (40)
  79. CURSOR_MASK    Equ    07h        ; Cursor type mask value
  80. ATTRIBUTE_MASK    Equ    0Fh        ; Foreground/background attribute mask
  81. MAX_TAB     Equ    24h        ; Maximum horizontal tab position (36)
  82. TAB_SIZE    Equ    04h        ; Tab stop size value (4)
  83. TAB_MASK    Equ    03h        ; Tab count mask value
  84. VIDEO_MEMORY    Equ    0B800h        ; Start of video memory segment
  85. ;
  86. ;  Define any include files needed
  87. ;
  88.     Include     Macros.inc    ; Include the macro definitions
  89.     Include     Equates.inc    ; Include the equate definitions
  90.     .286c                ; Include 80286 instructions
  91.     Page
  92. ;
  93. ;  Define the emulator code segment
  94. ;
  95. Emulate Segment Word Public 'EMULATE'   ; Emulator code segment
  96.     Assume    cs:Emulate, ds:Nothing, es:Nothing
  97.     Subttl    TTY_Init    Initialize TTY Mode Routine
  98.     Page    +
  99. ;******************************************************************************
  100. ;
  101. ;    TTY_Init()
  102. ;
  103. ;        Save the required registers
  104. ;        Set text mode 0 (40x25)
  105. ;        Call routine to turn off cursor
  106. ;        Call routine to disable blink (Intensity)
  107. ;        Restore the required registers
  108. ;        Return to the caller
  109. ;
  110. ;    Registers on Entry:
  111. ;
  112. ;        None
  113. ;
  114. ;    Registers on Exit:
  115. ;
  116. ;        None
  117. ;
  118. ;******************************************************************************
  119.         Even            ; Force procedure to even address
  120. TTY_Init    Proc    Near        ; Initialize TTY mode procedure
  121.     Save    ax            ; Save the required registers
  122.     mov    ah,SET_MODE        ; Get set mode video sub-function code
  123.     mov    al,TEXT_MODE        ; Get the 40x25 text mode value
  124.     int    VIDEO            ; Set video mode to 40x25 text mode
  125.     call    Cursor_Off        ; Call routine to turn cursor off
  126.     call    Blink_Off        ; Call routine to turn blink off
  127.     Restore ax            ; Restore the required registers
  128.     ret                ; Return to the caller
  129. TTY_Init    Endp            ; End of the TTY_Init procedure
  130.     Subttl    TTY_Reset    Reset TTY Mode Routine
  131.     Page    +
  132. ;******************************************************************************
  133. ;
  134. ;    TTY_Reset()
  135. ;
  136. ;        If this is a CGA type video
  137. ;            Call routine to restore CGA screen
  138. ;        Else this is an EGA type video
  139. ;            Call routine to restore EGA screen
  140. ;        Endif for video type
  141. ;        Return to the caller
  142. ;
  143. ;    Registers on Entry:
  144. ;
  145. ;        None
  146. ;
  147. ;    Registers on Exit:
  148. ;
  149. ;        None
  150. ;
  151. ;******************************************************************************
  152.         Even            ; Force procedure to even address
  153. TTY_Reset    Proc    Near        ; Reset TTY mode procedure
  154.     test    cs:[System_Flag],EGA_TYPE
  155.     jnz    Reset_Ega        ; Jump if this is an EGA type video
  156. Reset_CGA:
  157.     call    CGA_Restore        ; Call routine to restore CGA
  158.     jmp    Short Reset_Exit    ; Go return to the caller
  159. Reset_EGA:
  160.     call    EGA_Restore        ; Call routine to restore EGA
  161. Reset_Exit:
  162.     ret                ; Return to the caller
  163. TTY_Reset    Endp            ; End of the TTY_Reset procedure
  164.     Subttl    Write_TTY    Write TTY Routine
  165.     Page    +
  166. ;******************************************************************************
  167. ;
  168. ;    Write_TTY(Character)
  169. ;
  170. ;        Save the required registers
  171. ;        If special character
  172. ;            Call routine to handle special character
  173. ;        Else
  174. ;            Calculate the current screen position
  175. ;            Get current screen colors (Foreground/Background)
  176. ;            Put requested character on the screen
  177. ;        Endif
  178. ;        Restore the required registers
  179. ;        Return to the caller
  180. ;
  181. ;    Registers on Entry:
  182. ;
  183. ;        AL    - Character to write
  184. ;
  185. ;    Registers on Exit:
  186. ;
  187. ;        None
  188. ;
  189. ;******************************************************************************
  190.         Even            ; Force procedure to even address
  191. Write_TTY    Proc    Near        ; Write TTY procedure
  192.     Save    ax,bx,cx,dx,di,es    ; Save the required registers
  193.     mov    bx,cs            ; Setup access to
  194.     mov    es,bx            ;          character table
  195.     mov    cx,SPECIAL_LENGTH    ; Get length of special character table
  196.     lea    di,cs:[Special_Table]    ; Get pointer to character table
  197.     repne    scasb            ; Check for a special character
  198.     jne    Write_Character     ; Jump if NOT a special character
  199.     lea    ax,cs:[Special_Table]    ; Calculate
  200.     sub    di,ax            ;        matching
  201.     dec    di            ;             character value
  202.     shl    di,1            ; Convert matching number to table index
  203.     call    cs:[di + Special_Jump]    ; Call correct special character routine
  204.     jmp    Short Write_Exit    ; Go return control to the caller
  205. Write_Character:
  206.     mov    cx,cs:[Current_Row]    ; Get the current row number
  207.     mov    bx,cx            ; Compute
  208.     shl    bx,2            ;      row number
  209.     add    bx,cx            ;             times five (*80)
  210.     add    bx,VIDEO_MEMORY     ; Compute actual video memory segment
  211.     mov    es,bx            ; Setup to access video memory
  212.     mov    di,cs:[Current_Col]    ; Compute the actual
  213.     shl    di,1            ;             memory address
  214.     mov    ah,Byte Ptr cs:[Current_Back]
  215.     shl    ah,BACK_SHIFT        ; Shift background into position
  216.     or    ah,Byte Ptr cs:[Current_Fore]
  217.     stosw                ; Store character into memory
  218.     mov    ax,cs:[Current_Row]    ; Get the current
  219.     mov    bx,cs:[Current_Col]    ;          row/column values
  220.     inc    bx            ; Increment the column number
  221.     cmp    bx,MAX_COLUMN        ; Check against maximum column value
  222.     jb    Write_Update        ; Jump if column number valid
  223.     xor    bx,bx            ; Reset current column number
  224.     inc    ax            ; Increment the row number
  225.     cmp    ax,MAX_ROW        ; Check against maximum row value
  226.     jae    Write_Exit        ; Jump if invalid row/column values
  227. Write_Update:
  228.     mov    cs:[Current_Row],ax    ; Update the current
  229.     mov    cs:[Current_Col],bx    ;             row/column values
  230. Write_Exit:
  231.     Restore ax,bx,cx,dx,di,es    ; Restore the required registers
  232.     ret                ; Return to the caller
  233. Write_TTY    Endp            ; End of the Write_TTY procedure
  234.     Subttl    Special_NULL    Special NULL Character Routine
  235.     Page    +
  236. ;******************************************************************************
  237. ;
  238. ;    Special_NULL()
  239. ;
  240. ;        Return to the caller
  241. ;
  242. ;    Registers on Entry:
  243. ;
  244. ;        None
  245. ;
  246. ;    Registers on Exit:
  247. ;
  248. ;        None
  249. ;
  250. ;******************************************************************************
  251.         Even            ; Force procedure to even address
  252. Special_NULL    Proc    Near        ; Special NULL character procedure
  253.     ret                ; Return to the caller
  254. Special_NULL    Endp            ; End of the Special_NULL procedure
  255.     Subttl    Special_BELL    Special BELL Character Routine
  256.     Page    +
  257. ;******************************************************************************
  258. ;
  259. ;    Special_BELL()
  260. ;
  261. ;        Save the required registers
  262. ;
  263. ;        Restore the required registers
  264. ;        Return to the caller
  265. ;
  266. ;    Registers on Entry:
  267. ;
  268. ;        None
  269. ;
  270. ;    Registers on Exit:
  271. ;
  272. ;        None
  273. ;
  274. ;******************************************************************************
  275.         Even            ; Force procedure to even address
  276. Special_BELL    Proc    Near        ; Special BELL character procedure
  277.     Save                ; Save the required registers
  278.  
  279.  
  280.  
  281.     Restore             ; Restore the required registers
  282.     ret                ; Return to the caller
  283. Special_BELL    Endp            ; End of the Special_BELL procedure
  284.     Subttl    Special_BS    Special BS Character Routine
  285.     Page    +
  286. ;******************************************************************************
  287. ;
  288. ;    Special_BS()
  289. ;
  290. ;        Save the required registers
  291. ;        If current column number greater than zero
  292. ;            Decrement the current column number
  293. ;            Calculate the current screen position
  294. ;            Get current screen colors (Foreground/Background)
  295. ;            Put space character on the screen
  296. ;        Endif
  297. ;        Restore the required registers
  298. ;        Return to the caller
  299. ;
  300. ;    Registers on Entry:
  301. ;
  302. ;        None
  303. ;
  304. ;    Registers on Exit:
  305. ;
  306. ;        None
  307. ;
  308. ;******************************************************************************
  309.         Even            ; Force procedure to even address
  310. Special_BS    Proc    Near        ; Special BS character procedure
  311.     Save    ax,bx,di,es        ; Save the required registers
  312.     mov    ax,cs:[Current_Col]    ; Get the current column number
  313.     or    ax,ax            ; Check for in column zero
  314.     jz    BS_Exit         ; Jump if currently in column zero
  315.     dec    cs:[Current_Col]    ; Decrement the current column value
  316.     mov    ax,cs:[Current_Row]    ; Get the current row number
  317.     mov    bx,ax            ; Compute
  318.     shl    bx,2            ;      row number
  319.     add    ax,bx            ;             times five (*80)
  320.     add    ax,VIDEO_MEMORY     ; Compute actual video memory segment
  321.     mov    es,ax            ; Setup to access video memory
  322.     mov    di,cs:[Current_Col]    ; Compute the actual
  323.     shl    di,1            ;             memory address
  324.     mov    al,SPACE        ; Setup to write a space character
  325.     mov    ah,Byte Ptr cs:[Current_Back]
  326.     shl    ah,BACK_SHIFT        ; Shift background into position
  327.     or    ah,Byte Ptr cs:[Current_Fore]
  328.     stosw                ; Store character into memory
  329. BS_Exit:
  330.     Restore ax,bx,di,es        ; Restore the required registers
  331.     ret                ; Return to the caller
  332. Special_BS    Endp            ; End of the Special_BS procedure
  333.     Subttl    Special_HT    Special HT Character Routine
  334.     Page    +
  335. ;******************************************************************************
  336. ;
  337. ;    Special_HT()
  338. ;
  339. ;        Save the required registers
  340. ;        If current column less than maximum tab position
  341. ;            Calculate number of pad characters required (Spaces)
  342. ;            Calculate the current screen position
  343. ;            Get current screen colors (Foreground/Background)
  344. ;            Update the current column position
  345. ;            While more pad characters to display
  346. ;                Put pad character on the screen (Space)
  347. ;                Decrement the pad counter
  348. ;            EndWhile
  349. ;        Endif
  350. ;        Restore the required registers
  351. ;        Return to the caller
  352. ;
  353. ;    Registers on Entry:
  354. ;
  355. ;        None
  356. ;
  357. ;    Registers on Exit:
  358. ;
  359. ;        None
  360. ;
  361. ;******************************************************************************
  362.         Even            ; Force procedure to even address
  363. Special_HT    Proc    Near        ; Special HT character procedure
  364.     Save    ax,bx,cx,di,es        ; Save the required registers
  365.     mov    ax,cs:[Current_Col]    ; Get the current column position
  366.     cmp    ax,MAX_TAB        ; Check against maximum tab position
  367.     jae    HT_Exit         ; Jump if past maximum tab position
  368.     and    ax,TAB_MASK        ; Compute
  369.     mov    cx,TAB_SIZE        ;      the actual
  370.     sub    cx,ax            ;             tab count value
  371.     mov    ax,cs:[Current_Row]    ; Get the current row number
  372.     mov    bx,ax            ; Compute
  373.     shl    bx,2            ;      row number
  374.     add    ax,bx            ;             times five (*80)
  375.     add    ax,VIDEO_MEMORY     ; Compute actual video memory segment
  376.     mov    es,ax            ; Setup to access video memory
  377.     mov    di,cs:[Current_Col]    ; Compute the actual
  378.     shl    di,1            ;             memory address
  379.     mov    al,SPACE        ; Setup to write a space character
  380.     mov    ah,Byte Ptr cs:[Current_Back]
  381.     shl    ah,BACK_SHIFT        ; Shift background into position
  382.     or    ah,Byte Ptr cs:[Current_Fore]
  383.     add    cs:[Current_Col],cx    ; Update the current column position
  384.     rep    stosw            ; Store the horizontal pad characters
  385. HT_Exit:
  386.     Restore ax,bx,cx,di,es        ; Restore the required registers
  387.     ret                ; Return to the caller
  388. Special_HT    Endp            ; End of the Special_HT procedure
  389.     Subttl    Special_LF    Special LF Character Routine
  390.     Page    +
  391. ;******************************************************************************
  392. ;
  393. ;    Special_LF()
  394. ;
  395. ;        Save the required registers
  396. ;        If not on the bottom row
  397. ;            Increment the current row value
  398. ;        Endif
  399. ;        Restore the required registers
  400. ;        Return to the caller
  401. ;
  402. ;    Registers on Entry:
  403. ;
  404. ;        None
  405. ;
  406. ;    Registers on Exit:
  407. ;
  408. ;        None
  409. ;
  410. ;******************************************************************************
  411.         Even            ; Force procedure to even address
  412. Special_LF    Proc    Near        ; Special LF character procedure
  413.     Save    ax            ; Save the required registers
  414.     mov    ax,cs:[Current_Row]    ; Get the current row position
  415.     cmp    ax,MAX_ROW - 1        ; Check for on the bottom row
  416.     jae    LF_Exit         ; Jump if currently on the last row
  417.     inc    cs:[Current_Row]    ; Increment to the next row
  418. LF_Exit:
  419.     Restore ax            ; Restore the required registers
  420.     ret                ; Return to the caller
  421. Special_LF    Endp            ; End of the Special_LF procedure
  422.     Subttl    Special_VT    Special VT Character Routine
  423.     Page    +
  424. ;******************************************************************************
  425. ;
  426. ;    Special_VT()
  427. ;
  428. ;        Save the required registers
  429. ;        If not on the bottom row
  430. ;            Increment the current row value
  431. ;        Endif
  432. ;        Restore the required registers
  433. ;        Return to the caller
  434. ;
  435. ;    Registers on Entry:
  436. ;
  437. ;        None
  438. ;
  439. ;    Registers on Exit:
  440. ;
  441. ;        None
  442. ;
  443. ;******************************************************************************
  444.         Even            ; Force procedure to even address
  445. Special_VT    Proc    Near        ; Special VT character procedure
  446.     Save    ax            ; Save the required registers
  447.     mov    ax,cs:[Current_Row]    ; Get the current row position
  448.     cmp    ax,MAX_ROW - 1        ; Check for on the bottom row
  449.     jae    VT_Exit         ; Jump if currently on the last row
  450.     inc    cs:[Current_Row]    ; Increment to the next row
  451. VT_Exit:
  452.     Restore ax            ; Restore the required registers
  453.     ret                ; Return to the caller
  454. Special_VT    Endp            ; End of the Special_VT procedure
  455.     Subttl    Special_FF    Special FF Character Routine
  456.     Page    +
  457. ;******************************************************************************
  458. ;
  459. ;    Special_FF()
  460. ;
  461. ;        Save the required registers
  462. ;        Call routine to clear the screen
  463. ;        Set row position to zero
  464. ;        Set column position to zero
  465. ;        Restore the required registers
  466. ;        Return to the caller
  467. ;
  468. ;    Registers on Entry:
  469. ;
  470. ;        None
  471. ;
  472. ;    Registers on Exit:
  473. ;
  474. ;        None
  475. ;
  476. ;******************************************************************************
  477.         Even            ; Force procedure to even address
  478. Special_FF    Proc    Near        ; Special FF character procedure
  479.     Save    ax            ; Save the required registers
  480.     call    Clear_Screen        ; Call routine to clear the screen
  481.     xor    ax,ax            ; Setup to zero current position (Home)
  482.     mov    cs:[Current_Row],ax    ; Zero the current
  483.     mov    cs:[Current_Col],ax    ;           row/column position
  484.     Restore ax            ; Restore the required registers
  485.     ret                ; Return to the caller
  486. Special_FF    Endp            ; End of the Special_FF procedure
  487.     Subttl    Special_CR    Special CR Character Routine
  488.     Page    +
  489. ;******************************************************************************
  490. ;
  491. ;    Special_CR()
  492. ;
  493. ;        Save the required registers
  494. ;        Set current column position to zero
  495. ;        Restore the required registers
  496. ;        Return to the caller
  497. ;
  498. ;    Registers on Entry:
  499. ;
  500. ;        None
  501. ;
  502. ;    Registers on Exit:
  503. ;
  504. ;        None
  505. ;
  506. ;******************************************************************************
  507.         Even            ; Force procedure to even address
  508. Special_CR    Proc    Near        ; Special CR character procedure
  509.     Save    ax            ; Save the required registers
  510.     xor    ax,ax            ; Setup to zero column position
  511.     mov    cs:[Current_Col],ax    ; Zero current column position value
  512.     Restore ax            ; Restore the required registers
  513.     ret                ; Return to the caller
  514. Special_CR    Endp            ; End of the Special_CR procedure
  515.     Subttl    Set_Position    Set Current Position Routine
  516.     Page    +
  517. ;******************************************************************************
  518. ;
  519. ;    Set_Position(Row, Column)
  520. ;
  521. ;        If new row position is valid
  522. ;            If new column position is valid
  523. ;                Set current row to new row
  524. ;                Set current column to new column
  525. ;            Endif
  526. ;        Endif
  527. ;        Return to the caller
  528. ;
  529. ;    Registers on Entry:
  530. ;
  531. ;        AX    - New row number
  532. ;        BX    - New column number
  533. ;
  534. ;    Registers on Exit:
  535. ;
  536. ;        None
  537. ;
  538. ;******************************************************************************
  539.         Even            ; Force procedure to even address
  540. Set_Position    Proc    Near        ; Set current position procedure
  541.     cmp    ax,MAX_ROW        ; Check the new row number value
  542.     jae    Position_Exit        ; Jump if new row value is invalid
  543.     cmp    bx,MAX_COLUMN        ; Check the new column number value
  544.     jae    Position_Exit        ; Jump if new column value is invalid
  545.     mov    cs:[Current_Row],ax    ; Update the current
  546.     mov    cs:[Current_Col],bx    ;             row/column values
  547. Position_Exit:
  548.     ret                ; Return to the caller
  549. Set_Position    Endp            ; End of the Set_Position procedure
  550.     Subttl    Set_Row     Set Current Row Position Routine
  551.     Page    +
  552. ;******************************************************************************
  553. ;
  554. ;    Set_Row(Row)
  555. ;
  556. ;        If new row position is valid
  557. ;            Set current row to new row
  558. ;        Endif
  559. ;        Return to the caller
  560. ;
  561. ;    Registers on Entry:
  562. ;
  563. ;        AX    - New row number
  564. ;
  565. ;    Registers on Exit:
  566. ;
  567. ;        None
  568. ;
  569. ;******************************************************************************
  570.         Even            ; Force procedure to even address
  571. Set_Row     Proc    Near        ; Set current row position procedure
  572.     cmp    ax,MAX_ROW        ; Check the new row number value
  573.     jae    Row_Exit        ; Jump if new row value is invalid
  574.     mov    cs:[Current_Row],ax    ; Update the current row value
  575. Row_Exit:
  576.     ret                ; Return to the caller
  577. Set_Row     Endp            ; End of the Set_Row procedure
  578.     Subttl    Set_Column    Set Current Column Position Routine
  579.     Page    +
  580. ;******************************************************************************
  581. ;
  582. ;    Set_Column(Column)
  583. ;
  584. ;        If new column position is valid
  585. ;            Set current column to new column
  586. ;        Endif
  587. ;        Return to the caller
  588. ;
  589. ;    Registers on Entry:
  590. ;
  591. ;        AX    - New column number
  592. ;
  593. ;    Registers on Exit:
  594. ;
  595. ;        None
  596. ;
  597. ;******************************************************************************
  598.         Even            ; Force procedure to even address
  599. Set_Column    Proc    Near        ; Set current column position procedure
  600.     cmp    ax,MAX_COLUMN        ; Check the new column number value
  601.     jae    Column_Exit        ; Jump if new column value is invalid
  602.     mov    cs:[Current_Col],ax    ; Update the current column value
  603. Column_Exit:
  604.     ret                ; Return to the caller
  605. Set_Column    Endp            ; End of the Set_Column procedure
  606.     Subttl    Set_Attribute    Set Current Attribute Routine
  607.     Page    +
  608. ;******************************************************************************
  609. ;
  610. ;    Set_Attribute(Foreground, Background)
  611. ;
  612. ;        Set current foreground color to new value
  613. ;        Set current background color to new value
  614. ;        Mask off the foreground value
  615. ;        Mask off the background value
  616. ;        Return to the caller
  617. ;
  618. ;    Registers on Entry:
  619. ;
  620. ;        AX    - New foreground color
  621. ;        BX    - New background color
  622. ;
  623. ;    Registers on Exit:
  624. ;
  625. ;        None
  626. ;
  627. ;******************************************************************************
  628.         Even            ; Force procedure to even address
  629. Set_Attribute    Proc    Near        ; Set current attribute procedure
  630.     mov    cs:[Current_Fore],ax    ; Save new foreground
  631.     mov    cs:[Current_Back],bx    ;              background colors
  632.     and    cs:[Current_Fore],ATTRIBUTE_MASK
  633.     and    cs:[Current_Back],ATTRIBUTE_MASK
  634.     ret                ; Return to the caller
  635. Set_Attribute    Endp            ; End of the Set_Attribute procedure
  636.     Subttl    Set_Foreground    Set Current Foreground Routine
  637.     Page    +
  638. ;******************************************************************************
  639. ;
  640. ;    Set_Foreground(Foreground)
  641. ;
  642. ;        Set current foreground color to new value
  643. ;        Mask off the foreground value
  644. ;        Return to the caller
  645. ;
  646. ;    Registers on Entry:
  647. ;
  648. ;        AX    - New foreground color
  649. ;
  650. ;    Registers on Exit:
  651. ;
  652. ;        None
  653. ;
  654. ;******************************************************************************
  655.         Even            ; Force procedure to even address
  656. Set_Foreground    Proc    Near        ; Set current foreground procedure
  657.     mov    cs:[Current_Fore],ax    ; Save new foreground color value
  658.     and    cs:[Current_Fore],ATTRIBUTE_MASK
  659.     ret                ; Return to the caller
  660. Set_Foreground    Endp            ; End of the Set_Foreground procedure
  661.     Subttl    Set_Background    Set Current Background Routine
  662.     Page    +
  663. ;******************************************************************************
  664. ;
  665. ;    Set_Background(Background)
  666. ;
  667. ;        Set current background color to new value
  668. ;        Mask off the background value
  669. ;        Return to the caller
  670. ;
  671. ;    Registers on Entry:
  672. ;
  673. ;        AX    - New background color
  674. ;
  675. ;    Registers on Exit:
  676. ;
  677. ;        None
  678. ;
  679. ;******************************************************************************
  680.         Even            ; Force procedure to even address
  681. Set_Background    Proc    Near        ; Set current background procedure
  682.     mov    cs:[Current_Back],ax    ; Save new background color value
  683.     and    cs:[Current_Back],ATTRIBUTE_MASK
  684.     ret                ; Return to the caller
  685. Set_Background    Endp            ; End of the Set_Background procedure
  686.     Subttl    Set_Cursor    Set Cursor Position Routine
  687.     Page    +
  688. ;******************************************************************************
  689. ;
  690. ;    Set_Cursor(Row, Column)
  691. ;
  692. ;        Save the required registers
  693. ;        If new row position is valid
  694. ;            If new column position is valid
  695. ;                Set new cursor position
  696. ;            Endif
  697. ;        Endif
  698. ;        Restore the required registers
  699. ;        Return to the caller
  700. ;
  701. ;    Registers on Entry:
  702. ;
  703. ;        AX    - Cursor row number
  704. ;        BX    - Cursor column number
  705. ;
  706. ;    Registers on Exit:
  707. ;
  708. ;        None
  709. ;
  710. ;******************************************************************************
  711.         Even            ; Force procedure to even address
  712. Set_Cursor    Proc    Near        ; Set cursor position procedure
  713.     Save    ax,bx,dx        ; Save the required registers
  714.     cmp    ax,MAX_ROW        ; Check the new row number value
  715.     jae    Cursor_Exit        ; Jump if new row value is invalid
  716.     cmp    bx,MAX_COLUMN        ; Check the new column number value
  717.     jae    Cursor_Exit        ; Jump if new column value is invalid
  718.     mov    dh,al            ; Setup the cursor
  719.     mov    dl,bl            ;           row and column values
  720.     xor    bh,bh            ; Setup for video page zero
  721.     mov    ah,WRITE_CURSOR     ; Get write cursor position function
  722.     int    VIDEO            ; Set the new cursor position
  723. Cursor_Exit:
  724.     Restore ax,bx,dx        ; Restore the required registers
  725.     ret                ; Return to the caller
  726. Set_Cursor    Endp            ; End of the Set_Cursor procedure
  727.     Subttl    Set_Type    Set Cursor Type Routine
  728.     Page    +
  729. ;******************************************************************************
  730. ;
  731. ;    Set_Type(Start, End)
  732. ;
  733. ;        Save the required registers
  734. ;        Mask off the cursor start value
  735. ;        Mask off the cursor end value
  736. ;        Set the new cursor type value
  737. ;        Restore the required registers
  738. ;        Return to the caller
  739. ;
  740. ;    Registers on Entry:
  741. ;
  742. ;        AX    - Cursor start row number (0 - 7)
  743. ;        BX    - Cursor end row number (0 - 7)
  744. ;
  745. ;    Registers on Exit:
  746. ;
  747. ;        None
  748. ;
  749. ;******************************************************************************
  750.         Even            ; Force procedure to even address
  751. Set_Type    Proc    Near        ; Set cursor type procedure
  752.     Save    ax,cx            ; Save the required registers
  753.     mov    ch,al            ; Get and mask
  754.     and    ch,CURSOR_MASK        ;           cursor start value
  755.     mov    cl,bl            ; Get and mask
  756.     and    cl,CURSOR_MASK        ;           cursor end value
  757.     mov    ah,CURSOR_TYPE        ; Get set cursor type function code
  758.     int    VIDEO            ; Set the new cursor type value
  759.     Restore ax,cx            ; Restore the required registers
  760.     ret                ; Return to the caller
  761. Set_Type    Endp            ; End of the Set_Type procedure
  762.     Subttl    Get_Position    Get Current Position Routine
  763.     Page    +
  764. ;******************************************************************************
  765. ;
  766. ;    Get_Position()
  767. ;
  768. ;        Get the current row value
  769. ;        Get the current column vlaue
  770. ;        Return to the caller
  771. ;
  772. ;    Registers on Entry:
  773. ;
  774. ;        None
  775. ;
  776. ;    Registers on Exit:
  777. ;
  778. ;        AX    - Current row number
  779. ;        BX    - Current column number
  780. ;
  781. ;******************************************************************************
  782.         Even            ; Force procedure to even address
  783. Get_Position    Proc    Near        ; Get current position procedure
  784.     mov    ax,cs:[Current_Row]    ; Get the current
  785.     mov    bx,cs:[Current_Col]    ;          row/column values
  786.     ret                ; Return to the caller
  787. Get_Position    Endp            ; End of the Get_Position procedure
  788.     Subttl    Get_Row     Get Current Row Position Routine
  789.     Page    +
  790. ;******************************************************************************
  791. ;
  792. ;    Get_Row()
  793. ;
  794. ;        Get the current row value
  795. ;        Return to the caller
  796. ;
  797. ;    Registers on Entry:
  798. ;
  799. ;        None
  800. ;
  801. ;    Registers on Exit:
  802. ;
  803. ;        AX    - Current row number
  804. ;
  805. ;******************************************************************************
  806.         Even            ; Force procedure to even address
  807. Get_Row     Proc    Near        ; Get current row position procedure
  808.     mov    ax,cs:[Current_Row]    ; Get the current row value
  809.     ret                ; Return to the caller
  810. Get_Row     Endp            ; End of the Get_Row procedure
  811.     Subttl    Get_Column    Get Current Column Position Routine
  812.     Page    +
  813. ;******************************************************************************
  814. ;
  815. ;    Get_Column()
  816. ;
  817. ;        Get the current column vlaue
  818. ;        Return to the caller
  819. ;
  820. ;    Registers on Entry:
  821. ;
  822. ;        None
  823. ;
  824. ;    Registers on Exit:
  825. ;
  826. ;        AX    - Current column number
  827. ;
  828. ;******************************************************************************
  829.         Even            ; Force procedure to even address
  830. Get_Column    Proc    Near        ; Get current column position procedure
  831.     mov    ax,cs:[Current_Col]    ; Get the current column value
  832.     ret                ; Return to the caller
  833. Get_Column    Endp            ; End of the Get_Column procedure
  834.     Subttl    Get_Attribute    Get Current Attribute Routine
  835.     Page    +
  836. ;******************************************************************************
  837. ;
  838. ;    Get_Attribute()
  839. ;
  840. ;        Get the current foreground color
  841. ;        Get the current background color
  842. ;        Return to the caller
  843. ;
  844. ;    Registers on Entry:
  845. ;
  846. ;        None
  847. ;
  848. ;    Registers on Exit:
  849. ;
  850. ;        AX    - Current foreground color
  851. ;        BX    - Current background color
  852. ;
  853. ;******************************************************************************
  854.         Even            ; Force procedure to even address
  855. Get_Attribute    Proc    Near        ; Get current attribute procedure
  856.     mov    ax,cs:[Current_Fore]    ; Get foreground/
  857.     mov    bx,cs:[Current_Back]    ;         background colors
  858.     ret                ; Return to the caller
  859. Get_Attribute    Endp            ; End of the Get_Attribute procedure
  860.     Subttl    Get_Foreground    Get Current Foreground Routine
  861.     Page    +
  862. ;******************************************************************************
  863. ;
  864. ;    Get_Foreground()
  865. ;
  866. ;        Get the current foreground color
  867. ;        Return to the caller
  868. ;
  869. ;    Registers on Entry:
  870. ;
  871. ;        None
  872. ;
  873. ;    Registers on Exit:
  874. ;
  875. ;        AX    - Current foreground color
  876. ;
  877. ;******************************************************************************
  878.         Even            ; Force procedure to even address
  879. Get_Foreground    Proc    Near        ; Get current foreground procedure
  880.     mov    ax,cs:[Current_Fore]    ; Get the current foreground color
  881.     ret                ; Return to the caller
  882. Get_Foreground    Endp            ; End of the Get_Foreground procedure
  883.     Subttl    Get_Background    Get Current Background Routine
  884.     Page    +
  885. ;******************************************************************************
  886. ;
  887. ;    Get_Background()
  888. ;
  889. ;        Get the current background color
  890. ;        Return to the caller
  891. ;
  892. ;    Registers on Entry:
  893. ;
  894. ;        None
  895. ;
  896. ;    Registers on Exit:
  897. ;
  898. ;        AX    - Current background color
  899. ;
  900. ;******************************************************************************
  901.         Even            ; Force procedure to even address
  902. Get_Background    Proc    Near        ; Get current background procedure
  903.     mov    ax,cs:[Current_Back]    ; Get the current background color
  904.     ret                ; Return to the caller
  905. Get_Background    Endp            ; End of the Get_Background procedure
  906.     Subttl    Get_Cursor    Get Cursor Position Routine
  907.     Page    +
  908. ;******************************************************************************
  909. ;
  910. ;    Get_Cursor()
  911. ;
  912. ;        Save the required registers
  913. ;        Get current cursor position
  914. ;        Restore the required registers
  915. ;        Return to the caller
  916. ;
  917. ;    Registers on Entry:
  918. ;
  919. ;        None
  920. ;
  921. ;    Registers on Exit:
  922. ;
  923. ;        AX    - Cursor row number
  924. ;        BX    - Cursor column number
  925. ;
  926. ;******************************************************************************
  927.         Even            ; Force procedure to even address
  928. Get_Cursor    Proc    Near        ; Get cursor position procedure
  929.     Save    cx,dx            ; Save the required registers
  930.     xor    bh,bh            ; Setup for video page zero
  931.     mov    ah,READ_CURSOR        ; Get read cursor position function
  932.     int    VIDEO            ; Get the current cursor position
  933.     mov    al,dh            ; Get the current
  934.     xor    ah,ah            ;          row position value
  935.     mov    bl,dl            ; Get the current
  936.     xor    bh,bh            ;          column position value
  937.     Restore cx,dx            ; Restore the required registers
  938.     ret                ; Return to the caller
  939. Get_Cursor    Endp            ; End of the Get_Cursor procedure
  940.     Subttl    Get_Type    Get Cursor Type Routine
  941.     Page    +
  942. ;******************************************************************************
  943. ;
  944. ;    Get_Type()
  945. ;
  946. ;        Save the required registers
  947. ;        Get current cursor type
  948. ;        Restore the required registers
  949. ;        Return to the caller
  950. ;
  951. ;    Registers on Entry:
  952. ;
  953. ;        None
  954. ;
  955. ;    Registers on Exit:
  956. ;
  957. ;        AX    - Cursor start row number (0 - 7)
  958. ;        BX    - Cursor end row number (0 - 7)
  959. ;
  960. ;******************************************************************************
  961.         Even            ; Force procedure to even address
  962. Get_Type    Proc    Near        ; Get cursor type procedure
  963.     Save    cx,dx            ; Save the required registers
  964.     xor    bh,bh            ; Setup for video page zero
  965.     mov    ah,READ_CURSOR        ; Get read cursor position function
  966.     int    VIDEO            ; Get the current cursor position
  967.     mov    al,ch            ; Get cursor start
  968.     xor    ah,ah            ;           row position value
  969.     mov    bl,cl            ; Get cursor end
  970.     xor    bh,bh            ;         row position value
  971.     Restore cx,dx            ; Restore the required registers
  972.     ret                ; Return to the caller
  973. Get_Type    Endp            ; End of the Get_Type procedure
  974.     Subttl    Clear_Screen    Clear Screen Routine
  975.     Page    +
  976. ;******************************************************************************
  977. ;
  978. ;    Clear_Screen()
  979. ;
  980. ;        Save the required registers
  981. ;        Set window to entire screen
  982. ;        Call routine to clear window
  983. ;        Restore the required registers
  984. ;        Return to the caller
  985. ;
  986. ;    Registers on Entry:
  987. ;
  988. ;        None
  989. ;
  990. ;    Registers on Exit:
  991. ;
  992. ;        None
  993. ;
  994. ;******************************************************************************
  995.         Even            ; Force procedure to even address
  996. Clear_Screen    Proc    Near        ; Clear screen procedure
  997.     Save    ax,bx,cx,dx        ; Save the required registers
  998.     xor    ax,ax            ; Setup
  999.     xor    bx,bx            ;    window
  1000.     mov    cx,MAX_ROW - 1        ;           to the
  1001.     mov    dx,MAX_COLUMN - 1    ;              entire screen
  1002.     call    Clear_Window        ; Call routine to clear the window
  1003.     Restore ax,bx,cx,dx        ; Restore the required registers
  1004.     ret                ; Return to the caller
  1005. Clear_Screen    Endp            ; End of the Clear_Screen procedure
  1006.     Subttl            TTY Interface Data Areas
  1007.     Page    +
  1008. ;******************************************************************************
  1009. ;
  1010. ;    Define any data areas needed by the TTY interface
  1011. ;
  1012. ;******************************************************************************
  1013. Special_Table    Equ    This Byte    ; Special character table
  1014.         Db    NULL        ; Null character
  1015.         Db    BELL        ; Bell character
  1016.         Db    BS        ; Backspace character
  1017.         Db    HT        ; Horizontal tab character
  1018.         Db    LF        ; Line feed character
  1019.         Db    VT        ; Vertical tab character
  1020.         Db    FF        ; Form feed character
  1021.         Db    CR        ; Carriage return character
  1022. SPECIAL_LENGTH    Equ    This Byte - Special_Table
  1023. Special_Jump    Equ    This Word    ; Special character jump table
  1024.         Dw    Special_NULL    ; Null character routine
  1025.         Dw    Special_BELL    ; Bell character routine
  1026.         Dw    Special_BS    ; Backspace character routine
  1027.         Dw    Special_HT    ; Horizontal tab character routine
  1028.         Dw    Special_LF    ; Line feed character routine
  1029.         Dw    Special_VT    ; Vertical tab character routine
  1030.         Dw    Special_FF    ; Form feed character routine
  1031.         Dw    Special_CR    ; Carriage return character routine
  1032. Current_Row    Dw    0        ; Current screen row number
  1033. Current_Col    Dw    0        ; Current screen column number
  1034. Current_Fore    Dw    INTENSE_WHITE    ; Current foreground color value
  1035. Current_Back    Dw    GRAY        ; Current background color value
  1036. ;******************************************************************************
  1037. ;
  1038. ;    Define the end of the Emulator Code Segment
  1039. ;
  1040. ;******************************************************************************
  1041. Emulate Ends
  1042.     End                ; End of the TTY module
  1043.