linkmatch:
call _clrWindow
+
+
+; in a,(7)
+; and %11
+; cp %11
ld a,WormVersion
- call SendByte
+; jr nz,host
+ call send
jr c,host
client:
;hl=ix+head
pop de ;ix+tail
ld a,(gameCar)
- and _dataMulti
+ and _datamulti
jr nz,safewormsizedone
; or a
sbc hl,de
;-----------------------------
;----------- link ------------
;-----------------------------
+#ifdef 0
+TIMEOUT = $1200
send:
push af ;ld b,a
ReceiveByte:
call LinkPrep
ReceiveBits:
+ ld de,TIMEOUT
WaitRecBit:
call checklink
jr z,LinkFailed
ld (AckBit),a
ld a,d
out (7),a
+ ld de,TIMEOUT
WaitAckRec:
call checklink
cp 0
ld a,D0hD1l
sendselected:
out (7),a
+ ld de,TIMEOUT
waitacknowledge:
call checklink
jr nz,waitacknowledge
SendAcked:
ld a,D0hD1h
out (7),a
+ ld de,TIMEOUT
waitsendready:
call checklink
cp %11
jp Exit
checklink:
+ pop hl
+ dec de
+ ld a,d
+ or e
+ jr z,LinkFailed
ld a,$BF ;key
call _readkeypad
bit 6,a
in a,(7)
and %11
+ jp (hl)
ret
_readkeypad:
out (1),a
pop af
ret
+#endif
+
+send:
+SendByte:
+ in a,(7)
+ and %11
+ jr z,nolink
+ ld b,8
+sendloop:
+ ld de,$8000
+ rl c
+ ld a,%11010100
+ jr nc,sendbit
+ ld a,%11101000
+sendbit:
+ out (7),a
+sendwait1:
+ call checklink
+ in a,(7)
+ and %11
+ jr nz,sendwait1
+ ld a,%11000000
+ out (7),a
+sendwait2:
+ call checklink
+ in a,(7)
+ and %11
+ cp %11
+ jr nz,sendwait2
+ djnz sendloop
+ xor a
+ ret
+timeout:
+ scf
+ ret
+
+
+receive:
+ in a,(7)
+ and %11
+ jr z,nolink
+ cp %11
+ jr z,receive
+ ld b,8
+receiveloop:
+ ld de,$8000
+receivewait1:
+ call checklink
+ in a,(7)
+ and %11
+ cp %11
+ jr z,receivewait1
+ rra
+ rl c
+ rra
+ ld a,%11010100
+ jr nc,receivebit
+ ld a,%11101000
+receivebit:
+ out (7),a
+receivewait2:
+ call checklink
+ in a,(7)
+ and %11
+ jr z,receivewait2
+ ld a,%11000000
+ out (7),a
+ djnz receiveloop
+ xor a
+ ret
+
+checklink:
+ dec de
+ ld a,d
+ or e
+ jr z,timeout
+ ld a,$BF ;key
+ call _readkeypad
+ bit 6,a
+ jr z,timeout
+ ret
+_readkeypad:
+ out (1),a
+ in a,(1)
+ push af
+ ld a,%11111111
+ out (1),a
+ pop af
+ ret
+nolink:
+ jp Exit
;-----------------------------
;---------- levels -----------
gamesdata:
_datalink = %00000001
+_datamulti = %00000010
_datalivel = %00000010 ;ix+lives=0 limit
_datafoodl = %00000100 ;left=0 limit
_datanextl = %00001000 ;next level if left=0