home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / z / zsim20.zip / CONIO.ASM < prev    next >
Assembly Source File  |  1992-12-02  |  22KB  |  875 lines

  1. ;
  2. ; BILDSCHIRMTREIBER FUER CP/M EMULATOR
  3. ;
  4. ;
  5. ; (C) 1990,1991 by Jürgen Weber
  6. ;
  7.  
  8. LOCALS
  9.  
  10. INCLUDE DOS.INC
  11.  
  12. WS_KEY equ TRUE
  13.  
  14. EMU_SCR_PAGE EQU 0
  15. DOS_SCR_PAGE EQU 1
  16.  
  17. HIGHLIGHT_ATTR EQU 1000b
  18. UNDERLINE_ATTR EQU 110b
  19. BLINK_ATTR     EQU 10000000b
  20.  
  21. SCRNWIDTH EQU 79
  22. LASTLINE  EQU 24
  23.  
  24. emudata_seg segment para public 'DATA'
  25.  
  26.  
  27. IF WS_KEY
  28. after_ctrl_q db 0
  29.  
  30. CTRL_MASK EQU 111111B
  31. ext_keys db 72, 'E' AND CTRL_MASK,0   ; up
  32.          db 73, 'R' AND CTRL_MASK,0   ; page up
  33.          db 75, 'S' AND CTRL_MASK,0   ; left
  34.          db 77, 'D' AND CTRL_MASK,0   ; right
  35.          db 80, 'X' AND CTRL_MASK,0   ; down
  36.          db 81, 'C' AND CTRL_MASK,0   ; page down
  37.          db 82, 'V' AND CTRL_MASK,0   ; ins
  38.          db 83, 'G' AND CTRL_MASK,0   ; del
  39.          db 115, 'A' AND CTRL_MASK,0  ; ctrl-left
  40.          db 116, 'F' AND CTRL_MASK,0  ; ctrl-right
  41.          db 71, 'Q' AND CTRL_MASK,'S' ; home
  42.          db 79, 'Q' AND CTRL_MASK,'D' ; end
  43.          db 117, 'Q' AND CTRL_MASK,'X' ; ctrl-end
  44.          db 118, 'Q' AND CTRL_MASK,'C'  ; ctrl-pgdn
  45.          db 119, 'Q' AND CTRL_MASK,'E'  ; ctrl-home
  46.          db 132, 'Q' AND CTRL_MASK,'R'  ; ctrl-pgup
  47.          db 0,0 ; 2. Null damit bei not found was geladen
  48. ENDIF
  49.  
  50. tr_usa             db '#','$','@','[','\',']'
  51.                    db '^','`','{','|','}','~'
  52. tr_french          db '#','$','à','°','ç',21
  53.                    db '^','`','é','ù','è','~'
  54. tr_german          db '#','$', 21,'Ä','Ö','Ü'
  55.                    db '^','`','ä','ö','ü','ß'
  56. tr_english         db '£','$','@','[','\',']'
  57.                    db '^','`','{','|','}','~'
  58. tr_danish          db '#','$','@','Æ','Θ','Å'
  59.                    db '^','`','æ','φ','å','~'
  60. tr_swedish         db '#','$','É','Ä','Ö','Å'
  61.                    db 'Ü','é','ä','ö','å','ü'
  62. tr_italian         db '#','$','@','°','\','é'
  63.                    db '^','ù','à','ò','è','ì'
  64. tr_spanish         db '₧','$','@','î','Ñ','¿'
  65.                    db '^','`','~','ñ','}','~'
  66. tr_end equ this byte
  67.  
  68. tr_tab_poi         dw offset tr_usa
  69. char_tran_flag     db FALSE
  70.  
  71.  
  72. cursor_size        dw (?)
  73. cursor_on_flag     db TRUE
  74. cursor_pos         dw 0
  75.  
  76. txt_attribute           db 7
  77.  
  78.  
  79. ESC_flag           db FALSE
  80. ctrl_paramcount    db 0
  81. ctrl_address       dw (?)
  82. ctrl_buf_entries   db 0
  83. ctrl_buf_poi       dw offset ctrl_buf
  84. ctrl_buf           db 10 dup (?)
  85.  
  86. ; Struktur zur beschreibung der einzelnen Bildschirmtreiberfunktionen
  87.  
  88. termfkt  struc
  89.          db          (?)          ; Funktionsnummer
  90.          db          (?)          ; Paramameterzahl
  91.          dw offset   (?)          ; Adresse des zugehoerigen UPs
  92. termfkt  ends
  93.  
  94. ; Tabelle fuer Terminalfunktionen des Schneider CPC
  95. ; (noch nicht alle Funktionen implementiert)
  96.  
  97. CPC_tab  termfkt <0,0,dummy_rout>
  98.          termfkt <1,0,dummy_rout>
  99.          termfkt <2,0,cursor_off>
  100.          termfkt <3,0,cursor_on>
  101.          termfkt <4,0,dummy_rout>
  102.          termfkt <5,0,dummy_rout>
  103.          termfkt <6,0,dummy_rout>
  104.          termfkt <7,0,char_out>    ;  Bell macht Bios
  105.          termfkt <8,0,char_out>    ;  csr left macht bios
  106.          termfkt <9,0,csr_right>
  107.          termfkt <10,0,char_out>   ;  csr down macht bios
  108.          termfkt <11,0,csr_up>
  109.          termfkt <12,0,clear_screen>
  110.          termfkt <13,0,csr_to_lstart>
  111.          termfkt <14,0,dummy_rout>
  112.          termfkt <15,0,dummy_rout>
  113.          termfkt <16,0,clr_chr_at_cursor>
  114.          termfkt <17,0,del_line_to_cursor>
  115.          termfkt <18,0,del_line_from_cursor>
  116.          termfkt <19,0,clear_window_to_cursor>
  117.          termfkt <20,0,clear_window_from_cursor>
  118.          termfkt <21,0,dummy_rout>
  119.          termfkt <22,0,dummy_rout>
  120.          termfkt <23,0,dummy_rout>
  121.          termfkt <24,0,txt_inverse>
  122.          termfkt <25,0,dummy_rout>
  123.          termfkt <26,0,dummy_rout>
  124.          termfkt <27,0,use_esc_tab>
  125.          termfkt <28,0,dummy_rout>
  126.          termfkt <29,0,dummy_rout>
  127.          termfkt <30,0,cursor_home>
  128.          termfkt <31,2,set_cursor>
  129.  
  130.          db 0ffh                  ; sentinel
  131.  
  132. ; Tabelle fuer Terminalfunktionen von CP/M Plus
  133. ; (noch nicht alle Funktionen implementiert)
  134.  
  135.  
  136. ESC_tab   label byte
  137.  
  138. ; die erste Routine stammt nicht von CP/M Plus, sondern
  139. ; ist eigendefiniert (entsprechend zu Epson Druckern)
  140.  
  141.           termfkt <'@',0,Reset_Screen>
  142.  
  143.           termfkt <'0',0,dummy_rout> ; Statuszeile aus
  144.           termfkt <'1',0,dummy_rout> ; Statuszeile an
  145.           termfkt <'2',1,select_country>
  146.           termfkt <'3',1,dummy_rout> ; waehle Bildschirmmodus
  147.           termfkt <'A',0,csr_up>
  148.           termfkt <'B',0,ESC_csr_down>
  149.           termfkt <'C',0,ESC_csr_right>
  150.           termfkt <'D',0,ESC_csr_left>
  151.           termfkt <'E',0,ESC_clear_screen>
  152.           termfkt <'H',0,cursor_home>
  153.           termfkt <'I',0,csr_up_scr_down>
  154.           termfkt <'J',0,clear_window_from_cursor>
  155.           termfkt <'K',0,del_line_from_cursor>
  156.           termfkt <'L',0,insert_line>
  157.           termfkt <'M',0,delete_line>
  158.           termfkt <'N',0,delete_char_at_cursor>
  159.           termfkt <'Y',2,ESC_set_cursor>
  160.           termfkt <'b',0,dummy_rout> ; setze Zeichenhelligkeit
  161.           termfkt <'c',0,dummy_rout> ; setze Hintergrundhelligkeit
  162.           termfkt <'d',0,del_line_to_cursor>
  163.           termfkt <'e',0,cursor_on>
  164.           termfkt <'f',0,cursor_off>
  165.           termfkt <'j',0,push_cursor_pos>
  166.           termfkt <'k',0,pop_cursor_pos>
  167.           termfkt <'l',0,dummy_rout> ; loesche Zeile des Cursors
  168.           termfkt <'o',0,del_line_to_cursor>
  169.           termfkt <'p',0,inverse_on>
  170.           termfkt <'q',0,inverse_off>
  171.           termfkt <'r',0,underline_on>
  172.           termfkt <'s',0,blink_on>
  173.           termfkt <'t',0,blink_off>
  174.           termfkt <'u',0,underline_off>
  175.           termfkt <'v',0,dummy_rout>
  176.           termfkt <'w',0,dummy_rout>
  177.           termfkt <'x',0,dummy_rout> ; setze 24x80
  178.           termfkt <'y',0,dummy_rout> ; 24x80 wieder weg
  179.  
  180.           db 0ffh                 ; sentinel
  181.  
  182. emudata_seg ends
  183.  
  184.  
  185. emulator_seg segment para public 'CODE'
  186.  
  187. assume  cs:emulator_seg,ds:emudata_seg,es:nothing,ss:nothing
  188.  
  189. PUBLIC reset_crt,crtout,crtin,crtinstat,sel_scr_page,cursor_off,cursor_on
  190. EXTRN prg_exit:far
  191. EXTRN breakflag:byte
  192.  
  193. reset_crt proc
  194.      mov  ctrl_buf_entries,0
  195.      mov  ctrl_paramcount,0
  196.      mov  ctrl_buf_poi,offset ctrl_buf
  197.     ret
  198. reset_crt endp
  199.  
  200. ;
  201. crtout proc
  202. ;
  203. ; console character output aus register c
  204. ;
  205. ; es gibt zwei Sprungtabellen: ESC_tab für mit ESC eingeleitete
  206. ;                              CP/M Plus Steuercodes und
  207. ;                              CPC_tab für die Steuercodes des CPC
  208.        PUSHR <si,di,bp,ax>
  209.        mov al,ctrl_paramcount
  210.        cmp al,0
  211.        jnz short @@not_empty
  212.          cmp byte ptr ESC_flag,TRUE
  213.          mov byte ptr ESC_flag,FALSE
  214.          mov di,offset ESC_tab
  215.  
  216.          jz  short @@search_entrie
  217.          cmp cl,' '
  218.          jnc short @@write_out
  219.        mov di,offset CPC_tab
  220. @@search_entrie:
  221.        cmp byte ptr [di],0ffh
  222.        jz  short @@execon         ; nicht gefunden
  223.        cmp cl,[di]
  224.        jz short @@entrie_found
  225.        add di,4                   ; jeder Eintrag belegt 4 Bytes
  226.      jmp short @@search_entrie
  227.  
  228. @@entrie_found:
  229.        mov al,[di+1]              ; benoetigte Parameter
  230.        cmp al,0
  231.      jz  short @@execute
  232.        mov ctrl_paramcount,al
  233.        mov di,[di+2]
  234.        mov ctrl_address,di        ; Adresse des zugehoerigen UP merken
  235.       jmp short @@exit
  236.  
  237. @@not_empty:
  238.        mov bx,ctrl_buf_poi
  239.        mov [bx],cl                ; Parameter merken
  240.        inc bx
  241.        mov ctrl_buf_poi,bx
  242.        inc ctrl_buf_entries
  243.        mov al,ctrl_paramcount
  244.        cmp al,ctrl_buf_entries    ; alle Parameter komplett ?
  245.        jnz short @@exit
  246.        mov di,offset ctrl_address - 2
  247.  
  248. @@execute:
  249.        call [di+2]
  250. @@execon:
  251.        call reset_crt
  252.        jmp  short @@exit
  253.  
  254. @@write_out:
  255.        call char_out
  256. @@exit:
  257.        POPR <ax,bp,di,si>
  258.        ret
  259. crtout endp
  260.  
  261. ;
  262. ; display 0 terminated string in ds:si
  263. ;
  264.  
  265. use_esc_tab proc
  266.        mov  byte ptr ESC_flag,TRUE
  267.        ret
  268. use_esc_tab endp
  269. ;
  270. dummy_rout proc
  271.        ret
  272. dummy_rout endp
  273.  
  274. Reset_Screen proc
  275.           call ESC_clear_screen
  276.           call cursor_home
  277.           call inverse_off
  278.           call cursor_on
  279.           call underline_off
  280.           mov  char_tran_flag,FALSE
  281.           ret
  282. Reset_Screen endp
  283.  
  284. push_cursor_pos proc
  285.       call get_cursor_pos
  286.       mov  cursor_pos,dx
  287.       ret
  288. push_cursor_pos endp
  289.  
  290. pop_cursor_pos proc
  291.       mov dx,cursor_pos
  292.       call bios_set_cursor
  293.       ret
  294. pop_cursor_pos endp
  295.  
  296. get_cursor_pos proc
  297.        PUSHR <ax,si,di,bp>
  298.          mov ah,3
  299.          mov bh,EMU_SCR_PAGE
  300.          int 10h
  301.        POPR  <bp,di,si,ax>
  302.        ret
  303. get_cursor_pos endp
  304.  
  305. cursor_off proc
  306.        cmp cursor_on_flag,FALSE
  307.        jz  short @@exit
  308.        PUSHR <ax,bx,cx,si,di,bp>
  309.          call get_cursor_pos
  310.          mov  cursor_size,cx
  311.          mov ah,1                 ; define cursor
  312.          mov cx,0ffffh            ; unmoeglicher Wert = Cursor aus
  313.          mov bh,EMU_SCR_PAGE
  314.          int 10h
  315.          mov cursor_on_flag,FALSE
  316.        POPR  <bp,di,si,cx,bx,ax>
  317. @@exit:
  318.        ret
  319. cursor_off endp
  320.  
  321. cursor_on proc
  322.        cmp cursor_on_flag,TRUE
  323.        jz  short @@exit
  324.        PUSHR <ax,bx,cx,si,di,bp>
  325.          mov  cx,cursor_size
  326.          mov ah,1                 ; define cursor
  327.          mov bh,EMU_SCR_PAGE
  328.          int 10h
  329.        mov cursor_on_flag,TRUE
  330.        POPR  <bp,di,si,cx,bx,ax>
  331. @@exit:
  332.        ret
  333. cursor_on endp
  334.  
  335. csr_up_scr_down proc              ; ESC I
  336.        PUSHR <ax,bx,cx,si,di,bp>
  337.          call get_cursor_pos
  338.          cmp  dh,0                ; vorher schon oben ?
  339.          jz short @@is_up
  340.            dec dh                 ; y
  341.            call bios_set_cursor
  342.            jmp short @@exit
  343.    @@is_up:
  344.          push dx
  345.          mov ah,7                 ; scroll down window
  346.          mov al,1                 ; um eine Zeile
  347.          mov bh,txt_attribute
  348.          mov cx,0
  349.          mov dh,LASTLINE
  350.          mov dl,SCRNWIDTH
  351.          int 10h
  352.          pop dx
  353.          call bios_set_cursor
  354. @@exit:
  355.        POPR  <bp,di,si,cx,bx,ax>
  356.        ret
  357. csr_up_scr_down endp
  358.  
  359. insert_line proc
  360.        PUSHR <ax,bx,cx,si,di,bp>
  361.          call get_cursor_pos
  362.          push dx
  363. ; scrolle den Rest des Bildschirms ab Cursorpos eine Zeile nach unten
  364. ; Cursorpos bleibt erhalten
  365.          mov ah,7                 ; scroll down window
  366.          mov al,1                 ; eine Zeile
  367.          mov bh,txt_attribute
  368.          mov ch,dh
  369.          mov cl,0
  370.          mov dh,LASTLINE
  371.          mov dl,SCRNWIDTH
  372.          int 10h
  373.          pop dx
  374.          call bios_set_cursor
  375.        POPR  <bp,di,si,cx,bx,ax>
  376.        ret
  377. insert_line endp
  378.  
  379. delete_line proc
  380.        PUSHR <ax,bx,cx,si,di,bp>
  381.          call get_cursor_pos
  382.          push dx
  383. ; scrolle den Rest des Bildschirms ab Cursorzeile+1 eine Zeile nach unten
  384. ; Cursorpos bleibt erhalten
  385.          mov ah,6                 ; scroll up window
  386.          mov al,1                 ; um eine Zeile
  387.          mov bh,txt_attribute
  388.          mov ch,dh
  389.          mov cl,0
  390.          mov dh,LASTLINE
  391.          mov dl,SCRNWIDTH
  392.          int 10h
  393.          pop dx
  394.          call bios_set_cursor
  395.        POPR  <bp,di,si,cx,bx,ax>
  396.        ret
  397. delete_line endp
  398.  
  399. delete_char_at_cursor proc
  400.        PUSHR <ax,bx,cx,si,di,bp>
  401.          call get_cursor_pos
  402.          push dx
  403. @@while:                          ; WHILE XPos <SCRNWIDTH DO
  404.                                   ; schlürfe Rest der Zeile ein
  405.          inc dl
  406.          cmp dl,SCRNWIDTH
  407.          ja  short @@endwhile
  408.          call bios_set_cursor
  409.          call read_from_screen
  410.          push ax
  411.          dec  dl
  412.          call bios_set_cursor
  413.          pop  ax
  414.          mov  bl,ah ; attribute
  415.          mov  bh,EMU_SCR_PAGE
  416.          mov  cx,1
  417.          mov  ah,9 ; write char
  418.          int  10h
  419.          inc  dl
  420.        jmp short @@while
  421. @@endwhile:
  422.          pop dx
  423.          call bios_set_cursor
  424.        POPR  <bp,di,si,cx,bx,ax>
  425.        ret
  426. delete_char_at_cursor endp
  427.  
  428. read_from_screen proc             ; nach ax
  429.        PUSHR <si,di,bp>
  430.          mov ah,8                 ; bios read from screen
  431.          mov bh,EMU_SCR_PAGE
  432.          int 10h
  433.        POPR  <bp,di,si>
  434.        ret
  435. read_from_screen endp
  436.  
  437. csr_up proc
  438.        PUSHR <ax,bx,cx,si,di,bp>
  439.          call get_cursor_pos
  440.          cmp  dh,0                ; vorher schon oben ?
  441.          jz short @@dont
  442.            dec dh
  443.            call bios_set_cursor
  444.          @@dont:
  445.        POPR  <bp,di,si,cx,bx,ax>
  446.        ret
  447. csr_up endp
  448.  
  449. ESC_csr_down proc
  450.        PUSHR <ax,bx,cx,si,di,bp>
  451.          call get_cursor_pos
  452.          cmp  dh,LASTLINE         ; vorher schon unten ?
  453.          jz short @@dont
  454.            inc dh
  455.            call bios_set_cursor
  456.          @@dont:
  457.        POPR  <bp,di,si,cx,bx,ax>
  458.        ret
  459. ESC_csr_down endp
  460.  
  461. ESC_csr_right proc
  462.        PUSHR <ax,bx,cx,si,di,bp>
  463.          call get_cursor_pos
  464.          cmp  dl,SCRNWIDTH
  465.          jz short @@dont
  466.            inc dl
  467.            call bios_set_cursor
  468.          @@dont:
  469.        POPR  <bp,di,si,cx,bx,ax>
  470.        ret
  471. ESC_csr_right endp
  472.  
  473. ESC_csr_left proc
  474.        PUSHR <ax,bx,cx,si,di,bp>
  475.          call get_cursor_pos
  476.          cmp  dl,0
  477.          jz short @@dont
  478.            dec dl
  479.            call bios_set_cursor
  480.          @@dont:
  481.        POPR  <bp,di,si,cx,bx,ax>
  482.        ret
  483. ESC_csr_left endp
  484.  
  485. csr_right proc
  486.        PUSHR <ax,bx,cx,si,di,bp>
  487.          call get_cursor_pos
  488.          cmp  dl,SCRNWIDTH
  489.          jz short @@dont
  490.            inc dl
  491.            call bios_set_cursor
  492.          @@dont:
  493.        POPR  <bp,di,si,cx,bx,ax>
  494.        ret
  495. csr_right endp
  496.  
  497. clear_window proc
  498.        PUSHR <ax,bx,cx,si,di,bp>
  499.          mov ah,6                 ; scroll window
  500.          mov al,0                 ; clear window
  501.          mov bh,txt_attribute
  502.          int 10h
  503.        POPR  <bp,di,si,cx,bx,ax>
  504.        ret
  505. clear_window endp
  506.  
  507. ESC_clear_screen proc
  508.        PUSHR <cx,dx>
  509.          mov ch,0                 ; y oben
  510.          mov dh,25                ; y unten
  511.          mov cl,0                 ; x links
  512.          mov dl,SCRNWIDTH         ; x rechts
  513.          call clear_window
  514.        POPR  <dx,cx>
  515.        ret
  516. ESC_clear_screen endp
  517.  
  518. clear_screen proc
  519.        call ESC_clear_screen
  520. clear_screen endp                 ; und weiter mit Home
  521.  
  522. cursor_home proc
  523.        push dx
  524.        mov  dx,0                  ; x=y=0
  525.        call bios_set_cursor
  526.        pop dx
  527.        ret
  528. cursor_home endp
  529.  
  530. set_cursor proc
  531.        PUSHR <dx,si>
  532.          mov si,offset ctrl_buf
  533.          mov dx,[si]
  534.          dec dh
  535.          dec dl                   ; offset 1 beim CPC
  536.          call bios_set_cursor
  537.        POPR  <si,dx>
  538.        ret
  539. set_cursor endp
  540.  
  541. ESC_set_cursor proc
  542.        PUSHR <dx,si>
  543.          mov si,offset ctrl_buf
  544.          mov dx,[si]
  545.          sub dh,20h
  546.          sub dl,20h               ; offset 32 bei CP/M Plus
  547.          cmp dl,LASTLINE
  548.          jna short @@yok
  549.          mov dl,LASTLINE
  550. @@yok:
  551.          cmp dh,SCRNWIDTH
  552.          jna short @@xok
  553.          mov dh,SCRNWIDTH
  554. @@xok:
  555.          xchg dh,dl
  556.          call bios_set_cursor
  557.        POPR  <si,dx>
  558.        ret
  559. ESC_set_cursor endp
  560.  
  561. ;
  562. ; dh=y
  563. ; dl=x
  564. ;
  565. bios_set_cursor proc
  566.        PUSHR <ax,cx,si,di,bp>
  567.          mov bh,EMU_SCR_PAGE
  568.          mov ah,2
  569.          int 10h
  570.        POPR  <bp,di,si,cx,ax>
  571.        ret
  572. bios_set_cursor endp
  573.  
  574. sel_scr_page proc
  575.        PUSHR <ax,si,di,bp>
  576.        mov ah,5
  577.        int 10h
  578.        POPR  <bp,di,si,ax>
  579.        ret
  580. sel_scr_page endp
  581.  
  582. csr_to_lstart proc                ; Cursor an Zeilenanfang
  583.        PUSHR <ax,bx,cx,si,di,bp>
  584.          call get_cursor_pos
  585.          mov bh,EMU_SCR_PAGE
  586.          xor dl,dl                ; x:= 0
  587.          call bios_set_cursor
  588.        POPR  <bp,di,si,cx,bx,ax>
  589.        ret
  590. csr_to_lstart endp
  591.  
  592. clr_chr_at_cursor proc
  593.        mov cx,1                   ; 1 char
  594.        call clr_chars
  595.        ret
  596. clr_chr_at_cursor endp
  597.  
  598. ; Zeichenzahl in cx
  599. clr_chars proc
  600.        PUSHR <ax,bx,cx,si,di,bp>
  601.          mov al,' '
  602.          mov bh,EMU_SCR_PAGE
  603.          mov bl,txt_attribute
  604.          mov ah,9
  605.          int 10h
  606.        POPR  <bp,di,si,cx,bx,ax>
  607.        ret
  608. clr_chars endp
  609.  
  610. del_line_to_cursor proc
  611.        PUSHR <ax,bx,cx,si,di,bp>
  612.          call get_cursor_pos
  613.          push dx
  614.            mov cl,dl              ; x
  615.            mov dl,0
  616.            call bios_set_cursor
  617.            mov ch,0
  618.            call clr_chars
  619.          pop dx
  620.          call bios_set_cursor
  621.        POPR  <bp,di,si,cx,bx,ax>
  622.        ret
  623. del_line_to_cursor endp
  624.  
  625. del_line_from_cursor proc
  626.        PUSHR <cx,dx>
  627.          call get_cursor_pos
  628.          mov cl,SCRNWIDTH
  629.          sub cl,dl
  630.          mov ch,0
  631.          call clr_chars
  632.        POPR  <dx,cx>
  633.        ret
  634. del_line_from_cursor endp
  635.  
  636.  
  637. clear_window_to_cursor proc
  638.        PUSHR <cx,dx>
  639.          call get_cursor_pos
  640.  
  641.          dec dh                   ; y
  642.          mov ch,0
  643.          mov cl,0
  644.          mov dl,SCRNWIDTH
  645.          call clear_window
  646.          call del_line_to_cursor
  647.        POPR  <dx,cx>
  648.        ret
  649. clear_window_to_cursor endp
  650.  
  651. clear_window_from_cursor proc
  652.        PUSHR <cx,dx>
  653.          call del_line_from_cursor
  654.          call get_cursor_pos
  655.          inc dh                   ; y++
  656.          mov ch,dh
  657.          mov dh,24
  658.          mov cl,0
  659.          mov dl,SCRNWIDTH
  660.          call clear_window
  661.        POPR  <dx,cx>
  662.        ret
  663. clear_window_from_cursor endp
  664.  
  665. txt_inverse proc
  666.          xor txt_attribute,HIGHLIGHT_ATTR
  667.          ret
  668. txt_inverse endp
  669.  
  670. inverse_on proc
  671.          or txt_attribute,HIGHLIGHT_ATTR
  672.          ret
  673. inverse_on endp
  674.  
  675. inverse_off proc
  676.          and txt_attribute,not HIGHLIGHT_ATTR
  677.          ret
  678. inverse_off endp
  679.  
  680. underline_on proc
  681.          and txt_attribute,not UNDERLINE_ATTR
  682.          ret
  683. underline_on endp
  684.  
  685. underline_off proc
  686.          or txt_attribute,UNDERLINE_ATTR
  687.          ret
  688. underline_off endp
  689.  
  690.  
  691. blink_on proc
  692.          or txt_attribute,BLINK_ATTR
  693.          ret
  694. blink_on  endp
  695.  
  696. blink_off proc
  697.          and txt_attribute,not BLINK_ATTR
  698.          ret
  699. blink_off endp
  700.  
  701.  
  702. ;
  703. ; jedes Zeichen wird 2 mal ausgegeben, da Funktion 9 nicht den Cursor
  704. ; bewegt und Funktion 14 kein Attribut aendert
  705. ; dies selbst zu erledigen waere zu aufwendig
  706. ; Fkt 14 wird auf jeden Fall benoetigt, da sie u.a. piepsen kann
  707. ;
  708. char_out proc
  709.        PUSHR <si,di,bp,ax,cx>
  710.        mov al,cl     ;get to accumulator
  711.        cmp al,' '    ; Piepser oder CR ?
  712.        jb short @@dont
  713.        call char_tran
  714.         push ax
  715.          mov ah,9
  716.          mov bl,txt_attribute
  717.          mov bh,EMU_SCR_PAGE
  718.          mov cx,1
  719.          int 10h                  ; erst mal Attribut setzen
  720.         pop ax
  721. @@dont:
  722.        mov ah,14                  ; character output
  723.        mov bl,txt_attribute
  724.        int 10h                    ; und nochmal um den Cursor weiterzusetzen
  725.  
  726.        POPR <cx,ax,bp,di,si>
  727.        ret
  728. char_out endp
  729.  
  730. char_tran proc
  731.        cmp char_tran_flag,FALSE
  732.        jz  short @@exit
  733.        push es
  734.        push ds
  735.        pop  es
  736.        mov  di,offset tr_usa
  737.        mov  cx,tr_french-tr_usa
  738. ; muss Zeichen uebersetzt werden ?
  739.        repnz scasb
  740.        pop  es
  741.        jnz  short @@exit
  742.        sub di,offset tr_usa       ; di:= # zu uebersetzendes Zeichen
  743.        dec di                     ; da scas eins zuviel inct
  744.        mov bx,tr_tab_poi
  745.        mov al,bx[di]
  746. @@exit:
  747.        ret
  748. char_tran endp
  749.  
  750. select_country proc
  751.        mov si,offset ctrl_buf
  752.        mov al,[si]
  753.        cmp al,7
  754.        ja  short @@exit
  755.        mov byte ptr char_tran_flag,FALSE
  756.        cmp al,0
  757.        jz  @@noflag
  758.        mov byte ptr char_tran_flag,TRUE
  759. @@noflag:
  760.        mov bl,tr_french-tr_usa ; Eintraege pro Land
  761.        mul bl
  762.        add ax,offset tr_usa
  763.        mov tr_tab_poi,ax
  764. @@exit:
  765.        ret
  766. select_country endp
  767.  
  768.  
  769. ;
  770. ;
  771. crtinstat proc
  772. ;
  773. ; console status, return 0ffh if character ready, 00h,Z_flag if not
  774. ;
  775. ; Out: al=keyboard status
  776. ;
  777.         push bx
  778.         mov ah,1                  ; keybord status
  779.         int 16h
  780.         mov al,0ffh
  781.         jnz short @@exit
  782.         mov al,0
  783. @@exit:
  784.         pop bx
  785.         ret
  786. crtinstat endp
  787.  
  788.  
  789. crtin proc
  790. ;
  791. ; console character nach register a
  792. ;
  793. ; Out: al=ascii
  794. ;      ah zerstoert
  795. ;
  796. IF WS_KEY
  797.        mov al,after_ctrl_q
  798.        mov after_ctrl_q,0
  799.        cmp al,0
  800.        jnz @@end_crtin
  801. ENDIF
  802.        mov ah,0                   ; keybord input
  803.        push bx
  804.        int 16h
  805.        pop bx
  806.        cmp breakflag,TRUE
  807.        mov breakflag,FALSE
  808.        jnz short @@nobreak
  809.        call prg_exit
  810.        jmp crtin
  811. @@nobreak:
  812.  
  813. IF WS_KEY    ; erweiterte Codes nach WS übersetzen
  814.        cmp al,0
  815.        jnz short @@no_extended
  816.  
  817.        push bx
  818.  
  819.        mov bx,offset ext_keys
  820.        mov cx,ax
  821. @@cmp_loop:
  822.        mov al,[bx]            ; extended code
  823.        mov after_ctrl_q,0     ; damit es bei Aussprung richtig
  824.        cmp al,0
  825.        jz  short @@no_key_tr  ; z = Tabellen ende
  826.        cmp al,ch
  827.        pushf
  828.        inc bx
  829.        mov al,[bx]            ; CTRL-...
  830.        inc bx
  831.        mov ah,[bx]            ; CTRL-Q-...
  832.        inc bx
  833.        mov after_ctrl_q,ah
  834.        popf
  835.        jnz @@cmp_loop
  836.  
  837. @@no_key_tr:
  838.        pop bx
  839. @@no_extended:
  840. ENDIF
  841.  
  842. ; Umlaute werden in CP/M Form übersetzt
  843.        push di
  844.        push cx
  845.        push es
  846.         push ds
  847.         pop  es
  848.        mov  di,offset tr_french
  849.        mov  cx,tr_end-tr_french
  850. ; muss Zeichen uebersetzt werden ?
  851.        repnz scasb
  852.        pop  es
  853.        jnz  short @@exit
  854.        sub di,offset tr_french    ; di:= # zu uebersetzendes Zeichen
  855.        dec di                     ; da scas eins zuviel inct
  856.        mov ax,di
  857.        mov bx,tr_french-tr_usa
  858.        mov dx,0
  859.        div bx
  860.        mov di,dx
  861.        mov bx,offset tr_usa
  862.        mov al,bx[di]
  863. @@exit:
  864.        pop cx
  865.        pop di
  866.      ;  and al,7fh                ;strip parity bit von DR vorgeschlagen
  867. @@end_crtin:
  868.        ret
  869. crtin endp
  870.  
  871. emulator_seg ends
  872.  
  873. end
  874.  
  875.