X-Git-Url: http://git.shiar.nl/wormy.git/blobdiff_plain/14699b6ef3e5d2192b16c8c5c9995d186e63f6d3..ce0bf2b9f5148725977f1cc2dbeccb59249e54d6:/worm.z80 diff --git a/worm.z80 b/worm.z80 index 68d5112..e254d01 100644 --- a/worm.z80 +++ b/worm.z80 @@ -20,9 +20,9 @@ ; 3% * linkplay ; 2% * make linkplay available for all gametypes (not just deathmatch) -; * game types: -; 1% * ctf: take enemy flag (right-bottom) and return to your flag (left-top) -; 1% * domination?: take control points by running over them and hold them +; 1% * fix pea XOR problem in ctf (+dom?) +; 1% * domination?: take control points by running over them and hold them +; * customizable keys ; * complete readme (+custom level info) ; 2% * ... (pollish, &&&) @@ -722,7 +722,7 @@ linkmatch: cal _clrWindow ld a,WormVersion cal send - jr c,client ;2nd + jr nc,client ;2nd host: ld hl,txtWaiting @@ -732,17 +732,18 @@ host: jp nz,LinkBreak cal send - ld hl,SwapPos - ld (hl),$f6 jr multiplayer client: ld hl,txtReceive cal _puts - cal receive + cal ReceiveByte + jp c,LinkBreak cp WormVersion jp nz,LinkBreak + ld hl,SwapPos + ld (hl),$f6 multiplayer: ld a,2 ld (nrworms),a @@ -1001,6 +1002,16 @@ noboxes: psh hl ; >> levelp new cal showstats + ld a,(Gametype) + cp gamectf + jr nz,noctf + ld hl,$1010 + ld (peaspos),hl + cal DrawPea + ld hl,$2010 + ld (peaspos+2),hl + cal DrawPea +noctf: ld a,(gameCar) and _datafood jr z,nofood @@ -1537,18 +1548,7 @@ Hitworm: ld hl,0 PeaY =$-2 PeaX =$-1 - ld a,(sprsize) - inc a - ld d,a - ld a,b - sub h - inc a - cp d ;=(sprsize)+1 - jp nc,WormDead - ld a,c - sub l - inc a - cp d + cal chkpeahit jp nc,WormDead cal DrawPea ;remove pea ld a,(ix+grow) @@ -1562,10 +1562,10 @@ peagrowth =$-1 ld de,10 cal IncScore pop af - jp nz,still_alive_not_dead + jp nz,Drawworm ;continue ld a,(gameCar) and _datafoodl - jp z,still_alive_not_dead + jp z,Drawworm ld a,(Gametype) or a jp nz,Exit ;stack restored @@ -1586,8 +1586,7 @@ peagrowth =$-1 pop hl ; << levelp new jp StartLevel -multiple_peas: - ld hl,(peaspos) +chkpeahit: ;hl=peapos ld a,(sprsize) inc a ld d,a @@ -1595,14 +1594,77 @@ multiple_peas: sub h inc a cp d ;=(sprsize)+1 - jp nc,peaaction + ret nc ;nc=no pea ld a,c sub l inc a cp d - ret c -peaaction: - ret + ret ;c=pea + +flagcaptured: + psh hl + ld de,30 + cal IncScore + pop hl +sillylabel: + cal WormDead +DrawAllPeas: + ld hl,(peaspos) + cal DrawPea + ld hl,(peaspos+2) + jp DrawPea + +multiple_peas: + ld hl,(peaspos) ;1st pea + psh hl + ld a,(ix+reserv) + ld e,a ;push a + and %01 + jr nz,sel_ownpea + ld hl,(peaspos+2) ;2nd pea +sel_ownpea: + cal chkpeahit + pop hl ;(peapos) 1st pea + jp c,stopworm ;own pea hit + + ld a,e ;peek a (that x86 asm for pop\push ;) + and %01 + jr z,sel_otherpea + ld hl,(peaspos+2) ;2nd pea +sel_otherpea: + cal chkpeahit + jp c,hitflag + +;no peas hit + ld a,e + cal flagtoken + jp z,WormDead + ld b,a ;%10 + srl b ;%01 + add a,b ;%11 + ld (ix+reserv),a + cal DrawPea ;restore own flag + jr sillylabel ;inv both\die + +hitflag: ;correct pea hit + ld a,e ;pop a + xor %01 ;0=1;1=0 + ld (ix+reserv),a + cal flagtoken + psh af ;safe z-flag + cal DrawPea ;remove + pop af + jr z,flagcaptured + jr stopworm + +flagtoken: + and %01 ;current + add a,a ;<< for cp + ld b,a ;in b + ld a,e + and %10 ;own + cp b ;same? + ret ;Z=yes: no flag taken ;----------------------------- @@ -1666,15 +1728,15 @@ chkworm: pop ix ret z ;not hit pop bc ;call -previouspos =$+1 +stopworm: ld bc,0 +previouspos =$-2 ld de,0 ld (ix+pos),c ld (ix+pos+1),b ld (ix+pos2),e ld (ix+pos2+1),d ret -still_alive_not_dead: ;-------- draw worm ---------- @@ -1885,8 +1947,7 @@ DrawPea: ;hl=(PeaY) ld c,l ld de,peasprite spritepos =$-2 - cal PutSprite ;||-ed - ret + jp PutSprite ;||-ed ;----------- score ----------- @@ -2502,6 +2563,7 @@ boxloop: ;----------- link ------------ ;----------------------------- +#ifdef 0 TIMEOUT = $1000 receive: @@ -2614,6 +2676,175 @@ CheckLink: in a,(7) and %11 jp (hl) +#endif + +LinkBreak: + pop hl + ld a,D0HD1H + out (7),a + jp DisplayMenu + + +receive: + cal GET_KEY + cp K_EXIT + jp z,LinkBreak + cal TryReceiveByte + jr c,receive + ret + + +LINKPORT =7 +TIMEOUT =$1000 +LINKMASK =3 + +LinkPrep: + ex (sp),hl + push bc + push de +; ld b,(iy+12h) +; push bc + set 2,(iy+12h) + ld b,8 + jp (hl) + +TryReceiveByte: + in a,(LINKPORT) + and LINKMASK + cp LINKMASK + scf + ret z +ReceiveByteCont: + call LinkPrep + jr ReceiveCont +ReceiveByte: + call LinkPrep +ReceiveBits: + ld de,TIMEOUT +WaitRecBit: + call CheckLink + jr z,LinkFailed + cp LINKMASK + jr z,WaitRecBit +ReceiveCont: + sub LINKMASK/3*2 + ld a,LINKMASK/3*2 + ld d,D0LD1H + jr c,ReceiveLow + rra + ld d,D0HD1L +ReceiveLow: + rr c + ld (AckBit),a + ld a,d + out (LINKPORT),a + ld de,TIMEOUT +WaitAckRec: + call CheckLink + cp 0 +AckBit =$-1 + jr nz,WaitAckRec + ld a,D0HD1H + out (LINKPORT),a + ld d,4 +WaitReadyRec: + dec d + jr z,ReadyRec + in a,(LINKPORT) + cp LINKMASK + jr nz,WaitReadyRec +ReadyRec: + djnz ReceiveBits + jr LinkSuccess + +send: +SendByte: + call LinkPrep + ld c,a + + inc b + jr SendAcked + +SendBits: + rr c + ld a,D0LD1H + jr nc,SendLow + ld a,D0HD1L +SendLow: + out (LINKPORT),a + ld de,TIMEOUT +WaitAckSend: + call CheckLink + jr nz,WaitAckSend +SendAcked: + ld a,D0HD1H + out (LINKPORT),a + ld de,TIMEOUT +WaitReadySend: + call CheckLink + cp LINKMASK + jr nz,WaitReadySend + djnz SendBits +LinkSuccess: + or 0 +.org $-1 +LinkFailed: + scf + ld a,c + res 2,(iy+12h) + pop de + pop bc + pop hl + ret + +CheckLink: + pop hl + dec de + ld a,d + or e + jr z,LinkFailed + ld a,0BFh + call _readkeypad + bit 6,a + jr z,LinkFailed + in a,(LINKPORT) + and LINKMASK + jp (hl) + +_readkeypad: + out (1),a + in a,(1) + push af + ld a,255 + out (1),a + pop af + ret + + +TEST_2: + ld b,8 +T2delay: + halt + dnz T2delay + in a,(7) + and %11 + ld b,a + ld a,'1' + rr b + jr c,T2no1 + ld a,'-' +T2no1: + cal _putc + ld a,'2' + rr b + jr c,T2no2 + ld a,'-' +T2no2: + cal _putc + cal GET_KEY + cp K_EXIT + jp z,DisplayMenu + jr TEST_2 ;----------------------------- @@ -2706,7 +2937,7 @@ _datafood = %00010000 ;food present _________ = %00100000 ; _datadie = %01000000 ;worm dies on impact _datascore = %10000000 ;score>=100 limit -_datamultpeas = 0 +_datamultpeas = %00100000 gamesingle = 0 datasingle: .db %01011110 @@ -2721,7 +2952,7 @@ datalinkm: .db %01000011 gamerace = 5 datarace: .db %10000000 gamectf = 6 -datactf: .db %01000000 +datactf: .db %11100000 gamedomin = 7 datadomin: .db %01000000 ;==(8 modes) @@ -2732,10 +2963,10 @@ datalevels: .dw LevelDef, LevelDef nrlevels: .db 2,2,2,2,2,2,2,2 worm1set: .dw worm1p,worm1p - .db %11110111,3,0,%01111110,%10,%100 ;< > + .db %11110111,3,%00,%01111110,%10,%100 ;< > worm1name: .db "worm #01",0 worm2set: .dw worm2p,worm2p - .db %11111011,3,0,%00111111,%10000,%1000 ;f1 f2 + .db %11111011,3,%11,%00111111,%10000,%1000 ;f1 f2 worm2name: .db "worm #02",0 worm3set: .dw worm3p,worm3p .db %11111011,3,0,%01011111,%10,%100 ;sto , @@ -2744,7 +2975,6 @@ worm4set: .dw worm4p,worm4p .db %11111011,3,0,%01111101,%10,%1 ;enter + worm4name: .db "worm #04",0 -hipeaworm: .dw 0 end: defsprsize = 4 @@ -2769,7 +2999,7 @@ storepos = 16 lives = 17 reserv = 18 ;loop ;race:lap - ;hunt:time + ;ctf:pea input = 19 left = 20 right = 21