; ; ZDB23.S - Subroutine Module ; ; Screen display routines ; frame: call curoff ; Turn off cursor call cls ; Clear screen call at ; Do standout header db 1,1 ld b,79 ; Do standout bar call pad call vprint ; Back up one and overwrite '<' dc bs,1,' ',2 call at db 2,1 call grxon call line call at db 22,1 call line call grxoff ; ld hl,panel ld b,(hl) ; Enter with hl=panel pointer inc hl ; scrnlp: call @goxy call vpstr djnz scrnlp ret ; refscr: call frame ; Refreshes entire screen call currec jp menu ; ; Display current record number and total ; currec: call savcurr ; Save current FPTR call disprec ; Display current record number and total ; ; Display current record ; displa: ld hl,pospanel ; Point to cursor position panel ld de,afpnl ; Point to field panel ld b,(hl) inc hl ; dsplalp:call @goxy ; Position cursor to field start push bc ; Save field count ld b,(hl) ; Get field length dec b ; Minus termination inc hl ; Point to next field call stndout ex de,hl ; Hl=field address push hl ; Save field address pointer call lhlhl ; Get field addr in hl call bpstr ; Display field call stndend pop hl pop bc ; Restore field count inc hl ; Point to next field inc hl ex de,hl djnz dsplalp ; newdat: call gxymsg ; Displays date db 3,64,1,0 ; Date location ld hl,datmod+1 ; Get month call paslsh inc hl ; Get day call paslsh dec hl dec hl ; Get year ld a,(hl) call pa2hc jp stndend ; divhl2: srl h ; Divide hl by 2, result in hl rr l ret ; curtim: call gxymsg ; Displays current date and time db 1,64,1,0 ld hl,today+1 call paslsh inc hl call paslsh dec hl dec hl ld a,(hl) call pa2hc call gettim jr nz,notime ld a,' ' call cout inc hl inc hl inc hl ; ; Format clock display correctly for 12 or 24 hour time ; ld a,(time) ; Get time flag or a ld a,(hl) ; Get bcd hour jr nz,condun ; 24hr, so we're done ; sub 12h jr z,noon ; Noon jr c,morn ; Morning ; daa ; Decimal adjust time to bcd jr condun ; morn: add a,12h jr nz,condun ; Not Midnight ; noon: add a,12h ; condun: ld b,a ; Save hour ld a,(time) or a ld a,b push af call nz,pa2hc ; Use leading 0 for military time pop af call z,pahc ; Else use leading space ld a,':' call cout inc hl ld a,(hl) call pa2hc ; notime: jp stndend ; gettim: call timini ; See if there is a clock jr nz,clkfnd inc a ret ; clkfnd: push hl ld hl,today ; Point to clock buffer call rclock pop hl ret ; paslsh: ld a,(hl) call pa2hc ; Print date with slash ld a,'/' jp cout ; ; Since the index may have been resorted and we only know the ; current fptr, we need to find the corresponding recptr to properly ; redisplay the current record at its new location in the index. ; getrp: call decfptr ; Back up one ; getrp0: ld hl,(first) ; Start of index ld de,14 ; Record number offset ; recplp: add hl,de ; Hl=recptr push hl ; Save recptr call lhlhl ; Hl=fptr for index record ld de,(fptr) ; De=fptr call comphd ; Does this record have the right fptr? pop hl ; Restore recptr ld de,16 ; Offset to next jr nz,recplp ; Not this index record, check next ; recc: ld (recptr),hl ; Save record pointer call disprec ; Update record display jr current ; Display record ; ; Write 256 bytes to random record ; rwrtblk:ld hl,edblk call rwrite ; Write new record ld hl,edblk1 jp rwrite ; ; Delete record ; delete: call clrmnu dc bel,1,'Are you sure? y/[N] ?',2,bs call getchar cp 'Y' jp nz,menu ; ld a,'D' ld (newflg),a call iniblk ; Fill current record w/ nulls ld hl,edblk ld (hl),on ; Make first byte 0ffh call decfptr ; Decrement file record ; wrecs: call rwrtblk ; Write 256 bytes to file ld hl,(recptr) ; Get record pointer ld de,14 sbc hl,de ; Back up to index pointer ex de,hl ; Pointer in de for movkey call movkey ; Update index key ld de,ssb call sort ; Sort index ; ld a,(newflg) ; Deleting a record? cp 'D' jr nz,getrp ; Exit from edit, so get record pointer ; call ckdel ; Quit if no non-deleted records call next jp menu ; ; File movement routines ; oknxt: call riread ; Increment pointers, read next record ; ckrec: call delrec ; Check for deleted record jp nz,currec ; Ok, display it, else fall thru ; ; Find and display next record ; next: call ckeoi ; Check for end of index jr nz,oknxt ; Not eoi ; firstr: call gotop ; Set pointer to beginning of file ; current:call rread ; Read current record jr ckrec ; ; Move to and display last record ; last: ld hl,(xrecptr) ; Get last index record pointer in hl call savptr jr current ; ; Move to and display previous record ; prev: call backup ; Move pointer back call rread ; Read a record ld hl,edblk ; Check first byte to see if it's a ld a,(hl) ; Valid record. 0ffh = deleted record. inc a jr z,prev ; If deleted, try the previous one jp currec ; ; Get first index record number ; gotop: ld hl,(first) ; Get start of index table ; getpt0: ld de,14 ; Offset to record number ; getptr: add hl,de ; savptr: ld (recptr),hl ; Save record pointer call lhlhl ld (fptr),hl ; Save record number ret ; ; Back up to previous record ; backup: ld hl,(recptr) ; Get current index record or a ; Clear carry ld de,16 ; Back up one index record sbc hl,de ; Get new record pointer ld de,(first) ; Check if past first call comphd jr nc,savptr ; Save pointers ; ld hl,(xrecptr) ; Point to last record pointer jr savptr ; Save pointers ; ; Read record, increment pointers ; rrinc: call rread jr mxrptr ; ; Increment record pointers ; mvrptr: call ckeoi ; Check for end of index table jr z,gotop ; Yes, start over ; mxrptr: ld hl,(recptr) ; Get index record pointer ld de,16 ; Point to next jr getptr ; ; Scans the entire record for a match ; find: ld b,11 ; Long key length for find call getkeyf ; Get search input ret z ; Quit if empty search string ; ld hl,rloop ; Set continue search routine address ld (stype),hl ; Save search type call savcurr ; Save current FPTR ; ; Check for end of file ; rloop: call ckeoi ; Check for end of index jr nz,okgo ; nofind: call clrmnu dc bel,1,'Not Found' call pak call cin ; rcurr: call rstcurr ; Restore current record jp getrp0 ; okgo: call mxrptr ; Point to next index entry call rread ld de,edblk ; DE points to target call scanbuf ; Scan buffer jr nz,rloop ; No match ; call savcurr ; Save current FPTR jp getrp ; ; Scan edblk buffer ; scanbuf:ld bc,253*256 ; B=length of target, 0=init count push bc ; Save buffer length ld de,edblk ; Point to buffer ld hl,srch-1 ; Hl=search string pointer ld c,(hl) ; Put length in C inc hl ; Point to search string call scan pop bc ret nz ; 1st string not found so quit ; ld hl,srch2-1 ; Point to second search string length byte ld a,(hl) ; Quit search if empty string or a ret z ; ld c,a ; Put length in C inc hl ; Point to second search string ld de,edblk ; Point to target ; ; Search routines. Uses a revised 'scanner' from syslib which eliminates ; case sensitivity. QFIND uses an index in RAM to find file pointers for ; last names or zip codes, depending on which index is selected. FIND ; runs through the file, top to bottom, to do its search. ; scan: ld a,b ; Done if b=Prev/Nxt P=PrintCurrent' call vpstr ; Display trailing message call qquit ; And fall thru to get input ; getchar:call curon ; Get keyboard input at prompt/message call capin push af call curoff pop af ret ; line: ld b,79 ; Draw graphics line ld a,(@ghl) ; linlp: call cout djnz linlp ret ; ; Display current record number and total ; disprec:ld hl,(recptr) call lhlhl ; Get record number of current record call divhl2 ; Divide by 2 inc hl ; Make it rel 1 ; currec0:call gxymsg db 1,45,1,0 call phldc call vprint dc ' of ' ld hl,(recs) ; Get total number of records call divhl2 ; Divide by 2 call phlfdc call vprint ; Terminate field and end standout dc ' ',2 ret ; noclk: call vprint db bel,'Can''t find clock!',cr,lf,lf db 'Enter today''s date:',cr,lf dc ' Month (MM): ' ld de,today+1 ; Point to month call getdat call vprint dc cr,lf,' Day (DD): ' inc de ; Point to day call getdat call vprint dc cr,lf,' Year (YY): ' dec de ; Point to year dec de ; getdat: ld hl,datbuf ld b,2 ; getdat0:call cin cp 3 jp z,exit2 call cout ld (hl),a inc hl djnz getdat0 ld (hl),0 dec hl dec hl push de call eval10 pop de call binbcd ld (de),a ret ; ; Common quit message ; qquit: call vprint dc ' Q=Quit ?',bs,2 ret ; ; Common press any key message ; pak: call vprint dc ' - Press Any Key',2,bel ret ; ; Get contents of hl in hl ; lhlhl: ld a,(hl) ; Get record number inc hl ld h,(hl) ld l,a ret ; ; Check for current return address record and invalid addresses. ; To be valid, an address must have a city entry, at least one ; address entry and must not be the current return address record ; or a deleted record. ; ; Entry:None ; Exit: Z if record is invalid and to be skipped ; valid: ld a,(city) or a ret z ; Invalid if no city ; ld a,(addr1) ; Check address 1 or a jr nz,valid0 ; Yes, check return address ; ld a,(addr2) ; Check address 2 or a ret z ; Invalid if no address ; valid0: ld hl,(ofptr) ; Get last file record pointer ld de,(rafptr) ; Get return address record pointer call comphd ret z ; Skip return address record ; ; Check to see if record is deleted ; delrec: ld hl,edblk ld a,(hl) inc a ret ; ; Check for end of index ; ckeoi: ld de,(recptr) ; Get current index record pointer ld hl,(xrecptr) ; Get last index record pointer jr comphd ; ; Check for end of file ; ckeof: ld hl,(recs) ; Get number of records ld de,(fptr) ; Get current record number jr comphd ; ; Check available memory ; chkmem: ld hl,(order) ; Get address of order table ld de,(recs) ; Get number of records add hl,de ; Add to addr of order table inc h ; Start buffer at next page boundary ld l,0 ld (bufadr),hl ; Save as address of file buffer ex de,hl call gzmtop ; Get top of TPA (hl=1st byte of CCP) dec h ; Safety zone of 256 bytes ; ; Compare HL with DE, set flags ; ; Exit: DE>HL C,NZ ; DE=HL NC,Z ; DE