; Title : Worm
-; Version : 90%
-; Release Date : april 2000???
-; Filename : worm.86p (4kb)
+; Version : 91%
+; Release Date : may 2000
+; Filename : worm.86p (5kb)
; Author(s) : Shiar
; Email Address : shiar@mailroom.com
; ICQ UIN : #43840958
;----------- TO-DO -----------
;-----------------------------
-; 90% = DONE
+; 91% = DONE
-; 3% * linkplay
+; 2% * fix deaths linkplay and transmit game/level data
; 2% * make linkplay available for all gametypes (not just deathmatch)
; 1% * fix pea XOR problem in ctf (+dom?)
+; * fix wormstop
; 1% * domination?: take control points by running over them and hold them
; * customizable keys
; * complete readme (+custom level info)
;-----------------------------
;-----------------------------
-#define buffer ;use display buffer (otherwise write directly to screen)
+#define buffer ;use display buffer (otherwise write directly to screen)
+#define readymask ;"grays" out the field before starting a level
+
+;#define readytext ;displays "prepare" before level starts
+;#define invincible ;worms cannot die =)
#define cal call
#define psh push
_PTEMP_END = $D29A ;end of VAT
_load_ram_ahl = $462F ;ahl->page+hl
_writeb_inc_ahl = $5567 ;ld (ahl),c
+_jforce = $409C ;TI-OS stack restored
;-----------------------------
;------- data storage -------
.org _asm_exec_ram
-WormVersion = 090
+WormVersion = 091
start:
nop
.dw WormIcon
WormMsg:
- .db "WORM by SHIAR -- pre-beta 90%",0
+ .db "WORM by SHIAR -- pre-beta 91%",0
WormIcon:
.db 9,2
.db %10010110,%01101111
.db %11000011,%10000000
levelhead = 'w'
-levelhead2 = 90 ;worm levels header = "90"
+levelhead2 = 91 ;worm levels header = "91"
Start:
ld (SpSave),sp
cal _puts ;---
dec e ;$0206
ld (_curRow),de
- cal _puts ;Level
+ cal _puts ;Level <00>
dec e ;$0205
ld (_curRow),de
- cal _puts ;Worms: 2
+ cal _puts ;Worms <2>
dec e ;$0204
ld (_curRow),de
ld hl,(CURtxtGame)
notselect
cp K_EXIT
jp z,ExitNoStats
+ cp K_LEFT
+ jr z,selleft
cp K_RIGHT
ld a,b
jr nz,mainMenu
ld hl,nrlevels
add hl,de
ld d,(hl) ;max level for sel.game
+curlevel =$+1
ld a,1
-curlevel =$-1
inc a
cp d
jr c,changedlevel
- ld a,1
+ ld a,d
changedlevel:
ld (curlevel),a
-dispcurlevel:
- ld hl,$0806
+_dispcurlevel:
+ ld hl,$0906
ld (_curRow),hl
cal showA
+_mainMenu:
+ jr mainMenu
+
+selleft:
+ ld a,b
+ dec a
+ jr z,bchangenrworms
+ dec a
+ jr nz,mainMenu
+
+bchangelevel:
+ ld a,(curlevel)
+ dec a
+ jr nz,changedlevel
jr mainMenu
changegame:
cal _puts
ld (NEXTtxtGame),hl
howmanyworms:
+ ld hl,nrworms
ld a,(Gametype)
cp 2
- ld a,1
- jr c,oneworm
-nrworms =$+1
- ld a,2
-oneworm:
- jr dispnrworms ;jr mainMenu
+ ld (hl),1
+ jr c,dispnrworms
+ inc (hl) ;2
+ jr dispnrworms ;mainMenu
changenrworms:
ld a,(Gametype)
- cp 2
- jr c,mainMenu ;type 0/1
+ cp 2 ;&&
+ jr c,_mainMenu ;type 0/1
ld hl,nrworms
ld a,(hl)
inc a
cp 5
- jr c,changednrworms
- ld a,1
+ jr nc,dispcurlevel
changednrworms:
ld (hl),a
dispnrworms:
+ ld a,(hl) ;hl=nrworms
ld hl,$0905
ld (_curRow),hl
- cal showA
+ add a,'0'
+ cal _putc
+dispcurlevel
ld a,(curlevel)
- jr dispcurlevel ;mainMenu
+ jr _dispcurlevel ;mainMenu
+
+bchangenrworms:
+ ld hl,nrworms
+ ld a,(hl)
+ dec a
+ cp 2 ;2-4
+ jr nc,changednrworms
+ jr dispcurlevel
menucall:
psh bc
cp 2
ld a,1
jr c,wormnrname
- ld a,(nrworms)
+nrworms =$+1
+ ld a,1
wormnrname:
add a,'0'
cal _putc
sub '0'
+
+ ld d,a ;1x
add a,a ;2x
ld e,a
add a,a ;4x
add a,a ;8x
add a,a ;16x
add a,e ;18x
+ add a,d ;19x
ld e,a
- ld d,0
- ld ix,worm1name-18
+ ld d,0 ;de=a
+
+ ld ix,worm1name-19
add ix,de
ld a,maxnamelength
cal entername
entername:
ld h,1
- ld l,h
+ ld l,h ;)
ld (_curRow),hl
ld (namelength),a
enternameloop:
chartable:
.db 0,".<>!",0,0,0,0 ;down,L,R,up
- .db 0,"xtoje0",0 ;enter..clear
- .db " wsnid9",0 ;(-)..custom
- .db "zvrmhc8",0 ;dot..del
- .db "yuqlgb7#" ;0..xvar
- .db 0,"-pkfa6'" ;on..alpha
- .db "54321*",0,0 ;F5..more
+ .db 0,"XTOJE0",0 ;enter..clear
+ .db " WSNID9",0 ;(-)..custom
+ .db "ZVRMHC8",0 ;dot..del
+ .db "YUQLGB7#" ;0..xvar
+ .db $D9,"-PKFA6'" ;on..alpha
+ .db "54321*",0,$D0 ;F5..more
;--proc
skipballs:
inc hl
dnz skipballs
+
+skipflags:
+ ld a,(Gametype)
+ cp gamectf
+ jr nz,noflagstoskip
+ inc hl
+ inc hl
+ inc hl
+ inc hl
+noflagstoskip:
+
cal skiplines ;lines
skiplines: ;boxes
ld a,(hl) ;lines/boxes
add a,a
inc a
ld b,a ;4x(hl)+1
+
skiplb
inc hl
dnz skiplb
cal _puts
cal receive
cp WormVersion
- jp nz,LinkBreak
+ jp nz,linkiniterror
cal send
jr multiplayer
+linkiniterror:
+ pop hl
+ jp DisplayMenu
+
client:
ld hl,txtReceive
cal _puts
- cal ReceiveByte
- jp c,LinkBreak
+ cal Qreceive
+ jp c,linkiniterror
cp WormVersion
- jp nz,LinkBreak
+ jp nz,linkiniterror
ld hl,SwapPos
ld (hl),$f6
toobad_noballs:
ex de,hl
+#ifndef invincible
ld (thislevel),de
+#endif
ld hl,worm1
ld a,(gameCar)
ld c,64
ldir
-;-draw lines-
pop hl ; << levelp
+ ld a,(Gametype)
+ cp gamectf
+ jr nz,noctf
+ ld de,peaspos
+ ld bc,4
+ ldir
+ psh hl
+ cal DrawAllPeas
+ pop hl
+noctf:
+
+;-draw lines-
+
ld a,(hl)
inc hl
or a
psh hl ; >> levelp new
cal showstats
- ld a,(Gametype)
- cp gamectf
- jr nz,noctf
- ld hl,$1010
- ld (peaspos),hl
- cal DrawPea
- ld hl,$2010
- ld (peaspos+2),hl
- cal DrawPea
-noctf:
ld a,(gameCar)
and _datafood
jr z,nofood
nofood:
ld bc,(worm1+pos)
cal DisplayField
+
+#ifdef readymask
+ ld hl,$FC70
+ ld d,%10101010
+ ld c,56
+maskloop:
+ ld a,d
+ xor %11111111
+ ld d,a
+ ld b,$10
+maskline:
+ ld a,(hl)
+ or d
+ ld (hl),a
+ inc hl
+ dnz maskline
+ dec c
+ jr nz,maskloop
+#endif
+
+#ifdef readytext
ld hl,$FDE0
ld de,$FDE1
ld (hl),%11111111
ld hl,txtReady
cal _puts
res 3,(iy+5)
+#endif
ld a,0
gameCar =$-1
ld (worm2+heading),a
initfinished:
- ld b,0
+ ld b,startdelay
ReadyDelay:
halt
dnz ReadyDelay
+ cal releasekeys
;-----------------------------
;----------- LOOP ------------
jr Exit
WormDead:
+#ifdef invincible
+ jp stopworm
+#else
ld a,2
ld (flashtime),a
ld (ix+delay),respawndelay
ld a,$A7 ;exit@end of turn
ld (CheckExit),a ;set exit state
ret ;finish turn
+#endif
Exit:
ld sp,0 ;pop all
ld bc,input-died
add hl,bc ;+input
xor a
- cp (hl)
+ cp (hl) ;input=0 = link
jr nz,NoLinkIndic
ld b,7
inc hl ;+left
ld a,13
ld (_curCol),a
ld a,(hl) ;worm+died
- psh hl
cal showA
pop hl
+ psh hl
ld a,16
ld (_curCol),a
checkhilevel:
ld hl,nrlevels
ld a,(Level)
- inc a
cp (hl)
jr c,hilevelcheckdone
ld (hl),a ;save local
cal showHL
hiscorecheckdone:
+ cal releasekeys
waitkey:
halt
halt
cal GET_KEY
cp K_ENTER
jp z,DisplayMenu
-; cp K_EXIT
+ cp K_SECOND
+ jp z,DisplayMenu
+ cp K_EXIT
jr nz,waitkey
;x123456789012345678901
cal _SET_MM_NUM_BYTES
cal _mm_ldir
+ cal releasekeys
res 4,(iy+9)
set 2,(iy+13)
jp _clrWindow
;----------- worm ------------
;-----------------------------
-inlink:
- ld a,0
-sendbyte =$-1
- ld b,(ix+left)
- dec b
- jr z,receivefirst
- cal send
- cal receive
- ld l,a
- ret
-receivefirst:
- psh af
- cal receive
- ld l,a
- pop af
- psh hl
- cal send
- pop hl
- ret
-
-inkeys: ;use jp not call!
- out (1),a ;nop\nop
- in a,(1)
- ld b,a
- and (ix+right)
- jr z,notright
- ld a,l
- add a,8
- ld l,a
-notright:
- ld a,b
- and (ix+left)
- ret z
- ld a,l
- sub 8
- ld l,a
- ret
-
-chkinput:
- ld bc,donediddelydone
- psh bc ;ret-dest.
-inputcall:
- ld a,(ix+input)
- or a
- jr nz,inkeys
- jr inlink
-
respawncheck:
cp respawndelay-1
jr nz,unnamedlabel
;de=ix+head
ld (ix+tail+1),d
ld (ix+tail),e ;head=tail/size=0
+ jr norespawn
ret
unnamedlabel:
ret z
saverespawncounter:
ld (ix+delay),a
+norespawn:
+ ld a,(gameCar)
+ and _datalink
+ jr nz,inlink
+ ret
+
+inkeys: ;use jp not call!
+ out (1),a ;nop\nop
+ in a,(1)
+ ld b,a
+ and (ix+right)
+ jr z,notright
+ ld a,l
+ add a,8
+ ld l,a
+notright:
+ ld a,b
+ and (ix+left)
+ ret z
+ ld a,l
+ sub 8
+ ld l,a
+ ret
+
+inputcall:
+ ld a,(ix+input)
+ or a
+ jr nz,inkeys
+
+inlink:
+ ld a,0
+sendbyte =$-1
+ ld b,(ix+left)
+ dec b
+ jr z,receivefirst
+ cal send
+ cal receive
+ ld l,a
+ ret
+receivefirst:
+ psh af
+ cal receive
+ ld l,a
+ pop af
+ psh hl
+ cal send
+ pop hl
ret
;------- handle worm ---------
HandleWorm:
ld a,(ix+delay)
dec a
- jr nz,respawncheck
+ jp nz,respawncheck
ld l,(ix+heading)
- jr chkinput
+ cal inputcall
donediddelydone:
ld a,l
ld (sendbyte),a
;----------- procs -----------
;-----------------------------
+releasekeys:
+ halt
+ ld a,%10000000 ;all key-masks
+ out (1),a
+ in a,(1)
+ inc a ;cp %11111111 (no keys pressed)
+ jr nz,releasekeys ;keep waitin
+ cal GET_KEY ;clear buffer
+ ret
+
resbit:
ld a,h
and (ix+storepos)
;----------- link ------------
;-----------------------------
-#ifdef 0
TIMEOUT = $1000
+LinkBreak:
+ pop hl
+ ld a,D0HD1H
+ out (7),a
+ jp Exit
+
+
receive:
cal GET_KEY
cp K_EXIT
and %11
cp %11
jr z,receive
- cal Qreceive
+ in a,(7)
+ and %11
+ cp %11
+ jr z,receive
+ ld b,8
+ cal ReceiveCont
jr c,receive
ret
Qreceive:
ld b,8
- jr ReceiveCont
receiveloop:
ld de,TIMEOUT
WaitRecBit:
cp %11
jr z,WaitRecBit
ReceiveCont:
- sub 2
- ld a,2
+ sub %10
+ ld a,%10
ld d,D0LD1H
jr c,ReceiveLow
rra
ld d,D0HD1L
ReceiveLow:
- rr c
- ld (AckBit),a
- ld a,d
+ rr c
+ ld (AckBit),a
+ ld a,d
out (7),a
ld de,TIMEOUT
WaitAckRec:
jr nz,WaitReadyRec
ReadyRec:
dnz receiveloop
- jr LinkSuccess
+ ld a,c
+ ret
send:
- ld b,9
ld c,a
+ ld b,8+1
jr SendAcked
-SendBits:
+
+sendloop:
rr c
ld a,D0LD1H
jr nc,SendLow
cal CheckLink
cp %11
jr nz,WaitReadySend
- dnz SendBits
+ dnz sendloop
LinkSuccess:
- ld a,c ;pop a
- ret
-
+ .db $F6 ;or NN (skip scf)
LinkFailed:
scf
- ld a,c
+ ld a,c
ret
-LinkBreak:
- ld a,D0HD1H
- out (7),a
- jp Exit
CheckLink:
pop hl
ld a,$BF
out (1),a
- nop \ nop
+; nop \ nop
in a,(1)
psh af
ld a,%11111111
out (1),a
pop af
bit 6,a
+ jr z,LinkFailed
in a,(7)
and %11
jp (hl)
-#endif
-
-LinkBreak:
- pop hl
- ld a,D0HD1H
- out (7),a
- jp DisplayMenu
-
-
-receive:
- cal GET_KEY
- cp K_EXIT
- jp z,LinkBreak
- cal TryReceiveByte
- jr c,receive
- ret
-
-
-LINKPORT =7
-TIMEOUT =$1000
-LINKMASK =3
-
-LinkPrep:
- ex (sp),hl
- push bc
- push de
-; ld b,(iy+12h)
-; push bc
- set 2,(iy+12h)
- ld b,8
- jp (hl)
-
-TryReceiveByte:
- in a,(LINKPORT)
- and LINKMASK
- cp LINKMASK
- scf
- ret z
-ReceiveByteCont:
- call LinkPrep
- jr ReceiveCont
-ReceiveByte:
- call LinkPrep
-ReceiveBits:
- ld de,TIMEOUT
-WaitRecBit:
- call CheckLink
- jr z,LinkFailed
- cp LINKMASK
- jr z,WaitRecBit
-ReceiveCont:
- sub LINKMASK/3*2
- ld a,LINKMASK/3*2
- ld d,D0LD1H
- jr c,ReceiveLow
- rra
- ld d,D0HD1L
-ReceiveLow:
- rr c
- ld (AckBit),a
- ld a,d
- out (LINKPORT),a
- ld de,TIMEOUT
-WaitAckRec:
- call CheckLink
- cp 0
-AckBit =$-1
- jr nz,WaitAckRec
- ld a,D0HD1H
- out (LINKPORT),a
- ld d,4
-WaitReadyRec:
- dec d
- jr z,ReadyRec
- in a,(LINKPORT)
- cp LINKMASK
- jr nz,WaitReadyRec
-ReadyRec:
- djnz ReceiveBits
- jr LinkSuccess
-
-send:
-SendByte:
- call LinkPrep
- ld c,a
-
- inc b
- jr SendAcked
-
-SendBits:
- rr c
- ld a,D0LD1H
- jr nc,SendLow
- ld a,D0HD1L
-SendLow:
- out (LINKPORT),a
- ld de,TIMEOUT
-WaitAckSend:
- call CheckLink
- jr nz,WaitAckSend
-SendAcked:
- ld a,D0HD1H
- out (LINKPORT),a
- ld de,TIMEOUT
-WaitReadySend:
- call CheckLink
- cp LINKMASK
- jr nz,WaitReadySend
- djnz SendBits
-LinkSuccess:
- or 0
-.org $-1
-LinkFailed:
- scf
- ld a,c
- res 2,(iy+12h)
- pop de
- pop bc
- pop hl
- ret
-
-CheckLink:
- pop hl
- dec de
- ld a,d
- or e
- jr z,LinkFailed
- ld a,0BFh
- call _readkeypad
- bit 6,a
- jr z,LinkFailed
- in a,(LINKPORT)
- and LINKMASK
- jp (hl)
-
-_readkeypad:
- out (1),a
- in a,(1)
- push af
- ld a,255
- out (1),a
- pop af
- ret
-
-
-TEST_2:
- ld b,8
-T2delay:
- halt
- dnz T2delay
- in a,(7)
- and %11
- ld b,a
- ld a,'1'
- rr b
- jr c,T2no1
- ld a,'-'
-T2no1:
- cal _putc
- ld a,'2'
- rr b
- jr c,T2no2
- ld a,'-'
-T2no2:
- cal _putc
- cal GET_KEY
- cp K_EXIT
- jp z,DisplayMenu
- jr TEST_2
-
;-----------------------------
;---------- levels -----------
txtMenu: .db "by Shiar",0
.db "Have fun!",0 ;4th menu item
- .db "Level 00",0 ;3rd
- .db "Worms: 0",0 ;2nd
+ .db "Level ",$CF,"??",5,0 ;3rd
+ .db "Worms ",$CF,"?",5,0 ;2nd
txtGame: .db "Singleplayer",0 ;0 (1st)
txtGame2: .db "Peaworm ",0 ;1 (next 1st)
.db "Deathmatch",0 ;2
name = 22
wormsize = 31
+startdelay = 30
respawndelay = 30
maxnamelength = 8+1
.org $F3E3-16
- .db 'w',90
+ .db 'w',91
.db 16,"Worm LevelPack I"
.dw hiscore-single
.dw ctf
.dw domination
- .db 2,3,4,2
- .db 2,2,2,2
+ .db 1,2,3,1
+ .db 1,1,2,1
;---------- LEVELS ----------
foodmatch:
-ctf:
domination:
.db 8,5,18,15,0,0
.db $40,30,2,$C0,30,125, $00,2,64,$80,54,64
.db 52,10,74,37
+ctf:
+ .db 8,5,18,15,0,0
+ .db $20,2,2,$A0,54,125, $20,2,7,$A0,54,120
+ .db 128,57
+ .db 9,117,46,10
+ .db 0,0
+
+ .db 8,5,18,15,0,0
+ .db $60,54,2,$E0,2,125, $60,49,2,$E0,7,125
+ .db 128,57
+ .db 9,10,46,117
+ .db 0,1
+ .db 20,14,107,31
+
+
hiscore:
.dw 0
- .dw 1,2
+ .dw 0,0
.end