;процедуры для рисования в карту, верхнего уровня (не зависят от типа экрана)
AnimMines
ld hl,drawminesphase
ld a,(hl)
xor drawminesphase_xor
ld (hl),a
ret
UnDrawCrossInMap
DrawCrossInMap
curwormxy=$+1
ld hl,WORMXY
ld c,(hl) ;xlow, sprlow (bit3=right)
ld b,c
inc l
inc l
ld e,(hl) ;xhigh
inc l
;ld a,e
;cp XWID
;jr nc,DrawWormsInMap_skip
ld d,0
dup 2
sla c
rl e
rl d
edup
sla c ;bc=gfx
ld c,(hl) ;y
crossalpha=$+1 ;-64..+64 вправо (-64 самый нижний)
ld hl,tsin
ld a,(hl)
sra a
sra a
neg ;y считается сверху вниз
add a,c
ld c,a ;y
ld a,64
sub l
ld l,a ;cos table
ld a,(hl)
bit 3,b
jr nz,$+4
neg
sra a
sra a
ld l,a
rla
sbc a,a
ld h,a
add hl,de
ex de,hl ;x
ld l,c ;y
ld bc,sprcross
;de=x in pixels
;l=y
;bc=gfx
bit 7,d
ret nz
_max=MAPWID*8-4
ld a,e
sub _max&0xff
ld a,d
sbc a,_max/256
ret nc
if !ATM
LD A,PGMAP;16
CALL OUTME
endif
jp DrawWormInMap
UnDrawCurWorm_ifprinted
;hl=curwormxy
;out: nz=not printed, keep hl
ex de,hl
ld hl,5
add hl,de
ex de,hl
ld a,(de) ;dy
cp SPRLIST_PRINTED
;jr z,UnDrawCurWorm_ifprintedok ;стоячий червь (уже напечатанный) или пустышка
;cp SPRLIST_END
;jp z,WRMOVEQ ;конец списка
;cp SPRLIST_STAYING
ret nz
;jr z,UnDrawCurWorm_ifprintedok ;стоячий червь или пустышка
;ret
UnDrawCurWorm_ifprintedok
ld a,SPRLIST_STAYING;PRINTED
ld (de),a
if !ATM
LD A,PGMAP;16
CALL OUTME
endif
push hl
GETCOORDS
push de
ld e,l ;xhigh
ld d,0
dup 2
sla c
rl e
rl d
edup
sla c ;bc=gfx
push hl ;h=y, l=xhigh
ld l,h ;y
;de=x in pixels
;l=y
;bc=gfx
call DrawWormInMap
pop bc ;b=y, c=xhigh
pop de ;x
pop hl ;curwormxy+2
pop hl
xor a ;printed
ret
DrawCurWormData
if !ATM
LD A,PGMAP;16
CALL OUTME
endif
ld hl,(curwormxy)
GETCOORDS
ld b,h
ld c,l ;b=y, c=xhigh
pop hl ;curwormxy+2
inc hl
inc hl
inc hl
;hl=wormxy+5
;c=xhigh
;b=y
ld a,c
cp INVISIBLEX
jp nz,DrawWormDataInMap
ret
ForcedUnDrawWormsInMap
ForcedDrawWormsInMap
ld a,SPRLIST_IMPOSSIBLE;xor a ;"nop" - print all
ld (DrawWormsInMap_staypatch),a
ld a,DrawWormsInMap_drawminepatch_never
ld (DrawWormsInMap_drawminepatch),a ;never print mines
call DrawWormsInMap
ld a,SPRLIST_PRINTED;0x7e ;"ld a,(hl)" - print only non-staying
ld (DrawWormsInMap_staypatch),a
ld a,DrawWormsInMap_drawminepatch_always
ld (DrawWormsInMap_drawminepatch),a ;always print mines
ret
UnDrawWormsInMap ;FIXME
DrawWormsInMap
if !ATM
LD A,PGMAP;16
CALL OUTME
endif
ld hl,WORMXY
DrawWormsInMap0
;POP BC ;SPRITE (lsb=xlow*64;32)
;POP HL ;COORDS
;POP DE ;SPEED
ld c,(hl)
inc l
ld a,(hl) ;spritehsb
inc l
cp 1
ret z ;jr z,DrawWormsInMap0q
ld b,a
cp sprmine_0/256
drawminesphase=$
drawminesphase0=24 ;jr
drawminesphase1=32 ;jr nz
drawminesphase_xor=drawminesphase0^drawminesphase1
jr nz,DrawWormsInMap_nomine
ld a,c
xor 8;1
ld c,a
DrawWormsInMap_nomine
ld e,(hl) ;xhigh
inc l
ld a,e
cp XWID
jr nc,DrawWormsInMap_skip
ld d,0
dup 2
sla c
rl e
rl d
edup
sla c ;bc=gfx
ld a,b
cp sprmine_0/256
DrawWormsInMap_drawminepatch=$+1
jr z,DrawWormsInMap_drawalways
inc l
inc l
ld a,(hl) ;dy ;/nop
DrawWormsInMap_staypatch=$+1
cp SPRLIST_PRINTED
jr z,DrawWormsInMap_skipdy ;staying printed
cp SPRLIST_STAYING
jr nz,$+4
ld (hl),SPRLIST_PRINTED
dec l
dec l
DrawWormsInMap_drawalways
DrawWormsInMap_drawminepatch_always=DrawWormsInMap_drawalways-(DrawWormsInMap_drawminepatch+1)
push hl
ld l,(hl) ;y
;de=x in pixels
;l=y
;bc=gfx
call DrawWormInMap
pop hl
DrawWormsInMap_skip
DrawWormsInMap_drawminepatch_never=DrawWormsInMap_skip-(DrawWormsInMap_drawminepatch+1)
inc l
inc l
DrawWormsInMap_skipdy
inc l
jr DrawWormsInMap0
UnDrawWormsDataInMap ;FIXME
DrawWormsDataInMap
if !ATM
LD A,PGMAP;16
CALL OUTME
endif
ld hl,WORMXY
DrawWormsDataInMap0
;POP BC ;SPRITE (lsb=xlow*32)
;POP HL ;COORDS
;POP DE ;SPEED
;ld e,(hl)
inc l
ld a,(hl) ;spritehsb
inc l
cp 1
ret z ;jr z,DrawWormsInMap0q
ld c,(hl) ;xhigh
inc l
ld b,(hl) ;y
inc l
inc l
cp sprmine_0/256
jr z,DrawWormsDataInMap_skip
ld a,c ;xhigh
cp XWID
jr nc,DrawWormsDataInMap_skip ;dead
;ld a,(hl) ;dy
;cp SPRLIST_STAYING
;jr nz,DrawWormsDataInMap_skip ;not staying
push hl
call DrawWormDataInMap
pop hl
DrawWormsDataInMap_skip
inc l
jr DrawWormsDataInMap0
DrawWormDataInMap
;hl=wormxy+5
;c=xhigh
;b=y
ld a,b ;y
SUB 13
LD B,A ;y
ld de,+(CUWORMS+2)-(WORMXY+5)
add hl,de
ld a,(hl) ;health
add hl,hl
LD de,NAMES-(2*(CUWORMS+2))
ADD HL,de ;name+12
;a=health
;b=y
;c=xhigh (XXXXXXXX XXx?????)
;hl=name
PUSH af ;health
push bc ;yx
if 0
push hl
ld b,12
DrawWormDataInMap_namewid0
ld a,(hl)
cp ' '
jr z,$+3
ld c,b
inc hl
djnz DrawWormDataInMap_namewid0
;c=last nonempty chr shift=12..1
pop hl
endif
;ld a,XWID-(6*XWIDCHR) ;TODO по ширине имени
;cp c ;x
;jr nc,$+3
;ld c,a ;чтобы не заезжало за правый край карты
call SetXYInMap ;keeps bc ;c=x/4
ld b,6 ;12 letters
srl c ;x (now in chrs)
ld a,MAPWID
sub c ;visiblewid = MAPWID-c = 0..MAPWID
cp b
jr nc,$+3
ld b,a ;min(6, visiblewid)
SPRINTnam
LD a,(HL)
ex af,af' ;'
INC HL
LD A,(HL)
CALL Pr2CharsInMap
INC HL
DJNZ SPRINTnam
dec hl ;чтобы можно было использовать hl для указания на команду (т.е. на цвет)
pop bc ;yx
ld a,b
add a,6
ld b,a ;y
ld a,XWID-(2*XWIDCHR)
cp c ;x
jr nc,$+3
ld c,a ;чтобы не заезжало за правый край карты
call SetXYInMap
POP AF ;health
LD BC,+('0'-1)*256+100
INC B
SUB C
JR NC,$-2
ADD A,C
ld c,a;PUSH AF ;health mod 100
LD a,' '
ex af,af' ;'
LD A,B
CALL Pr2CharsInMap
ld a,c;POP AF ;health mod 100
LD BC,+('0'-1)*256+10
INC B
SUB C
JR NC,$-2
ex af,af' ;'
LD A,B
ex af,af' ;'
add a,'0'+10
jp Pr2CharsInMap
UnDrawCircleInMap
;e,bc=y0,x0
;d=R
push bc
push de
call PrepareUnSetPixInMap
ld hl,UnSetPixInMap
xor a
call UnDrawCircle
call SetPgMask
pop de
pop bc
ld a,e
sub 8 ;таблица строк маски использует координату "y" для ног, т.е. на 8 пикс ниже
srl a
ld e,a ;y0
srl b
rr c ;x0
dec bc
dec bc
srl d ;R
ld hl,UnSetPixInMask
ld a,0x87 ;"add a,a"
UnDrawCircle
;e,bc=y0,x0
;d=R
;hl=pixproc
;a="add a,a"/"nop"
ld (hline_unsetpixpatch),hl
ld (hline_y2patch),a
ld hx,e ;y0
LD L,d ;R
ld H,#00 ;hl=R
ADD HL,HL ;hl=curwidth=R*2
ld a,3 ;???
sub l
ld l,a
sbc a,h
sub l
ld h,a ;hl=3-(R*2)
LD e,d ;R
ld d,#00 ;e=curx=R, d=cury=0
fCIR0 PUSH bc ;x0
push hl
push de
push bc
;e=curx
;d=cury
;hx,bc=y0,x0
ld a,c
sub e
ld c,a ;x=x0-curx
jr nc,$+3
dec b
ld a,e ;len=curx
add a,a ;len=2*len
ld lx,a ;len
push bc
push de
ld a,hx ;y0
add a,d ;cury
ld e,a ;y=y0+cury
push ix
call hline_lx ;e,bc=y,x ;lx=len=2*curx
pop ix
pop de
pop bc
ld a,hx ;y0
sub d ;cury
ld e,a ;y=y0-cury
call hline_lx ;e,bc=y,x ;lx=len=2*curx
pop bc
pop de
pop HL
PUSH HL ;curwidth
BIT 7,H:JR Z,fCIR2
;curwidth<0
INC d ;cury
LD L,d
ld H,#00
LD bc,#0006 ;???
JR fCIR3 ;hl=cury
fCIR2
;конец ступеньки
push bc
push de
ld a,c
sub d
ld c,a ;x=x0-cury
jr nc,$+3
dec b
ld a,d ;len=cury
add a,a ;len=2*len
ld lx,a ;len
push bc
push de
ld a,hx ;y0
add a,e ;curx
ld e,a ;y
push ix
call hline_lx ;b,ec=y,x ;lx=len=2*cury
pop ix
pop de
pop bc
ld a,hx ;y0
sub e ;curx
ld e,a ;y
call hline_lx ;b,ec=y,x ;lx=len=2*cury
pop de
pop bc
INC d ;cury
DEC e ;curx
LD L,d
ld H,#00
LD c,e
ld b,#00
OR A
SBC HL,bc ;hl=cury-curx
LD bc,#000A ;???
fCIR3 ADD HL,HL
add HL,HL ;hl=(cury-curx)*4
add HL,bc ;hl=(cury-curx)*4 + const
POP bc
ADD HL,bc ;hl=(cury-curx)*4 + const + curwidth
POP bc ;x0
LD A,e
cp d
JP NC,fCIR0
ret
hline_lx
;e=y (TODO check here)
;bc=x
;lx=len
LD A,e
hline_y2patch=$
add a,a ;/nop
add a,MAPHGT-TERRAINHGT
SUB TERRAINHGT;MAPHGT
RET NC
ld e,a
ld d,lx
hline0
push bc
hline_unsetpixpatch=$+1
call UnSetPixInMap ;/UnSetPixInMask
pop bc
inc bc
dec d ;--
jr nz,hline0
ret
UnSetPixInMask
;e=truey ;e=y (/2) (от верхнего края TERRAIN)
;bc=x (/2)
; LD A,e
; add a,a
;add a,MAPHGT-TERRAINHGT
; SUB TERRAINHGT;MAPHGT
; RET NC
;PUSH HL
;push bc
;sub 8 ;таблица строк маски использует координату "y" для ног, т.е. на 8 пикс ниже
ld l,e;a
;srl b ;xhigh
;rr c ;xlow
;dec bc
;dec bc ;маска рассчитана под "x" центра червя, т.е. сдвинута на 4 больших (2 масочных) пикс
LD H,TMASKLN/256
LD A,C
AND 0xf8
ADD A,b ;0/1 = xhigh/2
RRCA
RRCA
RRCA
CP MASKWID
ret nc;JR NC,UnSetPixInMaskq
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,0xfe
RRCA
DJNZ $-1
;ld b,TABROLL07/256
;ld a,(bc) ;bit
;cpl
and (HL)
LD (HL),A
;UnSetPixInMaskq
;POP BC
;POP HL
RET