?login_element?

Subversion Repositories NedoOS

Rev

Rev 1507 | 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.        jr c,DrawWormInMap_right
  145.         xor e
  146.         and 0xfc ;0..3 x layer
  147.         xor e
  148.        if SKIPPGS
  149.        add a,SKIPPGS
  150.        endif
  151.         ld ly,a;0
  152.         ld hy,tpushpgs/256 ;первая страница 0 слоя, первая страница 1 слоя, первая страница 2 слоя, первая страница 3 слоя, вторая страница 0 слоя...
  153.         srl d
  154.         rr e
  155.         srl d
  156.         rr e
  157.         ld a,l ;y
  158.         and 0x3f
  159.        cpl
  160.         ;add a,0xc0
  161.         ld d,a
  162. ;e=0: l=0x3d
  163. ;e=1: l=0x3e
  164. ;e=2: l=0x39
  165. ;e=3: l=0x3a
  166. ;...
  167.        ld a,e ;x/8
  168.        cpl
  169.        add a,a
  170.        and 0xfc
  171.        ;inc a ;add a,1;l
  172.        rr e
  173.        adc a,1
  174.        ld e,a
  175.      pop hl ;gfx
  176.         call DrawWormInMappp2
  177.         ;call MapGoRight_de
  178. DrawWormInMappp2
  179.         call DrawWormInMappp
  180.         ;call MapGoRight_de
  181. ;TODO 16c sprites
  182. DrawWormInMappp
  183. _left=0x47
  184. _right=0xb8
  185.         push de
  186.         push hl
  187.         push iy
  188.         ld a,(iy)
  189.         SETPGC000
  190.         ld b,8
  191. DrawWormInMap0
  192.         ld a,(de)
  193.         rlc (hl)
  194.         jr nc,$+4
  195.         xor _left
  196.         rlc (hl)
  197.         jr nc,$+4
  198.         xor _right    
  199.         ld (de),a
  200.         inc hl
  201.         dec d
  202.         bit 6,d
  203.         call z,MapNextPg_de
  204.         djnz DrawWormInMap0
  205.         pop iy
  206.         pop hl
  207.         pop de
  208.         jp MapGoRight_de
  209.  
  210. DrawWormInMap_right
  211.         xor e
  212.         and 0xfc ;0..3 x layer
  213.         xor e
  214.        if SKIPPGS
  215.        add a,SKIPPGS
  216.        endif
  217.         ld ly,a;0
  218.         ld hy,tpushpgs/256 ;первая страница 0 слоя, первая страница 1 слоя, первая страница 2 слоя, первая страница 3 слоя, вторая страница 0 слоя...
  219.         srl d
  220.         rr e
  221.         srl d
  222.         rr e
  223.         ld a,l ;y
  224.         and 0x3f
  225.        cpl
  226.         ;add a,0xc0
  227.         ld d,a
  228. ;e=0: l=0x3d
  229. ;e=1: l=0x3e
  230. ;e=2: l=0x39
  231. ;e=3: l=0x3a
  232. ;...
  233.        ld a,e ;x/8
  234.        cpl
  235.        add a,a
  236.        and 0xfc
  237.        ;inc a ;add a,1;l
  238.        rr e
  239.        adc a,1
  240.        ld e,a
  241.      pop hl ;gfx
  242. ;DrawWormInMappp_leftcolumn
  243. _left=0x47
  244. _right=0xb8
  245.         push de
  246.         push hl
  247.         push iy
  248.         ld a,(iy)
  249.         SETPGC000
  250.         ld b,8
  251. DrawWormInMap_leftcolumn0
  252.         ld a,(de)
  253.         rlc (hl)
  254.         jr nc,$+4
  255.         xor _right
  256.         ld (de),a
  257.         inc hl
  258.         dec d
  259.         bit 6,d
  260.         call z,MapNextPg_de
  261.         djnz DrawWormInMap_leftcolumn0
  262.         pop iy
  263.         pop hl
  264.         pop de
  265.         call MapGoRight_de
  266.         call DrawWormInMappp2
  267.         call DrawWormInMappp
  268. ;DrawWormInMappp_rightcolumn
  269. _left=0x47
  270. _right=0xb8
  271.         push de
  272.         push hl
  273.         push iy
  274.         ld a,(iy)
  275.         SETPGC000
  276.         ld b,8
  277. DrawWormInMap_rightcolumn0
  278.         ld a,(de)
  279.         rlc (hl)
  280.         jr nc,$+4
  281.         xor _left
  282.         ld (de),a
  283.         inc hl
  284.         dec d
  285.         bit 6,d
  286.         call z,MapNextPg_de
  287.         djnz DrawWormInMap_rightcolumn0
  288.         pop iy
  289.         pop hl
  290.         pop de
  291.         ;jp MapGoRight_de
  292. MapGoRight_de
  293. ;de=map
  294. ;iy=tpushpgs+
  295.         inc ly
  296.         ld a,ly
  297.         and 3
  298.         ret nz
  299.         ld a,ly
  300.         sub 4
  301.         ld ly,a
  302.         inc e
  303.         bit 0,e
  304.         ret z ;0xfd -> 0xfe
  305.         ld a,e
  306.         sub 6
  307.         ld e,a
  308.         ret
  309.  
  310. PrepareXorPixInMap
  311.         ret
  312.  
  313. XorPixInMap
  314. ;e=y (от верхнего края TERRAIN)
  315. ;bc=x
  316.        LD A,e
  317.        add a,MAPHGT-TERRAINHGT
  318.         SUB TERRAINHGT;MAPHGT
  319.        RET NC
  320. ;a=-TERRAINHGT..-1
  321.        PUSH BC
  322.        PUSH HL
  323.        cpl
  324.        ld h,a ;~truey
  325.         rrca
  326.         rrca
  327.         rrca
  328.         xor c
  329.         and 3*8 ;6(7)=xlayer ;3*8=(y/64)*8
  330.         xor c
  331.         rrca
  332.         and 15 ;4 layers with 4 pages each
  333.        if SKIPPGS
  334.        add a,SKIPPGS
  335.        endif
  336.       ld (XorPixInMap_pgnum),a ;окупается только при экономии push..pop de
  337.         srl b
  338.         rr c
  339.       ex af,af' ;'
  340.         srl b
  341.         ld a,c
  342.         rra ;x/4
  343.      if 1
  344.         cpl
  345. ;11. -> 100 -> 101
  346. ;10. -> 101 -> 110
  347. ;01. -> 000 -> 001
  348. ;00. -> 001 -> 010
  349.         rrca   ;"b1" -> b0
  350.         rrca   ;"b1" -> b7
  351.         add a,a;"b1" -> CY
  352.         ccf
  353.         rla   ;~"b1" -> b0
  354.         inc a
  355.      else
  356.         rra ;x/8
  357.        cpl
  358.        ld c,a ;x/8
  359.        add a,a
  360.        and 0xfc
  361.        rr c
  362.        sbc a,-2
  363.      endif
  364.        ld l,a ;x8=0: 0x3d ;x8=1: 0x3e ;x8=2: 0x39 ;x8=3: 0x3a
  365.         ld a,h ;~truey
  366.         or 0xc0
  367.         ld h,a
  368. XorPixInMap_pgnum=$+1
  369.         ld a,(tpushpgs) ;первая страница 0 слоя, первая страница 1 слоя, первая страница 2 слоя, первая страница 3 слоя, вторая страница 0 слоя...
  370.         SETPGC000
  371.       ex af,af' ;'
  372.       sbc a,a
  373.       xor 0x47
  374.         xor (hl)
  375.         ld (hl),a
  376.        POP HL
  377.        POP BC
  378.         RET
  379.  
  380. PrepareUnSetPixInMap
  381.         ret
  382.  
  383. UnSetPixInMap
  384. ;e=truey ;e=y (от верхнего края TERRAIN)
  385. ;bc=x
  386. ;        LD A,e
  387. ;       add a,MAPHGT-TERRAINHGT
  388. ;        SUB TERRAINHGT;MAPHGT
  389. ;        RET NC ;TODO чтобы не вырезало потолок, если взорван пол! или проверять в самом круге
  390.        ld a,e
  391. ;a=-TERRAINHGT..-1
  392.        ;PUSH BC
  393.        ;PUSH HL
  394.        cpl
  395.        ld h,a ;~truey
  396.         rrca
  397.         rrca
  398.         rrca
  399.         xor c
  400.         and 3*8 ;6(7)=xlayer ;3*8=(y/64)*8
  401.         xor c
  402.         rrca
  403.         and 15 ;4 layers with 4 pages each
  404.        if SKIPPGS
  405.        add a,SKIPPGS
  406.        endif
  407.       ld (UnSetPixInMap_pgnum),a ;окупается только при экономии push..pop de
  408.         srl b
  409.         rr c
  410.       ex af,af' ;'
  411.         srl b
  412.         ld a,c
  413.         rra ;x/4
  414.      if 1
  415.         cpl
  416. ;11. -> 100 -> 101
  417. ;10. -> 101 -> 110
  418. ;01. -> 000 -> 001
  419. ;00. -> 001 -> 010
  420.         rrca   ;"b1" -> b0
  421.         rrca   ;"b1" -> b7
  422.         add a,a;"b1" -> CY
  423.         ccf
  424.         rla   ;~"b1" -> b0
  425.         inc a
  426.      else
  427.         rra ;x/8
  428.        cpl
  429.        ld c,a ;x/8
  430.        add a,a
  431.        and 0xfc
  432.        rr c
  433.        sbc a,-2
  434.      endif
  435.        ld l,a ;x8=0: 0x3d ;x8=1: 0x3e ;x8=2: 0x39 ;x8=3: 0x3a
  436.         ld a,h ;~truey
  437.         or 0xc0
  438.         ld h,a
  439. UnSetPixInMap_pgnum=$+1
  440.         ld a,(tpushpgs) ;первая страница 0 слоя, первая страница 1 слоя, первая страница 2 слоя, первая страница 3 слоя, вторая страница 0 слоя...
  441.         SETPGC000
  442.       ex af,af' ;'
  443.       sbc a,a
  444.       xor 0xb8;0x47
  445.         and (hl)
  446.         ld (hl),a
  447.        ;POP HL
  448.        ;POP BC
  449.         RET
  450.