worm 0.80.0206: partial revert?
[wormy.git] / worm.asm
index 8d0bab19e702045dc9706836d894d6a971d05c45..383bab21a0ff9df450ea507923a9be3d72d27e98 100644 (file)
--- a/worm.asm
+++ b/worm.asm
@@ -1,7 +1,7 @@
 ; Title                      : Worm
 ; Version                    : 0.92
 ; Release Date               : soon (I hope)
-; Filename                   : worm.86p
+; Filename                   : worm.86p (3404)
 ; Author(s)                  : Shiar
 ; Email Address              : shiar@mailroom.com
 ; ICQ UIN                    : #43840958
@@ -16,7 +16,7 @@
 ;----------- TO-DO -----------
 ;-----------------------------
 
-;       Shiar 23.I .00
+;       Shiar 4.II.00
 
 ;Feel like doing something? (name indicates who's working on it)
 ;  * linkplay TESTING! (+faster)
@@ -26,7 +26,6 @@
 ;  * two worms collide with heads -> both should die
 ;  * bouncing balls :)
 ;  * game types:
-;    * hot pursuit/hunting/kodh: catch the other player and vv
 ;1)  * ctf: take enemy flag (right-bottom) and return to your flag (left-top)
 ;1)  * domination?: take control points by running over them and hold them
 ;  * AI worms?
@@ -34,7 +33,7 @@
 ;  * fix linedraw procedure
 ;  * save hiscore
 
-;1) Shiar: working on a new pickup-system allowing more than one "food" and different pickup-handling
+;1) Working on a new pickup-system allowing more than one "food" and different pickup-handling
 
 #include "TI86.inc"
 
@@ -63,9 +62,9 @@ WormIcon:
   .db %11000011,%10000000
 
 Start:
-  ld (SpSave),sp
+  ld  (SpSave),sp
   call _runIndicOff
-;  call _flushAllMenus
+  call _flushAllMenus
   call _clrLCD
   res 2,(iy+13) ;appAutoScroll
 
@@ -76,25 +75,25 @@ Start:
 ;----- build trig tables -----
 ;-----------------------------
 
-  ld hl,TrigPrecalc
-  ld de,SinCosTable
+  ld  hl,TrigPrecalc
+  ld  de,SinCosTable
   push de                        ; >> 1
-  ld bc,65
+  ld  bc,65
   ldir
   dec hl
-  ld b,63
+  ld  b,63
 MirrorSineWave:
   dec hl
-  ld a,(hl)
-  ld (de),a
+  ld  a,(hl)
+  ld  (de),a
   inc de
   djnz MirrorSineWave
   pop hl                         ; << 0k
-  ld b,128+64
+  ld  b,128+64
 NegativeSineWave:
   xor a
   sub (hl)
-  ld (de),a
+  ld  (de),a
   inc hl
   inc de
   djnz NegativeSineWave
@@ -126,7 +125,7 @@ select:
   ld  a,b
   or  a
   jr  nz,gooptionsMenu
-  jp  ThePartyIsOn
+  jp  LetsGetThisPartyOn
 notselect
   cp  K_EXIT
   jp  z,ExitNoStats
@@ -238,7 +237,7 @@ notup:
 ;-------- start game ---------
 ;-----------------------------
 
-ThePartyIsOn:
+LetsGetThisPartyOn:
   ld  hl,Gametype
   ld  a,(hl)
   add a,a
@@ -258,7 +257,7 @@ notsingle:
   push af
 
   and _datascore
-  ld  de,$FF64
+  ld  de,$FF64 ;virt.infinate
   jr  z,setscorelimit
   ld  d,0 ;de=100
 setscorelimit:
@@ -306,22 +305,19 @@ multiplayer:
 
 GameOver:
   call _clrLCD
-  xor a
-  ld  (worm1+died),a
-  ld  (worm2+died),a
-  ld  (worm3+died),a
-  ld  (worm4+died),a
-  ld  h,a
-  ld  l,a
-  ld  (worm1+score),hl
-  ld  (worm2+score),hl
-  ld  (worm3+score),hl
-  ld  (worm4+score),hl
-  inc a
-  ld  (worm1+delay),a
-  ld  (worm2+delay),a
-  ld  (worm3+delay),a
-  ld  (worm4+delay),a
+  ld  hl,0
+  ld  (worm1+died),hl
+;+died=0 \ +score1=0
+  ld  (worm2+died),hl
+  ld  (worm3+died),hl
+  ld  (worm4+died),hl
+  inc h
+  ld  (worm1+score+1),hl
+;+score2=0 \ +delay=1
+  ld  (worm2+score+1),hl
+  ld  (worm3+score+1),hl
+  ld  (worm4+score+1),hl
+  ld  a,l
   ld  (Level),a
   ld  hl,worm1set+4
   ld  de,worm1+lives
@@ -355,6 +351,13 @@ StartLevel:
   ld  (worm4+grow),a
   inc de
 
+  ld  a,(gameCar)
+  and _datahunt
+  jr  z,nohunter
+  ld  a,huntersize
+  ld  (worm2+grow),a
+nohunter:
+
   ld  (thislevel),de
   push de
   ld  hl,worm1set
@@ -587,6 +590,22 @@ GameLoop:
   ld  bc,(worm1+pos)
   call DisplayField
 
+  ld  a,1
+flashtime =$-1
+  dec a
+  jr  z,noflash
+  ld  (flashtime),a
+  ld  hl,$fc00+(16*7)
+screeninvertloop:
+  ld  a,(hl)
+  cpl
+  ld  (hl),a
+  inc hl
+  xor a
+  cp  h
+  jr  nz,screeninvertloop
+noflash:
+
   ld  a,0
 Speed =$-1
   or  a
@@ -630,6 +649,9 @@ NotPaused:
   jr  Exit ;&&
 
 WormDead:
+  ld  a,2
+  ld  (flashtime),a
+
   ld  h,(ix+tail+1)
   ld  l,(ix+tail)
   push hl
@@ -659,11 +681,8 @@ removewormloop:
   inc a
   ld  (ix+grow),a
 
-  push ix
   ld  de,10
   call DecScore
-  pop ix
-
   ld  h,(ix+head+1)
   ld  l,(ix+head)
   ld  (ix+tail+1),h
@@ -751,7 +770,7 @@ NoLinkIndic:
 
   ld  a,16
   ld  (_curCol),a
-  inc hl
+  inc hl ;worm+score
   call _ldHLind ;ld hl,(hl)
   call showHL ;worm+score
 
@@ -967,22 +986,19 @@ PeaX =$-1
   ld  hl,Left
   dec (hl)
   push af
-  push ix
   ld  de,10
   call IncScore
-  pop ix
   pop af
-  jr  nz,NotNextLevel
+  jr  nz,still_alive_not_dead
   ld  a,(gameCar)
   and _datafoodl
-  jr  z,NotNextLevel
+  jr  z,still_alive_not_dead
   ld  hl,Level
   ld  a,(hl)
   inc (hl)
   pop hl                         ; << call
   pop hl                         ; << call
   pop de                         ; << levelp new
-;  pop hl                         ; << levelp old
   cp  NUM_LEVELS
   jp  z,Exit
   ld  a,(gameCar)
@@ -996,17 +1012,17 @@ checkhitotherworm:
   .db $dd,$7d ;ld a,lx
   cp  worm2&255
   ret nz
-
-  ld  hl,worm1+tail
-  ld  d,20
+ThisIsJustASillyUselessLabel:
+  ld  hl,(worm1+tail)
+  ld  de,(worm1+head)
 nextotherwormbit:
-  ld  a,b
+  ld  a,c
   sub (hl)
   inc hl
   inc a
   cp  4
   jr  nc,nothit1 ;no
-  ld  a,c
+  ld  a,b
   sub (hl)
   inc a
   cp  4
@@ -1014,19 +1030,9 @@ nextotherwormbit:
 nothit1:
   inc hl
   res resbit,h
-  push bc
-  push de
-  push hl
-;  ld  de,worm1+head
-;  call _cphlde
- dec d
-  pop hl
-  pop de
-  pop bc
+  call _cphlde
   jr  nz,nextotherwormbit
   ret
-otherwormHIT:
-  jp Exit
 
 checkhitlapline:
   ld  a,63
@@ -1036,26 +1042,36 @@ checkhitlapline:
   ret nz
 nextlaphalf:
   ld  a,c
-  and 32 ;>=32?
+  and 32 ;y>=32?
   jr  nz,nolap
   cp  (ix+reserv)
   jr  z,nolap
-  push ix
   push bc
   ld  de,20
   call IncScore
   pop bc
-  pop ix
   xor a
 nolap:
   ld  (ix+reserv),a
   ret
 
-NotNextLevel:
+otherwormHIT:
+  push ix
+  ld  de,10
+  call IncScore
+  ld  ix,worm1
+  call WormDead
+  pop ix
+  pop bc
+still_alive_not_dead:
 
 ;-------- draw worm ----------
 
 Drawworm:
+  ld  a,(gameCar)
+  and _datahunt
+  call nz,HuntingTimeScore
+
   ld  c,(ix+pos)
   ld  b,(ix+pos+1)
 
@@ -1231,17 +1247,25 @@ FindPixel: ;bc to ahl + de gone
 
 ;----------- score -----------
 
-DecScore:
+HuntingTimeScore:
+  .db $dd,$7d ;ld a,lx
+  cp  worm2&255
+  ret z ;=worm#2
+  dec (ix+reserv)
+  ret nz
+  ld  de,10
+
+IncScore:
   ld  h,(ix+score+1)
   ld  l,(ix+score)
-  or  a
-  sbc hl,de
-  ret c
+  add hl,de
   jr  scorecommon
-IncScore:
+DecScore: ;&&&
   ld  h,(ix+score+1)
   ld  l,(ix+score)
-  add hl,de
+  or  a
+  sbc hl,de
+  ret c
 scorecommon:
   ld  (ix+score+1),h
   ld  (ix+score),l
@@ -1251,8 +1275,9 @@ scorelimit =$-2
   jp  nc,Exit
 
 showstats:
-  xor a
-  sbc hl,hl
+  push ix
+  ld  h,0
+  ld  l,h
   ld  (_penCol),hl
   ld  a,(nrworms)
   ld  b,a
@@ -1262,9 +1287,9 @@ showstats:
   jr  nz,showstatsS
 showstatloop:
   push bc
-  push ix
+;  push ix
   call showstat
-  pop ix
+;  pop ix
   ld  de,worm2-worm1
   add ix,de
   ld  hl,_penCol
@@ -1273,6 +1298,7 @@ showstatloop:
   ld  (hl),a
   pop bc
   djnz showstatloop
+  pop ix
   ret
 
 showstat:
@@ -1283,16 +1309,19 @@ showscore:
   ld  h,(ix+score+1)
   ld  l,(ix+score)
   call _D_HL_DECI
-  jp  _vputs
+  jr __vputs
 showlives:
   ld  a,(ix+lives)
   add a,'0'
-  jp  _vputmap
+__vputmap:
+  push ix
+  call _vputmap
+  pop ix
+  ret
 
 showstatsS:
-  push ix
   ld  hl,txtLevel
-  call _vputs
+  call __vputs
   ld  a,(Level)
   cp  10
   jr  c,tilllevel9
@@ -1302,12 +1331,11 @@ showstatsS:
   push af
   ld  a,l
   add a,'0'
-  call _vputmap
+  call __vputmap
   pop af
 tilllevel9:
   add a,'0'
-  call _vputmap
-  pop ix
+  call __vputmap
 
   ld  a,98
   ld  (_penCol),a
@@ -1323,12 +1351,17 @@ Left =$-1
   push af
   call _divAby10
   add a,'0'
-  call _vputmap
+  call __vputmap
   pop af
   add a,'0'
-  call _vputmap
+  call __vputmap
   ld  hl,txtLeft
-  jp _vputs
+  pop ix
+__vputs:
+  push ix
+  call _vputs
+  pop ix
+  ret
 
 showLevel:
   ld  hl,txtLevel
@@ -1894,11 +1927,24 @@ LevelsR:
   .db 1
   .db 8,29,32,20
 
+LevelsH:
+
+  .db 8,5,5
+huntersize = 31
+  .db $40,28,2,$C0,28,125, $00,2,63,$80,54,63
+  .db 128,57
+  .db 0
+  .db 4
+  .db 4,19,16,14
+  .db 4,19,80,14
+  .db 4,19,16,34
+  .db 4,19,80,34
+
 NUM_LEVELS = 9
 
 LevelsS:
 
-  .db 5,4,15        ;5 peas, speed 5
+  .db 5,4,15        ;peas,speed,begin_size
   .db 0,2,63        ;d,y,x
   .db 128,57        ;field width, height
   .db 0             ;no additional lines
@@ -2050,7 +2096,7 @@ datafoodm:  .db %10010000
 datalinkm:  .db %00000011
             .dw LevelsDM
 datahuntin: .db %00110100
-            .dw LevelsDM
+            .dw LevelsH
 datarace:   .db %11000000
             .dw LevelsR
 datactf:    .db %00000000
@@ -2061,16 +2107,16 @@ datadomin:  .db %00000000
 
 setdata = 18
 resbit  = 2 ;and%11111011
-worm1set:  .dw $B000,$B000 ;10110000
+worm1set:  .dw $B000,$B000 ;%10110000
            .db 3,0,%01111110,%10,%100 ;< >
            .db "Worm #1",0
-worm2set:  .dw $B800,$B800 ;10111000
+worm2set:  .dw $B800,$B800 ;%10111000
            .db 3,0,%00111111,%10000,%1000 ;f1 f2
            .db "Worm #2",0
-worm3set:  .dw $E800,$E800 ;11101000 ;$D748+$1000+
+worm3set:  .dw $E800,$E800 ;%11101000 ;$D748+$1000+
            .db 3,0,%01011111,%10,%100 ;sto ,
            .db "Worm #3",0
-worm4set:  .dw $F000,$F000 ;11110000
+worm4set:  .dw $F000,$F000 ;%11110000
            .db 3,0,%01111101,%10,%1 ;enter +
            .db "Worm #4",0
 worm1 = $B400
@@ -2084,14 +2130,15 @@ pos     = 2   ;level*
 pos2    = 4   ;level
 grow    = 6   ;level
 died    = 8   ;game
-delay   = 9   ;game
-score   = 10  ;game
+score   = 9   ;game
+delay   = 11  ;game
 
 head    = 12  ;level
 tail    = 14  ;level
 lives   = 16  ;game
 reserv  = 17  ;loop
- ;race=lap
+ ;race:lap
+ ;hunt:time
 input   = 18  ;&
 left    = 19  ;&
 right   = 20  ;&
@@ -2100,11 +2147,11 @@ name    = 21  ;game
 Level =$+1
 DispBuffer =$+2 ;912 bytes
 
-ScrBuffer   = $8200 ;32x256 bytes
-SinCosTable = $A200
+ScrBuffer   = $8200 ;-$A1FF (32x256)
+SinCosTable = $A200 ;-$A300 (4x64)
 
 ;-----------------------------
 ;----------- end -------------
 ;-----------------------------
 
-.end
+.end
\ No newline at end of file