From daa6847068e3ae9b0201187f7f619feb27229385 Mon Sep 17 00:00:00 2001 From: Mischa Poslawsky Date: Sat, 12 Feb 2000 10:42:12 +0100 Subject: [PATCH] worm 0.80.0212: link improvements --- worm.asm | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 161 insertions(+), 11 deletions(-) diff --git a/worm.asm b/worm.asm index 383bab2..6c84154 100644 --- a/worm.asm +++ b/worm.asm @@ -272,8 +272,14 @@ setscorelimit: linkmatch: call _clrWindow + + +; in a,(7) +; and %11 +; cp %11 ld a,WormVersion - call SendByte +; jr nz,host + call send jr c,host client: @@ -673,16 +679,18 @@ removewormloop: ;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 @@ -703,6 +711,10 @@ thislevel =$+1 inc (ix+died) dec (ix+lives) + push af + ld de,10 + call DecScore + pop af ret nz ;HandleWorm done ld a,(gameCar) and _datalivel @@ -1216,7 +1228,41 @@ CheckPixel: ;at bc in d 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 @@ -1226,11 +1272,11 @@ FindPixel: ;bc to ahl + de gone 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 @@ -1769,6 +1815,8 @@ boxloopx: ;----------------------------- ;----------- link ------------ ;----------------------------- +#ifdef 0 +TIMEOUT = $1200 send: push af ;ld b,a @@ -1802,6 +1850,7 @@ ReceiveByteCont: ReceiveByte: call LinkPrep ReceiveBits: + ld de,TIMEOUT WaitRecBit: call checklink jr z,LinkFailed @@ -1819,6 +1868,7 @@ ReceiveLow: ld (AckBit),a ld a,d out (7),a + ld de,TIMEOUT WaitAckRec: call checklink cp 0 @@ -1851,12 +1901,14 @@ sendbit: 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 @@ -1878,6 +1930,11 @@ linkerror: jp Exit checklink: + pop hl + dec de + ld a,d + or e + jr z,LinkFailed ld a,$BF ;key call _readkeypad bit 6,a @@ -1885,8 +1942,98 @@ checklink: 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) @@ -1895,6 +2042,8 @@ _readkeypad: out (1),a pop af ret +nolink: + jp Exit ;----------------------------- ;---------- levels ----------- @@ -2079,6 +2228,7 @@ HiScore: .db 0 gamesdata: _datalink = %00000001 +_datamulti = %00000010 _datalivel = %00000010 ;ix+lives=0 limit _datafoodl = %00000100 ;left=0 limit _datanextl = %00001000 ;next level if left=0 @@ -2147,7 +2297,7 @@ name = 21 ;game Level =$+1 DispBuffer =$+2 ;912 bytes -ScrBuffer = $8200 ;-$A1FF (32x256) +ScrBuffer = $8000 ;-$A1FF (32x256) SinCosTable = $A200 ;-$A300 (4x64) ;----------------------------- -- 2.30.0