; ; Virtual Net 96 Routinenpack, 1996 by Hage & Steve of Wizcat ;_____________________________________________________________ ; IMPORTANT; All routines do not change the interrupt state. But if a routine ; is executed the interrupts MUST be disabled (DI). ; vnsnd Transmit a byte ; vnrec Receive a byte ; vnsndb Transmit a data block ; vnrecb Receive a data block ; vnzero Wait for zero ; vnone Wait for one ; vnzeri Wait for zero without timeout ; vnonei Wait for one without timeout ; vnwait Wait a determined time ; vnwais Wait for a request routine ; Routine; 'vnsndb', transmit a data block ; ---------------------------------------------- ; Jump in; HL=Pointer to the data block ; DE=Length of the data block in bytes ; Jump out; A, BC, DE, HL destroyed ; ; Comments; Data block is immediately transmitted without checking the ; wire. ; -------------------------------------------------------------------------- vnsndb: push de ; Laenge senden ld a,e call vnsnd pop de push de ld a,d call vnsnd pop de ; vnsnd1: push de ; Block senden ld a,(hl) inc hl call vnsnd pop de dec de ld a,d or e jr nz,vnsnd1 ret ; Routine; 'vnrecb', receive a data block ; --------------------------------------------- ; Jump in; HL=Pointer to a buffer ; Jump out; CY=0 --> Ok, (HL)=data block ; DE=length ot the data block in bytes ; CY=1 --> Timeout error ; A, BC, DE, HL destroyed ; ; Comments; If there's no data block received within ca. 1s the routine ; returns with CY=1. ; -------------------------------------------------------------------------- vnrecb: call vnrec ; Laenge empfangen ret c ld (vnrec1+1),a call vnrec ret c ld (vnrec1+2),a ; vnrec1: ld de,0 ; Block empfangen vnrec2: push de call vnrec jr c,vnrec3 ld (hl),a inc hl pop de dec de ld a,d or e jr nz,vnrec2 ld de,(vnrec1+1) or a ret vnrec3: pop de ret ; Routine; 'vnsnd', transmit a byte ; --------------------------------------- ; Jump in; A=Byte to transmit ; Jump out; A, BC destroyed ; ; Comments; Byte is immediately transmitted without checking the wire. ; -------------------------------------------------------------------------- vnsnd: ld c,a ; Startbit senden ld b,&EF xor a out (c),a ds 18 ld a,128 out (c),a ; rr c:rra ; Byte senden ds 13 out (c),a rr c:rra ds 5 out (c),a rr c:rra ds 5 out (c),a rr c:rra ds 5 out (c),a rr c:rra ds 5 out (c),a rr c:rra ds 5 out (c),a rr c:rra ds 5 out (c),a rr c:rra ds 5 out (c),a ; ld a,128 ds 4 out (c),a ret ; Routine; 'vnrec', receive a byte ; -------------------------------------- ; Jump in; - ; Jump out; CY=0 --> Ok, A=received byte ; CY=1 --> Timeout error ; A, BC, DE destroyed ; ; Comments; If there's no byte received within ca. 1s the routine ; returns with CY=1. ; -------------------------------------------------------------------------- vnrec: ld b,&F5 ; Startbit empfangen ld de,0 vnemp1: in a,(c) cp 64 jr c,vnemp2 dec de ld a,d or e jr nz,vnemp1 scf ret ; vnemp2: in a,(c) cp 64 jr c,vnemp2 ; ds 12 ; Byte empfangen in a,(c) rla:rla:rr c ds 4 in a,(c) rla:rla:rr c ds 4 in a,(c) rla:rla:rr c ds 4 in a,(c) rla:rla:rr c ds 4 in a,(c) rla:rla:rr c ds 4 in a,(c) rla:rla:rr c ds 4 in a,(c) rla:rla:rr c ds 4 in a,(c) rla:rla:rr c ; ld a,c or a ret ; Routine; 'vnwait', wait a determined time ; ----------------------------------------------- ; Jump in; HL=Wait time in 7.63us steps ; Jump out; A, HL destroyed ; ; Comments; Waits HL*7.63 micro seconds. ; Rule of thumb; 9 HL cycles are one raster line. ; -------------------------------------------------------------------------- vnwait: dec hl ld a,h or l jr nz,vnwait ret ; Routine; 'vnwais', wait for a request routine ; --------------------------------------------------- ; Jump in; - ; Jump out; - ; ; Comments; Waits the time the routines vnzero, vnone, vnzeri and ; vnonei need to notice a change of the data state. ; -------------------------------------------------------------------------- vnwais: ds 60 ret ; Routine; 'vnzero', wait for zero state ; -------------------------------------------- ; Jump in; - ; Jump out; CY=0 --> Data wire is zero ; CY=1 --> Timeout error ; A, B, DE destroyed ; ; Comments; If the data wire doesn't switch to zero state within ca. 1s ; the routine returns with CY=1. ; -------------------------------------------------------------------------- vnzero: ld b,&F5 ld de,0 vnzer1: in a,(c) cp 64 jr c,vnzer2 dec de ld a,d or e jr nz,vnzer1 scf ret vnzer2: or a ret ; Routine; 'vnone', wait for one state ; ------------------------------------------ ; Jump in; - ; Jump out; CY=0 --> Data wire is one ; CY=1 --> Timeout error ; A, B, DE destroyed ; ; Comments; If the data wire doesn't switch to one state within ca. 1s ; the routine returns with CY=1. ; -------------------------------------------------------------------------- vnone: ld b,&F5 ld de,0 vnone1: in a,(c) cp 64 ret nc dec de ld a,d or e jr nz,vnone1 scf ret ; Routine; 'vnzeri', wait for zero state without timeout ; ------------------------------------------------------------ ; Jump in; - ; Jump out; Data wire is zero ; A, B, DE destroyed ; ; Comments; This routine returns only if the data wire is in zero ; state. ; -------------------------------------------------------------------------- vnzeri: ld b,&F5 vnzei1: in a,(c) cp 64 jr nc,vnzei1 ret ; Routine; 'vnonei', wait for one state without timeout ; ----------------------------------------------------------- ; Jump in; - ; Jump out; Data wire is one ; A, B, DE destroyed ; ; Comments; This routine returns only if the data wire is in one state. ; -------------------------------------------------------------------------- vnonei: ld b,&F5 vnoni1: in a,(c) cp 64 jr c,vnoni1 ret ____________reRBADJPROICFQXWRLFDFKOLB:23:AGHECDD@6-+.59:99:;;9:BNTQJHKOJA;<2+)-:K]e\PHDGKKF@>AHRYZTLGIOVZRD:79;:89=AD@6.*((&')/32.,-14437?<;?=;:7548BJH>8;DHD;79COWZXTNGA?@GMJ@:9:AHJF:0+-7GQWTNNNQRNF>:?JSXUMEEJRVSMHDB<2/04898;=8.(&&()+,.//0/.,,/6<>93/./27;=<=?DFD?;:9646=7105?LNH=4017CKMMOS]ee_RHIR_hheaacbacjomdZSOHA>?DKNKC;61.,++*,/21.*()-39;93..132137;<?:5