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
- or a
+ ld a,(gameCar)
+ and _datamulti
+ jr nz,safewormsizedone
+; or a
sbc hl,de
ld a,l
rr h
rra
inc a
ld (ix+grow),a
+safewormsizedone:
- ld de,10
- call DecScore
ld h,(ix+head+1)
ld l,(ix+head)
ld (ix+tail+1),h
inc (ix+died)
dec (ix+lives)
+ push af
+ ld de,10
+ call DecScore
+ pop af
ret nz ;HandleWorm done
ld a,(gameCar)
and _datalivel
dec d
ret
-FindPixel: ;bc to ahl + de gone
+;------------------------------------------------------
+; CLEM's FIND_PIXEL
+; by Clem
+;
+; 131 cycles 28 bytes (b,c) to hl:a destroyes: none
+;------------------------------------------------------
+
+FindPixel:
+ ld h,ScrBuffer/$800
+ ld a,c
+ add a,a
+ add a,a
+ ld l,a ;hl=$3f00+4*y
+ ld a,b
+ rra
+ add hl,hl
+ rra
+ add hl,hl ;hl=$fc00+16*y
+ add hl,hl
+ rra ;a=x/8
+ or l
+ ld l,a
+ ld a,b
+ and 7
+ cpl
+ rlca
+ rlca
+ rlca
+ ld (FP_Bit),a
+ xor a
+FP_Bit =$+1
+ set 0,a
+ ret
+
+;FindPixel: ;bc to ahl + de gone
push de
push bc
ld a,b
ld d,offsets_table/256
ld h,0
ld l,c
- add hl,hl
- add hl,hl
- add hl,hl
- add hl,hl
- add hl,hl
+ add hl,hl ;2y
+ add hl,hl ;4y
+ add hl,hl ;8y
+ add hl,hl ;16y
+ add hl,hl ;32y
ld a,b
and %11111000
rra
;-----------------------------
;----------- 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
+ in a,(1)
+ push af
+ ld a,%11111111
+ 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)
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
Level =$+1
DispBuffer =$+2 ;912 bytes
-ScrBuffer = $8200 ;-$A1FF (32x256)
+ScrBuffer = $8000 ;-$A1FF (32x256)
SinCosTable = $A200 ;-$A300 (4x64)
;-----------------------------