?login_element?

Subversion Repositories NedoOS

Rev

Rev 1506 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;процедуры для рисования в карту, нижнего уровня (зависят от типа экрана)
  2.  
  3. Pr2CharsInMap
  4. ;a'=char1
  5. ;a=char2
  6. ;de'=map+
  7.         ;push bc
  8.         ;PUSH HL
  9.         exx
  10.         ex af,af' ;'
  11.         SUB 32
  12.         add a,a
  13.         add a,a
  14.         add a,a
  15.         LD h,FONT/256
  16.         LD L,A
  17.         jr nc,$+3
  18.         inc h
  19.         call PrCharInMappp2
  20.  
  21.         ex af,af' ;'
  22.         SUB 32
  23.         add a,a
  24.         add a,a
  25.         add a,a
  26.         LD h,FONT/256
  27.         LD L,A
  28.         jr nc,$+3
  29.         inc h
  30.         call PrCharInMappp2
  31.         exx
  32.         ;POP HL
  33.         ;POP bc
  34.         RET
  35.  
  36. PrCharInMappp2
  37.         call PrCharInMappp
  38.         ;call MapGoRight_de
  39. PrCharInMappp
  40. ;hl=gfx
  41. ;de=map+
  42. _left=0x47
  43. _right=0xb8
  44.         push de
  45.         push hl
  46.         push iy
  47.         ld a,(iy)
  48.         SETPGC000
  49.         ld b,7;8
  50. PrCharInMappp0
  51.         ld a,(de)
  52.         rlc (hl)
  53.         jr nc,$+4
  54. PrCharInMap_leftcolor=$+1
  55.         xor _left
  56.         rlc (hl)
  57.         jr nc,$+4
  58. PrCharInMap_rightcolor=$+1
  59.         xor _right    
  60.         ld (de),a
  61.         inc l
  62.         dec d
  63.         bit 6,d
  64.         call z,MapNextPg_de
  65.         djnz PrCharInMappp0
  66.         pop iy
  67.         pop hl
  68.         pop de
  69.         jp MapGoRight_de
  70.  
  71. SetXYInMap
  72. ;b=y
  73. ;c=x/4
  74. ;hl=NAMES+ (по нему /(4*12) можно вычислить номер команды и найти цвет)
  75.         ld a,l
  76.          push bc
  77.          exx
  78.         sub NAMES&0xff
  79.         ld c,9*3      ;color3 (red)
  80.         sub 48
  81.         jr c,SetXYInMap_colorok
  82.         ld c,9*1+0xc0 ;color9 (yellow)
  83.         sub 48
  84.         jr c,SetXYInMap_colorok
  85.         ld c,9*2+0xc0 ;color10 (green)
  86.         sub 48
  87.         jr c,SetXYInMap_colorok
  88.         ld c,9*6+0xc0 ;color14 (cyan)
  89. SetXYInMap_colorok
  90.         ld a,c
  91.         and 0x47
  92.         ld (PrCharInMap_leftcolor),a
  93.         xor c
  94.         ld (PrCharInMap_rightcolor),a
  95.          pop bc
  96.        ld a,b ;y
  97.        cpl
  98.         rlca
  99.         rlca
  100.         and 3 ;y/64
  101.         srl c ;x0=x phase (0/2)
  102.         adc a,a
  103.         add a,a
  104.        if SKIPPGS
  105.        add a,SKIPPGS
  106.        endif
  107.         ld ly,a;0
  108.         ld hy,tpushpgs/256 ;первая страница 0 слоя, первая страница 1 слоя, первая страница 2 слоя, первая страница 3 слоя, вторая страница 0 слоя...
  109.         ld a,b ;y
  110.         and 0x3f
  111.        cpl
  112.         ld d,a
  113. ;c=0: l=0x3d
  114. ;c=1: l=0x3e
  115. ;c=2: l=0x39
  116. ;c=3: l=0x3a
  117. ;...
  118.        ld a,c ;x/8
  119.        cpl
  120.        add a,a
  121.        and 0xfc
  122.        rr c
  123.        adc a,1
  124.        ld e,a
  125.        ld a,(iy)
  126.        SETPGC000
  127.          exx
  128.         ret
  129.  
  130. DrawWormInMap ;TODO и в маску?
  131. ;de=x in pixels
  132. ;l=y
  133. ;bc=gfx
  134.     push bc ;gfx
  135.        ld a,l ;y
  136.        cpl
  137.         rlca
  138.         rlca
  139.         and 3 ;y/64
  140.         add a,a
  141.         add a,a
  142.         srl d
  143.         rr e
  144. ;        ld lx,0x47
  145. ;       jr nc,DrawWormInMap_right
  146. ;        ld lx,0xb8
  147. ;DrawWormInMap_right
  148.         xor e
  149.         and 0xfc ;0..3 x layer
  150.         xor e
  151.        if SKIPPGS
  152.        add a,SKIPPGS
  153.        endif
  154.         ld ly,a;0
  155.         ld hy,tpushpgs/256 ;первая страница 0 слоя, первая страница 1 слоя, первая страница 2 слоя, первая страница 3 слоя, вторая страница 0 слоя...
  156.         srl d
  157.         rr e
  158.         srl d
  159.         rr e
  160.         ld a,l ;y
  161.         and 0x3f
  162.        cpl
  163.         ;add a,0xc0
  164.         ld d,a
  165. ;e=0: l=0x3d
  166. ;e=1: l=0x3e
  167. ;e=2: l=0x39
  168. ;e=3: l=0x3a
  169. ;...
  170.        ld a,e ;x/8
  171.        cpl
  172.        add a,a
  173.        and 0xfc
  174.        ;inc a ;add a,1;l
  175.        rr e
  176.        adc a,1
  177.        ld e,a
  178.      pop hl ;gfx
  179.         call DrawWormInMappp2
  180.         ;call MapGoRight_de
  181. DrawWormInMappp2
  182.         call DrawWormInMappp
  183.         ;call MapGoRight_de
  184. ;TODO 16c sprites
  185. DrawWormInMappp
  186. _left=0x47
  187. _right=0xb8
  188.         push de
  189.         push hl
  190.         push iy
  191.         ld a,(iy)
  192.         SETPGC000
  193.         ld b,8
  194. DrawWormInMap0
  195.         ld a,(de)
  196.         rlc (hl)
  197.         jr nc,$+4
  198.         xor _left
  199.         rlc (hl)
  200.         jr nc,$+4
  201.         xor _right    
  202.         ld (de),a
  203.         inc hl
  204.         dec d
  205.         bit 6,d
  206.         call z,MapNextPg_de
  207.         djnz DrawWormInMap0
  208.         pop iy
  209.         pop hl
  210.         pop de
  211.         ;ret
  212. MapGoRight_de
  213. ;de=map
  214. ;iy=tpushpgs+
  215.         inc ly
  216.         ld a,ly
  217.         and 3
  218.         ret nz
  219.         ld a,ly
  220.         sub 4
  221.         ld ly,a
  222.         inc e
  223.         bit 0,e
  224.         ret z ;0xfd -> 0xfe
  225.         ld a,e
  226.         sub 6
  227.         ld e,a
  228.         ret
  229.  
  230. PrepareXorPixInMap
  231.         ret
  232.  
  233. XorPixInMap
  234. ;e=y (от верхнего края TERRAIN)
  235. ;bc=x
  236.        LD A,e
  237.        add a,MAPHGT-TERRAINHGT
  238.         SUB TERRAINHGT;MAPHGT
  239.        RET NC
  240. ;a=-TERRAINHGT..-1
  241.        PUSH BC
  242.        PUSH HL
  243.        cpl
  244.        ld h,a ;~truey
  245.         rrca
  246.         rrca
  247.         rrca
  248.         xor c
  249.         and 3*8 ;6(7)=xlayer ;3*8=(y/64)*8
  250.         xor c
  251.         rrca
  252.         and 15 ;4 layers with 4 pages each
  253.        if SKIPPGS
  254.        add a,SKIPPGS
  255.        endif
  256.       ld (XorPixInMap_pgnum),a ;окупается только при экономии push..pop de
  257.         srl b
  258.         rr c
  259.       ex af,af' ;'
  260.         srl b
  261.         ld a,c
  262.         rra ;x/4
  263.      if 1
  264.         cpl
  265. ;11. -> 100 -> 101
  266. ;10. -> 101 -> 110
  267. ;01. -> 000 -> 001
  268. ;00. -> 001 -> 010
  269.         rrca   ;"b1" -> b0
  270.         rrca   ;"b1" -> b7
  271.         add a,a;"b1" -> CY
  272.         ccf
  273.         rla   ;~"b1" -> b0
  274.         inc a
  275.      else
  276.         rra ;x/8
  277.        cpl
  278.        ld c,a ;x/8
  279.        add a,a
  280.        and 0xfc
  281.        rr c
  282.        sbc a,-2
  283.      endif
  284.        ld l,a ;x8=0: 0x3d ;x8=1: 0x3e ;x8=2: 0x39 ;x8=3: 0x3a
  285.         ld a,h ;~truey
  286.         or 0xc0
  287.         ld h,a
  288. XorPixInMap_pgnum=$+1
  289.         ld a,(tpushpgs) ;первая страница 0 слоя, первая страница 1 слоя, первая страница 2 слоя, первая страница 3 слоя, вторая страница 0 слоя...
  290.         SETPGC000
  291.       ex af,af' ;'
  292.       sbc a,a
  293.       xor 0x47
  294.         xor (hl)
  295.         ld (hl),a
  296.        POP HL
  297.        POP BC
  298.         RET
  299.  
  300. PrepareUnSetPixInMap
  301.         ret
  302.  
  303. UnSetPixInMap
  304. ;e=truey ;e=y (от верхнего края TERRAIN)
  305. ;bc=x
  306. ;        LD A,e
  307. ;       add a,MAPHGT-TERRAINHGT
  308. ;        SUB TERRAINHGT;MAPHGT
  309. ;        RET NC ;TODO чтобы не вырезало потолок, если взорван пол! или проверять в самом круге
  310.        ld a,e
  311. ;a=-TERRAINHGT..-1
  312.        ;PUSH BC
  313.        ;PUSH HL
  314.        cpl
  315.        ld h,a ;~truey
  316.         rrca
  317.         rrca
  318.         rrca
  319.         xor c
  320.         and 3*8 ;6(7)=xlayer ;3*8=(y/64)*8
  321.         xor c
  322.         rrca
  323.         and 15 ;4 layers with 4 pages each
  324.        if SKIPPGS
  325.        add a,SKIPPGS
  326.        endif
  327.       ld (UnSetPixInMap_pgnum),a ;окупается только при экономии push..pop de
  328.         srl b
  329.         rr c
  330.       ex af,af' ;'
  331.         srl b
  332.         ld a,c
  333.         rra ;x/4
  334.      if 1
  335.         cpl
  336. ;11. -> 100 -> 101
  337. ;10. -> 101 -> 110
  338. ;01. -> 000 -> 001
  339. ;00. -> 001 -> 010
  340.         rrca   ;"b1" -> b0
  341.         rrca   ;"b1" -> b7
  342.         add a,a;"b1" -> CY
  343.         ccf
  344.         rla   ;~"b1" -> b0
  345.         inc a
  346.      else
  347.         rra ;x/8
  348.        cpl
  349.        ld c,a ;x/8
  350.        add a,a
  351.        and 0xfc
  352.        rr c
  353.        sbc a,-2
  354.      endif
  355.        ld l,a ;x8=0: 0x3d ;x8=1: 0x3e ;x8=2: 0x39 ;x8=3: 0x3a
  356.         ld a,h ;~truey
  357.         or 0xc0
  358.         ld h,a
  359. UnSetPixInMap_pgnum=$+1
  360.         ld a,(tpushpgs) ;первая страница 0 слоя, первая страница 1 слоя, первая страница 2 слоя, первая страница 3 слоя, вторая страница 0 слоя...
  361.         SETPGC000
  362.       ex af,af' ;'
  363.       sbc a,a
  364.       xor 0xb8;0x47
  365.         and (hl)
  366.         ld (hl),a
  367.        ;POP HL
  368.        ;POP BC
  369.         RET
  370.