wormy 0.95.1907
[wormy.git] / wormy.z80
index e76ab019faa03442085b7a3e463ad982207bd73d..e0bb2b21affa566f98efa39a2fd6ba19de19d30a 100644 (file)
--- a/wormy.z80
+++ b/wormy.z80
@@ -1,5 +1,5 @@
 ; Title                      : Wormy
-; Version                    : 93%
+; Version                    : 95%
 ; Release Date               : summer 2001
 ; Filename                   : wormy.86p (5kb)
 ; Author(s)                  : Shiar
 ;----------- TO-DO -----------
 ;-----------------------------
 
-; 93% = DONE
+; 95% = DONE
 
-;     * internal levels
-;       * check levels/gametype
-;       * enough hiscore saves!
-;     * complete readme
+;    [* internal levels         ]
+;    [  * check levels/gametype ]
+;    [  * enough hiscore saves! ]
+;    [* complete readme         ]
 ;  1% * misc (pollish, bugs, &&&)
 ;   * LINK
-;  2% * fix deaths linkplay and transmit game/level data
-;  2% * make linkplay available for all gametypes (not just deathmatch)
-;   * CTF
-;  1% * fix pea XOR problem in ctf (+dom?)
-;     * fix wormstop
-;  1% * domination?: take control points by running over them and hold them
+;     * fix first packet loss
+;  1% * transmit game/level data
+;;;1% * get g/o signal (l&l) working
+;  2% * send new peas' positions
 
 ;100% = bugs fixed + levels done
 
 ;-----------------------------
 
 #define buffer      ;use display buffer (otherwise write directly to screen)
-#define readymask   ;"grays" out the field before starting a level
+#define readymask   ;"greys" out the field before starting a level
+#define coolzgfx    ;nice graphics for game over screen
 
 ;#define readytext  ;displays "prepare" before level starts
 ;#define invincible ;worms cannot die =)
+;#define optdie     ;in race games worms don't die when they run into each other
 
 #define cal call
 #define psh push
 #define dnz djnz
+;#define halt nop
 
 #include "asm86.h"
 #include "ti86asm.inc"
 
-_SHRACC            = $4383
-_SHLACC            = $438B
+_SHRACC            = $4383 ;4x srl a
+_SHLACC            = $438B ;4x sll a
 _divHLby10         = $4044 ;hl=hl/10
 _divAby10          = $4DAF ;a=a/10
 _HLTIMES10         = $41BF ;hl=hl*10
-_cphlde            = $403C
+_cphlde            = $403C ;cp hl,de
 _clrWindow         = $4A86 ;clear screen
 _asapvar           = $D6FC ;own name (worm)
 _MOV4B             = $429B ;4x ld (de),(hl)
@@ -74,13 +75,15 @@ _LOAD_ABS_SRC_ADDR = $5209 ;ahl = mm.ldir source
 _SET_ABS_DEST_ADDR = $5285 ;set destination for mm.ldir = ahl
 _SET_MM_NUM_BYTES  = $464F ;number of bytes for mm.ldir = ahl
 _mm_ldir           = $52ED ;24bit ldir
+_MM_LDIR_SET_SIZE  = $524D ;_SET_MM_NUM_BYTES + _mm_ldir
 _RAM_PAGE_1        = $47E3 ;set $8000+ to page 1
-_RAM_PAGE_7        = $47F3
+_RAM_PAGE_7        = $47F3 ;"""" 7
 _PTEMP_END         = $D29A ;end of VAT
 _load_ram_ahl      = $462F ;ahl->page+hl
-_writeb_inc_ahl    = $5567 ;ld (ahl),c
+_writeb_inc_ahl    = $5567 ;ld (ahl++),c
 _jforce            = $409C ;TI-OS stack restored
 _EXLP              = $4493 ;swap (hl),(de) b times
+_GETB_AHL         = $46C3 ;a=(ahl) \ hl=ahl
 
 ;-----------------------------
 ;------- data  storage -------
@@ -95,18 +98,21 @@ worm2       = $AC1F ;-AC3B (1F)
 worm3       = $AC3E ;-AC59 (1F)
 worm4       = $AC5D ;-AC77 (1F)
 balls       = $AC7C ;-ACFF (3x43d)
-SinCosTable = $AD00 ;-AE00 (4x40)
+SinCosTable = $AD00 ;-AE00 (4*40)
         ;free $AE01 ;-AFFF (1FF)
 worm1p      = $B000 ;-B7FF (800)      %1011O000
 worm3p      = $B800 ;-BBFF (400)      %10111O00
         ;free $BF91 ;-BFFF (6F)
-
-     ;program $D748 ;-E7FF (106D+4A)
-        ;free $E800 ;-EFFF (800)
+     ;program $D748 ;-EFFF (186D+4A)
 worm4p      = $F000 ;-F3FF (400)      %11110O00
 leveldata   = $F400 ;-FA70 (<=671)
 
-peaspos = $AE01
+turn10      = $AE01 ;      (1) (counter)
+peaspos     = $AE02 ;-AE05 (4) (peas)
+
+;MEM|8---9---A---B---C---D---E---F---|
+;   |..[------]||[]|......[-----]|[].|
+;   |   SCREEN 2* 13      PRGM   4LV |
 
 ;--- temporary
 
@@ -134,21 +140,20 @@ start:
   .dw WormIcon
 
 WormTxt:
-  .db "WORMY by SHIAR -- alpha 93%",0
+  .db "WORMY by SHIAR -- beta 95%",0
 WormIcon:
-  .db 9,2
-  .db %10010110,%01101111
-  .db %10110101,%01001011
-  .db %01110011,%01001001
-  .db %00000011,%10000000
-  .db %00000001,%11100000
-  .db %00111000,%11111000
-  .db %01111110,%00111111
-  .db %11101111,%00001111
-  .db %11000011,%10000000
+  .db 8,2
+  .db %00000000,%00111100
+  .db %00000000,%01010010
+  .db %00000000,%01100001
+  .db %01100011,%10011001
+  .db %10010100,%01101001
+  .db %10011001,%00011001
+  .db %01000010,%11000001
+  .db %00111100,%00111110
 
 levelhead  = 'w'
-levelhead2 = 93 ;wormy levels header = "93"
+levelhead2 = 95 ;wormy levels header = "95"
 
 int_handler:
   ex af,af'
@@ -168,26 +173,26 @@ Start:
   im  1
   ld  a,$D4
   ld  h,a
-  ld  l,0     ;ld hl,$D400
+  ld  l,0 ;ld hl,$D400
   ld  d,a
-  ld  e,1     ;ld de,$D401
+  ld  e,1 ;ld de,$D401
   ld  b,e
-  ld  c,l     ;ld bc,$0100
-  dec a       ;ld a,$D3
+  ld  c,l ;ld bc,$0100
+  dec a   ;ld a,$D3
   ld  (hl),a
   ldir
   ld  hl,int_handler
   ld  d,a
-  ld  e,a     ;ld de,$D3D3
+  ld  e,a ;ld de,$D3D3
   ld  bc,int_end-int_handler
   ldir
-  inc a       ;ld a,$D4
+  inc a   ;ld a,$D4
   ld  i,a
   im  2
 
   cal _RAM_PAGE_7
   ld  hl,$BFFF ;VAT start
-  ld  bc,templevels
+  ld  ix,templevels
 searchloop:
   ld  de,(_PTEMP_END+1) ;VAT end
   or  a ;nc
@@ -199,20 +204,17 @@ searchloop:
   cp  $0C ;string
   jr  z,stringfound
 searchnext:
- cal _RAM_PAGE_7
   pop hl
   dec hl ;5x
   dec hl
   dec hl
   dec hl
   dec hl
- psh bc
   ld  b,(hl) ;name size
   inc b
 skipname:
   dec hl
   dnz skipname
- pop bc
   jr  searchloop
 
 stringfound:
@@ -225,40 +227,34 @@ stringfound:
   ex  de,hl ;ld ahl,(hl)
   cal _AHL_PLUS_2_PG3 ;string id
   cal _Get_Word_ahl ;ld de,(ahl)
- cal _RAM_PAGE_1
- ld (bc),a
+  ld (ix),a
   ld  a,levelhead
   cp  e
-  jr  nz,searchnext ;not worm
+  jr  nz,_searchnext ;not worm
   ld  a,levelhead2
   cp  d
-  jr  nz,searchnext
-
- inc bc
- ld a,h
- ld (bc),a
- inc bc
- ld a,l
- ld (bc),a
- inc bc
- jr searchnext
+  jr  nz,_searchnext
+  inc ix ;save level's ahl
+  ld a,h
+  ld (ix),a
+  inc ix
+  ld a,l
+  ld (ix),a
+  inc ix
+_searchnext:
+  cal _RAM_PAGE_7
+  jr searchnext
 
 loadgametype:
   psh de
-  inc bc
-  inc bc
   cal _Get_Word_ahl ;ld de,(ahl++)
   psh af
-  ld  a,d
-  or  e
-  jr  z,defaultlevels
   ld  a,e ;set new level
   ld  (bc),a
   inc bc
   ld  a,d
   ld  (bc),a
-  dec bc
-defaultlevels:
+  inc bc
   pop af
   pop de ;counter
   dec d ;8x
@@ -266,77 +262,135 @@ defaultlevels:
   ret
 
 searchcomplete:
-  cal _RAM_PAGE_1
   ld  a,255
-  ld  (bc),a ;end mark
-  ld  hl,templevels-3
-dispnextlevel:
-  cal _RAM_PAGE_1
-  psh hl
+  ld  (ix),a ;end mark
+
+  ld  ix,templevels-6
+levelselectmenu:
+  psh ix ;offset
+  ld  a,-2
+  ld  (availevels),a
   cal _clrWindow
-  ld  a,2
-  ld  (_curRow),a
+  ld  hl,$0320
+  ld  (_penCol),hl
   ld  hl,txtLevsel
-  cal _puts ;"< Select levels: >"
-  ld  hl,$0004
-  ld  (_curRow),hl
-  pop hl
-  ld  a,(hl)
-  cp  255 ;&&
-  jr  nz,displevel
-  ld  hl,templevels-3
-  ld  a,(hl)
+  cal _vputs ;"< SELECT LEVELS >"
+  ld  hl,$FC00+(2*16)
+  cal hr
+  ld  hl,$FC00+(10*16)
+  cal hr
+  ld  hl,$FC00+(56*16)
+  cal hr
+  ld  hl,$0C01 ;x=1
+  ld  (_penCol),hl
+dispnextlevel:
+  ld  de,3
+  add ix,de
+  ld  a,(ix)
+  inc a ;cp 255
+  jr  z,__levselect
+  dec a
 displevel:
-  inc hl
-  ld  d,(hl)
-  inc hl
-  ld  e,(hl)
-  inc hl  ;ade=(hl)
-  psh hl  ;HL
-  ld  c,a
-  ld  h,d
-  ld  l,e ;cde=ahl=(hl)
+  ld  h,(ix+1)
+  ld  l,(ix+2) ;ahl=(ix)
   cal _load_ram_ahl ;hl=ahl
   ld  b,(hl) ;b=title size
-  psh bc
-  cal _putps ;destr=abchl
-  pop bc  ;cde=hl
-  pop hl  ;HL
+  cal _vputs
+  ld  hl,_penCol
+  ld  (hl),$01 ;x=1
+  inc hl
+  ld  a,(hl)
+  add a,6
+  ld  (hl),a ;y+6
+  ld  hl,availevels
+  inc (hl)
+  cp  49 ;bottom of screen
+  jr  nc,_levselect
+  jr  dispnextlevel
+
+levup:
+  cal menupos
+  dec b ;up
+  ld  a,b
+  cp  -3
+  jr  nz,levselected
+  inc b ;undo
+  jr  levselected
+levdown:
+  cal menupos
+  inc b ;down
+  ld  a,b
+  cp  -2
+availevels =$-1
+  jr  nz,levselected
+  dec b ;back up
+levselected:
+  jp  menupos
+
+__levselect:
+  ld  ix,templevels-6 ;reset 2 1st page
+_levselect:
+  ld  b,-2 ;level selected
+  cal menupos
+  pop hl
 levselect:
-  halt
   psh hl
-  psh de
   psh bc
-  cal GET_KEY
-  pop bc
-  pop de
-  pop hl
-  cp  K_RIGHT
-  jr  z,dispnextlevel
-  sub K_SECOND
+  cal ubergetkey
+  pop bc ;GET_KEY destr. b
+  cp  K_UP
+  cal z,levup
+  dec a ;K_DOWN
+  cal z,levdown
+  cp  K_SECOND-1
   jr  z,loadlevel
-  dec a ;K_EXIT
-  ret z
-  cp  K_ENTER-K_EXIT+256
+  pop hl
+  cp  K_RIGHT-1
+  jp  z,levelselectmenu
+  cp  K_EXIT-1
+  jp  z,ExitNoStats
+  cp  K_ENTER-1
   jr  nz,levselect
+; jr  z,loadlevel
 
 loadlevel:
-  ld  a,c
+; ld  hl,templevels-3
+  ld  a,b
+  add a,3 ;sellev+3 (#0==-3)
+  ld  e,a
+  add a,a ;*2
+  add a,e ;*3
+  ld  e,a
+  ld  d,0 ;de=sellev*3
+  add hl,de
+  ld  a,(hl) ;ade=(hl)
   or  a ;levelfile on page 0 (=internal)
   jr  z,levelloaded
 
-  ex  de,hl ;ahl=cde
-  inc b ;b=titlesize+1
+  inc hl
+  ld  d,(hl)
+  inc hl
+  ld  e,(hl)
+  ex  de,hl ;ahl=ade
 skiptitle:
-  cal _INC_PTR_AHL
-  dnz skiptitle
+  ld  b,a ;psh ahl
+  psh hl
+  cal _GETB_AHL ;ld a,(ahl)
+  pop hl
+  or  a
+  ld  a,b ;pop ahl
+  psh af
+  cal _INC_PTR_AHL ;ahl++
+  pop af ;cp 0
+  jr  nz,skiptitle ;goto #0-terminator
 
   cal _Get_Word_ahl
   ld  (leveldataSize),de
+
   ld  d,8 ;counter
-  ld  bc,datalevels-2
+  ld  bc,datalevels
   cal loadgametype
-  ld  (hilvlposa),a
+  ld  (hilvlposa),a ;singleplayer levels
   ld  (hilvlposhl),hl
   ld  d,4
   cal loadgametype
@@ -347,8 +401,7 @@ skiptitle:
   cal _SET_ABS_DEST_ADDR ;store in mem.
   ld  hl,0
 leveldataSize =$-2
-  cal _SET_MM_NUM_BYTES
-  cal _mm_ldir
+  cal _MM_LDIR_SET_SIZE
 
   cal _LOAD_ABS_SRC_ADDR ;->ahl
   ld  (hiscrposa),a
@@ -366,13 +419,21 @@ levelloaded:
   ld  a,r
   ld  (Seed),a
 
+  ld  hl,datasingle+3
+  ld  b,8
+  ld  de,8
+setdeflevels:
+  ld  (hl),1 ;def=level#1
+  add hl,de ;next
+  dnz setdeflevels
+
 ;-----------------------------
 ;----- build trig tables -----
 ;-----------------------------
 
   ld  hl,TrigPrecalc
   ld  de,SinCosTable
-  psh de                        ; >> 1
+  psh de
   ld  bc,65
   ldir
   dec hl
@@ -383,7 +444,7 @@ MirrorSineWave:
   ld  (de),a
   inc de
   dnz MirrorSineWave
-  pop hl                         ; << 0k
+  pop hl ;SinCosTable
   ld  b,128+64
 NegativeSineWave:
   xor a
@@ -398,14 +459,44 @@ NegativeSineWave:
 ;-----------------------------
 
 DisplayMenu: ;---draw menu---
+  cal linkok
   cal _clrWindow
   ld  de,$FC40 ;(0,4)
   ld  hl,wtPicture
   ld  bc,16*16
   ldir
-
+  ld  hl,$FC00+$010 ;(*,01)
+  cal hr
+  ld  hl,$FC00+$160 ;(*,22)
+  cal hr
+  ld  hl,$FC00+$3E0 ;(*,62)
+  cal hr
+dispmainmenu:
+  ld  hl,Gametype
+  ld  a,(hl)
+  dec a ;will be inced @changegame
+  and 7
+  ld  (hl),a
+  ld  hl,changegame ;dispmenusets ;mainMenu
+  psh hl ;jump here after ret
   ld  hl,txtMenu
   ld  ix,posMenu
+;Mode|Level|Limit|Worms|worm #|controls
+; jr  dispmenucommon ;cal
+
+dispmenucommon:
+  ld  de,$FD80 ;begin pos
+  ld  b,36*16/3
+  xor a
+clroldmenuloop:
+  ld  (de),a
+  inc de
+  ld  (de),a
+  inc de
+  ld  (de),a
+  inc de
+  dnz clroldmenuloop
+
   ld  b,6
 dispmenuloop:
   ld  d,(ix)
@@ -413,14 +504,232 @@ dispmenuloop:
   ld  e,(ix)
   inc ix
   ld  (_penCol),de
-  cal _vputs ;Mode \ Level \ Limit \ Worms \ worm # \ controls
+  cal _vputs
   dnz dispmenuloop
+; ld  b,0 ;b=menu#
+  ret
 
-  ld  b,0 ;b=menu#
-  jr  setgame ;> dispmenusets > mainMenu
+hr: ;draw horizontal line at hl
+  ld  b,16
+  jp  menuinvloop
 
 ;--- menu loop ---
 
+dispoptionmenu:
+  ld  hl,txtoMenu
+  ld  ix,posoMenu
+;Back|Lives|Limit|Speed|Rotation|Growth
+  cal dispmenucommon
+
+dispomenusets:
+  cal clrold
+
+  ld  hl,$1E3E
+  ld  (_penCol),hl
+  cal loadgamecar
+  psh hl
+  cal cshowA0 ;lives
+
+  ld  hl,$2A3E
+  ld  (_penCol),hl
+  pop hl ;loadgamecar
+  inc hl \ inc hl \ inc hl
+  psh hl
+  ld  a,(hl) ;(Speed)
+  inc a ;1..99
+  jr  nz,dispspeed
+  ld  hl,txtDef
+  cal _vputs
+  jr  dispspeeddone
+dispspeed:
+  cal cshowA0
+dispspeeddone:
+
+  ld  hl,$363E
+  ld  (_penCol),hl
+  pop hl ;loadgamecar
+  inc hl
+  psh hl
+  ld  a,(hl) ;(growth)
+  inc a ;-1=None; 0..98->1..99
+  cal cshowA0
+
+  ld  hl,$303E
+  ld  (_penCol),hl
+  pop hl ;loadgamecar
+  inc hl
+  psh hl
+  ld  a,(hl)
+  cp  8
+  jr  nz,dispturn
+  ld  hl,txtDef
+  cal _vputs
+  jr  dispturndone
+dispturn:
+  cal cshowA0 ;turn speed
+dispturndone:
+
+  ld  hl,$243E
+  ld  (_penCol),hl
+  pop hl ;loadgamecar
+  inc hl
+  ld  a,(hl) ;(scorelimit)
+  or  a
+  psh af
+  cal cshowA0 ;limit
+  pop af ;a==0?
+  jr  z,optionMenu ;do not display 0 behind 'None'
+  ld  a,'0'
+  cal _vputmap ;x10
+
+optionMenu:
+  cal menupos
+  cal menucall
+  jr  nz,notoselect
+oselect:
+  cal menupos
+  ld  a,b
+  or  a ;1st item?
+  jp  z,dispmainmenu ;mainMenu
+  jr  optionMenu
+notoselect
+  cp  K_EXIT
+  jp  z,dispmainmenu
+  psh af
+  cal menupos
+  cal loadgamecar
+  inc hl
+  pop af
+  sub K_LEFT
+  jr  z,seloleft
+  dec a ;K_RIGHT
+  ld  a,b
+  jr  nz,optionMenu
+
+seloright:
+  dec a
+  jr  z,changelives
+  dec a
+  jr  z,changelimit
+  dec a
+  jr  z,changespeed
+  dec a
+  jr  z,changeturn
+  dec a
+  jr  z,changegrowth
+
+seloleft:
+  ld  a,b
+  dec a
+  jr  z,bchangelives
+  dec a
+  jr  z,bchangelimit
+  dec a
+  jr  z,bchangespeed
+  dec a
+  jr  z,bchangeturn
+  dec a
+  jr  z,bchangegrowth
+_optionMenu:
+  jr  optionMenu
+
+changelives:
+  cal loadgamecar ;a=(hl)
+  inc a
+  cp  100
+  jr  nc,optionMenu ;>99
+changedlives:
+  ld  (hl),a
+_dispomenusets:
+  jp  dispomenusets ;optionMenu
+bchangelives:
+  cal loadgamecar
+  sub 1 ;dec does not set cf
+  jr  c,optionMenu ;<0
+  jr  changedlives
+
+changelimit:
+  cal changelimitInit
+  inc a
+  cp  100
+  jr  nc,optionMenu ;>99
+changedlimit:
+  ld  (hl),a
+  jr  _dispomenusets ;optionMenu
+bchangelimit:
+  cal changelimitInit
+  sub 1 ;dec does not set cf
+  jr  c,optionMenu ;<0
+  jr  changedlimit
+changelimitInit:
+  cal loadgamecar
+  ld  de,6
+  add hl,de
+  ld  a,(hl) ;(scorelimit)
+  ret
+
+changespeed:
+  cal changespeedInit
+  inc a
+  cp  20
+  jr  nc,_optionMenu ;>98
+changedspeed:
+  dec hl ;(Speed)
+  ld  (hl),a
+  jr  _dispomenusets ;optionMenu
+bchangespeed:
+  cal changespeedInit
+  dec a
+  cp  -2
+__optionMenu: ;w/ zf
+  jr  z,_optionMenu ;<-1
+  jr  changedspeed
+changespeedInit:
+  cal loadgamecar
+  ld  de,3
+  add hl,de
+  ld  a,(hl) ;(Speed)
+  inc hl ;=saves 2 bytes :P
+  ret
+
+changeturn:
+  cal changespeedInit
+  inc hl ;(turnspeed)
+  ld  a,(hl)
+  inc a
+  cp  26
+  jr  nc,_optionMenu ;>25
+changedturn:
+  ld  (hl),a
+  jr  _dispomenusets ;optionMenu
+bchangeturn:
+  cal changespeedInit
+  inc hl
+  ld  a,(hl)
+  dec a
+  cp  3
+  jr  c,_optionMenu ;<3
+  jr  changedturn
+
+changegrowth:
+  cal changespeedInit
+  ld  a,(hl)
+  inc a
+  cp  99
+  jr  nc,_optionMenu ;>98
+changedgrowth:
+  ld  (hl),a
+  jr  _dispomenusets ;optionMenu
+bchangegrowth:
+  cal changespeedInit
+  ld  a,(hl)
+  dec a
+  cp  -2
+  jr  z,__optionMenu ;<-1
+  jr  changedgrowth
+
+;---
+
 mainMenu:
   cal menupos
   cal menucall
@@ -428,11 +737,13 @@ mainMenu:
 select:   ;2nd/enter
   cal menupos
   ld  a,b
-  sub 4 ;4th item?
+  dec a ;2nd item: level
+  jp  z,dispoptionmenu
+  sub 3 ;5th item: wormname
   jp  z,changeworms
-  dec a ;5th?
+  dec a ;6th: controls
   jp  z,changekeys
-  jp  LetsGetThisPartyOn ;1/2/3/5
+  jp  LetsGetThisPartyOn ;otherwise
 notselect
   cp  K_EXIT
   jp  z,ExitNoStats
@@ -441,9 +752,9 @@ notselect
   cal loadgamecar
   inc hl
   pop af
-  cp  K_LEFT
+  sub K_LEFT
   jr  z,selleft
-  cp  K_RIGHT
+  dec a ;K_RIGHT
   ld  a,b
   jr  nz,mainMenu
 
@@ -451,9 +762,9 @@ selright:
   or  a
   jr  z,changegame
   dec a
-  jp  z,changelevel ;&&&jr??
+  jr  z,changelevel
   dec a
-  jr  z,changelives
+  jr  z,changelink
   dec a
   jr  z,changenrworms
 ; dec a
@@ -467,7 +778,7 @@ changecurworm:
   inc a
 changedcurworm:
   ld  (curworm),a
-  jp  dispmenusets ;mainMenu
+  jr  _dispmenusets ;mainMenu
 
 selleft:
   ld  a,b
@@ -476,7 +787,7 @@ selleft:
   dec a
   jr  z,bchangelevel
   dec a
-  jr  z,bchangelives
+  jr  z,bchangelink
   dec a
   jr  z,bchangenrworms
 ; dec a
@@ -489,92 +800,99 @@ bchangecurworm:
   jr  mainMenu
 
 changenrworms:
-  ld  a,(Gametype)
-  cp  2
-  jr  c,mainMenu ;type 0/1
-  ;hl=nrworms
-  ld  a,(hl)
+  cal change4spOnly
+  ld  a,(hl) ;hl=nrworms
   inc a
   cp  5
   jr  nc,mainMenu ;may not be >4
 changednrworms:
   ld  (hl),a
-  jr  dispmenusets ;mainMenu
+  jr  _dispmenusets ;mainMenu
+changenrwormsInit:
+  ld  a,(Gametype)
+  cp  3
+  ld  a,(hl) ;hl=nrworms
+  ret
 bchangenrworms:
-  ;hl=nrworms
-  ld  a,(hl)
+  cal change4spOnly
+  ld  a,(hl) ;hl=nrworms
   dec a ;0-3
-  jr  nz,changednrworms ;save >0
+  cp  2
+  jr  nc,changednrworms ;save >=2
 _mainMenu:
   jr  mainMenu
 
+change4spOnly:
+  ld  a,(Gametype)
+  cp  3
+  ret nc
+  pop hl ;cal
+  jr  _mainMenu ;don't change for singleplayer
+
+changelink:
+bchangelink:
+  cal change4spOnly
+  dec hl ;inced earlier
+  dec hl ;gameCar
+  ld  a,1 ;change LS-bit (=link)
+  xor (hl) ;0=1; 1=0
+  ld  (hl),a
+_dispmenusets:
+  jr  dispmenusets ;mainMenu
+
 changegame:
-  ld  a,0
-Gametype =$-1
+  ld  a,(Gametype)
   inc a
+  cal changedgame
+  jr  z,changegame
+  jr  dispmenusets ;mainMenu
 changedgame:
   and 7 ;mod 8
   ld  (Gametype),a
-setgame:
-  ld  a,1
-  ld  (curlevel),a ;reset level#
-  jr  dispmenusets ;mainMenu
+  cal getnrlevels
+  xor a
+  cp  (hl)
+  ret
 bchangegame:
   ld  a,(Gametype)
   dec a
-  jr  changedgame
-
-changelives:
-  cal changelivesInit
-  inc a
-  cp  100
-  jr  nc,_mainMenu ;&& _?
-changedlives:
-  ld  (hl),a
+  cal changedgame
+  jr  z,bchangegame
   jr  dispmenusets ;mainMenu
-bchangelives:
-  cal changelivesInit
-  dec a
-  jr  z,_mainMenu
-  jr  changedlives
-changelivesInit:
-  cal loadgamecar ;c=(gameCar)
-;a=(hl)=(Gametype+1)=(wormbeglives)
-  ld  a,(Gametype) ;&&&
-  cp  3
-  ld  a,(hl)
-  ret nc ;change lives
-  pop hl ;restore stack
-  jr  _mainMenu ;singleplayer (no limit)
 
 changelevel:
-  ld  hl,Gametype
-  ld  d,0
-  ld  e,(hl)
-  ld  hl,nrlevels
-  add hl,de
-  ld  d,(hl) ;max level for sel.game
-curlevel =$+1
-  ld  a,1
-  cp  d
+  inc hl ;hl=loadgamecar+2
+  psh hl
+  ld  a,(hl) ;(curlevel)
+  cal getnrlevels
+  cp  (hl) ;max level for sel.game
+  pop hl
   jr  z,_mainMenu
   inc a
 changedlevel:
-  ld  (curlevel),a
+  ld  (hl),a
   jr  dispmenusets ;mainMenu
 bchangelevel:
-  ld  a,(curlevel)
+  inc hl
+  ld  a,(hl) ;(curlevel)
   dec a
   jr  nz,changedlevel
   jr  _mainMenu
 
+getnrlevels: ;for current gametype at hl
+  ld  hl,Gametype
+  ld  d,0
+  ld  e,(hl)
+  ld  hl,nrlevels
+  add hl,de
+  ret
+
 getcustomkey:
   cal _vputs
   dec ix
 waitcustomkey:
-  halt \ halt
   psh hl
-  cal GET_KEY
+  cal ubergetkey
   pop hl
   or  a
   jr  z,waitcustomkey
@@ -595,20 +913,7 @@ changekeys:
 ;---display current settings---
 
 dispmenusets:
-  ld  hl,$FD97 ;begin pos
-  ld  de,7 ;bytes to add
-  ld  a,35 ;nr of lines
-clroldsettings:
-  ld  c,9 ;bytes to clear
-clroldsetsloop:
-  ld  (hl),d ;=0
-  inc hl
-  dec c
-  jr  nz,clroldsetsloop
-  add hl,de
-  dec a
-  jr  nz,clroldsettings
-
+  cal clrold
   ld  de,$183E
   ld  (_penCol),de
   ld  d,0
@@ -623,34 +928,41 @@ clroldsetsloop:
   ld  (CURtxtGame),hl ;save for g/o
   cal _vputs ;Singleplayer
 
-  ld  hl,$1E3E ;level
+  ld  hl,$2A3E ;worms
   ld  (_penCol),hl
-  ld  a,(curlevel)
-  cal cshowA
-
   cal loadgamecar
   psh hl
-  ld  hl,$243E
-  ld  (_penCol),hl
-  cal cshowA ;liveslimit
-  sub '0' ;original A
-  ld  l,a
-  ld  a,c
-  and _datascore
-  ld  a,' '
-  jr  z,limitok
-  ld  a,'0'
-limitok:
-  cal _vputmap ;x10
-
-  ld  hl,$2A3E ;worms
-  ld  (_penCol),hl
-  pop hl ;cal loadgamecar
   inc hl
   ld  a,(hl)
   add a,'0'
   cal _vputmap
 
+  ld  hl,$243E
+  ld  (_penCol),hl
+  rr  c ;(gameCar)
+  ld  hl,txtNo
+  jr  nc,displink
+  ld  hl,txtYes
+displink:
+  cal _vputs
+
+  ld  hl,$1E3E ;level
+  ld  (_penCol),hl
+  pop hl ;loadgamecar
+  psh bc
+  ld  d,0
+  cal hlatlevel
+  ld  a,(Gametype)
+  or  a ;gamesingle
+  jr  nz,displvlname
+  ld  a,(Level)
+  cal cshowA0
+  jr  lvldisped
+displvlname:
+  cal _vputs
+lvldisped:
+  pop bc
+
   ld  hl,$3032
   ld  (_penCol),hl
   ld  a,1
@@ -660,13 +972,13 @@ curworm =$-1
   ld  hl,$303E
   ld  (_penCol),hl
   cal getwormname
-  ld  hl,worm1name-18
-  add hl,de
+  psh ix ;wormNname
+  pop hl ;ld hl,ix
   cal _vputs
   ld  hl,$363E ;controls
   ld  (_penCol),hl
-;  ld  hl,txtMenu
-;  cal _vputs
+  ld  hl,txtMenuR
+  cal _vputs
   jp  mainMenu
 
 ;--- handle menukeys ---
@@ -674,8 +986,7 @@ curworm =$-1
 menucall:
   psh bc
 menuwaitkey:
-  halt \ halt
-  cal GET_KEY
+  cal ubergetkey
   or  a
   jr  z,menuwaitkey
   pop bc ;GET_KEY destr. b
@@ -750,62 +1061,53 @@ getwormname: ;of (curworm)
   ret
 
 changeworms:
-  cal _clrWindow
-  ld  hl,txtEName
-  cal _puts ;"Enter name player "
-  ld  a,(curworm)
-  add a,'0'
-  cal _putc
-
   cal getwormname
+  psh ix
+  pop hl ;ld hl,ix
+  psh hl
+  ld  b,8
+emptyname:
+  ld  (hl),' '
+  inc hl
+  dnz emptyname
   ld  a,maxnamelength
-  cal entername
-  ld  (ix),0 ;end mark
-  jp  DisplayMenu
-
-entername:
-  ld  h,1
-  ld  l,h ;)
-  ld  (_curRow),hl
   ld  (namelength),a
 enternameloop:
+  ld  hl,$FF07 ;begin pos
+  ld  a,6 ;nr of lines
+  cal clroldcustom
+  ld  hl,$303E
+  ld  (_penCol),hl
+  pop hl
+  psh hl
+  ld  (ix),0
+  cal __vputs
+  ld  (ix),' '
   ld  a,'_'
-  cal _putc
-  ld  hl,_curCol
-  dec (hl)
+  cal __vputmap
 nokeypressed:
-  halt
-  cal GET_KEY
+  cal ubergetkey
   or  a
   jr  z,nokeypressed
 
+  ld  hl,namelength
   cp  K_DEL
   jr  nz,continue
 backspace:
-  ld  hl,namelength
   ld  a,(hl)
   cp  maxnamelength
   jr  nc,nokeypressed
   inc (hl)
-
   dec ix
-  ld  a,' '
-  ld  (ix),a
-  cal _putc
-  ld  hl,_curCol
-  dec (hl)
-  dec (hl)
   jr  enternameloop
 continue:
   cp  K_ENTER
-  ret z
+  jr  z,nameentered
   cp  K_EXIT
-  ret z
-
-  ld  hl,namelength
-  dec (hl)
-  ret z
+  jr  z,nameentered
 
+  dec (hl) ;(namelength)
+  jr  z,nameentered
   ld  hl,chartable
   ld  e,a
   ld  d,0
@@ -813,14 +1115,11 @@ continue:
   ld  a,(hl)
   or  a
   jr  z,nokeypressed
-
   ld  (ix),a
-  cal _putc
   inc ix
   cal releasekeys
   jr  enternameloop
 
-
 chartable:
   .db 0,".<>!",0,0,0,0  ;down,L,R,up
   .db 0,"XTOJE0",0      ;enter..clear
@@ -830,9 +1129,70 @@ chartable:
   .db $D9,"-PKFA6'"     ;on..alpha
   .db "54321*",0,$D0    ;F5..more
 
+nameentered:
+  pop ix ;stringbegin
+  ld  (ix+8),0 ;end mark
+  jp  DisplayMenu
+
 ;--proc
 
+ubergetkey:
+  halt ;woo hoo
+  halt ;save them batteries! yeah!
+  jp  GET_KEY
+
+clrold:
+  ld  hl,$FD97 ;begin pos
+  ld  a,35 ;nr of lines
+clroldcustom:
+  ld  de,7 ;bytes to add
+clroldsettings:
+  ld  c,9 ;bytes to clear
+clroldsetsloop:
+  ld  (hl),d ;=0
+  inc hl
+  dec c
+  jr  nz,clroldsetsloop
+  add hl,de
+  dec a
+  jr  nz,clroldsettings
+  ret
+
+hlatlevel: ;d must be 0
+  psh hl ;loadgamecar
+  ld  a,(Gametype) ;8bytes -> 7bytes
+  ld  e,a
+  add a,a ;nc
+  add a,e
+  add a,a ;8->2bytes
+  add a,24+1 ;go to datalevels
+  ld  e,a ;=de
+  sbc hl,de ;datalevels
+  cal _ldHLind ;ld hl,(hl)
+  pop de ;de=loadgamecar
+  inc de \ inc de
+  ld  a,(de) ;(curlevel)
+  ld  (Level),a
+  ld  d,a ;begin level
+skiplevelloop:
+  dec d ;levels to skip
+  ret z
+  cal skiplevel
+  jr  skiplevelloop
+  ret ;hl=begin of correct level
+
+skiplvltitle: ;zf=singleplayer
+  ld  a,(hl)
+  or  a ;null-terminator
+  inc hl
+  jr  nz,skiplvltitle
+  ret
+
 skiplevel: ;@hl - destr:ab - alter:hl
+  ld  a,(Gametype)
+  or  a ;gamesingle
+  psh af
+  cal nz,skiplvltitle
   inc hl
   inc hl
   inc hl
@@ -845,8 +1205,7 @@ skipsprite:
   ld  b,(hl) ;balls
   inc b
   inc b ;skip 6
-  ld  a,c
-  cp  _datasp
+  pop af ;cp (Gametype),0
   jr  z,skipworms
   inc b ;multiplayer lvl
   inc b
@@ -883,15 +1242,15 @@ skipobjects:
 
 loadgamecar:
 ;in:    (Gametype)
-;out:   Gametype+1=hl
+;out:   hl=dataTYPE
 ;build: c=(gameCar)=(hl-1)
 ;       a=(wormbeglives)=(hl)
 ;destr: acdehl
   ld  hl,datasingle
   ld  a,(Gametype)
-  ld  e,a
   add a,a
-  add a,e
+  add a,a
+  add a,a ;8 bytes per mode
   ld  e,a
   ld  d,0
   add hl,de
@@ -912,43 +1271,35 @@ LetsGetThisPartyOn:
   ld  (CheckExit),a ;set exit state
 
   cal loadgamecar
-  ld  b,a ;psh a
+  psh hl
+  ld  (wormbeglives),a
   inc hl ;nrworms
   ld  a,(hl)
   ld  (nrworms),a
-  ld  l,b ;pop a
-  ld  h,0             ;hl=a
-  cal _HLTIMES10      ;hl=10*(hl)
-  ld  (scorelimit),hl ;set limit
-
-  cal loadgamecar ;nc
-  ld  a,(Gametype) ;3bytes -> 2bytes
-  add a,24+1 ;go to datalevels
-  ld  e,a ;=de
-  sbc hl,de ;datalevels
-
-  ld  a,c ;(gameCar)
-  and _datascore
-  jr  nz,scorelimitset
-  dec a ;ld a,$FF ;=no_limit
-  ld  (scorelimit),a
-scorelimitset:
+  inc hl ;level
+  inc hl
+  ld  a,(hl)
+  ld  (customspeed),a
+  inc hl
+  ld  a,(hl)
+  ld  (growspeed),a
+  inc hl
+  ld  a,(hl)
+  ld  (turnleft),a
+  ld  (turnright),a ;more efficient
+  inc hl
+  ld  l,(hl)
+  ld  h,0
+  cal _HLTIMES10       ;hl=10*(hl)
+  ld  (scorelimit),hl
 
-  cal _ldHLind ;ld hl,(hl)
-  ld  a,(curlevel)
-  ld  (Level),a
-  ld  d,a ;begin level
-skiplevelloop:
-  dec d ;levels to skip
-  jr  z,levelsskipped
-  cal skiplevel
-  jr  skiplevelloop
-levelsskipped:
+  pop hl ;loadgamecar
+  cal hlatlevel
 
   psh hl  ;1st level
-  ld  a,c
-  and _datalink
-  jr  z,GameOver
+  ld  a,(gameCar)
+  rra ;and _datalink
+  jr  nc,GameOver
 
 linkmatch:
   cal _clrWindow
@@ -961,22 +1312,23 @@ linkmatch:
   cp  wormVclient
   jr  z,client
   cp  wormVhost
-  jr  nz,linkiniterror
+  jr  z,host
+  pop hl ;error
+  jp  DisplayMenu ;return to menu
+
 host:
   ld  c,wormVclient
   cal Qsend
   ld  a,$18
   jr  multiplayer
-
-linkiniterror:
-  pop hl
-  jp  DisplayMenu
-
 client:
   ld  hl,txtReceive
   cal _puts
   ld  a,$E6
 multiplayer:
+;  cal linkok
+;  ld a,D0LD1L
+;  out (7),a
   ld  (SwapPos),a
   ld  a,2
   ld  (nrworms),a
@@ -986,21 +1338,19 @@ multiplayer:
 ;-----------------------------
 
 GameOver:
-  ld  a,%11000000
-  out (7),a ;link normal
-  cal _clrLCD
   ld  hl,worm1set
   ld  de,worm1
   ld  a,4 ;4x (all worms)
 createwormsloop:
   ex  de,hl
-  ld  bc,died
+  ld  bc,died ;8
   add hl,bc
-  ld  (hl),0 ;died=0
+; ld  b,0
+  ld  (hl),b ;died=0
   inc hl
-  ld  (hl),0 ;score=0
+  ld  (hl),b ;score=0
   inc hl
-  ld  (hl),0 ;score+1=0
+  ld  (hl),b ;score+1=0
   inc hl
   ld  (hl),2 ;delay=2
   inc hl
@@ -1013,17 +1363,17 @@ wormbeglives =$-1
   dec a      ;loop
   jr  nz,createwormsloop
 
-  pop hl ;begin of current level
-
 StartLevel:
-  ld  de,Left
+  cal _clrWindow
+  pop hl ;begin of current level
   ld  a,(hl)
   inc a ;=255?
   jp  nz,nextlevel
 
   psh hl
+  ld  hl,Level
+  dec (hl) ;curlevel-- (not beyond last lvl)
   cal releasekeys
-  cal _clrWindow
   pop hl
 ;show end msg or smtn
   ld  bc,Exit
@@ -1031,9 +1381,23 @@ StartLevel:
   inc hl   ;location of ending-code
   jp  (hl) ;go there ("call")
 nextlevel:
+  ld  a,(Gametype)
+  or  a ;gamesingle
+  psh af
+  cal nz,skiplvltitle
+  ld  de,Left
   ldi
   ld  de,Speed
-  ldi
+  ld  a,0
+customspeed =$-1
+  inc a ;$FF=def
+  jr  nz,setspeed
+  ld  a,(hl) ;speed from level
+  inc a
+setspeed:
+  dec a
+  ld  (de),a ;custom speed
+  inc hl
   ld  de,peagrowth
   ldi
   ld  a,(hl)
@@ -1083,67 +1447,78 @@ toobad_noballs:
 #endif
 
   ld  hl,worm1
-  ld  a,(gameCar)
-  cp  _datasp
+  pop af ;cp (Gametype),0
   ld  b,1
   jr  z,worminit
   ld  b,4
 worminit:
-  psh bc                        ; >> 1
+  psh bc ;>1
   ex  de,hl
-  ldi          ;d
+  ldi        ;d
   ld  a,SinCosTable/256
   ld  (de),a
   inc de
-  ldi          ;y
-  ldi          ;x
+  ldi        ;y
+  ldi        ;x
   ex  de,hl
-
   xor a
-  ld  (hl),a   ;y2
+  ld  (hl),a ;y2
   inc hl
-  ld  (hl),a   ;x2
+  ld  (hl),a ;x2
 
   ld  bc,(worm2-worm1)-5
   add hl,bc
-  pop bc                         ; << 0k
+  pop bc ;<0
   dnz worminit
 
+  inc a ;ld a,1
+  ld  (turn10),a
+  inc a ;ld a,2
+  ld  (flashtime),a
+
 ;-------- draw level ---------
 
   ld  a,(de)
   inc de
   sub 128
+  jr  nc,setfieldx
+  xor a ;fieldx<128
+setfieldx:
   ld  (FieldWidth),a
   ld  a,(de)
   inc de
+  ld  l,a
   sub 57
+  jr  nc,setfieldy
+  xor a ;fieldy<57
+setfieldy:
   ld  (FieldHeight),a
-  add a,57-5
   psh de                        ; >> levelp
+  ld  a,l ;pop
+  sub 5
   ld  l,a
   ld  h,0
   add hl,hl
   add hl,hl
   add hl,hl
   add hl,hl
-  add hl,hl
+  add hl,hl ;32=scr.width
   ex  de,hl
 
   ld  hl,ScrBuffer
   psh hl                        ; >> 1
   psh de                        ; >> 2
   ld  de,ScrBuffer+1
-  ld  bc,63
+  ld  bc,63 ;first 2 rows
   ld  (hl),%11111111
-  ldir
+  ldir ;draw upper border
   inc hl
-  ld  (hl),%11000000
+  ld  (hl),%11000000 ;first left border
   inc hl
   ld  b,31
 ClearLine:
-  ld  (hl),c
-  inc hl
+  ld  (hl),c ;=0
+  inc hl ;clear rest of line
   dnz ClearLine
   psh hl                        ; >> 3
 
@@ -1155,12 +1530,12 @@ ClearLine:
   rra
   rra
   ld  l,a
-  ld  h,0
+  ld  h,c ;0
   add hl,de
   pop af                         ; << 3
   and %00000111
   ld  b,a
-  ld  c,0
+; ld  c,0
   ld  a,%11000000
   jr  z,NoVertShift
 VertShift:
@@ -1183,22 +1558,25 @@ NoVertShift:
 
   pop hl                         ; << levelp
   ld  a,(Gametype)
-  cp  gamectf
-  jr  nz,noctf
+  cp  gamerace ;or gamectf
+  jr  c,levelhasbeensetup
   ld  de,peaspos
-  ld  bc,4
+  ld  c,2 ;ld bc,2 (2 bytes)
+  jr  z,loadextralevelstuff ;cp gamerace
+  ld  c,4 ;ld bc,4 (2nd flag in ctf)
+loadextralevelstuff:
   ldir
-  psh hl
-  cal DrawAllPeas
-  pop hl
-noctf:
+  ld  a,1 ;draw delay
+  ld  (drawctfpea1),a
+  ld  (drawctfpea2),a
+levelhasbeensetup:
 
   cal drawstuff
 
 ;-----------------------------
 
   psh hl                        ; >> levelp new
-  cal showstats
+  cal forceshowstats
   ld  a,(gameCar)
   and _datafood
   jr  z,nofood
@@ -1242,18 +1620,53 @@ maskline:
 
   ld  a,0
 gameCar =$-1
-  and _datalink
-  jr  z,initfinished ;no link
+  rra ;and _datalink
+  jr  nc,initfinished ;no link
   xor a
-  ld  (Speed),a ;max.speed
 SwapPos: ;$18 xx -> $E6 xx
          ; jr xx -> and xx
   jr  sethost
 setclient:
-  ld  (worm1+left),a ;worm 1 via link
+  ld  (worm1+left),a ;worm 1...
+  ld  (worm3+left),a ;and worm 3 via link
+  ld  hl,worm1+name
+  ld  b,9
+  cal recvstuff
+  ld  hl,worm2+name
+  ld  b,9
+  cal sendstuff
   jr  initfinished
+sendstuff:
+  psh bc
+  ld  c,(hl)
+  inc hl
+  psh hl
+  cal Qsend
+  pop hl
+  pop bc
+  dnz sendstuff
+  ret
+recvstuff:
+  psh bc
+  psh hl
+  cal Qrecv
+  pop hl
+  ld  (hl),c
+  inc hl
+  pop bc
+  dnz recvstuff
+  ret
 sethost:
-  ld  (worm2+left),a ;worm 2 via link
+ halt
+ dnz sethost
+  ld  (worm2+left),a ;worm 2+4..
+  ld  (worm4+left),a ;..over link
+  ld  hl,worm1+name
+  ld  b,9
+  cal sendstuff
+  ld  hl,worm2+name
+  ld  b,9
+  cal recvstuff
 initfinished:
 
   ld  b,startdelay
@@ -1267,8 +1680,13 @@ ReadyDelay:
 ;-----------------------------
 
 GameLoop:
-  ld  bc,(worm1+pos)
-  cal DisplayField
+  ld  bc,(worm1+pos) ;camera worm #1
+  ld  a,(worm1+left)
+  or  a ;if #1 not over link
+  jr  nz,showfield
+  ld  bc,(worm2+pos) ;otherwise view from #2
+showfield:
+  cal DisplayField ;display piece of level
 
   ld  a,1
 flashtime =$-1
@@ -1282,7 +1700,7 @@ screeninvertloop:
   ld  (hl),a
   inc hl
   xor a
-  cp  h
+  cp  h ;end at >$FFFF
   jr  nz,screeninvertloop
 noflash:
 
@@ -1296,7 +1714,40 @@ Delay:
   jr  nz,Delay
 NoDelay:
 
-  ld  (handledworm),a ;=0
+  ld  (handledworm),a ;reset
+
+  ld  hl,turn
+  ld  a,(hl)
+  inc a ;-1
+  jr  z,nextturnok
+  dec (hl)
+  dec a ;0 (now <0)
+  jr  nz,nextturnok
+growspeed =$+1
+  ld  (hl),$FF
+nextturnok:
+
+  ld  a,(gameCar)
+  and _datatime
+  jr  z,nodispupdate
+  ld  hl,turn10
+  dec (hl)
+  jr  nz,nodispupdate ;just once every 10 turns
+  ld  (hl),10 ;reset counter
+  cal forceshowstats ;update score
+nodispupdate:
+
+  ld  a,(Gametype)
+  cp  gamectf
+  jr  nz,noctfpeas2draw
+  ld  de,drawctfpea1
+  ld  hl,(peaspos)
+  cal tryDrawPea ;pea#1
+  ld  de,drawctfpea2
+  ld  hl,(peaspos+2)
+  cal tryDrawPea ;pea#2
+noctfpeas2draw:
+
 
   ld  a,0
 nrballs =$-1
@@ -1314,7 +1765,7 @@ handleworms:
   add ix,bc
   pop bc
   ld  hl,handledworm
-  inc (hl) ;1..nrworms
+  inc (hl) ;0..nrworms-1
   dnz handleworms
 
 ;-----------------------------
@@ -1358,48 +1809,79 @@ handledworm =$-2
   inc hl
   ld  (ix+heading),a
   ld  a,(hl)
-  ld  (ix+pos),a
+  ld  (ix+pos),a ;y
   inc hl
   ld  a,(hl)
-  ld  (ix+pos+1),a
+  ld  (ix+pos+1),a ;x
+  xor a
+  ld  (ix+pos2),a ;y2
+  ld  (ix+pos2+1),a ;x2
 
   inc (ix+died)
   dec (ix+lives)
   psh af
   ld  de,10
-  cal DecScore
+  ld  a,(Gametype)
+  cp  gamectf ;ctf no death penalty
+  cal nz,DecScore
   pop af
   ret nz ;HandleWorm done
+  ld  a,(wormbeglives)
+  or  a ;0=no live limit
+  ret z ;don't end game
   ld  a,(gameCar)
-  and _datalivel
-  ret z
+  and _datatime
+  jr  z,anyworm ;quit at any worm's death
+  ld  a,(nrworms) ;timematch: all worms must've died
+  ld  b,a ;# of worms
+  ld  hl,worm1+lives-(worm2-worm1)
+  ld  de,worm2-worm1
+  xor a ;check for 0 lives
+checklives:
+  add hl,de ;next worm
+  cp  (hl) ;lives==0?
+  ret nz ;any >0: don't exit
+  dnz checklives
+anyworm:
   ld  a,$A7 ;exit@end of turn
   ld  (CheckExit),a ;set exit state
   ret ;finish turn
 #endif
 
 Exit:
+  cal releasekeys
   ld  sp,0 ;pop all
 SpSave = $-2
-  ld  a,D0HD1H
-  out (7),a
+  ld  a,D0LD1L
+  out (7),a    ;both wires low = game over signal
   cal _clrWindow
+#ifdef coolzgfx
+  ld  de,$FC30 ;(0,1)
+  ld  hl,wtWormy
+  ld  bc,16*7
+  ldir
+  ld  hl,$FC10
+  ld  b,16*11
+  cal menuinvloop ;invert
+  ld  hl,$FD80
+  cal hr ;menuinvloop w/ b=16
+  ld  hl,$FCE0
+  cal hr
+  ld  hl,_curRow
+  ld  (hl),2
+#else
   ld  hl,txtGO
   cal _puts
   ld  hl,$FC00
   ld  b,16*8
   cal menuinvloop ;invert
   inc h ;$FD80
-  ld  b,16
-  cal menuinvloop ;<hr>
+  cal hr ;menuinvloop w/ b=16
   ld  hl,$FCE0
-  ld  b,16
-  cal menuinvloop ;<hr>
-; ld  l,$74
-; ld  b,8
-; cal menuinvloop
+  cal hr
   ld  hl,_curRow
   inc (hl)
+#endif
   ld  hl,txtGame
 CURtxtGame =$-2
   cal _puts
@@ -1411,25 +1893,65 @@ CURtxtGame =$-2
   ld  (_penCol),de
   ld  hl,txtName
   cal _vputs ;Name
-  ld  a,$4F
+  ld  a,$3D
   ld  (_penCol),a
   cal _vputs ;Died    Score
   ld  de,$0004
   ld  (_curRow),de
 
+findwinner:
+  ld  hl,(worm1+score)
+  ld  (winnerscore),hl
+  ld  b,3 ;(nrworms)-1
+  ld  hl,worm2+score
+findwinnerloop:
+  psh hl
+  cal _ldHLind
+  ld  de,(winnerscore)
+  ld  a,h
+  cp  d
+  jr  c,nonewwinner ;h<d
+  jr  nz,newwinner  ;h>d
+  ld  a,e
+  cp  l
+  jr  nc,nonewwinner ;l<e
+newwinner:
+  ld  (winnerscore),hl
+nonewwinner:
+  pop hl
+  ld  de,worm2-worm1
+  add hl,de
+  dnz findwinnerloop
+
+  ld  a,(nrworms)
+  ld  b,a
+  cpl ;high value (>$FB)
+  ld  hl,worm1+died
+finddmwinner:
+  cp  (hl)
+  jr  c,nonewdmwinner
+  ld  a,(hl) ;less deaths
+nonewdmwinner:
+  ld  de,worm2-worm1
+  add hl,de
+  dnz finddmwinner
+  ld  (dmwinner),a
+
+;---display worms---
+
   ld  a,(nrworms)
   ld  b,a
   ld  hl,worm1+died
 displayWormStats:
   psh bc
-  psh hl
 
+  psh hl
   ld  bc,left-died
   add hl,bc ;+left
   xor a
   cp  (hl)  ;input=0 = link
   jr  nz,NoLinkIndic
-  ld  a,8
+  ld  a,9
   ld  (_curCol),a
   ld  a,$DC ;-O
   cal _putc
@@ -1439,23 +1961,42 @@ NoLinkIndic:
   inc hl
   inc hl ;+name
   cal _puts
-
   pop hl
+
   psh hl
   ld  a,13
   ld  (_curCol),a
   ld  a,(hl) ;worm+died
-  cal showA
+  cal showA0
   pop hl
-  psh hl
 
+  psh hl
+  ld  a,(Gametype)
+  cp  gamedeathm
+  jr  nz,nodmwinner ;deathmatch?
+  ld  a,0 ;winner's deaths
+dmwinner =$-1
+  cp  (hl) ;equals this worm?
+  scf ;jr nz,notwinner
+  cal z,iswinner
+nodmwinner:
+  jr  c,notwinner ;no singleplayer winners
+  inc hl ;worm+score
+  cal _ldHLind ;ld hl,(hl)
+  ld  de,0
+winnerscore =$-2
+  cal _cphlde ;==highest score..
+  cal z,iswinner
+notwinner:
   ld  a,16
   ld  (_curCol),a
+  pop hl
+  psh hl
   inc hl ;worm+score
-  cal _ldHLind ;ld hl,(hl)
-  cal showHL ;worm+score
-
+  cal _ldHLind
+  cal showHL
   pop hl
+
   ld  bc,worm2-worm1
   add hl,bc
   pop bc
@@ -1469,7 +2010,7 @@ checkhilevel:
   ld  a,(Level)
   cp  (hl)
   jr  c,hilevelcheckdone
-  ld  (hl),a    ;save local
+  ld  (hl),a ;save local
   ld  c,a
   ld  a,0
 hilvlposa =$-1
@@ -1480,45 +2021,55 @@ hilevelcheckdone:
 
   ld  a,(gameCar)
   and _datasingl
-
-  jr  z,hiscorecheckdone
+  jr  z,hiscorecheckdone ;no SP
 checkhiscore:
   cal loadhiscoreposinahl
-  cal _Get_Word_ahl ;de=old_hi
- psh de
- cal _RAM_PAGE_1 ;&&
- pop de
-  ld  hl,(worm1+score)
-
-  ld  a,h           ;New
-  cp  d             ;Old
-  jr  c,NotNewHigh  ;New<Old
-  jr  nz,newhigh    ;New>Old
-
-  ld  a,e           ;old
-  cp  l             ;new
-  jr  nc,NotNewHigh ;new<old
+  cal _SET_ABS_SRC_ADDR ;from ahl (lvlfile)
+  xor a
+  ld  hl,highsave
+  cal _SET_ABS_DEST_ADDR ;to local
+  ld  hl,5 ;5 bytes
+  cal _MM_LDIR_SET_SIZE ;get old score+name
+  cal _RAM_PAGE_1
 
-newhigh:            ;New>=Old
-  ex  de,hl
+  ld  de,(highsave)    ;de=prev. hiscore
+  ld  hl,(worm1+score) ;hl=worm1's score
+  cal _cphlde ;sub hl,de
+  jr  c,NotNewHigh ;new<old
+  jr  z,NotNewHigh ;new<=old
+newhigh:            ;New>Old
+  ld  (highsave),hl ;store new hiscore
+  ld  de,highsave+2 ;to
+  ld  hl,worm1+name ;from
+  ld  bc,3 ;3 chars
+  ldir ;store new hiname
   cal loadhiscoreposinahl
-  cal _Set_Word_ahl ;de->(ahl)
- cal _RAM_PAGE_1
+  cal _SET_ABS_DEST_ADDR ;to ahl
+  xor a
+  ld hl,highsave
+  cal _SET_ABS_SRC_ADDR ;from local
+  ld  hl,5
+  cal _MM_LDIR_SET_SIZE ;save new
+  cal _RAM_PAGE_1
+  ld  hl,_curRow
+  dec (hl)
+  cal iswinner
 
-NotNewHigh: ;de=current hiscore
-  ld  hl,$0807
-  ld  (_curRow),hl
+NotNewHigh:
+  ld  hl,$3149
+  ld  (_penCol),hl
   ld  hl,txthiscore
+  cal _vputs
+  ld  hl,$0C07
+  ld  (_curRow),hl
+  ld  hl,highsave+2
   cal _puts
-  ex  de,hl ;pop
+  ld  hl,(highsave)
   cal showHL
 hiscorecheckdone:
 
-  cal releasekeys
 waitkey:
-  halt
-  halt
-  cal GET_KEY
+  cal ubergetkey
   cp  K_ENTER
   jp  z,DisplayMenu
   cp  K_SECOND
@@ -1537,6 +2088,7 @@ waitkey:
 ;8Snaky   @    00 04820
 
 ExitNoStats:
+  cal linkok
   ld  hl,_asapvar
   rst 20h ;_ABS_MOV10TOOP1
   rst 10h ;_FINDSYM
@@ -1550,8 +2102,7 @@ ExitNoStats:
   ld  hl,savestart
   cal _SET_ABS_SRC_ADDR
   ld  hl,saveend-savestart
-  cal _SET_MM_NUM_BYTES
-  cal _mm_ldir
+  cal _MM_LDIR_SET_SIZE
 
   cal releasekeys
   res 4,(iy+9)
@@ -1560,37 +2111,37 @@ ExitNoStats:
   jp  _clrWindow
 
 loadhiscoreposinahl:
-  ld  a,(Level)
-  ld  b,a
-
-  ld  h,0            ;hl=
-  ld  a,(nrlevels+1) ;# peaworm lvls
-  add a,a
-  ld  l,a
-
+  ld  hl,0 ;for peaworm and singleplayer
   ld  a,(Gametype)
-  dec a
-  ld  c,a
-  dec a              ;z=(Gametype)=2
-  jr  z,tronhi
-  ld  l,h            ;hl=0
-tronhi:
-
-  xor a              ;ahl=0(+x)
-  psh bc
+  or  a ;Singleplayer?
+  jr  z,hi__
+  dec a ;peaworm?
+  jr  z,hi_
+  ld  a,(nrlevels+1) ;skip peaworm slots if tron mode
+hi_:
+  ld  bc,(Level)
+  add a,c
+  ld  b,a ;levels to skip (including 1 for singleplayer)
+  ld  de,5 ;to add per level
+addlevelposition:
+  add hl,de ;one word+3 bytes for name
+  dnz addlevelposition
+hi__:
+  xor a ;ahl=0(+hl)
   ld  bc,defhiscrpos
 hiscrposhl =$-2
   add hl,bc
-  pop bc
-  adc a,0
-hiscrposa =$-1       ;ahl=saveloc
-
-  inc c
-  ret z              ;(Gametype)=0
-addlevelposition:
-  cal _AHL_PLUS_2_PG3
-  dnz addlevelposition
+hiscrposa =$+1
+  adc a,0 ;ahl=saveloc
   ret
+highsave:
+  .db 0,0,"WOR ",0
+
+iswinner:
+  ld  a,10
+  ld  (_curCol),a
+  ld  a,'*'
+  jp  _putc ;..then put *
 
 ;-----------------------------
 ;----------- worm ------------
@@ -1648,10 +2199,6 @@ respawndue:
 saverespawncounter:
   ld  (ix+delay),a
   jr  inputcall
-;  ld  a,(ix+input)
-;  or  a
-;  jr  z,inlink
-;  ret
 
 chkkey: ;key=a
   dec a
@@ -1682,6 +2229,7 @@ inkeys: ;use jp not call!
   jr  nc,notright
   ld  a,l
   add a,8
+turnright =$-1
   ld  l,a
 notright:
   ld  a,(ix+right)
@@ -1689,6 +2237,7 @@ notright:
   ret nc
   ld  a,l
   sub 8
+turnleft =$-1
   ld  l,a
   ret
 inputcall:
@@ -1697,33 +2246,42 @@ inputcall:
   jr  z,inlink ;input by link
   cal inkeys ;input by keys
   ld  a,(gameCar)
-  and _datalink
-  ret z ;no link
+  rra ;and _datalink
+  ret nc ;no link
   ld  c,l ;send our keys
-  psh hl
-  cal Qsend ;Csend
-  pop hl
-  ret
+  jp  Qsend
 inlink:
-  psh hl
   cal Qrecv ;Crecv
-  pop hl
   ld  l,c
   ret
 
 ;------- handle worm ---------
 
 HandleWorm:
+  xor a
+  cp  (ix+lives)
+  jr  nz,alive
+  ld  a,(wormbeglives)
+  or  a
+  ret nz ;live limit
+alive:
   ld  a,(ix+delay)
   dec a
   jp  nz,respawncheck
 
-  ld  a,(Gametype)
-  cp  gametron
-  jr  nz,notron
-  ld  de,1
+  xor a
+  cp  0
+turn =$-1
+  jr  nz,nogrow
+  inc (ix+grow)
+nogrow:
+
+  ld  a,(gameCar)
+  and _datatime
+  jr  z,notimescore
+  ld  e,1
   cal IncScore
-notron:
+notimescore:
 
   ld  l,(ix+heading)
   cal inputcall
@@ -1806,11 +2364,13 @@ GotFour:
 Hitworm:
   ld  a,(gameCar)
   ld  h,a
+#ifdef optdie
   and _datadie
   cal z,checkhitotherworm
   ld  a,h
+#endif
   and _datamultpeas ;&&bit
-  jr  nz,multiple_peas
+  jr  nz,chkctfpeas
   ld  a,h
   and _datafood
   jp  z,WormDead ;no food
@@ -1829,7 +2389,7 @@ peagrowth =$-1
   ld  hl,Left
   dec (hl)
   psh af
-  ld  de,10
+  ld  e,10
   cal IncScore
   pop af
   jp  nz,Drawworm ;continue
@@ -1849,15 +2409,14 @@ peagrowth =$-1
   add hl,hl
   cal _HLTIMES10
   ex  de,hl
-  cal IncScore ;score+(40*level)
+  cal _IncScore ;score+(40*level)
   cal removeworm
   pop hl                         ; << call
   pop hl                         ; << call
-  pop hl                         ; << levelp new
   ld  (ix+delay),2
   jp  StartLevel
 
-chkpeahit: ;hl=peapos
+chkpeahit: ;bc=ownpos;hl=peapos (destr:ad)
   ld  a,(sprsize)
   inc a
   ld  d,a
@@ -1872,70 +2431,52 @@ chkpeahit: ;hl=peapos
   cp  d
   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:
+chkctfpeas:
   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,WormDead ;stopworm ;own pea hit
-
-  ld  a,e ;peek a (that's x86 asm for pop\push ;)
-  and %01
+  and %01 ;ourpea (0|1)
   jr  z,sel_otherpea
-  ld  hl,(peaspos+2) ;2nd pea
+  ld  hl,(peaspos+2) ;2nd pea ;&&&ex de,hl?
 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
+  jr  c,hitflag
+;no peas hit:
+  ld  a,e ;peek a (that's x86asm for pop\push ;)
+  bit 1,a ;%10 = carrying flag?
+  jp  z,WormDead ;if not just die
+  xor %11 ;drop flag
   ld  (ix+reserv),a
-  cal DrawPea ;restore own flag
-  jr  sillylabel ;inv both\die
+  psh af
+  cal WormDead
+  pop af ;which flag? (=and %1)
+  ld  hl,drawctfpea1 ;restore #1
+  jr  z,nottheotherflag
+  ld  hl,drawctfpea2 ;restore #2
+nottheotherflag:
+  ld  (hl),3 ;draw delay 3 turns
+  ret
+
+drawctfpea1: .db 0
+drawctfpea2: .db 0
 
 hitflag: ;correct pea hit
   ld  a,e ;pop a
-  xor %01 ;0=1;1=0
+  xor %11 ;invert flag taken + ownflag
   ld  (ix+reserv),a
-  cal flagtoken
+  and %10 ;just returned?
   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
+  jr  nz,Drawworm ;flag taken, continue game
+  psh hl
+  ld  e,20 ;flag captured+returned
+  cal IncScore
+  pop hl
+  ld  a,3 ;draw delay
+  ld  (drawctfpea1),a ;redraw..
+  ld  (drawctfpea2),a ;..both flags
+  jr  Drawworm
 
 ;-----------------------------
 
@@ -1960,26 +2501,33 @@ ChkWorm:
   ret ;z
 
 checkhitlapline:
-  ld  a,63
-  sub b
+  ld  a,(peaspos) ;63
+  sub b ;x==63
   jr  z,nextlaphalf
   inc a
   ret nz
 nextlaphalf:
-  ld  a,c
-  and 32 ;y>=32?
-  jr  nz,nolap
+  ld  a,(peaspos+1) ;yline
+  cp  c ;ypos
+  ld  a,1
+  jr  nc,checklap ;y>yline -> a=1
+  xor a ;y<yline -> a=0
+checklap:
   cp  (ix+reserv)
-  jr  z,nolap
+  ret z ;same as before
+  ld  (ix+reserv),a ;1st time
+  ld  e,a
+  ld  a,(handledworm)
+  and 1 ;group 0 (1,3) or 1 (2,4)
+  xor e
+  ret z ;(group 0 and y<yline) or (group 1 and y>yline)
   psh bc
-  ld  de,20
-  cal IncScore
+  ld  e,20
+  cal IncScore ;lap!
   pop bc
-  xor a
-nolap:
-  ld  (ix+reserv),a
   ret
 
+#ifdef optdie
 checkhitotherworm:
  .db  $dd,$7d ;ld a,lx
   cp  worm2&255
@@ -1999,6 +2547,7 @@ chkworm:
  pop ix
   ret z ;not hit
   pop bc ;call
+#endif
 stopworm:
   ld  bc,0
 previouspos =$-2
@@ -2016,14 +2565,13 @@ Drawworm:
   ld  b,(ix+pos+1)
 
   ld  a,(Gametype)
-  ld  d,a
   cp  gamerace
   cal z,checkhitlapline
 
   cal set4pixels
   dec c
-  ld  a,d
-  cp  gametron
+  ld  a,(growspeed)
+  or  a ;0=tron
   ret z ;keep tail in "Tron"
 
   ld  l,(ix+head)
@@ -2195,18 +2743,7 @@ Seed =$+1
   add a,2
   ret
 
-NewPea:
-  ld  a,(FieldWidth)
-  add a,127-4
-  cal randompos
-  ld  h,a
-  ld  a,(FieldHeight)
-  add a,56-4
-  cal randompos
-  ld  l,a
-  ld  (PeaY),hl
-
-CheckPea:
+CheckPea: ;@hl; destr:abcde
   ld  c,l
   ld  a,(sprsize)
   ld  e,a
@@ -2219,24 +2756,121 @@ chkloopx:
   cal FindPixel
   and (hl)
   pop hl
-  jr  nz,NewPea ;pixel found
+  ret nz ;nz=pixel found
   inc b
   dec d
   jr  nz,chkloopx
   inc c
   dec e
   jr  nz,chkloopy
-;all ok; empty space
+  ret ;z=empty space
+
+tryDrawPea: ;hl=peapos;bc=dopea
+  ld  a,(de)
+  or  a ;0=drawn
+  ret z
+  psh de
+  cal CheckPea
+  pop de
+  ret nz ;unsuccesful
+  ex  de,hl
+  dec (hl) ;hl=appeartime
+  ex  de,hl ;hl=peaspos
+  jr  z,DrawPea
+  ret
 
+NewPea:
+  ld  a,(FieldWidth)
+  add a,127-4
+  cal randompos
+  ld  h,a
+  ld  a,(FieldHeight)
+  add a,56-4
+  cal randompos
+  ld  l,a
+  ld  (PeaY),hl
+  cal CheckPea
+  jr  nz,NewPea
 DrawPea: ;hl=(PeaY)
   ld  b,h
   ld  c,l
   ld  de,0
 spritepos =$-2
-  jp  PutSprite ;||-ed
+; jp PutSprite
+
+PutSprite:  ;||@(b,c)
+  ;by SHIAR  only ix saved
+  cal FindPixel
+  ld  (beginbit),a
+  ld  a,0
+sprsize =$-1
+  ld  b,a ;rows
+sprloopy:
+  psh bc ;rows
+  psh hl
+  ld  a,(de)
+  ld  c,a
+  inc de
+  ld  a,(sprsize)
+  ld  b,a ;width
+beginbit =$+1
+  ld  a,1
+sprloopx:
+  sla c ;draw?
+  jr  nc,sprnodraw
+  psh af
+  xor (hl)
+  ld  (hl),a
+  pop af
+sprnodraw:
+  rrca ;next bit
+  jp  nc,nextbitok
+  inc hl ;next byte
+nextbitok:
+  dnz sprloopx
+
+  pop hl
+  ld  bc,32 ;next line
+  add hl,bc
+  pop bc
+  dnz sprloopy
+  ret
 
 ;----------- score -----------
 
+timematchscore: ;piece of crap checking whether you've already won in timematch
+  ld  a,(nrworms)
+  ld  b,a ;# of worms
+  ld  hl,worm1+lives
+  ld  de,worm2-worm1
+  ld  a,(handledworm)
+  ld  c,a ;wormcounter
+chktimematchover:
+  xor a
+  cp  c
+  jr  z,nneexxtt ;yourself
+  cp  (hl)
+  ret nz ;someone else still alive
+  dec hl ;+delay
+  dec hl ;+score+1
+  ld  a,(hl)
+  cp  (ix+score+1)
+  jr  c,nneexxtt_ ;you>him
+  ret nz ;not highest
+  dec hl ;+score
+  ld  a,(hl)
+  cp  (ix+score)
+  ret nc ;you<=him
+  inc hl
+nneexxtt_:
+  inc hl
+  inc hl
+nneexxtt:
+  dec c
+  add hl,de
+  dnz chktimematchover
+  jp  anyworm ;g/o
+
 _divHLby1000:
   psh hl
   ld  b,3
@@ -2247,39 +2881,55 @@ divideagain: ;3x
   pop hl
   ret
 
-IncScore:
-  ld  h,(ix+score+1)
-  ld  l,(ix+score)
+extralives:
   cal _divHLby1000
   ld  c,a
-  add hl,de
+  add hl,de ;increase score
   cal _divHLby1000
   cp  c
   jr  z,scorecommon ;hl/1000 not increased
   inc (ix+lives)
   jr  scorecommon
+
 DecScore: ;&&&
   ld  h,(ix+score+1)
   ld  l,(ix+score)
   or  a
   sbc hl,de
   jr  c,showstats ;<0=0
+  jr  scorecommon
+
+IncScore: ;inc score by e
+  ld  d,0
+_IncScore ; inc by de
+  ld  h,(ix+score+1)
+  ld  l,(ix+score)
+  ld  a,(Gametype)
+  or  a ;if singleplayer...
+  jr  z,extralives
+  add hl,de ;score+=de
 scorecommon:
   ld  (ix+score+1),h
-  ld  (ix+score),l
+  ld  (ix+score),l ;save
   ld  de,0
 scorelimit =$-2
-  inc e
-  jr  z,showstats ;de=$FF??=no limit
-  dec e
+  ld  a,d
+  or  e
+  jr  z,showstats ;de=0=no limit
   cal _cphlde
   jp  nc,Exit
 
 showstats:
-  ld  a,(Gametype)
-  cp  gametron
-  ret z
-showstatsEven4tron:
+  ld  a,(gameCar)
+  and _datatime
+  jr  nz,timematchscore ;no disp for timematches
+  ld  hl,$FC00 ;&&&only necessary in deathmatch
+  ld  b,6*16-1 
+clearstats:
+  ld  (hl),a ;=0
+  inc hl
+  dnz clearstats
+forceshowstats:
   psh ix
   ld  h,0
   ld  l,h
@@ -2288,51 +2938,56 @@ showstatsEven4tron:
   ld  b,a
   ld  ix,worm1
   ld  a,(gameCar)
-  and _datanextl
+  and _datasingl
   jr  nz,showstatsS
 showstatloop:
   psh bc
+#ifdef longnames
+  ld  b,3
+  psh ix
+shownameloop: ;1st 3 chars
+  ld  a,(ix+name)
+  or  a
+  jr  z,nameshown
+  cal __vputmap
+  inc ix
+  dnz shownameloop
+nameshown:
+  ld  a,':'
+  cal _vputmap
+  pop ix
+#else
+  ld  a,(ix+name)
+  cal __vputmap
+  ld  a,':'
+  cal __vputmap
+#endif
   cal showstat
   ld  de,worm2-worm1
-  add ix,de
+  add ix,de ;next
   ld  hl,_penCol
   ld  a,(hl)
-  add a,10
+  add a,4 ;div
   ld  (hl),a
   pop bc
   dnz showstatloop
   pop ix
   ret
 
-showstat:
-  ld  a,(gameCar)
-  and _datascore
+showstat: ;(multiplayer)
+  ld  a,(Gametype)
+  cp  gamedeathm
   jr  z,showlives
 showscore:
   ld  h,(ix+score+1)
   ld  l,(ix+score)
   cal _D_HL_DECI
-  jr __vputs
+  jr  __vputs
 showlives:
-  ld  a,(Gametype)
-  cp  gametron
-  jr  z,showscore
-
   ld  a,(ix+lives)
-  add a,'0'
-__vputmap:
-  psh ix
-  cal _vputmap
-  pop ix
-  ret
-
-showstatsS:
-  ld  hl,txtLevel
-  cal __vputs
-  ld  a,0
-Level =$-1
+showA: ;small w/o leading 0 (&&&combine w/ cshowA0??)
   cp  10
-  jr  c,tilllevel9
+  jr  c,showleastsign
   ld  l,a
   ld  h,0
   cal _divHLby10
@@ -2341,9 +2996,20 @@ Level =$-1
   add a,'0'
   cal __vputmap
   pop af
-tilllevel9:
+showleastsign:
   add a,'0'
-  cal __vputmap
+__vputmap:
+  psh ix
+  cal _vputmap
+  pop ix
+  ret
+
+showstatsS: ;(singleplayer)
+  ld  hl,txtLevel
+  cal __vputs
+  ld  a,0
+Level =$-1
+  cal showA
 
   ld  a,98
   ld  (_penCol),a
@@ -2360,7 +3026,7 @@ showleft:
   ld  (_penCol),a
   ld  a,0
 Left =$-1
-  cal cshowA
+  cal cshowA0
 
   ld  hl,txtLeft
 __vputs:
@@ -2373,7 +3039,7 @@ showLevel:
   ld  hl,txtLevel
   cal _puts
   ld  a,(Level)
-showA:
+showA0: ;big w/ leading 0
   ld  l,a
   ld  h,0
   cal _divHLby10
@@ -2385,7 +3051,12 @@ showA:
   add a,'0'
   jp  _putc
 
-cshowA:
+cshowA0: ;small w/ leading 0
+  or  a
+  jr  nz,cshowavalue
+  ld  hl,txtNone
+  jp  _vputs
+cshowavalue:
   ld  l,a
   ld  h,0
   cal _divHLby10
@@ -2694,47 +3365,6 @@ FP_Bit =$+1
   pop de
   ret
 
-;--- sprite ---
-
-PutSprite:  ;||@(b,c)
-  ;by SHIAR  only ix saved
-  cal FindPixel
-putspr:
-  ld  (beginbit),a
-  ld  a,0
-sprsize =$-1
-  ld  b,a ;rows
-sprloopy:
-  psh bc ;rows
-  psh hl
-  ld  a,(de)
-  ld  c,a
-  inc de
-  ld  a,(sprsize)
-  ld  b,a ;width
-beginbit =$+1
-  ld  a,1
-sprloopx:
-  sla c ;draw?
-  jr  nc,sprnodraw
-  psh af
-  xor (hl)
-  ld  (hl),a
-  pop af
-sprnodraw:
-  rrca ;next bit
-  jp  nc,nextbitok
-  inc hl ;next byte
-nextbitok:
-  dnz sprloopx
-
-  pop hl
-  ld  bc,32 ;next line
-  add hl,bc
-  pop bc
-  dnz sprloopy
-  ret
-
 ;--- objects ---
 
 drawstuff:
@@ -2752,19 +3382,85 @@ drawstuff:
   psh hl
   ld  l,(hl)
   ld  h,b
+  cal drawsmtn
+  pop hl
+  inc hl
+  jr  drawstuff
 
+drawsmtn:
   dec a ;1 = line
-  cal z,drawline
+  jr  z,drawline
   dec a ;2 = fatline
-  cal z,drawfatline
+  jr  z,drawfatline
   dec a ;3 = box
-  cal z,drawbox
-  dec a ;4 = circle
-  cal z,circle
+  jr  z,drawbox
+; dec a ;4 = circle
+; jp  z,drawcircle
+
+drawcircle: ;(d,e),h   ;de=x,y; h=z
+  ld  c,h              ;c=yy=z
+  ld  a,h
+  neg
+  ld  l,a              ;l=-z
+  xor a
+  ld  b,a              ;b=xx=0
+  dec a                ;-$00**
+  ld  h,a              ;hl=zz=-z
+circloop:
+  psh de               ;x,y
+  ex  (sp),hl          ;push zz \ pop x,y
+  cal circledraw       ;(x-xx,y+yy)-(x+xx,y+yy)
+                       ;(x-xx,y-yy)-(x+xx,y-yy)
+  cal circledraw       ;(x-yy,y+xx)-(x+yy,y+xx)
+                       ;(x-yy,y-xx)-(x+yy,y-xx)
+
+  ex  (sp),hl          ;push x,y \ pop zz
+  xor a
+  ld  d,a              ;d=0
+  dec a                ;-256<h<0 = $FF**
+  cp  h                ;h<0?
+  jr  z,circlenext     ;jump if zz<0
+
+  ld  a,c              ;yy
+  dec a                ;89<a<128
+  add a,a              ;a=2yy-2 ;nc
+  ld  e,a              ;de=a
+  sbc hl,de            ;zz=zz-2yy+2
+  dec c                ;yy--
+circlenext:
+  ld  a,b              ;xx
+  inc a                ;0<a<92
+  add a,a              ;2xx+2
+  inc a
+  ld  e,a              ;de=a
+  add hl,de            ;zz=zz+2xx+3
+
+  pop de               ;x,y
+  ld  a,b
+  cp  c
+  ret nc               ;xx>=yy
+  inc b                ;xx++
+  jr  circloop
 
+circledraw:            ;destr:de
+  psh hl
+  ld  a,h              ;hl=x,y
+  sub b                ;bc=xx,yy
+  ld  d,a              ;d=x-xx
+  add hl,bc            ;h=x+xx; l=y+yy
+  ld  e,l              ;e=y+yy
+  cal drawline         ;(h-b,l+c)-(h+b,l+c)
+  ld  a,l
+  sub c                ;a=y again
+  sub c
+  ld  l,a              ;l=y-yy
+  ld  e,l              ;e=l=y-yy
+  cal drawline         ;(h-b,l-c)-(h+b,l-c)
+  ld  a,b              ;swap xx and yy
+  ld  b,c
+  ld  c,a              ;ex b,c
   pop hl
-  inc hl
-  jr  drawstuff
+  ret
 
 drawbox: ;(d,e)-(h,l)
   ld  b,l ;Delta-y
@@ -2786,13 +3482,13 @@ drawfatline:
   cal drawline
   dec d
   dec h
-  jp  drawline
+; jp  drawline
 
 ;LINE (d,e)-(h,l)
 ;destroyes a
 
-drawline:
-  psh bc
+drawline: ;(d,e)-(h,l)
+  psh bc  ;destr: a
   psh hl
   psh de
   ld  a,d
@@ -2892,242 +3588,55 @@ line4sm:
   dnz LineLoopSteep
   jr  DoneLine
 
-;CIRCLE (d,e),h
-;destroyes ?
-
-circle:                ;de=x,y; h=z
-  ld  c,h              ;c=yy=z
-  ld  a,h
-  neg
-  ld  l,a              ;l=-z
-  xor a
-  ld  b,a              ;b=xx=0
-  dec a                ;-$00**
-  ld  h,a              ;hl=zz=-z
-circloop:
-  psh de               ;x,y
-  ex  (sp),hl          ;push zz \ pop x,y
-  cal circledraw       ;(x-xx,y+yy)-(x+xx,y+yy)
-                       ;(x-xx,y-yy)-(x+xx,y-yy)
-  cal circledraw       ;(x-yy,y+xx)-(x+yy,y+xx)
-                       ;(x-yy,y-xx)-(x+yy,y-xx)
-
-  ex  (sp),hl          ;push x,y \ pop zz
-  xor a
-  ld  d,a              ;d=0
-  dec a                ;-256<h<0 = $FF**
-  cp  h                ;h<0?
-  jr  z,circlenext     ;jump if zz<0
-
-  ld  a,c              ;yy
-  dec a                ;89<a<128
-  add a,a              ;a=2yy-2 ;nc
-  ld  e,a              ;de=a
-  sbc hl,de            ;zz=zz-2yy+2
-  dec c                ;yy--
-circlenext:
-  ld  a,b              ;xx
-  inc a                ;0<a<92
-  add a,a              ;2xx+2
-  inc a
-  ld  e,a              ;de=a
-  add hl,de            ;zz=zz+2xx+3
-
-  pop de               ;x,y
-  ld  a,b
-  cp  c
-  ret nc               ;xx>=yy
-  inc b                ;xx++
-  jr  circloop
-
-circledraw:            ;destr:de
-  psh hl
-  ld  a,h              ;hl=x,y
-  sub b                ;bc=xx,yy
-  ld  d,a              ;d=x-xx
-  add hl,bc            ;h=x+xx; l=y+yy
-  ld  e,l              ;e=y+yy
-  cal drawline         ;(h-b,l+c)-(h+b,l+c)
-  ld  a,l
-  sub c                ;a=y again
-  sub c
-  ld  l,a              ;l=y-yy
-  ld  e,l              ;e=l=y-yy
-  cal drawline         ;(h-b,l-c)-(h+b,l-c)
-  ld  a,b              ;swap xx and yy
-  ld  b,c
-  ld  c,a              ;ex b,c
-  pop hl
-  ret
-
-
-
-
-
-;**** link routines ****
-;these are identical in concept to the routines used in ZTetris, ZPong, and probably
-;every other link game out there.  However, these are commented :)
-losses: .dw 0
-Csend:
-  cal Qsend
-  jr  c,Csend
-  ret
-Qsend:
-send:
-;inputs: c=byte to send, both wires must be high by default
-;outputs: b=8-number of bits sent, both wires high, goes to game over on certain conditions
-;destroys: af,bc,de
-       in a,(7)
-       and %00000011
-       jr z,killlink           ;if both lines low, get out of here (game over signal)
-       ld b,8                          ;sending 8 bits
-sendloop:
-       ld de,$8000                     ;error timer
-       rl c                            ;force high bit into carry
-       ld a,%11010100          ;lower the red wire by default (sending 0) ($d4)
-       jr nc,selected          ;if high bit was 0, use above value
-       ld a,%11101000          ;if 1, lower the white wire instead ($e8)
-selected:
-       out (7),a                       ;put it out the link port
-waitconfirm:
-       call linktimer
-       in a,(7)                        ;see what the wires are doing
-       and %00000011           ;check lower 2 bits
-       jr nz,waitconfirm       ;if both bits 0, data was received ok (both wires low)
-       ld a,%11000000
-       out (7),a                       ;give the ok to raise both wires (one will be done automatically) ($c0)
-waitconfirm2:
-       call linktimer
-       in a,(7)
-       and %00000011
-       cp 3
-       jr nz,waitconfirm2      ;wait for other calc to raise the other wire
-       djnz sendloop           ;continue sending
-       xor a                           ;reset c; ld a,0
-       ld (losses),a           ;reset number of losses
-       ret
-
-
-Crecv:
-  cal receive
-  jr  c,Crecv
-  ret
-Qrecv:
-receive:
-;inputs: both wires must be high by default
-;outputs: c=byte received, b=8-number of bits received, both wires high
-;      goes to game over on certain conditions
-;destroys: af,bc,de
-       in a,(7)
-       and %00000011
-       jr z,killlink           ;game over signal applies to receiving too
-       ld b,8                          ;receiving 8 bits
-receiveloop:
-       ld de,$8000                     ;error timer
-waitreceive:
-       call linktimer
-       in a,(7)
-       and %00000011
-       cp 3                            ;if bits 0 and 1 set, both wires are high
-       jr z,waitreceive        ;wait for one of the wires to go low
-       rra                                     ;check red wire status
-       rl c                            ;if set, red is high (thus white is low), so put the correct bit into c
-       rra                                     ;now check white wire (since the flags are destroyed)
-       ld a,%11010100          ;$d4
-       jr nc,selected2         ;if white is low, lower red and vice versa              
-       ld a,%11101000          ;$e8
-selected2:
-       out (7),a                       ;so now both wires are low
-waitreceive2:
-       call linktimer
-       in a,(7)
-       and %00000011
-       jr z,waitreceive2       ;wait for the wire we didn't lower to go high again (the other will remain low)
-       ld a,%11000000          ;$c0
-       out (7),a                       ;raise both wires since the other calc will have given the ok sign
-       djnz receiveloop        ;if not done, wait for next bit
-       xor a                           ;reset c
-       ld (losses),a           ;reset number of losses
-       ret
-
-linktimer:                             ;leave if we have to wait too long (and return an error)
-       dec de
-       ld a,d
-       or e                            ;see if de is 0
-       ret nz                          ;if not, keep going as usual
-                                               ;otherwise we have to deal with a link failure
-       ld a,%11000000          ;$c0
-       out (7),a                       ;reset link status (both high)
-       ld a,(losses)           ;see how many consecutive losses we have
-       inc a
-       ld (losses),a           ;add this loss to it
-       pop de                          ;fix the stack to leave the link routine (de is ok to destroy)
-       cp 20                           ;see if this is the 20th consecutive failure
-       ret c                           ;if not, keep playing
-                                               ;otherwise, all is probably lost...
-
-killlink2:
-       jr linkend
-killlink:
-linkend:
-  jp  z,Exit
-
-
-
-
-
-
-
-
-
-#ifdef 0
 ;-----------------------------
 ;----------- link ------------
 ;-----------------------------
 
-timeout = $800
+linkok:
+  ld  a,D0HD1H
+  out (7),a    ;raise both wires = link ok
+  ret
 
-checklink:
-  dec de
+timeout = $8000
+lossout = 20
+
+checklink:             ;load wires in A and check for timeout
+  dec de               ;decrease timer
   ld  a,d
   or  e
-  jr  z,linkerror
-
-  ld  a,$BF
-  out (1),a
-  in  a,(1)
-  bit 6,a
-  jp  z,Exit
-
+  jr  nz,linkfine      ;ok if de>0
+;de==0 = timeout
+  cal linkok
+  ld a,0               ;losses so far
+linklosses =$-1
+  inc a                ;and this is another one
+  ld (linklosses),a
+  pop de               ;return from link
+  cp  lossout          ;quit if too many errors
+  ret c                ;otherwise just continue
+linkerr:
+  jp  Exit
+linkfine:
   in  a,(7)
   and %11
   ret
 
-linkerror:
-  scf
-  ld  a,%11
-  pop hl
-  ret
-
-;--------------
 ;---- SEND ----
-;--------------
 
-Csend:         ;--- send 8 bits in A --- destr:abcdehl ---
-  ld  c,a
-Csendloop:
+Csend:
+  ld  b,32
+csendwait:
+  nop
+  dnz csendwait
   cal Qsend
-  ret nc               ;NC = all ok
-  ld  a,D0HD1H
-  out (7),a            ;both high
-  jr  Csendloop        ;CF = error
+  jr  c,Csend
+  ret
 
-Qsend:         ;--- try to send 8 bits in C; CF=error --- destr:abcdehl ---
-  ld  de,timeout
-  cal checklink
-  cp  %11              ;are they?
-  scf
-  ret nz               ;nope, wait
+Qsend:         ;try to send 8 bits in C; CF=error --- destr:abcde
+  nop \ nop
+  in  a,(7)
+  and %11              ;both wires low = exit signal
+  jr  z,linkerr        ;error otherwise
   ld  b,8              ;bits to send
 sendloop:
   ld  de,timeout
@@ -3146,29 +3655,23 @@ sendfinish:
   cal checklink
   cp  %11              ;both raised (by other calc)
   jr  nz,sendfinish
-  nop \ nop
+; nop \ nop
   dnz sendloop         ;repeat for all bits
   xor a                        ;nc...
+  ld (linklosses),a    ;reset number of losses
   ret                  ;=ok
 
-;--------------
 ;---- RECV ----
-;--------------
 
 Crecv:         ;--- receive 8 bits into A/C --- destr:abcdehl ---
   cal Qrecv
   ret nc               ;return if all went ok
-  ld  a,D0HD1H
-  out (7),a            ;raise both on error
   jr  Crecv            ;and try again
 
-Qrecv:         ;--- receive 8 bits into A/C; CF=error --- destr:abcdehl ---
-  ld  de,timeout
-  cal checklink
-  jp  z,Exit           ;both low = error, quit
-  cp  %11
-  scf
-  ret z                        ;both high = nothing yet, wait
+Qrecv:         ;--- receive 8 bits into A/C; CF=error --- destr:abcde ---
+  in  a,(7)
+  and %11
+  jr  z,linkerr        ;both low = error, quit
   ld  b,8              ;bits to receive
 recvloop:
   ld  de,timeout
@@ -3191,9 +3694,9 @@ recvwaitack:
 recvfinish:
   dnz recvloop         ;repeat for all bits
   xor a                        ;nc=no error
-  ld  a,c              ;result in a
+  ld (linklosses),a    ;reset number of losses
   ret
-#endif
+
 
 ;-----------------------------
 ;---------- levels -----------
@@ -3204,82 +3707,116 @@ LevelDef:
   .db 0,2,63           ;start d, y, x
   .db 128,57           ;field width (128-255), height (57-255)
   .db 0                ;no additional lines, boxes
-  .db 255
-   ret
+
+  .db 255              ;last level
+   ret                 ;ending code
 
 LevelDefM:
+  .db "Empty Arena",0
   .db 8,4,15,15,0,0
   .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
   .db 128,57
   .db 0
 
+  .db "Fast Fun :))",0
   .db 8,0,18,12,5
   .db %1110000,%10001000,%10001000,%10001000,%1110000,0
   .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
   .db 128,57
   .db 0
 
+  .db "Two Circles",0
   .db 8,5,18,12,0,0
   .db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
   .db 128,57
- .db 4,40,26,20,0
- .db 4,90,40,11,0,0
 .db 4,40,26,20,0
 .db 4,90,40,11,0,0
 
 LevelDefT: ;tron=no delay
+  .db "Empty Tron Level",0
   .db 8,4,18,12,5
   .db %1110000,%10001000,%10001000,%10001000,%1110000,0
   .db $40,30,64,$C0,30,64, $00,30,64,$80,30,64
   .db 128,57
   .db 0
 
+LevelDefR: ;race
+  .db "Round and Round",0
+  .db 8,4,18,12,5
+  .db %1110000,%10001000,%10001000,%10001000,%1110000,0
+  .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125
+  .db 128,57
+  .db 63,27
+  .db 4,63,27,10,0,0
+
 LevelDefC: ;ctf
+  .db "Default CTF",0
   .db 8,4,18,12,5
   .db %1110000,%10001000,%10001000,%10001000,%1110000,0
-  .db $40,30,64,$C0,30,64, $00,30,64,$80,30,64
+  .db $40,23,2,$C0,23,125, $40,35,2,$C0,35,125
   .db 128,57
-  .db 10,10,50,50
+  .db 27,8,27,116
   .db 0
 
 ;-----------------------------
 ;---------- data -------------
 ;-----------------------------
 
-wdPicture = 16
 wtPicture:
-.db %01001010,%00101001,%00000111,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01110000,%00000000,%00000000,%00000000,%01000000,%00000000
-.db %10001010,%10101000,%10001111,%10000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01111000,%00000000,%00000000,%00000000,%10100100,%01000000
-.db %10101010,%10101010,%10011100,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00011100,%00001110,%00000000,%00000000,%10101010,%10100000
-.db %01010001,%01000101,%00011000,%00011111,%00000000,%01111111,%11000000,%00111100,%00011110,%01111000,%00001100,%00011111,%00000000,%00000000,%11001001,%10100000
-.db %00000000,%00000000,%00111000,%00111111,%10000000,%11111111,%11100000,%11111110,%00111111,%11111100,%00001100,%00111011,%10000000,%00000011,%10001000,%00100000
-.db %01101010,%10010011,%00110000,%01110001,%11000001,%11000000,%01110001,%11100110,%01110011,%11001110,%00001100,%00110001,%10000000,%00000000,%10010000,%00100000
-.db %10001010,%00101010,%10110000,%01100000,%11000001,%10000000,%00111001,%10000000,%01100111,%11100110,%00001110,%01110001,%10000000,%00000000,%01100000,%01000000
-.db %11101110,%10111011,%00110000,%01100000,%11000001,%10110000,%00011011,%10000000,%11101110,%01110111,%00001110,%01110001,%10000011,%11100000,%00000011,%10000000
-.db %00101010,%10101010,%10110000,%01110001,%11000001,%10110000,%00011011,%00000000,%11001100,%00110011,%00000111,%11100001,%10001100,%00011000,%00010000,%00000000
-.db %11001010,%10101010,%10110000,%00110001,%10000001,%10110000,%00011011,%00000000,%11001100,%00110011,%00000011,%11000011,%10010000,%00000100,%00100011,%00001100
-.db %00000000,%00000000,%00111000,%00111011,%10000011,%10110000,%00011011,%00000000,%11001110,%01110011,%00000000,%00000011,%00010011,%00000100,%00100100,%10010010
-.db %00111001,%11000111,%00011000,%00011111,%00000011,%00110000,%00011011,%00000000,%11000111,%11100011,%10000000,%00000011,%00001100,%10000100,%00101000,%10010100
-.db %01100101,%00101000,%00011100,%00001110,%00000111,%00111000,%00111011,%10000000,%11000011,%11000001,%10000000,%00000111,%00000000,%01001110,%00101000,%10011000
-.db %01001101,%11001011,%00001110,%00111111,%10001110,%00011100,%01110001,%10000000,%11100000,%00000001,%11100000,%00001110,%00000000,%01010101,%00101000,%10011000
-.db %00111001,%01100111,%00000111,%11111011,%11111100,%00001111,%11100001,%11000000,%01100000,%00000000,%11111111,%11111100,%00000000,%10010101,%00100110,%00010100
-.db %00000000,%00000000,%00000011,%11100000,%11111000,%00000111,%11000000,%11000000,%01100000,%00000000,%00111111,%11111000,%11111111,%00001000,%11000001,%11100011
+.db %00011110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%11000000,%00000000,%00000000,%00000001,%10000000,%00000000,%00001111,%10000000
+.db %00111110,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000001,%11100000,%00000000,%00000011,%11000010,%01000011,%10011100,%00110000,%01100000
+.db %01110000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01110000,%00111000,%00001100,%00110001,%00110100,%01100011,%01000000,%00010000
+.db %01100000,%01111100,%00000001,%11111111,%00000000,%11110000,%01111001,%11100000,%00110000,%01111100,%00010001,%11001001,%00001000,%00100000,%10000010,%00010000
+.db %11100000,%11111110,%00000011,%11111111,%10000011,%11111000,%11111111,%11110000,%00110000,%11101100,%00010001,%11000100,%10000001,%00000100,%10001110,%00001000
+.db %11000001,%11000111,%00000111,%00000001,%11000111,%10011001,%11001111,%00111000,%00110000,%11000110,%00001100,%00000010,%01100010,%10011100,%00010001,%00001000
+.db %11000001,%10000011,%00000110,%00000000,%11100110,%00000001,%10011111,%10011000,%00111001,%11000110,%00000011,%11000010,%00011100,%01100010,%00100001,%01101000
+.db %11000001,%10000011,%00000110,%11000000,%01101110,%00000011,%10111001,%11011100,%00111001,%11000110,%01111000,%00100001,%00000000,%00000001,%11000001,%01101000
+.db %11000001,%11000111,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00011111,%10000110,%10000101,%11100001,%00000000,%00000000,%00000001,%00010000
+.db %11000000,%11000110,%00000110,%11000000,%01101100,%00000011,%00110000,%11001100,%00001111,%00001110,%10010110,%00010001,%00000000,%00000000,%00000000,%11100000
+.db %11100000,%11101110,%00001110,%11000000,%01101100,%00000011,%00111001,%11001100,%00000000,%00001100,%01100100,%00001001,%00111111,%11111111,%11000000,%00000000
+.db %01100000,%01111100,%00001100,%11000000,%01101100,%00000011,%00011111,%10001110,%00000000,%00001100,%01000000,%10000001,%01000000,%00000000,%00000000,%00000000
+.db %01110000,%00111000,%00011100,%11100000,%11101110,%00000011,%00001111,%00000110,%00000000,%00011100,%01000000,%11000001,%01100101,%01001001,%10000011,%01100011
+.db %00111000,%11111110,%00111000,%01110001,%11000110,%00000011,%10000000,%00000111,%10000000,%00111000,%01000001,%00100001,%00110101,%00010101,%01000101,%01010100
+.db %00011111,%11101111,%11110000,%00111111,%10000111,%00000001,%10000000,%00000011,%11111111,%11110000,%00111110,%00011110,%00010111,%01011101,%10010101,%01100101
+.db %00001111,%10000011,%11100000,%00011111,%00000011,%00000001,%10000000,%00000000,%11111111,%11100000,%00000000,%00000000,%11100101,%01010101,%01000110,%01010011
+
+wtWormy:
+.db %00000110,%00111000,%00000000,%00111100,%00001111,%10001110,%00111100,%01111000,%00001100,%11011000,%11100011,%10000000,%00000000,%11111100,%00111000,%00000000
+.db %00011001,%01000110,%11100000,%11000010,%00011100,%11011111,%01111110,%11111000,%00011110,%11011101,%11110111,%11000000,%00111111,%00000011,%01000110,%11100000
+.db %00100000,%10000011,%00010001,%00110010,%00011000,%00010011,%01101010,%11000000,%00111011,%01001101,%10000110,%01000000,%11000000,%00000000,%10000001,%00010000
+.db %00100000,%00000000,%00001110,%00110010,%00011001,%10011011,%01101010,%11100000,%00110011,%01101101,%11000111,%10000001,%00011100,%00000000,%00000000,%00001100
+.db %01001100,%00011000,%00000000,%00000100,%00011000,%11011111,%01100010,%11001100,%00110011,%01101101,%10000111,%11000001,%00011100,%00111000,%00011000,%10000010
+.db %01010010,%00100100,%01100000,%00011000,%00011111,%11011011,%11101110,%11111100,%00011111,%01111000,%11110110,%11100000,%11000000,%11000110,%00101001,%10000010
+.db %01100001,%11000011,%10011111,%11100000,%00001111,%10001001,%11001100,%01111000,%00001110,%00110000,%01100110,%01100000,%00111111,%00000001,%11000110,%01111100
+
+;.db %00000000,%00000001,%10000000,%00000000,%00001111,%10000000
 
 txtMenu:  .db "Mode",0  ;1st menu item
          .db "Level",0 ;2nd
-         .db "Limit",0 ;...
+         .db "Link",0  ;...
          .db "Worms",0
          .db "worm #",0
-         .db "controls",0
-posMenu:  .dw $$2418,$231E,$2524,$1F2A,$1730,$1936
+         .db 0
+posMenu:  .dw $2418,$231E,$2824,$1F2A,$1730,$1936
+txtMenuR: .db "controls",0
+txtoMenu: .db "Back",0  ;1st menu item
+         .db "Lives",0 ;2nd
+         .db "Limit",0 ;...
+         .db "Speed",0
+         .db "Rotation",0
+         .db "Growth",0
+posoMenu: .dw $2618,$251E,$2524,$222A,$1A30,$1C36
 txtGame:  .db "Singleplayer",0
 txtGame1: .db "Peaworm",0
 txtGame2: .db "Tron",0
 txtGame3: .db "Deathmatch",0
 txtGame4: .db "Foodmatch",0
-txtGame5: .db "LinkMatch",0
+txtGame5: .db "Timematch",0
 txtGame6: .db "Race",0
-txtGame7: .db "CTF",0
-;            .db "Domination",0    ;8
-posGame:  .db 0,txtGame1-txtGame
+txtGame7: .db "CTF" ;,0
+
+posGame:  .db 0
+         .db txtGame1-txtGame
          .db txtGame2-txtGame
          .db txtGame3-txtGame
          .db txtGame4-txtGame
@@ -3287,10 +3824,14 @@ posGame:  .db 0,txtGame1-txtGame
          .db txtGame6-txtGame
          .db txtGame7-txtGame
 
-txtKeyleft: .db "Left",0
-txtKeyright:.db " | Right",0
-txtLevsel:  .db $CF," Select levels: ",5,0
-txtEName:   .db "Enter name player ",0
+txtNone:   .db "None",0
+txtDef:    .db "Default",0
+txtYes:    .db "Yes",0
+txtNo:     .db "No",0
+txtKeyleft: .db ":left",0
+txtKeyright:.db "/right",0
+posLevsel = $0320
+txtLevsel:  .db $CF," SELECT LEVELS ",5,0
 txtWaiting: .db "Waiting...",0
 txtReceive: .db "Receiving..." ;,0
 
@@ -3308,68 +3849,80 @@ TrigPrecalc:
 txtLevel:  .db "Level ",0
 txtWorms:  .db "Worms: 0",0    ;follows txtLevel
 txtName:   .db "Name",0
-txtDied:   .db "Died    "      ;follows txtName
+txtWinner: .db "Wins   "       ;follows txtName
+txtDied:   .db "Died    "      ;follows txtWinner
 txtScore:  .db "Score",0       ;follows txtDied
 txtLeft:   .db " left",0       ;follows txtScore
 txthiscore:.db "HiScore:",0
+#ifdef readytext
 txtReady:  .db "Prepare!",0
 txtposReady = 7
+#endif
+#ifndef coolzgfx
 txtGO:     .db 5,5,5,5,5," GAME OVER ",$CF,$CF,$CF,$CF,$CF,0
+#endif
 
-_datalink  = %00000001 ;linkplay
-_datalivel = %00000010 ;lives=0 limit
-_datafoodl = %00000100 ;left=0 limit
-_datanextl = %00001000 ;next level if left=0
-_datasingl = %00001000 ;singleplayer=1
-                       ;1=hiscore+keep_length
-_datafood  = %00010000 ;food present
-_datadie   = %01000000 ;worm dies on impact
-_datascore = %10000000 ;score>=100 limit
-_datamultpeas = %00100000
-_datasp    = %01011110
-
-datalevels: .dw LevelDef, LevelDefT
+datalevels: .dw LevelDef, LevelDefM
             .dw LevelDefT,LevelDefM
             .dw LevelDefM,LevelDefM
-            .dw LevelDefM,LevelDefC
+            .dw LevelDefR,LevelDefC
 nrlevels:   .db 1,3,1,3,3,3,3,1     ;=defaults
 
-savestart:
-
-gamesingle   =  0
-datasingle: .db %01011110,3,1 ;3 lives (<must b unique)
+_datalink      = %0000001 ;linkplay
+_datafoodl     = %0000010 ;left=0 limit
+_datasingl     = %0000100 ;singleplayer=1 (=hiscore+keep_length+nextlevel)
+_datamultpeas  = %0001000 ;multiple peas=1
+_datatime      = %0010000 ;time incs score (timematch)
+_datafood      = %0100000 ;food present
+_datadie       = %1000000 ;worm dies on impact
+;reserved       %10000000 ;for future use
+
+savestart:        ;     �game info (see above)
+                  ;     | �lives (0=unlimited)
+                  ;     | | �nrworms (can be altered by user)
+                  ;     | | | �level (reset to 1 at startup)
+                  ;     | | | |  �speed/delay (-1=def)
+                  ;     | | | |  |  �grow speed (-1=none; 0=continuous)
+                  ;     | | | |  |  |  �turn speed (8=def)
+                  ;     | | | |  |  |  |  �score limit (0=none)
+gamesingle   =  0 ;used | | | |  |  |  |  |
+datasingle: .db  %1100110,3,1,1,-1,-1, 8, 0 ;Singleplayer (SP; 3 lives)
 gamepeas     =  1
-datapeas:   .db %01011010,1,1 ;1 "
+datapeas:   .db  %1100100,1,1,1,-1,-1, 8, 0 ;Peaworm (SP; 1 live)
 gametron     =  2
-datatron:   .db %01000010,1,2
-gamedeathm   =  3
-datadeathm: .db %01000010,3,2
+datatron:   .db  %1010100,1,1,1,-1, 0, 8, 0 ;Tron (SP; 1 live, cont.growth)
+gamedeathm   =  3 ;used
+datadeathm: .db  %1000000,3,2,1,-1,49, 8, 0 ;Deathmatch (3 lives, 50 growth)
 gamefoodm    =  4
-datafoodm:  .db %11010000,10,2 ;10 score limit (=100)
-gamelinkm    =  5
-datalinkm:  .db %01000011,3,2
-gamerace     =  6
-datarace:   .db %10000000,10,2
-gamectf      =  7
-datactf:    .db %11100000,9,4
-;gamedomin    =  8
-;datadomin:  .db %01100000,3 ;==(8 modes)
+datafoodm:  .db  %1100000,0,2,1,-1,-1, 8,10 ;Foodmatch (100 score)
+gametimem    =  5
+datatimem:  .db  %1010000,1,2,1,-1, 0, 8, 0 ;Timematch (tron, 100 score)
+gamerace     =  6 ;used
+datarace:   .db  %0000000,0,2,1,-1,-1, 8,10 ;Race (100 score, no collision)
+gamectf      =  7 ;used
+datactf:    .db  %1001000,0,4,1,-1,-1, 8,10 ;CTF (100 score)
 
 worm1set:  .dw worm1p,worm1p
-           .db %11110111,%00,%01111110,K_RIGHT,K_LEFT
-worm1name: .db "Wormy   ",0
+           .db %11110111,1,-01,K_RIGHT,K_LEFT
+worm1name: .db "WORMY   ",0
 worm2set:  .dw worm2p,worm2p
-           .db %11111011,%11,%00111111,K_F2,K_F1
-worm2name: .db "Viper   ",0
+           .db %11111011,0,-01,K_F2,K_F1
+worm2name: .db "VIPER   ",0
 worm3set:  .dw worm3p,worm3p
-           .db %11111011,0,%01011111,K_COMMA,K_STO
-worm3name: .db "Nibbler ",0
+           .db %11111011,1,-01,K_COMMA,K_STO
+worm3name: .db "NIBBLER ",0
 worm4set:  .dw worm4p,worm4p
-           .db %11111011,0,%01111101,K_PLUS,K_ENTER
-worm4name: .db "Spunky  ",0
+           .db %11111011,0,-01,K_PLUS,K_ENTER
+worm4name: .db "JIM     ",0
 
 defhiscrpos:
-  .dw 0,0,0,0,0,0
+  .db 0,0,"SHI"
+  .db 0,0,"SHI"
+  .db 0,0,"SHI"
+  .db 0,0,"SHI"
+  .db 0,0,"SHI"
+
+Gametype:  .db 0 ;last gamemode
 
 saveend:
 
@@ -3406,7 +3959,27 @@ maxnamelength = 8+1
 .db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
 .db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
 .db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
-.db "   shiar0@hotmail.com",0
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "WWW.SHIAR.ORG  WWW.SHIAR.ORG  "
+.db "   wormy@shiar.org",0
 
 defspritesz = 4
 defspriteimg:  .db %01100000
@@ -3415,7 +3988,7 @@ defspriteimg:     .db %01100000
                .db %01100000
 
 deflevels:
-  .db 15,"Internal Levels"
+  .db "Internal Levels" ;,0
 
   .db 0,deflevels/256,deflevels&255
 templevels: