Subversion Repositories NedoOS

Rev

Rev 1507 | Rev 1545 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1. ;процедуры для рисования в карту, верхнего уровня (не зависят от типа экрана)
  2.  
  3. AnimMines
  4.         ld hl,drawminesphase
  5.         ld a,(hl)
  6.         xor drawminesphase_xor
  7.         ld (hl),a
  8.         ret
  9.  
  10. ForcedUnDrawWormsInMap
  11. ForcedDrawWormsInMap
  12.         ld a,SPRLIST_IMPOSSIBLE;xor a ;"nop" - print all
  13.         ld (DrawWormsInMap_staypatch),a
  14.         ld a,DrawWormsInMap_drawminepatch_never
  15.         ld (DrawWormsInMap_drawminepatch),a ;never print mines
  16.         call DrawWormsInMap
  17.         ld a,SPRLIST_PRINTED;0x7e ;"ld a,(hl)" - print only non-staying
  18.         ld (DrawWormsInMap_staypatch),a
  19.         ld a,DrawWormsInMap_drawminepatch_always
  20.         ld (DrawWormsInMap_drawminepatch),a ;always print mines
  21.         ret
  22.  
  23. UnDrawWormsInMap ;FIXME
  24. DrawWormsInMap
  25.        if !ATM
  26.         LD A,PGMAP;16
  27.         CALL OUTME
  28.        endif
  29.         ld hl,WORMXY
  30. DrawWormsInMap0
  31.         ;POP BC ;SPRITE (lsb=xlow*64;32)
  32.         ;POP HL ;COORDS
  33.         ;POP DE ;SPEED
  34.         ld c,(hl)
  35.         inc l
  36.         ld a,(hl) ;spritehsb
  37.         inc l
  38.         cp 1
  39.         ret z ;jr z,DrawWormsInMap0q
  40.        ld b,a
  41.        cp sprmine_0/256
  42. drawminesphase=$
  43. drawminesphase0=24 ;jr
  44. drawminesphase1=32 ;jr nz
  45. drawminesphase_xor=drawminesphase0^drawminesphase1
  46.        jr nz,DrawWormsInMap_nomine
  47.        ld a,c
  48.        xor 8;1
  49.        ld c,a
  50. DrawWormsInMap_nomine
  51.         ld e,(hl) ;xhigh
  52.         inc l
  53.        ld a,e
  54.        cp XWID
  55.        jr nc,DrawWormsInMap_skip
  56.         ld d,0
  57.        dup 2
  58.         sla c
  59.         rl e
  60.         rl d
  61.        edup
  62.         sla c ;bc=gfx
  63.        ld a,b
  64.        cp sprmine_0/256
  65. DrawWormsInMap_drawminepatch=$+1
  66.        jr z,DrawWormsInMap_drawalways
  67.         inc l
  68.         inc l
  69.         ld a,(hl) ;dy ;/nop
  70. DrawWormsInMap_staypatch=$+1
  71.        cp SPRLIST_PRINTED
  72.        jr z,DrawWormsInMap_skipdy ;staying printed
  73.         cp SPRLIST_STAYING
  74.        jr nz,$+4
  75.        ld (hl),SPRLIST_PRINTED
  76.         dec l
  77.         dec l
  78. DrawWormsInMap_drawalways
  79. DrawWormsInMap_drawminepatch_always=DrawWormsInMap_drawalways-(DrawWormsInMap_drawminepatch+1)
  80.        push hl
  81.         ld l,(hl) ;y
  82. ;de=x in pixels
  83. ;l=y
  84. ;bc=gfx
  85.         call DrawWormInMap
  86.        pop hl
  87. DrawWormsInMap_skip
  88. DrawWormsInMap_drawminepatch_never=DrawWormsInMap_skip-(DrawWormsInMap_drawminepatch+1)
  89.         inc l
  90.         inc l
  91. DrawWormsInMap_skipdy
  92.         inc l
  93.         jr DrawWormsInMap0
  94.  
  95. UnDrawWormsDataInMap ;FIXME
  96. DrawWormsDataInMap
  97.  
  98.        if !ATM
  99.         LD A,PGMAP;16
  100.         CALL OUTME
  101.        endif
  102.         ld hl,WORMXY
  103. DrawWormsDataInMap0
  104.         ;POP BC ;SPRITE (lsb=xlow*32)
  105.         ;POP HL ;COORDS
  106.         ;POP DE ;SPEED
  107.         ;ld e,(hl)
  108.         inc l
  109.         ld a,(hl) ;spritehsb
  110.         inc l
  111.         cp 1
  112.         ret z ;jr z,DrawWormsInMap0q
  113.         ld c,(hl) ;xhigh
  114.         inc l
  115.         ld b,(hl) ;y
  116.         inc l
  117.         inc l
  118.        cp sprmine_0/256
  119.        jr z,DrawWormsDataInMap_skip
  120.        ld a,c ;xhigh
  121.        cp XWID
  122.        jr nc,DrawWormsDataInMap_skip ;dead
  123.        ;ld a,(hl) ;dy
  124.        ;cp SPRLIST_STAYING
  125.        ;jr nz,DrawWormsDataInMap_skip ;not staying
  126.        push hl
  127.         ld a,b ;y
  128.         SUB 13
  129.         LD B,A ;y
  130.        ld de,+(CUWORMS+2)-(WORMXY+5)
  131.        add hl,de
  132.        ld a,(hl) ;health
  133.         add hl,hl
  134.         LD de,NAMES-(2*(CUWORMS+2))
  135.         ADD HL,de ;name+12
  136. ;a=health
  137. ;b=y
  138. ;c=xhigh (XXXXXXXX XXx?????)
  139. ;hl=name
  140.        PUSH af ;health
  141.        push bc ;yx
  142.        ld a,XWID-(6*XWIDCHR) ;TODO по ширине имени
  143.        cp c ;x
  144.        jr nc,$+3
  145.        ld c,a ;чтобы не заезжало за правый край карты
  146.         call SetXYInMap
  147.         LD B,6
  148. SPRINTnam
  149.         LD a,(HL)
  150.         ex af,af' ;'
  151.         INC HL
  152.         LD A,(HL)
  153.         CALL Pr2CharsInMap
  154.         INC HL
  155.         DJNZ SPRINTnam
  156.         dec hl ;чтобы можно было использовать hl для указания на команду (т.е. на цвет)
  157.        pop bc ;yx
  158.        ld a,b
  159.        add a,6
  160.        ld b,a ;y
  161.        ld a,XWID-(2*XWIDCHR)
  162.        cp c ;x
  163.        jr nc,$+3
  164.        ld c,a ;чтобы не заезжало за правый край карты
  165.         call SetXYInMap
  166.        POP AF ;health
  167.         LD BC,+('0'-1)*256+100
  168.         INC B
  169.         SUB C
  170.         JR NC,$-2
  171.         ADD A,C
  172.        ld c,a;PUSH AF ;health mod 100
  173.         LD a,' '
  174.         ex af,af' ;'
  175.         LD A,B
  176.         CALL Pr2CharsInMap
  177.        ld a,c;POP AF ;health mod 100
  178.         LD BC,+('0'-1)*256+10
  179.         INC B
  180.         SUB C
  181.         JR NC,$-2
  182.         ex af,af' ;'
  183.         LD A,B
  184.         ex af,af' ;'
  185.         add a,'0'+10
  186.         call Pr2CharsInMap
  187.        pop hl
  188. DrawWormsDataInMap_skip
  189.         inc l
  190.         jr DrawWormsDataInMap0
  191.  
  192. UnDrawCircleInMap
  193. ;e,bc=y0,x0
  194. ;d=R
  195.        push bc
  196.        push de
  197.         call PrepareUnSetPixInMap
  198.         ld hl,UnSetPixInMap
  199.         xor a
  200.         call UnDrawCircle
  201.         call SetPgMask
  202.        pop de
  203.        pop bc
  204.        
  205.         ld a,e
  206.         sub 8 ;таблица строк маски использует координату "y" для ног, т.е. на 8 пикс ниже
  207.         srl a
  208.         ld e,a ;y0
  209.         srl b
  210.         rr c ;x0
  211.         dec bc
  212.         dec bc
  213.         srl d ;R
  214.        
  215.         ld hl,UnSetPixInMask
  216.         ld a,0x87 ;"add a,a"
  217. UnDrawCircle
  218. ;e,bc=y0,x0
  219. ;d=R
  220. ;hl=pixproc
  221. ;a="add a,a"/"nop"
  222.         ld (hline_unsetpixpatch),hl
  223.         ld (hline_y2patch),a
  224.         ld hx,e ;y0
  225.         LD L,d ;R
  226.         ld H,#00 ;hl=R
  227.         ADD HL,HL ;hl=curwidth=R*2
  228.         ld a,3 ;???
  229.         sub l
  230.         ld l,a
  231.         sbc a,h
  232.         sub l
  233.         ld h,a ;hl=3-(R*2)
  234.         LD e,d ;R
  235.         ld d,#00 ;e=curx=R, d=cury=0
  236.  
  237. fCIR0    PUSH bc ;x0
  238.        push hl
  239.        push de
  240.        push bc
  241. ;e=curx
  242. ;d=cury
  243. ;hx,bc=y0,x0
  244.         ld a,c
  245.         sub e
  246.         ld c,a ;x=x0-curx
  247.         jr nc,$+3
  248.          dec b
  249.         ld a,e ;len=curx
  250.         add a,a ;len=2*len
  251.         ld lx,a ;len
  252.        push bc
  253.        push de
  254.         ld a,hx ;y0
  255.         add a,d ;cury
  256.         ld e,a ;y=y0+cury
  257.         push ix
  258.         call hline_lx ;e,bc=y,x ;lx=len=2*curx
  259.         pop ix
  260.        pop de
  261.        pop bc
  262.         ld a,hx ;y0
  263.         sub d ;cury
  264.         ld e,a ;y=y0-cury
  265.         call hline_lx ;e,bc=y,x ;lx=len=2*curx
  266.        pop bc
  267.        pop de
  268.        pop HL
  269.       PUSH HL ;curwidth
  270.         BIT 7,H:JR Z,fCIR2
  271. ;curwidth<0
  272.         INC d ;cury
  273.         LD L,d
  274.         ld H,#00
  275.         LD bc,#0006 ;???
  276.         JR fCIR3 ;hl=cury
  277. fCIR2
  278. ;конец ступеньки
  279.        push bc
  280.        push de
  281.         ld a,c
  282.         sub d
  283.         ld c,a ;x=x0-cury
  284.         jr nc,$+3
  285.          dec b
  286.         ld a,d ;len=cury
  287.         add a,a ;len=2*len
  288.         ld lx,a ;len
  289.        push bc
  290.        push de
  291.         ld a,hx ;y0
  292.         add a,e ;curx
  293.         ld e,a ;y
  294.         push ix
  295.         call hline_lx ;b,ec=y,x ;lx=len=2*cury
  296.         pop ix
  297.        pop de
  298.        pop bc
  299.         ld a,hx ;y0
  300.         sub e ;curx
  301.         ld e,a ;y
  302.         call hline_lx ;b,ec=y,x ;lx=len=2*cury
  303.        pop de
  304.        pop bc
  305.         INC d ;cury
  306.         DEC e ;curx
  307.         LD L,d
  308.         ld H,#00
  309.         LD c,e
  310.         ld b,#00
  311.         OR A
  312.         SBC HL,bc ;hl=cury-curx
  313.         LD bc,#000A ;???
  314. fCIR3    ADD HL,HL
  315.         add HL,HL ;hl=(cury-curx)*4
  316.         add HL,bc ;hl=(cury-curx)*4 + const
  317.       POP bc
  318.       ADD HL,bc ;hl=(cury-curx)*4 + const + curwidth
  319.  
  320.         POP bc ;x0
  321.         LD A,e
  322.         cp d
  323.         JP NC,fCIR0
  324.         ret
  325.        
  326. hline_lx
  327. ;e=y (TODO check here)
  328. ;bc=x
  329. ;lx=len
  330.         LD A,e
  331. hline_y2patch=$
  332.         add a,a ;/nop
  333.        add a,MAPHGT-TERRAINHGT
  334.         SUB TERRAINHGT;MAPHGT
  335.         RET NC
  336.         ld e,a
  337.         ld d,lx
  338. hline0
  339.        push bc
  340. hline_unsetpixpatch=$+1
  341.         call UnSetPixInMap ;/UnSetPixInMask
  342.        pop bc
  343.         inc bc
  344.         dec d ;--
  345.         jr nz,hline0
  346.         ret
  347.  
  348. UnSetPixInMask
  349. ;e=truey ;e=y (/2) (от верхнего края TERRAIN)
  350. ;bc=x (/2)
  351.        ; LD A,e
  352.        ; add a,a
  353.        ;add a,MAPHGT-TERRAINHGT
  354.        ; SUB TERRAINHGT;MAPHGT
  355.        ; RET NC
  356.       ;PUSH HL
  357.       ;push bc
  358.          ;sub 8 ;таблица строк маски использует координату "y" для ног, т.е. на 8 пикс ниже
  359.         ld l,e;a
  360.          ;srl b ;xhigh
  361.          ;rr c ;xlow
  362.          ;dec bc
  363.          ;dec bc ;маска рассчитана под "x" центра червя, т.е. сдвинута на 4 больших (2 масочных) пикс
  364.         LD H,TMASKLN/256
  365.         LD A,C
  366.         AND 0xf8
  367.         ADD A,b ;0/1 = xhigh/2
  368.         RRCA
  369.         RRCA
  370.         RRCA
  371.         CP MASKWID
  372.        ret nc;JR NC,UnSetPixInMaskq
  373.         ADD A,(HL)
  374.         INC H
  375.         LD H,(HL)
  376.         LD L,A
  377.         JR NC,$+3
  378.         INC H
  379.         LD A,C
  380.         AND 7
  381.         INC A
  382.         LD B,A
  383.         LD A,0xfe
  384.         RRCA
  385.         DJNZ $-1
  386.          ;ld b,TABROLL07/256
  387.          ;ld a,(bc) ;bit
  388.          ;cpl
  389.         and (HL)
  390.         LD (HL),A
  391. ;UnSetPixInMaskq
  392.       ;POP BC
  393.       ;POP HL
  394.         RET
  395.