?login_element?

Subversion Repositories NedoOS

Rev

Rev 521 | Go to most recent revision | 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.         SHAPESPROC shapes_colortocolormask
  497. ;a=color = %....3210
  498.         push bc
  499.         ld c,a
  500.         ld b,c
  501.         srl b
  502.         rra
  503.         srl b
  504.         rra
  505.         srl b
  506.         rra
  507. ;a=%210...
  508.         srl c
  509.         rra
  510.         srl c
  511.         rra
  512.         srl c
  513.         rra
  514. ;a=%210210...
  515.         rrc c
  516.         rra
  517.         rlc c
  518.         rra
  519.         pop bc
  520.         ret
  521.  
  522.         SHAPESPROC shapes_fillbox
  523. ;b=y
  524. ;c=x/8
  525. ;d=hgt
  526. ;e=wid8
  527. ;a=%33210210
  528. fillbox0
  529.         push de ;d = hgt, e = wid(chr)
  530.         call prhorline
  531.         pop de ;d = hgt, e = wid(chr)
  532.         inc b ;y
  533.         dec d
  534.         jr nz,fillbox0
  535.         ret
  536.        
  537.         SHAPESPROC shapes_prbox
  538. ;b=y
  539. ;c=x/8
  540. ;d=hgt
  541. ;e=wid8
  542. ;a=%33210210 (рамка чёрная)
  543.         push bc ;b = y, c = x
  544.         push de ;d = hgt, e = wid(chr)
  545.         call shapes_fillbox
  546.         pop de ;d = hgt, e = wid(chr)
  547.         pop bc ;b = y, c = x
  548.         jp shapes_prboxframe
  549.        
  550.         SHAPESPROC shapes_prboxframe
  551. ;b=y
  552. ;c=x/8
  553. ;d=hgt
  554. ;e=wid8
  555. ;(рамка чёрная)
  556.         push de ;d = hgt, e = wid(chr)
  557.         call prverline_l
  558.         pop de ;d = hgt, e = wid(chr)
  559.         push bc
  560.         ld a,c ;x/8
  561.         add a,e ;wid(chr)
  562.         dec a
  563.         ld c,a ;x/8+wid(chr)-1
  564.         push de ;d = hgt, e = wid(chr)
  565.         call prverline_r
  566.         pop de ;d = hgt, e = wid(chr)
  567.         pop bc
  568.  
  569.         xor a ;black
  570.         call prhorline                  
  571.         ld a,b ;y
  572.         add a,d ;hgt
  573.         dec a
  574.         ld b,a ;y+hgt-1
  575.         xor a ;black
  576.         ;call prhorline          
  577.         ;ret      
  578. prhorline
  579. ;b=y
  580. ;c=x/8
  581. ;e=wid(chr)
  582. ;a=%rlrrrlll
  583.         push bc
  584.         push af
  585.         call calcscr_from_xchr_y
  586.         pop af
  587.         ld b,e
  588. prhorline0
  589.         ld (hl),a
  590.         set 5,h
  591.         ld (hl),a
  592.         set 6,h
  593.         ld (hl),a
  594.         res 5,h
  595.         ld (hl),a
  596.         res 6,h
  597.         inc hl
  598.         djnz prhorline0
  599.         pop bc
  600.         ret
  601.        
  602. prverline_l
  603. ;b=y
  604. ;c=x/8
  605. ;d=hgt
  606.         push bc
  607.         call calcscr_from_xchr_y
  608.         ld a,0xb8;%10111000
  609.         and (hl)
  610.         ld b,d
  611.         ld de,40
  612. prverline_l0
  613.         ld (hl),a
  614.         add hl,de
  615.         djnz prverline_l0
  616.         pop bc
  617.         ret
  618.        
  619. prverline_r
  620. ;b=y
  621. ;c=x/8
  622. ;d=hgt
  623.         push bc
  624.         call calcscr_from_xchr_y
  625.         ld a,h
  626.         add a,0x60
  627.         ld h,a
  628.         ld a,0x47;%01000111
  629.         and (hl)
  630.         ld b,d
  631.         ld de,40
  632. prverline_r0
  633.         ld (hl),a
  634.         add hl,de
  635.         djnz prverline_r0
  636.         pop bc
  637.         ret
  638.        
  639.         SHAPESPROC shapes_line
  640. ;bc=x (в плоскости экрана, но может быть отрицательным)
  641. ;de=y (в плоскости экрана, но может быть отрицательным)
  642. ;ix=x2
  643. ;hl=y2
  644.         or a
  645.         sbc hl,de
  646.         add hl,de
  647.         jp p,shapes_line_noswap
  648.         ex de,hl ;y <-> y2
  649.         push ix
  650.         push bc
  651.         pop ix
  652.         pop bc ;x <-> x2
  653.         ;ld a,lx
  654.         ;ld lx,c
  655.         ;ld c,a
  656.         ;ld a,hx
  657.         ;ld hx,b
  658.         ;ld b,a ;x <-> x2
  659. shapes_line_noswap
  660.         or a
  661.         sbc hl,de ;dy >= 0
  662.         push hl ;dy
  663.         ;ld a,lx
  664.         ;sub c
  665.         ;ld l,a
  666.         ;ld a,hx
  667.         ;sbc a,b
  668.         ;ld h,a
  669.         push ix
  670.         pop hl
  671.         sbc hl,bc
  672.         push hl ;dx
  673.         exx
  674.         pop bc ;dx
  675.         ld a,0x03 ;inc bc
  676.         jp p,shapes_line_nodec
  677.         xor a
  678.         sub c
  679.         ld c,a
  680.         sbc a,b
  681.         sub c
  682.         ld b,a ;dx >= 0
  683.         ld a,0x0b ;dec bc
  684. shapes_line_nodec
  685.         pop de ;dy
  686. ;a=код inc/dec bc
  687. ;bc'=x (в плоскости экрана, но может быть отрицательным)
  688. ;de'=y (в плоскости экрана, но может быть отрицательным)
  689. ;bc=dx
  690. ;de=dy
  691.         ex de,hl
  692.         or a
  693.         sbc hl,bc
  694.         add hl,bc
  695.         ex de,hl
  696.         jr nc,shapes_linever ;dy>=dx
  697.         ld hy,b
  698.         ld ly,c ;counter=dx
  699.         inc iy ;inc hy ;рисуем, включая последний пиксель (учтено в цикле)
  700.         ld h,b
  701.         ld l,c
  702.         sra h
  703.         rr l ;ym=dx div 2
  704.          ;xor a
  705.          ;sub l
  706.          ;ld l,a
  707.          ;sbc a,h
  708.          ;sub l
  709.          ;ld h,a ;mym=256-(dx div 2)
  710.         exx
  711.         ld (shapes_lineincx),a
  712. ;bc=x
  713. ;de=y
  714. ;hl'=xm
  715. ;bc'=dx
  716. ;de'=dy
  717. shapes_linehor0
  718.         call line_invpixel
  719. shapes_lineincx=$
  720.         inc bc ;x+1        
  721.         exx
  722.         ;add hl,de ;mym+dy
  723.         or a
  724.         sbc hl,de ;ym-dy
  725.         exx
  726.         jr nc,shapes_linehor1
  727.         inc de ;y+1
  728.         exx
  729.         ;or a
  730.         ;sbc hl,bc ;mym-dx
  731.         add hl,bc ;ym+dx
  732.         exx
  733. shapes_linehor1
  734.         dec iy
  735.         ld a,hy
  736.         rla
  737.         jp nc,shapes_linehor0
  738.         ret
  739. shapes_linever
  740.         ld hy,d
  741.         ld ly,e ;counter=dy
  742.         ;inc iy ;inc hy ;рисуем, включая последний пиксель (учтено в цикле)
  743.         ld h,d
  744.         ld l,e
  745.         sra h
  746.         rr l
  747.          ;xor a
  748.          ;sub l
  749.          ;ld l,a
  750.          ;sbc a,h
  751.          ;sub l
  752.          ;ld h,a ;mxm=256-(dy div 2)
  753.         exx
  754.         ld (shapes_lineincx2),a
  755. ;bc=x
  756. ;de=y
  757. ;hl'=xm
  758. ;bc'=dx
  759. ;de'=dy
  760. shapes_linever0
  761.         call line_invpixel
  762.         inc de ;y+1
  763.         exx
  764.         ;add hl,bc ;mxm+dx
  765.         or a
  766.         sbc hl,bc ;xm-dx
  767.         exx
  768.         jr nc,shapes_linever1
  769. shapes_lineincx2=$
  770.         inc bc ;x+1
  771.         exx
  772.         ;or a
  773.         ;sbc hl,de ;mxm-dy
  774.         add hl,de ;xm+dy
  775.         exx
  776. shapes_linever1
  777.         dec iy
  778.         ld a,hy
  779.         rla
  780.         jp nc,shapes_linever0
  781.         ret
  782.  
  783.         macro NEXTCOLUMN
  784.         bit 6,h
  785.         set 6,h
  786.         jr z,1f;shapes_linehorR_incxok
  787.         ld a,h
  788.         xor 0x60
  789.         ld h,a
  790.         and 0x20
  791.         jr nz,1f;shapes_linehorR_incxok
  792.         inc hl
  793. 1;shapes_linehorR_incxok
  794.         endm
  795.  
  796. xytoscraddr
  797. ;l=x/2
  798. ;e=y (не портится)
  799. ;screen pages are mapped in 2 CPU windows
  800. ;addr = tY(y) + tX(x)
  801.         ld h,tx/256
  802.         ld d,ty/256
  803.         ld a,(de) ;(y*40)
  804.         add a,(hl) ;x div 4
  805.         ld (xytoscraddr_l),a
  806.         inc d
  807.         inc h
  808.         ld a,(de) ;'(y*40)
  809.         adc a,(hl) ;f(x mod 4)
  810.         ld h,a
  811. xytoscraddr_l=$+1
  812.         ld l,0
  813.         ret
  814.  
  815.         if 1==0
  816. prpixel
  817. ;bc=x (не портится)
  818. ;e=y (не портится)
  819. ;screen pages are mapped in 2 CPU windows
  820. ;addr = tY(y) + tX(x)
  821.         push bc
  822.         ld a,b
  823.         rra
  824.         ld a,c
  825.         rra
  826.         ld l,a
  827.         ;ld d,ty/256
  828.         ;ld h,tx/256
  829.         ld a,(de) ;(y*40)
  830.         jr c,prpixel_r
  831.         add a,(hl) ;x div 4
  832.         ld c,a
  833.         inc d
  834.         inc h
  835.         ld a,(de) ;'(y*40)
  836.         adc a,(hl) ;f(x mod 4)
  837.         ld b,a
  838.         ld a,(bc)
  839.         and 0xb8 ;keep right pixel ;иначе надо cls перед redraw
  840. prpixel_color_l=$+1
  841.         or 0;lx
  842.         ld (bc),a
  843.         dec h
  844.         dec d
  845.         pop bc
  846.         ret
  847. prpixel_r
  848.         add a,(hl) ;x div 4
  849.         ld c,a
  850.         inc d
  851.         inc h
  852.         ld a,(de) ;'(y*40)
  853.         adc a,(hl) ;f(x mod 4)
  854.         ld b,a
  855.         ld a,(bc)
  856.         and 0x47 ;keep left pixel ;иначе надо cls перед redraw
  857. prpixel_color_r=$+1
  858.         or 0;lx
  859.         ld (bc),a
  860.         dec h
  861.         dec d
  862.         pop bc
  863.         ret
  864.         endif
  865.  
  866.         SHAPESPROC shapes_drawwindow
  867.         push iy
  868. ;hx=brush color byte 0bRLrrrlll
  869. ;lx=background fill color byte 0bRLrrrlll
  870. ;b=hgt
  871. ;c=wid/2
  872. ;l=x/2
  873. ;e=y
  874.         ld hy,e
  875.         ld a,l
  876.         ld ly,a
  877. ;ly=x/2
  878. ;hy=y
  879.         call xytoscraddr
  880. ;hl=screen addr
  881.         dec b
  882.         push bc
  883.         push hl
  884.        
  885. drawwindowfill0
  886.         push bc
  887.         push hl
  888.         ld c,lx ;ld c,0b11111111 ;color byte 0bRLrrrlll
  889.         call drawverline
  890.         pop hl
  891.         NEXTCOLUMN
  892.         pop bc
  893.         dec c
  894.         jr nz,drawwindowfill0
  895.        
  896.         pop hl ;screen addr
  897.         pop bc
  898.  
  899.         push bc
  900.  
  901.         push bc
  902.         push hl
  903.         call drawbox
  904.         pop hl
  905.         pop bc
  906.         NEXTCOLUMN
  907.         ld de,40*2
  908.         add hl,de ;второй бокс внутри первого
  909.         dec c
  910.         dec c
  911.         ld a,b
  912.         sub 4
  913.         ld b,a
  914.         call drawbox
  915.        
  916.         pop bc ;b=hgt-1, c=wid/2
  917.        
  918. ;ly=x/2
  919. ;hy=y
  920.         ld e,hy
  921.         inc e
  922.         call drawwindowhormarks
  923.        
  924.         ld a,hy
  925.         add a,b ;+hgt-1
  926.         dec a
  927.         ld e,a
  928.         call drawwindowhormarks
  929.  
  930.         push bc
  931.         call drawwindowvermarks
  932.         pop bc
  933.         ld a,ly
  934.         add a,c ;wid/2
  935.         dec a
  936.         ld ly,a
  937.         call drawwindowvermarks
  938.         pop iy
  939.         ret
  940.        
  941. drawwindowvermarks
  942. ;ly=x/2
  943. ;hy=y
  944. ;b=hgt-1
  945. ;lx=color byte 0bRLrrrlll
  946.         ld a,ly
  947.         ld l,a
  948.         ld a,hy
  949.         add a,6
  950.         ld e,a
  951. ;l=x/2
  952. ;e=y
  953.         call xytoscraddr
  954.         ld a,hx
  955.         ld (hl),a
  956.         ld a,ly
  957.         ld l,a
  958.         ld a,hy
  959.         add a,b ;+hgt-1
  960.         sub 6
  961.         ld e,a
  962. ;l=x/2
  963. ;e=y        
  964.         call xytoscraddr
  965.         ld a,hx
  966.         ld (hl),a
  967.         ret
  968.  
  969.        
  970. drawwindowhormarks
  971. ;ly=x/2
  972. ;e=y
  973. ;c=wid/2
  974.         ld a,ly
  975.         add a,3
  976.         ld l,a
  977. ;l=x/2
  978. ;e=y
  979.         call xytoscraddr
  980.         ld a,hx
  981.         xor lx
  982.         and 0b01000111 ;color byte 0bRLrrrlll
  983.         xor lx
  984.         ld (hl),a
  985.  
  986.         ld a,ly
  987.         add a,c ;+wid/2
  988.         sub 3+1
  989.         ld l,a
  990. ;l=x/2
  991. ;e=y
  992.         call xytoscraddr
  993.         ld a,hx
  994.         xor lx
  995.         and 0b10111000 ;color byte 0bRLrrrlll
  996.         xor lx
  997.         ld (hl),a
  998.         ret
  999.        
  1000.         SHAPESPROC shapes_drawbutton_pressed
  1001.         scf
  1002.         jr drawbutton_go
  1003.  
  1004.         SHAPESPROC shapes_drawbutton
  1005.         or a
  1006. drawbutton_go
  1007.        push iy
  1008.  
  1009.         push af
  1010. ;iy=button descriptor (kept)
  1011. ;hx=brush color byte 0bRLrrrlll
  1012. ;lx=background fill color byte 0bRLrrrlll
  1013. ;b=hgt
  1014. ;c=wid/2
  1015. ;l=x/2
  1016. ;e=y
  1017.        ;push iy
  1018.         ld hy,e
  1019.         ld a,l
  1020.         ld ly,a
  1021. ;ly=x/2
  1022. ;hy=y
  1023. ;l=x/2
  1024. ;e=y
  1025.         ;call xytoscraddr
  1026. ;hl=screen addr
  1027.         dec b
  1028.         if 1==0
  1029.         push bc
  1030.         push hl
  1031. drawbuttonfill0
  1032.         push bc
  1033.         push hl
  1034.         ld c,lx ;ld c,0b11111111 ;color byte 0bRLrrrlll
  1035.         call drawverline
  1036.         pop hl
  1037.         NEXTCOLUMN
  1038.         pop bc
  1039.         dec c
  1040.         jr nz,drawbuttonfill0
  1041.         pop hl ;screen addr
  1042.         pop bc
  1043.         endif
  1044.  
  1045.        ;pop de ;"iy"
  1046.        
  1047.         pop af
  1048.         jr c,drawbutton_pressed_go
  1049.  
  1050.          push ix
  1051.          ld a,hx
  1052.          ld hx,lx
  1053.          ld lx,a
  1054.         call drawbutton_pressed_pp
  1055.          pop ix
  1056.         push bc
  1057.         ld e,hy
  1058.         ld a,ly
  1059.         ld l,a
  1060. ;l=x/2
  1061. ;e=y
  1062.         call xytoscraddr
  1063.         call drawbox
  1064.         pop bc
  1065.  
  1066.         call drawbutton_unpressed_pp
  1067.  
  1068.         push bc
  1069. ;ly=x/2
  1070. ;hy=y
  1071.         ld e,hy
  1072.         inc e
  1073.         inc e
  1074.         ld a,ly
  1075.         add a,c
  1076.         dec a
  1077.         ld l,a
  1078. ;l=x/2
  1079. ;e=y
  1080.         call xytoscraddr
  1081. ;hl=scraddr
  1082.         dec b
  1083.         ld c,hx
  1084. ;c=color byte 0bRLrrrlll
  1085. ;b=hgt
  1086.         call drawverline
  1087.         pop bc
  1088.        pop iy
  1089.         ret
  1090.  
  1091. drawbutton_pressed_go
  1092.          push ix
  1093.          ld a,hx
  1094.          ld hx,lx
  1095.          ld lx,a
  1096.         call drawbutton_unpressed_pp
  1097.          pop ix
  1098.         push bc
  1099.         ld e,hy
  1100.         ld a,ly
  1101.         ld l,a
  1102. ;l=x/2
  1103. ;e=y
  1104.         call xytoscraddr
  1105.         call drawbox
  1106.         pop bc
  1107.         call drawbutton_pressed_pp
  1108.  
  1109.         push bc
  1110. ;ly=x/2
  1111. ;hy=y
  1112.         ld e,hy
  1113.         inc e
  1114.         ld a,ly
  1115.         ld l,a
  1116. ;l=x/2
  1117. ;e=y
  1118.         call xytoscraddr
  1119. ;hl=scraddr
  1120.         ld c,hx
  1121. ;c=color byte 0bRLrrrlll
  1122. ;b=hgt
  1123.         dec b
  1124.         call drawverline
  1125.         pop bc
  1126.        pop iy
  1127.         ret
  1128.  
  1129. drawbutton_pressed_pp
  1130. ;bc=hgtwid/2
  1131.         push bc
  1132. ;ly=x/2
  1133. ;hy=y
  1134.         ld e,hy
  1135.         inc e
  1136.         ld a,ly
  1137.         ld l,a
  1138. ;l=x/2
  1139. ;e=y
  1140.         call xytoscraddr
  1141. ;hl=scraddr
  1142.         ld b,c
  1143.         ld c,hx
  1144. ;c=color byte 0bRLrrrlll
  1145. ;b=wid/2
  1146.         call drawhorline
  1147.         pop bc
  1148.         ret
  1149.  
  1150. drawbutton_unpressed_pp
  1151. ;bc=hgtwid/2
  1152.         push bc
  1153. ;ly=x/2
  1154. ;hy=y
  1155.         ld a,hy
  1156.         add a,b
  1157.         dec a
  1158.         ld e,a
  1159.         ld a,ly
  1160.         inc a
  1161.         ld l,a
  1162. ;l=x/2
  1163. ;e=y
  1164.         call xytoscraddr
  1165. ;hl=scraddr
  1166.         ld b,c
  1167.         dec b
  1168.         ld c,hx
  1169. ;c=color byte 0bRLrrrlll
  1170. ;b=wid/2
  1171.         call drawhorline
  1172.         pop bc
  1173.         ret
  1174.  
  1175.  
  1176. drawbox
  1177. ;hl=screen addr
  1178. ;hx=brush color byte 0bRLrrrlll
  1179. ;lx=background fill color byte 0bRLrrrlll
  1180. ;b=hgt-1
  1181. ;c=wid/2
  1182.         push bc
  1183.         push hl
  1184.         push bc
  1185.         ld a,hx
  1186.         xor lx
  1187.         and 0b01000111 ;color byte 0bRLrrrlll
  1188.         xor lx
  1189.         ld c,a
  1190.         call drawverline ;left line
  1191.         pop bc
  1192.         ld b,c ;wid/2
  1193.         ex (sp),hl
  1194.         ld c,hx ;ld c,0b11111111 ;color byte 0bRLrrrlll
  1195.         push bc
  1196.         call drawhorline ;top line
  1197.         pop bc ;b=wid/2, c=color byte 0bRLrrrlll
  1198.         ex (sp),hl ;bottom of left line
  1199.         call drawhorline ;bottom line
  1200.         pop hl ;rightmost byte of top line
  1201.         ld de,40
  1202.         add hl,de
  1203.         pop bc
  1204.         dec b ;b=hgt/2
  1205.         ld a,hx
  1206.         xor lx
  1207.         and 0b10111000 ;color byte 0bRLrrrlll
  1208.         xor lx
  1209.         ld c,a
  1210.         ;call drawverline ;right line
  1211.         ;ret
  1212. drawverline
  1213. ;hl=scraddr
  1214. ;c=color byte 0bRLrrrlll
  1215. ;b=hgt
  1216.         ld de,40
  1217. drawverline0
  1218.         ld (hl),c
  1219.         add hl,de
  1220.         djnz drawverline0
  1221.         ret
  1222.  
  1223. drawhorline
  1224. ;hl=scraddr
  1225. ;c=color byte 0bRLrrrlll
  1226. ;b=wid/2
  1227.         ld de,0x4000
  1228.         jr drawhorline0go
  1229. drawhorline0
  1230.         NEXTCOLUMN
  1231. drawhorline0go
  1232.         ld (hl),c
  1233.         djnz drawhorline0
  1234.         ret
  1235.  
  1236.         align 256
  1237. tx
  1238.         dup 256
  1239.         db ($&0xff)/4
  1240.         edup
  1241.         dup 64
  1242.         db 0x80
  1243.         db 0xc0
  1244.         db 0xa0
  1245.         db 0xe0
  1246.         edup
  1247. ty
  1248.         dup 200
  1249.         db 0xff&(($&0xff)*40)
  1250.         edup
  1251.         ds 56,0xff&8000
  1252.         dup 200
  1253.         db (($&0xff)*40)/256
  1254.         edup
  1255.         ds 56,8000/256
  1256.