home *** CD-ROM | disk | FTP | other *** search
- .printx Reading ZFSUBS4.Z80
- ;===========================================================================
- ;
- ; ZFSUBS4.Z80 - General Screen Output Routines
- ;
- ;===========================================================================
-
- ; PRTSPAC - Print spaces - Reg B has number of spaces
-
- prtspac:
- inc b ; Test for B = 0
- dec b
- ret z
- push af ; Save AF just in case
- ld a,' '
- prtspac1:
- call cout
- djnz prtspac1
- pop af
- ret
-
- ;---------------------------------------------------------------------------
-
- ; PRDU - Print DU in HL
-
- prdu:
- push hl ; Save regs
- push bc
-
- if revvideo
- call stndout ; Dim
- else
- call stndend
- endif
-
- ld a,h ; Get drive
- add a,'A' ; Convert to letter
- call cout
- ld a,l ; Get user
- ld b,h ; Get du in bc
- ld c,l
- call pafdc ; Print user as floating
- ld a,':' ; Print colon
- call cout
- call dutdir ; Scan named directory table
- jr z,prdu2 ; No name?
- ld b,8 ; Print name
- prdu1:
- ld a,(hl) ; Get char
- cp ' ' ; Done if space encountered
- jr z,prdu3
- call cout
- inc hl
- djnz prdu1
- jr prdu3
-
- prdu2:
- ld hl,msg110 ; "Noname"
- call pstri
- prdu3:
- if revvideo
- call stndend ; Bright
- endif
-
- pop bc ; Restore regs
- pop hl
- ret
-
- ;---------------------------------------------------------------------------
-
- ; File Name Printing Routines
-
-
- ; DISPCFN - Display file name of current file
-
- dispcfn:
- call ringempt ; Check ring empty
- ret z ; Don't bother
-
- if fcols eq 5
- ld hl,fnadr ; Position cursor for file name print
- else ; four columns
- ld hl,fnadr-1 ; One position more to left
- endif
-
- call gotoxy
- ld hl,(ringpos) ; Pt to current file name
- inc hl ; Pt to first char
-
- ; Use video to show file attributes. Use '_' to show
- ; spaces with attributes if not using reverse video, or to
- ; show all attributes if reverse/low video not available.
-
- if revvideo
- push af
- call stndout
- pop af
- endif
- ld b,8 ; 8 chars
- call disp1
- ld a,'.'
- call cout
- ld b,3 ; File type and fall thru
- disp1:
- ld a,(hl) ; Get char
- cp 80h ; 7th bit set?
- jr c,disp3 ; no
-
- if novid ; terminals with no reverse/low video
- ld a,'_' ; use '_' to show file attributes
- else
-
- if not revvideo
- cp ' '+80h ; space with 7th bit set?
- jr nz,disp2 ; no
- ld a,'_' ; yes, use '_'
- endif ; not revvideo
- disp2:
- push af
- if revvideo
- call stndend
- else
- call stndout
- endif
- pop af
-
- endif ; novid
-
- disp3:
- and 7fh ; strip 7th bit
- call cout ; print char
- if revvideo
- call stndout
- else
- call stndend
- endif
- inc hl ; Pt to next
- djnz disp1
- ret
-
-
- ; PRFNS - Print File Name Pointed to by HL (saving HL)
-
- prfnsx:
- push hl ; Save hl
- jr prfns0
-
- ; PRFNSX - Print file name in S$FCB (saving HL)
-
- prfns:
- push hl ; Affect only psw
- ld hl,s$fcb+1
-
- prfns0:
- push bc ; Save bc
- call prfnskip ; Print file name with no spaces
- pop bc ; Restore
- pop hl
- ret
-
-
- ; PRFN - Print file name pted to by HL
-
- prfn:
- xor a ; Preset for no char skipping
- jr prfnsk
-
- prfnskip:
- ld a,' ' ; Preset for skipping spaces
-
- prfnsk:
- ld c,a ; Save char to skip in C
- ld b,8 ; 8 chars
- call prfns1
- ld a,'.'
- call cout
- ld b,3 ; File type and fall thru
-
- prfns1:
- ld a,(hl) ; Get char
- and 7fh
- call setcase ; Possible shift to lower case
- cp c ; Is it char to skip?
- call nz,cout
- inc hl ; Pt to next
- djnz prfns1
- ret
-
- ;--------------------
-
- setcase:
- push bc
- ld b,a ; Save character to display
- ld a,(casefl) ; Check desired case
- or a
- ld a,b
- pop bc
- ret nz ; If upper case desired, quit now
- cp 'A'
- ret c ; If less than 'A', no change needed
- cp 'Z'+1
- ret nc ; If greater than 'Z', no change needed
- add a,20h ; Shift to lower case
- ret
-
- ;---------------------------------------------------------------------------
-
- if datestamp
-
- ; BTIME - If real-time clock available, print 12-hour time in Banner,
- ; no leading zeroes.
-
- extrn @b2hh,@b2hl ; SYSLIB4
-
- btime:
- call cpm3
- jr c,btime0 ; Not CPM Plus
- ld c,105
- ld de,81h
- call bdosptr
- jr time$ret
- btime0:
- call checkds ; Clock address returned in HL
- ret z ; No clock
- ld de,time$ret
- push de ; Return address on stack
- push hl ; Clock address on stack
- ld hl,80h ; Point to buffer
- ret ; Call clock (buffer filled)
-
- time$ret:
- ld hl,1*256+18 ; Cursor to time location
- call gotoxy
-
- ld hl,msg120 ; "Time:"
- call pstri
-
- ld hl,83h ; Point to hours
- ld a,(hl)
- bit 7,(hl) ; If relative time
- ret nz ; ..don't display
-
- sub 13h ; Time past 12:59?
- jr c,btime1 ; No, don't change
- daa ; Yes, decimal adjust
- inc a ; Xlate to 12-hour
- daa
- ld (hl),a ; Save 2nd digit
- jr btime2
- btime1:
- ld a,(hl)
- btime2: call @b2hh ; High nybble of A --> ASCII in A
- cp '0' ; Leading zero?
- jr nz,btime3 ; No, display digit
- ld a,' ' ; Yes, leading space instead
- btime3: call btime4 ; Print hours
- if revvideo
- call stndout
- endif
- ld a,':'
- call cout
- inc hl ; Point to minutes
- ld a,(hl)
- call @b2hh
- btime4:
- if revvideo
- push af
- call stndout
- pop af
- endif
- call cout ; Show digit 1
- ld a,(hl) ; Restore A
- call @b2hl ; Low nybble A --> ASCII
- call cout
- if revvideo
- call stndend
- endif
- ret
-
- endif ; Datestamp
-
-
- ; Test for CPM Plus
-
- cpm3:
- ld c,dosver
- call bdosptr
- cp 30h
- ret
-
- ;---------------------------------------------------------------------------
-
- ; PRINT$FRE - Print free space on disk
-
- print$fre:
- call erclr ; Position and set flags
- ld hl,(disksp)
- ld a,swcon ; Switch to console
- ld (sctlfl),a
- call shlfdc ; # of free k-bytes in hl
- ld hl,msg111 ; "K Bytes free on Disk X:"
- call pstri
- ld hl,free$drv
- jp vpstr
- free$drv:
- db 'X:',0
-
- ;---------------------------------------------------------------------------
-
- ; File Screen Display Routines
-
-
- ; REBUILD - Build Entire Screen
-
- rebuild:
- ld hl,(curat) ; Save cursor and ring positions
- ld (scurat),hl
- ld hl,(ringpos)
- ld (sringpos),hl
- call banner ; Print banner
- call dirmore ; Print current du:dir (and '[more files]' msg).
-
- if bihelp ; Built-in help?
- ld a,(helpdisp) ; Display help?
- or a ; 0=no
- jr z,reb1
- call helpmsg ; Print help message
- jr reb2
- reb1:
- endif ; Bihelp
-
- call cur$first ; Position cursor at first position
- ld hl,(locbeg) ; Pt to first file name
- call dispfiles ; Display files
- call cur$first ; Re-position cursor at first position
- reb2:
- ld hl,cpmadr ; Command prompt message
- call gotoxy
- ld hl,msg112 ; "Command (..."
- call pstri ; Prompt with drive prefix
- ld a,(helpdisp) ; In help now?
- or a ; 0=no
- jr z,reb3
- ld hl,msg113 ; "Files"
- call pstri
- jr reb4
-
- reb3:
- ld hl,msg114 ; "Help"
- call pstri
-
- reb4:
- ld hl,msg115 ; "X=Quit"
- call pstri
-
- reb5:
- ld hl,(scurat) ; Restore cursor and ring positions
- ld (curat),hl
- ld hl,(sringpos)
- ld (ringpos),hl
- call ringempt ; Ring empty?
- ret z ; No cursor
- jp setcur ; Restore cursor on screen and return
-
- ;------------------------------
-
- ; REFRESH - Refresh Files Portion of Screen
-
- refresh:
- ld hl,(curat) ; Save cursor and ring positions
- ld (scurat),hl
- ld hl,(ringpos)
- ld (sringpos),hl
- ld hl,(ring)
- ld (ringpos),hl ; Beginning of file display
- call dirmore ; Print current du:dir (and '[more files]' msg).
-
- if bihelp ; Built-in help?
- ld a,(helpdisp) ; Display help?
- or a ; 1=yes
- jr nz,ref1
- endif ; Bihelp
-
- call cur$first ; Set cursor top left
- ld hl,(locbeg) ; Beginning of current screen
- call dispfiles ; Display files
- ref1:
- ld hl,(scurat) ; Restore cursor and ring positions
- ld (curat),hl
- ld hl,(sringpos)
- ld (ringpos),hl
- ret
-
- ;------------------------------
-
- ; BANNER - Print ZFILER Banner
-
- banner:
- call cls ; Clear screen
-
- if fcols eq 5
- ld hl,banadr
- else ; four columns
- ld hl,banadr-2 ; Two spaces to left
- endif
-
- call gotoxy
- call vprint ; Print banner
- if not revvideo
- db dim
- endif
- db 'ZFILER ',vers/10+'0','.',vers mod 10+'0'
-
- if subvers eq ' '
-
- db ' '
-
- else
-
- db subvers
-
- if usestk
- db ' '
- else ; using system file
- db 'f'
- endif ; usestk
-
- endif ; subvers eq ' '
-
- db ' '
-
- if not revvideo
- db dim
- endif
- db 0
-
- ld hl,msg116 ; "Current File:"
- jp pstri
-
- ;------------------------------
-
- ; DIRMORE - Print Current Directory (and Possibly '[More Files]') messages
-
- dirmore:
- if fcols eq 5
- ld hl,duadr ; Du screen address
- else ; four columns
- ld hl,duadr+2 ; Two columns to right
- endif
-
- call gotoxy
- ld hl,(du$req) ; Get current du
- call prdu ; Print du:dir>
-
- call public
- jr z,dirmr0 ; Not public
- call vprint
- db ' [PUBLIC]',0
-
- dirmr0:
- if fcols eq 5
- ld hl,moreadr ; More screen address
- else ; four columns
- ld hl,moreadr-1 ; One column more to left
- endif
-
- call gotoxy
- ld hl,(ringcnt) ; Get # files in ring.
- ld de,eps ; And maximum number that can be displayed.
- call cmpdehl
- jr nc,dirmr1 ; Br if all files will be displayed.
- ld hl,msg117 ; "[More Files]"
- jp pstri
-
- dirmr1:
- call vprint
- db bright,0
- ld b,12 ; Print 12 spaces
- jp prtspac ; And return
-
- ;------------------------------
-
- ; DISPFILES - Refresh File Display
-
- dispfiles:
- ld a,(caseflag)
- ld (casefl),a
- call dispfils
- ld a,0ffh
- ld (casefl),a
- ret
-
- dispfils:
- ld (locpos),hl ; Save local position
- dspf1:
- ld hl,(locend) ; At end?
- ex de,hl
- ld hl,(locpos)
- call cmpdehl
- ret z ; Return if done.
-
- call vprint
- if fcols eq 4
- db ' ',0 ; 4 spaces
- else
- db ' ',0 ; 2 spaces
- endif
-
- push hl ; Save current local position in ring
- call reffnt ; Print file name, tag.
- pop hl ; Get current local position
- ld de,eltsiz
- add hl,de
- ld (locpos),hl
- call cur$next ; Advance cursor
- jr dspf1
-
- ;---------------------------------------------------------------------------
-
- ; FINDSCR - Find screen containing file at RINGPOS
- ; Set the screen accordingly and position cursor
-
- findscr:
- ld hl,(ring) ; Begin at the beginning
- fndscr1:
- push hl ; Maybe this is it, save it
- ld de,eps*eltsiz ; One screen
- add hl,de ; Next screen
- ld de,(ringpos)
- call cmpdehl
- jr c,fndscr2 ; Found it
- pop de ; Adjust the stack
- jr fndscr1 ; Try again
- fndscr2:
- pop hl ; Beginning of this screen
- call setscr2 ; Set LOCBEG and LOCEND
-
- ; Position cursor at RINGPOS
-
- ld hl,curhome
- ld (curat),hl ; First position
- ld hl,(locbeg)
- fndnxt:
- ld de,(ringpos)
- call cmpdehl
- ret z ; We are there
- ld de,eltsiz ; One element length
- add hl,de
- push hl
- call psn$next ; Advance cursor
- pop hl
- jr fndnxt ; Try again..
-
-
- ; SETSCR - Setup Screen Display Variables
-
- setscr:
- ld hl,curhome ; Set cursor home
- ld (curat),hl
- ld hl,(ring) ; Set ring position
-
- ; Entry to Reset Ring Position at HL
-
- setscr1:
- ld (ringpos),hl
-
- ; Entry to Reset Local Ring Position at HL
-
- setscr2:
- ld (locbeg),hl ; Front of ring
- ld de,eps*eltsiz ; New end?
- add hl,de
- ld de,(ringend) ; End of ring
- call cmpdehl
- jr nc,setscr3
- ex de,hl
- setscr3:
- ld (locend),hl
- ret
-
- ;---------------------------------------------------------------------------
-
- ; CUR Subroutines to position the cursor
-
-
- ; CUR$FIRST - Home the Cursor
-
- cur$first:
- ld hl,curhome ; Home address
- ld (curat),hl ; Set cursor position
- jp gotoxy
-
-
- ; CUR$LAST - Move Cursor to Last File Position
-
- cur$last:
- call psn$last ; Position cursor
- cur$new:
- ld hl,(curat) ; Set new cursor position
- jp gotoxy
-
-
- ; CUR$NEXT - Move Cursor to Next File Position
-
- cur$next:
- call psn$next ; Position cursor
- jr cur$new ; Set new cursor position
-
-
- ; CUR$BACK - Move Cursor to Previous File Position
-
- cur$back:
- call psn$back ; Position cursor
- jr cur$new ; Set new cursor position
-
-
- ; CUR$DOW - Move Cursor Down a File Position
-
- cur$down:
- call psn$down ; Position cursor
- jr cur$new ; Set new cursor position
-
-
- ; PSN Subroutines manipulate the CURAT value without moving cursor
-
-
- ; PSN$LAST - Set Last File Position
-
- psn$last:
- ld hl,(ringpos) ; Advance
- pl0:
- ld de,eltsiz
- add hl,de
- ex de,hl
- ld hl,(locend) ; End of local ring?
- call cmpdehl
- ret z
- call psn$next ; Advance cursor position.
- ex de,hl ; Get position
- jr pl0
-
-
- ; PSN$NEXT - Advance the Cursor Position
-
- psn$next:
- ld hl,(curat) ; Compute new position
- ld a,l ; Check for new line
- add a,entsiz ; Size of each entry
- cp entsiz*[fcols-1]+2 ; Last column?
- jr nc,pn1 ; Advance to next line
- ld l,a ; New position
- ld (curat),hl
- ret
-
- pn1:
- ld a,h ; Get line
- ld hl,curhome ; Get col
- ld h,a ; Set line and continue with psn$down
- ld (curat),hl
-
- ; PSN$DOWN - Move Cursor Position Down One Line
-
- psn$down:
- ld hl,curhome ; Get home address
- ld b,h ; Line in b
- ld hl,(curat) ; Get current address
- inc h ; Move down
- ld a,h ; Check for too far
- sub b
- cp eps/fcols
- jr c,pd1 ; Ok, so save position
- ld a,l ; Get col
- ld hl,curhome
- ld l,a
- pd1:
- ld (curat),hl
- ret
-
- ; PSN$BACK - Back Up the Cursor Position
-
- psn$back:
- ld de,curhome ; Get home address
- ld hl,(curat)
- call cmpdehl ; Compare
- jr z,psn$last ; Goto end if last
- ld a,l ; Check for first col
- cp e
- jr z,pb1
- sub entsiz ; Back up one col
- ld l,a
- ld (curat),hl ; New pos
- ret
-
- pb1:
- ld a,e ; Get home col
- add a,entsiz*[fcols-1] ; Get last col
- ld l,a
- dec h ; Prev line
- ld (curat),hl
- ret
-
- ; SETCUR - Position Cursor at CURAT
-
- setcur:
- ld a,(helpdisp) ; Nogo if help display is active.
- or a
- ret nz
- ld hl,(curat)
- call gotoxy
- call vprint
-
- if revvideo
-
- db dim
- if fcols eq 4
- db '-->',bright,' '
- else ; not fcols eq 4
- db '->',bright
- endif ; fcols eq 4
-
- else ; not revvideo
-
- if fcols eq 4
- db '--> '
- else ; not fcols eq 4
- db '->'
- endif ; fcols eq 4
-
- endif ; revvideo
-
- db 0
-
- ret
-
- ; CLRCUR - Clear Cursor
-
- clrcur:
- ld a,(helpdisp) ; Nogo if help display is active.
- or a
- ret nz
- ld hl,(curat)
- call gotoxy
- call vprint
- if fcols eq 4
- db bright,' ',0
- else
- db bright,' ',0
- endif
- ret
-
- ;---------------------------------------------------------------------------
-
- ; Command Prompts and Messages
-
-
- ; CPRMPT - Command Prompt
-
- ; Clear any existing prompt and position cursor for new prompt (either
- ; on the error message or command line).
-
- erclr:
- eprmpt:
- push hl
- ld hl,eradr ; Get error line cursor address
- ld a,(erecnt) ; Get # chars to erase.
- jr xprmpt ; Clear line and position cursor
-
- cprmpt:
- push hl
- ld hl,cpadr ; Get command line cursor address
- ld a,(cpecnt) ; Get # chars to erase.
-
- xprmpt:
- push bc
- ld b,a ; Number of characters in B
- push hl ; Save cursor address
- call gotoxy ; Set cursor.
-
- if revvideo
- call stndend ; Dim
- else
- call stndout
- endif
-
- call ereol ; Erase to eol
- pop hl ; Restore address
- pop bc
- call gotoxy ; Position cursor
- pop hl
- ret
-
- ; Clear command prompt and print a language-dependent message.
-
- cprmpt2:
- call cprmpt ; Clear prompt and position cursor
- jp pstri ; Print message and return
-
- ; Clear command prompt and print a language-dependent message with yes/no
- ; suffix.
-
- cprmptyn:
- call cprmpt ; Clear prompt and position cursor
- jp pstriyn ; Print message with '(Y/N)' and return
-
- ; ERMSG - Error Message
-
- ermsg2:
- call eprmpt ; Clear error message line and position cursor
- jp pstri ; Print message
-
-
- ; WORKMSG - Working Message
-
- workmsg:
- ld hl,msg118 ; "Working ..."
- jp ermsg2
-
-
- ; ATCMD - Position at Command Prompt and Clear It
-
- atcmd:
- if datestamp
- push bc
- call btime ; Refresh time
- jr atcmd2
- endif
- atcmd1: ; No time
- push bc
- atcmd2:
- ld hl,cpadr ; Position cursor
- call gotoxy
- ld a,(cpecnt) ; Get # chars to erase.
- ld b,a ; In b.
- call ereol ; Clear message
- pop bc
- ret
-
- ; End of ZFSUBS4.Z80
-