Z3ANDR Z80 #p!Z3APPCL Z800Z3CLRCL Z80@(Z3DIRTDUZ80F?Z3DUTDIRZ80Z OZ3GCL1 Z80cxZ3GCL2 Z80k -Z3GCRT Z80tZ3GDUOK Z80{Z3GEFCB Z80Z3GENV Z80`FZ3GFCP Z80|Z3GFN1 Z80@Z3GFN2 Z80zZ3GFNX Z80yZ3GIOP Z80T&Z3GIOX Z80dZ3GMDISKZ80ZZ3GMSG Z80+"Z3GMUSERZ80}Z3GNDR Z80]Z3GPATH Z80ќZ3GPRT Z80Z3GQUIETZ80;Z3GRCP Z80Z3GSH Z80 0Z3GSPEEDZ80Z3GVID Z80Z3GWHL Z80Z3GZFC Z80idZ3GZNC Z80GZ3GZR Z80Z3HDR Z80 ~Z3HZEX Z80CPZ3IF Z80Z3IFELSEZ80$mZ3IFEND Z80,WZ3IFTESTZ8012KZ3INI Z807RZ3IOMA Z80;ZZ3IOR Z80KZ3LOG Z80Y Z3LVER Z80bs ; ; Z3LIB Module Name: Z3ANDR ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public addndr ext envptr,getndr,retud,caps ; ; Constants ; npsize equ 8 ;number of chars in name/password entsize equ 18 ;number of bytes in entry ; ; ADDNDR adds a directory name to the named directory buffer, if ; possible. HL pts to a Z3 FCB (disk at offset 0, user at offset 13, ; current disk = 0) containing the name, and DE pts to an 8-char password. ; Both the name and password are 8 chars, and space fill. ; ; On input, ; A = 0 if no password (space fill password) ; A <> 0 if get password from DE ; HL = address of FCB ; DE = address of password (A <> 0) ; On output, A = 0 and Z if error (no NDR or NDR full) ; addndr: push bc ;save regs push de push hl ld (passfl),a ;save password flag ld (dname),hl ;save ptr to dir name ex de,hl ld (dpass),hl ;save ptr to dir password call getndr ;get ptr to named directory buffer jp z,pndrex ; ; Compute possible number of entries in directory ; 7 * (number of 128-byte records) ; ld b,7 ;count number of dir entries ld c,a ;number of records in A xor a ;zero accumulated value addn1: add a,b ;add increment dec c ;count down jp nz,addn1 ld c,a ;max number of entries in C ; ; Look for free entry (every 18 bytes) ; ld de,entsize addn2: ld a,(hl) ;look for free entry or a ;got one? jp z,addn3 add hl,de ;pt to next dec c ;count down jp nz,addn2 ; ; Error exit ; pndrex: xor a ;error pop hl ;restore regs pop de pop bc ret ; ; Space available ; HL pts to empty entry ; addn3: ex de,hl ;destination in DE ld hl,(dname) ;get ptr to dir name ; ; Store disk number (1..) ; ld a,(hl) ;get disk or a ;current disk? jp nz,addn4 call retud ;get DU in BC inc b ;disk A = 1 ld a,b ;disk in A addn4: ld (de),a ;store disk letter inc de ;pt to user number ; ; Store user number ; push de ;save ptr push hl ;save ptr to disk name ld de,13 ;offset to user number add hl,de ld a,(hl) ;get user number pop hl ;get ptr to disk name pop de ;get ptr to user number ld (de),a ;save user number inc de ;pt to name inc hl ;pt to name ; ; Copy disk name ; call move8 ;copy name and capitalize ; ; Space fill password and then set it if instructed ; push de ;save ptr to password ld b,npsize ;fill password with spaces ld a,' ' ;get space addn5: ld (de),a ;store space inc de ;next dec b jp nz,addn5 xor a ;make next entry empty ld (de),a pop de ;get ptr to password ld a,(passfl) ;set password? or a ;0=no jp z,addn6 ld hl,(dpass) ;pt to password call move8 ;copy password and capitalize ; ; Sort directory and then exit ; addn6: call getndr ;pt to named directory buffer ; ; Sort so entry pted to by HL is lowest ; addn7: ld a,(hl) ;end of dir? or a ;0=yes jp z,addone ld de,entsize ;pt to next entry ex de,hl add hl,de ex de,hl ;HL pts to target, DE pts to next call sort ;do the sort ld de,entsize ;pt to next entry add hl,de jp addn7 ; ; Sort dir entries so target pted to by HL is less than rest, pted to by DE ; sort: push hl ;save HL,DE push de sort0: ld a,(de) ;done? or a jp z,sortdn sort1: ld a,(de) ;get new ld b,a ;save in B ld a,(hl) ;test target cp b ;must be less or equal jp c,sortnxt jp nz,sortsw ;switch inc hl ;check user inc de ld a,(de) ;get new user ld b,a ld a,(hl) dec de ;pt back dec hl cp b jp c,sortnxt jp z,sortnxt sortsw: push hl ;save regs push de ld b,entsize ssw: ld c,(hl) ;get one ld a,(de) ;get another ld (hl),a ;put one ld a,c ld (de),a ;put another inc hl ;pt to next inc de dec b ;count down jp nz,ssw pop de ;get regs pop hl sortnxt: ex de,hl ;increment DE to next ld bc,entsize add hl,bc ex de,hl jp sort0 ;continue sort sortdn: pop de ;get regs and exit pop hl ret ; ; Exit with success ; addone: pop hl ;restore regs pop de pop bc or 0ffh ;set NZ for OK ret ; ; Copy 8 bytes from HL to DE and capitalize ; move8: ld b,npsize move8l: ld a,(hl) ;get call caps ;capitalize ld (de),a ;put inc hl ;next inc de dec b jp nz,move8l ret ; ; Data ; passfl: ds 1 ;password flag dname: ds 2 ;ptr to name dpass: ds 2 ;ptr to password end ; ; Z3LIB Module Name: Z3APPCL ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public appcl ext getcl1,getcl2 ; ; Macros ; putrg macro push bc push de push hl endm getrg macro pop hl pop de pop bc endm ; ; APPCL stores a command line in the ZCPR3 command line buffer. ; This command line is pted to by HL. On return, A=0 and Zero Flag Set ; if command line overflow is possible (no change to command line). ; appcl: putrg ;save registers push hl ;save ptr to new line call getcl1 ;is command line available? jp nz,pcl0 ; ; Error Return ; nocl: pop hl ;get ptr to new line getrg ;restore registers xor a ;ret Z ret ; ; Pack old command line ; pcl0: ld b,a ;count of chars in B push hl call getcl2 ;get address of new first command ld (oldcmd),hl ;save position pop hl ld de,4 ;pt to first char in buffer ex de,hl add hl,de ex de,hl ld (hl),e ;store address inc hl ld (hl),d ;DE pts to first char of buffer ld hl,(oldcmd) ;get address of first char of remaining CL ; ; Copy Old Command Line into Front of Buffer ; pcl1: ld a,(hl) ;copy ld (de),a inc hl inc de dec b ;count down or a ;EOL? jp nz,pcl1 inc b ;B = number of bytes left in buffer pop hl ;HL = address of first char of new command line ; ; HL pts to first char of new command line ; DE pts to after ending 0 of old command line ; B = number of chars remaining before overflow of Z3 command line ; push de ;save ptr on stack pcl2: ld a,(hl) ;get next char ld (de),a ;put next char dec b ;count down remaining chars jp z,nocl ;overflow if reached zero inc hl ;pt to next inc de or a ;EOL? jp nz,pcl2 pop hl ;get ptr to first char of new line dec hl ;pt to ending 0 of old line ld (hl),';' ;store semicolon separator getrg or 0ffh ;no error ret ; ; Data ; oldcmd: ds 2 ;pointer to old command line in CL buffer end ; ; Z3LIB Module Name: Z3CLRCL ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public clrcl ext envptr ; ; CLRCL clears the ZCPR3 command line, setting it to empty. ; On exit, A=0 and Zero Flag Set if no CL ; clrcl: push hl ;save regs push de ld hl,(envptr) ;pt to environment ld de,18h ;pt to entry add hl,de ld e,(hl) ;get address in DE inc hl ld d,(hl) ld a,d ;check for no buffer or e jp z,clrcl1 ld a,(de) ;get low address of next char ld l,a inc de ld a,(de) ;get high address of next char ld h,a ld (hl),0 ;store 0 for no line or 0ffh ;set NZ for OK clrcl1: pop de ;get regs pop hl ret end ; ; Z3LIB Module Name: Z3DIRTDU ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public dirtdu ext getndr,caps ; ; DIRTDU searches for the DIR named pted to by HL. If found, ; BC = DU (disk A = 0) and NZ. If not found, A=0 and Zero Flag Set. ; HL pts to delimiter at end of name. ; dirtdu: push de ;save DE ; ; Save DIR Name in Buffer ; ld de,dirbuf ;pt to buffer ld b,8 ;8 chars max dd1: ld a,(hl) ;get char call delchk ;check for delimiter jp z,dd3 ld (de),a ;store char inc hl ;pt to next inc de dec b ;count down jp nz,dd1 ; ; Name longer than 8 chars - skip to delimiter ; dd2: ld a,(hl) ;skip to delimiter inc hl ;pt to next call delchk ;check for delimiter jp nz,dd2 dec hl ;pt to delimiter jp dd4 ; ; Name shorter than 8 chars - space fill ; dd3: ld a,' ' ;space fill ld (de),a ;store space inc de ;pt to next dec b ;count down jp nz,dd3 ; ; HL pts to delimiter, buffer contains name ; dd4: push hl ;save ptr to delimiter ld de,dirbuf ;pt to directory name buffer call getndr ;pt to named dir jp nz,dd5 ; ; Directory Not Found ; dirnf: pop hl ;restore ptr to delimiter pop de ;restore DE xor a ;return with flag set ret ; ; Scan for Directory Name ; dd5: ld a,(hl) ;end of dir? or a jp z,dirnf ;not found if so push hl ;save ptr to current entry push de ;save ptr to target name inc hl ;pt to name inc hl ld b,8 ;8 chars dd6: ld a,(de) ;get target name cp (hl) ;compare jp nz,dd7 inc hl ;pt to next inc de dec b ;count down jp nz,dd6 ; ; DIR Names Match ; pop de ;restore ptrs pop hl ld b,(hl) ;get disk number dec b ;disk A = 0 inc hl ;get user number ld c,(hl) ;... in C pop hl ;restore ptr to delimiter pop de ;restore DE xor a ;return NZ for OK dec a ret ; ; Advance to Next DIR Entry ; dd7: pop de ;restore ptrs pop hl ld bc,18 ;pt to next entry add hl,bc jp dd5 ;resume search ; ; Check for Delimiter in A ; delchk: call caps ;capitalize char cp '0' ;numeric? jp c,del1 cp '9'+1 jp c,del2 cp 'A' ;alphabetic? jp c,del1 cp 'Z'+1 jp c,del2 ; ; Is a delimiter ; del1: push bc ld b,a ;save char xor a ;set Zero ld a,b pop bc ret ; ; Is not a delimiter ; del2: push bc ld b,a ;save char xor a ;set NZ dec a ld a,b pop bc ret ; ; Buffers ; dirbuf: ds 8 ;8 chars for name end ; ; Z3LIB Module Name: Z3DUTDIR ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public dutdir ext getndr ; ; DUTDIR searches the memory-based named directory for the DU ; given in BC (B=disk, disk A = 0, C=user). DUTDIR returns a pointer ; in HL to the 8-char disk name. If not found, A=0 and Zero Flag Set. ; dutdir: inc b ;disk A = 1 call getndr ;set HL to point to named directory jp nz,dd1 ; ; Directory Not Found ; dirnf: dec b ;restore registers xor a ;error - no named dir ret ; ; Search Loop ; dd1: ld a,(hl) ;check for end or a ;0 if end jp z,dirnf cp b ;check disk jp nz,dd2 ;skip to next if no match inc hl ;pt to user ld a,(hl) ;get user dec hl ;pt back cp c ;check user jp nz,dd2 ;skip to next if no match ; ; Directory Name Found ; inc hl ;pt to name inc hl dec b ;restore registers xor a ;return NZ for OK dec a ret ; ; Skip to Next Entry ; dd2: push bc ;save BC ld bc,18 ;pt to next entry add hl,bc pop bc ;restore BC jp dd1 end ; ; Z3LIB Module Name: Z3GCL1 ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getcl1 ext envptr ; ; GETCL1 returns the address of the command line buffer in HL and ; the size of the buffer in bytes in A. No other registers are affected. ; Note: The command line buffer is structured as follows: ; ; cmdline: ; dw
; db ; db ; db ; db 0 ; ; GETCL1 returns the address of CMDLINE in HL and the size (at CMDLINE+2) ; in A. ; getcl1: push de ;save DE ld hl,(envptr) ;pt to environment ld de,18h ;pt to entry add hl,de ld e,(hl) ;get address in DE inc hl ld d,(hl) push de ;save address in DE inc de ;pt to size as in buffer inc de ld a,(de) ;get size in A or a ;return with Zero Set if None pop hl ;get ptr to command line buffer pop de ;restore DE ret end ; ; Z3LIB Module Name: Z3GCL2 ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getcl2 ext envptr ; ; GETCL2 returns the address of the next command in the command line ; buffer in HL and the character at this address in A with the Zero Flag Set ; (Z) if there is no further characters in the line. Only HL and PSW are ; affected. Note: The command line buffer is structured as follows: ; ; cmdline: ; dw
; db ; db ; db ; db 0 ; ; GETCL2 returns the address in the first DW at the label CMDLINE in HL ; and the character at that address in A. ; getcl2: push de ;save DE ld hl,(envptr) ;pt to environment ld de,18h ;pt to entry add hl,de ld a,(hl) ;get address in DE inc hl ld h,(hl) ld l,a ;address in HL ld a,(hl) ;get address of first char in DE inc hl ld h,(hl) ld l,a ;HL pts to first char ld a,(hl) ;get first char in A or a ;set Zero Flag if no more chars pop de ;restore DE ret end ; ; Z3LIB Module Name: Z3GCRT ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getcrt ext envptr ; ; GETCRT returns the address of the CRT data record in HL. This ; record is structured as follows: ; ; db ; db ; db ; ; HL only is affected. ; getcrt: push af push de ld hl,(envptr) ;pt to environment ld de,2fh ;pt to selection byte add hl,de ld b,(hl) ;get selection byte inc hl ;pt to first CRT byte inc hl ld a,b ;multiply by 3 for record size add a,a ;*2 add a,b ;*3 ld e,a ;DE=offset ld d,0 add hl,de ;HL pts to byte pop de ;restore regs pop af ret end ; ; Z3LIB Module Name: Z3GDUOK ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getduok ext envptr ; ; GETDUOK returns the DU OK byte in A. Zero Flag is set ; accordingly. A=0 and Z if DU not OK. Only PSW is affected. ; getduok: push hl push de ld hl,(envptr) ;pt to environment ld de,2eh ;pt to byte address add hl,de ld a,(hl) ;get byte in A pop de ;restore regs pop hl or a ;set flag ret end ; ; Z3LIB Module Name: Z3GEFCB ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getefcb ext envptr ; ; GETEFCB returns the address of the ZCPR3 external FCB in HL. ; Return with Zero Flag Set (Z) if no external FCB. PSW and HL are affected. ; getefcb: push de ld hl,(envptr) ;get it ld de,24h ;offset add hl,de ld a,(hl) ;get address in HL inc hl ld h,(hl) ld l,a pop de ld a,h ;check for existence or l ret end ; ; Z3LIB Module Name: Z3GENV ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getenv ext envptr ; ; GETENV returns the address of the ZCPR3 environment buffer in HL. ; No other registers are affected. ; getenv: ld hl,(envptr) ;get it ret end ; ; Z3LIB Module Name: Z3GFCP ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getfcp ext envptr ; ; GETFCP returns the address of the flow command package in HL and ; the size of the package in terms of 128-byte blocks in A. If there is ; no FCP buffer, A=0 and Zero Flag Set (Z). No other registers are affected. ; getfcp: push de ;save DE ld hl,(envptr) ;pt to environment ld de,12h ;pt to entry add hl,de ld e,(hl) ;get address in DE inc hl ld d,(hl) inc hl ld a,(hl) ;get size in A ex de,hl ;HL contains address pop de ;restore DE or a ;set flag ret end ; ; Z3LIB Module Name: Z3GFN1 ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getfn1 ext envptr ; ; GETFN1 returns the address of the first filename.typ entry in HL. ; HL only is affected. ; getfn1: push af push de ld hl,(envptr) ;pt to environment ld de,47h ;pt to file name entry add hl,de pop de ;restore regs pop af ret end ; ; Z3LIB Module Name: Z3GFN2 ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getfn2 ext envptr ; ; GETFN2 returns the address of the second filename.typ entry in HL. ; HL only is affected. ; getfn2: push af push de ld hl,(envptr) ;pt to environment ld de,52h ;pt to file name entry add hl,de pop de ;restore regs pop af ret end ; ; Z3LIB Module Name: Z3GFNX ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getfnx ext envptr ; ; GETFNX returns the address of the nth filename.typ entry in HL. ; HL only is affected. On input, A = 1 to 4 to identify the desired file. ; getfnx: dec a ;check range cp 4 ;0 to 3 is valid jp nc,error inc a ;set offset to 1-4 again push de push af ;save A ld hl,(envptr) ;pt to environment ld de,52h ;pt to file name entry add hl,de ld de,11 ;offset to next name pop af ;get A gfnx1: dec a ;count down jp z,gfnx2 add hl,de ;pt to next jp gfnx1 gfnx2: pop de ;restore regs or 0ffh ;set NZ for OK ret error: xor a ;error ret end ; ; Z3LIB Module Name: Z3GIOP ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getiop ext envptr ; ; GETIOP returns the address of the input/output package in HL and ; the size of the package in terms of 128-byte blocks in A. If there is ; no IOP buffer, A=0 and Zero Flag Set (Z). No other registers are affected. ; getiop: push de ;save DE ld hl,(envptr) ;pt to environment ld de,0fh ;pt to entry add hl,de ld e,(hl) ;get address in DE inc hl ld d,(hl) inc hl ld a,(hl) ;get size in A ex de,hl ;HL contains address pop de ;restore DE or a ;set flag ret end ; ; Z3LIB Module Name: Z3GIOX (general IOP support) ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public putiod,getion,getios ext envptr,getiop ; ; PUTIOD selects the device indicated by logical id in B and physical ; selection in C. B is the number of the logical device, where CON: = 0, ; RDR: = 1, PUN: = 2, and LST: = 3. Return with A=0 and Zero Flag Set if ; error. ; ; Only PSW is affected. ; putiod: push hl ; save regs push de push bc call getioc ; get IOP address and check jp z,iodret ld de,iodret ; set return address push de ; ... on stack inc hl ; pt to routine inc hl inc hl jp (hl) ; "call" SELECT routine iodret: pop bc ; restore regs pop de pop hl ret ; error flags set by NAMER in IOP ; ; GETION returns a pointer to the string describing the device ; whose logical number is in B and physical selection in C. This pointer ; is in HL. If no error, return with HL pointing to the string (terminated ; by a null) and A=0FFH with NZ. If error (such as no IOP), A=0 and Z ; on return. ; getion: call getioc ; get IOP address and check ret z push de ; save regs push bc ld de,ionret ; set return address push de ; ... on stack ld de,6 ; pt to routine add hl,de jp (hl) ; "call" NAMER routine ionret: pop bc ; restore regs pop de ret ; error flags set by NAMER in IOP ; ; GETIOS returns a pointer to the I/O Package status table ; in HL. This table is structured as follows: ; ; Number of Current ; Bytes Device Devices Assignment ; ----- ------ --------- ---------- ; 0-1 CON: Byte 0 Byte 1 ; 2-3 RDR: Byte 2 Byte 3 ; 4-5 PUN: Byte 4 Byte 5 ; 6-7 LST: Byte 6 Byte 7 ; ; GETIOS returns A=0 and Zero Flag Set if no IOP loaded. ; If loaded, A=0FFH and NZ and HL = address of table ; getios: call getioc ; check for I/O ret z jp (hl) ; run routine ; ; Return the address of the IOP in HL if exists and is loaded; return ; A=0 and Z if error, A<>0 and NZ if OK ; getioc: call getiop ; get I/O Package address ret z ld a,(hl) ; check for loaded I/O Package or a ret z ld a,0ffh ; OK ret end ; ; Z3LIB Module Name: Z3GMDISK ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getmdisk ext envptr ; ; GETMDISK returns the maximum disk in A (disk A = 1). Zero Flag is set ; accordingly. Only PSW is affected. ; getmdisk: push hl push de ld hl,(envptr) ;pt to environment ld de,2ch ;pt to byte address add hl,de ld a,(hl) ;get byte in A pop de ;restore regs pop hl or a ;set flag ret end ; ; Z3LIB Module Name: Z3GMSG ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getmsg ext envptr ; ; GETMSG returns the address of the ZCPR3 message buffer in HL. ; A=0 and Zero Flag Set (Z) if there is no ZCPR3 message buffer. ; getmsg: push de ;save DE ld hl,(envptr) ;pt to environment ld de,22h ;pt to entry add hl,de ld a,(hl) ;get address in HL inc hl ld h,(hl) ld l,a or h ;set Z flag if HL=0 pop de ;restore DE ret end ; ; Z3LIB Module Name: Z3GMUSER ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getmuser ext envptr ; ; GETMUSER returns the maximum user in A. Zero Flag is set ; accordingly. Only PSW is affected. ; getmuser: push hl push de ld hl,(envptr) ;pt to environment ld de,2dh ;pt to byte address add hl,de ld a,(hl) ;get byte in A pop de ;restore regs pop hl or a ;set flag ret end ; ; Z3LIB Module Name: Z3GNDR ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getndr ext envptr ; ; GETNDR returns the address of the named directory buffer in HL and ; the maximum number of entries in A. If there is no NDR buffer, A=0 ; and Zero Flag Set (Z). No other registers are affected. ; getndr: push de ;save DE ld hl,(envptr) ;pt to environment ld de,15h ;pt to entry add hl,de ld e,(hl) ;get address in DE inc hl ld d,(hl) inc hl ld a,(hl) ;get size in A ex de,hl ;HL contains address pop de ;restore DE or a ;set flag ret end ; ; Z3LIB Module Name: Z3GPATH ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getpath ext envptr ; ; GETPATH returns the address of the external path in HL and the ; maximum number of elements in said path in A. If there is no external path, ; A=0 and Zero Flag Set. No other registers are affected. ; getpath: push de ;save DE ld hl,(envptr) ;pt to environment ld de,9 ;pt to path entry add hl,de ld e,(hl) ;get path address in DE inc hl ld d,(hl) inc hl ld a,(hl) ;get path size in A ex de,hl ;HL pts to path pop de ;restore DE or a ;set flag ret end ; ; Z3LIB Module Name: Z3GPRT ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getprt ext envptr ; ; GETPRT returns the address of the Printer data record in HL. This ; record is structured as follows: ; ; db ; db ; db ; db
; ; HL only is affected. ; getprt: push af push de ld hl,(envptr) ;pt to environment ld de,30h ;pt to selection byte add hl,de ld a,(hl) ;get selection byte inc hl ;pt to first CRT ld de,6 ;pt to first printer add hl,de add a,a ;*2 (multiply by 4 to pt to selected printer) add a,a ;*4 ld e,a ;DE=offset ld d,0 add hl,de ;HL pts to byte pop de ;restore regs pop af ret end ; ; Z3LIB Module Name: Z3GQUIET ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getquiet ext envptr ; ; GETQUIET returns the quiet byte in A. Zero Flag is set accordingly. ; Only PSW is affected. ; getquiet: push hl push de ld hl,(envptr) ;pt to environment ld de,28h ;pt to byte address add hl,de ld a,(hl) ;get byte in A pop de ;restore regs pop hl or a ;set flag ret end ; ; Z3LIB Module Name: Z3GRCP ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getrcp ext envptr ; ; GETRCP returns the address of the resident command package in HL and ; the size of the package in terms of 128-byte blocks in A. If there is ; no RCP buffer, A=0 and Zero Flag Set. No other registers are affected. ; getrcp: push de ;save DE ld hl,(envptr) ;pt to environment ld de,0ch ;pt to entry add hl,de ld e,(hl) ;get address in DE inc hl ld d,(hl) inc hl ld a,(hl) ;get size in A ex de,hl ;HL contains address pop de ;restore DE or a ;set flag ret end ; ; Z3LIB Module Name: Z3GSH ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getsh,getsh1,getsh2 ext envptr ; ; GETSH2 returns the address of the shell stack in HL, the size of each ; shell stack entry in DE, and the number of entries possible in the shell ; stack in A and B (same value in each register). A=0 and Zero Flag Set (Z) ; if there is no shell stack. ; getsh2: call getsh1 ;get data in a different form ld e,b ;DE=size of entry ld d,0 ld b,a ;B=A=number of entries ret ;Zero Flag has already been set ; ; GETSH1 returns the address of the shell stack in HL, the size of each ; shell stack entry in B, and the number of entries possible in the shell ; stack in A. A=0 and Zero Flag Set (Z) if there is no shell stack. ; No other registers are affected. ; getsh: getsh1: push de ;save DE ld hl,(envptr) ;pt to environment ld de,1eh ;pt to entry add hl,de ld e,(hl) ;get address in DE inc hl ld d,(hl) inc hl ld a,(hl) ;get number of entries in A inc hl ld b,(hl) ;get size of entry in B ex de,hl ;HL contains address pop de ;restore DE or a ;set flag ret end ; ; Z3LIB Module Name: Z3GSPEED ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getspeed ext envptr ; ; GETSPEED returns the processor speed in A. Zero Flag is set ; accordingly. Only PSW is affected. ; getspeed: push hl push de ld hl,(envptr) ;pt to environment ld de,2bh ;pt to byte address add hl,de ld a,(hl) ;get byte in A pop de ;restore regs pop hl or a ;set flag ret end ; ; Z3LIB Module Name: Z3GVID ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getvid ext envptr ; ; GETVID returns the address of the ZCPR3 TCAP buffer in HL. ; A=0 and Zero Flag Set (Z) if no Z3TCAP entry present. ; getvid: push de ;save DE ld hl,(envptr) ;get it ld de,80h ;pt to Z3TCAP add hl,de pop de ;restore DE ld a,(hl) ;get first char cp ' '+1 ;test for entry present jp c,noentry xor a ;return NZ dec a ret noentry: xor a ;return Z ret end ; ; Z3LIB Module Name: Z3GWHL ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getwhl ext envptr ; ; GETWHL returns the wheel byte in A. Zero Flag is set accordingly. ; Only PSW is affected. ; getwhl: push hl push de ld hl,(envptr) ;pt to environment ld de,29h ;pt to wheel byte address add hl,de ld a,(hl) ;get address in HL inc hl ld h,(hl) ld l,a ld a,(hl) ;get wheel byte in A pop de ;restore regs pop hl or a ;set flag ret end ; ; Z3LIB Module Name: Z3GZFC ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getzfc ext getenv ; ; GETZFC returns the address in HL of the first character in the ZEX ; buffer. Carry Flag is Set if data not available. A contains ; the character. ; getzfc: push hl call getenv ;pt to environment ld a,h ;any environment? or l jp z,error push de ;pt to message byte ld de,34 ;offset to message ptr add hl,de ld e,(hl) ;get address of messages inc hl ld d,(hl) ex de,hl ;HL pts to message pop de ld a,h ;any messages? or l jp z,error push de ;pt to Zex First Char ld de,11 add hl,de ld e,(hl) ;get address inc hl ld d,(hl) ex de,hl pop de pop af ;clear stack ld a,(hl) ;get next char or a ;set Z and Clear Carry ret error: pop hl ;restore HL scf ;set carry ret end ; ; Z3LIB Module Name: Z3GZNC ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getznc ext getenv ; ; GETZNC returns the address in HL of the next character which ; ZEX will return. Carry Flag is Set if data not available. A contains ; the character. ; getznc: push hl call getenv ;pt to environment ld a,h ;any environment? or l jp z,error push de ;pt to message byte ld de,34 ;offset to message ptr add hl,de ld e,(hl) ;get address of messages inc hl ld d,(hl) ex de,hl ;HL pts to message pop de ld a,h ;any messages? or l jp z,error push de ;pt to Zex Next Char Address ld de,9 add hl,de ld e,(hl) ;get address inc hl ld d,(hl) ex de,hl pop de pop af ;clear stack ld a,(hl) ;get next char or a ;set Z and Clear Carry ret error: pop hl ;restore HL scf ;set carry ret end ; ; Z3LIB Module Name: Z3GZR ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public getzrun ext getenv ; ; GETZRUN returns the ZEX run message byte in A. Zero Flag ; is Set accordingly. Carry Flag is Set if no such message available. ; getzrun: push hl call getenv ;pt to environment ld a,h ;any environment? or l jp z,error push de ;pt to message byte ld de,34 ;offset to message ptr add hl,de ld e,(hl) ;get address of messages inc hl ld d,(hl) ex de,hl ;HL pts to message pop de ld a,h ;any messages? or l jp z,error push de ;pt to Zex Running Flag ld de,8 add hl,de pop de ld a,(hl) ;get byte or a ;set Z and Clear Carry pop hl ;restore HL ret error: pop hl ;restore HL scf ;set carry ret end ; ; Environment Definition ; if z3env ne 0 ; ; External ZCPR3 Environment Descriptor ; jp start db 'Z3ENV' ;This is a ZCPR3 Utility db 1 ;External Environment Descriptor z3eadr: dw z3env start: ld hl,(z3eadr) ;pt to ZCPR3 environment ; else ; ; Internal ZCPR3 Environment Descriptor ; MACLIB Z3BASE.LIB MACLIB SYSENV.LIB z3eadr: jp start SYSENV start: ld hl,z3eadr ;pt to ZCPR3 environment endif ; ; Start of Program -- Initialize ZCPR3 Environment ; call z3init ;initialize the ZCPR3 Env and the VLIB Env ; ; Z3LIB Module Name: Z3HZEX ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public haltzex ext getzrun,strtzex,getznc ; ; HALTZEX terminates execution of the ZEX processor. STOPZEX ; simply suspends execution of ZEX, while HALTZEX causes ZEX to terminate ; completely. A=0 and Zero Flag Set if ZEX not running. ; haltzex: push hl ;save HL call getzrun ;ZEX running? pop hl ret z push hl call strtzex ;resume ZEX execution if stopped call getznc ;get ptr to next char for ZEX to return ld (hl),0ffh ;set stop flag pop hl ;get HL or 0ffh ;set OK ret end ; ; Z3LIB Module Name: Z3IF ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public ift,iff ext getmsg ; ; IFT turns on the next level of IF and sets it TRUE. Return ; with A=0 and Zero Flag Set (Z) if IF level overflow. ; ift: push bc ;save BC ld b,0ffh ;turn on call ifset pop bc ret ; ; IFF turns on the next level of IF and sets it FALSE. Return ; with A=0 and Zero Flag Set (Z) if IF level overflow. ; iff: push bc ;save BC ld b,0 ;turn off call ifset pop bc ret ; ; Turn on next IF level ; B register is 0 if level is inactive, 0FFH is level is active ; Return with Z flag set if IF overflow ; ifset: push hl ;save regs push de push bc call getmsg ;pt to messages inc hl ;pt to IF byte ld a,(hl) ;get IF byte or a ;if no IF at all, start 1st one jp z,ifset1 cp 80h ;check for overflow (8 IFs max) jp z,iferr inc hl ;pt to active IF and (hl) ;check to see if current IF is TRUE jp nz,ifset0 ;continue if so ld b,a ;B=0 to set next IF to FALSE ifset0: dec hl ;pt to IF level ld a,(hl) ;get it rlca ;advance to next level and 0feh ;only 1 bit on ld (hl),a ;set IF byte jp ifset2 ifset1: inc a ;A=1 ld (hl),a ;set 1st IF inc hl ;clear active IF byte ld (hl),0 dec hl ifset2: ld d,a ;get IF byte and b ;set interested bit ld b,a inc hl ;pt to active flag ld a,d ;complement IF byte cpl ld d,a ld a,(hl) ;get active byte and d ;mask in only uninterested bits or b ;mask in complement of interested bit ld (hl),a ;save result pop bc ;restore regs pop de pop hl xor a ;return with NZ dec a ret iferr: pop bc ;restore regs pop de pop hl xor a ;set Z ret end ; ; Z3LIB Module Name: Z3IFELSE ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public ifelse ext getmsg ; ; IFELSE complements the Active Bit for the Current IF. Return with ; A=0 and Zero Flag Set (Z) if there is no current IF. ; ifelse: push hl ;save regs push bc call getmsg ;pt to messages inc hl ;pt to IF byte ld a,(hl) ;get IF byte or a ;any active IFs? jp z,iferr ld b,a ;get IF byte in B inc hl ;pt to IF active byte ld a,(hl) ;get it cpl ;flip bits and b ;look at only interested bit ld c,a ;result in C ld a,b ;complement IF byte cpl ld b,a ld a,(hl) ;get active byte and b ;mask in only uninterested bits or c ;mask in complement of interested bit ld (hl),a ;save result pop bc ;restore registers pop hl xor a ;return NZ dec a ret iferr: pop bc ;restore registers pop hl xor a ;return Z ret end ; ; Z3LIB Module Name: Z3IFEND ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public ifend ext getmsg ; ; IFEND decrements to the previous IF. If there is no active IF, ; return with A=0 and Zero Flag Set (Z). Affect only PSW. ; ifend: push hl ;save regs call getmsg inc hl ;pt to IF byte ld a,(hl) ;get it or a ;no IF active? jp z,iferr rrca ;move right 1 bit and 7fh ;mask msb 0 ld (hl),a ;store active bit pop hl ;restore regs xor a ;return NZ dec a ret iferr: pop hl ;restore regs xor a ;return Z ret end ; ; Z3LIB Module Name: Z3IFTEST ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public iftest ext getmsg ; ; IFTEST returns the number of the Current IF. Return with ; A=0 and Zero Flag Set (Z) if there is no current IF. ; iftest: push hl ;save regs push bc call getmsg ;pt to messages inc hl ;pt to IF byte ld a,(hl) ;get IF byte or a ;any active IFs? jp z,ifdone ld b,0 ;set no IF iftl: inc b ;next IF level rrca ;rotate right 1 bit jp nc,iftl ;loop until none ld a,b ;count in A ifdone: pop bc ;restore registers pop hl or a ;set Z flag if A=0 ret end ; ; Z3LIB Module Name: Z3INI ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public z3init public envptr ; ; Z3INIT accepts as input a pointer to the Z3 Environment Descriptor and ; saves it away in a global buffer for future reference. ; z3init: ld (envptr),hl ret envptr: ds 2 ; global buffer for use by other Z3 routines end ; ; Z3LIB Module Name: Z3IOMA ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public iomatch ext getios,getion,caps ; ; GETIOM matches the name pted to by HL (as a string terminated by ; null or space) to a name of a device in the IOP. B is the logical device ; number. A=0 and Zero Flag Set if no match or error, A=0FFH and NZ and ; C = device number if no error. ; iomatch: push hl ; save regs push de push bc ld (target),hl ; save ptr to target name call getios ; get ptr to the status table jp z,iomex ; exit with zero flag set ld c,b ; get counter in C inc c ; increment for following decrement iom1: dec c ; count down jp z,iom2 inc hl ; pt to next device inc hl jp iom1 iom2: ld c,(hl) ; get number of devices in C ld a,c ; check for no devices or a jp z,iomex ; exit with zero flag set iom3: call iomat ; do match for device C-1 jp z,gotit dec c ; count down jp nz,iom3 iomex: pop bc ; restore regs and exit with error flag in PSW pop de pop hl xor a ; insure error flag ret gotit: dec c ; get device number as 1 less ld a,c ; save reg C pop bc ; restore regs pop de pop hl ld c,a ; number in C or 0ffh ; return OK ret ; ; I/O Match Routine ; Match the device B, C-1 to the TARGET ; Return with Z if match ; iomat: push bc ; don't affect C dec c ; device number call getion ; get name ex de,hl ; name in DE ld hl,(target) ; target in HL iomtch: ld a,(de) ; get char in name cp ' '+1 ; done if less than space jp c,iomtend call caps ; capitalize ld b,a ; char in B ld a,(hl) ; get target inc hl ; pt to next inc de call caps ; capitalize cp b ; compare jp z,iomtch pop bc ; no match ret iomtend: pop bc ; get BC ld a,(hl) ; check for end of target string cp ' '+1 jp c,match or 0ffh ; NZ and no match ret match: xor a ; Z and match ret ; ; Data ; target: ds 2 ; ptr to target string end ; ; Z3LIB Module Name: Z3IOR ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public iorcon,iorcoff,iorlon,iorloff ext envptr,getiop,getios ; ; Macros ; putrg macro push hl push de push bc endm getrg macro pop bc pop de pop hl endm ; ; IORCON opens the console recording. IORCOFF closes the console ; recording. IORLON opens the list recording. IORLOFF closes the list ; recording. HL points to an FCB containing the name of a file to ; record into; the directory reference is also stored here in the standard ; ZCPR3 format (disk at offset 0, user at offset 13). ; ; On input, HL pts to FCB identifying file to record into ; (used by IORCON and IORLON) ; On output, A=0 and Zero Flag Set if error. ; iorcoff: putrg ld de,39 ; offset common: ld (fcbptr),hl ; save FCB ptr call runio ; do recording call getrg ret iorcon: putrg ld de,36 ; offset jp common iorloff: putrg ld de,45 ; offset jp common iorlon: putrg ld de,42 ; offset jp common ; ; Run Routine whose Offset is in DE; Check for presence of IOP ; and return with Zero Set if problem (no IOP or IOP not loaded) ; runio: call getiop ; get I/O Package address ret z ld a,(hl) ; check for loaded I/O Package or a ret z add hl,de ; pt to routine push hl call getios ; check for driver routine and 80h ; MSB is set if drivers available pop hl ret z ld de,runior push de push hl ; save address on stack ld hl,(fcbptr) ; get ptr to FCB containing file name ret ; run routine from address on stack runior: or 0ffh ; set OK ret ; ; Data ; fcbptr: ds 2 ; pointer to FCB argument end ; ; Z3LIB Module Name: Z3LOG ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; public z3log ; ; Equates ; bdos equ 5 ; ; Macros ; putrg macro push hl push de push bc push af endm getrg macro pop af pop bc pop de pop hl endm ; ; Z3LOG logs into the DU contained in a ZCPR3 FCB. On input, ; DE pts to FCB. No codes are returned. ; z3log: putrg ;save regs ; ; Get Current Disk in B (disk A = 1) ; push de ;save ptr to FCB ld c,25 ;get disk call bdos inc a ld b,a ;current disk in B pop de ;pt to FCB ; ; Determine Disk in B (disk A = 0) ; ld a,(de) ;get disk or a ;0=default jp z,log1 ld b,a ;selected disk in B log1: dec b ;B=disk (disk A=0) ; ; Get Selected User in C ; ld hl,13 ;pt to S1 for user add hl,de ld c,(hl) ;user in C ; ; Log Into Disk in B ; push bc ;save DU ld e,b ;disk in E ld c,14 ;select disk call bdos pop bc ; ; Log Into User in C ; ld e,c ;user in E ld c,32 ;select user call bdos getrg ;restore registers ret end ; ; Z3LIB Module Name: Z3LVER ; Author: Richard Conn ; Z3LIB Version Number: 1.3 ; Module Version Number: 1.1 ; vers equ 103h ;Major Version = 1, Minor Version = 3 public z3lver ; ; Return Version Number of Z3LIB in HL; H=Major Version, L=Minor ; Version ; z3lver: ld hl,vers ;version number in HL ret ; ; Author Message ; db 'Z3LIB by Richard Conn',0 end