ARMS
LD L,(IX+UNIT_DIRECTION)
LD H,(IX+UNIT_ANIMATION)
LD DE,SPRCLOUD0;256+44
LD (IX+UNIT_NUMBERSPRITES),E
LD (IX+UNIT_NUMBERSPRITES+1),D
LD A,(IX+UNIT_BITFRIENDLYFIRE)
INC A
CP 3
CALL NC,ARMS2
CP 5
CALL NC,ARMS3
LD (IX+UNIT_BITFRIENDLYFIRE),A
PUSH IX
PUSH HL
POP IX
LD E,(IX+UNIT_X)
LD D,(IX+UNIT_X+1)
POP IX
LD (IX+UNIT_X),E
LD (IX+UNIT_X+1),D
PUSH IX
PUSH HL
POP IX
LD E,(IX+UNIT_Y)
LD D,(IX+UNIT_Y+1)
POP IX
LD (IX+UNIT_Y),E
LD (IX+UNIT_Y+1),D
LD A,(TANKP)
CP 0
RET NZ
LD A,(IX+UNIT_COUNTER)
DEC A
LD (IX+UNIT_COUNTER),A
CP 0
RET NZ
LD (IX+UNIT_YESORNOT),0
LD HL,0
LD (IX+UNIT_NUMBERSPRITES),L
LD (IX+UNIT_NUMBERSPRITES+1),H
RET
ARMS2 LD DE,SPRCLOUD1;256+46
LD (IX+UNIT_NUMBERSPRITES),E
LD (IX+UNIT_NUMBERSPRITES+1),D
RET
ARMS3 XOR A
RET
INSARM
LD IX,UNITS
LD HL,96
LD (IX+UNIT_X),L
LD (IX+UNIT_X+1),H
LD HL,MAXY;224
LD (IX+UNIT_Y),L
LD (IX+UNIT_Y+1),H
LD DE,96
ADD IX,DE
LD HL,128+32
LD (IX+UNIT_X),L
LD (IX+UNIT_X+1),H
LD HL,MAXY;224
LD (IX+UNIT_Y),L
LD (IX+UNIT_Y+1),H
LD IX,UNITS
LD A,(IX+UNIT_YESORNOT)
CP 1
JR NZ,UNNE
LD (IX+UNIT_SHELLTIME),16
PUSH IX
POP HL
LD IX,BRONITS
LD (IX+UNIT_DIRECTION),L
LD (IX+UNIT_ANIMATION),H
LD (IX+UNIT_COUNTER),16
LD (IX+UNIT_YESORNOT),6 ;ARMS
UNNE LD IX,UNITS
LD DE,4*UNITSZ;96
ADD IX,DE
LD A,(IX+UNIT_YESORNOT)
CP 1 ;SHOT1
RET NZ
LD (IX+UNIT_SHELLTIME),16
PUSH IX
POP HL
LD IX,BRONITS
LD DE,UNITSZ;24
ADD IX,DE
LD (IX+UNIT_YESORNOT),6 ;ARMS
LD (IX+UNIT_DIRECTION),L
LD (IX+UNIT_ANIMATION),H
LD (IX+UNIT_COUNTER),16
RET
PRTAN
LD A,(WARTAN)
CP 20
RET Z
LD L,21
LD H,0
LD C,A
LD B,0
SBC HL,BC
PUSH HL
POP BC
LD A,C
LD B,A ;21-(WARTAN)
LD DE,100
NNN LD IX,WAR ;таблица координат символов танков
DEC DE
DEC DE
DEC DE
DEC DE
DEC DE
ADD IX,DE
LD (IX),0
DJNZ NNN
RET
GAMEOV LD A,(NEWTAN1)
CP 1
JP Z,GAO1
CP 0
RET Z
DEC A
LD (NEWTAN1),A
RET
GAO1 LD IX,UNITS
LD (IX+UNIT_X),96
LD (IX+UNIT_X+1),0
LD (IX+UNIT_Y),MAXY;224
LD (IX+UNIT_Y+1),0
LD (IX+UNIT_NEEDRND),1
LD (IX+UNIT_DIRECTION),1
LD (IX+UNIT_YESORNOT),5 ;RELESE
LD (IX+UNIT_DIRECTION2),3
LD (IX+UNIT_DIRECTION),0
LD (IX+UNIT_TIMEFORSHOTONWAR),4
LD HL,SPRSTAR0;256+48
LD (IX+UNIT_NUMBERSPRITES),L
LD (IX+UNIT_NUMBERSPRITES+1),H
LD (IX+UNIT_BITFRIENDLYFIRE),1
XOR A
LD (NEWTAN1),A
RET
GAMEO11 LD (IX+UNIT_YESORNOT),1 ;SHOT1
LD HL,SPRMYTANKLEVEL0;256
LD (IX+UNIT_NUMBERSPRITES),L
LD (IX+UNIT_NUMBERSPRITES+1),H
LD (IX+UNIT_X),96
LD (IX+UNIT_X+1),0
LD (IX+UNIT_Y),MAXY;224
LD (IX+UNIT_Y+1),0
LD (IX+UNIT_NEEDRND),1
LD (IX+UNIT_DIRECTION),1
LD (IX+UNIT_ANIMATION),0
LD (IX+UNIT_COUNTER),0
LD (IX+UNIT_TIMEFORSHOTONWAR),0
LD (IX+UNIT_STOPBIT),0
LD (IX+UNIT_BITFRIENDLYFIRE),0
LD (IX+UNIT_SHELLTIME),0
LD (IX+UNIT_ICE),0
LD (IX+UNIT_SAND),0
LD (IX+UNIT_TYPEOFTANK),0
LD (IX+UNIT_WATERWAY),0
LD (IX+UNIT_STAR),0
LD (IX+UNIT_ENERGY),0
PUSH IX
LD IX,UNITS
LD (IX+UNIT_SHELLTIME),16
ld (ix+(UNITSZ+UNIT_STAR)),0 ;(IX+46),0
ld (ix+(2*UNITSZ+UNIT_STAR)),0 ;(IX+70),0
PUSH IX
POP HL
POP IX
LD A,(ENDG)
CP 0
RET NZ
LD IX,BRONITS
LD (IX+UNIT_DIRECTION),L
LD (IX+UNIT_ANIMATION),H
LD (IX+UNIT_COUNTER),16
LD (IX+UNIT_YESORNOT),6 ;ARMS
XOR A
LD (NEWTAN1),A
RET
GAMEOV2 LD A,(NEWTAN2)
CP 1
JP Z,GAO2
CP 0
RET Z
DEC A
LD (NEWTAN2),A
RET
GAO2 LD IX,UNITS
LD DE,4*UNITSZ;96
ADD IX,DE
LD (IX+UNIT_X),128+32
LD (IX+UNIT_X+1),0
LD (IX+UNIT_Y),MAXY;224
LD (IX+UNIT_Y+1),0
LD (IX+UNIT_NEEDRND),1
LD (IX+UNIT_DIRECTION),1
LD (IX+UNIT_YESORNOT),5 ;RELESE
LD (IX+UNIT_DIRECTION2),3
LD (IX+UNIT_DIRECTION),0
LD (IX+UNIT_TIMEFORSHOTONWAR),4
LD (IX+UNIT_ICE),0
LD (IX+UNIT_SAND),0
LD (IX+UNIT_TYPEOFTANK),0
LD (IX+UNIT_WATERWAY),0
LD (IX+UNIT_STAR),0
LD (IX+UNIT_ENERGY),0
LD HL,SPRSTAR0;256+48
LD (IX+UNIT_NUMBERSPRITES),L
LD (IX+UNIT_NUMBERSPRITES+1),H
LD (IX+UNIT_BITFRIENDLYFIRE),1
XOR A
LD (NEWTAN2),A
RET
GAMEO22 LD (IX+UNIT_YESORNOT),1 ;SHOT1
LD HL,SPRMYTANKLEVEL0+8;264 ;player 2
LD (IX+UNIT_NUMBERSPRITES),L
LD (IX+UNIT_NUMBERSPRITES+1),H
LD (IX+UNIT_X),128+32
LD (IX+UNIT_X+1),0
LD (IX+UNIT_Y),MAXY;224
LD (IX+UNIT_Y+1),0
LD (IX+UNIT_NEEDRND),1
LD (IX+UNIT_DIRECTION),1
LD (IX+UNIT_ANIMATION),0
LD (IX+UNIT_COUNTER),0
LD (IX+UNIT_TIMEFORSHOTONWAR),0
LD (IX+UNIT_STOPBIT),0
LD (IX+UNIT_BITFRIENDLYFIRE),0
LD (IX+UNIT_SHELLTIME),0
PUSH IX
LD IX,UNITS
LD DE,4*UNITSZ;96
ADD IX,DE
LD (IX+UNIT_SHELLTIME),16
ld (ix+(UNITSZ+UNIT_STAR)),0 ;(IX+46),0
ld (ix+(2*UNITSZ+UNIT_STAR)),0 ;(IX+70),0
PUSH IX
POP HL
POP IX
LD A,(ENDG)
CP 0
RET NZ
LD IX,BRONITS
LD DE,UNITSZ;24
ADD IX,DE
LD (IX+UNIT_DIRECTION),L
LD (IX+UNIT_ANIMATION),H
LD (IX+UNIT_COUNTER),16
LD (IX+UNIT_YESORNOT),6 ;ARMS
XOR A
LD (NEWTAN2),A
RET
PRINTW
LD HL,(ADDRY) ;y
LD BC,(ADDRX) ;x
;hl=x
;bc=y
;(NUMBS)=sprite pattern number
LD A,H
and 1
ld (SPBUFX),a ;x>=256?
LD E,L
LD A,b
and 1
ld (SPBUFY),a
;LD de,sprlist ;#200; DESCRIPTOR
LD hl,(ADDR)
;ADD HL,de
inc h
inc h
LD A,(YESORNO)
or a ;CP 0
JP Z,NPSP
LD (HL),c;--------Y
INC HL
LD A,(IX+UNIT_DIRECTION)
CP 3
LD A,(SPBUFY) ;y>=256???
jr nz,$+4
or 0x80 ;mirror vert
or 0x20 ;act
ld (hl),a
INC HL
LD (HL),E;--------X
INC HL
LD A,(IX+UNIT_DIRECTION)
CP 4
LD A,(SPBUFX) ;x>=256???
jr nz,$+4
or 0x80 ;mirror hor
ld (hl),a
INC HL
NUMBS=$+1
LD DE,0;(NUMBS) ;sprite pattern number
LD (HL),E
INC HL
LD (HL),D
RET
NPSP
;a=0
INC HL
LD (HL),a;0;A
RET
;NUMBS DEFW 0
PRINT
;for editor?
;TODO показывать графику тайла вместо спрайта!
;a=tile pattern number
;hl=x
;bc=y
;d=size
LD (NUMSPR),A
LD A,H
and 1
ld (SPBUFX),a ;x>=256?
LD E,L
LD A,b
and 1
ld (SPBUFY),a
;LD de,sprlist ;#200; DESCRIPTOR
LD hl,(ADDR)
;ADD HL,de
inc h
inc h
LD HL,sprlist ;#200; DESCRIPTOR
LD (HL),c;--------Y
INC HL
LD A,(SIZE); SIZE SPRITE Y
ADD A,SPACT
RES 0,A
LD (HL),A
LD A,(SPBUFY)
CP 1
CALL Z,SPBUFYY
INC HL
LD (HL),E;--------X
INC HL
LD A,(SIZE); SIZE SPRITE X
RES 0,A
LD (HL),A
LD A,(SPBUFX)
CP 1
CALL Z,SPBUFXX
INC HL
LD A,(NUMSPR); NUMBER OFF SPRITE IN MEMORY
LD (HL),A
INC HL
LD (HL),0
LD A,(FIGH)
CP 2
JP Z,DEACTS
RET
DEACTS LD B,80
NJJ PUSH BC
INC HL
LD (HL),D;--------Y
INC HL
LD A,(SIZE); SIZE SPRITE Y
ADD A,SPACT
RES 0,A
RES 5,A;------------------DEACTIVACIA SPRITES
LD (HL),A
LD A,(SPBUFY) ;y>=256???
CP 1
CALL Z,SPBUFYY
INC HL
LD (HL),E;--------X
INC HL
LD A,(SIZE); SIZE SPRITE X
RES 0,A
LD (HL),A
LD A,(SPBUFX) ;x>=256???
CP 1
CALL Z,SPBUFXX
INC HL
LD A,(NUMSPR); NUMBER OFF SPRITE IN MEMORY
LD (HL),A
INC HL
LD (HL),0
POP BC
DJNZ NJJ
RET
SPBUFXX
LD A,SPSIZ16; SIZE SPRITE X
SET 0,A
LD (HL),A
RET
SPBUFYY
LD A,(SIZE); SIZE SPRITE Y
ADD A,SPACT
SET 0,A
LD (HL),A
RET
NUMSPR DEFB 0
SIZE DEFB 0
FIGH DEFB 0
KEY1P LD IX,UNITS
LD A,(IX+UNIT_YESORNOT)
CP 1 ;SHOT1
RET NZ
LD A,(IX+UNIT_BITFRIENDLYFIRE)
CP 0
JR NZ,KEY1P2
LD (IX+UNIT_ANIMATION),0
CALL KEYRF; UPRAVLENIE
CALL KEYLF
CALL KEYDF
CALL KEYUF
LD (IX+UNIT_ICE),0
RET
GO LD A,5
LD (SOUNDGO),A
RET
KEY1P2 LD A,(IX+UNIT_YESORNOT)
CP 1 ;SHOT1
RET NZ
LD A,(IX+UNIT_BITFRIENDLYFIRE)
DEC A
LD (IX+UNIT_BITFRIENDLYFIRE),A
RET
KEY2P LD A,(PLAYER)
CP 0
RET Z
LD IX,UNITS
LD DE,4*UNITSZ;96
ADD IX,DE
LD A,(IX+UNIT_YESORNOT)
CP 1 ;SHOT1
RET NZ
LD A,(IX+UNIT_BITFRIENDLYFIRE)
CP 0
JR NZ,KEY1P2
LD (IX+UNIT_ANIMATION),0
CALL KEYRFP2; UPRAVLENIE
CALL KEYLFP2
CALL KEYDFP2
CALL KEYUFP2
LD (IX+UNIT_ICE),0
RET
KEYDF LD A,3
CALL YOMPA1P
LD A,(IX+UNIT_COUNTER)
CP 0
JP NZ,KEYD3
IF KEMPSTON ;Replace 1st player's control to Kempston joystick
ld a,(kempstonbuttons) ;IN A,(#1F)
AND %00000100
JP NZ,KEYDF22
ENDIF
if VIRTUALKEYS
ld a,(joy1state)
and JOYMASK_DOWN
else
LD HL,(Keys1PlDn) ;LD HL,Keys1PlDn+2
LD B,H ;LD BC,(Keys1PlDn)
LD C,#FE ;CALL CHBIT
IN A,(C)
AND L
endif
JP Z,KEYDF22
KEYDF_ok
XOR A
LD (RAZF4),A
RET
KEYDF22 LD A,(RAZF4)
CP 2 ;MOVE_PAUSE ;Pause for change move direction
JP NC,KEYDF2
LD A,(RAZF4)
INC A
LD (RAZF4),A
LD A,3
LD (IX+UNIT_DIRECTION),A
RET
KRF3 LD A,(TANKP)
CP 0
RET Z
CP 5
RET Z
POP HL
RET
KEYD3 LD (IX+UNIT_ANIMATION),1
LD A,(IX+UNIT_COUNTER)
CP 8
JR NZ,KEYQQ
CALL MATEMAT
;LD BC,256
;ADD HL,BC
TILEMAPLINEDOWN
CALL COUNT
KEYQQ LD A,(IX+UNIT_DIRECTION)
CP 3
RET NZ
LD A,(IX+UNIT_SAND)
CP 28
CALL Z,KRF3
LD A,(IX+UNIT_COUNTER)
DEC A
LD (IX+UNIT_COUNTER),A
LD E,(IX+UNIT_Y)
LD D,(IX+UNIT_Y+1)
LD A,E
CP MAXY;224
JP Z,RNDD
INC DE
LD (IX+UNIT_Y),E
LD (IX+UNIT_Y+1),D
POP HL
RET
RNDD
LD (IX+UNIT_NEEDRND),1
LD (IX+UNIT_COUNTER),0
RET
KEYDF2 LD A,(IX+UNIT_BITPARENTSBULL)
CP 3
JR NC,KEYDF2A
LD A,(IX+UNIT_ICE)
CP 26
JP Z,KRF2
KEYDF2A LD A,(IX+UNIT_STOPBIT)
CP 0
JP NZ,KQ1
LD A,(IX+UNIT_COUNTER)
CP 0
RET NZ
LD (IX+UNIT_DIRECTION),3
LD (IX+UNIT_COUNTER),8
LD A,(IX+UNIT_DIRECTION2)
CP 0
JP NZ,KEYDFC
JP KEYDF
KEYUF LD A,1
CALL YOMPA1P
LD A,(IX+UNIT_COUNTER)
CP 0
JP NZ,KEYF3
IF KEMPSTON ;Replace 1st player's control to Kempston joystick
ld a,(kempstonbuttons) ;IN A,(#1F)
AND %00001000
JP NZ,KEYUF22
ENDIF
if VIRTUALKEYS
ld a,(joy1state)
and JOYMASK_UP
else
LD HL,(Keys1PlUp) ;LD HL,Keys1PlUp+2
LD B,H ;LD BC,(Keys1PlUp)
LD C,#FE ;CALL CHBIT
IN A,(C)
AND L
endif
JP Z,KEYUF22
KEYUF_ok
XOR A
LD (RAZF3),A
RET
KEYUF22 LD A,(RAZF3)
CP 2 ;MOVE_PAUSE ;Pause for change move direction
JP NC,KEYUF2
LD A,(RAZF3)
INC A
LD (RAZF3),A
LD A,1
LD (IX+UNIT_DIRECTION),A
RET
KEYF3
LD (IX+UNIT_ANIMATION),1
LD A,(IX+UNIT_COUNTER)
CP 8
JR NZ,KEYQ1Q
CALL MATEMAT
;LD BC,256
;SBC HL,BC
TILEMAPLINEUP
CALL COUNT
KEYQ1Q
LD A,(IX+UNIT_DIRECTION)
CP 1
RET NZ
LD A,(IX+UNIT_SAND)
CP 28
CALL Z,KRF3
LD A,(IX+UNIT_COUNTER)
DEC A
LD (IX+UNIT_COUNTER),A
LD E,(IX+UNIT_Y)
LD D,(IX+UNIT_Y+1)
LD A,E
CP 0
JP Z,RNDD
DEC DE
LD (IX+UNIT_Y),E
LD (IX+UNIT_Y+1),D
POP HL
RET
KEYUF2 LD A,(IX+UNIT_BITPARENTSBULL)
CP 3
JR NC,KEYUF2A
LD A,(IX+UNIT_ICE)
CP 26
JP Z,KRF2
KEYUF2A LD A,(IX+UNIT_STOPBIT)
CP 0
JP NZ,KQ1
LD A,(IX+UNIT_COUNTER)
CP 0
RET NZ
LD (IX+UNIT_DIRECTION),1
LD (IX+UNIT_COUNTER),8
LD A,(IX+UNIT_DIRECTION2)
CP 0
JP NZ,KEYUFC
JP KEYUF
COUNT
LD A,(HL) ;wall tile
CP 2 ;brick
JP Z,C1
CP 12 ;beton
JP Z,C1
LD A,(IX+UNIT_WATERWAY)
CP 1
JR Z,CO1
LD A,(HL)
CP 22 ;water
jp z,C1
sub WATERANIMTILE
cp NWATERANIMTILES
jp c,C1
CO1 LD A,(HL)
;CP 38 ;brick broken from bottom
;JP Z,C1
;CP 36 ;brick broken from top
;JP Z,C1
;CP 35 ;brick broken from left
;JP Z,C1
;CP 37 ;brick broken from right
;JP Z,C1
;CP 30 ;eagle top-left
;JP Z,C1
;CP 31 ;eagle top-right
;JP Z,C1
;CP 94 ;eagle bottom-left
;JP Z,C1
;CP 95 ;eagle bottom-right
;JP Z,C1
sub 35
cp 4
jp c,C1
sub 30-35
cp 2
jp c,C1
sub 94-30
cp 2
jp c,C1
;INC HL
;INC HL
TILEMAPRIGHT
LD A,(HL)
CP 2
jp Z,C1
CP 12
jp Z,C1
LD A,(IX+UNIT_WATERWAY)
CP 1
JR Z,CO2
LD A,(HL)
CP 22 ;water
jr z,C1
sub WATERANIMTILE
cp NWATERANIMTILES
jr c,C1
CO2 LD A,(HL)
sub 35
cp 4
jr c,C1
sub 30-35
cp 2
jr c,C1
sub 94-30
cp 2
jr c,C1
;LD BC,254
;ADD HL,BC
TILEMAPLEFTLINEDOWN
LD A,(HL)
CP 2
jr Z,C1
CP 12
jr Z,C1
LD A,(IX+UNIT_WATERWAY)
CP 1
JR Z,CO3
LD A,(HL)
CP 22 ;water
jr z,C1
sub WATERANIMTILE
cp NWATERANIMTILES
jr c,C1
CO3 LD A,(HL)
sub 35
cp 4
jr c,C1
sub 30-35
cp 2
jr c,C1
sub 94-30
cp 2
jr c,C1
;INC HL
;INC HL
TILEMAPRIGHT
LD A,(HL)
CP 2
JR Z,C1
CP 12
JR Z,C1
LD A,(IX+UNIT_WATERWAY)
CP 1
JR Z,CO4
LD A,(HL)
CP 22 ;water
jr z,C1
sub WATERANIMTILE
cp NWATERANIMTILES
jr c,C1
CO4 LD A,(HL)
sub 35
cp 4
jr c,C1
sub 30-35
cp 2
jr c,C1
sub 94-30
cp 2
;jr c,C1
RET nz
C1 POP HL
LD (IX+UNIT_NEEDRND),1
LD (IX+UNIT_COUNTER),0
RET
KEYRF LD A,2
CALL COMPA1P
LD A,(IX+UNIT_COUNTER)
CP 0
JP NZ,KEYYR3
IF KEMPSTON ;Replace 1st player's control to Kempston joystick
ld a,(kempstonbuttons) ;IN A,(#1F)
AND %00000001
JP NZ,KEYRF22
ENDIF
if VIRTUALKEYS
ld a,(joy1state)
and JOYMASK_RIGHT
else
LD HL,(Keys1PlRt) ;LD HL,Keys1PlRt+2
LD B,H ;LD BC,(Keys1PlRt)
LD C,#FE ;CALL CHBIT
IN A,(C)
AND L
endif
JP Z,KEYRF22
KEYRF_ok
XOR A
LD (RAZF),A
RET
KEYRF22 LD A,(RAZF)
CP 2 ;MOVE_PAUSE ;Pause for change move direction
JP NC,KEYRF2
LD A,(RAZF)
INC A
LD (RAZF),A
LD A,2
LD (IX+UNIT_DIRECTION),A
RET
KQ1 LD HL,Keys1PlRt+2
LD A,(COMA)
LD (IX+UNIT_DIRECTION),A
LD (IX+UNIT_ANIMATION),1
RET
KEYYR3
LD (IX+UNIT_ANIMATION),1
LD A,(IX+UNIT_COUNTER)
CP 8
JR NZ,KEYQQ1
CALL MATEMAT
;INC HL
;INC HL
TILEMAPRIGHT
CALL COUNT
KEYQQ1 LD A,(IX+UNIT_DIRECTION)
CP 2
RET NZ
LD A,(IX+UNIT_SAND)
CP 28
CALL Z,KRF3
LD A,(IX+UNIT_COUNTER)
DEC A
LD (IX+UNIT_COUNTER),A
LD E,(IX+UNIT_X)
LD D,(IX+UNIT_X+1)
LD A,D
CP 1
CALL Z,KEYFCH
INC DE
LD (IX+UNIT_X),E
LD (IX+UNIT_X+1),D
POP HL
RET
KRF22
LD A,(IX+UNIT_DIRECTION)
CP 1
JP Z,PEYUF2A
CP 2
JP Z,PEYRF2A
CP 3
JP Z,PEYDF2A
CP 4
JP Z,PEYLF2A
RET
KRF2
LD A,(IX+UNIT_DIRECTION)
CP 1
JP Z,KEYUF2A
CP 2
JP Z,KEYRF2A
CP 3
JP Z,KEYDF2A
CP 4
JP Z,KEYLF2A
RET
LD A,(IX+UNIT_ICE)
CP 26
JP Z,KRF22
KEYRF2 LD A,(IX+UNIT_BITPARENTSBULL)
CP 3
JR NC,KEYRF2A
LD A,(IX+UNIT_ICE)
CP 26
JP Z,KRF2
KEYRF2A LD A,(IX+UNIT_STOPBIT)
CP 0
JP NZ,KQ1
LD A,(IX+UNIT_COUNTER)
CP 0
RET NZ
LD (IX+UNIT_DIRECTION),2
LD (IX+UNIT_COUNTER),8
LD A,(IX+UNIT_DIRECTION2)
CP 0
JP NZ,KEYRFC
JP KEYRF
KEYFCH
LD A,E
CP 0
RET NZ
CALL RNDD
POP HL
RET
KEYLF LD A,4
CALL COMPA1P
LD A,(IX+UNIT_COUNTER)
CP 0
JP NZ,KEYLL3
IF KEMPSTON ;Replace 1st player's control to Kempston joystick
ld a,(kempstonbuttons) ;IN A,(#1F)
AND %00000010
JP NZ,KEYLF22
ENDIF
if VIRTUALKEYS
ld a,(joy1state)
and JOYMASK_LEFT
else
LD HL,(Keys1PlLt) ;LD HL,Keys1PlLt+2
LD B,H ;LD BC,(Keys1PlLt)
LD C,#FE ;CALL CHBIT
IN A,(C)
AND L
endif
JP Z,KEYLF22
KEYLF_ok
XOR A
LD (RAZF2),A
RET
KEYLF22 LD A,(RAZF2)
CP 2 ;MOVE_PAUSE ;Pause for change move direction
JP NC,KEYLF2
LD A,(RAZF2)
INC A
LD (RAZF2),A
LD A,4
LD (IX+UNIT_DIRECTION),A
RET
KEYLL3
LD (IX+UNIT_ANIMATION),1
LD A,(IX+UNIT_COUNTER)
CP 8
JR NZ,KEYYY
CALL MATEMAT
;DEC HL
;DEC HL
TILEMAPLEFT
CALL COUNT
KEYYY LD A,(IX+UNIT_DIRECTION)
CP 4
RET NZ
LD A,(IX+UNIT_SAND)
CP 28
CALL Z,KRF3
LD A,(IX+UNIT_COUNTER)
DEC A
LD (IX+UNIT_COUNTER),A
LD E,(IX+UNIT_X)
LD D,(IX+UNIT_X+1)
LD A,D
CP 0
CALL Z,KEYFCH
DEC DE
LD (IX+UNIT_X),E
LD (IX+UNIT_X+1),D
POP HL
RET
KEYLF2 LD A,(IX+UNIT_BITPARENTSBULL)
CP 3
JR NC,KEYLF2A
LD A,(IX+UNIT_ICE)
CP 26
JP Z,KRF2
KEYLF2A LD A,(IX+UNIT_STOPBIT)
CP 0
JP NZ,KQ1
LD A,(IX+UNIT_COUNTER)
CP 0
RET NZ
LD (IX+UNIT_DIRECTION),4
LD (IX+UNIT_COUNTER),8
LD A,(IX+UNIT_DIRECTION2)
CP 0
JP NZ,KEYLFC
JP KEYLF
KEYDFP2 LD A,3
CALL YOMPA2P
LD A,(IX+UNIT_COUNTER)
CP 0
JP NZ,KEYD3P
if VIRTUALKEYS
ld a,(joy2state)
and JOYMASK_DOWN
else
LD HL,(Keys2PlDn) ;LD HL,Keys2PlDn+2
LD B,H ;LD BC,(Keys2PlDn)
LD C,#FE ;CALL CHBIT
IN A,(C)
AND L
endif
JP Z,KEYDF2P
RET
KEYD3P LD (IX+UNIT_ANIMATION),1
LD A,(IX+UNIT_COUNTER)
CP 8
JR NZ,KEYQQP
CALL MATEMAT
;LD BC,256
;ADD HL,BC
TILEMAPLINEDOWN
CALL COUNT
KEYQQP LD A,(IX+UNIT_DIRECTION)
CP 3
RET NZ
LD A,(IX+UNIT_SAND)
CP 28
CALL Z,KRF3
LD A,(IX+UNIT_COUNTER)
DEC A
LD (IX+UNIT_COUNTER),A
LD E,(IX+UNIT_Y)
LD D,(IX+UNIT_Y+1)
LD A,E
CP MAXY;224
RET Z
INC DE
LD (IX+UNIT_Y),E
LD (IX+UNIT_Y+1),D
POP HL
RET
KEYDF2P
LD A,(IX+UNIT_ICE)
CP 26
JP Z,KRF22
PEYDF2A LD A,(IX+UNIT_STOPBIT)
CP 0
JP NZ,KQ1
LD A,(IX+UNIT_COUNTER)
CP 0
RET NZ
LD (IX+UNIT_DIRECTION),3
LD (IX+UNIT_COUNTER),8
JP KEYDFP2
KEYUFP2 LD A,1
CALL YOMPA2P
LD A,(IX+UNIT_COUNTER)
CP 0
JP NZ,KEYF3P
if VIRTUALKEYS
ld a,(joy2state)
and JOYMASK_UP
else
LD HL,(Keys2PlUp) ;LD HL,Keys2PlUp+2
LD B,H ;LD BC,(Keys2PlUp)
LD C,#FE ;CALL CHBIT
IN A,(C)
AND L
endif
JP Z,QEYUF2P
RET
KEYF3P
LD (IX+UNIT_ANIMATION),1
LD A,(IX+UNIT_COUNTER)
CP 8
JR NZ,KEYQ1QP
CALL MATEMAT
;LD DE,256
;SBC HL,DE
TILEMAPLINEUP
CALL COUNT
KEYQ1QP
LD A,(IX+UNIT_DIRECTION)
CP 1
RET NZ
LD A,(IX+UNIT_SAND)
CP 28
CALL Z,KRF3
LD A,(IX+UNIT_COUNTER)
DEC A
LD (IX+UNIT_COUNTER),A
LD E,(IX+UNIT_Y)
LD D,(IX+UNIT_Y+1)
LD A,E
CP 0
RET Z
DEC DE
LD (IX+UNIT_Y),E
LD (IX+UNIT_Y+1),D
POP HL
RET
QEYUF2P
LD A,(IX+UNIT_ICE)
CP 26
JP Z,KRF22
PEYUF2A LD A,(IX+UNIT_STOPBIT)
CP 0
JP NZ,KQ1
LD (IX+UNIT_DIRECTION),1
LD (IX+UNIT_COUNTER),8
JP KEYUFP2
KEYRFP2 LD A,2
CALL COMPA2P
LD A,(IX+UNIT_COUNTER)
CP 0
JP NZ,KEYYR3P
if VIRTUALKEYS
ld a,(joy2state)
and JOYMASK_RIGHT
else
LD HL,(Keys2PlRt) ;LD HL,Keys2PlRt+2
LD B,H ;LD BC,(Keys2PlRt)
LD C,#FE ;CALL CHBIT
IN A,(C)
AND L
endif
JP Z,QEYRF2P
RET
KEYYR3P
LD (IX+UNIT_ANIMATION),1
LD A,(IX+UNIT_COUNTER)
CP 8
JR NZ,KEQQPP
CALL MATEMAT
;INC HL
;INC HL
TILEMAPRIGHT
CALL COUNT
KEQQPP LD A,(IX+UNIT_DIRECTION)
CP 2
RET NZ
LD A,(IX+UNIT_SAND)
CP 28
CALL Z,KRF3
LD A,(IX+UNIT_COUNTER)
DEC A
LD (IX+UNIT_COUNTER),A
LD E,(IX+UNIT_X)
LD D,(IX+UNIT_X+1)
LD A,D
CP 1
CALL Z,KEYFCH
INC DE
LD (IX+UNIT_X),E
LD (IX+UNIT_X+1),D
POP HL
RET
QEYRF2P
LD A,(IX+UNIT_ICE)
CP 26
JP Z,KRF22
PEYRF2A LD A,(IX+UNIT_STOPBIT)
CP 0
JP NZ,KQ1
LD (IX+UNIT_DIRECTION),2
LD (IX+UNIT_COUNTER),8
JP KEYRFP2
KEYLFP2 LD A,4
CALL COMPA2P
LD A,(IX+UNIT_COUNTER)
AND A
JP NZ,KEYLL3P
if VIRTUALKEYS
ld a,(joy2state)
and JOYMASK_LEFT
else
LD HL,(Keys2PlLt) ;LD HL,Keys2PlLt+2
LD B,H ;LD BC,(Keys2PlLt)
LD C,#FE ;CALL CHBIT
IN A,(C)
AND L
endif
JP Z,QEYLF2P
RET
KEYLL3P
LD (IX+UNIT_ANIMATION),1
LD A,(IX+UNIT_COUNTER)
CP 8
JR NZ,LLKK
CALL MATEMAT
;DEC HL
;DEC HL
TILEMAPLEFT
CALL COUNT
LLKK LD A,(IX+UNIT_DIRECTION)
CP 4
RET NZ
LD A,(IX+UNIT_SAND)
CP 28
CALL Z,KRF3
LD A,(IX+UNIT_COUNTER)
DEC A
LD (IX+UNIT_COUNTER),A
LD E,(IX+UNIT_X)
LD D,(IX+UNIT_X+1)
LD A,D
CP 0
CALL Z,KEYFCH
DEC DE
LD (IX+UNIT_X),E
LD (IX+UNIT_X+1),D
POP HL
RET
QEYLF2P
LD A,(IX+UNIT_ICE)
CP 26
JP Z,KRF22
PEYLF2A LD A,(IX+UNIT_STOPBIT)
CP 0
JP NZ,KQ1
LD (IX+UNIT_DIRECTION),4
LD (IX+UNIT_COUNTER),8
JP KEYLFP2