?login_element?

Subversion Repositories NedoOS

Rev

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

  1.         DEVICE ZXSPECTRUM128
  2.         include "../../_sdk/sys_h.asm"
  3.  
  4. STACK=0x4000
  5. scrbase=0x8000
  6.  
  7. ROTATEDFONT=1
  8. MAKEROTATEDFONT=0;1
  9. WIN1251=1
  10. MAKEWIN1251=0;1
  11.  
  12.         macro NEXTCOLUMN
  13.         bit 6,h
  14.         set 6,h
  15.         jr z,1f;shapes_linehorR_incxok
  16.         ld a,h
  17.         xor 0x60
  18.         ld h,a
  19.         and 0x20
  20.         jr nz,1f;shapes_linehorR_incxok
  21.         inc hl
  22. 1;shapes_linehorR_incxok
  23.         endm
  24.  
  25.         org PROGSTART
  26. begin
  27.         ld sp,STACK
  28.         OS_HIDEFROMPARENT
  29.  
  30.         ld e,0
  31.         OS_SETGFX ;e=0:EGA, e=2:MC, e=3:6912, e=6:text ;+SET FOCUS ;e=-1: disable gfx (out: e=old gfxmode)
  32.        
  33.         ld e,0 ;color byte 0bRLrrrlll
  34.         OS_CLS
  35.  
  36.        if MAKEWIN1251
  37. ;make 1251 font
  38.         ld hl,propfont
  39.         ld de,waspropfont
  40.         ld bc,0x900
  41.         ldir
  42.  
  43.         ld e,0
  44. mk1251_chars0        
  45.         ld d,twinto866/256
  46.         ld a,(de)
  47.         ld l,a
  48.         ld d,propfont/256
  49.         ld h,waspropfont/256
  50.         ld b,9
  51. mk1251_char0
  52.         ld a,(hl)
  53.         ld (de),a
  54.         inc h
  55.         inc d
  56.         djnz mk1251_char0
  57.         inc e
  58.         jr nz,mk1251_chars0
  59.        endif
  60.        
  61.        if MAKEROTATEDFONT
  62.         ld l,0
  63. mkrotfont0
  64.        push hl
  65.         ld h,propfont/256
  66.         ld de,chardata
  67.         ld b,8
  68. mkrotfont_copychar0
  69.         ld a,(hl)
  70.         ld (de),a
  71.         inc h
  72.         inc e
  73.         djnz mkrotfont_copychar0
  74.        ;ld c,(hl) ;charwidth
  75.         ex de,hl
  76.         ld d,propfont/256 + 7
  77.         ld b,8
  78. mkrotfont_rotchar0
  79.         ld hl,chardata
  80.         dup 8
  81.         rl (hl)
  82.         rla
  83.         inc l
  84.         edup
  85.         ld (de),a
  86.         dec d
  87.         djnz mkrotfont_rotchar0
  88.        pop hl
  89.         inc l
  90.         jr nz,mkrotfont0
  91.        endif
  92.        
  93.         ld a,(user_scr0_low) ;ok
  94.         SETPG8000
  95.         ld a,(user_scr0_high) ;ok
  96.         SETPGC000
  97.        
  98. ;01          89          01    ;low+0x0000
  99. ;   23          ab          23 ;high+0x0000
  100. ;      45          cd          ;low+0x2000
  101. ;         67          ef       ;high+0x2000
  102.  
  103.         ;ld hl,0x8000
  104.         ;ld b,10
  105.         ;ld c,0xff        
  106. ;hl=scraddr
  107. ;c=color byte 0bRLrrrlll
  108. ;b=wid/2
  109.         ;call drawhorline
  110.         ;jr $
  111.        
  112.         ld l,1
  113.         ld e,10
  114.         ld hx,0b00111111 ;fill color byte 0bRLrrrlll
  115.         ld lx,0b00000000 ;11111111 ;brush color byte 0bRLrrrlll
  116.         ld b,100-1 ;hgt-1
  117.         ld c,159 ;wid/2
  118. ;l=x/2
  119. ;e=y
  120. ;lx=brush color byte 0bRLrrrlll
  121. ;hx=fill color byte 0bRLrrrlll
  122. ;b=hgt-1
  123. ;c=wid/2
  124.         call drawwindow
  125.  
  126.         ld hl,0x8000+(40*100)
  127.         ld e,0
  128. pr0
  129.         push hl
  130.         ld ly,1;0 ;phase
  131.         ld d,32
  132. pr1
  133.         push de
  134.         ld a,e ;char
  135.         ex de,hl
  136.         call prcharprop
  137.         ex de,hl
  138.         pop de
  139.         inc e
  140.         dec d
  141.         jr nz,pr1
  142.         pop hl
  143.         ld bc,8*40
  144.         add hl,bc
  145.         inc e
  146.         dec e
  147.         jr nz,pr0
  148.        
  149.         jr $
  150.        
  151.         QUIT
  152.  
  153. xytoscraddr
  154. ;l=x/2
  155. ;e=y (не портится)
  156. ;screen pages are mapped in 2 CPU windows
  157. ;addr = tY(y) + tX(x)
  158.         ld h,tx/256
  159.         ld d,ty/256
  160.         ld a,(de) ;(y*40)
  161.         add a,(hl) ;x div 4
  162.         ld (xytoscraddr_l),a
  163.         inc d
  164.         inc h
  165.         ld a,(de) ;'(y*40)
  166.         adc a,(hl) ;f(x mod 4)
  167.         ld h,a
  168. xytoscraddr_l=$+1
  169.         ld l,0
  170.         ret
  171.  
  172.         if 1==0
  173. prpixel
  174. ;bc=x (не портится)
  175. ;e=y (не портится)
  176. ;screen pages are mapped in 2 CPU windows
  177. ;addr = tY(y) + tX(x)
  178.         push bc
  179.         ld a,b
  180.         rra
  181.         ld a,c
  182.         rra
  183.         ld l,a
  184.         ;ld d,ty/256
  185.         ;ld h,tx/256
  186.         ld a,(de) ;(y*40)
  187.         jr c,prpixel_r
  188.         add a,(hl) ;x div 4
  189.         ld c,a
  190.         inc d
  191.         inc h
  192.         ld a,(de) ;'(y*40)
  193.         adc a,(hl) ;f(x mod 4)
  194.         ld b,a
  195.         ld a,(bc)
  196.         and 0xb8 ;keep right pixel ;иначе надо cls перед redraw
  197. prpixel_color_l=$+1
  198.         or 0;lx
  199.         ld (bc),a
  200.         dec h
  201.         dec d
  202.         pop bc
  203.         ret
  204. prpixel_r
  205.         add a,(hl) ;x div 4
  206.         ld c,a
  207.         inc d
  208.         inc h
  209.         ld a,(de) ;'(y*40)
  210.         adc a,(hl) ;f(x mod 4)
  211.         ld b,a
  212.         ld a,(bc)
  213.         and 0x47 ;keep left pixel ;иначе надо cls перед redraw
  214. prpixel_color_r=$+1
  215.         or 0;lx
  216.         ld (bc),a
  217.         dec h
  218.         dec d
  219.         pop bc
  220.         ret
  221.         endif
  222.  
  223. drawwindow
  224. ;l=x/2
  225. ;e=y
  226.         ld hy,e
  227.         ld a,l
  228.         ld ly,a
  229. ;ly=x/2
  230. ;hy=y
  231.         call xytoscraddr
  232. ;hl=screen addr
  233. ;lx=brush color byte 0bRLrrrlll
  234. ;hx=fill color byte 0bRLrrrlll
  235. ;b=hgt-1
  236. ;c=wid/2
  237.         push bc
  238.         push hl
  239.        
  240. drawwindowfill0
  241.         push bc
  242.         push hl
  243.         ld c,hx ;ld c,0b11111111 ;color byte 0bRLrrrlll
  244.         call drawverline
  245.         pop hl
  246.         NEXTCOLUMN
  247.         pop bc
  248.         dec c
  249.         jr nz,drawwindowfill0
  250.        
  251.         pop hl ;screen addr
  252.         pop bc
  253.  
  254.         push bc
  255.  
  256.         push bc
  257.         push hl
  258.         call drawbox
  259.         pop hl
  260.         pop bc
  261.         NEXTCOLUMN
  262.         ld de,40*2
  263.         add hl,de ;второй бокс внутри первого
  264.         dec c
  265.         dec c
  266.         ld a,b
  267.         sub 4
  268.         ld b,a
  269.         call drawbox
  270.        
  271.         pop bc ;b=hgt-1, c=wid/2
  272.        
  273. ;ly=x/2
  274. ;hy=y
  275.         ld e,hy
  276.         inc e
  277.         call drawwindowhormarks
  278.        
  279.         ld a,hy
  280.         add a,b ;+hgt-1
  281.         dec a
  282.         ld e,a
  283.         call drawwindowhormarks
  284.  
  285.         push bc
  286.         call drawwindowvermarks
  287.         pop bc
  288.         ld a,ly
  289.         add a,c ;wid/2
  290.         dec a
  291.         ld ly,a
  292.         call drawwindowvermarks
  293.        
  294.         ret
  295.        
  296. drawwindowvermarks
  297. ;ly=x/2
  298. ;hy=y
  299. ;b=hgt-1
  300. ;lx=color byte 0bRLrrrlll
  301.         ld a,ly
  302.         ld l,a
  303.         ld a,hy
  304.         add a,6
  305.         ld e,a
  306. ;l=x/2
  307. ;e=y
  308.         call xytoscraddr
  309.         ld a,lx
  310.         ld (hl),a
  311.         ld a,ly
  312.         ld l,a
  313.         ld a,hy
  314.         add a,b ;+hgt-1
  315.         sub 6
  316.         ld e,a
  317. ;l=x/2
  318. ;e=y        
  319.         call xytoscraddr
  320.         ld a,lx
  321.         ld (hl),a
  322.         ret
  323.  
  324.        
  325. drawwindowhormarks
  326. ;ly=x/2
  327. ;e=y
  328. ;c=wid/2
  329.         ld a,ly
  330.         add a,3
  331.         ld l,a
  332. ;l=x/2
  333. ;e=y
  334.         call xytoscraddr
  335.         ld a,lx
  336.         xor hx
  337.         and 0b01000111 ;color byte 0bRLrrrlll
  338.         xor hx
  339.         ld (hl),a
  340.  
  341.         ld a,ly
  342.         add a,c ;+wid/2
  343.         sub 3+1
  344.         ld l,a
  345. ;l=x/2
  346. ;e=y
  347.         call xytoscraddr
  348.         ld a,lx
  349.         xor hx
  350.         and 0b10111000 ;color byte 0bRLrrrlll
  351.         xor hx
  352.         ld (hl),a
  353.         ret
  354.        
  355.  
  356. drawbox
  357. ;hl=screen addr
  358. ;lx=color byte 0bRLrrrlll
  359. ;b=hgt-1
  360. ;c=wid/2
  361.         push bc
  362.         push hl
  363.         push bc
  364.         ld a,lx
  365.         xor hx
  366.         and 0b01000111 ;color byte 0bRLrrrlll
  367.         xor hx
  368.         ld c,a
  369.         call drawverline ;left line
  370.         pop bc
  371.         ld b,c ;wid/2
  372.         ex (sp),hl
  373.         ld c,lx ;ld c,0b11111111 ;color byte 0bRLrrrlll
  374.         push bc
  375.         call drawhorline ;top line
  376.         pop bc ;b=wid/2, c=color byte 0bRLrrrlll
  377.         ex (sp),hl ;bottom of left line
  378.         call drawhorline ;bottom line
  379.         pop hl ;rightmost byte of top line
  380.         ld de,40
  381.         add hl,de
  382.         pop bc
  383.         dec b ;b=hgt/2
  384.         ld a,lx
  385.         xor hx
  386.         and 0b10111000 ;color byte 0bRLrrrlll
  387.         xor hx
  388.         ld c,a
  389.         ;call drawverline ;right line
  390.         ;ret
  391. drawverline
  392. ;hl=scraddr
  393. ;c=color byte 0bRLrrrlll
  394. ;b=hgt
  395.         ld de,40
  396. drawverline0
  397.         ld (hl),c
  398.         add hl,de
  399.         djnz drawverline0
  400.         ret
  401.  
  402. drawhorline
  403. ;hl=scraddr
  404. ;c=color byte 0bRLrrrlll
  405. ;b=wid/2
  406.         ld de,0x4000
  407.         jr drawhorline0go
  408. drawhorline0
  409.         NEXTCOLUMN
  410. drawhorline0go
  411.         ld (hl),c
  412.         djnz drawhorline0
  413.         ret
  414.  
  415.     if !ROTATEDFONT
  416. prcharprop_shch
  417.         ld a,30
  418.         call prcharprop_do
  419.         ld a,31
  420.         jr prcharprop_do
  421.     endif
  422. prcharprop
  423. ;print with proportional font (any char width up to 8)
  424. ;de=screen addr
  425. ;ly=phase (even=left pixel [of next screen addr], odd=right pixel)
  426. ;a=char
  427.     if ROTATEDFONT
  428.         ld l,a
  429.         ld h,propfont/256 + 8
  430.         ld a,ly ;phase
  431.        ld c,a ;phase
  432.         add a,(hl) ;charwidth
  433.         dec h
  434.         ld ly,a ;nextphase = phase + charwidth
  435.        inc a
  436.        or 1
  437.        sub c ;phase
  438.        rra
  439.        ld hy,a ;number of 2 pixel columns = (((nextphase+1)|1) - phase)/2      
  440.         ld bc,40
  441.         ld a,b ;0
  442.        jr nc,prcharprop_columns0_skipbyte ;odd phase = blank left pixel in same screen addr
  443. ;de=screen addr
  444. ;hl=gfx addr
  445. prcharprop_columns0
  446.         bit 6,d
  447.         set 6,d
  448.         jr z,$+2+4+2+2+1
  449.          ld a,d
  450.          xor 0x60
  451.          ld d,a
  452.          and 0x20
  453.          jr nz,$+3
  454.          inc de
  455.         ld a,(hl)
  456.         dec h
  457. prcharprop_columns0_skipbyte
  458.         push de ;screen addr
  459.         push hl ;gfx addr
  460.         ld h,(hl)
  461.         ld l,a
  462.         ex de,hl
  463.         dup 7
  464.         ld a,(hl)
  465.         rl e ;CY=left pixel
  466.         jr nc,$+4
  467.         or 0x47 ;hx
  468.         rl d ;CY=right pixel
  469.         jr nc,$+4
  470.         or 0xb8 ;lx
  471.         ld (hl),a
  472.         add hl,bc
  473.         edup
  474.         ld a,(hl)
  475.         rl e ;CY=left pixel
  476.         jr nc,$+4
  477.         or 0x47 ;hx
  478.         rl d ;CY=right pixel
  479.         jr nc,$+4
  480.         or 0xb8 ;lx
  481.         ld (hl),a
  482. ;3. next column and loop
  483.         pop hl ;gfx addr
  484.         dec h
  485.         pop de ;screen addr
  486.         dec hy
  487.         jp nz,prcharprop_columns0
  488. ;de=next screen addr
  489.         ret
  490.    
  491.     else ;~ROTATEDFONT
  492.    
  493. ;Щ (Shch) doesn't fit in 8 bits + scroll
  494. ;print it as Ш (Sh) + tail
  495.        if WIN1251
  496.         cp '┘'
  497.        else
  498.         cp 'Щ'
  499.        endif
  500.         jr z,prcharprop_shch
  501. prcharprop_do
  502.        push de
  503.         ld l,a
  504.         ld h,propfont/256
  505.         ld de,chardata
  506. ;1. copy char data
  507. ;shift 1 pix right if needed
  508.         ld a,ly ;phase
  509.         rra
  510.         jr nc,prcharprop_copyfontnoscroll
  511.         dup 7
  512.         ld a,(hl)
  513.         rrca
  514.         ld (de),a
  515.         inc h
  516.         inc e
  517.         edup
  518.         ld a,(hl)
  519.         rrca
  520.         jp prcharprop_copyfontq
  521. prcharprop_copyfontnoscroll
  522.         dup 7
  523.         ld a,(hl)
  524.         ld (de),a
  525.         inc h
  526.         inc e
  527.         edup
  528.         ld a,(hl)
  529. prcharprop_copyfontq
  530.         ld (de),a
  531.         inc h
  532.         ld b,(hl) ;charwidth
  533.         ld a,ly ;phase
  534.         add a,b
  535.         ld ly,a ;next phase = phase + charwidth
  536.         sub b ;ld a,c ;phase
  537.         and 1 ;phase&1
  538.         inc a
  539.         add a,b ;charwidth
  540.         rra
  541.         ld hy,a ;number of 2 pixel columns = (charwidth + (phase&1) + 1)/2
  542.        pop hl
  543. ;hl=screen addr
  544. ;hy=number of 2 pixel columns = (charwidth + (phase&1) + 1)/2
  545. ;ly=next phase (even=left, odd=right pixel)
  546. ;2. print 2 pixel vertical line (scroll left bits 7,6 in char data)
  547.         ld bc,40
  548. prcharprop_columns0
  549.         push hl
  550.         ld de,chardata
  551.         dup 7
  552.         ex de,hl
  553.         ld a,(de)
  554.         rl (hl) ;CY=left pixel
  555.         jr nc,$+4
  556.         or 0x47 ;hx
  557.         rl (hl) ;CY=right pixel
  558.         jr nc,$+4
  559.         or 0xb8 ;lx
  560.         ld (de),a
  561.         ex de,hl
  562.         add hl,bc
  563.         inc e
  564.         edup
  565.         ex de,hl
  566.         ld a,(de)
  567.         rl (hl) ;CY=left pixel
  568.         jr nc,$+4
  569.         or 0x47 ;hx
  570.         rl (hl) ;CY=right pixel
  571.         jr nc,$+4
  572.         or 0xb8 ;lx
  573.         ld (de),a
  574. ;3. next column and loop
  575.         pop hl
  576.         ld d,h
  577.         ld e,l ;this will be next screen addr if the char ends in odd column ((ly&1) = 1)
  578.         bit 6,h
  579.         set 6,h
  580.         jr z,$+2+4+2+2+1
  581.          ld a,h
  582.          xor 0x60
  583.          ld h,a
  584.          and 0x20
  585.          jr nz,$+3
  586.          inc hl
  587.         dec hy
  588.         jp nz,prcharprop_columns0
  589.         ld a,ly ;ly=next phase (even=left, odd=right pixel)
  590.         rra
  591.         ret c ;old screen addr if the char ends in odd column ((ly&1) = 1)
  592.         ex de,hl
  593. ;hl=next screen addr
  594.         ret
  595.     endif ;~ROTATEDFONT
  596.  
  597.         align 8
  598. chardata
  599.         ds 8 ;any place for inc l
  600.  
  601.       if ROTATEDFONT
  602.         align 256
  603.         ds 256 ;for max width 8 at odd x phase
  604.       endif
  605.         align 256
  606. propfont
  607.       if ROTATEDFONT & !MAKEROTATEDFONT
  608.        if WIN1251 & !MAKEWIN1251
  609.         incbin "prot1251.bin" ;0x800 font + 0x100 width
  610.        else
  611.         incbin "protfont.bin" ;0x800 font + 0x100 width
  612.        endif
  613.       else
  614.        if WIN1251 & !MAKEWIN1251
  615.         incbin "prop1251.bin" ;0x800 font + 0x100 width
  616.        else
  617.         incbin "propfont.bin" ;0x800 font + 0x100 width
  618.        endif
  619.       endif
  620.  
  621.        if MAKEWIN1251
  622. waspropfont
  623.         ds 0x900
  624.         align 256
  625. twinto866
  626.         incbin "winto866"
  627.        endif
  628.  
  629.         align 256
  630. tx
  631.         dup 256
  632.         db ($&0xff)/4
  633.         edup
  634.         dup 64
  635.         db 0x80
  636.         db 0xc0
  637.         db 0xa0
  638.         db 0xe0
  639.         edup
  640. ty
  641.         dup 200
  642.         db 0xff&(($&0xff)*40)
  643.         edup
  644.         ds 56,0xff&8000
  645.         dup 200
  646.         db (($&0xff)*40)/256
  647.         edup
  648.         ds 56,8000/256
  649.  
  650. end
  651.  
  652.       if !ROTATEDFONT
  653. ;fix font
  654.         org propfont+30 ;Ш without spacing instead of Щ
  655.         db 0
  656.         org $+255
  657.         db 0x82
  658.         org $+255
  659.         db 0x92
  660.         org $+255
  661.         db 0x92
  662.         org $+255
  663.         db 0x92
  664.         org $+255
  665.         db 0x92
  666.         org $+255
  667.         db 0xfe
  668.         org $+255
  669.         db 0
  670.         org $+255
  671.         db 7
  672.  
  673.         org propfont+31 ;tail
  674.         db 0
  675.         org $+255
  676.         db 0
  677.         org $+255
  678.         db 0
  679.         org $+255
  680.         db 0
  681.         org $+255
  682.         db 0
  683.         org $+255
  684.         db 0
  685.         org $+255
  686.         db 0x80
  687.         org $+255
  688.         db 0x80
  689.         org $+255
  690.         db 1
  691.       endif
  692.  
  693.         savebin "gfxtest.com",begin,end-begin
  694.         LABELSLIST "../../../us/user.l",1
  695.