worm 0.89.0426: further memory usage analysis/tweaking
[wormy.git] / worm.z80
index d5b88d118fd333243bd3847e680083471f60ded9..2db4d9cdfa04d2bc8eb5628cb6c67cd8f150d3e4 100644 (file)
--- a/worm.z80
+++ b/worm.z80
@@ -76,26 +76,33 @@ _writeb_inc_ahl    = $5567 ;ld (ahl),c
 ;------- data  storage -------
 ;-----------------------------
 
-leveldata   = $EA00 ;size< $400
-ScrBuffer   = $8100 ;size=$2000 (32x256)
-         ;->mod$800
-templevels  = $BC00 ;size= 3*$10
-DispBuffer  = $BC00 ;size= $390 (16x57)
-SinCosTable = $B500 ;size= $100  (4x64)
-
-worm1 = $B400
-worm2 = $B41E
-worm3 = $B43C
-worm4 = $B45A
-ball1 = $B478
-
-resbit  = 2   ;and%11111011
-worm1p = $B000   ;%10110000 -$B3FF
-worm2p = $B800   ;%10111000 -$BBFF
-worm3p = $F000   ;%11110000 -$F3FF
-worm4p = $A800   ;$E800=%11101000 ;$D748+$1000+
-
-WormVersion = 088
+;--- permanent
+
+resbit = 2                        ;and%111110**
+
+ScrBuffer   = $8820 ;-A7FF (20*FF=1FE0)
+worm1p      = $A800 ;-ABFF (400)      %10101O00
+worm1       = $AC00 ;-AC1D (30d)
+worm2       = $AC1E ;-AC3B (1E)
+worm3       = $AC3C ;-AC59 (1E)
+worm4       = $AC5A ;-AC77 (1E)
+balls       = $AC78 ;-ACFF (3x45d)
+SinCosTable = $AD00 ;-AE00 (4x40)
+        ;free $AE01 ;-AFFF (1FF)
+worm2p      = $B000 ;-B3FF (400)      %10110O00
+DispBuffer  = $B400 ;-B790 (10x57d)
+        ;free $B791 ;-B7FF (6F)
+worm3p      = $B800 ;-BBFF (400)      %10111O00
+        ;free $BC00 ;-BFFF (400)
+
+     ;program $D748 ;-E7FF (106D+4A)
+        ;free $E800 ;-EFFF (800)
+worm4p      = $F000 ;-F3FF (400)      %11110O00
+leveldata   = $F400 ;-FA70 (<=671)
+
+;--- temporary
+
+templevels  = $B400 ;(3*levelstr_on_calc)
 
 ;-----------------------------
 ;------- program start -------
@@ -103,6 +110,8 @@ WormVersion = 088
 
 .org _asm_exec_ram
 
+WormVersion = 089
+
 start:
   nop
   jp Start
@@ -124,8 +133,8 @@ WormIcon:
   .db %11101111,%00001111
   .db %11000011,%10000000
 
-levelhead  = '8'
-levelhead2 = '9' ;worm levels header = "89"
+levelhead  = 'w'
+levelhead2 = 89 ;worm levels header = "89"
 
 Start:
   ld  (SpSave),sp
@@ -137,7 +146,7 @@ Start:
   ld  hl,$BFFF ;VAT start
   ld  bc,templevels
 searchloop:
-  ld  de,(_PTEMP_END+1)
+  ld  de,(_PTEMP_END+1) ;VAT end
   or  a ;nc
   sbc hl,de ;hl<de?
   jr  c,searchcomplete
@@ -147,6 +156,7 @@ searchloop:
   cp  $0C ;string
   jr  z,stringfound
 searchnext:
+ cal _RAM_PAGE_7
   pop hl
   dec hl ;5x
   dec hl
@@ -188,7 +198,6 @@ stringfound:
  ld a,l
  ld (bc),a
  inc bc
- cal _RAM_PAGE_7
  jr searchnext
 
 loadgametype:
@@ -496,12 +505,17 @@ menudraw:
 
 changeworms:
   cal _clrWindow
+  ld  hl,txtName
+  cal _puts ;"Enter name player "
   ld  a,(Gametype)
   cp  2
   ld  a,1
   jr  c,wormnrname
   ld  a,(nrworms)
 wormnrname:
+  add a,'0'
+  cal _putc
+  sub '0'
   add a,a  ;2x
   ld  e,a
   add a,a  ;4x
@@ -518,6 +532,9 @@ wormnrname:
   jp  DisplayMenu
 
 entername:
+  ld  h,1
+  ld  l,h
+  ld  (_curRow),hl
   ld  (namelength),a
 enternameloop:
   ld  a,'_'
@@ -581,13 +598,13 @@ waitnokeypressed:
 namelength:
   .db 0
 chartable:
-  .db 0,"!<>^",0,0,0,0
+  .db 0,".<>!",0,0,0,0
   .db 0,"xtoje0",0      ;enter..clear
   .db " wsnid9",0       ;(-)..custom
   .db "zvrmhc8",0       ;dot..del
-  .db "yuqlgb7*"        ;0..xvar
+  .db "yuqlgb7#"        ;0..xvar
   .db 0,"-pkfa6'"       ;on..alpha
-  .db "54321.",0,0      ;F5..more
+  .db "54321*",0,0      ;F5..more
 
 ;--proc
 
@@ -811,7 +828,7 @@ setsprite:
   add a,c
   ld  c,a
   ld  b,0
-  ld  de,ball1
+  ld  de,balls
   ldir
 toobad_noballs:
 
@@ -1112,8 +1129,7 @@ CheckExit:
 WormDead:
   ld  a,2
   ld  (flashtime),a
-  ld  a,respawndelay
-  ld  (ix+delay),a
+  ld  (ix+delay),respawndelay
 
 thislevel =$+1
   ld  de,0
@@ -1314,7 +1330,7 @@ hiscrposa =$-1
   ld  hl,0
 hiscrposhl =$-2
   ret z ;(Gametype)=0
-  cal _INC_PTR_AHL
+  cal _AHL_PLUS_2_PG3
   ret
 
 ;-----------------------------
@@ -1678,7 +1694,7 @@ nrballs =$-1
   or  a
   ret z
 
-  ld  hl,ball1
+  ld  hl,balls
   ld  b,a
 handleballs
   psh bc
@@ -2583,17 +2599,6 @@ LevelDefM:
 ;---------- data -------------
 ;-----------------------------
 
-TrigPrecalc:
-.db   0,  3,  6,  9, 12, 15, 18, 21
-.db  24, 27, 30, 33, 36, 39, 42, 45
-.db  48, 51, 54, 57, 59, 62, 65, 67
-.db  70, 73, 75, 78, 80, 82, 85, 87
-.db  89, 91, 94, 96, 98,100,102,103
-.db 105,107,108,110,112,113,114,116
-.db 117,118,119,120,121,122,123,123
-.db 124,125,125,126,126,126,126,126
-.db 127
-
 txtWelcome: .db "Welcome to Worm!! ",
             .db "by Shiar",0
             .db "Have fun!",0 ;4th menu item
@@ -2608,8 +2613,20 @@ txtGame2:   .db "Peaworm     ",0  ;1
             .db "Race   ",0       ;6
             .db "CTF ",0          ;7
             .db "Domination",0    ;(>=8)
+txtName:    .db "Enter name player ",0
 txtWaiting: .db "Waiting...",0
-txtReceive: .db "Receiving...",0
+txtReceive: .db "Receiving..." ;,0
+
+TrigPrecalc:
+.db   0,  3,  6,  9, 12, 15, 18, 21
+.db  24, 27, 30, 33, 36, 39, 42, 45
+.db  48, 51, 54, 57, 59, 62, 65, 67
+.db  70, 73, 75, 78, 80, 82, 85, 87
+.db  89, 91, 94, 96, 98,100,102,103
+.db 105,107,108,110,112,113,114,116
+.db 117,118,119,120,121,122,123,123
+.db 124,125,125,126,126,126,126,126
+.db 127
 
 txtLevel:  .db "Level ",0
 txtWorms:  .db "Worms: 0",0 ;follows txtLevel
@@ -2646,20 +2663,20 @@ datalevels: .dw LevelDef, LevelDef
             .dw LevelDefM,LevelDefM
             .dw LevelDefM,LevelDefM
             .dw LevelDefM,LevelDefM
-nrlevels:   .db 1,1,1,1,1,1,1,1
+nrlevels:   .db 2,2,2,2,2,2,2,2
 
 worm1set:  .dw worm1p,worm1p
            .db 3,0,%01111110,%10,%100 ;< >
-worm1name: .db "Left    ",0
+worm1name: .db "worm #01",0
 worm2set:  .dw worm2p,worm2p
            .db 3,0,%00111111,%10000,%1000 ;f1 f2
-worm2name: .db "Right   ",0
+worm2name: .db "worm #02",0
 worm3set:  .dw worm3p,worm3p
            .db 3,0,%01011111,%10,%100 ;sto ,
-worm3name: .db "Top     ",0
+worm3name: .db "worm #03",0
 worm4set:  .dw worm4p,worm4p
            .db 3,0,%01111101,%10,%1 ;enter +
-worm4name: .db "Bottom  ",0
+worm4name: .db "worm #04",0
 
 hipeaworm: .dw 0
 end:
@@ -2692,7 +2709,7 @@ right    = 20  ;&
 name     = 21  ;game
 wormsize = 30
 
-respawndelay  = 40
+respawndelay  = 80
 maxnamelength = 9
 
 ;-----------------------------