                            
project mac-single channel sequence break routines

/insert just before section 4


zz=.

3/

	jmp 93d

zz/

93d,	cks
	ril 1s	/reader
	spi i
	jmp .+3
	szs 50 i	/reader on zero sense switch 5
	jmp 90r
	ril 3s	/punch
	spi
	jmp 90p
999p,	rir 1s	/typein on sense switch 5
	spi>>05<<szs 50
	jmp 90type

90d,	lio 2
	lac
	jmp i 1
          
                                                                  
/bbn extend midas sequence break routines

90r,	rrb		/reader
	law i 7777
	dac 90t
	lac 96r
	sad (jmp 90rbl+1
	jmp 90rbb
	szs 50
	jmp 90rr
91r,	xx		/iot 1, dio ., or last char
	swap
	sza i
	jmp 90rr		/flush blank tape
	add (rar		/begin parity check
	dac 9rar
	rcr 7s
	spi
	jmp 90rr		/flush code delete
	ril 1s		/char in left io
	law 2525
9rar,	xx
	sma
	stf 4		/illegal parity
          
                                                                  90rt,	lac 92r
	spa
	jmp 92n
	ral 1s
	spa
	jmp 92nn
	swap
	dip i 92r
93n,	lac 92r
	spa
	add (200000
	add (200000	/step input counter
	sad (92d+9lr	/end of buffer
	lac (92d		/beginning of buffer
	dac 92r
	add (600000
	spa
	sub (200000
	sub 93r
	sza		/next to last char?
	sub (9lr
	lio 90rr-1
	szf i 4
	sza i
	dio 91r		/yes, clob read instruc
90rr,	rdrchn

92nn,	lac i 92r	/insert 2nd char in word
	ral 6s
	rcl 6s
	ral 6s
	jmp 92n+3

92n,	lac i 92r	/insert 3rd char in word
	rar 6s
	rcl 6s
	dac i 92r
	jmp 93n
          
                                                                 
/read alpha requests from program

95r,	0
	dap 96r
	szs 50
	jmp .-1
	lac 91r
	sad 94n		/reading?
	jmp 99r		/yes
	lac 92r		/no, how many characters in buffer?
	sub 93r
	ral 2s
	spa
	add (4x9lr
	sub (30		/begin reading ~20 characters early
	spa		/i.e. before the buffer is empty
	jmp 91n
99r,	law i 7777	/initialize counter
	dac 90t
	lac 93r		/output pointer
	sad 92r		/buffer empty?
	jmp 90n		/yes, step counter
	lio i 93r	/no, get character
	spa
	add (200000
	add (200000	/step output pointer
	sad (92d+9lr
	lac (92d
	dac 93r
	spa
	rir 6s
	ral 1s
	spa
	ril 6s
	rcr 6s
	cli
	rcl 6s
	lac 95r
96r,	jmp .

90n,	szf 4
	jmp ilp
	isp 90t		/no character for too long?
	jmp 99r+2
91n,	lac 94n		/yes, start reader
	dac 91r
	szf i 4
94n,	iot 1
	jmp 99r

90t,	0
92r,	92d
93r,	92d

	rpa=jda 95r
          
                                                                 
/punch

90p,	lac 91p
	sza		/punching?
	jmp 999p		/no
	eem
	lac 93p
	add (400000	/step output pointer
	sad (92pb+9lp
	lac (92pb
	dac 93p
	lio i 93p
	sma		/which half word?
	ril 9s
	sas 92p		/buffer empty?
	iot 5		/no, punch
	sad 92p
	idx 91p		/yes, set indicator
9dp,	pchchn

/punch alpha. request from program

95p,	0
	dap 96p
	dio 91q
	lac 92p		/input pointer
	spa
	jmp 90q
92q,	ril 9s
	dio i 92p
	add (400000	/step input pointer
	sad (92pb+9lp
	lac (92pb
	sad 93p		/full?
	jmp .-1		/yes, wait for completion
	dac 92p
	lio 91q
	lac 91p
	sza i		/punching?
	jmp 96p-1
	iot 5		/no, start punch
	dzm 91p
	lac 95p
96p,	jmp .

90q,	lac i 92p
	rcl 9s
	lac 92p
	jmp 92q

91q,	0
91p,	-0
92p,	92pb
93p,	92pb

	ppa=jda 95p
          
                                                                  
/punch binary request from program

94p,	0		/simulate ppb w/ ppa
	dap 97p
	law 2
	rcr 6s
	rcr 6s
	ppa
	rcl 6s
	rcl 6s
	lac 94p
97p,	jmp .

	ppb=jda 94p

/typewriter

90type,	tyi
	rir 6s
	jmp 90rt

/read binary request from program

90rb,	0
	dap 90rbx
	setup 94p, 3

90rbl,	rpa
	rcr 6s
	lio 95p
	rcl 6s
	dio 95p
	count 94p, 90rbl
	lac 90rb
90rbx,	jmp .

rpb=jda 90rb

/part of rpa to handle rpb

90rbb,	xct 91r
	rir 8s
	spi i
	jmp 90rr
	ril 2s
	jmp 90rt
          
                                                                  
start
          
                                                                                                                       
