OTS EQU #7F00
;PROG ENDS #AFD2
;57*2=114 bytes UPPR period
FD EQU 32765
TEAMLEN EQU 16
COLOUR EQU 7
TITLCOL EQU 71
PGMASK EQU #17
BOMBWMS EQU #C000
MASK EQU #E000
PGLMN EQU #14
LMNS EQU #C000
NLMN EQU 15
WIDTH EQU 93
MASKWD EQU 46
SCRHGT EQU 17*8
DOPRSZ EQU 56
UPPRSZ EQU SCRHGT-DOPRSZ
DOPRSCR EQU -DOPRSZ*4+#4981
MAPHGT EQU 22*8
MASKHGT EQU MAPHGT/2
DOMAP EQU 256-MAPHGT
DOMASK EQU DOMAP/2-4
MAPDO EQU -WIDTH*DOMAP+#C000
MASKDO EQU -MASKWD*DOMASK+MASK
MASKSZ EQU MAPHGT/2*MASKWD
IMTAB EQU #BE00
IMER EQU #BFBF
TEXTUR EQU #5B00
ORG #6000
FONT
+ INCBIN "w64fnt
ORG #6200
WATER
+ INCBIN "water
PROGPW EQU #6300
TY4TOP EQU #6600
TY4LOW EQU TY4TOP+256
TABROW EQU #6800
DTNTAB EQU #6A00
TABSIN EQU #6A00
TABY EQU #6B00 ;256+256
TAB4 EQU #6D00 ;512
LMNBUF EQU #7000
LMNSZ EQU #800
TABROLL EQU #7A00
TPLACES EQU #6A00
TXY EQU TPLACES+#E0
TMASKLN EQU #7B00 ;512
WORMXY EQU #6E00
MAXWXY EQU 98
;TEAM,WORM,ENERGY,WEAPON,AIM,0
CUWORMS EQU #6EA0 ;96
TITBUF EQU #6F00
ORG #BF01
BLANK DS IMER-$
ORG #7D00
FONT88
+ INCBIN "w88?fnt
ORG LMNS,PGLMN
INCBIN "lmn
GUG
+ INCBIN "gug
ORG OTS
CALL 7766
CALL NOTWICE
LD HL,TITBUF
LD (HL),L
NACHALO
LD DE,MAPDO
LD BC,WIDTH
LD L,B
MKTBROW LD H,'TABROW
LD (HL),E
INC H
LD (HL),D
BIT 6,D
JR NZ,$+6
LD (HL),#C0
DEC H
LD (HL),B
EX DE,HL
ADD HL,BC
EX DE,HL
INC L
JR NZ,MKTBROW
LD HL,TLAND
MAPBAK CALL MTITLE
LD HL,(STTIT+1)
CALL UTITLE
CALL MAPER
LD HL,TABY
LD DE,TABY+1
LD BC,511
LD (HL),L
LDIR
LD DE,#4060
LD L,C
LD B,SCRHGT/2
MKTBDHL LD A,L
AND 7
JR NZ,$+4
LD (HL),32
INC L
LD (HL),D
INC D
CALL DDE
INC L
DJNZ MKTBDHL
CALL MAKPW
LD DE,#4060
LD HL,TY4TOP
LD B,128
MKTY4 LD (HL),E
INC L
LD (HL),D
INC L
PUSH DE
LD D,'TY4TOP
LD A,L
AND 31
LD E,A
LD A,(DE)
INC E
LD (HL),A
INC L
LD A,(DE)
LD (HL),A
POP DE
CALL DDE
INC HL
DJNZ MKTY4
LD L,B
LD DE,MASKDO
LD C,MASKWD
MKTBMSK LD H,'TMASKLN
LD (HL),E
INC H
LD (HL),D
LD A,L
CP -8
JR NC,$+6
BIT 5,D
JR NZ,$+7
LD (HL),'BLANK
DEC H
LD (HL),BLANK
RRA
JR NC,$+5
EX DE,HL
ADD HL,BC
EX DE,HL
INC L
JR NZ,MKTBMSK
LD H,'TABY
MKTDHLL LD A,L
RLA
RLA
AND #E0
SUB -96
LD (HL),A
INC L
JR NZ,MKTDHLL
LD H,'TABSIN
XOR A
LD B,22
DB "w#
ADD A,B
DJNZ $-3
CALL INIMOUS
LD HL,MESHOM
CALL MTITLE
CALL PASCOL
CALL SETTIM
CALL ENPANEL
LD HL,TABROLL
LD C,1
MKTRL LD A,L
AND 31
JR NZ,$+4
RRC C
LD (HL),C
INC L
JR NZ,MKTRL
LD HL,UPPR
LD DE,#4061
LD B,UPPRSZ
CALL MAKEPR
LD (DOPR+1),HL
CALL READER
LD HL,(MOUSE+1)
LD A,L
AND 3
XOR 1
INC A
XOR 18
LD BC,FD
OUT (C),A
XOR A
LD B,A
LD C,H
LD A,H
RLCA
ADD A,UPPRSZ
LD H,A
LD A,L
RRA
SRL A
LD L,H
LD H,'TABROW
ADD A,(HL)
LD LY,A
INC H
LD A,B
ADC A,(HL)
LD HY,A
LD A,60
SUB C
JR NC,DOPR_-7
SBC A,C
SUB C
LD C,A
LD L,C
LD H,B
DB ")))
DUP 2
ADD HL,BC
DB ")
EDUP
DB 1,0
LD (DOPRHL+1),HL
INC HL
CALL READER
DB 1
ADD HL,BC
LD (DOPRA+1),HL
LD (HL),#DD
INC HL
INC HL
LD (HL),#C9
DOPR_ LD BC,WIDTH
INC HL
LD DE,DOPRSCR
LD B,DOPRSZ
CALL MAKEPR
LD BC,-57*90-1
ADD HL,BC
DOPRHL LD (0),HL
LD A,'IMTAB
CALL MAKINT
LD IX,-2
ADD IX,SP
CALL PRnrg
START EI
HALT
DI
LD A,3
OUT (-2),A
LD A,-64
LD HY,'TY4TOP
CALL WORMS
LD A,7
OUT (-2),A
; CALL CURSOR
STCNT LD A,1
DEC A
JR NZ,STNOTIT
STTIT LD HL,TITBUF
CP (HL)
CALL NZ,UTITLE
JR $+5
STNOTIT LD (STCNT+1),A
LD A,5
OUT (-2),A
DOPR CALL 0
DOPRA LD HL,0
LD (HL),#FD
INC HL
INC HL
LD (HL),#E1
LD A,2
OUT (-2),A
CALL PRWAT
LD BC,999
LD D,B
NOLDIR LDIR
LD A,3
OUT (-2),A
XOR A
LD HY,'TY4LOW
CALL WORMS
XOR A
OUT (-2),A
; CALL CURSOR
CALL MOUSE
LD A,4
OUT (-2),A
CALL WRMOVE
LD A,7
OUT (-2),A
; CALL MANAGE
CALL TIME
LD A,1
OUT (-2),A
CALL CLRTOP
CALL UPPRU
XOR A
OUT (-2),A
CALL 8020
RET NC
LD A,127
IN A,(-2)
RRA
; CALL NC,FIRE
LD A,-3
IN A,(-2)
BIT 1,A
CALL Z,SETWMS
LD A,#FB
IN A,(-2)
BIT 3,A
JP Z,NACHALO
JP START
NOTWICE HALT
LD A,(23672)
LD HL,BUF
LD DE,#4000
LD BC,#1000
LDIR
CP (IY+62)
LD A,B
JR Z,$+5
LD (NOLDIR),A
LD B,11
LDIR
LD HL,TAB4
LD DE,#C000
LD BC,64
MAKET4 LD (HL),E
INC H
LD (HL),D
DEC H
EX DE,HL
ADD HL,BC
EX DE,HL
INC L
JR NZ,MAKET4
LD DE,TEXTUR
LD HL,#4020
LD B,32
GPATRN PUSH BC
LD BC,4
LDIR
LD B,4
GP1 DEC L
LD (HL),C
DJNZ GP1
CALL DHL
POP BC
DJNZ GPATRN
LD A,PGMASK
CALL OUTME
LD H,'BOMBWMS
GWMSMIR LD C,64 ;SPRITES QUANTITY
LD E,0
GWMS0 LD L,E
LD D,64
PUSH HL
LD B,8
GWMS1 PUSH BC
PUSH HL
LD A,(DE)
LD C,1
RRCA
RL C
JR NC,$-3
BIT 0,B
LD B,A
LD A,C
LD (DE),A
LD C,0
CALL Z,GETSUB
CALL NZ,GETSUB2
POP HL
INC D
INC H
INC H
POP BC
DJNZ GWMS1
POP HL
INC E
DEC C
JR NZ,GWMS0
LD A,H
LD H,'BOMBWMS+16
CP H
JR NZ,GWMSMIR
RET
GETSUB SRL B
RR C
SRL B
RR C
LD (HL),B
INC H
LD (HL),C
DEC H
LD A,L
ADD A,64
LD L,A
JR NC,GETSUB
XOR A
RET
GETSUB2 SRL B
RR C
SRL B
RR C
LD (HL),C
INC H
LD (HL),B
DEC H
LD A,L
ADD A,64
LD L,A
JR NC,GETSUB2
RET
MAKINT DI
LD BC,256
LD H,A
LD D,A
LD E,B
LD L,C
LD (HL),IMER
LDIR
LD L,(HL)
LD H,L
LD (HL),251
INC HL
LD (HL),201
LD I,A
IM 2
EI
RET
MAKEPR PUSH BC
LD (HL),253
INC HL
LD (HL),249
INC HL
LD B,9
MPR0 LD (HL),225
INC HL
LD (HL),34
INC HL
LD (HL),E
INC HL
LD (HL),D
INC HL
INC E
INC E
DJNZ MPR0
CALL READER
POP HL
POP DE
POP AF
EXX
POP BC
POP DE
POP HL
DEFB 49,0
LD A,E
SUB -12
LD (HL),A
SUB 30
LD E,A
INC HL
LD (HL),D
INC HL
CALL READER
PUSH HL
PUSH DE
PUSH BC
EXX
PUSH AF
PUSH DE
PUSH HL
ADD IY,BC
NOP
CALL DDE
POP BC
DJNZ MAKEPR
DEC HL
DEC HL
LD (HL),221
INC HL
LD (HL),249
INC HL
LD (HL),201
INC HL
RET
MAPER LD A,22
CALL OUTME
LD HL,GUG
LD (PRGUG+1),HL
LD HL,(23670)
LD (MAPERND+1),HL
CALL MAPERPP
LD HL,#FFEF
LD B,WIDTH
XOR A
OR (HL)
DEC HL
DJNZ $-2
JR Z,MAPER
CALL PRGUG
LD A,16
CALL OUTME
MAPERND LD HL,0
LD (23670),HL
CALL MAPERPP
CALL PRGUG
LD HL,#C000
LD DE,WIDTH
LD C,E
MAPERF PUSH HL
LD B,MAPHGT
XOR A
MAPERF0 XOR (HL)
LD (HL),A
ADD HL,DE
DJNZ MAPERF0
POP HL
INC L
DEC C
JR NZ,MAPERF
CALL PRGUG
LD HL,#C001
LD DE,BUF
PUSH DE
LD B,88
MAPER41 PUSH BC
LD B,MASKWD
MAPER42 LD A,(HL)
DUP 4
RLA
RLA
RL C
EDUP
INC HL
LD A,(HL)
DUP 4
RLA
RLA
RL C
EDUP
INC HL
LD A,C
LD (DE),A
INC DE
DJNZ MAPER42
LD C,WIDTH-MASKWD*2
ADD HL,BC
POP BC
DJNZ MAPER41
CALL PRGUG
LD HL,#C000
LD DE,WIDTH
LD B,E
LD C,D
MAKE4ST PUSH BC
PUSH HL
LD B,'TEXTUR
MAKE4SA LD A,(BC)
AND (HL)
LD (HL),A
LD A,C
SUB -4
AND 127
LD C,A
ADD HL,DE
JR NC,MAKE4SA
POP HL
INC L
POP BC
INC C
RES 2,C
DJNZ MAKE4ST
CALL PRGUG
LD A,22
CALL OUTME
LD (MAPERSP+1),SP
DI
LD SP,WIDTH
LD HL,#C000
LD C,128
MAPERG LD A,C
RRC C
OR C
LD B,A
LD (MAPERGQ+1),HL
MAPERG0 LD A,(HL)
AND C
JR NZ,MAPERGC
MAPERGA ADD HL,SP
JR NC,MAPERG0
JR MAPERGQ
MAPERGC XOR (HL)
LD (HL),A
LD DE,SPRGRND
SBC HL,SP
JR MAPERGB
MAPERG1 LD A,(HL)
AND C
JR NZ,MAPERGA
MAPERGB LD A,(DE)
OR A
JR Z,MAPERGE
AND B
OR (HL)
LD (HL),A
INC DE
MAPERGN ADD HL,SP
JR NC,MAPERG1
JR MAPERGQ
MAPERG2 LD A,(HL)
AND C
JR NZ,MAPERGA
MAPERGE ADD HL,SP
JR NC,MAPERG2
MAPERGQ LD HL,0
RRC C
JR NC,MAPERG
INC L
LD A,L
CP WIDTH
JR NZ,MAPERG
MAPERSP LD SP,0
CALL PRGUG
LD HL,MASKSZ+BUF
LD BC,MASKWD*256+255
LD (HL),C
INC HL
DJNZ $-2
LD C,3
LMN0 LD A,10
CALL RNDA
ADD A,C
CP MASKWD-5
JR NC,LMNQ
LD C,A
PUSH BC
LD A,PGLMN
CALL OUTME
LD A,NLMN
CALL RNDA
SCF
RLA
POP BC
CALL PRLMN
JR LMN0
LMNQ
LD A,PGMASK
CALL OUTME
POP HL
LD DE,MASK
LD BC,MASKSZ
LDIR
XOR A
LD DE,TPLACES
LD (DE),A
INC E
JR NZ,$-2
DEC HL
LD LX,C
LD C,64
LD E,MASKWD*4-5
SETF RLC C
RLC C
JR NC,$+3
DEC HL
PUSH DE
PUSH HL
LD DE,-MASKWD
LD B,MASKHGT-1
SETF0 ADD HL,DE
LD A,C
AND (HL)
JR NZ,SETF1
DJNZ SETF0
JR SETFQ
SETF1 ADD HL,DE
DEC B
AND (HL)
JR NZ,SETF1
INC LX
SETFQ POP HL
POP DE
LD A,B
LD (DE),A
DEC E
JR NZ,SETF
LD A,16
CALL OUTME
LD A,LX
LD BC,#10FF ;B=QUANTITY OF WORMS
INC C
SUB B
JR NC,$-2
LD A,C
CP 7
JR NC,SETXO
POP HL
LD HL,MESWHE
JP MAPBAK
SETXO
;C=WIDTH OF WORM PLACE
EXX
LD HL,NAMES
EXX
LD HL,TXY
SETX LD B,C
SRL B
PUSH BC
SETX0 INC E
LD A,(DE)
OR A
JR Z,SETX0
DJNZ SETX0
LD (HL),E
INC L
LD A,(DE)
SUB -DOMASK
RLCA
LD (HL),A
LD C,E
SRL C
SUB 13
LD B,A
CP DOMAP
LD A,150
CALL NC,SPRINT
POP BC
LD A,C
SUB B
LD B,A
SETX1 INC E
LD A,(DE)
OR A
JR Z,SETX1
DJNZ SETX1
INC L
JR NZ,SETX
CALL SETWMS
CALL PRGUG
LD HL,#FFEF
MAK4SOR LD A,22
CALL OUTME
LD DE,BUF+#FFB
LD BC,#FFC
PUSH HL
PUSH DE
PUSH BC
LDDR
LD A,16
CALL OUTME
POP BC
POP DE
EX (SP),HL
PUSH BC
PUSH DE
PUSH HL
M4SOR LD A,(DE)
OR (HL)
LD (HL),A
LDD
JP PE,M4SOR
POP DE
POP HL
POP BC
LD A,19
M4SCR PUSH BC
PUSH DE
PUSH HL
PUSH BC
CALL OUTME
POP BC
PUSH AF
M4SRL DUP 11
RL (HL)
EX AF,AF'
RL (HL)
EX AF,AF'
LDD
EDUP
JP PE,M4SRL
POP AF
POP HL
POP DE
POP BC
SUB -3
AND 23
CP 20
JR NZ,M4SCR
POP HL
BIT 6,H
JP NZ,MAK4SOR
PRGUG LD HL,0
LD A,PGLMN
CALL OUTME+3
LD DE,#482D
LD B,40
PRGUG0 LD A,E
DUP 6
LDI
EDUP
LD E,A
CALL DDE
DJNZ PRGUG0
LD (PRGUG+1),HL
PRGA LD A,0
OUTME LD (PRGA+1),A
LD BC,FD
OUT (C),A
RET
SPRINT PUSH DE
PUSH HL
PUSH AF
LD H,'TABROW
LD L,B
LD A,(HL)
INC H
LD H,(HL)
ADD A,C
LD L,A
JR NC,$+3
INC H
PUSH HL
LD DE,WIDTH
LD B,6
SPRINTX PUSH HL
EXX
LD A,(HL)
INC HL
SUB 32
RLA
RLA
RLA
LD E,A
LD A,(HL)
CALL SPRINTP
INC HL
EXX
POP HL
INC HL
DJNZ SPRINTX
POP HL
POP AF
LD BC,WIDTH*7
ADD HL,BC
LD BC,#2F64
INC B
SUB C
JR NC,$-2
ADD A,C
PUSH AF
PUSH HL
OR A
LD A,B
EXX
LD E,0
CALL SPRINTP
EXX
POP HL
INC HL
POP AF
LD BC,10
INC B
SUB C
JR NC,$-2
PUSH AF
LD A,B
EXX
SUB -15
RLCA
RLA
RLA
LD E,A
POP AF
SUB -58
CALL SPRINTP
EXX
POP HL
POP DE
RET
SPRINTP PUSH HL
LD D,'FONT/2
LD H,D
RL D
SUB 32
RLA
RLA
LD L,A
ADD HL,HL
LD B,7
SPRINT0 LD A,(DE)
INC E
RLCA
RLCA
RLCA
RLCA
OR (HL)
INC L
EXX
XOR (HL)
LD (HL),A
ADD HL,DE
EXX
DJNZ SPRINT0
POP HL
RET
PRLMN LD HL,LMNS
PRLMN0 LD E,(HL)
INC HL
LD D,(HL)
INC HL
DEC A
JR Z,PRLMNO
ADD HL,DE
JR PRLMN0
PRLMNO LD D,(HL)
INC HL
LD E,(HL)
INC HL
PUSH HL
PRLMN00 LD HL,BUF
XOR A
LD B,A
ADD HL,BC
LD B,E
PUSH DE
LD DE,MASKWD
OR (HL)
ADD HL,DE
DJNZ $-2
JR NZ,PRLMNhi
INC B
OR (HL)
ADD HL,DE
JR Z,$-3
POP DE
LD A,D
DEC A
RRA
NEG
ADD A,C
LD C,A
JR PRLMNok
PRLMNhi INC C
POP DE
LD A,C
CP MASKWD-5
JR C,PRLMN00
POP AF
RET
PRLMNok XOR A
POP HL
PUSH BC
OR B
PUSH HL
PUSH DE
LD HL,BUF
LD DE,MASKWD
JR Z,$+5
ADD HL,DE
DJNZ $-1
ADD HL,BC
POP BC
POP DE
PRLMN1 PUSH BC
PUSH HL
LD A,(DE)
OR (HL)
LD (HL),A
INC HL
INC DE
DJNZ $-5
POP HL
LD C,MASKWD
ADD HL,BC
POP BC
DEC C
JR NZ,PRLMN1
LD HL,3
ADD HL,DE
LD DE,LMNBUF
PUSH DE
LD BC,LMNSZ
LDIR
POP HL
LD D,(HL)
INC HL
LD E,(HL)
INC HL
POP BC
PUSH BC
XOR A
OR B
PUSH HL
PUSH DE
LD HL,#C000
LD DE,WIDTH*2
JR Z,$+5
ADD HL,DE
DJNZ $-1
ADD HL,BC
ADD HL,BC
LD A,16
CALL OUTME
POP BC
POP DE
PRLMN2 PUSH BC
PUSH HL
LD A,(DE)
INC HL
OR (HL)
LD (HL),A
INC DE
DJNZ $-5
POP HL
LD C,WIDTH
ADD HL,BC
POP BC
DEC C
JR NZ,PRLMN2
LD A,B
POP BC
ADD A,C
LD C,A
RET
MAPERPP LD HL,#C000
LD DE,#C001
LD BC,#3FFF
LD (HL),L
LDIR
CALL FILLDTN
LD E,0 ;SCREEN (X) NO. -1=NOPRINT
LD C,E
CALL RND
AND 127
SUB -48
LD B,A
LD HL,DTNTAB+8 ;14
MAPER0 LD A,2;4
CALL RNDA
CP 1;2
SBC A,0;1
ADD A,L
LD D,L
LD L,A
CALL TESTL
LD A,D
SUB 5
LD D,A
LD A,L
SUB 5
XOR D
AND 8
CALL NZ,PLOT
PUSH HL
SLA L
LD A,(HL)
DEC A
POP HL
LD A,5
JP P,$+5
LD A,3
CALL RNDA
INC A
LD D,A
MAPER1 PUSH HL
SLA L
LD A,(HL)
OR A
CALL NZ,PLOT
LD A,(HL)
CP 128
JR C,MAPERFW
ADD A,C
LD C,A
JR C,MAPERBW
DEC E
JR MAPERBW
MAPERFW CP 2
JR C,MAPERN2
INC C
JR NZ,$+3
INC E
CALL PLOT
LD A,1
MAPERN2 ADD A,C
LD C,A
JR NC,$+3
INC E
MAPERBW INC L
LD A,(HL)
ADD A,B
POP HL
CP 208
JR C,MAPERNY
LD A,17
SUB L
LD L,A
PUSH HL
SLI L
LD A,(HL)
ADD A,B
POP HL
MAPERNY LD B,A
DEC D
JR NZ,MAPER1
LD A,E
CP 4 ;LAST SCREEN
JR NZ,MAPER0
RET
TESTL LD A,L
CP 2
JR NC,TESTLNC
SUB -3
LD L,A
RET
TESTLNC CP 16
RET C
SUB 3
LD L,A
RET
FILLDTN LD HL,DIRECTN
LD DE,DTNTAB
LD BC,32
LDIR
RET
DIRECTN DW #100,#1FF,#FF,#FF
DW -1,#FF00,#FF01,#FF02
DW 2,2,#102,#101,#100,#1FF,#FF,#FF
RND PUSH BC
PUSH HL
LD HL,(23670)
LD BC,537
ADD HL,BC
LD (23670),HL
PUSH HL
LD A,L
AND 15
SUB -10
LD L,H
LD H,A
LD A,(HL)
POP HL
RES 7,H
RES 6,H
XOR (HL)
POP HL
POP BC
RET
RNDA PUSH BC
LD C,A
CALL RND
SUB C
JR NC,$-1
ADD A,C
POP BC
RET
SPRGRND DB #29,-1,#DB,#7E,#D5,#AA,0
;DB #52,-1,#BF,-4,#AB,#55,0
PLOT LD A,B
SUB MAPHGT
RET NC
PUSH BC
PUSH HL
LD H,'TABROW
LD L,A
LD A,C
AND -8
ADD A,E
RRCA
RRCA
RRCA
CP WIDTH
JR NC,PLOTQ
ADD A,(HL)
INC H
LD H,(HL)
LD L,A
JR NC,$+3
INC H
LD A,C
AND 7
INC A
LD B,A
LD A,1
RRCA
DJNZ $-1
XOR (HL)
LD (HL),A
PLOTQ POP HL
POP BC
RET
MTCL LD C,32
XOR A
MTCL0 LD D,80
LD B,8
LD (DE),A
INC D
DJNZ $-2
INC E
DEC C
JR NZ,MTCL0
RET
MTIDEAD LD C,13
LD A,32
FNDLF DEC HL
DEC C
CP (HL)
JR Z,FNDLF
LD A,C
LD DE,MESDIE+11
LDDR
EX DE,HL
ADD A,14
LD (HL),A
MTITLE LD DE,TITBUF
LD B,(HL)
INC B
MTITLEC LD A,(HL)
LD (DE),A
INC HL
INC E
DJNZ MTITLEC
EX DE,HL
LD (HL),B
LD (MTITLE+1),HL
RET
UTITLE LD E,#80
CALL MTCL
PUSH HL
CALL PRBT
POP HL
LD A,15
LD (STCNT+1),A
LD C,(HL)
INC L
LD A,32
SUB C
RET C
SCF
RRA
LD E,A
MT0 LD A,(HL)
INC L
CP 32
JR Z,MTSPC
LD D,80
PUSH HL
LD H,'FONT88/4
RLCA
LD L,A
DB "))
LD B,8
MT1 LD A,(HL)
LD (DE),A
INC D
INC L
DJNZ MT1
LD D,90
LD A,TITLCOL
LD (DE),A
POP HL
MTSPC INC E
DEC C
JR NZ,MT0
LD (STTIT+1),HL
RET
PASCOL LD HL,#5860
LD DE,COLOUR
LD C,17
PASC0L LD (HL),D
LD B,31
INC L
LD (HL),E
DJNZ $-2
LD (HL),D
INC HL
DEC C
JR NZ,PASC0L
RET
ENPANEL LD HL,#4000
LD DE,#4001
LD BC,#7FF
LD (HL),L
LDIR
LD A,6
LD HL,#5800
LD (HL),A
INC L
LD DE,#5802
LD C,#5D
LD (HL),67
LDIR
LD (DE),A
LD H,A
LD L,A
LD (#581F),HL
LD (#583F),HL
LD HL,#4747
LD (#580F),HL
LD (#582F),HL
LD (#584F),HL
LD HL,#4401
CALL ENRAMKA
LD HL,#4411
CALL ENRAMKA
LD HL,#4601
CALL ENFAKE
INC H
INC H
CALL ENFAKE
LD HL,#4611
CALL ENFAKE
INC H
INC H
CALL ENFAKE
LD HL,CUTEAMS
LD DE,#4102
CALL PRTEAM
LD DE,#4042
CALL PRTEAM
LD DE,#411E
CALL PRTEAM
LD DE,#405E
CALL PRTEAM
LD HL,#4000
CALL PRSTAR
LD HL,#401F
CALL PRSTAR
LD HL,#4720
CALL PRSTAR
LD HL,#473F
PRSTAR LD DE,SPRSTAR
LD B,9
BIT 4,L
JR NZ,PRSTAR1
PRSTAR0 LD A,(DE)
LD (HL),A
INC DE
INC A
JR NZ,$+6
INC L
SET 7,(HL)
DEC L
CALL DHL
DJNZ PRSTAR0
RET
PRSTAR1 LD A,(DE)
RLCA
LD (HL),A
INC DE
JR NC,$+6
DEC L
SET 0,(HL)
INC L
CALL DHL
DJNZ PRSTAR1
RET
SPRSTAR DB 8,12,#1C,-1,127,62,62,#66,66
ENRAMKA LD BC,#DFF
LD D,H
LD E,L
LD (HL),127
INC L
LD (HL),C
DJNZ $-2
DEC (HL)
LD B,15
ENRAMK0 CALL DHL
SET 1,(HL)
EX DE,HL
CALL DHL
SET 6,(HL)
EX DE,HL
DJNZ ENRAMK0
LD B,13
LD (HL),-2
DEC L
LD (HL),C
DJNZ $-2
LD (HL),127
RET
ENFAKE LD E,5
ENFAKE0 PUSH HL
LD (HL),#5F
LD B,13
INC L
LD (HL),C
DJNZ $-2
LD (HL),-6
POP HL
CALL DHL
DEC E
JR NZ,ENFAKE0
RET
PRTEAM PUSH HL
LD BC,TEAMLEN
ADD HL,BC
PUSH HL
LD A,32
LD B,C
PRTEAMF DEC HL
CP (HL)
JR NZ,PRTEAME
DJNZ PRTEAMF
INC B
PRTEAME POP HL
EX (SP),HL
PUSH DE
LD C,0
BIT 4,E
JR Z,PRTEAM0
LD A,E
ADD A,A
SUB B
RRA
LD E,A
RL C
SLA C
PRTEAM0 LD A,(HL)
INC HL
CALL PR64
DJNZ PRTEAM0
POP DE
POP HL
RET
PR64 PUSH BC
PUSH DE
PUSH HL
SUB 32
ADD A,A
LD L,A
LD H,'FONT/4
ADD HL,HL
ADD HL,HL
LD B,7
DEC C
JR Z,PR641
DEC C
JR Z,PR64R
PR640 LD A,(HL)
RLCA
RLCA
RLCA
RLCA
LD (DE),A
INC L
INC D
DJNZ PR640
LD D,#58
LD A,71
LD (DE),A
POP HL
POP DE
POP BC
INC C
RET
PR641 LD A,(DE)
OR (HL)
LD (DE),A
INC L
INC D
DJNZ PR641
POP HL
POP DE
INC E
POP BC
DEC C
RET
PR64R LD A,(HL)
LD (DE),A
INC L
INC D
DJNZ PR64R
LD D,#58
LD A,71
LD (DE),A
POP HL
POP DE
INC E
POP BC
LD C,0
RET
SETWMS LD HL,WORMXY
LD DE,TXY
LD B,0
SWMS0 LD A,(DE)
INC E
LD C,A
SWMSA LD A,#80
SRL C
RRA
LD (HL),A
INC HL
LD (HL),'BOMBWMS+1
INC HL
LD (HL),C
INC HL
LD A,(DE)
LD (HL),A
INC HL
LD (HL),B
INC HL
LD (HL),B
INC HL
INC E
JR NZ,SWMS0
INC HL
LD (HL),1
LD HL,SWMSA+1
LD A,(HL)
SUB -2
OR #80
LD (HL),A
LD HL,CUWORMS
MKCUW0 XOR A
MKCUW1 LD (HL),B
INC HL
LD (HL),A
INC HL
LD (HL),150
INC HL
LD (HL),0
INC HL
LD (HL),10
INC HL
INC HL
INC A
CP 4
JR C,MKCUW1
INC B
CP B
JR NZ,MKCUW0
RET
INKEY LD A,239
IN A,(-2)
RRCA
RLA
RLA
OR #C2
LD C,A
LD A,#DF
IN A,(-2)
RRA
JR C,$+4
RES 4,C
RRA
JR C,$+4
RES 5,C
LD A,-5
IN A,(-2)
RRA
JR C,$+4
RES 2,C
LD A,-3
IN A,(-2)
RRA
JR C,$+4
RES 3,C
LD A,-2
IN A,(-2)
RRA
JR C,$+4
RES 0,C
LD A,#7F
IN A,(-2)
CPL
AND 31
RET Z
RES 1,C
RET
MOUSE LD HL,0
CALL INKEY
ARVEL LD DE,0
LD A,C
KEY EQU $+1
CP 0
LD (KEY),A
RRA
RRA
CPL
JR NZ,MANTORM
AND 15
JR NZ,MANNOT
MANTORM LD A,128
CP D
JR NC,$+3
INC D
SRA D
CP E
JR NC,$+3
INC E
SRA E
MANNOT RRA
JR C,$+3
INC D
RRA
JR C,$+3
DEC D
RRA
JR C,$+3
DEC E
RRA
JR C,$+3
INC E
LD A,-5
IN A,(#DF)
OLDX LD C,0
LD (OLDX+1),A
SUB C
ADD A,E
LD E,A
JP Z,MXQ+1
JP P,MXP
SRA A
ADD A,L
CALL NC,MXZRO
JR MXQ
MXP DEC A
SRL A
SUB -8
ADD A,L
CALL C,MXZRO
SUB 8
MXQ LD L,A
LD A,-1
IN A,(#DF)
OLDY LD C,0
LD (OLDY+1),A
SUB C
SUB D
JR Z,MYQ+1
CPL
JP M,MYP
SRA A
ADD A,H
JR C,MYQ
XOR A
LD D,A
JR MYQ
MYP INC A
SRA A
ADD A,H
CP 64
JR C,MYQ
XOR A
LD D,A
LD A,64
MYQ LD H,A
LD (MOUSE+1),HL
LD (ARVEL+1),DE
RET
MXZRO XOR A
SUB E
JP P,$+4
INC A
SRA A
LD E,A
XOR A
RET
INIMOUS EI
HALT
IN A,(-1)
INC A
JR NZ,NOMOUSE
LD BC,#FADF
IN C,(C)
LD A,-5
IN A,(#DF)
LD B,A
LD (OLDX+1),A
LD A,-1
IN A,(#DF)
LD (OLDY+1),A
CP B
RET NZ
CP C
RET NZ
NOMOUSE LD A,62
LD (OLDX-2),A
LD (OLDY-2),A
XOR A
LD (OLDX-1),A
LD (OLDY-1),A
RET
SETTIM LD HL,#3000
LD (TIME+1),HL
LD HL,#4747
SETTCLR LD (#5A22),HL
LD (#5A42),HL
RET
TIME LD BC,0
LD A,C
INC A
JR Z,PTIMOUT
TIM0 LD A,50
DEC A
JR NZ,TIM1
LD A,50
TIM1 LD (TIM0+1),A
JR NZ,TIMPR
LD A,C
SUB 8
LD C,A
JR NC,TIM2
LD C,72
LD A,B
SUB 8
LD B,A
JR NC,TIM2
LD HL,MESTIM
CALL MTITLE
PTIMOUT LD HL,(#5A61)
LD (#5A22),HL
LD (#5A42),HL
LD A,-1
LD (TIME+1),A
RET
TIM2 LD (TIME+1),BC
TIMPR LD D,61
LD E,B
SET 7,E
LD B,D
SET 7,C
LD HL,#5022
TIMPR0 LD A,(DE)
LD (HL),A
INC L
LD A,(BC)
INC C
LD (HL),A
INC H
LD (HL),A
DEC L
LD A,(DE)
INC E
LD (HL),A
INC H
BIT 3,H
JR Z,TIMPR0
LD H,80
LD A,L
SUB -32
LD L,A
CP 96
JR C,TIMPR0
RET
PRBT LD L,#88
LD H,87
LD (HL),#E0
LD H,90
LD (HL),2
DEC L
DEC L
LD DE,BT
CALL PRBTP
PRBTP DEC L
LD H,84
LD B,4
PRBT0 LD A,(DE)
INC DE
LD (HL),A
INC H
DJNZ PRBT0
LD H,90
LD (HL),4
RET
BT DB #E0,-8,-2,-1,3,7,7,7
WRMOVEQ LD SP,IX
RET
WRMOVE LD SP,WORMXY
LD BC,FD
LD A,PGMASK
OUT (C),A
DOGRAV LD A,0
ADD A,64
LD (DOGRAV+1),A
SBC A,A
AND 36
LD (WMGRAV),A
WM0 POP BC ;SPRITE
POP HL ;COORDS
POP DE ;SPEED
DEC B
JR Z,WRMOVEQ
LD A,D
CP 99
JR Z,WM0
INC B
LD (NEWSPD+1),DE
XOR A
SRA E
RRA
SRA E
RRA
ADD A,C
ADC HL,DE
BIT 7,D
JR NZ,WMGOUP
JP C,WMDEAD
LD C,A
LD A,L
CP WIDTH
JP NC,WMDEAD
EX DE,HL
LD L,D
LD H,'TMASKLN
SRL A
ADD A,(HL)
INC H
LD H,(HL)
LD L,A
JR NC,$+3
INC H
LD A,E
RRA
LD A,(HL)
LD L,C
RR L
LD H,'TABROLL
AND (HL)
JP Z,NEWSPD
DUP 4
DEC SP
EDUP
POP HL ;OLD COORDS
POP DE ;OLD SPEED
XOR A
SUB E
LD E,A
LD (NEWSPD+1),DE
XOR A
SRA E
RRA
SRA E
RRA
ADD A,C
ADC HL,DE
JP C,WMDEAD
LD C,A
LD A,L
CP WIDTH
JP NC,WMDEAD
EX DE,HL ;TODO ЗАКРУТИТЬ
LD L,D
LD H,'TMASKLN
SRL A
ADD A,(HL)
INC H
LD H,(HL)
LD L,A
JR NC,$+3
INC H
LD A,E
RRA
LD A,(HL)
LD L,C
RR L
LD H,'TABROLL
AND (HL)
JP Z,NEWSPD
LD A,(NEWSPD+2)
DEC A
LD D,99
JR Z,$+5
LD DE,256
PUSH DE
POP DE
JP WM0
WMGOUP JR NC,WMDEAD
LD C,A
LD A,L
CP WIDTH
JR NC,WMDEAD
EX DE,HL
LD L,D
LD H,'TMASKLN
SRL A
ADD A,(HL)
INC H
LD H,(HL)
LD L,A
JR NC,$+3
INC H
LD A,E
RRA
LD A,(HL)
LD L,C
RR L
LD H,'TABROLL
AND (HL)
JP Z,NEWSPD
DUP 4
DEC SP
EDUP
POP HL
POP DE
XOR A
SUB E
LD E,A
LD (NEWSPD+1),DE
XOR A
SRA E
RRA
SRA E
RRA
ADD A,C
ADC HL,DE
JR NC,WMDEAD
LD C,A
LD A,L
CP WIDTH
JR C,WMNDEAD
WMDEAD LD HL,-6
ADD HL,SP
LD (WMSP+1),HL
EX DE,HL
LD HL,6
LD B,H
ADD HL,DE
LD A,MAXWXY
SUB L
LD C,A
LD SP,IX
PUSH DE
LDIR
LD C,A
POP DE
LD HL,CUWORMS-WORMXY
ADD HL,DE
LD A,(HL)
RLCA
RLCA
INC HL
OR (HL)
DEC HL
EX DE,HL
LD HL,6
ADD HL,DE
LDIR
LD L,A
LD C,A
LD H,B
DB ")
ADD HL,BC
DB "))
LD DE,NAMES+12
ADD HL,DE
CALL MTIDEAD
WMSP LD SP,0
JP WM0
WMNDEAD EX DE,HL
LD L,D
LD H,'TMASKLN
SRL A
ADD A,(HL)
INC H
LD H,(HL)
LD L,A
JR NC,$+3
INC H
LD A,E
RRA
LD A,(HL)
LD L,C
RR L
LD H,'TABROLL
AND (HL)
JP Z,NEWSPD
DUP 4
DEC SP
EDUP
POP HL
POP DE
XOR A
SUB D
LD D,A
LD (NEWSPD+1),DE
XOR A
SRA E
RRA
SRA E
RRA
ADD A,C
ADC HL,DE
JR NC,WMDEAD
LD C,A
LD A,L
CP WIDTH
JR NC,WMDEAD
EX DE,HL
LD L,D
LD H,'TMASKLN
SRL A
ADD A,(HL)
INC H
LD H,(HL)
LD L,A
JR NC,$+3
INC H
LD A,E
RRA
LD A,(HL)
LD L,C
RR L
LD H,'TABROLL
AND (HL)
JR Z,NEWSPD
DUP 4
DEC SP
EDUP
POP DE
POP HL
LD HL,0
JR $+5
NEWSPD LD HL,0
WMGRAV INC H
PUSH HL
PUSH DE
PUSH BC
DUP 3
POP BC
EDUP
JP WM0
WORMS LD HL,(MOUSE+1)
ADD A,H
ADD A,H
LD BC,FD
LD D,PGMASK
OUT (C),D
LD C,A
XOR A
SRL L
RRA
;DEC L
SRL L
RRA
CPL
LD (WORMDX+1),A
XOR A
SUB L
LD B,A
LD SP,WORMXY
JR W0+1
WLDISP LD A,(DE)
OR (HL)
LD (DE),A
WSP LD SP,0
W0 POP AF ;SPEED
POP HL ;SPRITE
DEC H
JR Z,WORMSQ
POP DE ;COORDS
LD A,D
SUB C
ADD A,A
JR C,W0
RLA
JR NC,W0
LD LY,A ;HY='TabYfor Top/Low
LD A,L
WORMDX ADC A,0 ;thanx Spencer...
LD L,A
LD A,E
ADC A,B
CP 31
JR NC,W0
LD (WSP+1),SP
LD SP,IY
POP DE
ADD A,E
LD E,A
RET
WORMSQ LD SP,IX
RET
TABPW1 LD A,(DE)
OR (HL)
LD (DE),A
INC H
INC E
LD A,(DE)
OR (HL)
LD (DE),A
INC D
INC H
TABPW2 LD A,(DE)
OR (HL)
LD (DE),A
INC H
DEC E
LD A,(DE)
OR (HL)
LD (DE),A
INC D
INC H
TABPW3 LD A,E ;thanx Spencer...
SUB -32
LD E,A
SBC A,A
AND -8
ADD A,D
LD D,A
TABPW4
MAKPW LD DE,PROGPW
LD HL,TY4TOP+2
LD C,8
MAKPW0 LD (HL),E
INC L
LD (HL),D
DB ",,,
PUSH HL
LD B,8
MAKPW1 LD A,8
SUB C
CP B
JR NZ,MAKPWN
PUSH BC
LD HL,TABPW3
LD BC,TABPW4-TABPW3
LDIR
POP BC
MAKPWN PUSH BC
LD HL,TABPW1
BIT 0,B
JR Z,$+5
LD HL,TABPW2
LD BC,TABPW2-TABPW1
LDIR
POP BC
DJNZ MAKPW1
EX DE,HL
LD DE,-5
ADD HL,DE
LD (HL),195
INC HL
LD (HL),WLDISP
INC HL
LD (HL),'WLDISP
INC HL
EX DE,HL
POP HL
DEC C
JR NZ,MAKPW0
RET
DHL INC H
LD A,H
AND 7
RET NZ
LD A,L
ADD A,32
LD L,A
RET C
LD A,H
ADD A,-8
LD H,A
RET
DHL2 INC H
INC H
LD A,H
AND 6
RET NZ
LD A,L
ADD A,32
LD L,A
RET C
LD A,H
ADD A,-8
LD H,A
RET
DDE INC D
LD A,D
AND 7
RET NZ
LD A,E
ADD A,32
LD E,A
RET C
LD A,D
ADD A,-8
LD D,A
RET
READER EX DE,HL
EX (SP),HL
DEC DE
READ0 INC DE
LD A,(HL)
LD (DE),A
INC HL
OR A
JR NZ,READ0
EX (SP),HL
EX DE,HL
RET
TLAND DB 18,"CREATING LANDSCAPE
MESHOM DB 17,"2X HOMING MISSILE
MESWHE DB 16,"NOWHERE TO WORM!"
MESTIM DB 11,"TIME IS OUT
NOP
MESDIE DB "123456789012 IS AN EX-WORM
MESTEAM
DB "1234567890123456 TEAM IS NO MORE
CUTEAMS DB "ALONE CODER "
DB "DAVE "
DB "WORMS "
DB "THE FARM "
NAMES DB "ALCO "
DB "ALCO2 "
DB "ALCO3 "
DB "ALCO4 "
DB "DAVE "
DB "D2 "
DB "D3 "
DB "D4 "
DB "FLAT "
DB "EARTH "
DB "TAPE "
DB "WOOD "
DB "MOO "
DB "HORSE "
DB "PIGGY "
DB "HEN "
windRA=#55B9
windLA=#55B6
windEA=#50F0
PRnrg
wind=$+1 ;1..46,47,48..93
LD BC,2+#2F00
LD HL,windLA
LD E,32
PRnrg0
LD A,B
DEC A
CP C
CALL nrgPLOT
RLC E
JR NC,$+3
DEC HL
DJNZ PRnrg0
windP
LD HL,windRA
LD B,#2F
LD E,4
PRnrg1
LD A,B
ADD A,C
CP 95
CALL nrgPLOT
RRC E
JR NC,$+3
INC HL
DJNZ PRnrg1
PRnrgE
powr=$+1
LD BC,25+#7600
LD HL,windEA
LD E,4
PRnrg2
LD A,B
CP C
CALL nrgPLOT
RRC E
JR NC,$+3
INC HL
DJNZ PRnrg2
RET
nrgPLOT
SBC A,A
XOR (HL)
AND E
XOR (HL)
LD (HL),A
INC H
XOR (HL)
AND E
XOR (HL)
LD (HL),A
INC H
XOR (HL)
AND E
XOR (HL)
LD (HL),A
DEC H
DEC H
RET
CLRTOP LD HL,MOUSE+2
LD A,40
SUB (HL)
RET C
RET Z
RLCA
LD B,A
LD HL,#407F
LD DE,0
CLRTOP0 LD SP,HL
DUP 15
PUSH DE
EDUP
LD SP,IX
CALL DHL
DJNZ CLRTOP0
RET
PRWAT LD A,(MOUSE+2)
SUB 61
RET C
CPL
RLCA
SUB -87
LD H,A
LD L,#7F
PRWATDE LD DE,WATER
LD A,E
SUB -16
LD (PRWATDE+1),A
PRWAT0 LD A,(DE)
INC E
LD C,A
LD A,(DE)
INC E
LD B,A
LD SP,HL
DUP 15
PUSH BC
EDUP
INC H
BIT 3,H
JR Z,PRWAT0
LD SP,IX
RET
UPPRU LD HL,(MOUSE+1)
LD A,L
AND 3
XOR 1
INC A
XOR 18
LD BC,FD
OUT (C),A
LD B,0
LD A,40
SUB H
JR NC,$+3
XOR A
LD C,A
LD A,L
RRA
SLA H
RRA
LD L,H
LD H,'TABROW
ADD A,(HL)
LD LY,A
INC H
LD A,B
ADC A,(HL)
LD HY,A
LD L,C
LD H,B
DUP 2
DB ")
ADD HL,BC
EDUP
DB ")))
ADD HL,BC
DB ")
LD DE,UPPR
ADD HL,DE
LD C,WIDTH
JP (HL)
BUF
INCBIN "worm$
UPPR EQU BUF
ORG OTS