;program sendout; ; to work around an apparent bug in the t1340 ROM} ; when esc ; 0000 is sent out get garbage sometime. } ; ;var infile : file of byte; ; x,y,z : integer; ; u : string[6]; ; new,old, blue : byte; ; test : string[6]; ; ;begin ; test:= #27+';0000'; ; assign(infile,'junk.bin'); ; reset(infile); ; u:=''; ; repeat ; read(infile,new); ; if new = 27 then begin { if esc, flush and start over } ; if length(u) > 0 then write(lst,u); ; u:=''+#27; ; end { if not escape } ; else ; if length(u) < 6 then u:=u+chr(new); ; if ( (length(u)=6) and (u <> test) ) then begin ; write(lst,u); ; u:=''; { don't print any esc ; 0000 } ; end; ; until eof(infile); ; close(infile); ; write(lst,u); ; end. ; this is a resident printer utility to short circuit the ; problem the Toshiba 1340 has when told to print 0 graphics ; bytes. The newer 1340's seem to dump a piece of some buffer ; as graphics at the beginning of blank lines when told to do this ; These model 1340 have one 23256 ROM firmware. ; This bug has not yet been verified with the old 1340's with extra ; contact switch on RHS for over extension of the carriage ; and with 4 2764 EPROMS firmware. ; 6-12-1986 by Clarence Wilkerson ; ROM BIOS calls prtint equ 17h newprtint equ 88h ; DOS calls TSR equ 27h ; terminate but stay resident by int 27h ; set dx to last address to be saved ; int 21h calls DOS equ 21h prtstrng equ 9h setint equ 25h getint equ 35h ; general equates cr equ 0dh lf equ 0ah ESC equ 27 code segment para assume cs:code, es:code, ds:code, ss:nothing org 100h ; done as a .COM program gothere proc far ; has to start at 100h. jump to disposable routines jmp putinplace gothere endp useold17h proc near ; do I need to restore flags? no ... int newprtint iret useold17h endp newprt proc far ; print char in al to printer dx ; return error codes in ah cmp dx,cs:printer ; is it the right printer? jnz useold17h or ah,ah ; only trap print routine, ah=0 jnz useold17h ; gofurther ; not a trivial case, so ; save all registers except a: assume stack is large enough push bx push cx push ds push dx push es push di push si pushf ; save al, since ax is frequently used mov cs:newchar,al ; know that ah is 0, or wouldn't be here ; get current state, and jump to particular routine mov ax,cs:currentstate mov cx,ax ; for future use cmp ax,6 ; check for out of range jae undefined ; may have offset problem ; skip out from here to test by passing through ; prepare for action mov bx,offset cs:messall ; set string address mov al,cs:newchar ; get back char cmp al,ESC ; esc jz isescape ; if escape, dump buffer, restart state at 1 ; ; special case for last char ; xchg bx,cx cmp al,byte ptr cs:messall[bx] ; on track so far??? xchg bx,cx jnz flush ; did not match, so dump it ; so does match the char needed. bump the state cmp cx,5 ; on the last leg? jz lastbyte ; still matching, but not done, so increment state of machine inc cs:currentstate jmp tidyup lastbyte: ; have match ESC;0000, so don't send it out. mov cs:currentstate,0 ; reset machine state mov ah,01010000B ; in case don't send anything, set the right jmp tidyup ; error return back in ah newprt endp undefined proc near mov cs:currentstate,0 ; reset machine state mov al,cs:newchar ; send out char call printone jmp tidyup undefined endp isescape proc near ; print buffer[0..cx-1] mov cs:currentstate,1 ; escape buffer started ; cx has old state or cl,ch ; if no current buffer, don't try to send it ; if in state 0 then nothing to send out jnz overes mov ah,01010000B ; but do send right flags back jmp tidyup overes:call printstring ; print cx chars from string jmp tidyup ; no newchar, since we know it is ESC isescape endp flush proc near ; have already loaded cx and dx ; will print old [buffer[0..cx-1] + new char mov cs:currentstate,0 or cl,ch ; zero chars case jnz overf ; in case no chars call printstring overf: mov al,cs:newchar ; so flush and print newchar call printone ; will have error code in ah jmp short tidyup flush endp tidyup proc near mov al,cs:newchar ; ah has error return from an popf pop si pop di pop es ; honest int 17h call, or one of the pop dx pop ds ; buffered fake ones above pop cx pop bx iret tidyup endp printone proc near ; send al to lpt1 via new interrupt newprtint push bx push cx mov ah,0 mov dx,cs:printer int newprtint pop cx pop bx ret ; don't save ax, because want error flags in ah printone endp printstring proc near ; print null terminated string pointed to by cs:bx ; up to cx chars long push bx push cx xor bx,bx sloop: or cl,ch jz sfinish mov al,cs:messall[bx] or al,al jz sfinish inc bx dec cx ; call printone jmp sloop sfinish: pop cx pop bx ret printstring endp newchar db 0 printer dw 0 ; possible values 0,1,2 for now currentstate dw 0 ; possible states are 0,1,2,3,4,5 messall db ESC,';0000',0,0,0 old17h dd 0 db 10 dup('END'); thatsall label byte ; throw away the signon message ; and initialization code putinplace proc near ; part executed as DOS program mov ax,cs mov ds,ax ; set segment addresses mov es,ax ; check the command line for any arguments mov al, byte ptr cs:[80h] or al,al jz setzero ; printer 0 xor bx,bx mov bl,al mov al, cs:[bx+128] ; get the last char on line cmp al,'2' jz settwo cmp al,'3' jz setthree setzero: mov cs:printer,0; mov cs:which,31h jmp over settwo: mov cs:printer,1 mov cs:which,32h jmp over setthree: mov cs:printer,2 mov cs:which,33h jmp over over: mov dx, offset greeting mov ah,prtstrng int DOS ; print the string ; get the old 17h interrupt mov al,prtint ; get printer interrupt mov ah,getint int DOS ; set trap for 17h calls mov ax,es mov word ptr old17h[2],ax mov word ptr old17h,bx mov al,prtint push cs pop ds mov dx,offset newprt mov ah, setint int dos ; set up int newprtint as same as 17h was lds dx,dword ptr old17h mov al,newprtint mov ah,setint int DOS ; mov cs:currentstate,0 mov cs:newchar,0 ; mov dx, offset thatsall int TSR ; back to dos, but keep program around putinplace endp greeting db 'Installing T1340 zero graphics trap on INT 17H.' db cr,lf db 'Uses INT 88h also. Affects only LPT' which db '1' db ' output.' db cr,lf,'Usage is ' db cr,lf,' A> FIX1340 X' db cr,lf,'where X is 1,2, or 3 for LPTX trapping.' db cr,lf,'$' code ends end gothere; jmp then to putinplace