game over screen mockup
[wormy.git] / wormy.z80
index d6b21fba449e0a4824df970a35059fda2c0c8890..6ed5a09dfdc5329daa4672abb5140d3034744374 100644 (file)
--- a/wormy.z80
+++ b/wormy.z80
 
 ; 93% = 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)
+;     * fix first packet loss
+;  1% * transmit game/level data
+;  1% * get g/o signal (l&l) working
+;  2% * send new peas' positions
 ;   * CTF
-;  1% * fix pea XOR problem in ctf (+dom?)
-;     * fix wormstop
-;  1% * domination?: take control points by running over them and hold them
+;  1% * fix pea XOR problem in ctf
+;  1% * fix wormstop in race
 
 ;100% = bugs fixed + levels done
 
 #define buffer      ;use display buffer (otherwise write directly to screen)
 #define readymask   ;"greys" out the field before starting a level
 ;#define hlines     ;horizontal-line routine for more speed drawing boxes
-                       ;(doesn't work properly)
-
+                       ;^^(doesn't work properly)^^
 ;#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
@@ -76,11 +77,12 @@ _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 ;"""" 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
@@ -140,19 +142,18 @@ start:
 WormTxt:
   .db "WORMY by SHIAR -- beta 93%",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 %00110000,%00111100
+  .db %01110000,%00111110
+  .db %11100000,%00000111
+  .db %11000011,%11000011
+  .db %11000111,%11100011
+  .db %11101110,%01100111
+  .db %01111100,%01111110
+  .db %00111000,%00111100
 
 levelhead  = 'w'
-levelhead2 = 93 ;wormy levels header = "93"
+levelhead2 = 94 ;wormy levels header = "93"
 
 int_handler:
   ex af,af'
@@ -246,20 +247,14 @@ _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
@@ -341,7 +336,7 @@ levselect:
   cp  K_SECOND-1
   jr  z,loadlevel
   cp  K_EXIT-1
-  ret z
+  jp  z,ExitNoStats
   cp  K_ENTER-1
   jr  nz,levselect
 ; jr  z,loadlevel
@@ -379,10 +374,11 @@ skiptitle:
 
   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
@@ -393,8 +389,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
@@ -463,7 +458,12 @@ DisplayMenu: ;---draw menu---
   ld  hl,$FC00+$3E0
   cal hr
 dispmainmenu:
-  ld  hl,dispmenusets ;mainMenu
+  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
@@ -794,7 +794,7 @@ changenrworms:
 changednrworms:
   ld  (hl),a
 _dispmenusets:
-  jr  dispmenusets ;mainMenu
+  jr  _dispmenusets ;mainMenu
 changenrwormsInit:
   ld  a,(Gametype)
   cp  3
@@ -827,27 +827,30 @@ bchangelink:
   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
-  jr  dispmenusets ;mainMenu
+  cal getnrlevels
+  xor a
+  cp  (hl)
+  ret
 bchangegame:
   ld  a,(Gametype)
   dec a
-  jr  changedgame
+  cal changedgame
+  jr  z,bchangegame
+  jr  dispmenusets ;mainMenu
 
 changelevel:
   inc hl ;hl=loadgamecar+2
   psh hl
   ld  a,(hl) ;(curlevel)
-  ld  hl,Gametype
-  ld  d,0
-  ld  e,(hl)
-  ld  hl,nrlevels
-  add hl,de
+  cal getnrlevels
   cp  (hl) ;max level for sel.game
   pop hl
   jr  z,_mainMenu
@@ -862,6 +865,14 @@ bchangelevel:
   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
@@ -938,8 +949,8 @@ 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
@@ -1028,62 +1039,54 @@ 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
   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
@@ -1091,14 +1094,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
@@ -1108,12 +1108,18 @@ 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
 
 clrold:
   ld  hl,$FD97 ;begin pos
-  ld  de,7 ;bytes to add
   ld  a,35 ;nr of lines
+clroldcustom:
+  ld  de,7 ;bytes to add
 clroldsettings:
   ld  c,9 ;bytes to clear
 clroldsetsloop:
@@ -1139,8 +1145,8 @@ skipsprite:
   ld  b,(hl) ;balls
   inc b
   inc b ;skip 6
-  ld  a,c
-  cp  _datasingle
+  ld  a,(Gametype)
+  cp  gamesingle
   jr  z,skipworms
   inc b ;multiplayer lvl
   inc b
@@ -1294,7 +1300,6 @@ multiplayer:
 ;-----------------------------
 
 GameOver:
-  cal _clrLCD
   ld  hl,worm1set
   ld  de,worm1
   ld  a,4 ;4x (all worms)
@@ -1320,8 +1325,9 @@ wormbeglives =$-1
   dec a      ;loop
   jr  nz,createwormsloop
 
-  pop hl ;begin of current level
 StartLevel:
+  cal _clrWindow
+  pop hl ;begin of current level
   ld  de,Left
   ld  a,(hl)
   inc a ;=255?
@@ -1331,7 +1337,6 @@ StartLevel:
   ld  hl,Level
   dec (hl) ;curlevel-- (not beyond last lvl)
   cal releasekeys
-  cal _clrWindow
   pop hl
 ;show end msg or smtn
   ld  bc,Exit
@@ -1677,6 +1682,18 @@ nextturnok:
   cal forceshowstats ;update score
 nodispupdate:
 
+drawctfpea1:
+  jr  drawctfpea2
+  ld  bc,drawctfpea1
+  ld  hl,(peaspos)
+  cal tryDrawPea
+drawctfpea2:
+  jr  noctfpeas2draw
+  ld  bc,drawctfpea2
+  ld  hl,(peaspos+2)
+  cal tryDrawPea
+noctfpeas2draw:
+
 
   ld  a,0
 nrballs =$-1
@@ -1943,33 +1960,44 @@ hilevelcheckdone:
   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
 
-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:
 
@@ -2009,8 +2037,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)
@@ -2019,24 +2046,25 @@ ExitNoStats:
   jp  _clrWindow
 
 loadhiscoreposinahl:
-  ld  h,0
+  ld  hl,0 ;for peaworm and singleplayer
   ld  a,(Gametype)
-  cp  2
-  ld  l,h ;hl=0 for peaworm and singleplayer
-  jr  nz,hi_
-  ld  a,(nrlevels+1)
-  ld  l,a ;skip peaworm slots for tron mode
-hi_:
   or  a ;Singleplayer?
-  ld  b,0 ;offset 0 for SP
   jr  z,hi__
-  ld  a,(Level)
+  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)
 addlevelposition:
+  inc hl
   inc hl ;add one word per level
+  inc hl
+  inc hl
+  inc hl ;plus 3 bytes for name
   dnz addlevelposition
 hi__:
-  add hl,hl ;one WORD per hiscore
   xor a ;ahl=0(+hl)
   ld  bc,defhiscrpos
 hiscrposhl =$-2
@@ -2044,6 +2072,8 @@ hiscrposhl =$-2
 hiscrposa =$+1
   adc a,0 ;ahl=saveloc
   ret
+highsave:
+  .db 0,0,"WOR ",0
 
 ;-----------------------------
 ;----------- worm ------------
@@ -2266,11 +2296,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
@@ -2313,11 +2345,10 @@ peagrowth =$-1
   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
@@ -2332,70 +2363,55 @@ 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),$E6 ;and nn
+  ret
 
 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
+  jr  nz,Drawworm ;flag taken, continue game
+  psh hl
+  ld  de,20 ;flag captured+returned
+  cal IncScore
+  pop hl
+  ld  a,$E6 ;and nn
+  ld  (drawctfpea1),a ;redraw..
+  ld  (drawctfpea2),a ;..both flags
+  jr  Drawworm
 
-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
+DrawAllPeas:
+  ld  hl,(peaspos)
+  cal DrawPea
+  ld  hl,(peaspos+2)
+  jp  DrawPea
 
 ;-----------------------------
 
@@ -2440,6 +2456,7 @@ nolap:
   ld  (ix+reserv),a
   ret
 
+#ifdef optdie
 checkhitotherworm:
  .db  $dd,$7d ;ld a,lx
   cp  worm2&255
@@ -2459,6 +2476,7 @@ chkworm:
  pop ix
   ret z ;not hit
   pop bc ;call
+#endif
 stopworm:
   ld  bc,0
 previouspos =$-2
@@ -2654,18 +2672,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
@@ -2678,21 +2685,80 @@ 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
+  psh bc
+  cal CheckPea
+  pop bc
+  ret nz ;unsuccesful
+  ld  a,$18 ;jr
+  ld  (bc),a
+  jr  DrawPea
 
+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 -----------
 
@@ -3174,47 +3240,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:
@@ -3232,26 +3257,27 @@ 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
+  jp  z,drawline
   dec a ;2 = fatline
-  cal z,drawfatline
+  jp  z,drawfatline
   dec a ;3 = box
-  cal z,drawbox
+  jp  z,drawbox
   dec a ;4 = circle
-  cal z,drawcircle
+  jp  z,drawcircle
   dec a ;5 = hline
 #ifdef hlines
-  cal z,drawhline
+  jp  z,drawhline
 #else
-  cal z,drawline
+  jp  z,drawline
 #endif
 
-  pop hl
-  inc hl
-  jr  drawstuff
-
 drawbox: ;(d,e)-(h,l)
   ld  b,l ;Delta-y
 #ifdef hlines
@@ -3475,12 +3501,6 @@ circledraw:              ;destr:de
   ret
 
 
-
-
-
-
-
-
 ;-----------------------------
 ;----------- link ------------
 ;-----------------------------
@@ -3687,7 +3707,8 @@ txtGame5: .db "Timematch",0
 txtGame6: .db "Race",0
 txtGame7: .db "CTF" ;,0
 
-posGame:  .db 0,txtGame1-txtGame
+posGame:  .db 0
+         .db txtGame1-txtGame
          .db txtGame2-txtGame
          .db txtGame3-txtGame
          .db txtGame4-txtGame
@@ -3702,7 +3723,6 @@ txtNo:     .db "No",0
 txtKeyleft: .db ":left",0
 txtKeyright:.db "/right",0
 txtLevsel:  .db $CF," Select levels ",5,0
-txtEName:   .db "Enter name player ",0
 txtWaiting: .db "Waiting...",0
 txtReceive: .db "Receiving..." ;,0
 
@@ -3759,7 +3779,7 @@ datapeas:   .db  %1100100,1,1,1,-1,-1, 8, 0 ;Peaworm (SP; 1 live)
 gametron     =  2
 datatron:   .db  %1010100,1,1,1,-1, 0, 8, 0 ;Tron (SP; 1 live, cont.growth)
 gamedeathm   =  3 ;used
-datadeathm: .db  %1000001,3,2,1,-1,49, 8, 0 ;Deathmatch (3 lives, 50 growth)
+datadeathm: .db  %1000000,3,2,1,-1,49, 8, 0 ;Deathmatch (3 lives, 50 growth)
 gamefoodm    =  4
 datafoodm:  .db  %1100000,0,2,1,-1,-1, 8,10 ;Foodmatch (100 score)
 gametimem    =  5
@@ -3768,23 +3788,28 @@ 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, 9 ;CTF (90 score)
-_datasingle    = %1100110 ;(datasingle) usable like gamesingle
 
 worm1set:  .dw worm1p,worm1p
            .db %11110111,%00,-01,K_RIGHT,K_LEFT
-worm1name: .db "Wormy   ",0
+worm1name: .db "WORMY   ",0
 worm2set:  .dw worm2p,worm2p
-           .db %11111011,%11,-01,K_F2,K_F1
-worm2name: .db "Viper   ",0
+           .db %11111011,%01,-01,K_F2,K_F1
+worm2name: .db "VIPER   ",0
 worm3set:  .dw worm3p,worm3p
            .db %11111011,%00,-01,K_COMMA,K_STO
-worm3name: .db "Nibbler ",0
+worm3name: .db "NIBBLER ",0
 worm4set:  .dw worm4p,worm4p
-           .db %11111011,%00,-01,K_PLUS,K_ENTER
-worm4name: .db "Jim     ",0
+           .db %11111011,%01,-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: