?login_element?

Subversion Repositories NedoOS

Rev

Blame | 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.         macro NEXTCOLUMN
  8.         bit 6,h
  9.         set 6,h
  10.         jr z,1f;shapes_linehorR_incxok
  11.         ld a,h
  12.         xor 0x60
  13.         ld h,a
  14.         and 0x20
  15.         jr nz,1f;shapes_linehorR_incxok
  16.         inc hl
  17. 1;shapes_linehorR_incxok
  18.         endm
  19.  
  20.         org PROGSTART
  21. begin
  22.         ld sp,STACK
  23.         OS_HIDEFROMPARENT
  24.  
  25.         ld e,0
  26.         OS_SETGFX ;e=0:EGA, e=2:MC, e=3:6912, e=6:text ;+SET FOCUS ;e=-1: disable gfx (out: e=old gfxmode)
  27.        
  28.         ld e,0 ;color byte 0bRLrrrlll
  29.         OS_CLS
  30.        
  31.         ld a,(user_scr0_low) ;ok
  32.         SETPG8000
  33.         ld a,(user_scr0_high) ;ok
  34.         SETPGC000
  35.        
  36. ;01          89          01    ;low+0x0000
  37. ;   23          ab          23 ;high+0x0000
  38. ;      45          cd          ;low+0x2000
  39. ;         67          ef       ;high+0x2000
  40.  
  41.         ;ld hl,0x8000
  42.         ;ld b,10
  43.         ;ld c,0xff        
  44. ;hl=scraddr
  45. ;c=color byte 0bRLrrrlll
  46. ;b=wid/2
  47.         ;call drawhorline
  48.         ;jr $
  49.        
  50.         ld l,1
  51.         ld e,10
  52.         ld hx,0b00111111 ;fill color byte 0bRLrrrlll
  53.         ld lx,0b00000000 ;11111111 ;brush color byte 0bRLrrrlll
  54.         ld b,100-1 ;hgt-1
  55.         ld c,159 ;wid/2
  56. ;l=x/2
  57. ;e=y
  58. ;lx=brush color byte 0bRLrrrlll
  59. ;hx=fill color byte 0bRLrrrlll
  60. ;b=hgt-1
  61. ;c=wid/2
  62.         call drawwindow
  63.  
  64.         ld hl,0x8000+(40*100)
  65.         ld e,0
  66. pr0
  67.         push hl
  68.         ld c,1;0 ;phase
  69.         ld d,32
  70. pr1
  71.         push de
  72.         ld a,e ;char
  73.         call prcharprop
  74.         pop de
  75.         inc e
  76.         dec d
  77.         jr nz,pr1
  78.         pop hl
  79.         ld bc,8*40
  80.         add hl,bc
  81.         inc e
  82.         dec e
  83.         jr nz,pr0
  84.        
  85.         jr $
  86.        
  87.         QUIT
  88.  
  89. xytoscraddr
  90. ;l=x/2
  91. ;e=y (╨╜╨╡ ╨┐╨╛╤А╤В╨╕╤В╤Б╤П)
  92. ;screen pages are mapped in 2 CPU windows
  93. ;addr = tY(y) + tX(x)
  94.         ld h,tx/256
  95.         ld d,ty/256
  96.         ld a,(de) ;(y*40)
  97.         add a,(hl) ;x div 4
  98.         ld (xytoscraddr_l),a
  99.         inc d
  100.         inc h
  101.         ld a,(de) ;'(y*40)
  102.         adc a,(hl) ;f(x mod 4)
  103.         ld h,a
  104. xytoscraddr_l=$+1
  105.         ld l,0
  106.         ret
  107.  
  108.         if 1==0
  109. prpixel
  110. ;bc=x (╨╜╨╡ ╨┐╨╛╤А╤В╨╕╤В╤Б╤П)
  111. ;e=y (╨╜╨╡ ╨┐╨╛╤А╤В╨╕╤В╤Б╤П)
  112. ;screen pages are mapped in 2 CPU windows
  113. ;addr = tY(y) + tX(x)
  114.         push bc
  115.         ld a,b
  116.         rra
  117.         ld a,c
  118.         rra
  119.         ld l,a
  120.         ;ld d,ty/256
  121.         ;ld h,tx/256
  122.         ld a,(de) ;(y*40)
  123.         jr c,prpixel_r
  124.         add a,(hl) ;x div 4
  125.         ld c,a
  126.         inc d
  127.         inc h
  128.         ld a,(de) ;'(y*40)
  129.         adc a,(hl) ;f(x mod 4)
  130.         ld b,a
  131.         ld a,(bc)
  132.         and 0xb8 ;keep right pixel ;╨╕╨╜╨░╤З╨╡ ╨╜╨░╨┤╨╛ cls ╨┐╨╡╤А╨╡╨┤ redraw
  133. prpixel_color_l=$+1
  134.         or 0;lx
  135.         ld (bc),a
  136.         dec h
  137.         dec d
  138.         pop bc
  139.         ret
  140. prpixel_r
  141.         add a,(hl) ;x div 4
  142.         ld c,a
  143.         inc d
  144.         inc h
  145.         ld a,(de) ;'(y*40)
  146.         adc a,(hl) ;f(x mod 4)
  147.         ld b,a
  148.         ld a,(bc)
  149.         and 0x47 ;keep left pixel ;╨╕╨╜╨░╤З╨╡ ╨╜╨░╨┤╨╛ cls ╨┐╨╡╤А╨╡╨┤ redraw
  150. prpixel_color_r=$+1
  151.         or 0;lx
  152.         ld (bc),a
  153.         dec h
  154.         dec d
  155.         pop bc
  156.         ret
  157.         endif
  158.  
  159. drawwindow
  160. ;l=x/2
  161. ;e=y
  162.         ld hy,e
  163.         ld a,l
  164.         ld ly,a
  165. ;ly=x/2
  166. ;hy=y
  167.         call xytoscraddr
  168. ;hl=screen addr
  169. ;lx=brush color byte 0bRLrrrlll
  170. ;hx=fill color byte 0bRLrrrlll
  171. ;b=hgt-1
  172. ;c=wid/2
  173.         push bc
  174.         push hl
  175.        
  176. drawwindowfill0
  177.         push bc
  178.         push hl
  179.         ld c,hx ;ld c,0b11111111 ;color byte 0bRLrrrlll
  180.         call drawverline
  181.         pop hl
  182.         NEXTCOLUMN
  183.         pop bc
  184.         dec c
  185.         jr nz,drawwindowfill0
  186.        
  187.         pop hl ;screen addr
  188.         pop bc
  189.  
  190.         push bc
  191.  
  192.         push bc
  193.         push hl
  194.         call drawbox
  195.         pop hl
  196.         pop bc
  197.         NEXTCOLUMN
  198.         ld de,40*2
  199.         add hl,de ;╨▓╤В╨╛╤А╨╛╨╣ ╨▒╨╛╨║╤Б ╨▓╨╜╤Г╤В╤А╨╕ ╨┐╨╡╤А╨▓╨╛╨│╨╛
  200.         dec c
  201.         dec c
  202.         ld a,b
  203.         sub 4
  204.         ld b,a
  205.         call drawbox
  206.        
  207.         pop bc ;b=hgt-1, c=wid/2
  208.        
  209. ;ly=x/2
  210. ;hy=y
  211.         ld e,hy
  212.         inc e
  213.         call drawwindowhormarks
  214.        
  215.         ld a,hy
  216.         add a,b ;+hgt-1
  217.         dec a
  218.         ld e,a
  219.         call drawwindowhormarks
  220.  
  221.         push bc
  222.         call drawwindowvermarks
  223.         pop bc
  224.         ld a,ly
  225.         add a,c ;wid/2
  226.         dec a
  227.         ld ly,a
  228.         call drawwindowvermarks
  229.        
  230.         ret
  231.        
  232. drawwindowvermarks
  233. ;ly=x/2
  234. ;hy=y
  235. ;b=hgt-1
  236. ;lx=color byte 0bRLrrrlll
  237.         ld a,ly
  238.         ld l,a
  239.         ld a,hy
  240.         add a,6
  241.         ld e,a
  242. ;l=x/2
  243. ;e=y
  244.         call xytoscraddr
  245.         ld a,lx
  246.         ld (hl),a
  247.         ld a,ly
  248.         ld l,a
  249.         ld a,hy
  250.         add a,b ;+hgt-1
  251.         sub 6
  252.         ld e,a
  253. ;l=x/2
  254. ;e=y        
  255.         call xytoscraddr
  256.         ld a,lx
  257.         ld (hl),a
  258.         ret
  259.  
  260.        
  261. drawwindowhormarks
  262. ;ly=x/2
  263. ;e=y
  264. ;c=wid/2
  265.         ld a,ly
  266.         add a,3
  267.         ld l,a
  268. ;l=x/2
  269. ;e=y
  270.         call xytoscraddr
  271.         ld a,lx
  272.         xor hx
  273.         and 0b01000111 ;color byte 0bRLrrrlll
  274.         xor hx
  275.         ld (hl),a
  276.  
  277.         ld a,ly
  278.         add a,c ;+wid/2
  279.         sub 3+1
  280.         ld l,a
  281. ;l=x/2
  282. ;e=y
  283.         call xytoscraddr
  284.         ld a,lx
  285.         xor hx
  286.         and 0b10111000 ;color byte 0bRLrrrlll
  287.         xor hx
  288.         ld (hl),a
  289.         ret
  290.        
  291.  
  292. drawbox
  293. ;hl=screen addr
  294. ;lx=color byte 0bRLrrrlll
  295. ;b=hgt-1
  296. ;c=wid/2
  297.         push bc
  298.         push hl
  299.         push bc
  300.         ld a,lx
  301.         xor hx
  302.         and 0b01000111 ;color byte 0bRLrrrlll
  303.         xor hx
  304.         ld c,a
  305.         call drawverline ;left line
  306.         pop bc
  307.         ld b,c ;wid/2
  308.         ex (sp),hl
  309.         ld c,lx ;ld c,0b11111111 ;color byte 0bRLrrrlll
  310.         push bc
  311.         call drawhorline ;top line
  312.         pop bc ;b=wid/2, c=color byte 0bRLrrrlll
  313.         ex (sp),hl ;bottom of left line
  314.         call drawhorline ;bottom line
  315.         pop hl ;rightmost byte of top line
  316.         ld de,40
  317.         add hl,de
  318.         pop bc
  319.         dec b ;b=hgt/2
  320.         ld a,lx
  321.         xor hx
  322.         and 0b10111000 ;color byte 0bRLrrrlll
  323.         xor hx
  324.         ld c,a
  325.         ;call drawverline ;right line
  326.         ;ret
  327. drawverline
  328. ;hl=scraddr
  329. ;c=color byte 0bRLrrrlll
  330. ;b=hgt
  331.         ld de,40
  332. drawverline0
  333.         ld (hl),c
  334.         add hl,de
  335.         djnz drawverline0
  336.         ret
  337.  
  338. drawhorline
  339. ;hl=scraddr
  340. ;c=color byte 0bRLrrrlll
  341. ;b=wid/2
  342.         ld de,0x4000
  343.         jr drawhorline0go
  344. drawhorline0
  345.         NEXTCOLUMN
  346. drawhorline0go
  347.         ld (hl),c
  348.         djnz drawhorline0
  349.         ret
  350.  
  351. prcharprop_shch
  352.         ;ld a,'Щ'
  353.         call prcharprop_do
  354.         ld a,255
  355.         jr prcharprop_do
  356. prcharprop
  357. ;Щ (Shch) doesn't fit in 8 bits + scroll
  358. ;print it as Ш (Sh) + tail
  359.         cp 'Щ'
  360.         jr z,prcharprop_shch
  361. prcharprop_do
  362. ;print with proportional font (any char width)
  363. ;hl=screen addr
  364. ;c=phase (even=left, odd=right pixel)
  365. ;a=char
  366.        push hl
  367.         ld l,a
  368.         ld h,propfont/256
  369.         ld de,chardata
  370. ;1. copy char data
  371. ;shift 1 pix right if needed
  372.         bit 0,c
  373.         jr z,prcharprop_copyfontnoscroll
  374.         dup 7
  375.         ld a,(hl)
  376.         rrca
  377.         ld (de),a
  378.         inc h
  379.         inc e
  380.         edup
  381.         ld a,(hl)
  382.         rrca
  383.         jp prcharprop_copyfontq
  384. prcharprop_copyfontnoscroll
  385.         dup 7
  386.         ld a,(hl)
  387.         ld (de),a
  388.         inc h
  389.         inc e
  390.         edup
  391.         ld a,(hl)
  392. prcharprop_copyfontq
  393.         ld (de),a
  394.         inc h
  395.         ld b,(hl) ;charwidth
  396.         ld a,c ;phase
  397.         add a,b
  398.         ld ly,a ;next phase = phase + charwidth
  399.         ld a,c ;phase
  400.         and 1 ;phase&1
  401.         inc a
  402.         add a,b ;charwidth
  403.         rra
  404.         ld hy,a ;number of 2 pixel columns = (charwidth + (phase&1) + 1)/2
  405.        pop hl
  406. ;hl=screen addr
  407. ;hy=number of 2 pixel columns = (charwidth + (phase&1) + 1)/2
  408. ;ly=next phase (even=left, odd=right pixel)
  409. ;2. print 2 pixel vertical line (scroll left bits 7,6 in char data)
  410.         ld bc,40
  411. prcharprop_columns0
  412.         push hl
  413.         ld de,chardata
  414.         dup 7
  415.         ex de,hl
  416.         ld a,(de)
  417.         rl (hl) ;CY=left pixel
  418.         jr nc,$+4
  419.         or 0x47 ;hx
  420.         rl (hl) ;CY=right pixel
  421.         jr nc,$+4
  422.         or 0xb8 ;lx
  423.         ld (de),a
  424.         ex de,hl
  425.         add hl,bc
  426.         inc e
  427.         edup
  428.         ex de,hl
  429.         ld a,(de)
  430.         rl (hl) ;CY=left pixel
  431.         jr nc,$+4
  432.         or 0x47 ;hx
  433.         rl (hl) ;CY=right pixel
  434.         jr nc,$+4
  435.         or 0xb8 ;lx
  436.         ld (de),a
  437. ;3. next column and loop
  438.         pop hl
  439.         ld d,h
  440.         ld e,l ;this will be next screen addr if the char ends in odd column ((ly&1) = 1)
  441.         bit 6,h
  442.         set 6,h
  443.         jr z,$+2+4+2+2+1
  444.          ld a,h
  445.          xor 0x60
  446.          ld h,a
  447.          and 0x20
  448.          jr nz,$+3
  449.          inc hl
  450.         dec hy
  451.         jp nz,prcharprop_columns0
  452.         ld c,ly
  453. ;c=next phase (even=left, odd=right pixel)
  454.         bit 0,c
  455.         ret z
  456.         ex de,hl ;old screen addr if the char ends in odd column ((ly&1) = 1)
  457. ;hl=next screen addr
  458.         ret
  459.  
  460.         align 8
  461. chardata
  462.         ds 8 ;any place for inc l
  463.  
  464.         align 256
  465. propfont
  466.         incbin "propfont.bin" ;0x800 font + 0x100 width
  467.  
  468.         align 256
  469. tx
  470.         dup 256
  471.         db ($&0xff)/4
  472.         edup
  473.         dup 64
  474.         db 0x80
  475.         db 0xc0
  476.         db 0xa0
  477.         db 0xe0
  478.         edup
  479. ty
  480.         dup 200
  481.         db 0xff&(($&0xff)*40)
  482.         edup
  483.         ds 56,0xff&8000
  484.         dup 200
  485.         db (($&0xff)*40)/256
  486.         edup
  487.         ds 56,8000/256
  488.  
  489. end
  490.  
  491. ;fix font
  492.         org propfont+'Щ' ;Ш without spacing instead of Щ
  493.         db 0
  494.         org $+255
  495.         db 0x82
  496.         org $+255
  497.         db 0x92
  498.         org $+255
  499.         db 0x92
  500.         org $+255
  501.         db 0x92
  502.         org $+255
  503.         db 0x92
  504.         org $+255
  505.         db 0xfe
  506.         org $+255
  507.         db 0
  508.         org $+255
  509.         db 7
  510.  
  511.         org propfont+255 ;tail
  512.         db 0
  513.         org $+255
  514.         db 0
  515.         org $+255
  516.         db 0
  517.         org $+255
  518.         db 0
  519.         org $+255
  520.         db 0
  521.         org $+255
  522.         db 0
  523.         org $+255
  524.         db 0x80
  525.         org $+255
  526.         db 0x80
  527.         org $+255
  528.         db 1
  529.  
  530.         savebin "gfxtest.com",begin,end-begin
  531.         LABELSLIST "../../../us/user.l",1
  532.