_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 -------
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
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
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)
jp nz,nextlevel
psh hl
- ld b,150
-waitsomemore:
- halt
- dnz waitsomemore
+ cal releasekeys
cal _clrWindow
pop hl
;show end msg or smtn
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
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
;de=ix+head
ld (ix+tail+1),d
ld (ix+tail),e ;head=tail/size=0
- jr norespawn
ret
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
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
pop hl ; << call
pop hl ; << call
pop hl ; << levelp new
+ ld (ix+delay),2
jp StartLevel
chkpeahit: ;hl=peapos
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
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
cp 0
AckBit =$-1
jr nz,WaitAckRec
- ld a,D0HD1H
+ ld a,D0HD1H ;11
out (7),a
ld d,4
WaitReadyRec:
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
cal CheckLink
jr nz,WaitAckSend
SendAcked:
- ld a,D0HD1H
+ ld a,D0HD1H ;%11
out (7),a
ld de,TIMEOUT
WaitReadySend:
cp %11
jr nz,WaitReadySend
dnz sendloop
+ ld a,c
+ ret
+
LinkSuccess:
.db $F6 ;or NN (skip scf)
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
out (1),a
pop af
bit 6,a
- jr z,LinkFailed
+ jr z,LinkBreak
in a,(7)
and %11