[comp.sys.ibm.pc] SETRAW/SETCOOKD

ralf@b.gp.cs.cmu.edu (Ralf Brown) (03/18/87)

Earlier today I promised to post programs to put the console in raw mode and
back into cooked mode.  Here they are; I think I originally got them from the
INFO-IBMPC lending library.

The following shell archive contains four files:
	source code--SETRAW.ASM
	source code--SETCOOKD.ASM
	uuencoded SETRAW.COM
	uuencoded SETCOOKD.COM

Cut at the line below, run the file through /bin/sh, and then run
the resulting setraw.uu and setcookd.uu through uudecode.

Download the final result of setraw.com and setcookd.com with a binary
file transfer protocol.

Usage:
	setraw
		place CON in raw mode, disabling ^S, ^C, and ^P checks on
		every character
	setcookd
		place CON in cooked mode, enables ^S, ^C, and ^P

---------------CUT---CUT---CUT---CUT---CUT----------------------
#
# type    sh setraw.shar   to unpack this archive.
#
echo extracting setcookd.uu...
cat >setcookd.uu <<'!E!O!F!'
begin 644 setcookd.com
HM##-(3P"<AZ[ 0"P +1$S2%R#_;"@'0*@>+/ + !M$3-(;1,S2'-(.SD
 
end
!E!O!F!
#
# type    sh /usre3/ralf/upload/setraw.shar   to unpack this archive.
#
echo extracting setraw.uu...
cat >setraw.uu <<'!E!O!F!'
begin 644 setraw.com
LM##-(3P"<B*[ 0"P +1$S2%R$_;"@'0.@>+/ ('*( "P ;1$S2&T3,TAS2"T
 
end
!E!O!F!
#
# type    sh /usre3/ralf/upload/setraw.shar   to unpack this archive.
#
echo extracting setcookd.asm...
cat >setcookd.asm <<'!E!O!F!'
;----- dos ----------------------
; Call DOS function # n.
dos     macro   fn
        mov     ah, fn
        int     21h
        endm

code    segment para public 'CODE'
        assume  cs:code

        org     100h

;----- Setraw -------------------------------------------
; Sets Cooked state of stdout if it is a device.
; Returns errorcode in AX if DOS error.
setcookd  proc    near
        DOS     30h
        cmp     al,2
        jb      dos1_exit
        mov     bx,1
        mov     al, 0
        DOS     44h
        jc      sc_exit
        test    dl, 80h         ; It it a device?
        jz      sc_exit         ; nope- do nothing.
        ; Current mode in DX
        and     dx, 00cfh       ; clear old raw bit and hi byte,
        mov     al, 1
        DOS     44h
sc_exit:
        DOS     4Ch
dos1_exit:
        int     20h
setcookd  endp

code    ends
        end     setcookd
!E!O!F!
#
# type    sh /usre3/ralf/upload/setraw.shar   to unpack this archive.
#
echo extracting setraw.asm...
cat >setraw.asm <<'!E!O!F!'
;----- dos ----------------------
; Call DOS function # n.
dos     macro   fn
        mov     ah, fn
        int     21h
        endm

code    segment para public 'CODE'
        assume  cs:code

        org     100h

;----- Setraw -------------------------------------------
; Sets Raw state of stdout if it is a device.
; Returns errorcode in AX if DOS error.
setraw  proc    near
        DOS     30h
        cmp     al,2
        jb      dos1_exit
        mov     bx,1
        mov     al, 0
        DOS     44h
        jc      sr_exit
        test    dl, 80h         ; It it a device?
        jz      sr_exit         ; nope- do nothing.
        ; Current mode in DX
        and     dx, 00cfh       ; clear old raw bit and hi byte,
        or      dx, 20h         ; set RAW bit
        mov     al, 1
        DOS     44h
sr_exit:
        DOS     4Ch
dos1_exit:
        int     20h
setraw  endp

code    ends
        end     setraw
!E!O!F!
-- 
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
| ARPA:  RALF@B.GP.CS.CMU.EDU            "Teaching COBOL ought to be          |
| AT&T:  (412) 268-3053 (school)          regarded as a criminal act"         |
| Snail: Ralf Brown                           --- Edsger Dijkstra             |
|        Computer Science Department                                          |
|        Carnegie-Mellon University      DISCLAIMER?  Who ever said I claimed |
|        Pittsburgh, PA 15213            anything?                            |
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+