+WormDead:
+#ifdef invincible
+ jp stopworm
+#else
+ ld a,2
+ ld (flashtime),a
+ ld (ix+delay),respawndelay
+
+thislevel =$+1
+ ld hl,0
+ ld de,0
+handledworm =$-2
+ add hl,de
+ add hl,de
+ add hl,de
+ ld a,(hl)
+ inc hl
+ ld (ix+heading),a
+ ld a,(hl)
+ ld (ix+pos),a ;y
+ inc hl
+ ld a,(hl)
+ 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
+ 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 _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
+