home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CDOSDSK5.ZIP / CDOSDSK5.TD0 / XIOS / STATLINE.A86 < prev    next >
Encoding:
Text File  |  1989-01-26  |  26.8 KB  |  1,112 lines

  1. ; STATLINE.A86
  2. title 'Status Line Driver'
  3. pagesize 60+11
  4. ;****************************************
  5. ;*                    *
  6. ;*    STATUS LINE ROUTINES        *
  7. ;*    CDOS 6.0 XIOS            *
  8. ;*    DRI OS ENGR, JMB        *
  9. ;*                    *
  10. ;****************************************
  11. ; Major mods:
  12. ; 6.x
  13. ;  9 Nov 88 -- Update VC buffer for SR Terminals    GMS
  14. ; 24 Oct 88 -- Suppress WIN if serial console        IJ
  15. ; 15 Sep 88 -- PC Term support added            IJ
  16. ;  8 SEP 88 -- use global chan_sel value for MGE    GMS
  17. ; 19 AUG 88 -- ignore status line update if we're no     GMS
  18. ;        longer top_screen (386)
  19. ; 21 Jul 88 -- Individual locks in status lines for SR    IJ
  20. ; 17 JUN 88 -- Display printer numbers >9        GMS
  21. ; 20 APR 88 -- SunRiver support added            GMS
  22. ; 12 JAN 87 -- use PC equipment word to test if mono/color GMS
  23. ;  7 DEC 87 -- top_screen_mode contains real ROS values    GMS
  24. ;  2 DEC 87 -- replaced num_color/num_mono with video$  GMS
  25. ; 6.0
  26. ;  9 SEP 87 -- z_clk_on/off changed for seconds        GMS
  27. ; 5.2
  28. ; 14 MAY 87 -- **NOT IMPLEMENTED ** 
  29. ;        Real time clock re-sync'ed every minute    GMS
  30. ; 17 MAR 87 -- Enhanced keyboard support        GMS
  31. ; 5.1
  32. ; 29 OCT 86 -- Skip retrace test if EGA            GMS
  33. ; 16 Oct 86 -- Added support for Amstrad attribute    GMS
  34. ;  8 OCT 86 -- European keyboard support added        GMS
  35. ; 24 JUN 86 -- display seconds as well (##JW##)
  36. ; 22 OCT 85 -- change to support new keyboard driver
  37. ; 10 JUN 85 -- update 4.1 ASM86 version to RASM86
  38.  
  39. ; include COPYRITE.TXT
  40.  
  41. nolist
  42. include CDOS.EQU
  43. include XIOS.EQU
  44. include PCHW.EQU
  45. include ROSDATA.EQU
  46. include NAT.EQU
  47. if V386
  48. if SR
  49. include SR.EQU
  50. else
  51. include PTERM.EQU
  52. endif
  53. endif
  54. list
  55. ; These were included:
  56. ; include CDOS.EQU
  57. ; include XIOS.EQU
  58. ; include PCHW.EQU
  59. ; include ROSDATA.EQU
  60. ; include NAT.EQU
  61. if V386
  62. if SR
  63. ; include SR.EQU
  64. else
  65. ; include PTERM.EQU
  66. endif
  67. endif
  68. CGROUP    group    CODE
  69. DGROUP    group    DATA
  70.  
  71. public    io_statline@,    sl_error_out@,    ww_statline@
  72. public    z_sl_off@,    z_sl_mono@,    z_sl_color@
  73. public    z_sl_both@,    z_sl_blank@
  74. public    z_clk_on@,    z_clk_off@
  75. public    clear_statline@, switch_statline@
  76. public    sl_exit_value$,    sl_crt_flag$,    sl_attrib$
  77.     cseg
  78. extrn    flagwait@    :near, supif@        :near    ; in HEADER.A86
  79. extrn    put_crt_s@    :near, copy_full_top@    :near    ; in WINDOWS3.A86
  80. extrn    int16_entry@    :near                ; in ROSIF.A86
  81. extrn    set_time@    :near                ; in INIT.A86
  82. if V386
  83. extrn    point_vs@    :near                ; in WINDOWS2.A86
  84. if SR
  85. extrn    test1_srterm@   :near                ; in SRTERM.A86
  86. extrn    point_pc1@    :near
  87. extrn    sr_raw_key@    :near
  88. else
  89. extrn    test_pcterm@    :near                ; in PCTERM.A86
  90. extrn    point_pc1@    :near
  91. extrn    point_vc@    :near
  92. endif
  93. endif
  94.  
  95.     dseg
  96. extrn    beep_counter$    :byte                ; in ISRS.A86
  97. extrn    key_flag$    :word, switch_key$    :byte    ; in KEYBOARD.A86
  98. extrn    prtsc_key$    :byte, wmenu_key$    :byte
  99. extrn    NX_natnlstat$    :byte                
  100. extrn    NX_language$    :byte
  101. extrn    NX_countries$    :word
  102. extrn    ccb_list$    :word                ; in PUBDATA.A86
  103. extrn    blank$        :word, sl_pc_flag$    :byte
  104. extrn    cloneflag$    :byte, iattrib$        :byte
  105. extrn    im_here$    :byte                ; in WINDOWS3.A86
  106. extrn    top_screen$    :byte, graphic_bits$    :byte
  107. extrn    top_screen_mode$:byte, var_sync$    :byte
  108. extrn    video$        :byte                ; in WINDOWS1.A86
  109. extrn    pc_at$        :byte                ; in FLOPPY.A86
  110. extrn    nlcb$        :byte
  111. if V386
  112. extrn    active_vc$:byte                
  113. endif
  114. if SR
  115. extrn     first_vs_num$    :byte                ; in PUBDATA.A86
  116. extrn    con_basead$    :word, station_on_off$    :byte    ; in SRTERM.A86
  117. extrn    chan_sel$    :byte
  118. endif
  119. eject
  120.  
  121. ; IO_STATLINE will display status line on the 25th line of IBM PC monochrome
  122. ; and/or color screen.  First gather information into local string
  123. ; and then copy to the video display RAM.
  124.  
  125. ; The format of the status line is:
  126. ;Process1 Process2 Process3 Process4 Console=0 ABCDEF* ^S ^P=0 Win Caps Num 23:59
  127.  
  128.     cseg
  129.  
  130. ret_statline:
  131. ;------------
  132. ; Quick return if status line is being used:
  133.     ret
  134.  
  135.  
  136. ;============
  137. ww_statline@:
  138. ;============
  139. ; Window manager status line call.  It's the same as a normal call
  140. ; except that source data is char/attrib (160 bytes):
  141.     mov    si,rlr$            ; find our process
  142.     mov    bl,top_screen$
  143.     cmp    bl,P_CONS[si]        ; are we already top
  144.     je    ww_display
  145.     mov    P_CONS[si],bl        ; update WMENU VC #
  146.     push    cx ! push dx
  147.     mov    cx,P_DELAY
  148.     mov    dx,1
  149.     call    supif@            ; make sure of dispatch
  150.     pop dx ! pop cx
  151. ww_display:    
  152.  
  153.     mov    si,offset sl_get_160        ; for char/attrib fetch
  154.     jmps    sl_shared            ; go to it
  155.  
  156.  
  157. ;============
  158. io_statline@:
  159. ;============
  160. ; Normal io status line call:
  161. ;    entry:    if cx = 0  normal status update
  162. ;        if cx = offset, print 80 chars at cx:dx
  163. ;        if cx = 0FFFFh, resume normal status
  164. ;        DL = physical console number
  165. ;    exit:    al = 0  if call was successful
  166. ;        al = 0FFh  if call was blocked
  167.  
  168.     mov    si,offset sl_get_80        ; for char/attrib fetch
  169. sl_shared:
  170. if V386
  171. ; keep a note of whether or not we update a given physical console
  172.     mov    bl,dl                ; make PCon an offset
  173.     xor    bh,bh                ; to block the status line
  174.     cmp    cx,0ffffh            ; someone returning status line
  175.     jne    sl_shared1            ; to normal ?
  176.     mov    sr_statline_block[bx],false    ; yes, unblock this console
  177.     jmps    sl_shared2
  178. sl_shared1:
  179.     jcxz    sl_shared2            ; normal update, do nothing
  180.     mov    bx,rlr$                ; find our process
  181.     mov    bl,P_CONS[bx]            ; get the VCON number
  182.     xor    bh,bh                ; make a word
  183.     shl    bx,1                ; make a word offset
  184.     mov    bx,ccb_list$[bx]        ; point to the CCB
  185.     mov    bl,C_PC[bx]            ; read the pcon number
  186.     xor    bh,bh                ; clear BH
  187.     mov    sr_statline_block[bx],true    ; special, block this console
  188. sl_shared2:
  189. endif
  190.     mov    al,TRUE
  191.     xchg    sline_locked,al            ; is in io_statline at time
  192.     test    al,al                ; sline_locked = 0ffh if locked
  193.      jz    sl_free                ; sline_locked = 0 if not
  194.     cmp    sl_exit_value$,al        ; if not locked on exit
  195.      jnz    ret_statline            ; then just return
  196. sl_free:
  197.     push    es                ; save UDA
  198.      jcxz    sl_keep                ; if cx=0, skip source update
  199.     mov    sl_off,cx            ; store offset
  200.     mov    sl_seg,dx            ;   and segment of source data
  201. sl_keep:
  202.     cmp    sl_off,0ffffh            ; if normal status line
  203.      jz    sl_norm                ;  then skip
  204.      jcxz    sl_ex                ; if cx=0, ignore the call
  205.  
  206.     mov    sl_get_char,si            ; save fetch call
  207.     mov    si,sl_off            ; source offset
  208.     mov    dl,sl_crt_flag$            ; which crt bits
  209.     and    dl,sl_pc_flag$            ; mask out pc monitors
  210.     call    sl_disp_prep            ; ready reg's for display
  211. if V386
  212.     push    bx
  213.     mov    bx,rlr$            ; find our process
  214.     mov    dh,P_CONS[bx]        ; get our VCON number
  215.     pop    bx
  216. endif
  217. sl_ext_loop:
  218.     mov    es,sl_seg            ; source segment
  219.     call    sl_get_char            ; either get_80 or get_160
  220.     call    sl_put_char            ; put one char to status line
  221.     loop    sl_ext_loop            ; 80 times
  222. sl_ex:
  223.     jmp    sl_exit
  224.  
  225. sl_get_80:
  226.     mov    al,es:[si]            ; fetch character only
  227.     mov    ah,sl_attrib$            ; status line attribute
  228.     inc    si                ; bump once
  229.     ret
  230.  
  231. sl_get_160:
  232.     mov    ax,es:[si]            ; fetch character / attribute
  233.     inc    si                ; and bump twice
  234.     inc    si
  235.     ret
  236. eject
  237.  
  238. sl_norm:
  239. ;-------
  240. ; Normal status line update:
  241. ; DL = physical console
  242.  
  243. if V386
  244.     mov    bl,dl                ; make PCon an offset
  245.     xor    bh,bh                ; to block the status line
  246.     cmp    sr_statline_block[bx],true    ; is it blocked ?
  247.      je     io_stat_ret            ; yes, do nothing
  248. if SR
  249.     cmp    dl,0                ; see if dl is too big
  250.      je    io_stat                ; if it isn't, skip
  251.     call    test1_srterm@            ; test if SUN RIVER main console
  252.     jz    io_stat_ret            ; no
  253.     mov    es,con_basead$            ; base address of control regs
  254.     mov    bl,chan_sel$            ; get old select
  255.     xor    bh,bh
  256.     test    byte ptr station_on_off$[bx],ON  ; is station ON
  257.     jz    io_stat_ret            ; no..
  258.     push    dx
  259.     mov    dl,top_screen$
  260.     call    point_vs@
  261.     call    copy_full_top@            ; keep VS_ buffer up to date
  262.     pop    dx
  263.     jmps    io_stat                ; yes..
  264. else
  265.     jmps    io_stat
  266. endif
  267. io_stat_ret:
  268.     jmp    sl_exit
  269. io_stat:
  270. else
  271.     mov    dl,0                ; force to main console
  272. endif
  273.     push ds ! pop es
  274.     mov    di,offset status_msg
  275.     mov    al,' '
  276.     mov    cx,offset smsg_hour - offset status_msg
  277.     rep    stosb                ; blank out all but time
  278.  
  279.     lea    si,console_msg
  280.     lea    di,smsg_cstr
  281.     mov    cx,length console_msg
  282.     rep    movsb
  283.  
  284.     mov    al,dl                ; physical console number
  285.     call    conv_digit            ; convert to ascii
  286.     mov    smsg_cnum,al            ; save it
  287. ;    or    ah,ah                ; > 9 not supported currently
  288. ;    jz    s_onedigit
  289. ;    mov    smsg_cnum+1,ah
  290. ;s_onedigit:
  291.  
  292.     lea    di,status_msg            ; at the start
  293.     mov    rev_console,offset rev_list
  294.     mov    bx,offset ccb_list$
  295. search_ccb:
  296.     mov    si,[bx]            ; ccb pointer
  297.     inc bx ! inc bx
  298.     cmp    dl,C_PC[si]        ; our ccb
  299.     jne    search_ccb        ; no get next
  300.     mov    bx,si            ; bx -> ccb
  301. sl_proc_loop:
  302.     mov    si,C_OWNER[bx]            ; si -> proc desc
  303.     test    si,si                ; if zero
  304.      jz    sl_no_pd            ;   then it's nobody
  305.  
  306.     test    P_FLAG[si],PF_SYS
  307.     lea    si,P_NAME[si]            ; si -> process name
  308.      jz    sl_move_pd            ; skip if user process
  309.  
  310. sl_no_pd:                    ; if system or null
  311.     lea    si,blank_pd            ;   show the space
  312. sl_move_pd:
  313.     mov    cx,8
  314.     rep    movsb                ; store the name
  315.     inc    di                ; to next process
  316.     test    C_STATE[bx],CSM_BACKGROUND
  317.      jnz    sl_backg
  318.     push    bx
  319.     call    sl_foreg
  320.     pop    bx
  321. sl_backg:
  322.     add    rev_console,2
  323.     mov    bx,C_LINK[bx]            ; link to next
  324.     cmp    bx,0000h            ; end link ?
  325.      jne    sl_proc_loop
  326.  
  327. s_get_openvec:                    ; display a letter for each drive
  328.     push    dx
  329.                         ; with open files  ABCDEF*
  330.     mov    dx,open_vec$            ; BDOS sets this vector in SYSDAT
  331.     mov    di,offset smsg_openvec        ; support up to 4 open drives
  332.     mov    cx,13                ; drives to check
  333.     mov    al,'A'                ; start off with A: drive
  334. s_get_open1:
  335.     shr    dx,1                ; test the LSB
  336.      jnc    s_get_open3            ; skip if not open
  337.     cmp    di,offset smsg_openvec+2    ; do we have space to display
  338.      jne    s_get_open2            ; skip if O.K.
  339.     dec    di                ; else go and overwrite 4th
  340.     mov    al,'*'                ; remind them there are more
  341. s_get_open2:                    ; AL = character to display
  342.     stosb                    ; store it into the status line
  343. s_get_open3:
  344.     inc    ax                ; move to next drive
  345.     test    dx,dx                ; test if any more open files
  346.      jnz    s_get_open1            ; loop back if more
  347.     pop    dx
  348.  
  349. ;; National keyboard support
  350. NX_update_status:                ; display country/mode
  351.  
  352. if V386
  353.     cmp    dl,0                ; see if dl is too big
  354.      je    nx_main                ; if it isn't, skip
  355. if SR
  356.     call    test1_srterm@            ; test if SUN RIVER main console
  357.     jz    nx_not_sr            ; no
  358.     mov    al,dl                ; physical to AL
  359.     call    point_pc1@
  360.     mov    al,'8'                ; assume eight bit mode
  361.     test    PC_NATNLSTAT,NX_just7_bit
  362.     jz    NX_bits                ; skip if not seven bit
  363.     mov    al,'7'                ; else display 'xx7'
  364. NX_bits:
  365.     mov    smsg_NX_bits,al            ; drop 7 or 8 into status line
  366.     sub    bx,bx                ; assume U.S.A.
  367.     test    PC_NAT,0ffh            ; national keyboard
  368.     jz    NX_updt_country            ; if not, assumption O.K.
  369.     test    PC_NATNLSTAT$,NX_nkbd_bit     ; U.S.
  370.     jz    NX_updt_country    
  371.     mov    bl,PC_LANGUAGE            ; else get language code
  372.     and    bl,0fh                ;  remove enhanced bit
  373.     jmps    NX_updt_country
  374. nx_not_sr:
  375. else
  376. ; we have a naming conflict on eg PC_NAT between PCTerm and Sunriver
  377. ; when we combine the PCTerm and Sunriver we will have to resolve this
  378. ; and then the following code will go in the SR as well
  379. ;
  380.     call    test_pcterm@            ; test if PC Terminal
  381.     jz    nx_main                ; no
  382.     mov    al,dl                ; physical to AL
  383.     call    point_pc1@
  384.     mov    al,'8'                ; assume eight bit mode
  385.     test    PC_NATNLSTAT,NX_just7_bit
  386.     jz    NX_bits_pc            ; skip if not seven bit
  387.     mov    al,'7'                ; else display 'xx7'
  388. NX_bits_pc:
  389.     mov    smsg_NX_bits,al            ; drop 7 or 8 into status line
  390.     sub    bx,bx                ; assume U.S.A.
  391.     test    PC_NAT,0ffh            ; national keyboard
  392.     jz    NX_updt_country            ; if not, assumption O.K.
  393.     test    PC_NATNLSTAT$,NX_nkbd_bit     ; U.S.
  394.     jz    NX_updt_country    
  395.     mov    bl,PC_LANGUAGE            ; else get language code
  396.     and    bl,0fh                ;  remove enhanced bit
  397.     jmps    NX_updt_country
  398. endif
  399. nx_main:
  400. endif
  401.     mov    al,'8'                ; assume eight bit mode
  402.     test    NX_natnlstat$,NX_just7_bit
  403.     jz    NX_updt_stat_bits        ; skip if not seven bit
  404.     mov    al,'7'                ; else display 'xx7'
  405. NX_updt_stat_bits:
  406.     mov    smsg_NX_bits,al            ; drop 7 or 8 into status line
  407.     sub    bx,bx                ; assume U.S.A.
  408.     test    NX_natnlstat$,NX_nkbd_bit    ; see if national keboard
  409.     jz    NX_updt_country            ; if not, assumption O.K.
  410.     mov    bl,NX_language$            ; else get language code
  411.     and    bl,0fh                ;  remove enhanced bit
  412. NX_updt_country:
  413.     shl    bx,1                ; make it offset in 2-byte table
  414.     mov    ax,word ptr NX_countries$[bx]    ; get language abreviation
  415.     mov    word ptr smsg_NX_country,ax    ; drop it into status line
  416.  
  417. s_window:
  418. if V386
  419.     test    dl,dl                ; main console ?
  420.      jz    s_window1            ; don't need to test further
  421. if not SR                    ; for the moment exclude SR
  422.     call    test_pcterm@            ; is it a PC Terminal
  423.      jz    s_capslock            ; if so suppress the Win msg
  424. endif
  425. s_window1:
  426. endif
  427.     cmp    im_here$,0
  428.      jz    s_capslock
  429.     mov    si,offset winstr
  430.     mov    di,offset smsg_window
  431.     mov    cx,length winstr
  432.     rep    movsb
  433.  
  434. s_capslock:
  435.     push    ds
  436.     mov    ax,PC_SEGMENT
  437.     mov    ds,ax
  438.     mov    al,kb_flag_40
  439.     pop    ds
  440.     test    al,CAPSLOCK_BIT
  441.      jz    s_numlock
  442.     mov    si,offset capstr
  443.     mov    di,offset smsg_capslock
  444.     mov    cx,length capstr
  445.     rep    movsb
  446.  
  447. s_numlock:
  448.     test    al,NUMLOCK_BIT
  449.      jz    sl_time
  450.     mov    si,offset numstr
  451.     mov    di,offset smsg_numlock
  452.     mov    cx,length numstr
  453.     rep    movsb
  454.  
  455. sl_time:
  456.     cmp    sl_clk_flag,0            ; if clocks disabled
  457.      jz    sl_display            ;   then skip
  458.  
  459. sl_hours:
  460.     mov    al,tod_hour$            ; get current hour from sysdat
  461.     call    sl_ascii            ; convert bcd to ascii
  462.     mov    smsg_hour,ax            ; and store the minute
  463.     mov    al,tod_min$
  464.     call    sl_ascii            ; convert bcd to ascii
  465.     mov    smsg_min,ax            ; and store the minute
  466.     mov    al,tod_sec$
  467.     call    sl_ascii
  468.     mov    smsg_sec,ax
  469.  
  470. sl_display:
  471.     mov    dl,sl_crt_flag$            ; get allowable crt bits
  472.     and    dl,sl_pc_flag$            ; mask out pc monitors
  473.     test    dl,SL_MONO_BIT + SL_COLOR_BIT
  474.      jz    sl_exit                ; if both off, bag it
  475.  
  476.     mov    si,offset status_msg
  477.     call    sl_disp_prep            ; get the reg's ready
  478. sl_disp1:
  479.     cmp    cloneflag$,IS_AMSTRAD
  480.      jne    use_def1
  481.     mov    ah,iattrib$            ; get amstrad default
  482.     jmps    def1
  483. use_def1:
  484.     mov    ah,0Fh                ; normal attribute
  485. def1:
  486.     cmp    cl,stop_rev            ; are we past it?
  487.      ja    sl_disp2            ; if so, skip
  488.     cmp    cl,start_rev            ; time to start?
  489.      jb    sl_disp2            ; if not, skip
  490.     cmp    cloneflag$,IS_AMSTRAD
  491.     jne    use_def2
  492.     mov    al,iattrib$
  493.     mov    ah,al
  494.     and    ax,8877h            ; save highlights
  495.     push    cx
  496.     mov    cl,4
  497.     rol    al,cl                ; swap colours
  498.     pop    cx
  499.     or    ah,al                ; re-combine
  500.     jmps    sl_disp2
  501. use_def2:
  502.     mov    ah,70h                ; reverse video it
  503.  
  504. sl_disp2:
  505. if V386
  506.     cli
  507.     push    ax
  508.     push    bx
  509.     mov    bx,rlr$            ; find our process
  510.     mov    dh,P_CONS[bx]        ; get the VCON number
  511.     push    dx            ; save VCON in DH
  512.     mov    dl,dh
  513. if not SR
  514.     cmp    dl,NUM_VIR_CONS
  515.      jb    sl_disp3    
  516.     call    point_vc@
  517.     cmp    VC_CRT_ROWS,CRT_ROWS_C    ; in 24 line mode ?
  518.      jmps    sl_disp4
  519. sl_disp3:
  520. endif
  521.     call    point_vs@
  522.     cmp    VS_CRT_ROWS,CRT_ROWS_C    ; in 24 line mode ?
  523. sl_disp4:
  524.     pop    dx
  525.     pop    bx
  526.     pop    ax
  527.      jne    sl_exit            ; if not 24 line skip the update
  528.  
  529.  
  530.     push    dx            ; save VCON in DH
  531.     mov    dh,sl_crt_flag$            ; get allowable crt bits
  532.     and    dh,sl_pc_flag$            ; mask out pc monitors
  533.     test    dh,SL_MONO_BIT + SL_COLOR_BIT
  534.     pop    dx
  535.     sti
  536.      jz    sl_exit                ; if both off, bag it
  537.  
  538. endif                    ; so ignore update
  539.     lodsb                    ; get character
  540.     call    sl_put_char            ; put ax to status line
  541.     loop    sl_disp1
  542. sl_exit:
  543.     pop    es
  544.     mov    al,sl_exit_value$        ; successful update
  545.     mov    sline_locked,al            ; free the semaphore
  546.  
  547.     JMPS    sl_ret                ; the following was patched
  548.                         ; out because of incompatibilty
  549.                         ; with TIME command
  550.     test    pc_at$,0ffh            ; are we on AT/clone
  551.      jz    sl_ret
  552.     jmp    set_time@            ; yes..re -sync the clock
  553. sl_ret:
  554. if V386                ; sl_off was used to block normal update
  555.     mov    sl_off,0ffffh    ; with SunRiver we have an explicit block
  556. endif                ; per status line so return to non-block value
  557.     sti
  558.     ret
  559. eject
  560.  
  561. sl_foreg:
  562.     mov    si,rev_console
  563.     mov    ax,[si]             ; hilight start-stop
  564.     mov    START_STOP,ax            ; save for later
  565. s_ctrlS:
  566.     mov    ax,C_STATE[bx]
  567.     test    ax,CSM_CTRLS
  568.      jz    s_ctrlO
  569.     mov    smsg_ctrlS,'S^'
  570.     jmps    s_ctrlP
  571. s_ctrlO:
  572.     test    ax,CSM_CTRLO
  573.      jz    s_ctrlP                ; ctrl S and ctrl O are mutally
  574.     mov    smsg_ctrlS,'O^'            ; exclusive print one of ^S or ^O
  575. s_ctrlP:
  576.     test    ax,CSM_CTRLP
  577.      jz    s_mode
  578.     mov    smsg_ctrlP,'P^'
  579.     mov    dh,'='
  580.     mov    smsg_ctrlP_num,dh
  581.     mov    al,C_MIMIC[bx]
  582.     call    conv_digit            ; convert to ascii
  583.     mov    smsg_ctrlP_num+1,al        ; save it
  584.     or    ah,ah                ; > 9 
  585.     jz    s_mode
  586.     mov    smsg_ctrlP_num+2,ah
  587. s_mode:
  588.     ret
  589.     
  590. ; convert hex number in al to ascii in ah and al
  591. conv_digit:
  592.     xor    ah,ah
  593. do_tens:
  594.     cmp    al,9
  595.     jbe    do_digit
  596.     sub    al,10
  597.     inc    ah                ; increment tens
  598.     jmps    do_tens
  599. do_digit:
  600.     or      al,'0'              ; convert to ascii
  601.     or    ah,ah
  602.     jz    do_al
  603.     or    ah,'0'
  604.     xchg    al,ah                ; make al tens
  605. do_al:
  606.     ret
  607.     
  608. sl_disp_prep:
  609. ; Set up pointers and count for status display:
  610.  
  611.     mov    di,S_L_OFFSET * 2
  612.     mov    bx,offset status_copy
  613.     mov    cx,80                ; character count
  614.     ret
  615.  
  616. sl_put_char:
  617. ; Put one char/attrib to either or both status lines:
  618. ;    entry:    ax = char/attrib
  619. ;        dl = crt code mask   01 => mono  02 => color
  620. if V386
  621. ;        dh = VC number on start of STATLINE update
  622. endif
  623.  
  624. if not V386                    ; always update for SunRiver/PCTerm
  625.     cmp    ax,[bx]                ; if character is the same
  626.      jz    sl_put4                ;   then just bump pointers
  627. endif
  628.     mov    [bx],ax                ; save the copy
  629.     test    dl,SL_MONO_BIT
  630.      jz    sl_put1                ; skip if not to mono
  631.  
  632.     mov    es,sl_mono_seg
  633. if V386
  634.     cli
  635.     push    bx
  636.     mov    bx,rlr$            ; find our process
  637.     cmp    dh,P_CONS[bx]        ; has our VCON number changed
  638.     pop    bx
  639.     jne    sl_put1            ; yes we must be in background
  640. endif
  641.     mov    es:[di],ax        ; store if mono on
  642.     
  643. sl_put1:
  644.     sti
  645.     test    dl,SL_COLOR_BIT
  646.      jz    sl_put4                ; back to loop if off
  647.     cmp    top_screen_mode$,03        ; if anyone is in graphics
  648.      jnz    sl_put4                ;   then don't show color
  649.  
  650. ; Color status line character output:
  651.  
  652.     push    bx                ; get some room
  653.     push    cx
  654.     push    dx
  655.     mov    es,sl_color_seg
  656. if V386
  657.     cli
  658.     mov    bx,rlr$            ; find our process
  659.     cmp    dh,P_CONS[bx]        ; has our VCON number changed
  660.      jne    sl_c_inback         ; yes we must be in background
  661. endif
  662.  
  663.     cmp    var_sync$,0            ; need to wait for retrace?
  664.      je    sl_c_nowait            ;   no, just ship it
  665.  
  666.     mov    bx,ax                ; save char in bx
  667.     mov    dx,COLOR_PORT+6            ; crt status
  668.     mov    cx,3                ; maximum wait
  669.  
  670. if not V386
  671.     cli                    ;; hold the interrupts
  672. endif
  673. sl_c_norm1:
  674.     in    al,dx                ;; wait for horiz retrace
  675.     test    al,HRT                ;;   to go away
  676.     loopnz    sl_c_norm1            ;; but don't wait too long
  677. sl_c_norm2:
  678.     in    al,dx                ;; wait for a fresh
  679.     test    al,HRT                ;;   horiz retrace
  680.      jz    sl_c_norm2
  681.     xchg    ax,bx                ;; char to ax
  682. sl_c_nowait:
  683.     stosw                    ;; store and bump di
  684.     sti                    ;; ints back on
  685.  
  686.     pop    dx                ; recover registers
  687.     pop    cx
  688.     pop    bx
  689.     jmps    sl_put5                ; di already bumped
  690. if V386
  691. sl_c_inback:
  692.     sti                    ;; ints back on
  693.     pop    dx                ; recover registers
  694.     pop    cx
  695.     pop    bx
  696. endif
  697. sl_put4:
  698.     inc    di                ; bump the crt pointer
  699.     inc    di
  700. sl_put5:
  701.     inc    bx                ; bump the copy pointer
  702.     inc    bx
  703.     ret                    ; back to loop
  704.  
  705.  
  706. sl_ascii:
  707. ; Convert bcd in al to ascii in ax:
  708.  
  709.     mov    ah,33h                ; the ms nibbles
  710.     mov    cl,4
  711.     ror    ax,cl                ; al = 10's digit
  712.     mov    cl,4
  713.     ror    ah,cl                ; ah = 1's digit
  714.     ret
  715. eject
  716.  
  717. sl_error_out@:
  718. ;-------------
  719. ; ***  Status line error message entry  ***
  720. ;
  721. ; entry:    si -> error message
  722. ;        di -> allowable responses  (count,string..)
  723. ; exit:    al = response character
  724.  
  725.  
  726. if V386
  727.     mov    al,'A'                ;   accept all errors
  728.     cmp    active_vc$,NUM_VIR_CONS
  729.     jae    a_ret                ; return immediately for PCTERM
  730. endif
  731.  
  732.     mov    al,sl_crt_flag$            ; if neither status line
  733.     and    al,sl_pc_flag$            ;   is enabled, then
  734.     mov    al,'A'                ;   accept all errors
  735.      jnz    sl_error_cont
  736. a_ret:
  737.     ret
  738.  
  739. sl_error_cont:                    ; status line is up
  740.     mov    al,TRUE
  741.     xchg    al,sline_locked            ; test and set status semaphore
  742.     test    al,al
  743.      jnz    sl_error_out@            ; if somebody's using it, wait
  744.     mov    sl_exit_value$,TRUE
  745.  
  746.     mov    sl_error_msg,si             ; save message offset
  747.     mov    sl_error_resp,di         ;   and responses
  748.     push    sl_off                 ; save offset address
  749.     push    sl_seg                 ;   and segment
  750.     push    key_flag$             ; save keyboard state
  751.  
  752.     push    es
  753.     push ds ! pop es            ; for local moves
  754.     mov    si,offset status_copy
  755.     mov    di,offset sl_error_save
  756.     mov    cx,80
  757.     rep    movsw                ; save the current status line
  758.     pop    es
  759.  
  760.     mov    dx,ds
  761.     mov    cx,sl_error_msg
  762.     call    io_statline@            ; print the error message
  763. if not SR
  764.     inc    beep_counter$
  765. endif
  766. er_response:
  767. if not SR
  768.     inc    beep_counter$            ; beep once
  769. endif
  770.  
  771. sl_wait:
  772. if SR
  773.     mov    dl,top_screen$            ; at this console
  774.     cmp    dl,NUM_VIR_CONS
  775.      jb    sl_wait_main
  776.     mov    cl,0                ; wait until key ready
  777.     call    sr_raw_key@            ; get a key
  778.     jmps    sl_wait_notmain
  779. sl_wait_main:
  780. endif
  781.     mov    dx,ER_FLAG
  782.     mov    key_flag$,dx            ; now keyboard is ours
  783.     call    flagwait@            ; wait here for a key
  784.  
  785.     mov    ah,1                ; ROS int 10h status
  786.     call    int16_entry@            ; a key there?
  787. ;     jz    sl_wait                ; jump if no
  788.      jz    er_response
  789.  
  790.     sub    ah,ah                ; ROS int 10h conin
  791.     call    int16_entry@
  792.  
  793.     sub    bl,bl                ; zero out the special keys
  794.     mov    prtsc_key$,bl            ; we won't accept them
  795.     mov    wmenu_key$,bl
  796.     mov    switch_key$,bl
  797.  
  798. sl_wait_notmain:
  799.     or    al,al                ; is this an extended code
  800. ;     jz    sl_wait                ; if so, try again...we don't
  801.      jz    er_response            ;  want it
  802.  
  803.     and    al,0DFh                ; convert to upper case
  804.     mov    di,sl_error_resp
  805.     mov    cl,[di]
  806.     mov    ch,0
  807.      jcxz    er_resp_good            ; if di -> 0, take anything
  808.  
  809.     push     es
  810.     push ds ! pop es
  811.     inc    di                ; to response chars
  812.     repnz    scasb                ; check for legal value
  813.     pop    es
  814.      jnz    er_response            ; if bad, try again
  815.  
  816. er_resp_good:
  817.     mov    sl_error_key,al            ; save the value
  818.     mov    dx,ds
  819.     mov    cx,offset sl_error_save
  820.     call    ww_statline@            ; full 160 byte write
  821.  
  822.     mov    bl,top_screen$            ; this is the current VC
  823.     xor    bh,bh
  824.     shl    bx,1                ; make word offset
  825.     mov    bx,ccb_list$[bx]        ; pick up CCB
  826.     mov    dl,C_PC[bx]            ; hence Physical Console
  827.     mov    cx,0ffffh            ; resume normal status line
  828.     call    io_statline@            ; on this console
  829.  
  830.     pop    key_flag$
  831.     pop    sl_seg
  832.     pop    sl_off
  833.  
  834.     mov    sline_locked,FALSE
  835.     mov    sl_exit_value$,FALSE
  836.     mov    al,sl_error_key            ; return value
  837.     ret
  838. eject
  839.  
  840. ;************************************************
  841. ;*    STATUS LINE ESCAPE HANDLERS        *
  842. ;************************************************
  843.  
  844. z_sl_off@:
  845. ;---------
  846. ; esc 0  -  turn status line off:
  847.  
  848.     mov    dh,0                ; finish with none
  849.     jmps    z_sl_blank@            ; shared routine
  850.  
  851.  
  852. z_sl_mono@:
  853. ;----------
  854. ; esc 1  -  turn on monochrome status only:
  855.  
  856.     mov    dh,SL_MONO_BIT            ; finish with mono
  857.     jmps    z_sl_blank@            ; shared routine
  858.  
  859.  
  860. z_sl_color@:
  861. ;-----------
  862. ; esc 2  -  turn on color status only:
  863.  
  864.     mov    dh,SL_COLOR_BIT            ; finish with color
  865.     jmps    z_sl_blank@            ; shared routine
  866.  
  867.  
  868. z_sl_both@:
  869. ;----------
  870. ; esc 3  -  turn on both status lines:
  871.  
  872.     mov    dh,SL_MONO_BIT + SL_COLOR_BIT
  873. ;    jmps    z_sl_blank@            ; try for both
  874.  
  875.  
  876. z_sl_blank@:
  877. ;-----------
  878. ;    shared status line BLANK and change
  879. ;    entry:    dh = new sl_crt_flag$ to try
  880.  
  881.     mov    al,0FFh                ; first get sole control
  882.     xchg    al,sline_locked$
  883.     test    al,al                ; if someone's there
  884. if SR
  885.      jnz    z_sl_exit            ;   then exit
  886. else
  887.      jnz    z_sl_blank@            ;   then wait
  888. endif
  889.     push    bx                ; save vs_ pointer
  890.     push    es
  891. ;    mov    dl,video$
  892. ;    and    dl,MONO+COLOR            ; 01 for mono 02 color
  893.     mov    ax,PC_SEGMENT
  894.     mov    es,ax
  895.     mov    ax,es: equip_flag_40        ; get equipment byte
  896.     mov    dl,02                ; assume color seg
  897.     and    al,30h
  898.     cmp    al,30h                ; mono video ?
  899.     jne    z_sl_blank1
  900.     mov    dl,01                ; mono
  901. z_sl_blank1:
  902.     call    sl_disp_prep            ; prepare for blanking
  903.     push    dx
  904. if V386
  905.     push    bx
  906.     mov    bx,rlr$            ; find our process
  907.     mov    dh,P_CONS[bx]        ; get our VCON number
  908.     pop    bx
  909. endif
  910. z_sl_blank2:
  911.     mov    ax,blank$
  912.     call    sl_put_char            ; write one BLANK
  913.     loop    z_sl_blank2            ; 80 times
  914.     pop    dx
  915.     pop    es
  916.     pop    bx                ; restore vs_ pointer
  917.  
  918.     and    dl,dh                ; see who's left
  919.     mov    sl_crt_flag$,dl            ; and save for updates
  920.     mov    sline_locked$,0            ; release the semaphore
  921. z_sl_exit:
  922.     ret
  923.  
  924.  
  925. z_clk_off@:
  926. ;----------
  927. ; esc 4  -  turn status line clock display off:
  928.  
  929.     push    es
  930.     push    ds
  931.     pop    es                ; local for stos
  932.     mov    sl_clk_flag$,0            ; disable update
  933.     mov    di,offset smsg_hour$
  934.     mov    cx,8                ; clock characters
  935.     mov    al,' '
  936.     rep    stosb                ; BLANK 'em
  937.     pop    es
  938.     ret
  939.  
  940.  
  941. z_clk_on@:
  942. ;---------
  943. ; esc 5  -  enable status line clock display:
  944.  
  945.     mov    smsg_c1$,':'                ; first delimiter
  946.     mov    smsg_c2$,':'                ; second delimiter
  947.     mov    smsg_hour$,'0 '                ; assume initial time
  948.     mov    sl_clk_flag$,0FFh            ; if hour not 0
  949.     ret
  950. eject
  951.  
  952. clear_statline@:
  953. ;---------------
  954. ; If our status line is off and we're a 24 line cpm full screen,
  955. ; then BLANK the physical status line:
  956. ;  entry:    bx -> vs_
  957.  
  958.     mov    al,SL_MONO_BIT
  959.     cmp    VS_CRT_SEG,MONO_SEG
  960.      jz    clear_sl_test            ; skip if we're monochrome
  961.     mov    al,SL_COLOR_BIT
  962. clear_sl_test:
  963.     test    sl_crt_flag$,al            ; if our statline is on,
  964.      jnz    clear_sl_done            ;   then this isn't needed
  965.  
  966.     cmp    VS_BOTTOM,CRT_ROWS_C-1
  967.      jnz    clear_sl_done            ; skip if not 24 lines
  968.  
  969.     mov    di,2*S_L_OFFSET            ; point to physical statline
  970.     mov    cx,80                ; chars per line
  971.     mov    ax,blank$
  972.     call    put_crt_s@            ; store to our monitor
  973. clear_sl_done:
  974.     ret
  975.  
  976.  
  977. switch_statline@:
  978. ;----------------
  979. ; If in pc mode, disable status line; if not, enable.
  980. ; Called from io_switch and pc_kbd.
  981. ;  entry:    bx -> vs_
  982.  
  983.     mov    dl,top_screen$            ; if we're not on top
  984.     cmp    dl,VS_NUMBER            ;  then do nothing
  985.     jne    switch_ret
  986.     
  987.     mov    al,SL_MONO_BIT            ; assume we're monochrome
  988.     cmp    VS_CRT_SEG,MONO_SEG
  989.      jz    sw_stat_set            ; skip if on monochrome
  990.     mov    al,SL_COLOR_BIT            ; else we're color
  991. sw_stat_set:
  992.     test    VS_MODE,PCMODE_BIT
  993.      jz    sw_stat_on            ; skip if not pc mode
  994.     cmp    VS_BOTTOM,CRT_ROWS_P - 1
  995.      jb    sw_stat_on            ; skip if above the bottom
  996.  
  997. sw_stat_off:
  998.     not    al                ; to turn sl off, complement
  999.     and    sl_pc_flag$,al            ;   and mask the bit off
  1000.     jmps    sw_stat_clear            ; now force an update
  1001. sw_stat_on:
  1002.     or    sl_pc_flag$,al            ; to turn sl on,
  1003. ;    jmps    sw_stat_clear            ;   or it in and fall through
  1004.  
  1005. sw_stat_clear:
  1006.     push es ! push ds ! pop es
  1007.     mov    di,offset status_copy$
  1008.     mov    cx,80                ; words per stat line
  1009.     sub    ax,ax
  1010.     cld
  1011.     rep    stosw                ; force a full update
  1012.     pop    es                ; get back the uda
  1013. switch_ret:
  1014.     ret
  1015.  
  1016. eject
  1017.  
  1018.     dseg
  1019. ; STATLINE data area:
  1020.  
  1021. sline_locked    db    0        ; semaphore for status line code
  1022. sl_clk_flag    db    0FFh        ; do we show the clock?
  1023. sl_exit_value$    db    0        ; restore semaphore on exit
  1024.  
  1025. sl_attrib$    db    0Fh        ; now used only by external call
  1026. sl_off        dw    0ffffh        ; offset of source
  1027. sl_seg        dw    0        ; segment of source
  1028. sl_get_char    rw    1        ; variable fetch vector
  1029.  
  1030. sl_crt_flag$    rb    1        ; which monitors to show statline
  1031. sl_mono_seg    dw    0B000h        ; monochrome crt base address
  1032. sl_color_seg    dw    0B800h        ; color crt base address
  1033.  
  1034. sl_error_msg    rw    1        ; error message offset
  1035. sl_error_resp    rw    1        ; allowable response table offset
  1036. sl_error_key    rb    1        ; response key
  1037.  
  1038. start_rev    rb    1        ; first column of rev video
  1039. stop_rev    rb    1        ; last column of rev video
  1040. START_STOP    equ    word ptr start_rev
  1041.  
  1042. rev_list    dw    5049h        ; process 1
  1043.         dw    4740h        ; process 2
  1044.         dw    3E37h        ; process 3
  1045.         dw    352Eh        ; process 4
  1046.  
  1047. rev_console    rw    1
  1048.  
  1049. ; Status line message image:
  1050.  
  1051. status_msg        rb    0
  1052. smsg_proc1        rb    8
  1053.             rb    1
  1054. smsg_proc2        rb    8
  1055.             rb    1
  1056. smsg_proc3        rb    8
  1057.             rb    1
  1058. smsg_proc4        rb    8
  1059. smsg_cstr        rb    8
  1060. smsg_cnum        rb    1
  1061.             rb    1
  1062. smsg_NX_country        rb    2
  1063. smsg_NX_bits        rb    1
  1064.             rb    1
  1065. smsg_openvec        rb    2
  1066.             rb    1
  1067. smsg_ctrlS        rw    0
  1068. smsg_ctrlO        rw    1
  1069. smsg_ctrlP        rw    1
  1070. smsg_ctrlP_num        rb    2
  1071.             rb    1
  1072. smsg_window        rb    3
  1073.             rb    1
  1074. smsg_capslock        rb    4
  1075.             rb    1
  1076. smsg_numlock        rb    3
  1077.             rb    1
  1078. smsg_hour        dw    '0 '
  1079. smsg_c1            db    ':'
  1080. smsg_min        dw    '00'
  1081. smsg_c2            db    ':'
  1082. smsg_sec        dw    '00'
  1083.  
  1084. ; To restore "Console=":
  1085.  
  1086. console_msg        db    'Station='
  1087.  
  1088. ; For system or null processes:
  1089.  
  1090. blank_pd        db    '  ____  '
  1091.  
  1092. ; Window, capslock, and numlock indicators:
  1093.  
  1094. winstr            db    'Win'
  1095. capstr            db    'Caps'
  1096. numstr            db    'Num'
  1097.  
  1098. status_copy        rw    80    ; keep a copy of status line
  1099.  
  1100. sl_error_save        rw    80    ; back up for error messages
  1101.  
  1102. if V386
  1103. if SR
  1104. sr_statline_block    rb    NUM_SR_CONS + 1
  1105. else
  1106. sr_statline_block    rb    NUM_AUX_PORTS + 1
  1107. endif
  1108. endif
  1109. end
  1110.  
  1111. ; END OF STATLINE.A86
  1112.