home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG115.ARC
/
MXSET23.MAC
< prev
next >
Wrap
Text File
|
1979-12-31
|
27KB
|
1,307 lines
;MXSET Ver 2.3 19 May 84
;**********************************************************
;
;This program will set/reset all of the major functions of the
;Epson MX80 or MX-100 printer with or without Graftrax
;The program uses Z80 Zilog mnemonics and calls are made to
;Richard Conn's excellent SYSLIB.REL file.
;Microsoft's M80 macro assembler is needed
;
;***********************************************************
;
;Note - sub menu A, 0/1 options correct?
; grafics
;Rev 2.3 19 May 84 Frans Van Duinen
; modified for 8080 compatibility
; added hex keypad to printer function
; in typewriter & keypad functions maintain condensed
; mode across CR/LF
;
;Rev 2.2 21 April 84 Frans Van Duinen
; and some more bugs
;
;Rev 2.2 21 April 84 Frans Van Duinen
; fixed some bugs introduced with ver 2.1
; capability to run under WS
;
;Rev 2.1 20 April 84 Frans Van Duinen, Toronto
; set up for MX80 or 100 with or without Graftrax,
; cleaned up coding
;
;Rev 2.0 16 April 84 David C. Naylor, Halton Hills
; set up for MX100 without graftrax
;
;Rev. 1.2 by Simon J. Ewins, Toronto, Ontario, Canada.
; June 28, 1983. Toronto, Ontario.
;
;
; Legend:
;
; <DE> - refers to content of registers, e.g. <A>
; DE> - refers to memory location pointed to be register pair
; <> - not equal
;
; SYSLIB functions used
EXTRN BBLINE ;Get input line, returns HL>line
; <A> count; on input <A><>0 - capitalize
EXTRN EVAL10 ;Convert decimal number at HL> to binary
; returns <DE> number, HL> next char
; handling of nos>65535 unknown
; returns zero if no valid digits
;
;Note that CIN, COUT PRINT CCOUT are not compatible with WS
;
;Conditional assembly
;
FALSE EQU 0
TRUE EQU NOT FALSE
;
MX100 EQU TRUE ;Set true if using wider printer
GTRAX EQU FALSE ;Set true if printer graftrax equiped
;
;
; Equated symbols
BELL EQU 07 ;Bell
BS EQU 08 ;Backspace
LF EQU 0AH ;Linefeed
FF EQU 0CH ;Formfeed
CR EQU 0DH ;Carriage return
SO EQU 0EH ;Turn on double width
SI EQU 0FH ;Shift in (activates compressed)
DC2 EQU 12H ;Turn off compressed
DC4 EQU 14H ;Turn off double width
EOF EQU 1AH ;End of file (^Z)
ESC EQU 1BH ;Escape char
;
OFF EQU 0 ;Off flag
ON EQU 1 ;On flag for printer
;
;
BDOS EQU 5 ;Entry for BDOS
;
IF MX100
;
; MX100 related values
;
MAXWDTH EQU 233 ;Max page width
MAXGMED EQU 816 ;Max no of dots - med graphics
MAXGHI EQU 1632 ;Max no of dots - hi graphics
;
ELSE
;
; MX80 related values
;
MAXWDTH EQU 132 ;Max page width
MAXGMED EQU 480 ;Max no of dots - med graphics
MAXGHI EQU 960 ;Max no of dots - hi graphics
;
ENDIF
;
;Techniques:
;
;Note the sequence
; CALL LPRINT
; DB ESC,...,0
;
; The routine LPRINT never returns control.
; instead it exits to label START, a call is used
; to pass the return address as the addr of the string
; to print. String must terminate on 00H
;
;
;Note that the sequence
; CALL RPRINT
; DB ESC,...,0
;
; does return control
;
;
.Z80
CSEG
;
JP START ;Skip subrtn
CLR:
DB FF,0,0,0,0,0,0 ;Clear screen & home cursor
; Set to sequence for your computer:
; Osborne - 1AH,0
; Televideo - 1AH,0
; Superbrain - FF,0
; Heath - ESC,'E',0
; If not wanted set to CR,LF,LF,LF...
;
; Constants & Workfields
;
;
OPTIONS: DB 0 ;Printer options activated in this session
; ; 0 - Condensed
; ; is used for typewriter function
; ; set/reset by condensed on/off & reset
;
START:
CALL CPRINT ;Cls & display
DB 'EPSON SET-UP ver 2.2',CR,LF
;
IF MX100
;
DB 'For MX100 '
;
ELSE
;
DB 'For MX80 '
;
ENDIF
;
IF GTRAX
;
DB 'with Graftrax '
;
ELSE
;
DB 'without Graftrax '
;
ENDIF
;
DB CR,LF
DB 'OPTIONS:',CR,LF
DB 'A: Select character font',CR,LF
;
IF GTRAX
;
DB 'B: Reset printer to defaults',CR,LF
;
ELSE
;
DB 'B: Select character set',CR,LF
;
ENDIF
;
DB 'C: Set line spacing',CR,LF
DB 'D: Set page size',CR,LF
;
IF GTRAX
;
DB 'E: Set uni-directional print ON/OFF',CR,LF
;
ELSE
;
DB 'E: Set vertical tabs',CR,LF
;
ENDIF
;
DB 'F: Set horizontal tabs',CR,LF
DB 'G: Set to top of form (FF)',CR,LF
DB 'H: Turn ON perforation skip',CR,LF
DB 'I: Turn OFF perforation skip',CR,LF
DB 'J: Enable out of paper signal',CR,LF
DB 'K: Disable out of paper signal',CR,LF
DB 'L: Set graphics mode',CR,LF
DB 'M: Print test',CR,LF
;
IF GTRAX
;
DB 'N: Set bit 8 handling',CR,LF
DB 'O: Home printhead',CR,LF
;
ENDIF
;
DB 'X: Hex keypad to printer',CR,LF
DB 'Z: Keyboard to printer',CR,LF
DB '^C: Quit to CP/M',CR,LF,LF,0
CALL CHOICE ;Complete menu, get input
;
CP 'A'
JP Z,LA ;Select type font
CP 'B'
JP Z,LB ;Select character set/reset printer
CP 'C'
JP Z,LC ;Set line spacing
CP 'D'
JP Z,LD ;Set page size
CP 'E'
JP Z,LE ;Set vertical tabs/reset
CP 'F'
JP Z,LBLF ;Set horizontal tabs
CP 'G'
JP Z,LG ;Force formfeed
CP 'H'
JP Z,LH ;Set perf skip on
CP 'I'
JP Z,LI ;Set perf skip off
CP 'J'
JP Z,LJ ;Enable paper-out detector (signal only)
CP 'K'
JP Z,LK ;Disable paper-out detector
CP 'L'
JP Z,LL ;Set graphics
CP 'M'
JP Z,LM ;Print test
;
IF GTRAX
;
CP 'N'
JP Z,LN ;Handling of h/o bit
CP 'O'
JP Z,LO ;Home print head
;
ENDIF
;
CP 'X'
JP Z,LX ;Hex keypad to printer
CP 'Z'
JP Z,LZ ;Keyboard to printer
;
; Invalid response
ERROR:
CALL PRINT
DB BELL,0
JP START
;
;
;
; Select font
LA:
CALL CPRINT ;Cls & display
DB CR,LF,LF
DB '1: Set condensed ON',CR,LF
DB '2: Set condensed OFF',CR,LF
DB '3: Set enlarged ON',CR,LF
DB '4: Set enlarged OFF',CR,LF
DB '5: Set emphasized ON',CR,LF
DB '6: Set emphasized OFF',CR,LF
;
IF GTRAX
;
DB '7: Set Italics ON',CR,LF
DB '8: Set Italics OFF',CR,LF
DB '9: Set double strike ON',CR,LF
DB '10: Set double strike OFF',CR,LF
DB '11: Set to subscript',CR,LF
DB '12: Set to superscript',CR,LF
DB '13: Set super/subscript OFF',CR,LF
DB '14: Set permanent enlarged ON',CR,LF
DB '15: Set permanent enlarged OFF',CR,LF
;
ENDIF
;
DB LF,0 ;Extra LF & terminating null
;
CALL CHOICE ;Get response
LD B,1 ;Set minimum
;
IF GTRAX
;
LD C,16 ;Get max+1
;
ELSE
;
LD C,7 ;Get max+1
;
ENDIF
;
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LA ;Out of range
; CP 2 ;Condensed on/off?
JP Z,CONDOFF ;Yes -
JP NC,NOCOND ;No -
LD C,80H ;Yes - set flag
CALL SETOPT
JP NOCOND
CONDOFF:
LD C,7FH ;Set flag off
CALL RESOPT ;Reset option flag
NOCOND:
;
; Note that different selections
; have differing formats:
; 1 - SI - no ESC
; 2 - DC2 - no ESC
; 3 - SO - no ESC
; 4 - DC4 - no ESC
; 5 - ESC,'E'
; 6 - ESC,'F'
; 7 - ESC,'4'
; 8 - ESC,'5'
; 9 - ESC,'G'
; 10 - ESC,'H'
; 11 - ESC,'S',OFF
; 12 - ESC,'S',ON
; 13 - ESC,'T'
; 14 - ESC,'W',ON
; 15 - ESC,'W',OFF
;
LD A,E ;Get index
LD HL,ATABL-1 ;Index table (offset for ascii char index)
ADD A,L ;Combine with index char
JP NC,LA1 ;No carry to high byte
INC H
LA1:
LD L,A ;Complete index
;
LD A,(HL) ;Get byte at HL>
PUSH AF ; & save
LD A,E ;Get selection back
CP 5
JP C,LA2 ; 1-4 no ESC
LD A,ESC
CALL LOUT
LA2:
POP AF
CALL LOUT ;Byte from table
;
;
IF GTRAX
;
LD A,11
SUB E ;Normalize '11' & '12' to 0 & 1
CP 2 ;Is this option 11 or 12?
JP C,LA3 ;Yes - put normalized
OR A ;Was this #1 - #10 (positive now)
JP P,START ;Yes - get out
CP 255 ;No - was it #13
JP Z,START ;Yes - is complete
ADD A,4 ;No - adjust 14 - 15 to 1 - 0
LA3:
CALL LOUT ;Output 0 (option 11/14) or 1 (12/15)
;
ENDIF
;
JP START
;
;
ATABL: DB SI,DC2 ;Condensed on/off - no ESC
DB SO,DC4 ;Enlarged (double width) on/off - no ESC
DB 'E','F' ;Emphasized on/off
;
IF GTRAX
;
DB '4','5' ;Italics on/off
DB 'G','H' ;Double strike on/off
DB 'S','S' ;Super/subscr - with ESC & 1,0
DB 'T' ;Super/sub off - with Esc
DB 'W','W' ;Double width on/off - With ESC & 1,0
;
ENDIF
;
;
;
LB:
;
IF GTRAX
; Reset printer to default
LD C,0 ;Reset options
CALL RESOPT
;
CALL LPRINT ;Print & exit
DB ESC,'@',0
;
;
ELSE
;
;Select character set
CALL CPRINT ;Cls & display
DB CR,LF,LF
DB '1: North American',CR,LF
DB '2: British',CR,LF
DB '3: French',CR,LF
DB '4: German',CR,LF
DB '5: Spanish',CR,LF
DB '6: Italian',CR,LF
DB '7: Danish',CR,LF
DB '8: Swedish',CR,LF,LF,0
;
CALL CHOICE ;Get response
LD B,1 ;Set minimum
LD C,9 ; & max+1
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LB ;Out of range
LD A,E ;Get index
LD HL,BTABL-1 ;Index table (offset for ascii char index)
ADD A,L ;Combine with index char
JP NC,LB1 ;No carry to high byte
INC H
LB1:
LD L,A ;Complete index
;
CALL RPRINT
DB ESC,'R',0 ;Put out 1st part
LD A,(HL) ;Get language/ char set code
CALL LOUT ;May be zero
JP START
;
;
;
BTABL: DB 0 ;North American
DB 3 ;British
DB 1 ;French
DB 2 ;German
DB 7 ;Spanish
DB 6 ;Italian
DB 4 ;Danish
DB 5 ;Swedish
;
;
ENDIF
;
;
;
LC: ;Set line spacing
CALL CPRINT ;Cls & display
DB '1: Select 6 lines per inch',CR,LF
DB '2: Select 8 lines per inch',CR,LF
DB '3: Set line spacing in 1/72" increments',CR,LF
;
IF GTRAX
;
DB '4: Set line spacing in 1/216" increments',CR,LF
;
ENDIF
;
DB LF,0 ;Mark end of string
;
CALL CHOICE ;Get input
LD B,1 ;Set minimum
;
IF GTRAX
;
LD C,5 ; & max+1
;
ELSE
;
LD C,4 ; & max+1
;
ENDIF
;
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LC ;Out of range
LD A,E ;Get index
CP 2 ;Which one?
JP Z,LC2 ;#2
JP NC,LC3 ;#3 (or 4 if GTRAX)
;
;Select 6 lines per inch
CALL LPRINT ;Print & exit
DB ESC,'2',0 ;Set 6 lines/inch
;
;
LC2: ;Select 8 lines per inch
CALL LPRINT ;Print & exit
DB ESC,'0',0 ;Set 8 lines/inch
;
;
LC3: ;Set variable line spacing
;
IF GTRAX
;
CP 4 ;Item 4 (1/216)
JP NZ,LC5 ;No -
;
LC4:
CALL PRINT
DB CR,LF,LF,'Enter quantity of 1/216 inches (max 85): ',CR,LF
DB '---> ? ',0
;
LD A,0 ;No capitals reqd
CALL BBLINE ;Get input line
LD B,1 ;Set minimum
LD C,0 ; & max+1 (256)
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LC4 ;Out of range
LD A,E ;Get index
LD (LC42),A
CALL LPRINT ;Print & exit
DB ESC,'3' ;Set spacing in 1/216" increments
LC42: DB 1,0
;
;
;
ENDIF
;
LC5:
CALL PRINT
DB CR,LF,LF,'Enter quantity of 1/72 inches (max 85): ',CR,LF
DB '---> ? ',0
;
LD A,0 ;No capitals reqd
CALL BBLINE ;Get input line
LD B,1 ;Set minimum
LD C,86 ; & max+1
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LC5 ;Out of range
LD A,E ;Get index
LD (LC52),A
CALL LPRINT ;Print & exit
DB ESC,'A' ;Set LF spacing in 1/72" increments
LC52: DB 1,0
;
;
LD: ;Set page dimensions
CALL CPRINT ;Cls & display
DB '1: Set form length in lines',CR,LF
DB '2: Set form length in inches',CR,LF
DB '3: Set width',CR,LF,0
;
CALL CHOICE
LD B,1 ;Set minimum
LD C,4 ; & max+1
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LD ;Out of range
LD A,E ;Get index
CP 2 ;Which one?
JP NC,LD3 ;#3
JP Z,LD2 ;#2
;
;Set page length in lines
LD1:
CALL PRINT
DB CR,LF,LF,'Enter length in lines (max 127): ',CR,LF
DB '---> ? ',0
;
LD A,0
CALL BBLINE
LD B,1 ;Set minimum
LD C,128 ; & max+1
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LD1 ;Out of range
LD A,E ;Get index
LD (LD12),A
CALL LPRINT ;Print & exit
DB ESC,'C'
LD12: DB 1,0
;
;
;
LD2: ;Set page length in inch increments
CALL PRINT
DB CR,LF,LF,'Enter length in inches (max 22): ',CR,LF
DB '---> ? ',0
;
LD A,0
CALL BBLINE
LD B,1 ;Set minimum
LD C,23 ; & max+1
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LD2 ;Out of range
LD A,E ;Get index
LD (LD22),A
;
CALL RPRINT
DB ESC,'C',0
XOR A ;Force null
CALL LOUT ; & put
;
CALL LPRINT ;Print & exit
LD22: DB 1,0
;
;
LD3: ;Set page width
CALL PRINT
DB CR,LF,LF,'Enter width: ',CR,LF
;
IF MX100
;
DB 'Up to 136 in normal or emphasized mode.',CR,LF
DB ' 233 in condensed mode.',CR,LF
DB ' 68 in enlarged mode.',CR,LF
DB ' 116 in enlarged-condensed mode',CR,LF
;
ELSE
;
DB 'Up to 80 in normal or emphasized mode.',CR,LF
DB ' 132 in condensed mode.',CR,LF
DB ' 40 in enlarged mode.',CR,LF
DB ' 60 in enlarged-condensed mode',CR,LF
;
ENDIF
;
DB '---> ? ',0
;
LD A,0
CALL BBLINE
LD B,1 ;Set minimum
LD C,MAXWDTH+1 ; & max+1
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LD3 ;Out of range
LD A,E ;Get index
LD (LD32),A
CALL LPRINT ;Print & exit
DB ESC,'Q'
LD32: DB 1,0
;
;
;
;
;
LE:
;
IF GTRAX
;
; Set uni-directional print on/off
CALL CPRINT ;Cls & display
DB '1: Set uni-directional print ON',CR,LF
DB '2: Set uni-directional print OFF',CR,LF,0
;
CALL CHOICE ;Ask & get input
LD B,1 ;Set minimum
LD C,3 ; & max+1
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LE ;Out of range
CALL RPRINT
DB ESC,'U',0
LD A,2 ;Convert index to 1/0 flag
SUB E ;1 now 1; 2 now 0
CALL LOUT
JP START
;
;
ELSE
;
; ;Set vertical tabs
CALL CPRINT ;Cls & display
DB CR,LF,LF,'Enter vertical tab positions (max 8)',CR,LF
DB '(in ascending order) ---> ? ',0
;
LD A,0
CALL BBLINE ;Get line of tabs, terminated by 00h
LD DE,VTABS ;Set to tab list
LD A,1 ;Set minimum tab
LD (DE),A ;Prime tab list
LD C,128 ;Set max tab+1 (we dont know page len)
LD B,8 ;Set loop count
CALL TABS ;Handle tabs, returns flag in <A>
OR A ;OK?
JP Z,LE2 ;Yes
DEC A ;No - exit?
JP Z,START ;Yes -
JP LE ;No - ask new input
;
; Output tab string
LE2:
LD HL,VTABS-2 ;Set to string to put
JP HTBS2 ; & go put
;
;
;
DB ESC,'B' ;Vertical tabs
VTABS: DB 1,0,0,0,0,0,0,0,0 ;8 tabs & null
;
;
;
ENDIF
;
;
LBLF: ;Set horizontal tabs
CALL CPRINT ;Cls & display
DB CR,LF,LF,'Enter horizontal tab positions (max 12)',CR,LF
DB '(in ascending order) ---> ? ',0
;
LD A,0
CALL BBLINE
LD DE,HTABS ;Set to tab list
LD A,1 ;Set minimum tab
LD (DE),A ;Prime tab list
LD C,MAXWDTH+1 ;Set max tab+1 (we dont know page width)
LD B,12 ;Set loop count
CALL TABS ;Handle tabs, returns flag in <A>
OR A ;OK?
JP Z,LBLF2 ;Yes
DEC A ;No - exit?
JP Z,START ;Yes -
JP LBLF ;No - ask new input
;
; Output tab string
LBLF2:
LD HL,HTABS-2 ;Set to string to put
HTBS2:
CALL LPR ;Put string at HR>
; Is safer than RPRINT due to variable len
; past null may be garbage
XOR A ;Force null after tabs
CALL LOUT
JP START
;
;
DB ESC,'D'
HTABS: DB 1,0,0,0,0,0,0,0,0,0,0,0,0 ; 12 tabs & null
;
;
;
LG: ;Set top of form (FF)
CALL LPRINT ;Print & exit
DB FF,0 ;Output formfeed
;
;
LH: ;Turn on perf. skip-over
CALL CPRINT ;Cls & display
DB CR,LF,LF
DB 'Enter no of lines to skip over perforation'
DB ' (max 127)',CR,LF
DB '---> ? ',0
;
LD A,0
CALL BBLINE
LD B,1 ;Set minimum
LD C,128 ; & max+1
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LH ;Out of range
LD A,E ;Get index
LD (LH2),A
CALL LPRINT ;Print & exit
DB ESC,'N'
LH2: DB 0,0 ;Skip n lines
;
;
;
LI: ;Turn off perf. skip-over
CALL LPRINT ;Print & exit
DB ESC,'O',0
;
;
;
LJ: ;Enable paper-out signal
CALL LPRINT ;Print & exit
DB ESC,'9',0
;
;
;
LK: ;Disable paper-out signal
CALL LPRINT ;Print & exit
DB ESC,'8',0 ;Disable paper-out sensor
;
;
;
LL: ;Set graphics
; Note that non-graftrax also supports graphics
;
CALL CPRINT ;Cls & display
DB '1: Set medium density graphics',CR,LF
DB '2: Set high density graphics',CR,LF,0
;
CALL CHOICE ;Ask & get input
LD B,1 ;Set minimum
LD C,3 ; & max+1
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LL ;Out of range
LD A,E ;Get index
CP 1 ;Medium density?
JP NZ,LL2 ;No - high
;
; Set medium density
LL1:
LD HL,MAXGMED ;Set max no acceptable
CALL GETBITS ;Get no of bits
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LL1 ;Out of range
LD (LL12),HL ;Save wanted no bits
CALL LPRINT ;Print & exit
DB ESC,'K'
;
;
LL12: DB 0,0,0
;
;
;
LL2: ;Set graphics - high density
LD HL,MAXGHI ;Set max no acceptable
CALL GETBITS ;Get no of bits
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LL2 ;Out of range
LD (LL22),HL ;Save wanted no bits
CALL LPRINT ;Print & exit
DB ESC,'L'
LL22: DB 0,0,0
;
;
LM: ;Print test
CALL LPRINT
; DB CR,LF,LF ;Removed re double width SO
DB 'ABCDEFGHIJKLMNOPQRSTUVWXYZ '
DB 'abcdefghijklmnopqrstuvwxyz',CR,LF,0
; ; LF turns off condensed
CALL SETCOND ;Re-activate condensed if reqd
;
CALL LPRINT
DB "1234567890-=['\;,./"
DB '!@#$%^&*()_+]"|:<>?',CR,LF,LF,0
; ; LF turns off condensed
CALL SETCOND ;Re-activate condensed if reqd
;
;
IF GTRAX
;
LN: ;Set handling of 8th bit
CALL CPRINT ;Cls & display
DB '1: Bit 8 as is',CR,LF
DB '2: Bit 8 always ON',CR,LF
DB '3: Bit 8 always OFF',CR,LF,0
;
CALL CHOICE ;Ask & get input
LD B,1 ;Set minimum
LD C,4 ; & max+1
CALL NUMBER
CP 1 ;Test flag
JP Z,START ;Get out on thru
JP NC,LN ;Out of range
LD A,E ;Get index
LD HL,NTABL-1 ;Index table (offset for ascii char index)
ADD A,L ;Combine with index char
JP NC,LN1 ;No carry to high byte
INC H
LN1:
LD L,A ;Complete index
;
LD A,(HL) ;Get byte at HL>
LD (LNBYT),A ; & store in string
CALL LPRINT ;Print & exit
DB ESC
LNBYT: DB 0,0
;
;
NTABL: DB '#','>','=' ;As is, on, off
;
;
;
LO: ;Home print head
CALL LPRINT ;Print & exit
DB ESC,'<',0
;
;
ENDIF
;
;
; Hex keypad to printer
LX:
CALL CPRINT ;Cls & display
DB 'Only keys 0-9 and A-F are accepted',CR,LF
DB 'For every pair of hex digits a character',CR,LF
DB 'passed to the printer',CR,LF
DB 'Use ^Z (single keystroke) to end',CR,LF,CR,LF,0
;
LXLP:
CALL XIN ;Get one hex digit (or ^Z)
CALL CCOUT ;& display, control char as ^.
CP EOF ;^Z?
JP Z,START ;Yes - get out
LD D,C ;Keep 1st hex digit
CALL XIN ;Get second hex digit (or ^Z)
CALL CCOUT ;& display, control char as ^.
CP EOF ;^Z?
JP Z,START ;Yes - get out
LD A,' ' ;Blank between digit pairs
CALL CCOUT
; Combine hex digits
; Low-order digit in <C>
LD A,D ;
ADD A,A ; 2x
ADD A,A ; 4x
ADD A,A ; 8x
ADD A,A ;16x
ADD A,C ;Combine digits
;
CALL LOUT ;No - put to printer
CP LF ;Line feed?
JP Z,CHKCNDX ;Yes - check condensed
CP CR ;Or carriage return (may not be necessary)
JP NZ,LXLP ;No - go for next char
CHKCNDX:
CALL SETCOND ;Re-activate condensed if reqd
JP LXLP ;Go for next char
;
;
; Get Hex digit
; Returns hex digit in <C>,
; original char entered in <A>
;
XIN:
CALL DIN ;Get one char
OR A ;Anything?
JP Z,XIN ;No - try again
CP EOF ;^Z?
RET Z ;Yes - return
LD B,A ;Keep actual char
CP '0' ;Validate 0 - 9
JP C,XIN
CP '9'
JP C,XIN2 ;Yes - digit 0 -9
CP 'A' ;Lower case A - F?
JP C,XIN
CP 'F'
JP C,XIN3 ;Yes - A - F
CP 'a' ;Upper case A - F
JP C,XIN
CP 'f'+1
JP NC,XIN ;No - ignore
XIN3: ;Alpha A-F/a-f
AND 07H ;Convert to 01-06
ADD A,9 ;now 0A-0FH
XIN2: AND 0FH ;Strip zone for 0-9, noop for alpha
LD C,A ;Hex digit
LD A,B ;Original char
RET
;
;
; Re-activate condensed if selected
SETCOND:
LD A,(OPTIONS) ;Get current options
AND 80H ;Condensed on?
JP Z,LXLP ;No - go for next char
LD A,SI ;Set condensed on again
CALL LOUT ; to printer
RET
;
;
; Keyboard to printer
LZ:
CALL CPRINT ;Cls & display
DB 'All keys pressed are passed to the printer',CR,LF
DB 'This includes all control keys, except ^Z',CR,LF
DB 'Use ^Z to end',CR,LF,CR,LF,0
;
LZLP:
CALL DIN ;Get one char
OR A ;Anything?
JP Z,LZLP ;No - try again
CALL CCOUT ;& display, control char as ^.
CP EOF ;^Z?
JP Z,START ;Yes - get out
CALL LOUT ;No - put to printer
CP LF ;Line feed?
JP Z,CHKCOND ;Yes - check condensed
CP CR ;Or carriage return (may not be necessary)
JP NZ,LZLP ;No - go for next char
CHKCOND:
CALL SETCOND ;Re-activate condensed if reqd
JP LZLP ;Go for next char
;
;
; Print string on printer & exit
LPRINT:
EX (SP),HL ;Save <HL> & get string addr
CALL LPR ;Print string at HL>
POP HL ;Restore register used
JP START
;
; Print string on printer & return
RPRINT:
EX (SP),HL ;Save <HL> & get string addr
CALL LPR ;Print string at HL>
EX (SP),HL ;Restore register used & return addr
RET
;
; Print string at HL>
;
LPR:
PUSH AF
LPRLP:
LD A,(HL) ;Get next char
INC HL ; & step past
OR A ;End?
JP Z,LPREX ;Yes
CALL LOUT ;Output byte in <A>
JP LPRLP ;Go for next byte
;
LPREX:
POP AF
RET
;
; Print string on Console & return
PRINT:
EX (SP),HL ;Save <HL> & get string addr
CALL PR ;Print string at HL>
EX (SP),HL ;Restore register used & return addr
RET
;
; Print string at HL> on console
;
PR:
PUSH AF
PRLP:
LD A,(HL) ;Get next char
INC HL ; & step past
OR A ;End?
JP Z,PREX ;Yes
CALL COUT ;Output byte in <A>
JP PRLP ;Go for next byte
;
PREX:
POP AF
RET
;
;
; loop through all tabs
; ;HL> tab source string
; ;DE> tab destination list
; ;<B> max no of tabs
; ;<C> max allowed tab
; ;Returns <A> 0 - ok, 1 zero tab found, 2 error
TABS:
PUSH DE ;Save tab destination pointer
PUSH BC ;Save no of tabs
LD A,(DE) ;Get minimum
LD B,A
CALL NUMBER ;Get next number in <E>, flag in <A>
POP BC
LD A,E ;Save tab # (2x)
LD B,E ;Save tab #
POP DE ;Restore dest'n pointer
LD (DE),A ;Save tab
INC DE ;Step to next posn
OR A ;Test flag
RET NZ ; On null response & on error
LD A,(HL) ;Was current no last?
OR A ;(i.e. terminating null)
JP Z,TABT ;Yes - thru
LD A,B ;Get save tab no
INC A ;Set as new minimum
LD (DE),A ; & save tab+1 for minimum check
DJNZ TABS ;Continue if count not out
; max no tabs - ignore rest
TABT: ;Thru all tabs
XOR A
LD (DE),A ;Ensure last posn zero
RET ;With <A> zero
;
;
; :Get number from HL>,
; limited by , or 00H
; test min in <B>, max in <C>
; returned in <E>,
; flag in <A> 0 - ok, 1 end input, 2 error
; returns HL> past comma if present
NUMBER:
PUSH HL ;Save current posn for null check
CALL EVAL10 ;Get next number at HL> in <DE>
EX DE,HL ;Put curr posn in <DE>
EX (SP),HL ;Get prev posn in <HL>
XOR A ;Turn off carry flag
SBC HL,DE ;Did we move at all? (equal/not eq)
POP HL ;Either way restore
EX DE,HL ;<DE> number, HL> next posn
JP Z,NUMEX ;Didn't move - exit
; We picked up some number - may be zero
LD A,D
OR A
JP NZ,NUMER ;Over 255
LD A,C ;Get max if any
OR A ;Set flag
LD A,E ;Get number - leave flag
JP Z,NUMMAX ;No maximum
CP C ;Over max?
JP NC,NUMER ;Yes - get out
NUMMAX:
CP B ;Less minimum
JP C,NUMER ;Invalid
LD A,(HL) ;Get delimiter following tab
OR A ;Null?
JP Z,NUMTRU ;Yes - thru
CP ',' ;Valid delimiter?
JP NZ,NUMER ;No - ask new input
INC HL ;Step past comma
LD A,E ;Get no again, now check for zero
OR A ;Zero - treat as end
RET Z ;Yes - get out with
; Number ok
NUMTRU:
XOR A ;Set ok flag
RET
NUMEX:
LD A,(HL) ;Get delimiter following tab
OR A ;Null?
JP NZ,NUMER ;No - invalid
LD A,1 ;Set exit flag
RET
NUMER:
CALL PRINT ;Put out error
DB BELL,CR,LF,LF,0
;
LD A,2 ;Set error flag
RET
;
;
; Get No of bits for graphics mode,
; in: <HL> max
; out: <HL> actual
GETBITS:
PUSH HL ;Save max
CALL PRINT
DB 'No of bits of graphics? ',0
;
LD A,0
CALL BBLINE
CALL EVAL10
EX DE,HL ;Put curr posn in <DE>
EX (SP),HL ;Get prev posn in <HL>
XOR A ;Turn off carry flag
SBC HL,DE ;Did we move at all? (equal/not eq)
POP HL ;Either way restore
EX DE,HL ;<DE> number, HL> max no
JP Z,NUMEX ;Didn't move - exit with flag
XOR A ;Turn off carry flag
SBC HL,DE ;is entered over max?
JP C,NUMER ;Yes - get out on error flag
EX DE,HL
RET ;No -ok, zero in <A>, numberin <HL>
;
; Ask for input - return 1 byte in <A>
CHOICE:
CALL PRINT ;Show last line in menu
DB 'Enter your choice: ',0
;
LD A,1 ;Specify capitalization
CALL BBLINE ;Wait for input line
LD A,(HL) ;Get first char, all others ignored
RET
;
;
; Set Options flags on
; <C> has bit mask
SETOPT:
PUSH HL
PUSH AF
LD A,(OPTIONS) ;Get current options
OR C ;Turn on bits
LD (OPTIONS),A ;Save updated flags
POP AF
POP HL
RET
;
; Set Options flags off
; <C> has bit mask
RESOPT:
PUSH HL
PUSH AF
LD A,(OPTIONS) ;Get current options
AND C ;Turn off bits
LD (OPTIONS),A ;Save updated flags
POP AF
POP HL
RET
;
;
; Clear screen & display text
CPRINT:
PUSH HL
PUSH AF
LD HL,CLR ;Set to clear screen string
CPRTLP:
LD A,(HL) ;Get next char
INC HL
OR A ;End of string?
JP Z,CPRT ;Yes -
CALL COUT ;No - display
JP CPRTLP
;
CPRT:
POP AF
POP HL
JP PRINT ;Go print string whose addr now on stack
;
;
COUT: ;Put char in <A> to CON:
PUSH AF
PUSH BC
PUSH DE
PUSH HL
LD E,A ;Set char
LD C,2 ;Set CONOUT funtion
CALL BDOS
POP HL
POP DE
POP BC
POP AF
RET
;
LOUT: ;Put char in <A> to LST:
PUSH AF
PUSH BC
PUSH DE
PUSH HL
LD E,A ;Set char
LD C,5 ;Set LISTOUT funtion
CALL BDOS
POP HL
POP DE
POP BC
POP AF
RET
;
CCOUT: ;Put char in <A> to CON:
; Show control chars
PUSH AF
PUSH BC
CP ' ' ;Control char?
JP NC,CCO2 ;No
CP CR ;Special?
JP Z,CCO2 ;Yes - as is
CP LF ;Special?
JP Z,CCO2 ;Yes - as is
CP BELL ;Special?
JP Z,CCO2 ;Yes - as is
CP BS ;Special?
JP Z,CCO2 ;Yes - as is
; Convert & display
CP ESC ;Escape?
JP NZ,CCO3 ;Yes - spell
LD A,'E'
CALL COUT
LD A,'S'
CALL COUT
LD A,'C'
JP CCO2
;
CCO3: ;Show ^
OR 40H ;Convert to alpha
PUSH AF
LD A,'^'
CALL COUT
POP AF ;Get converted
CCO2:
CALL COUT ;Put char in <A>
POP BC
POP AF
RET
;
DIN: ;Get char - if available
PUSH BC
PUSH DE
PUSH HL
LD C,6 ;Set Direct CON I/O funtion
LD E,0FFH ;Flag as input request
CALL BDOS
POP HL
POP DE
POP BC
RET
;
;
END