worm 0.91.0516: send game data over link (wip)
authorMischa Poslawsky <wormy@shiar.org>
Tue, 16 May 2000 11:00:54 +0000 (13:00 +0200)
committerMischa Poslawsky <wormy@shiar.org>
Sun, 22 Feb 2009 15:19:55 +0000 (16:19 +0100)
example1.z80
worm.z80
wormlvl.z80

index 9a2a5565bf40d46b38982e867c0e9d0ffb71a7fb..6bf86fefdbe29161c4382711dfc9d5852e3aa615 100644 (file)
@@ -52,7 +52,7 @@
   .org $F3E3-10                ;$F3E3-[name size]
             ;^^ <-MUST EQUAL NAME SIZE BELOW!!! If not, Worm will crash!
 
-  .db 'w',90                   ;wormLevel header (version .90)
+  .db 'w',91                   ;wormLevel header (version .91)
   .db 10,"Example #1"          ;name size (UPDATE .ORG!!!); level name
   .dw hiscore-single           ;leveldata size
 
@@ -70,8 +70,8 @@ levelsdata:
 
 ;note: use <.dw 0> if no levels present (empty level will be used).
 
-  .db 2,3,4,2         ;max. choosable level+1 for each gametype
-  .db 2,2,2,2         ;so: 2 = level 1 only; 4 = level 1 to 3 available
+  .db 1,2,3,1         ;max. choosable level for each gametype
+  .db 1,1,1,1         ;so: 1 = level 1 only; 3 = level 1 to 3 available
 
 ;again .db 0 indicates no levels present.
 
@@ -94,7 +94,7 @@ levelsdata:
 ; .db 4               ;         begin-x
 ; .db %00             ;         direction (%00=right+down, %11=left+up)
 ; .db 2,7,%00         ;BALL #2: y,x,direction
-; .db 0               ;your start direction (0=up,$40=right,$80=down,$C0=left)
+; .db 0               ;your start direction (0=down,$40=right,$80=up,$C0=left)
 ; .db 2               ;your y-position (2=at top)
 ; .db 63              ;your x-position (63=center)
 ;                     ;IN MULTIPLAYER LEVELS also set positions for worm 2-4:
@@ -104,6 +104,10 @@ levelsdata:
 ;
 ; .db 128,57          ;field size: width (128-255), height (57-255)
 ;                     ; screen will SCROLL if size is more than 128,57
+;                     ;IN CTF LEVELS also set flag-positions:
+;(.db 10,117 )        ;flag #1 y-position, x-position
+;(.db 46,10  )        ;flag #2 y-pos, x-pos.
+;
 ; .db 2               ;number of lines:
 ; .db 28,14,100,41    ;LINE #1 coordinates: (x1,y1)-(x2,y2)
 ; .db 28,41,100,14    ;LINE #2: the same
@@ -184,7 +188,6 @@ deathmatch:           ;deathmatch levels
 
 
 foodmatch:
-ctf:
 domination:
   .db 8,5,18,15,0,0
   .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
@@ -209,6 +212,15 @@ race:
   .db 52,10,74,37
 
 
+ctf:
+  .db 8,5,18,15,0,0
+  .db $20,2,2,$A0,54,125, $20,2,7,$A0,54,120
+  .db 128,57
+  .db 10,117,46,10
+  .db 0,0
+
+
+
 hiscore:              ;space reserved to store hi-scores
   .dw 0               ;singleplayer hiscore will be saved here
   .dw 0,0             ;peaworm hiscore for each peaworm-level
index a5cdab9cc89d01c070bcff60253b5b13f104794e..030690327b65b68a5ff414f3233ad6c333732ff9 100644 (file)
--- 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
index 7ad6a49bd8e7c3ffb97c5baa0ba943fba679d073..a1250b89243110e9fe1a48938c150b94bcd138e2 100644 (file)
@@ -25,7 +25,7 @@ levelsdata:
   .dw domination
 
   .db 1,2,3,1
-  .db 1,1,2,1
+  .db 6,1,2,1
 
 
 ;---------- LEVELS ----------
@@ -167,6 +167,13 @@ peaworm:
   .db 0,0
 
 
+linkmatch:
+  .db 8,0,15,15,0,0
+  .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
+  .db 228,157
+  .db 0,0
+
+
 deathmatch:
   .db 8,5,15,31,0,0
   .db $40,28,2        ;begin stats for each player
@@ -201,13 +208,6 @@ domination:
   .db 0,0
 
 
-linkmatch:
-  .db 8,0,15,15,0,0
-  .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
-  .db 228,157
-  .db 0,0
-
-
 race:
   .db 8,4,15,10,0,0
   .db $40,3,2,$40,6,2, $40,9,2,$40,12,2
@@ -220,9 +220,9 @@ race:
 
 ctf:
   .db 8,5,18,15,0,0
-  .db $20,2,2,$A0,54,125, $20,2,7,$A0,54,120
+  .db $00,2,62,$00,2,64, $20,2,7,$A0,54,120
   .db 128,57
-  .db 9,117,46,10
+  .db 46,117,46,10
   .db 0,0
 
   .db 8,5,18,15,0,0