VID1 Z80"VID2 Z80 RVID3 Z805VID4 Z80@VID5 Z80!ZVID6 Z80(sVID7 Z80/).VID8 Z80XcVID9 Z80] EVIDA Z80gVIDB Z80k<$VLAT Z80qjVLGXYMSGZ80v l ; ; VLIB Module Name: VID1 ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; public cls ext vidptr,vidout ; ; Clear Screen ; Return with A=0 and Zero Flag Set if not done ; cls: push hl ;save regs push de ld hl,(vidptr) ;pt to environment ld a,(hl) ;no terminal? cp ' '+1 jp c,clserr ld de,14h ;pt to cls delay add hl,de ld d,(hl) ;get it inc hl ;pt to cls string inc hl inc hl ld a,(hl) ;get first char of string or a ;if no string, error jp z,clserr call vidout ;output string with delay pop de ;done pop hl xor a ;return NZ dec a ret clserr: pop de ;done pop hl xor a ;return Z ret end ; ; VLIB Module Name: VID2 ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; public ereol ext vidptr,vidout,vidskp ; ; Erase to End of Line ; Return with A=0 and Zero Flag Set if not done ; ereol: push hl ;save regs push de ld hl,(vidptr) ;pt to environment ld a,(hl) ;no terminal? cp ' '+1 jp c,err ld de,16h ;pt to ereol delay add hl,de ld d,(hl) ;get it inc hl ;pt to cls string call vidskp ;skip over it call vidskp ;skip over CM string ld a,(hl) ;get first char of ereol string or a ;if no string, error jp z,err call vidout ;output string with delay pop de ;done pop hl xor a ;return NZ dec a ret err: pop de ;done pop hl xor a ;return Z ret end ; ; VLIB Module Name: VID3 ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; public stndout ext vidptr,vidout,vidskp ; ; Begin Standout Mode ; Return with A=0 and Zero Flag Set if not done ; stndout: push hl ;save regs push de ld hl,(vidptr) ;pt to environment ld a,(hl) ;no terminal? cp ' '+1 jp c,err ld de,17h ;pt to cls string add hl,de ld d,0 ;no delay call vidskp ;skip over CL string call vidskp ;skip over CM string call vidskp ;skip over CE string ld a,(hl) ;get first char of SO string or a ;if no string, error jp z,err call vidout ;output string with delay pop de ;done pop hl xor a ;return NZ dec a ret err: pop de ;done pop hl xor a ;return Z ret end ; ; VLIB Module Name: VID4 ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; public stndend ext vidptr,vidout,vidskp ; ; Terminate Standout Mode ; Return with A=0 and Zero Flag Set if not done ; stndend: push hl ;save regs push de ld hl,(vidptr) ;pt to environment ld a,(hl) ;no terminal? cp ' '+1 jp c,err ld de,17h ;pt to cls string add hl,de ld d,0 ;no delay call vidskp ;skip over CL string call vidskp ;skip over CM string call vidskp ;skip over CE string call vidskp ;skip over SO string ld a,(hl) ;get first char of SE string or a ;if no string, error jp z,err call vidout ;output string with delay pop de ;done pop hl xor a ;return NZ dec a ret err: pop de ;done pop hl xor a ;return Z ret end ; ; VLIB Module Name: VID5 ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; public tinit ext vidptr,vidout,vidskp ; ; Initialize Terminal ; Affect No Registers ; tinit: push hl ;save regs push de push af ld hl,(vidptr) ;pt to environment ld a,(hl) ;no terminal? cp ' '+1 jp c,done ld de,17h ;pt to cls string add hl,de ld d,0 ;no delay call vidskp ;skip over CL string call vidskp ;skip over CM string call vidskp ;skip over CE string call vidskp ;skip over SO string call vidskp ;skip over SE string ld a,(hl) ;get first char of TI string or a ;if no string, error jp z,done call vidout ;output string with delay done: pop af ;done pop de pop hl ret end ; ; VLIB Module Name: VID6 ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; public dinit ext vidptr,vidout,vidskp ; ; De-Initialize Terminal ; Affect No Registers ; dinit: push hl ;save regs push de push af ld hl,(vidptr) ;pt to environment ld a,(hl) ;no terminal? cp ' '+1 jp c,done ld de,17h ;pt to cls string add hl,de ld d,0 ;no delay call vidskp ;skip over CL string call vidskp ;skip over CM string call vidskp ;skip over CE string call vidskp ;skip over SO string call vidskp ;skip over SE string call vidskp ;skip over TI string ld a,(hl) ;get first char of TE string or a ;if no string, error jp z,done call vidout ;output string with delay done: pop af ;done pop de pop hl ret end ; ; VLIB Module Name: VID7 ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; public gotoxy ext vidptr,vidskp,videlay,cout ; ; GOTO XY ; HL = Row/Col, with Home=1/1 ; Return with A=0 and Zero Flag Set if not done ; gotoxy: push bc ;save regs push de push hl ld hl,(vidptr) ;pt to environment ld a,(hl) ;no terminal? cp ' '+1 jp c,err ld de,15h ;pt to CM delay add hl,de ld a,(hl) ;get it ld (cmdelay),a ;save it inc hl ;pt to CL string inc hl call vidskp ;skip CL string ld a,(hl) ;get first char of CM string or a ;if no string, error jp z,err ex de,hl ;DE=address of CM string pop hl ;get coordinates in HL push hl call gxy ;output xy string with delay ld a,(cmdelay) ;pause call videlay pop hl ;done pop de pop bc xor a ;return NZ dec a ret err: pop hl ;done pop de pop bc xor a ;return Z ret ; ; GOTOXY ; On input, H=Row and L=Column to Position To (1,1 is Home) ; On input, DE=address of CM string ; gxy: dec h ;adjust to 0,0 for home dec l xor a ;set row/column ld (rcorder),a ;row before column ld (rcbase),a ;add 0 to base ; ; Cycle thru string ; gxyloop: ld a,(de) ;get next char inc de ;pt to next or a ;done? ret z cp '%' ;command? jp z,gxycmd cp '\' ;escape? jp z,gxyesc call cout ;send char jp gxyloop ; ; Escape - output following byte literally ; gxyesc: ld a,(de) ;get next char call cout ;output literally inc de ;pt to next jp gxyloop ; ; Interpret next character as a command character ; gxycmd: ld a,(de) ;get command char inc de ;pt to next cp 'd' ;%d jp z,gxyout1 cp 'D' ;%D jp z,gxyout1 cp '2' ;%2 jp z,gxyout2 cp '3' ;%3 jp z,gxyout3 cp '.' ;%. jp z,gxyout4 cp '+' ;%+v jp z,gxyout5 cp '>' ;%>xy jp z,gxygt cp 'r' ;%r jp z,gxyrev cp 'R' ;%R jp z,gxyrev cp 'i' ;%i jp z,gxyinc cp 'I' ;%I jp z,gxyinc call cout ;output char if nothing else jp gxyloop ; ; Set row/col home to 1,1 rather than 0,0 ; gxyinc: ld a,1 ;set rcbase to 1 ld (rcbase),a jp gxyloop ; ; Reverse order of output to column then row (default is row then column) ; gxyrev: ld a,1 ;set column and row order ld (rcorder),a jp gxyloop ; ; Command: >xy ; If value of row/col is greater than x, add y to it ; gxygt: call getval ;get value ld c,a ;save value ld a,(de) ;get value to test inc de ;pt to next cp c ;if carry, value>x jp nc,gxygt1 ld a,(de) ;get value to add add a,c call putval ;put value back gxygt1: inc de ;pt to next jp gxyloop ;resume ; ; Command: +n ; Add n to next value and output ; gxyout5: ld a,(de) ;get value to add inc de ;pt to next ld b,a ;save in B call getval ;get value add a,b ;add in B call cout ;output value rcmark: ld a,(rcorder) ;mark output or 80h ld (rcorder),a jp gxyloop ; ; Command: . ; Output next value ; gxyout4: call getval ;get value call cout ;output value jp rcmark ; ; Command: 3 ; Output next value as 3 decimal digits ; gxyout3: call getval ;get value ld b,100 ;output 100's ld c,1 ;leading zeroes call digout gxyot3: ld b,10 ;output 10's ld c,1 ;leading zeroes gxyot2: call digout add '0' ;output 1's call cout jp rcmark ; ; Command: 2 ; Output next value as 2 decimal digits ; gxyout2: call getval ;get value jp gxyot3 ; ; Command: d ; Output next value as n decimal digits with no leading zeroes ; gxyout1: call getval ;get value ld b,100 ;output 100's ld c,0 ;no leading zeroes call digout ld b,10 ;output 10's ld c,0 ;no leading zeroes jp gxyot2 ; ; Return next value in A ; getval: ld a,(rcorder) ;get order flag or a ;already output the first value? jp m,getval2 and 1 ;look at lsb jp z,getvalr ;if 0, row first getvalc: ld a,(rcbase) ;get base offset add a,l ;get column ret getvalr: ld a,(rcbase) ;get base offset add a,h ;get row ret getval2: and 1 ;look at lsb jp z,getvalc jp getvalr ; ; Store A as next value ; putval: ld c,a ;save value ld a,(rcorder) ;get order flag or a ;already output the first value? jp m,putval2 and 1 ;look at lsb jp z,putvalr ;if 0, row first putvalc: ld l,c ;set column ret putvalr: ld h,c ;set row ret putval2: and 1 ;look at lsb jp z,putvalc jp putvalr ; ; Output A as decimal digit char ; B=Quantity to Subtract from A, C=0 if no leading zero ; digout: push de ;save DE ld d,'0' ;char decot1: sub b ;subtract jp c,decot2 inc d ;increment char jp decot1 decot2: add a,b ;add back in push af ;save result ld a,d ;get digit cp '0' ;zero? jp nz,decot3 ld a,c ;get zero flag or a ;0=no zero jp z,decot4 decot3: ld a,d ;get digit call cout ;print it decot4: pop af ;get A pop de ;restore DE ret ; ; GXY Buffers ; rcorder: db 0 ;0=row/col, else col/row rcbase: db 0 ;0=org is 0,0, else org is 1,1 cmdelay: db 0 ;number of milliseconds to delay for CM end ; ; VLIB Module Name: VID8 ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; public vidout ext cout,videlay ; ; VIDOUT - Output video string pted to by HL ; Output also a delay contained in the D register ; vidout: ld a,(hl) ;get next char or a ;done if zero jp z,vid2 inc hl ;pt to next cp '\' ;literal value? jp nz,vid1 ld a,(hl) ;get literal char inc hl ;pt to after it vid1: call cout ;output char jp vidout vid2: ld a,d ;output delay jp videlay ;output delay end ; ; VLIB Module Name: VID9 ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; public videlay ext envptr ; ; VIDELAY pauses for the number of milliseconds indicated by the A ; register. VIDELAY assumes a ZCPR3 environment and uses it to determine ; processor speed. ; videlay: push af ;save regs push bc push de push hl ld c,a ;save count in C or a ;no delay? jp z,done ld hl,(envptr) ;pt to environment ld de,2bh ;offset to processor speed add hl,de ld a,(hl) ;get processor speed or a ;zero? jp nz,vid1 ld a,4 ;assume 4 MHz vid1: ld b,a ;processor speed in B vid2: push bc ;delay 1 ms call delay pop bc dec c ;count down jp nz,vid2 done: pop hl ;restore regs pop de pop bc pop af ret ; ; Delay 1 ms at Clock speed ; delay: call del1 ;delay 1 ms at 1MHz dec b ;count down clock speed jp nz,delay ret ; ; Delay 1 ms at 1MHz ; del1: ld c,20 ;20 loops of 51 cycles each ~ 1000 cycles del1a: ex (sp),hl ;18 cycles ex (sp),hl ;+18 = 36 cycles dec c ;+ 5 = 41 cycles jp nz,del1a ;+10 = 51 cycles ret end ; ; VLIB Module Name: VIDA ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; public vidskp ; ; VIDSKP - Skip over video string pted to by HL; pt to byte after string ; vidskp: ld a,(hl) ;get next char inc hl ;pt to next or a ;done if zero ret z cp '\' ;literal value? jp nz,vidskp ;continue if not inc hl ;pt to after literal value jp vidskp end ; ; VLIB Module Name: VIDB ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; Module Entry Points: ; Z3VINIT VIDINIT VIDPTR ; Module External References: ; ENVPTR ; public z3vinit,vidinit,vidptr ext envptr ; ; Z3VINIT - Set ptr to ZCPR3 Environment and Z3TCAP ; On input, HL pts to ZCPR3 Environment Descriptor ; z3vinit: push hl ;save HL ld (envptr),hl ld de,80h ;80H bytes later ... add hl,de ld (vidptr),hl ;set Z3TCAP pointer pop hl ;restore HL ret ; ; VIDINIT - Set ptr to Z3TCAP ; On input, HL pts to Z3TCAP ; vidinit: ld (vidptr),hl ;set ptr ret ; ; Termcap Pointer ; vidptr: dw 0 ;first byte of termcap entry end ; ; VLIB Module Name: VLAT ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; public at ext gotoxy ; ; Position Cursor at Location Specified by Return Address ; Usage: ; call at ; db row,col ;location ; at: ex (sp),hl ;pt to address push de ;save DE ld d,(hl) ;get row inc hl ld e,(hl) inc hl ;HL pts to return byte ex de,hl ;DE pts to return byte, HL contains screen loc call gotoxy ;position cursor ex de,hl ;HL pts to return byte pop de ;restore registers ex (sp),hl ;restore stack ptr ret end ; ; VLIB Module Name: VLGXYMSG ; Author: Richard Conn ; VLIB Version Number: 1.1 ; Module Version Number: 1.1 ; public gxymsg,vprint ext gotoxy,stndout,stndend,cout ; ; Position Cursor and Print Following Message ; Usage: ; call gxymsg ; db row,col ; db 'message' ; db 0 ; Message may contain the special byte values of 1 and 2 to begin and ; end standout mode, resp. For instance: ; ; call gxymsg ; db 5,10 ; db 'Hello ',1,'World',2,' - How are things?',0 ; ; prints "Hello " and " - How are things?" normally, but "World" is in ; Standout Mode. ; gxymsg: ex (sp),hl ;pt to coords push de ;save DE ld d,(hl) ;get row in D inc hl ld e,(hl) ;get col in E inc hl ;pt to message ex de,hl ;HL pts to coords call gotoxy ;position cursor ex de,hl ;HL pts to message pop de ;restore DE ex (sp),hl ;restore return address and fall thru ; ; Print String At Return Address with STNDOUT/STNDEND Processing ; Like PRINT, but 1 invokes STNDOUT and 2 invokes STNDEND (see above) ; vprint: ex (sp),hl push af ;save A vp1: ld a,(hl) ;get char inc hl ;pt to next or a ;done? jp z,vp4 cp 1 ;stand out? jp z,vp2 cp 2 ;stand end? jp z,vp3 call cout ;print char jp vp1 vp2: call stndout ;enter standout mode jp vp1 vp3: call stndend ;exit standout mode jp vp1 vp4: pop af ;restore A ex (sp),hl ret end