.Title	STT TPARSE - version dependent (v4)
.Library	/SYS$LIBRARY:LIB/

	$SMGDEF

;	Following commands are handled here...
;
;	EXIT
;	SDA
;	SHOW  ...

.Psect	stt$code,rd,page,exe
.Sbttl	+++		EXIT
.Entry	stt$exit,^M<>

	pushal	stt$L_pasteboard_id
	calls	#1,G^smg$erase_pasteboard
	$EXIT_S

.Sbttl	+++		Invoke SDA as subprocess...
.Entry	stt$sda,^M<>

	movl	#23,stt$AL_callparm	;set up to save screen
	movl	#1,stt$AL_callparm+4
	pushal	stt$AL_callparm
	pushal	stt$AL_callparm+4
	pushal	stt$AL_display_ids+stt$K_save_id ;use this as saved ID
	pushal	stt$L_pasteboard_id
	calls	#4,G^smg$save_physical_screen
	movl	#8,stt$AL_callparm	;NOKEYPAD passed
	clrq	stt$AL_callparm+4
	clrq	stt$AL_callparm+12
	clrq	stt$AL_callparm+20
	clrq	stt$AL_callparm+28
	movq	#0,-(sp)		;prompt & cli
	movq	#0,-(sp)		;ASTADR & ASTPRM
	movq	#0,-(sp)		;comp sts & efn
	movq	#0,-(sp)		;proc name & PID
	pushal	stt$AL_callparm		;flags longword
	pushaq	stt$D_output_device
	clrl	-(sp)			;just execute the ANA/SYS command
	pushaq	stt$D_sda_command
	calls	#12,G^lib$spawn
	pushal	stt$AL_display_ids+stt$K_save_id ;set up to restore
	pushal	stt$L_pasteboard_id
	calls	#2,G^smg$restore_physical_screen
	ret


.Sbttl	+++		submit unknpown command to DCL
.Entry	stt$submit_command,^M<>

	ret


.Sbttl	+++		SHOW DRIVER
.Entry	stt$show_driver,^M<r2,r3,r4,r5>

	bsbw	stt$erase_maindisplay
	movl	#16,stt$AL_callparm		;column
	movl	#3,stt$AL_callparm+4		;row
	pushal	stt$AL_callparm
	pushal	stt$AL_callparm+4
	pushal	stt$AL_display_ids+stt$K_maindisplay
	calls	#3,G^smg$set_cursor_abs

	movl	#SMG$C_ASCII,stt$AL_callparm
	clrq	stt$AL_callparm+4		;nowrap,comp
	movl	#SMG$M_REVERSE,stt$AL_callparm+12
	clrl	stt$AL_callparm+16
	pushal	stt$AL_callparm
	pushal	stt$AL_callparm+4
	pushal	stt$AL_callparm+8
	pushal	stt$AL_callparm+12
	pushal	stt$AL_callparm+16
	movzbl	stt$B_driv_len,stt$D_driver	;copy driver name length
	bneq	100$
		pushaq	stt$D_nodrivmsg
		brb	200$
100$:
	pushaq	stt$D_driver
200$:
	pushal	stt$AL_display_ids+stt$K_maindisplay
	calls	#7,G^smg$put_line
	pushal	stt$L_pasteboard_id
	calls	#1,G^smg$flush_buffer
	ret

.Sbttl	+++		SHOW FLAGS
.Entry	stt$show_flags,^M<r2,r3,r4,r5,r6>

	calls	#0,stt$show_driver		;output driver name
	$CMKRNL_S	stt$get_flags
	blbs	r0,100$
		ret
100$:
	clrq	stt$AL_callparm
	movl	#65,stt$AL_callparm+8		;bottom right col
	movl	#9,stt$AL_callparm+12		;row
	movl	#15,stt$AL_callparm+16		;top left col
	movl	#4,stt$AL_callparm+20		;row
	pushal	stt$AL_callparm
	pushal	stt$AL_callparm+4
	pushal	stt$AL_callparm+8
	pushal	stt$AL_callparm+12
	pushal	stt$AL_callparm+16
	pushal	stt$AL_callparm+20
	pushal	stt$AL_display_ids+stt$K_maindisplay
	calls	#7,G^smg$draw_rectangle
	movl	#5,r3				;start at row 5
	movl	#16,r2				;column 16
	clrl	r4				;flag marker
	clrl	stt$AL_callparm+12		;noerase flag
200$:
	bbc	r4,stt$Q_flagmask,300$
		movl	#SMG$M_REVERSE!SMG$M_BOLD,r6
		pushl	r4
		movl	#512,stt$D_fao_outbuf	;reinit descriptor
		pushaq	stt$D_fao_outbuf
		pushaw	stt$D_fao_outbuf
		pushaq	stt$D_cvtflag
		calls	#4,G^lib$sys_fao
		movaq	stt$D_fao_outbuf,r5
		brb	400$
300$:
	clrl	r6				;blanks are NORMAL video
	movaq	stt$D_blankflag,r5
400$:
	bbs	r4,stt$Q_flagmask,430$		;flag set??
		bbs	r4,stt$Q_old_flagmask,440$ ;set before?
			brb	450$		;no change in state
430$:
		bbs	r4,stt$Q_old_flagmask,450$
440$:
			movl	#SMG$M_BOLD!SMG$M_BLINK!SMG$M_REVERSE,r6 ;note it once
450$:
	movl	#SMG$C_ASCII,stt$AL_callparm
	clrq	stt$AL_callparm+4		;leading NORMAL blank
	movq	r2,stt$AL_callparm+16		;column & row
	pushal	stt$AL_callparm
	pushal	stt$AL_callparm+4
	pushal	stt$AL_callparm+8
	pushal	stt$AL_callparm+12
	pushal	stt$AL_callparm+16
	pushal	stt$AL_callparm+20
	pushaq	stt$D_blank
	pushal	stt$AL_display_ids+stt$K_maindisplay
	calls	#8,G^smg$put_chars

	incl	stt$AL_callparm+16		;bump column
	movl	r6,stt$AL_callparm+8		;now out put characters
	pushal	stt$AL_callparm
	pushal	stt$AL_callparm+4
	pushal	stt$AL_callparm+8
	pushal	stt$AL_callparm+12
	pushal	stt$AL_callparm+16
	pushal	stt$AL_callparm+20
	pushl	r5
	pushal	stt$AL_display_ids+stt$K_maindisplay
	calls	#8,G^smg$put_chars
	addl	#3,r2
	cmpl	r2,#61				;time for next line?
	bleq	1000$				;LEQ ==> not yet
		movl	#16,r2			;reset column
		incl	r3			;bump row
1000$:
	aobleq	#63,r4,1100$
		bbs	#stt$V_showspec,stt$L_control,1200$ ;show specific flags?
			brw	3000$		;if not, get on out
1100$:
	brw	200$				;looperdooper
1200$:
		movl	#11,stt$AL_callparm+4	;row 
		movl	#1,stt$AL_callparm	;column
1250$:
;		Erase last possible flag states...

		pushal	stt$AL_callparm
		pushal	stt$AL_callparm+4
		pushal	stt$AL_display_ids+stt$K_maindisplay
		calls	#3,G^smg$erase_line
		aobleq	#18,stt$AL_callparm+4,1250$
		clrl	r4
		movl	#SMG$C_ASCII,stt$AL_callparm
		clrl	stt$AL_callparm+4
		movl	#10,stt$AL_callparm+16	;column 1
		movl	#11,stt$AL_callparm+20	;start at row 11
		clrl	stt$AL_callparm+12	;clear ERASE LINE flag 
1300$:
		bbc	r4,stt$Q_setclear_mask,2000$
			movl	#SMG$M_UNDERLINE,stt$AL_callparm+8 ;reset rendition
			movaq	stt$D_flag_off,r3 ;assume flag off
			bbc	r4,stt$Q_flagmask,1400$ ;is it?
				movaq	stt$D_flag_on,r3 ;then report ON
				bisl	#SMG$M_REVERSE,stt$AL_callparm+8
1400$:
			bsbw	stt$show_flag_on_off
2000$:
		aobleq	#63,r4,1300$
3000$:
		pushal	stt$L_pasteboard_id
		calls	#1,G^smg$flush_buffer
		ret

.Sbttl	+++		SHOW TRACE
.Entry	stt$show_trace,^M<r2,r3,r4,r5,r6,r8,r9>

	$CMKRNL_S	stt$copy_trace		;copy the trace table
	blbs	r0,100$
		cmpl	#ss$_ivaddr,r0		;just some consistency failure?
		beql	50$
			ret			;if not, all done
50$:
		bsbw	stt$check_continue_trace
100$:

	movl	#stt$K_main_width,stt$AL_callparm ;last column
	movl	#stt$K_main_length,stt$AL_callparm+4 ;last row 
	movl	#1,stt$AL_callparm+8		;first column
	movl	#1,stt$AL_callparm+12		;first row
	pushal	stt$AL_callparm
	pushal	stt$AL_callparm+4
	pushal	stt$AL_callparm+8
	pushal	stt$AL_callparm+12
	pushal	stt$AL_display_ids+stt$K_tracedisplay
	calls	#5,G^smg$erase_display
	movl	#1,stt$AL_callparm		;paste trace table
	movl	#6,stt$AL_callparm+4
	pushal	stt$AL_callparm
	pushal	stt$AL_callparm+4
	pushal	stt$L_pasteboard_id
	pushal	stt$AL_display_ids+stt$K_tracedisplay
	calls	#4,G^smg$paste_virtual_display
	clrl	r8				;assume start at beginning
	bbcc	#stt$V_tracelimits,stt$L_control,200$ ;user define limits?
		movl	stt$L_trace_start,r8	;use his start
200$:
	ashl	#-2,stt$L_table_length,r9	;assume go to end
	bbcc	#stt$V_dotoend,stt$L_control,300$
		movl	stt$L_trace_end,r9
300$:
	cmpl	r9,r8
	bgeq	400$
350$:
		movzwl	#ss$_badparam,r0
		bsbw	stt$error_message
		brb	1000$
400$:
	cmpl	r9,#<stt$K_maxtrace-1>*4	;too big?
	bgtr	350$
500$:
	bsbw	stt$show_trace_table
1000$:
	movl	#512,stt$D_input_buf		;maximum input length
	pushal	stt$AL_display_ids+stt$K_tracedisplay
	pushaq	stt$D_input_buf
	pushaq	stt$D_thru_w_trace
	pushaw	stt$D_input_buf			;input length (result)
	pushal	stt$L_keytable_id
	pushal	stt$L_keyboard_id
	calls	#6,G^smg$read_composed_line	;any input will do
	
	pushal	stt$L_pasteboard_id
	pushal	stt$AL_display_ids+stt$K_tracedisplay
	calls	#2,G^smg$unpaste_virtual_display
	ret

.End
