?login_element?

Subversion Repositories NedoOS

Rev

Rev 657 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;вывод на экран
  2.  
  3.         SHAPESPROC shapes_cls
  4.         ld e,a
  5.         OS_CLS
  6.         ret
  7.  
  8.         SHAPESPROC shapes_copybox
  9. ;hl=экранный адрес левого верхнего угла окна
  10. ;de=экранный адрес, куда копировать окно
  11. ;c=wid8
  12. ;b=hgt
  13.         or a
  14.         sbc hl,de
  15.         add hl,de
  16.         jr c,copyboxrightdown_topleft ;hl < de
  17. copyboxleftup
  18. ;hl=экранный адрес левого верхнего угла окна
  19. ;de=экранный адрес, куда копировать окно (выше или левее hl)
  20. ;c=wid8
  21. ;b=hgt
  22.         ld a,c
  23. copyboxleftup0
  24.         push bc
  25.         ld b,0
  26.         call ldir_a
  27.         set 5,h
  28.         set 5,d
  29.         call ldir_a
  30.         set 6,h
  31.         set 6,d
  32.         call ldir_a
  33.         res 5,h
  34.         res 5,d
  35.         call ldir_a
  36.         res 6,h
  37.         res 6,d
  38.         ld  c,40 ;b=0
  39.         ex de,hl
  40.         add hl,bc
  41.         ex de,hl
  42.         add hl,bc
  43.         pop bc
  44.         djnz copyboxleftup0
  45.         ret
  46. copyboxrightdown_topleft
  47. ;hl=экранный адрес левого верхнего угла окна
  48. ;de=экранный адрес, куда копировать окно (выше или левее hl)
  49. ;c=wid8
  50. ;b=hgt
  51.         push bc
  52.         push hl
  53.         ld a,c ;wid8
  54.         ld c,b ;hgt
  55.         ld b,0
  56.         ld h,b
  57.         ld l,c ;hgt
  58.         add hl,hl
  59.         add hl,hl
  60.         add hl,bc ;*5
  61.         add hl,hl
  62.         add hl,hl
  63.         add hl,hl ;*40
  64.         add a,l
  65.         ld c,a
  66.         adc a,h
  67.         sub c
  68.         ld b,a        
  69.         pop hl
  70.         dec bc
  71. ;bc=hgt*40 + wid8 - 1
  72.         ex de,hl
  73.         add hl,bc
  74.         ex de,hl
  75.         add hl,bc
  76.         pop bc
  77. ;hl=экранный адрес правого нижнего угла окна + 40
  78. ;de=экранный адрес, куда копировать окно + 40 (ниже или правее hl)
  79. ;c=wid8
  80. ;b=hgt
  81.         ld a,c
  82. copyboxrightdown0
  83.         push bc
  84.         ld bc,-40
  85.         ex de,hl
  86.         add hl,bc
  87.         ex de,hl
  88.         add hl,bc
  89.         ld b,0
  90.         call lddr_a
  91.         set 5,h
  92.         set 5,d
  93.         call lddr_a
  94.         set 6,h
  95.         set 6,d
  96.         call lddr_a
  97.         res 5,h
  98.         res 5,d
  99.         call lddr_a
  100.         res 6,h
  101.         res 6,d
  102.         pop bc
  103.         djnz copyboxrightdown0
  104.         ret
  105.        
  106. ldir_a
  107.         ld c,a
  108.         push hl
  109.         push de
  110.         ldir
  111.         pop de
  112.         pop hl  
  113.         ret
  114.        
  115. lddr_a
  116.         ld c,a
  117.         push hl
  118.         push de
  119.         lddr
  120.         pop de
  121.         pop hl  
  122.         ret
  123.        
  124. prpixel
  125. ;de=x (не портится)
  126. ;c=y (bc не портится)
  127. ;lx=color = %33210210
  128.        ld a,b
  129.         ld l,c
  130.         ld h,0
  131.         ld b,scrbase/256/8 ;h
  132.         add hl,hl
  133.         add hl,hl
  134.         add hl,bc
  135.         add hl,hl
  136.         add hl,hl
  137.         add hl,hl ;y*40 + scrbase
  138.        ld b,a
  139. prpixel_cury
  140. ;de=x (не портится)
  141. ;hl=addr(y)
  142. ;lx=color = %33210210
  143.         ld a,d
  144.         rra
  145.         ld a,e
  146.         rra
  147.         jr c,prpixel_r
  148.         rra
  149.         jr nc,$+4
  150.         set 6,h
  151.         rra
  152.         jr nc,$+4
  153.         set 5,h
  154.         and 0x3f;%00111111
  155.         add a,l
  156.         ld l,a
  157.         adc a,h
  158.         sub l
  159.         ld h,a
  160.         ld a,lx
  161.         xor (hl)
  162.         and 0x47;%01000111 ;keep left pixel
  163.         xor (hl) ;right pixel from screen
  164.         ld (hl),a
  165.         ret
  166. prpixel_r
  167.         rra
  168.         jr nc,$+4
  169.         set 6,h
  170.         rra
  171.         jr nc,$+4
  172.         set 5,h
  173.         and 0x3f;%00111111
  174.         add a,l
  175.         ld l,a
  176.         adc a,h
  177.         sub l
  178.         ld h,a
  179.         ld a,lx
  180.         xor (hl)
  181.         and 0xb8;%10111000 ;keep right pixel
  182.         xor (hl) ;left pixel from screen
  183.         ld (hl),a
  184.         ret
  185.  
  186. line_invpixel
  187. ;bc=x (в плоскости экрана относительно рабочей зоны, но может быть отрицательным)
  188. ;de=y (в плоскости экрана относительно рабочей зоны, но может быть отрицательным)
  189.         ld a,c
  190.         sub 255&(workzonewid8*8)
  191.         ld a,b
  192.         sbc a,+(workzonewid8*8)/256
  193.         ret p
  194.         xor b
  195.         ret p ;x было отрицательное
  196.         ld a,e
  197.         sub 255&workzonehgt
  198.         ld a,d
  199.         sbc a,workzonehgt/256
  200.         ret p
  201.         xor d
  202.         ret p ;y было отрицательное
  203.         push bc
  204.         push de
  205.         ld a,e ;y
  206.         ld hl,workzonex8*8
  207.         add hl,bc
  208.         ex de,hl ;de=x
  209.         add a,workzoney
  210.         ld c,a ;c=y
  211.         call invpixel
  212.         pop de
  213.         pop bc
  214.         ret
  215.        
  216. invpixel
  217. ;de=x (не портится)
  218. ;c=y (bc не портится)
  219.        ld a,b
  220.         ld l,c
  221.         ld h,0
  222.        ld b,scrbase/256/8 ;h
  223.         add hl,hl
  224.         add hl,hl
  225.         add hl,bc
  226.         add hl,hl
  227.         add hl,hl
  228.         add hl,hl ;y*40 + scrbase
  229.        ld b,a
  230. invpixel_cury
  231. ;de=x (не портится)
  232. ;hl=addr(y)
  233.         ld a,d
  234.         rra
  235.         ld a,e
  236.         rra
  237.         jr c,invpixel_r
  238.         rra
  239.         jr nc,$+4
  240.         set 6,h
  241.         rra
  242.         jr nc,$+4
  243.         set 5,h
  244.         and 0x3f;%00111111
  245.         add a,l
  246.         ld l,a
  247.         adc a,h
  248.         sub l
  249.         ld h,a
  250.         ld a,(hl)
  251.         xor 0x47;%01000111 ;left pixel from screen
  252.         ld (hl),a
  253.         ret
  254. invpixel_r
  255.         rra
  256.         jr nc,$+4
  257.         set 6,h
  258.         rra
  259.         jr nc,$+4
  260.         set 5,h
  261.         and 0x3f;%00111111
  262.         add a,l
  263.         ld l,a
  264.         adc a,h
  265.         sub l
  266.         ld h,a
  267.         ld a,(hl)
  268.         xor 0xb8;%10111000 ;right pixel from screen
  269.         ld (hl),a
  270.         ret
  271.  
  272.         SHAPESPROC shapes_prpixelbox
  273. ;c=y
  274. ;de=x
  275. ;b=hgt (последний пиксель = y+hgt-1)
  276. ;hl=wid (последний пиксель = x+wid-1)
  277. ;lx=color %rlrrrlll
  278. prpixelbox0
  279.         push bc
  280.         push de
  281.         push hl ;wid
  282.         call prpixelhorline
  283.         pop hl ;wid
  284.         pop de
  285.         pop bc
  286.         inc c
  287.         djnz prpixelbox0
  288.         ret
  289.  
  290.         SHAPESPROC shapes_invpixelframe
  291. ;bc=x
  292. ;de=y
  293. ;hl=hgt (последний пиксель = y+hgt)
  294. ;ix=wid (последний пиксель = x+wid)
  295.         push bc
  296.         push de
  297.         push hl ;wid
  298.         inc bc ;x
  299.         call invpixelhorline
  300.         pop hl ;wid
  301.         pop de
  302.         pop bc
  303.         push bc
  304.         push de
  305.         push hl ;wid
  306.         push ix
  307.         add ix,de
  308.         ld d,hx
  309.         ld e,lx ;de=y+hgt
  310.         pop ix
  311.         call invpixelhorline
  312.         pop hl ;wid
  313.         pop de
  314.         pop bc
  315.         push bc
  316.         push de
  317.         add hl,bc ;x
  318.         ld b,h
  319.         ld c,l ;bc=x+wid
  320.         push ix
  321.         pop hl ;hgt
  322.         inc de ;y
  323.         push hl
  324.         call invpixelverline
  325.         pop hl ;hgt
  326.         pop de
  327.         pop bc
  328. invpixelverline
  329. ;bc=x
  330. ;de=y
  331. ;hl=hgt
  332.         ld a,h
  333.         or l
  334.         ret z
  335. invpixelverline0
  336.         push hl
  337.         bit 0,l
  338.         call nz,line_invpixel
  339.         pop hl
  340.         inc de ;y
  341.         dec hl
  342.         ld a,h
  343.         or l
  344.         jr nz,invpixelverline0
  345.         ret
  346.        
  347. invpixelhorline
  348. ;bc=x
  349. ;de=y
  350. ;hl=wid
  351.         ld a,h
  352.         or l
  353.         ret z
  354. invpixelhorline0
  355.         push hl
  356.         bit 0,l
  357.         call nz,line_invpixel
  358.         pop hl
  359.         inc bc ;x
  360.         dec hl
  361.         ld a,h
  362.         or l
  363.         jr nz,invpixelhorline0
  364.         ret
  365.  
  366.         SHAPESPROC shapes_prpixelframe
  367. ;c=y
  368. ;de=x
  369. ;b=hgt (последний пиксель = y+hgt)
  370. ;hl=wid (последний пиксель = x+wid)
  371. ;lx=color %rlrrrlll
  372.         push bc
  373.         push de
  374.         push hl ;wid
  375.         inc de ;x
  376.         call prpixelhorline
  377.         pop hl ;wid
  378.         pop de
  379.         pop bc
  380.         push bc
  381.         push de
  382.         push hl ;wid
  383.         ld a,c ;y
  384.         add a,b ;hgt
  385.         ld c,a ;c=y+hgt
  386.         call prpixelhorline
  387.         pop hl ;wid
  388.         pop de
  389.         pop bc
  390.         push bc
  391.         push de
  392.         add hl,de ;x
  393.         ex de,hl ;de=x+wid
  394.         inc c ;y
  395.         call prpixelverline
  396.         pop de
  397.         pop bc
  398. prpixelverline
  399. ;c=y
  400. ;de=x
  401. ;b=hgt
  402. ;lx=color
  403.         inc b
  404.         dec b
  405.         ret z
  406. prpixelverline0
  407. prpixelverline_patch=$+1
  408.         call prpixel
  409.         inc c
  410.         djnz prpixelverline0
  411.         ret
  412.        
  413. prpixelhorline
  414. ;c=y
  415. ;de=x
  416. ;hl=wid
  417. ;lx=color
  418.         ld a,h
  419.         or l
  420.         ret z
  421.         push hl
  422.         ld l,c
  423.         ld h,0
  424.         ld b,scrbase/256/8 ;h
  425.         add hl,hl
  426.         add hl,hl
  427.         add hl,bc
  428.         add hl,hl
  429.         add hl,hl
  430.         add hl,hl ;y*40 + scrbase
  431.         pop bc
  432.         ld a,c
  433.         dec bc
  434.         ld c,b
  435.         inc c ;c=(bc-1)/256+1
  436.         ld b,a ;b=bc&0xff
  437. prpixelhorline0
  438.         push hl ;addr(cury)
  439. prpixelhorline_patch=$+1
  440.         call prpixel_cury
  441.         pop hl ;addr(cury)
  442.         inc de ;x
  443.         djnz prpixelhorline0
  444.         dec c
  445.         jr nz,prpixelhorline0
  446.         ret
  447.        
  448.         SHAPESPROC shapes_invbox
  449. ;hx=color1
  450. ;lx=color2
  451. ;b=y
  452. ;c=x/8
  453. ;d=hgt
  454. ;e=wid
  455. invbox0
  456.         push de ;d = hgt, e = wid(chr)
  457.         call invhorline
  458.         pop de ;d = hgt, e = wid(chr)
  459.         inc b ;y
  460.         dec d
  461.         jr nz,invbox0
  462.         ret
  463.  
  464. invhorline
  465. ;b=y
  466. ;c=x/8
  467. ;e=wid(chr)
  468.         push bc
  469.         call calcscr_from_xchr_y
  470.          ld a,hx
  471.          xor lx
  472.          ld c,a
  473.         ld b,e
  474. invhorline0
  475.         ld a,(hl)
  476.         xor c;cpl
  477.         ld (hl),a
  478.         set 5,h
  479.         ld a,(hl)
  480.         xor c;cpl
  481.         ld (hl),a
  482.         set 6,h
  483.         ld a,(hl)
  484.         xor c;cpl
  485.         ld (hl),a
  486.         res 5,h
  487.         ld a,(hl)
  488.         xor c;cpl
  489.         ld (hl),a
  490.         res 6,h
  491.         inc hl
  492.         djnz invhorline0
  493.         pop bc
  494.         ret
  495.        
  496.        if 0
  497.         SHAPESPROC shapes_colortocolormask
  498. ;a=color = %....3210
  499.         push bc
  500.         ld c,a
  501.         ld b,c
  502.         srl b
  503.         rra
  504.         srl b
  505.         rra
  506.         srl b
  507.         rra
  508. ;a=%210...
  509.         srl c
  510.         rra
  511.         srl c
  512.         rra
  513.         srl c
  514.         rra
  515. ;a=%210210...
  516.         rrc c
  517.         rra
  518.         rlc c
  519.         rra
  520.         pop bc
  521.         ret
  522.        endif
  523.  
  524.         SHAPESPROC shapes_fillbox
  525. ;b=y
  526. ;c=x/8
  527. ;d=hgt
  528. ;e=wid8
  529. ;a=%33210210
  530. fillbox0
  531.         push de ;d = hgt, e = wid(chr)
  532.         call prhorline
  533.         pop de ;d = hgt, e = wid(chr)
  534.         inc b ;y
  535.         dec d
  536.         jr nz,fillbox0
  537.         ret
  538.        
  539.         SHAPESPROC shapes_prbox
  540. ;b=y
  541. ;c=x/8
  542. ;d=hgt
  543. ;e=wid8
  544. ;a=%33210210 (рамка чёрная)
  545.         push bc ;b = y, c = x
  546.         push de ;d = hgt, e = wid(chr)
  547.         call shapes_fillbox
  548.         pop de ;d = hgt, e = wid(chr)
  549.         pop bc ;b = y, c = x
  550.         jp shapes_prboxframe
  551.        
  552.         SHAPESPROC shapes_prboxframe
  553. ;b=y
  554. ;c=x/8
  555. ;d=hgt
  556. ;e=wid8
  557. ;(рамка чёрная)
  558.         push de ;d = hgt, e = wid(chr)
  559.         call prverline_l
  560.         pop de ;d = hgt, e = wid(chr)
  561.         push bc
  562.         ld a,c ;x/8
  563.         add a,e ;wid(chr)
  564.         dec a
  565.         ld c,a ;x/8+wid(chr)-1
  566.         push de ;d = hgt, e = wid(chr)
  567.         call prverline_r
  568.         pop de ;d = hgt, e = wid(chr)
  569.         pop bc
  570.  
  571.         xor a ;black
  572.         call prhorline                  
  573.         ld a,b ;y
  574.         add a,d ;hgt
  575.         dec a
  576.         ld b,a ;y+hgt-1
  577.         xor a ;black
  578.         ;call prhorline          
  579.         ;ret      
  580. prhorline
  581. ;b=y
  582. ;c=x/8
  583. ;e=wid(chr)
  584. ;a=%rlrrrlll
  585.         push bc
  586.         push af
  587.         call calcscr_from_xchr_y
  588.         pop af
  589.         ld b,e
  590. prhorline0
  591.         ld (hl),a
  592.         set 5,h
  593.         ld (hl),a
  594.         set 6,h
  595.         ld (hl),a
  596.         res 5,h
  597.         ld (hl),a
  598.         res 6,h
  599.         inc hl
  600.         djnz prhorline0
  601.         pop bc
  602.         ret
  603.        
  604. prverline_l
  605. ;b=y
  606. ;c=x/8
  607. ;d=hgt
  608.         push bc
  609.         call calcscr_from_xchr_y
  610.         ld a,0xb8;%10111000
  611.         and (hl)
  612.         ld b,d
  613.         ld de,40
  614. prverline_l0
  615.         ld (hl),a
  616.         add hl,de
  617.         djnz prverline_l0
  618.         pop bc
  619.         ret
  620.        
  621. prverline_r
  622. ;b=y
  623. ;c=x/8
  624. ;d=hgt
  625.         push bc
  626.         call calcscr_from_xchr_y
  627.         ld a,h
  628.         add a,0x60
  629.         ld h,a
  630.         ld a,0x47;%01000111
  631.         and (hl)
  632.         ld b,d
  633.         ld de,40
  634. prverline_r0
  635.         ld (hl),a
  636.         add hl,de
  637.         djnz prverline_r0
  638.         pop bc
  639.         ret
  640.        
  641.         SHAPESPROC shapes_line
  642. ;bc=x (в плоскости экрана, но может быть отрицательным)
  643. ;de=y (в плоскости экрана, но может быть отрицательным)
  644. ;ix=x2
  645. ;hl=y2
  646.         or a
  647.         sbc hl,de
  648.         add hl,de
  649.         jp p,shapes_line_noswap
  650.         ex de,hl ;y <-> y2
  651.         push ix
  652.         push bc
  653.         pop ix
  654.         pop bc ;x <-> x2
  655.         ;ld a,lx
  656.         ;ld lx,c
  657.         ;ld c,a
  658.         ;ld a,hx
  659.         ;ld hx,b
  660.         ;ld b,a ;x <-> x2
  661. shapes_line_noswap
  662.         or a
  663.         sbc hl,de ;dy >= 0
  664.         push hl ;dy
  665.         ;ld a,lx
  666.         ;sub c
  667.         ;ld l,a
  668.         ;ld a,hx
  669.         ;sbc a,b
  670.         ;ld h,a
  671.         push ix
  672.         pop hl
  673.         sbc hl,bc
  674.         push hl ;dx
  675.         exx
  676.         pop bc ;dx
  677.         ld a,0x03 ;inc bc
  678.         jp p,shapes_line_nodec
  679.         xor a
  680.         sub c
  681.         ld c,a
  682.         sbc a,b
  683.         sub c
  684.         ld b,a ;dx >= 0
  685.         ld a,0x0b ;dec bc
  686. shapes_line_nodec
  687.         pop de ;dy
  688. ;a=код inc/dec bc
  689. ;bc'=x (в плоскости экрана, но может быть отрицательным)
  690. ;de'=y (в плоскости экрана, но может быть отрицательным)
  691. ;bc=dx
  692. ;de=dy
  693.         ex de,hl
  694.         or a
  695.         sbc hl,bc
  696.         add hl,bc
  697.         ex de,hl
  698.         jr nc,shapes_linever ;dy>=dx
  699.         ld hy,b
  700.         ld ly,c ;counter=dx
  701.         inc iy ;inc hy ;рисуем, включая последний пиксель (учтено в цикле)
  702.         ld h,b
  703.         ld l,c
  704.         sra h
  705.         rr l ;ym=dx div 2
  706.          ;xor a
  707.          ;sub l
  708.          ;ld l,a
  709.          ;sbc a,h
  710.          ;sub l
  711.          ;ld h,a ;mym=256-(dx div 2)
  712.         exx
  713.         ld (shapes_lineincx),a
  714. ;bc=x
  715. ;de=y
  716. ;hl'=xm
  717. ;bc'=dx
  718. ;de'=dy
  719. shapes_linehor0
  720.         call line_invpixel
  721. shapes_lineincx=$
  722.         inc bc ;x+1        
  723.         exx
  724.         ;add hl,de ;mym+dy
  725.         or a
  726.         sbc hl,de ;ym-dy
  727.         exx
  728.         jr nc,shapes_linehor1
  729.         inc de ;y+1
  730.         exx
  731.         ;or a
  732.         ;sbc hl,bc ;mym-dx
  733.         add hl,bc ;ym+dx
  734.         exx
  735. shapes_linehor1
  736.         dec iy
  737.         ld a,hy
  738.         rla
  739.         jp nc,shapes_linehor0
  740.         ret
  741. shapes_linever
  742.         ld hy,d
  743.         ld ly,e ;counter=dy
  744.         ;inc iy ;inc hy ;рисуем, включая последний пиксель (учтено в цикле)
  745.         ld h,d
  746.         ld l,e
  747.         sra h
  748.         rr l
  749.          ;xor a
  750.          ;sub l
  751.          ;ld l,a
  752.          ;sbc a,h
  753.          ;sub l
  754.          ;ld h,a ;mxm=256-(dy div 2)
  755.         exx
  756.         ld (shapes_lineincx2),a
  757. ;bc=x
  758. ;de=y
  759. ;hl'=xm
  760. ;bc'=dx
  761. ;de'=dy
  762. shapes_linever0
  763.         call line_invpixel
  764.         inc de ;y+1
  765.         exx
  766.         ;add hl,bc ;mxm+dx
  767.         or a
  768.         sbc hl,bc ;xm-dx
  769.         exx
  770.         jr nc,shapes_linever1
  771. shapes_lineincx2=$
  772.         inc bc ;x+1
  773.         exx
  774.         ;or a
  775.         ;sbc hl,de ;mxm-dy
  776.         add hl,de ;xm+dy
  777.         exx
  778. shapes_linever1
  779.         dec iy
  780.         ld a,hy
  781.         rla
  782.         jp nc,shapes_linever0
  783.         ret
  784.  
  785.         macro NEXTCOLUMN
  786.         bit 6,h
  787.         set 6,h
  788.         jr z,1f;shapes_linehorR_incxok
  789.         ld a,h
  790.         xor 0x60
  791.         ld h,a
  792.         and 0x20
  793.         jr nz,1f;shapes_linehorR_incxok
  794.         inc hl
  795. 1;shapes_linehorR_incxok
  796.         endm
  797.  
  798. xytoscraddr
  799. ;l=x/2
  800. ;e=y (не портится)
  801. ;screen pages are mapped in 2 CPU windows
  802. ;addr = tY(y) + tX(x)
  803.         ld h,tx/256
  804.         ld d,ty/256
  805.         ld a,(de) ;(y*40)
  806.         add a,(hl) ;x div 4
  807.         ld (xytoscraddr_l),a
  808.         inc d
  809.         inc h
  810.         ld a,(de) ;'(y*40)
  811.         adc a,(hl) ;f(x mod 4)
  812.         ld h,a
  813. xytoscraddr_l=$+1
  814.         ld l,0
  815.         ret
  816.  
  817.         if 1==0
  818. prpixel
  819. ;bc=x (не портится)
  820. ;e=y (не портится)
  821. ;screen pages are mapped in 2 CPU windows
  822. ;addr = tY(y) + tX(x)
  823.         push bc
  824.         ld a,b
  825.         rra
  826.         ld a,c
  827.         rra
  828.         ld l,a
  829.         ;ld d,ty/256
  830.         ;ld h,tx/256
  831.         ld a,(de) ;(y*40)
  832.         jr c,prpixel_r
  833.         add a,(hl) ;x div 4
  834.         ld c,a
  835.         inc d
  836.         inc h
  837.         ld a,(de) ;'(y*40)
  838.         adc a,(hl) ;f(x mod 4)
  839.         ld b,a
  840.         ld a,(bc)
  841.         and 0xb8 ;keep right pixel ;иначе надо cls перед redraw
  842. prpixel_color_l=$+1
  843.         or 0;lx
  844.         ld (bc),a
  845.         dec h
  846.         dec d
  847.         pop bc
  848.         ret
  849. prpixel_r
  850.         add a,(hl) ;x div 4
  851.         ld c,a
  852.         inc d
  853.         inc h
  854.         ld a,(de) ;'(y*40)
  855.         adc a,(hl) ;f(x mod 4)
  856.         ld b,a
  857.         ld a,(bc)
  858.         and 0x47 ;keep left pixel ;иначе надо cls перед redraw
  859. prpixel_color_r=$+1
  860.         or 0;lx
  861.         ld (bc),a
  862.         dec h
  863.         dec d
  864.         pop bc
  865.         ret
  866.         endif
  867.  
  868.         SHAPESPROC shapes_drawwindow
  869.         push iy
  870. ;hx=brush color byte 0bRLrrrlll
  871. ;lx=background fill color byte 0bRLrrrlll
  872. ;b=hgt
  873. ;c=wid/2
  874. ;l=x/2
  875. ;e=y
  876.         ld hy,e
  877.         ld a,l
  878.         ld ly,a
  879. ;ly=x/2
  880. ;hy=y
  881.         call xytoscraddr
  882. ;hl=screen addr
  883.         dec b
  884.         push bc
  885.         push hl
  886.        
  887. drawwindowfill0
  888.         push bc
  889.         push hl
  890.         ld c,lx ;ld c,0b11111111 ;color byte 0bRLrrrlll
  891.         call drawverline
  892.         pop hl
  893.         NEXTCOLUMN
  894.         pop bc
  895.         dec c
  896.         jr nz,drawwindowfill0
  897.        
  898.         pop hl ;screen addr
  899.         pop bc
  900.  
  901.         push bc
  902.  
  903.         push bc
  904.         push hl
  905.         call drawbox
  906.         pop hl
  907.         pop bc
  908.         NEXTCOLUMN
  909.         ld de,40*2
  910.         add hl,de ;второй бокс внутри первого
  911.         dec c
  912.         dec c
  913.         ld a,b
  914.         sub 4
  915.         ld b,a
  916.         call drawbox
  917.        
  918.         pop bc ;b=hgt-1, c=wid/2
  919.        
  920. ;ly=x/2
  921. ;hy=y
  922.         ld e,hy
  923.         inc e
  924.         call drawwindowhormarks
  925.        
  926.         ld a,hy
  927.         add a,b ;+hgt-1
  928.         dec a
  929.         ld e,a
  930.         call drawwindowhormarks
  931.  
  932.         push bc
  933.         call drawwindowvermarks
  934.         pop bc
  935.         ld a,ly
  936.         add a,c ;wid/2
  937.         dec a
  938.         ld ly,a
  939.         call drawwindowvermarks
  940.         pop iy
  941.         ret
  942.        
  943. drawwindowvermarks
  944. ;ly=x/2
  945. ;hy=y
  946. ;b=hgt-1
  947. ;lx=color byte 0bRLrrrlll
  948.         ld a,ly
  949.         ld l,a
  950.         ld a,hy
  951.         add a,6
  952.         ld e,a
  953. ;l=x/2
  954. ;e=y
  955.         call xytoscraddr
  956.         ld a,hx
  957.         ld (hl),a
  958.         ld a,ly
  959.         ld l,a
  960.         ld a,hy
  961.         add a,b ;+hgt-1
  962.         sub 6
  963.         ld e,a
  964. ;l=x/2
  965. ;e=y        
  966.         call xytoscraddr
  967.         ld a,hx
  968.         ld (hl),a
  969.         ret
  970.  
  971.        
  972. drawwindowhormarks
  973. ;ly=x/2
  974. ;e=y
  975. ;c=wid/2
  976.         ld a,ly
  977.         add a,3
  978.         ld l,a
  979. ;l=x/2
  980. ;e=y
  981.         call xytoscraddr
  982.         ld a,hx
  983.         xor lx
  984.         and 0b01000111 ;color byte 0bRLrrrlll
  985.         xor lx
  986.         ld (hl),a
  987.  
  988.         ld a,ly
  989.         add a,c ;+wid/2
  990.         sub 3+1
  991.         ld l,a
  992. ;l=x/2
  993. ;e=y
  994.         call xytoscraddr
  995.         ld a,hx
  996.         xor lx
  997.         and 0b10111000 ;color byte 0bRLrrrlll
  998.         xor lx
  999.         ld (hl),a
  1000.         ret
  1001.        
  1002.         SHAPESPROC shapes_drawbutton_pressed
  1003.         scf
  1004.         jr drawbutton_go
  1005.  
  1006.         SHAPESPROC shapes_drawbutton
  1007.         or a
  1008. drawbutton_go
  1009.        push iy
  1010.  
  1011.         push af
  1012. ;iy=button descriptor (kept)
  1013. ;hx=brush color byte 0bRLrrrlll
  1014. ;lx=background fill color byte 0bRLrrrlll
  1015. ;b=hgt
  1016. ;c=wid/2
  1017. ;l=x/2
  1018. ;e=y
  1019.        ;push iy
  1020.         ld hy,e
  1021.         ld a,l
  1022.         ld ly,a
  1023. ;ly=x/2
  1024. ;hy=y
  1025. ;l=x/2
  1026. ;e=y
  1027.         ;call xytoscraddr
  1028. ;hl=screen addr
  1029.         dec b
  1030.         if 1==0
  1031.         push bc
  1032.         push hl
  1033. drawbuttonfill0
  1034.         push bc
  1035.         push hl
  1036.         ld c,lx ;ld c,0b11111111 ;color byte 0bRLrrrlll
  1037.         call drawverline
  1038.         pop hl
  1039.         NEXTCOLUMN
  1040.         pop bc
  1041.         dec c
  1042.         jr nz,drawbuttonfill0
  1043.         pop hl ;screen addr
  1044.         pop bc
  1045.         endif
  1046.  
  1047.        ;pop de ;"iy"
  1048.        
  1049.         pop af
  1050.         jr c,drawbutton_pressed_go
  1051.  
  1052.          push ix
  1053.          ld a,hx
  1054.          ld hx,lx
  1055.          ld lx,a
  1056.         call drawbutton_pressed_pp
  1057.          pop ix
  1058.         push bc
  1059.         ld e,hy
  1060.         ld a,ly
  1061.         ld l,a
  1062. ;l=x/2
  1063. ;e=y
  1064.         call xytoscraddr
  1065.         call drawbox
  1066.         pop bc
  1067.  
  1068.         call drawbutton_unpressed_pp
  1069.  
  1070.         push bc
  1071. ;ly=x/2
  1072. ;hy=y
  1073.         ld e,hy
  1074.         inc e
  1075.         inc e
  1076.         ld a,ly
  1077.         add a,c
  1078.         dec a
  1079.         ld l,a
  1080. ;l=x/2
  1081. ;e=y
  1082.         call xytoscraddr
  1083. ;hl=scraddr
  1084.         dec b
  1085.         ld c,hx
  1086. ;c=color byte 0bRLrrrlll
  1087. ;b=hgt
  1088.         call drawverline
  1089.         pop bc
  1090.        pop iy
  1091.         ret
  1092.  
  1093. drawbutton_pressed_go
  1094.          push ix
  1095.          ld a,hx
  1096.          ld hx,lx
  1097.          ld lx,a
  1098.         call drawbutton_unpressed_pp
  1099.          pop ix
  1100.         push bc
  1101.         ld e,hy
  1102.         ld a,ly
  1103.         ld l,a
  1104. ;l=x/2
  1105. ;e=y
  1106.         call xytoscraddr
  1107.         call drawbox
  1108.         pop bc
  1109.         call drawbutton_pressed_pp
  1110.  
  1111.         push bc
  1112. ;ly=x/2
  1113. ;hy=y
  1114.         ld e,hy
  1115.         inc e
  1116.         ld a,ly
  1117.         ld l,a
  1118. ;l=x/2
  1119. ;e=y
  1120.         call xytoscraddr
  1121. ;hl=scraddr
  1122.         ld c,hx
  1123. ;c=color byte 0bRLrrrlll
  1124. ;b=hgt
  1125.         dec b
  1126.         call drawverline
  1127.         pop bc
  1128.        pop iy
  1129.         ret
  1130.  
  1131. drawbutton_pressed_pp
  1132. ;bc=hgtwid/2
  1133.         push bc
  1134. ;ly=x/2
  1135. ;hy=y
  1136.         ld e,hy
  1137.         inc e
  1138.         ld a,ly
  1139.         ld l,a
  1140. ;l=x/2
  1141. ;e=y
  1142.         call xytoscraddr
  1143. ;hl=scraddr
  1144.         ld b,c
  1145.         ld c,hx
  1146. ;c=color byte 0bRLrrrlll
  1147. ;b=wid/2
  1148.         call drawhorline
  1149.         pop bc
  1150.         ret
  1151.  
  1152. drawbutton_unpressed_pp
  1153. ;bc=hgtwid/2
  1154.         push bc
  1155. ;ly=x/2
  1156. ;hy=y
  1157.         ld a,hy
  1158.         add a,b
  1159.         dec a
  1160.         ld e,a
  1161.         ld a,ly
  1162.         inc a
  1163.         ld l,a
  1164. ;l=x/2
  1165. ;e=y
  1166.         call xytoscraddr
  1167. ;hl=scraddr
  1168.         ld b,c
  1169.         dec b
  1170.         ld c,hx
  1171. ;c=color byte 0bRLrrrlll
  1172. ;b=wid/2
  1173.         call drawhorline
  1174.         pop bc
  1175.         ret
  1176.  
  1177.  
  1178. drawbox
  1179. ;hl=screen addr
  1180. ;hx=brush color byte 0bRLrrrlll
  1181. ;lx=background fill color byte 0bRLrrrlll
  1182. ;b=hgt-1
  1183. ;c=wid/2
  1184.         push bc
  1185.         push hl
  1186.         push bc
  1187.         ld a,hx
  1188.         xor lx
  1189.         and 0b01000111 ;color byte 0bRLrrrlll
  1190.         xor lx
  1191.         ld c,a
  1192.         call drawverline ;left line
  1193.         pop bc
  1194.         ld b,c ;wid/2
  1195.         ex (sp),hl
  1196.         ld c,hx ;ld c,0b11111111 ;color byte 0bRLrrrlll
  1197.         push bc
  1198.         call drawhorline ;top line
  1199.         pop bc ;b=wid/2, c=color byte 0bRLrrrlll
  1200.         ex (sp),hl ;bottom of left line
  1201.         call drawhorline ;bottom line
  1202.         pop hl ;rightmost byte of top line
  1203.         ld de,40
  1204.         add hl,de
  1205.         pop bc
  1206.         dec b ;b=hgt/2
  1207.         ld a,hx
  1208.         xor lx
  1209.         and 0b10111000 ;color byte 0bRLrrrlll
  1210.         xor lx
  1211.         ld c,a
  1212.         ;call drawverline ;right line
  1213.         ;ret
  1214. drawverline
  1215. ;hl=scraddr
  1216. ;c=color byte 0bRLrrrlll
  1217. ;b=hgt
  1218.         ld de,40
  1219. drawverline0
  1220.         ld (hl),c
  1221.         add hl,de
  1222.         djnz drawverline0
  1223.         ret
  1224.  
  1225. drawhorline
  1226. ;hl=scraddr
  1227. ;c=color byte 0bRLrrrlll
  1228. ;b=wid/2
  1229.         ld de,0x4000
  1230.         jr drawhorline0go
  1231. drawhorline0
  1232.         NEXTCOLUMN
  1233. drawhorline0go
  1234.         ld (hl),c
  1235.         djnz drawhorline0
  1236.         ret
  1237.  
  1238.         align 256
  1239. tx
  1240.         dup 256
  1241.         db ($&0xff)/4
  1242.         edup
  1243.         dup 64
  1244.         db 0x80
  1245.         db 0xc0
  1246.         db 0xa0
  1247.         db 0xe0
  1248.         edup
  1249. ty
  1250.         dup 200
  1251.         db 0xff&(($&0xff)*40)
  1252.         edup
  1253.         ds 56,0xff&8000
  1254.         dup 200
  1255.         db (($&0xff)*40)/256
  1256.         edup
  1257.         ds 56,8000/256
  1258.