page ; Library: RCPECHO for Z34RCP ; Author: Carson Wilson ; Version: 1.0 ; Date: June 15, 1988 ; ; Command: ECHO ; Function: Echo text to console or printer echo: xor a ; Lower case/printer off flag setting ld (crtfl),a ; Printer off by default if upcase ; If upper case default dec a endif ;upcase ld (casefl),a ; Store flag in code below ld hl,tbuff+1 ; Point to first character call getchar ; Get first character (should be blank) ; If none, exit from routine ; Loop to echo chars echo2: call getchar if echolst cp ff ; Form feed? jr z,echo3 endif ;echolst cp '^' jr nz,echo2a ; Not control character prefix call getchar ; Get next character and 1fh ; Convert to control character jr echo2e ; Echo it echo2a: cp cmdchar ; Case shift prefix? jr nz,echo2e ; No, normal echo call getchar ; Get next character if echolst cp prtchar ; Turn printer on? jr z,echo2b ; Store non-zero in crt flag cp crtchar ; Turn printer off? jr nz,echo2c ; No, test for shift characters xor a ; Yes, clear crt flag echo2b: ld (crtfl),a jr echo2 ; On to next character echo2c: endif ; echolst cp ucasechar ; Up-shift character? jr z,echo2d ; Store non-zero value in case flag cp lcasechar ; Lower-case character? jr nz,echo2e ; No, echo the character as is xor a ; Else, clear case flag echo2d: ld (casefl),a jr echo2 ; On to next character echo2e: call echout ; Send char jr echo2 ; Form feed - send new line followed by form feed if printer output if echolst echo3: ld a,(crtfl) ; Check for printer output or a ; Non-zero? jr z,echoff ; No, send form feed normally call echonl ; Send new line ld a,ff ; Send form feed jr echout ; Send form feed char to console echoff: ld a,ff ; Get char jr echo2e endif ;echolst ; End of print loop - check for printer termination echo4: if not echolst ret else ld a,(crtfl) ; Get list mode flag or a ret z ; Done if no printer output ; Output a new line echonl: ld a,cr ; Output new line on printer call echout ld a,lf ; Fall thru to echout endif ; not echolst ; Output char to printer or console echout: ld c,a ; Char in c cp 'A' ; If less than 'A' jr c,echouta ; Leave as is cp 'Z'+1 ; If greater than 'Z' jr nc,echouta ; Leave as is add 20h ; Else convert to lower case echouta: ld d,a ; Save lower case version in d casefl equ $+1 ; Pointer for in-the-code modification ld a,0 or a ; Upper case? jr nz,echoutb ; If upper case selected, go on as is ld c,d ; Else substitute lower case version echoutb: push hl ; Save hl push bc ; Save bc ld de,0ch-3 ; Offset for BIOS console output if echolst crtfl equ $+1 ld a,0 or a ; Printer? jr z,echout1 ; No inc de ; Offset for BIOS printer output inc de inc de endif ;echolst ; Output char in C with BIOS offset in DE echout1: call biout ; Bios output pop bc ; Restore bc,hl pop hl ret ; Get a character from the command tail buffer getchar: ld a,(hl) ; Get character inc hl ; Point to next one or a ; Check for end of string ret nz ; If not end, return pop hl ; Else, clean up stack jr echo4 ; And exit from routine ; Output char in C to BIOS with offset in DE biout: ld hl,(wboot+1) ; Get address of warm boot add hl,de ; Pt to routine jp (hl) ; Jump to it ; End RCPECHO.LIB