; XTAIL.Z80 ; ; Displays command tail as parsed by the command processor. ; Vers equ 11 ; current version SubVers equ ' ' ; modification level ; ; USAGE: ; ; XTAIL {whatever you want} ; ; HISTORY: ; ; Version 1.1 -- January 12, 1991 -- Gene Pizzetta ; Changed hard-coded video attributes to use VLIB routines. Converted ; to Zilog mnemonics. Added type-3 header and type-4 assembly. Created ; documentation file. ; ; Version 1.0 -- December 21, 1987 -- Gene Pizzetta ; Original version. ; ; Gene Pizzetta ; 481 Revere St. ; Revere, MA 02151 ; ; Voice: (617) 284-0891 ; Newton Centre Z-Node: (617) 965-7259 ; Ladera Z-Node Central: (213) 670-9465 ; .request vlib,z3lib,syslib1,syslib0 ; ext gz3init,vprint,stndout,stndend,setatr ext zsyschk ext pa2hc,phl4hc,bout ; ; System addresses . . . ; CpmFcb equ 05Ch AltFcb equ 06Ch CpmDma equ 080h ; ; ASCII characters . . . ; HON equ 01h ; highlight on HOF equ 02h ; highlight off LF equ 0Ah ; line feed CR equ 0Dh ; carriage return ; ; TYP3HDR.Z80, Version 1.1 ; This code has been modified as suggested by Charles Irvine so that it will ; function correctly with interrupts enabled. ; Entry: jr Start0 ; must use relative jump defb 0 ; filler db 'Z3ENV',3 ; type-3 environment Z3EAdr: dw 0 ; filled in by Z33 dw Entry ; intended load address ; Start0: ld hl,0 ; point to warmboot entry ld a,(hl) ; save the byte there di ; protect against interrupts ld (hl),0C9h ; replace warmboot with a return opcode rst 0 ; call address 0, pushing RETADDR onto stack RetAddr: ld (hl),a ; restore byte at 0 dec sp ; get stack pointer to point dec sp ; ..to the value of RETADDR pop hl ; get it into HL and restore stack ei ; we can allow interrupts again ld de,RetAddr ; this is where we should be xor a ; clear carry flag push hl ; save address again sbc hl,de ; subtract -- we should have 0 now pop hl ; restore value of RETADDR jr z,Start ; if addresses matched, begin real code ld de,NotZ33Msg-RetAddr ; offset to message add hl,de ex de,hl ; switch pointer to message into DE ld c,9 jp 0005h ; return via BDOS print string function NotZ33Msg: db 'Not Z33+$' ; abort message if not Z33-compatible ; Start: ld hl,(Z3EAdr) ; get environment address call zsyschk ; is this a z-system? ret nz ; (no, exit) ld (OldStk),sp ; set up new stack ld sp,OldStk call gz3init ; initialize environment ld (Z3TFlg),a call vprint ; print sign-on db HON,'XTAIL Version ' db Vers/10+'0','.',Vers mod 10+'0',SubVers db ' (loaded at ',0 ld hl,Entry ; print load address call phl4hc call vprint ; print header for fcb's db 'h)',HOF,CR,LF,LF db 'Default and alternate file control blocks:',CR,LF db HON,' addr dr filename -- -- -- -- -- filetype us fl',HOF,CR,LF,0 ld hl,CpmFcb ; point to default fcb call PrtRec ; ..and dump it call vprint db CR,LF,0 ld hl,AltFcb ; point to alternate fcb call PrtRec ; ..and dump it call vprint ; print fcb trailer and header for DMA buffer db CR,LF db HON,' offset: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15',HOF db CR,LF,LF db 'Command tail:',CR,LF db HON,' addr ct tail -- -- -- -- -- -- -- -- -- -- -- -- --',HOF,CR,LF,0 ld hl,CpmDma ; point toe default DMA buffer ld a,(hl) ; get character count inc a ; increment it ld (DmaCnt),a ; ..and save it TailLp: call PrtRec ld a,(DmaCnt) ; check for end of command string sub 16 ld (DmaCnt),a jr c,Exit ; (yes, we display only as much as needed) call vprint db CR,LF,0 ld de,10h ; increment address pointer add hl,de jr TailLp ; Exit: ld sp,(OldStk) ; restore stack ret ; ; PrtRec -- prints starting address and then dumps 16 bytes in hexadecimal ; and ASCII. Expects starting address in HL, which is returned unchanged. ; PrtRec: push hl ; save address pointer for caller ld a,' ' ; print 2 spaces, call bout call bout call phl4hc ; ..address in hex, ld a,':' ; ..a colon, call bout ld a,' ' ; ..another space, call bout ld b,16 ; ..and 16 bytes in hex push hl ; save address for ASCII dump HDump: ld a,(hl) ; get byte and print as call pa2hc ; ..2 hex characters ld a,' ' ; ..followed by a space call bout inc hl ; increment pointer djnz HDump ; ..and loop ld a,' ' ; print 2 spaces call bout call bout ld a,(Z3TFlg) ; extended TCAP? or a ld a,2 ; set for reverse video call nz,setatr ; (extended attributes, if available) call z,stndout ; (not available, try standout) ld a,'|' ; (not available, use bar) call z,bout ld b,16 pop hl ; recover address for ASCII dump ADump: ld a,(hl) ; get byte cp ' ' ; control character? jr c,DotPrt ; (yes, print dot) cp 07Fh ; delete or above? jr c,AscPrt ; (no, print as is) DotPrt: ld a,'.' ; print dot AscPrt: call bout inc hl ; increment pointer djnz ADump ; ..and loop ld a,(Z3TFlg) ; extended TCAP? or a ld a,0 ; set to turn off reverse video call nz,setatr ; (extended attributes, if available) call z,stndend ; (not available, try standout) ld a,'|' ; (not available, use bar) call z,bout pop hl ; recover address pointer for caller ret ; DSEG ; Z3TFlg: ds 1 ; non-zero = extended TCAP DmaCnt: ds 1 ; number of characters in DMA ds 50 ; stack OldStk: ds 2 ; old stack pointer storage ; end