; GSET.ASM 1.0 - 7/26/85 - Modified PSET.ASM for Gemini-10X and ; other Star Micronics printers. Added BEGIN and DONE to exit ; directly to CP/M instead of warm boot (CP/M 2.2 or lower only). ; Changed pitch settings to direct call by pitch number. Added ; messages to echo printer selections. Added option Y to set 8th ; bit low. Allows printing of WordStar files. Added optional ; command mode to bypass the menu, and other minor changes. ; - Merlin R. Null ; ; PSET VERSION 1.2 - 6 Jan 85 - I have added the superscript and ; subscript modes, as they can create some very fine printing ; when permanently set, if somewhat slow. - Barron McIntire ; ; PSET VERSION 1.1 - 12/9/84 - This is one of the nicest and most ; generic Epson menus. My only contribution was to add the ; appropriate mask byte wherever required to allow selection via ; lower case as well upper case letters. It seems to run fine on ; a Kaypro 4-84 under ZCPR3 with a Mannesmann-Talley Spirit 80 ; printer. - Bruce Morgen ; ; PSET.ASM - 5 November 1983 ; ; Presets certain printer states. These remain in effect until ; printer power is recycled, or directed into another state by ; program control. ; ; Originally written in MBASIC, and translated into ASM code for ; speed and ease of use. ; ; Written by: Barron F. McIntire III ; 3400 S. Greeley Hwy #8 ; Cheyenne, Wyoming 82007 ; RCP/M phone 307-635-8366, 300/1200 baud, 24 hours ;---------------------------------------------------------------------- ; ; Define CP/M Routines ; RCONF EQU 1 ; read CON: into (A) WCONF EQU 2 ; write (A) to CON: DRIVE EQU 4 ; check current drive number BDOS EQU 5 ; system call entry WLSTF EQU 5 ; write (E) to LST: WSTRF EQU 9 ; write string to CON: CSTAF EQU 11 ; check CON: status TBUFF EQU 80H ; transient default buffer ; ; Misc. Equates ; BEL EQU 7 ; bell LF EQU 10 ; line feed CR EQU 13 ; carriage return ESC EQU 27 ; escape ; ORG 0100H ; load at start of TPA ; ; Set Up Stack ; BEGIN: LXI H,0 ; save CP/M stack DAD SP SHLD CPMSP LXI SP,STAK ; set up local stack LDA DRIVE ; save current disk STA DRSAV MVI C,CSTAF ; check console status CALL BDOS ; for any input ORA A ; if none, set zero flag JZ START ; if zero, run the program MVI C,RCONF ; read and ignore CON: CALL BDOS ; (debounce keys) JMP START ; run the program ; ; COMMON SUBROUTINES ; ; Message Pointed to by Stack out to Console ; SPMSG: XTHL ; get "return address" to HL PUSH B ; save registers outside of PUSH D ; the main print loop for speed ; SPMSG1: MOV A,M ; get one message character ORA A ; check for zero INX H ; point to next JZ SPMSG2 ; exit if done MVI C,WCONF ; select write to CON: MOV E,A ; character to E PUSH H ; save next char address CALL BDOS ; output to CP/M POP H ; restore next char address JMP SPMSG1 ; get another ; SPMSG2: POP D ; restore registers POP B ; and stack for XTHL ; "return" when done RET ; ; Send Message to LST: ; LSTMSG: MOV A,M ; get a LST: message character CPI 0FFh ; is it a terminator? RZ ; if so, return CALL LSTOUT ; otherwise send it INX H ; point to next JMP LSTMSG ; and do another ; ; Send Contents of A to CP/M LST: Device ; LSTOUT: PUSH B ; save all registers PUSH D PUSH H MOV E,A ; character to E MVI C,WLSTF ; write to LST: function CALL BDOS ; let CP/M do it POP H ; restore registers POP D POP B RET ; ; End of Program Execution ; DONE: LDA DRSAV ; restore "current" disk STA DRIVE LHLD CPMSP ; restore CP/M stack SPHL RET ; return to CP/M ; ; Clear Screen ====> SET FOR YOUR TERMINAL <==== ; Terminate the bytes with a 0 ; CLSCR: CALL SPMSG ; message to console DB 7EH,1CH,1AH,0 ; Hazeltine 1500 + ADM-3A RET ; for STM Pied Piper ; ; Display Opening Message ; START: CALL CLSCR ; clear the screen CALL SPMSG ; message to console DB '**** PRE-SET for Star Micronics Printers - ' DB 'version 1.0 ****',CR,LF DB '--------------------------------------------' DB '-----------------',CR,LF,0 ; ; Command Line Input ; LXI H,TBUFF ; set command line buffer pointer MOV B,M ; get length of command line buffer INX H DCR B JM MENU ; use menu if command line buffer empty ; ; Scan the rest of the buffer for options. ; XCHG ; Get option field pointer to de ; SCNOPT: INX D ; Bump to next option field character DCR B ; Dock characters left in option field JM DONE ; If option field exhausted, exit LDAX D ; Get the next option character CPI 'A' ; option less than A? JC SCNOPT ; if so, ignore it CPI 'Z' ; option greater than Y? JNC SCNOPT ; if so, ignore it ; PUSH B PUSH D PUSH H CALL CMPOPT ; compare option POP H POP D POP B JMP SCNOPT ; more options? ; ; Display Options ; MENU: CALL SPMSG DB 'Presets certain printer states. These remain in' DB ' effect until',CR,LF DB 'printer power is recycled, or redirected by program ' DB 'control.',CR,LF,LF,0 MORE: MVI C,WSTRF ; string to console LXI D,MENUM ; print the menu PUSH H CALL BDOS POP H MVI C,RCONF ; get RCONF function CALL BDOS ; get the option char PUSH PSW CALL CLSCR ; clear screen POP PSW CALL CMPOPT ; compare option CALL SPMSG DB CR,LF,LF,LF,0 JMP MORE ; another option? ; MENUM: DB 'The following options are available:',CR,LF,LF DB 'A. Printer initialization ' DB 'N. 1/6 (0.167) inch line spacing',CR,LF DB 'B. 10 Pitch (Pica) ' DB 'O. 1/8 (0.125) inch line spacing',CR,LF DB 'C. 12 Pitch (Elite) ' DB 'P. 7/72 (0.097) inch line spacing',CR,LF DB 'D. 17 Pitch (Condensed) ' DB 'Q. n/72 inch line spacing',CR,LF DB 'E. 5 Pitch (Enlarged) ' DB 'R. n/144 inch line spacing',CR,LF DB 'F. 6 Pitch (Enlarged) ' DB 'S. Form length setting',CR,LF DB 'G. 8.5 Pitch (Enlarged) ' DB 'T. Skip over perforation',CR,LF DB 'H. Emphasized mode ' DB 'U. Right margin setting',CR,LF DB 'I. Double Strike mode ' DB 'V. Left margin setting',CR,LF DB 'J. Italic character set ' DB 'W. Superscript mode',CR,LF DB 'K. Underline mode ' DB 'X. Subscript mode',CR,LF DB 'L. Ignore paper end detector ' DB 'Y. Set 8th bit low',CR,LF DB 'M. Unidirectional printing',CR,LF,LF DB 'Option or to exit? $' ; ; Compare Option ; CMPOPT: CPI CR ; bare return? JZ DONE ; if so then exit ANI 5FH ; mask to upper case (B.M. - 12/84) CPI 'Z' ; option greater than Y? JNC OPTERR ; if so, do error message SUI 'A' ; convert letter to index JM OPTERR ; do error message if option < A PUSH H ; save HL ADD A ; double index for word length entries LXI H,JTABL ; index into table using 8-bit ADD L ; addition to avoid disturbing MOV L,A ; another register pair MVI A,0 ADC H MOV H,A ; access routine address ; ; obtain routine address from table and tranfer control to it, ; leaving all register pairs unchanged MOV A,M ; move routine address to HL INX H MOV H,M MOV L,A XTHL ; restore old HL, push routine address RET ; jump to option routine ; JTABL: DW OPTA ; address for option A DW OPTB ; address for option B DW OPTC ; address for option C DW OPTD ; address for option D DW OPTE ; address for option E DW OPTF ; address for option F DW OPTG ; address for option G DW OPTH ; address for option H DW OPTI ; address for option I DW OPTJ ; address for option J DW OPTK ; address for option K DW OPTL ; address for option L DW OPTM ; address for option M DW OPTN ; address for option N DW OPTO ; address for option O DW OPTP ; address for option P DW OPTQ ; address for option Q DW OPTR ; address for option R DW OPTS ; address for option S DW OPTT ; address for option T DW OPTU ; address for option U DW OPTV ; address for option V DW OPTW ; address for option W DW OPTX ; address for option X DW OPTY ; address for option Y ; ; Printer Initialization ; OPTA: LXI H,OPTAM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB 'All printer functions reset to defaults',CR,LF,LF,0 RET ; OPTAM: DB ESC,'@',0FFh ; ; 10 Pitch (Pica) Mode ; OPTB: LXI H,OPTBM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB '10 pitch (Pica) set',CR,LF,LF,0 RET ; OPTBM: DB ESC,'B',1,ESC,'W',0,0FFh ; ; 12 Pitch (Elite) Mode ; OPTC: LXI H,OPTCM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB '12 pitch (Elite) set',CR,LF,LF,0 RET ; OPTCM: DB ESC,'B',2,ESC,'W',0,0FFh ; ; 17 Pitch (Condensed) Mode ; OPTD: LXI H,OPTDM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB '17 pitch (Condensed) set',CR,LF,LF,0 RET ; OPTDM: DB 15,ESC,'W',0,0FFh ; ; 5 Pitch (Enlarged) Mode ; OPTE: LXI H,OPTEM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB '5 pitch (Enlarged) set',CR,LF,LF,0 RET ; OPTEM: DB ESC,'W',1,ESC,'B',1,0FFh ; ; 6 Pitch (Enlarged) Mode ; OPTF: LXI H,OPTFM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB '6 pitch (Enlarged) set',CR,LF,LF,0 RET ; OPTFM: DB ESC,'W',1,ESC,'B',2,0FFh ; ; 8.5 Pitch (Enlarged) Mode ; OPTG: LXI H,OPTGM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB '8.5 pitch (Enlarged) set',CR,LF,LF,0 RET ; OPTGM: DB ESC,'W',1,ESC,'B',3,0FFh ; ; Emphasized Mode ; OPTH: LXI H,OPTHM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB 'Emphasized mode set, valid only for ' DB '5 or 10 pitch',CR,LF,LF,0 RET ; OPTHM: DB ESC,'E',0FFh ; ; Double-Strike Mode ; OPTI: LXI H,OPTIM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB 'Double Strike mode set',CR,LF,LF,0 RET ; OPTIM: DB ESC,'G',0FFh ; ; Alternate Character Set (Italics) ; OPTJ: LXI H,OPTJM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB 'Italics font selected',CR,LF,LF,0 RET ; OPTJM: DB ESC,'4',0FFh ; ; Underline Mode ; OPTK: LXI H,OPTKM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB 'Underline mode set',CR,LF,LF,0 RET ; OPTKM: DB ESC,'-',1,0FFh ; ; Ignore Paper End Detector ; OPTL: LXI H,OPTLM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB 'Ignore paper end set',CR,LF,LF,0 RET ; OPTLM: DB ESC,'8',0FFh ; ; Unidirectional Printing ; OPTM: LXI H,OPTMM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB 'Unidirectional printing set',CR,LF,LF,0 RET ; OPTMM: DB ESC,'U',1,0FFh ; ; 1/6 (0.167) Inch Linefeeds ; OPTN: LXI H,OPTNM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB 'Linefeed set to 1/6 inch',CR,LF,LF,0 RET ; OPTNM: DB ESC,'2',0FFh ; ; 1/8 (0.125) Inch Linefeeds ; OPTO: LXI H,OPTOM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB 'Linefeed set to 1/8 inch',CR,LF,LF,0 RET ; OPTOM: DB ESC,'0',0FFh ; ; 7/72 (0.097) Inch Linefeeds ; OPTP: LXI H,OPTPM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB 'Linefeed set to 7/72 inch',CR,LF,LF,0 RET ; OPTPM: DB ESC,'1',0FFh ; ; n/72 Inch Linefeeds ; OPQERR: CALL CLSCR ; on error, clear screen CALL SPMSG ; message to console DB BEL,0 ; and beep the bell OPTQ: CALL LIM127 ; limit of 1-127 message CALL SPMSG ; message to console DB 'Enter n/72 linefeed required: ',0 CALL DECIN ; decimal input routine MOV A,E ; save low byte in accumulator CPI 0 ; check for error JZ OPQERR ; try again if so CPI 127 ; greater than 127? JNC OPQERR ; try again if so PUSH PSW ; save n LXI H,OPTQM ; point to message CALL LSTMSG ; send message to LST: MVI C,WLSTF ; get write to LST: POP PSW ; restore n to A reg MOV E,A ; copy n to E CALL BDOS ; send to printer RET ; OPTQM: DB ESC,'A',0FFh ; ; n/144 Inch Linefeeds ; OPRERR: CALL CLSCR ; on error, clear screen CALL SPMSG ; message to console DB BEL,0 ; and beep the bell OPTR: CALL LIM127 ; limit of 1-127 message CALL SPMSG ; message to console DB 'Enter n/144 line spacing required: ',0 CALL DECIN ; decimal input routine MOV A,E ; save low byte in accumulator CPI 0 ; check for error JZ OPRERR ; try again if so CPI 127 ; greater than 127? JNC OPRERR ; try again if so PUSH PSW ; save A reg LXI H,OPTRM ; point to message CALL LSTMSG ; send message to LST: MVI C,WLSTF ; get write to LST: POP PSW ; restore n to A reg MOV E,A ; copy n to E CALL BDOS ; send to printer RET ; OPTRM: DB ESC,'3',0FFh ; ; Form Length Setting ; OPTS: CALL SPMSG ; message to console DB CR,LF,LF DB 'Form length by lines (L) or inches (I) ? ',0 MVI C,RCONF ; get RCONF function CALL BDOS ; get the option char ANI 5FH ; mask to upper case (B.M. - 12/84) CPI 'I' ; is it inches? JZ INCHS ; go to inches routine CPI 'L' ; is it lines? JZ LINES ; go to lines routine CALL CLSCR ; on error, clear screen CALL SPMSG ; message to console DB BEL,0 ; beep the bell JMP OPTS ; and try again ; INERR: CALL SPMSG ; message to console DB BEL,0 ; on error, beep the bell INCHS: CALL CLSCR ; clear screen CALL SPMSG ; message to console DB 'Value must be between 1 and 32',CR,LF,LF DB 'Number of inches per page? ',0 CALL DECIN ; get number of inches MOV A,E ; save low byte in accumulator CPI 0 ; check for error JZ INERR ; try again if so CPI 32 ; greater than 32? JNC INERR ; try again if so PUSH PSW ; save inches on stack LXI H,OPTSM1 ; point to message CALL LSTMSG ; send message to LST: MVI C,WLSTF ; get write to LST: POP PSW ; restore inches to A reg MOV E,A ; copy inches to E CALL BDOS ; send to printer RET ; OPTSM1: DB ESC,'C',0,0FFh ; LINERR: CALL SPMSG ; message to console DB BEL,0 ; on error, beep the bell LINES: CALL CLSCR ; clear screen CALL LIM127 ; limit of 1-127 message CALL SPMSG ; message to console DB 'Number of lines per page? ',0 CALL DECIN ; get number of lines MOV A,E ; save low byte in accumulator CPI 0 ; check for error JZ LINERR ; try again if so CPI 127 ; greater than 127? JNC LINERR ; try again if so PUSH PSW ; save A reg LXI H,OPTSM2 ; point to message CALL LSTMSG ; send message to LST: MVI C,WLSTF ; get write to LST: POP PSW ; restore line to A MOV E,A ; copy lines to E CALL BDOS ; send to printer RET ; OPTSM2: DB ESC,'C',0FFh ; ; Skip Over Perforation ; OPTTER: CALL CLSCR ; clear screen CALL SPMSG ; message to console DB BEL,0 OPTT: CALL SPMSG ; message to console DB 'Value must be between 1 and 255',CR,LF,LF DB 'Number of lines to skip at perforations? ',0 CALL DECIN ; get number of lines to be skipped MOV A,E ; save low byte in accumulator CPI 0 ; check for error JZ OPTTER ; try again if so PUSH PSW ; save lines on stack LXI H,OPTTM ; point to message CALL LSTMSG ; send message to LST: MVI C,WLSTF ; get write to LST: POP PSW ; restore lines to A MOV E,A ; copy lines to E CALL BDOS ; send to printer RET ; OPTTM: DB ESC,'N',0FFh ; ; Right Margin ; OPUERR: CALL CLSCR ; clear screen CALL SPMSG ; message to console DB BEL,0 OPTU: CALL SPMSG ; message to console DB CR,LF,LF DB ' Maximum Columns Per Row',CR,LF,LF DB ' 10 Inch 15 Inch',CR,LF DB ' Carriage Carriage',CR,LF DB '----------------------------------------',CR,LF DB '10 Pitch 80 136',CR,LF DB '12 Pitch 96 164',CR,LF DB '17 Pitch 136 232',CR,LF DB '5 Pitch 40 68',CR,LF DB '6 Pitch 48 82',CR,LF DB '8.5 Pitch 68 116',CR,LF,LF DB 'Last column to print? ',0 CALL DECIN ; get number of char in line MOV A,E ; save low byte in accumulator CPI 0 ; check for error JZ OPUERR ; try again if so PUSH PSW ; save column number on stack LXI H,OPTUM ; point to message CALL LSTMSG ; send message to LST: MVI C,WLSTF ; get write to LST: POP PSW ; restore column number to A MOV E,A ; copy column number to E CALL BDOS ; send to printer CALL CLSCR ; clear screen CALL SPMSG ; message to console DB CR,LF,'Right margin set',CR,LF,LF,0 RET ; OPTUM: DB ESC,'Q',0FFh ; ; Left Margin Setting ; OPVERR: CALL CLSCR ; clear screen for error CALL SPMSG ; message to console DB BEL,0 OPTV: CALL SPMSG ; message to console DB CR,LF,LF DB 'Column to start printing? ',0 CALL DECIN ; get left margin column number MOV A,E ; save low byte in accumulator CPI 0 ; check for error JZ OPVERR ; try again if so PUSH PSW ; save column # on stack LXI H,OPTVM ; point to message CALL LSTMSG ; send message to LST: MVI C,WLSTF ; get write to LST: POP PSW ; restore column # to A MOV E,A ; copy column number to E CALL BDOS ; send to printer RET ; OPTVM: DB ESC,'M',0FFh ; ; Superscript Mode ; OPTW: LXI H,OPTWM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB 'Superscript mode set',0 CALL PITCHM RET ; OPTWM: DB ESC,'S',0,ESC,'W',0,0FFh ; ; Subscript Mode ; OPTX: LXI H,OPTXM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB 'Subscript mode set',0 CALL PITCHM RET ; OPTXM: DB ESC,'S',1,ESC,'W',0,0FFh ; ; Set 8th Bit Low ; OPTY: LXI H,OPTYM ; point to message CALL LSTMSG ; send message to LST: CALL SPMSG ; message to console DB '8th bit set low',CR,LF,LF,0 RET ; OPTYM: DB ESC,'=',0FFh ; ; Decimal Input Subroutine ; DECIN: LXI D,0000H ; clear D-E reg NEXT: PUSH D ; save D-E reg MVI C,RCONF ; get RCONF function CALL BDOS ; get the character POP D ; get D-E reg CPI CR ; are we done with input? RZ ; return if so SUI 0030H ; convert ASCII to decimal JC ERROR ; no good if carry (less than 0) CPI 000AH ; higher than 9? JNC ERROR ; no good if so LXI H,0000H ; clear H-L reg for multiplication DAD D ; multiply previous data by TEN DAD H DAD H DAD D DAD H MOV E,A ; new entry to E MVI D,00H ; clear D reg DAD D ; add units value to D-E reg XCHG ; new total to D-E reg JMP NEXT ; loop for next char ; ; Limit of 127 message ; LIM127: CALL SPMSG ; message to console DB CR,LF,'Value must be between 1 and 127',CR,LF,LF,0 RET PITCHM: CALL SPMSG ; message to console DB ' Valid only for 10, 12 and 17 pitch',CR,LF,LF,0 RET ; ERROR: CALL SPMSG ; message to console DB CR,LF,'Numbers Only! Try Again',CR,LF,0 LXI D,0000H ; clear D-E reg RET ; ; Bad Option Character ; OPTERR: CALL SPMSG ; message to console DB BEL,'+++ Option Not Implemented +++' DB CR,LF,LF,0 RET ; ; Define Space ; DRSAV: DB 0 ; Current Drive Number CPMSP: DW 0 ; CP/M stack pointer ; ; DS 20H ; reserve stack of 32 bytes STAK: ; END