X-Git-Url: http://git.shiar.net/wormy.git/blobdiff_plain/7ec10d8466fbe267a3d0a8fe8fbfaed79adbf07f..ffea7bf228e19e45c18996c09bacf50026e868f0:/worm.z80 diff --git a/worm.z80 b/worm.z80 index a5cdab9..0306903 100644 --- a/worm.z80 +++ b/worm.z80 @@ -78,6 +78,7 @@ _PTEMP_END = $D29A ;end of VAT _load_ram_ahl = $462F ;ahl->page+hl _writeb_inc_ahl = $5567 ;ld (ahl),c _jforce = $409C ;TI-OS stack restored +_EXLP = $4493 ;swap (hl),(de) b times ;----------------------------- ;------- data storage ------- @@ -780,12 +781,43 @@ host: jp nz,linkiniterror cal send - jr multiplayer +; cal sendname +; cal receivename + + ld a,$18 + jr nc,multiplayer linkiniterror: pop hl jp DisplayMenu +sendname: + ld hl,worm1+name + ld b,maxnamelength +sendnameloop: + ld a,(hl) + inc hl + psh bc + psh hl + cal send + pop hl + pop bc + dnz sendnameloop + ret +receivename: + ld hl,worm2+name + ld b,maxnamelength +recvnameloop: + psh bc + psh hl + cal receive + pop hl + pop bc + ld (hl),a + inc hl + dnz recvnameloop + ret + client: ld hl,txtReceive cal _puts @@ -794,9 +826,12 @@ client: cp WormVersion jp nz,linkiniterror - ld hl,SwapPos - ld (hl),$f6 +; cal receivename +; cal sendname + + ld a,$f6 multiplayer: + ld (SwapPos),a ld a,2 ld (nrworms),a @@ -806,29 +841,25 @@ multiplayer: GameOver: cal _clrLCD - ld hl,0 - ld (worm1+died),hl -;+died=0 \ +score1=0 - ld (worm2+died),hl - ld (worm3+died),hl - ld (worm4+died),hl - inc h - ld (worm1+score+1),hl -;+score2=0 \ +delay=1 - ld (worm2+score+1),hl - ld (worm3+score+1),hl - ld (worm4+score+1),hl ld hl,worm1set - ld de,worm1+head + ld de,worm1 ld a,4 ;4x (all worms) createwormsloop: - ld bc,19 - ldir ;copy 19 bytes ex de,hl - ld bc,head + ld bc,died add hl,bc - ex de,hl ;de=wormX+head - dec a ;loop + ld (hl),0 ;died=0 + inc hl + ld (hl),0 ;score=0 + inc hl + ld (hl),0 ;score+1=0 + inc hl + ld (hl),2 ;delay=2 + inc hl + ex de,hl ;de=wormX+head + ld bc,19 + ldir ;copy 19 bytes + dec a ;loop jr nz,createwormsloop ld a,(Gametype) @@ -845,10 +876,7 @@ StartLevel: jp nz,nextlevel psh hl - ld b,150 -waitsomemore: - halt - dnz waitsomemore + cal releasekeys cal _clrWindow pop hl ;show end msg or smtn @@ -1112,26 +1140,26 @@ maskline: ld a,0 gameCar =$-1 and _datalink - jr z,SwapPos ;no link + jr z,initfinished ;no link + xor a - ld (worm2+input),a + ld (worm2+input),a ;worm 2 via link ld (worm2+left),a - ld (Speed),a - + ld (Speed),a ;max.speed SwapPos: ;$18 xx -> $F6 xx + ; jr xx -> or xx jr initfinished inc a - ld (worm2+left),a - ld hl,(worm1+pos) - ld de,(worm2+pos) - ld (worm2+pos),hl - ld (worm1+pos),de - ld a,(worm1+heading) - ld b,a - ld a,(worm2+heading) - ld (worm1+heading),a - ld a,b - ld (worm2+heading),a + ld (worm2+left),a ;1 + ld hl,worm1 + ld de,worm2 + ld b,4 ;+heading +pos + cal _EXLP ;swap positions +;&&& over link + ld hl,worm1+name + ld de,worm2+name + ld b,maxnamelength + cal _EXLP ;swap positions initfinished: ld b,startdelay @@ -1278,11 +1306,11 @@ displayWormStats: xor a cp (hl) ;input=0 = link jr nz,NoLinkIndic - ld b,7 + ld b,7 ;{DOWN} inc hl ;+left cp (hl) jr z,hostLinkIndic - dec b + dec b ;{UP} hostLinkIndic: ld a,8 ld (_curCol),a @@ -1469,7 +1497,6 @@ safewormsizedone: ;de=ix+head ld (ix+tail+1),d ld (ix+tail),e ;head=tail/size=0 - jr norespawn ret unnamedlabel: @@ -1479,16 +1506,19 @@ unnamedlabel: respawndue: ld l,a cal inputcall + ld (sendbyte),a ld a,h ;previous cp l ;changed? ret z + ld (ix+delay),a ;=0 + ret saverespawncounter: ld (ix+delay),a -norespawn: - ld a,(gameCar) - and _datalink - jr nz,inlink - ret + jr inputcall +; ld a,(ix+input) +; or a +; jr z,inlink +; ret inkeys: ;use jp not call! out (1),a ;nop\nop @@ -1519,13 +1549,17 @@ sendbyte =$-1 ld b,(ix+left) dec b jr z,receivefirst + psh hl cal send cal receive + pop hl ld l,a ret receivefirst: psh af + psh hl cal receive + pop hl ld l,a pop af psh hl @@ -1671,6 +1705,7 @@ peagrowth =$-1 pop hl ; << call pop hl ; << call pop hl ; << levelp new + ld (ix+delay),2 jp StartLevel chkpeahit: ;hl=peapos @@ -2662,23 +2697,13 @@ boxloop: TIMEOUT = $1000 -LinkBreak: - pop hl - ld a,D0HD1H - out (7),a - jp Exit - - receive: cal GET_KEY cp K_EXIT jp z,LinkBreak in a,(7) and %11 - cp %11 - jr z,receive - in a,(7) - and %11 +; jr z,LinkBreak cp %11 jr z,receive ld b,8 @@ -2698,10 +2723,10 @@ WaitRecBit: ReceiveCont: sub %10 ld a,%10 - ld d,D0LD1H + ld d,D0LD1H ;01 jr c,ReceiveLow - rra - ld d,D0HD1L + rra ;ld a,%01 + ld d,D0HD1L ;10 ReceiveLow: rr c ld (AckBit),a @@ -2713,7 +2738,7 @@ WaitAckRec: cp 0 AckBit =$-1 jr nz,WaitAckRec - ld a,D0HD1H + ld a,D0HD1H ;11 out (7),a ld d,4 WaitReadyRec: @@ -2727,16 +2752,20 @@ ReadyRec: ld a,c ret +LinkBreak: + ld a,D0HD1L + out (7),a + jp Exit + send: ld c,a ld b,8+1 jr SendAcked - sendloop: rr c - ld a,D0LD1H + ld a,D0LD1H ;%01 jr nc,SendLow - ld a,D0HD1L + ld a,D0HD1L ;%10 SendLow: out (7),a ld de,TIMEOUT @@ -2744,7 +2773,7 @@ WaitAckSend: cal CheckLink jr nz,WaitAckSend SendAcked: - ld a,D0HD1H + ld a,D0HD1H ;%11 out (7),a ld de,TIMEOUT WaitReadySend: @@ -2752,6 +2781,9 @@ WaitReadySend: cp %11 jr nz,WaitReadySend dnz sendloop + ld a,c + ret + LinkSuccess: .db $F6 ;or NN (skip scf) LinkFailed: @@ -2762,9 +2794,9 @@ LinkFailed: CheckLink: pop hl dec de - ld a,d - or e - jr z,LinkFailed + ld a,d + or e + jr z,LinkFailed ld a,$BF out (1),a @@ -2775,7 +2807,7 @@ CheckLink: out (1),a pop af bit 6,a - jr z,LinkFailed + jr z,LinkBreak in a,(7) and %11