; QT-ADM40.Z - QTERM patch for the Coleco ADAM, w/ 40 columns .var no 0 .var yes ! no .var datap 0x44 ; data port (in/out) .var statp 0x45 ; status port (in) .var contlp 0x47 ; control port (out) .var baudrp 0x46 ; baud rate port (out) .var inmsk 2 ; 8251 RxRDY .var outmsk 1 ; 8251 TxRDY .var chipset 0x37 ; 8251 RTS,ER,RxE,DTR,TxEN .var chipoff 0x35 ; 8251 RTS,ER,RxE,TxEN (no dtr) .var break chipset | 8 ; chipset OR send break .var freeze 0x22 .var reset 0x27 ; Misc variables .var scrout 0x0109 ; output char in (QTERM) .var decout 0x010c ; output decimal value in (QTERM) ; Modem input status. 110h-11fh. .org 0x0110 istat: in a,(statp) and inmsk ret ; Read modem character. 120h-12fh. .org 0x0120 idata: in a,(datap) ret ; Modem output status. 130h-13fh. .org 0x0130 ostat: in a,(statp) and outmsk ret ; Write modem character. 140h-14fh. .org 0x0140 odata: out (datap),a ret ; Break. Start break 150h-15fh; end break 160-16fh. .org 0x0150 brkon: ld a,break out (contlp),a ret .org 0x0160 brkoff: ld a,chipset out (contlp),a ret ; Dtr. Drop dtr 170h-17fh; restore dtr 180h-18fh. .org 0x0170 dtroff: ld a,chipoff out (contlp),a ret .org 0x0180 dtron: ld a,chipset out (contlp),a ret ; Baud rate. Routine 190h-19fh; table 1a0h-1afh. .org 0x0190 brset: jp finbd .org 0x01a0 brtbl: b38400: db 0,no ; 38400 b19200: db 0x3f,yes ; 19200 b9600: db 0x3e,yes ; 9600 b4800: db 0x3c,yes ; 4800 b2400: db 0x3a,yes ; 2400 b1200: db 0x37,yes ; 1200 b600: db 0x36,yes ; 600 b300: db 0x35,yes ; 300 ; Mode. Routine 1b0h-1bfh. .org 0x01b0 modset: jp finmod ; Mode. Table 1c0h-1cbh. 8251 mode byte, sets stop bits, parity, .org 0x01c0 modtbl: n71: db 0b01001010 ; 7n1 ; this table must be n81: db 0b01001110 ; 8n1 ; exactly 12 bytes long n72: db 0b11001010 ; 7n2 n82: db 0b11001110 ; 8n2 e71: db 0b01111010 ; 7e1 e81: db 0b01111110 ; 8e1 e72: db 0b11111010 ; 7e2 e82: db 0b11111110 ; 8e2 o71: db 0b01011010 ; 7o1 o81: db 0b01011110 ; 8o1 o72: db 0b11011010 ; 7o2 o82: db 0b11011110 ; 8o2 ; Miscellaneous one byte values. .org 0x01cc db 0 ; reserved for future use .org 0x01cd db 8 ; 1cdh - size of xfer buffer .org 0x01ce db 4 ; 1ceh - cpu clock speed .org 0x01cf db '\e' ; 1cfh - escape character ; Signon message. 1d0h-1efh .org 0x01d0 db '\ex9\nColeco ADAM 40 Col W/-RS232\0' ; Clear screen string .org 0x01f0 db 'z' & 0x1f, 0 ; Moveto - move the cursor .org 0x0200 moveto: push hl ; save row,col ld c,'\e' ; send escape call scrout ld c,'=' ; send = call scrout pop hl ; get row,col ld de,0x2020 ; add offset add hl,de push hl ; and save ld c,h ; send row+offset call scrout pop bc ; get col+offset jp scrout ; send ; tcbits - what terminal capabilities are present .org 0x022f db 0xff .org 0x0230 db '\eq\0' .org 0x0238 db '\ep\0' .org 0x0240 db '\eM\0' .org 0x0248 db '\eL\0' .org 0x0250 db 0x97,0 .org 0x0258 db 0x94,0 .org 0x0260 db '\eK\0' .org 0x0268 db '\eJ\0' .org 0x0270 jp entry .org 0x0273 jp exit .org 0x0276 ret .org 0x0279 ret .org 0x0280 finbd: ld b,a in a,(baudrp) ld c,a in a,(baudrp) ld a,freeze out (contlp),a ld a,c out (baudrp),a ld a,b out (baudrp),a ld a,reset out (contlp),a ret finmod: ld b,a in a,(baudrp) in a,(baudrp) ld c,a ld a,freeze out (contlp),a ld a,b out (baudrp),a ld a,c out (baudrp),a ld a,reset out (contlp),a ret entry: ld e,0x1a ld c,2 call 5 in a,(baudrp) ld b,a in a,(baudrp) ld a,b or a ret nz ld a,0x4e call 0x01b0 ld a,0x37 call 0x0190 ret exit: ld e,0x19 ld c,2 call 5 ld c,9 ld de,exitstr jp 5 exitstr: db 'z' & 0x1f, '\ey9$'