; NTS Note Taker Screen ; Usage: NTS [dir:][file][.typ] ; If no file name, one is requested on exit. Blank name ; adds text to default file. ; Author: Rob Friefeld 4607 Colorado Sreet, Long Beach, CA 90814 ; Electronic mail: Ladera Znode ; Version: 1.1b 9/25/91 ; - File name prompt configurable. ; - Command line option to append without date separator. curvers equ '1' .request dslib,zslib,vlib,z3lib,syslib ; Stuff for editor is put in this I/O module for convenience ; public txtlns ; Contains lines to use for text public bufsz ; Editing buffer size (DW) public statline ; Puts cursor on a status line public rtmarg ; Contains right margin setting public loffset ; Contains lines to leave blank at top screen public insflg ; Insert/overwrite flag public print ; In line print, hi bit terminated ext edit ; System library routines ; ext $memry,zprsfn,fcbchk ext gz3init,getcrt,gotoxy,at,clreos,ereol ext caps,cout7 ext timini,rclock,mdat2,mtimc2 ; Standard Defs include sysdef.lib ; Standard equates RECS EQU FCB1+33 ; Direct access record DREADF EQU 33 ; Direct access read EOF EQU 1AH DEL EQU 7FH ; PROGRAM DEFS seplen equ 20 ; Length of note separator (not 0) sepchr equ '-' ; Note separator dslen equ 24 ; Date string length buffer equ 3000h ; Size of editing buffer ; ----------------- ; CODE START entry: jp start db 'Z3ENV' db 1 z3eadr: dw 0 ; Filled in by Z33 ds 2 ; reserved for type 3/4 ; ----------------- ; PATCH AREA cfgfn: db 'NTS11 ',0 ; CFG filename dfdr: db 0 ; Default drive (A=1...) dfusr: db 0ffh ; Default user (FF=current user) dfnam: db 'NOTES ' ; Default filename dfext: db 'NT ' ; Default fileext txtlns: db 8 ; Def text lines rtmarg: db 65 ; Def right margin insflg: db true ; T = Insert, F = Overwrite pflag: db true ; T = Prompt for "File: " on exit bufsz: dw buffer ; More text than this is truncated. ; ----------------- ; MAIN PROGRAM start: ld (stack),sp ld sp,stack ld hl,(fcb+1) ; Help? ld de,'//' or a sbc hl,de jp z,help ; ID message ld hl,(z3eadr) ld a,h or l jp z,notzcpr call GZ3INIT and 3 ; Check for CLREOS and INS/DEL cp 3 jp nz,notcap ; ; DEFINE TEXT BUFFER ; ld hl,($MEMRY) ; Start of text buffer ld de,128+seplen+2+dslen add hl,de ld (index),hl ; Input location for text ld (textloc),hl ld (hl),eof ; ; BANNER ; call GETCRT inc hl ld h,(hl) ; CRTLNS ld a,(txtlns) sub h neg ; CRTLNS - TXTLNS ld (loffset),a dec a ld h,a dec a ld (statln),a ; Message line # ld l,1 call GOTOXY ; Top of text area call CLREOS ; Clear screen from here xor a ld (dflag),a ; Init date flag ld hl,tbuf ; Check for command line option ld a,(hl) or a jr z,ban0 ; No command tail ld c,a ld b,0 inc hl ld a,'/' cpir jr nz,ban0 ; No option ld a,(hl) ld (dflag),a ; Save possible option cp 'D' ; No date? jr nz,ban0 ; Do date call crlf jr ban1 ban0: call date ; Read clock and load time to DATEBUF ld hl,datebuf call printhl ; Print time ban1: ld b,seplen ; Print ------------- ld a,sepchr call COUT7 djnz $-3 call crlf ; ; TEXT INPUT ; textin: ld hl,(index) call edit ; Screen editor jr z,exit ; Cancel call getname call setfcb call writefile exit: ld sp,(stack) ret ; ; GET A FILE NAME ; ; This section accepts a file name AFTER the note has been made. If ; PFLAG is false, uses installed name unless specified on command line. ; getname: call whlchk ; Wheel? jp z,resfcb ; Nonwheel, clear spec and return NOW getname1: ld a,(fcb+1) cp ' ' ; Command line name? jr z,getname2 ; No cp '/' jr z,getname2 ; No ld de,fcb call fcbchk ; Command line filespec valid? ret z ; Yes, use it. getname2: call resfcb ; No, remove it ld a,(pflag) ; Prompt for filename? or a ret z ; No, use installed defaults getname3: ; Input a file name call print dc bell,cr,'File: ' ld hl,tbuf ld (hl),50 ex de,hl ld c,rdbuff call bdos ld hl,tbuf+1 ; Capitalize string and terminate it ld a,(hl) inc hl push hl ; Save start of token or a jr z,gnam1b ; No input ld b,a gnam1A: ld a,(hl) call CAPS ld (hl),a inc hl djnz gnam1a gnam1b: ld (hl),0 pop hl ld de,fcb call ZPRSFN ; Parse token call FCBCHK ; OK? jr nz,getname3 ; Oops ret resfcb: ; Get rid of FCB spec. ld a,' ' ld (fcb+1),a ; Flag for SETFCB ld (fcb+9),a ld c,sguserf ; Reset user to current ld e,0ffh call bdos ld (fcb+13),a ret ; ; SET UP FCB ; Use default if DU:FILE.EXT not specified on command line ; setfcb: ld de,fcb+1 ; Target: FCB ld h,d ld l,e ld a,(de) ; Was name specified? cp ' ' jr nz,setfcb1 ; Yes, copy name to self, use input drive/user setfcb0: ld hl,dfnam ; No, use default name ld a,(dfdr) ; ..and default du: ld (fcb),a ld a,(dfusr) cp 0ffh ; ..and current jr z,setfcb1 ld (fcb+13),a ; ..or default (installed) user setfcb1: ld bc,8 ldir ; Copy name (specified or default) ld a,(de) cp ' ' ; Was .EXT specified? ret nz ; Yes ld hl,dfext ; No, use default ld bc,3 ldir ret ; ; WRITE THE OUTPUT FILE ; writefile: ld a,(fcb+13) ; Set the user code ld e,a ld c,sguserf call bdos call addfil ; Append file, if exists jr nz,wrtf1 ; Appending ld c,makef ; Make new file call bdosfcb ld hl,fcb+12 ; Zero control bytes ld b,24 ld (hl),0 inc hl djnz $-3 wrtf1: ld hl,($MEMRY) ; Write buffer to file wrtloop: push hl ex de,hl ld c,setdmaf call bdos ld c,writef call bdosfcb pop hl ld bc,128 ld a,eof cpir ; Compare each character with EOF jr nz,wrtloop ; And get next record ld c,closef ; Close file and exit thru bdos bdosfcb: ld de,fcb jp bdos ; APPEND ; If the file exists, read the last record. ; Move text down from textloc to end of last record (or start of buffer). ; Return Z = new file ; addfil: ld c,openf ; Open file call bdosfcb inc a jr z,addx ; No file addf1: ld c,compszf ; 0 length file? call bdosfcb ld hl,(recs) ; Record bytes = 0 ? ld a,h or l jr z,addx ; Yes, nothing to read dec hl ; Read last record ld (recs),hl ld de,($MEMRY) ld c,setdmaf call bdos ld c,dreadf call bdosfcb ld hl,($MEMRY) ; Find EOF ld a,eof dec hl addf2: inc hl cp (hl) jr nz,addf2 push hl pop de ; Get target address in DE also ld a,(dflag) ; Putting in separator? cp 'D' jr z,addf5 ; No ld b,seplen ; Since we are appending, insert separator. addf3: ld (hl),sepchr inc hl djnz addf3 call inscrlf ; Put crlf after it addf4: ex de,hl ; DE -> current buffer position ld hl,datebuf ; Return HL->date string ld a,(hl) or a jr z,addf5 ; No routine xor a ; Date string terminator addf4a: ldi ; Move string cp (hl) jr nz,addf4a addf5: ld hl,(textloc) ; Move text to output buffer ld bc,bufsz+0ffh ; Extra for a line of text ldir or -1 ret addx: ld hl,($MEMRY) call addf4 xor a ret ; ; SUPPORT ROUTINES ; toobig: call print dc 'Ovfl' buzzer: ld a,bell jp COUT7 inscrlf: ld (hl),cr ; CR,LF written into text buffer inc hl ld (hl),lf inc hl ret crlf: call print dc cr,lf ret ; In line print ; String terminated with 0 or hi bit set ; print: ex (sp),hl call printhl ex (sp),hl ret ; ; Print String pted to by HL ; printhl: ld a,(hl) ; Done? inc hl ; Pt to next or a ; 0 terminator ret z call COUT7 ; Print char ret m jr printhl whlchk: ; Test wheel byte ld hl,(z3eadr) ; HL --> Z3ENV ld de,29h add hl,de ; (HL) --> wheel byte ld e,(hl) inc hl ld d,(hl) ; DE --> wheel byte ld a,(de) or a ; Wheel? ret ; Return (Z) if not ; Public routine for editor - Put cursor on a status line somewhere ; statline: call at statln: db 1 ; (New location loaded at run time) db 1 jp EREOL ; Load up the date date: ld hl,datebuf push hl call TIMINI jr z,datex ld hl,clkbuf call RCLOCK jr nz,datex pop de ld hl,clkbuf call MDAT2 ld a,' ' ld (de),a inc de ld (de),a inc de call MTIMC2 ex de,hl call inscrlf push hl datex: pop hl ld (hl),0 ret ; ----------------- ; MESSAGES help: call print db 'NTS, Version 1.',curvers,' - Note Taker',cr,lf dc ' Syntax: NTS' call whlchk jr z,nwhelp call print db ' [dir:][file][.typ] [/d]',cr,lf db ' Text added to default file if none specified.',cr,lf db ' Option /d omits date from note.' db 0 nwhelp: call print db cr,lf db ' Command set is ZDE-like. ^KX,^KQ to exit.' dc cr,lf jp exit notzcpr: call print dc bell,'Need ZCPR 3.0+' jp exit notcap: call print dc bell,'XTCAP?' jp exit ; ----------------- ; DATA ; dseg textloc: ds 2 ; Start of input text loffset: ds 1 ; Free lines at top appfil: ds 1 ; Append flag dflag: ds 1 ; Date option index: ds 2 ; Pointer to output buffer clkbuf: ds 6 ; For clock read datebuf: ds 24 ; Enough room for time string ds 60 stack: ds 2 end ;END NT.Z80