?login_element?

Subversion Repositories NedoOS

Rev

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

  1.        
  2. ;взять b=R/G/Bmin, hl установить на начало буфера R/G/B:
  3.         ;pop bc ;ld bc,(maxdistaxis) ;b=maxaxis
  4.         ;ld l,0xff&chrbuf
  5.         ;ld a,(Rminmax) ;Rmin
  6.         ;djnz $+2+2+3
  7.         ;ld l,0xff&(chrbuf+8)
  8.         ;ld a,(Gminmax) ;Gmin
  9.         ;djnz $+2+2+3
  10.         ;ld l,0xff&(chrbuf+16)
  11.         ;ld a,(Bminmax) ;Bmin
  12.         ;ld b,a ;b=R/G/Bmin
  13.         ;ld a,c ;c=maxdist
  14.         ;rra
  15.         ;rra
  16.         ; and 0x3f
  17.         ; add a,tmaxdistdiv/256
  18.         ;ld d,a ;d=maxdistdiv
  19.  
  20. ;потом выбираем лучшую ось:
  21.         ;ld de,(Bminmax)
  22.         ld a,d ;Bmax
  23.         sub e ;Bmin
  24.         ld c,a ;maxdist
  25.         ld b,2 ;maxaxis
  26.         pop de ;ld de,(Gminmax)
  27.         ld a,d ;Gmax
  28.         sub e ;Gmin
  29.         cp c ;>=maxdist?
  30.         ld hl,(Bminmaxcolor)
  31.         jr c,$+2+1+1
  32.          ld c,a ;maxdist
  33.          ;dec b ;maxaxis=1
  34.          ld hl,(Gminmaxcolor)
  35.         pop de ;ld de,(Rminmax)
  36.         ld a,d ;Rmax
  37.         sub e ;Rmin
  38.         cp c ;>=maxdist?
  39.         jr c,$+2+4;2
  40.          ;ld b,0 ;maxaxis
  41.          ld hl,(Rminmaxcolor)
  42.         ex de,hl
  43.  
  44. ;потом берём положение рекордных цветов:
  45.         ;pop de ;ld de,(Rminmaxcolor)
  46.         ;djnz $+2+4
  47.         ;ld de,(Gminmaxcolor)
  48.         ;djnz $+2+4
  49.         ;ld de,(Bminmaxcolor)
  50.  
  51.  
  52.         if 1==0
  53. ;0:03
  54. CNVTOGR
  55.         LD HL,#C000
  56.         LD BC,#7FFD
  57.         LD E,1
  58.         CALL SETPG
  59.        LD D,GRF/256 ;таблица brightness/contract/dithering level
  60.         LD A,(MAXV8)
  61.         LD B,A
  62. YSGOOP
  63.         PUSH BC
  64.         LD BC,(LSZX) ;<256?
  65.       ;LD A,C
  66.       ;DEC BC
  67.       ;INC B
  68.       ;LD C,B ;1..256 => 1, 257..512 => 2
  69.       ;LD B,A
  70. XSGOOP
  71.         LD E,(HL)
  72.         LD A,(DE)
  73.         LD (HL),A
  74.       ;INC HL
  75.       ;DJNZ XSGOOP
  76.       ;DEC C
  77.       ;JNZ XSGOOP
  78.        CPI
  79.        JP PE,XSGOOP
  80.         POP BC
  81.        ;hgt<256
  82.         DJNZ YSGOOP
  83.         RET
  84.  
  85.         endif
  86.  
  87.         if 1==0
  88. ;0:26
  89. CNVTORGB
  90.         LD HL,#C000
  91.         LD BC,#7FFD
  92.         LD DE,#7FDF
  93.         EXX
  94.         LD E,1
  95.         CALL SETPG
  96.         LD A,(MAXV8)
  97.         LD B,A
  98. YSLOOP
  99.         PUSH BC
  100.         LD BC,(LSZX)
  101. XSLOOP
  102.         PUSH BC
  103. ;once+ini
  104. ;/168900 CALLS
  105. ;20t=1s!!!
  106. ;SCONV
  107.         EXX
  108.         LD A,#1B
  109.         OUT (C),A
  110.         LD A,(HL)
  111.         LD (pCB+1),A
  112.         LD A,#1C
  113.         OUT (C),A
  114.         LD A,(HL)
  115.        EXA
  116.         LD A,#19
  117.         OUT (C),A
  118.         LD A,(HL)
  119.         LD (pY+1),A
  120.        EXA
  121.         EXX
  122.        LD L,A
  123.        LD H,'G716C
  124.        LD E,(HL)
  125.        INC H
  126.        LD D,(HL)
  127.       INC H
  128.        LD C,(HL)
  129.        INC H
  130.        LD B,(HL)
  131. pY      LD HL,PTAB
  132.       EX DE,HL
  133.        ADD HL,DE
  134.        LD A,(HL)
  135.       LD (RC+1),A
  136. pCB    LD HL,G7170
  137.       DEC H
  138.       LD A,(HL)
  139.       DEC H
  140.       LD L,(HL)
  141.       LD H,A
  142.        ADD HL,BC
  143.        ADD HL,DE
  144.        LD A,(HL)
  145.       LD (GC+1),A
  146.  
  147.       LD HL,(pCB+1)
  148.        LD C,(HL)
  149.        INC H
  150.        LD B,(HL)
  151.       EX DE,HL
  152.        ADD HL,BC
  153.        LD C,(HL)
  154.       LD B,'GRF
  155.        LD A,(BC)
  156.        LD (BCL+1),A
  157.        LD A,(RC+1)
  158.        LD C,A
  159.        LD A,(BC)
  160.        LD (RC+1),A
  161.        LD A,(GC+1)
  162.        LD C,A
  163.        LD A,(BC)
  164.        LD (GC+1),A
  165. ;считали все, а берем одну....
  166. pCLRS   LD A,(0)
  167.         EXX
  168.         LD (HL),A
  169.         INC HL
  170.         EXX
  171.         POP BC
  172.         DEC BC
  173.         LD A,B
  174.         OR C
  175.         JP NZ,XSLOOP
  176.         POP BC
  177.         DEC B ;hgt<256
  178.         JP NZ,YSLOOP
  179.         RET
  180.  
  181.         endif
  182.  
  183. RC      OR 0
  184. GC      OR 0
  185. BCL     OR 0
  186.  
  187.  
  188.  
  189. curbold=$+1
  190.         ld a,0
  191. curlink=$+1
  192.         or 0
  193.         ld hl,tfontweight
  194.         add a,l
  195.         ld l,a
  196.         adc a,h
  197.         sub l
  198.         ld h,a
  199.         ld a,(hl)
  200.         ld (prcharmc_attr),a
  201. curitalic=$+1
  202.         ld a,0
  203.         ld (prcharmc_italic1),a
  204.         ld (prcharmc_italic2),a
  205.         ld (prcharmc_italic3),a
  206.         ld (prcharmc_italic4),a
  207. curstroke=$+1
  208.         ld a,0
  209.         ld (prcharmc_stroke),a
  210. curunderline=$+1
  211.         ld a,0
  212.         ld (prcharmc_underline),a
  213.  
  214.        
  215.        
  216.  
  217.         if 1==0
  218.         ld de,pathbuf
  219.         push de
  220. getpath_patch=$+1
  221.         call getpath_file
  222.         pop de
  223.         ;DE = Filled in with whole path string (DRIVE:/PATH/ !!!)
  224.         ld h,d
  225.         ld l,e
  226.         call strcopy
  227.         dec de ;terminator
  228. browser_oldfilename=$+1
  229.         ld hl,emptyfilename
  230.         call strcopy
  231.         endif
  232.  
  233.         ;ld hl,curfulllink;linkbuf
  234.         ;ld de,COMMANDLINE
  235.         ;push de
  236.         ;call strcopy ;TODO убрать (сейчас только для отладки)
  237.         ;pop hl        
  238. ;command line = "<file to load>"
  239.  
  240.         if 1==0
  241.  
  242.          xor a
  243.          ld (washttpword),a
  244. ;если в имени файла стоит file://, то включить работу с файлами, если http://, то включить работу с http
  245.         push hl
  246.         ld de,tfileprotocol
  247.         call strcp_tillde0 ;if found, hl=after "//"
  248.         ld a,0
  249.         jr z,browser_go_changeprotocol
  250.         pop hl
  251.         push hl
  252.         ld de,thttpprotocol
  253.         call strcp_tillde0 ;if found, hl=after "//"
  254.         ld a,1
  255.         jr z,browser_go_changeprotocolhttp
  256.         pop hl
  257.         jr browser_go_nochangeprotocol
  258. browser_go_changeprotocolhttp
  259.          ld a,1
  260.          ld (washttpword),a        
  261. browser_go_changeprotocol
  262.         ld (browserprotocol),a
  263.         ;pop af ;skip old hl
  264.         ex (sp),hl ;push hl
  265.        
  266.         endif
  267.        
  268.  
  269.         if 1==0
  270. ;сменить текущий каталог (или http-каталог) в соответствии с каталогом в ссылке
  271.         push hl ;hl=начало path без протокола
  272. browser_go_findslash
  273.          push hl
  274.         call findlastslash.
  275.          pop hl
  276. ;de=after last slash or start
  277.          or a
  278.          sbc hl,de
  279.          add hl,de ;hl=начало path без протокола
  280.          jr nz,browser_go_slashfound
  281.          ;no slash in end
  282. browserprotocol=$+1
  283.         ld a,0 ;0=file, 1=http
  284. washttpword=$+1
  285.         ld a,0 ;1=was "http://"
  286.         or a
  287.         jr z,browser_go_slashfound
  288.          ;http => add slash after (as in http://nedopc.com)
  289.          push hl
  290.          xor a
  291.          ld b,-1
  292.          cpir
  293.          dec hl ;at terminator
  294.          ld (hl),'/'
  295.          inc hl
  296.          ld (hl),0
  297.          pop hl
  298.          jr browser_go_findslash
  299. browser_go_slashfound
  300.         ex de,hl ;hl=after last slash (filename)
  301.         pop de ;начало path без протокола
  302.         or a
  303.         sbc hl,de
  304.         add hl,de ;hl=filename, de=начало path без протокола, Z=(path len==0)
  305.         jr z,browsernopath
  306.         push hl ;filename
  307.         dec hl
  308.         ld (hl),0
  309. ;de=path
  310. chdir_patch=$+1
  311.         call chdir_file
  312.         pop hl ;hl=filename
  313. browsernopath
  314. ;hl=filename
  315.          ld (browser_oldfilename),hl
  316.          
  317.         endif
  318.          
  319.         if 1==0
  320. getpath_http
  321. ;de=buffer to get path
  322.         ld hl,httpcurdir ;server/path (without / in the end)
  323.         jp strcopy
  324.  
  325. rootdir_http
  326.         xor a
  327.         ld (httpcurdir),a ;server/path (without / in the end)
  328.         ret
  329.        
  330. chdir_http_dot
  331.         inc de ;skip dot
  332.         inc de ;skip another dot supposed
  333.         ld a,(de)
  334.         or a
  335.         jr z,$+3
  336.         inc de ;skip / supposed
  337. ;hl=end of curdir (slash or terminator)
  338. ;remove last element of curdir = move hl to previous slash or =httpcurdir:
  339.         ld a,'/'
  340.         dec hl
  341.         ld b,-1
  342.         cpdr
  343.         inc hl ;at slash (might be httpcurdir-1)
  344.         ld bc,httpcurdir
  345.         or a
  346.         sbc hl,bc
  347.         ;add hl,bc
  348.         ;jr nc,$+3 ;< httpcurdir?
  349.         ;inc hl ;if so, hl=httpcurdir
  350.          adc hl,bc ;if (hl<httpcurdir) hl=httpcurdir
  351.         ;jr chdir_http
  352.  
  353. chdir_http
  354. ;de=server/path (without / in the end)
  355.         ld hl,httpcurdir
  356.         xor a
  357.         ld b,-1
  358.         cpir
  359.         dec hl
  360. ;hl=end of curdir
  361.         ld a,(de)
  362.         cp '.'
  363.         jr z,chdir_http_dot
  364.         ld (hl),'/'
  365.         inc hl
  366.         ex de,hl
  367.         call strcopy ;TODO check overflow
  368.         ret
  369.         endif
  370.  
  371. ;httphostname=server name (filename before slash, not including slash)
  372. ;top of stack=filename (after ser.ver/)
  373.         ;jr $
  374.        
  375.         if 1==0
  376.          push de ;filename
  377. ;httphostname=server name (httpcurdir before slash), curdir=httpcurdir after slash:
  378.         ld hl,httpcurdir+1 ;server/path (without / in the end)
  379.         ld de,httphostname
  380.         push de
  381.          push hl
  382.         call strcopy
  383.          pop bc
  384.          or a
  385.          sbc hl,bc
  386.          ld b,h
  387.          ld c,l
  388.         pop hl ;httphostname
  389.         ld a,'/'
  390.         ;ld bc,128
  391.         cpir ;TODO ser.ver:port
  392.          jr z,openstream_http_slashfound
  393. ;if no slash
  394.          ld hl,httphostname
  395.          xor a
  396.          cpir
  397.          dec hl ;at terminator
  398.          dec a ;NZ
  399. openstream_http_slashfound
  400.         ld (openstream_http_curdir),hl
  401.         jr nz,$+2+1+2
  402.         dec hl
  403.         ld (hl),0 ;end of httphostname
  404.         endif
  405.        
  406.         if 1==0
  407. openstream_http_curdir=$+1
  408.         ld hl,0 ;httpcurdir+N
  409. ;if empty path, don't add second slash
  410.          ld a,(hl)
  411.          or a
  412.          jr z,openstream_http_emptypath
  413.         call strcopy
  414.         dec de
  415.         ld a,'/'
  416.         ld (de),a
  417.         inc de
  418. openstream_http_emptypath
  419.         endif
  420.  
  421. ;         ld b,50 ;10 OK for nedopc.com
  422. ;httpconnectwait0
  423. ;        push bc
  424. ;        YIELD
  425. ;        pop bc
  426. ;        djnz httpconnectwait0
  427.        
  428.  
  429.        
  430. ;store converted frame with timings:
  431. ;+0 (3) pnext
  432. ;+3 (2) time
  433. ;+5 converted frame
  434.  
  435.         if 1==0
  436. ;берём с экрана
  437.         ;call setpgtemp4000
  438.         ld hl,0xc000
  439.         ld bc,(curpichgt_visible)
  440. keepframelines0
  441.         push bc
  442.         push hl
  443.  
  444.         call setpgs_scr
  445.         ld de,LINEPIXELS;KEEPFRAMELINE
  446.        
  447. ;pixels
  448.         push hl
  449.         push de
  450.         xor a
  451.         call copylinefromscr
  452.         inc de
  453.         set 5,h
  454.         ld a,1
  455.         call copylinefromscr
  456.         pop de
  457.         ld hl,(keepframe_linesize)
  458.         add hl,de
  459.         ex de,hl
  460.         pop hl
  461. ;attr
  462.         res 6,h
  463.         xor a
  464.         call copylinefromscr
  465.         inc de
  466.         set 5,h
  467.         ld a,1
  468.         call copylinefromscr
  469.  
  470.         ld bc,(keepframe_linesize_bytes) ;size (pixels+attr)
  471.         push bc
  472.         ld de,LINEPIXELS;KEEPFRAMELINE
  473. keepframeaddr=$+1
  474.         ld hl,0
  475. keepframeaddrHSB=$+1
  476.         ld a,0
  477.         ;ld hl,(keepframeaddr)
  478.         ;ld a,(keepframeaddrHSB)
  479.         call puttomem
  480.         pop bc ;size
  481.         ld hl,(keepframeaddr)
  482.         ld a,(keepframeaddrHSB)
  483.         add hl,bc
  484.         adc a,0
  485.         ld (keepframeaddr),hl
  486.         ld (keepframeaddrHSB),a
  487.        
  488.         pop hl
  489.         ld bc,40
  490.         add hl,bc
  491.         pop bc
  492.         dec bc
  493.         ld a,b
  494.         or c
  495.         jr nz,keepframelines0
  496.         call setpgtemp8000
  497.         endif
  498.  
  499.         ld de,KEEPFRAMELINE
  500. ;pixels
  501.         push hl
  502.         push de
  503.         xor a
  504.         call copylinetoscr
  505.         inc de
  506.         set 5,h
  507.         ld a,1
  508.         call copylinetoscr
  509.         pop de
  510.         ld hl,(keepframe_linesize)
  511.         add hl,de
  512.         ex de,hl
  513.         pop hl
  514. ;attr
  515.         res 6,h
  516.         xor a
  517.         call copylinetoscr
  518.         inc de
  519.         set 5,h
  520.         ld a,1
  521.         call copylinetoscr
  522.  
  523.         if 1==0
  524. copylinetoscr
  525. ;hl=line (kept)
  526. ;de=buf
  527. ;a=нечётность (0=чётные, 1=нечётные столбцы)
  528.         push de
  529.         push hl
  530.         ex de,hl
  531.         call copyline_countsize
  532.         call copyline_countsize_ldirtoscr
  533.         ex de,hl
  534.         pop hl
  535.         pop de
  536.         ret
  537.  
  538. copylinefromscr
  539. ;hl=line (kept)
  540. ;de=buf
  541. ;a=нечётность (0=чётные, 1=нечётные столбцы)
  542.         push de
  543.         push hl
  544.         call copyline_countsize
  545.         call copyline_countsize_ldir
  546.         pop hl
  547.         pop de
  548.         ret
  549.  
  550. copyline_countsize
  551. keepframe_linesize=$+1
  552.         ld bc,0
  553.         or a
  554.         jr nz,$+3 ;нечётных столбцов меньше
  555.         inc bc
  556.         srl b
  557.         rr c
  558.         ret
  559. copyline_countsize_ldir
  560.         ld a,b
  561.         or c
  562.         ret z;jr z,$+4 ;for width=1
  563. copyline_countsize_ldir0
  564.         ldi
  565.         inc de
  566.         jp pe,copyline_countsize_ldir0
  567.         ret
  568. copyline_countsize_ldirtoscr
  569.         ld a,b
  570.         or c
  571.         ret z;jr z,$+4 ;for width=1
  572. copyline_countsize_ldirtoscr0
  573.         ldi
  574.         inc hl
  575.         jp pe,copyline_countsize_ldirtoscr0
  576.         ret
  577.         endif
  578.        
  579.         if 1==0
  580.        
  581.         push iy
  582. ;ищем адрес последнего байта картинки
  583.         ex de,hl
  584.         ld bc,0
  585.         scf
  586.         sbc hl,bc
  587.         ex de,hl
  588.         sbc hl,bc
  589. ;ищем номер страницы последнего байта картинки
  590.         ld a,l
  591.         rl d
  592.         rla
  593.         rl d
  594.         rla ;a=lastpg
  595.         inc a ;a=npages
  596.         ld b,a
  597. reserve_bmp_pages0
  598.         push bc
  599.         push hl
  600. reserve_bmp_pages_fail        
  601.         call reservepage
  602.         or a
  603.         jr nz,reserve_bmp_pages_fail ;repeat until success
  604.         pop hl
  605.         pop bc
  606.         djnz reserve_bmp_pages0
  607.         pop iy
  608.         ret
  609.        
  610.         endif
  611.  
  612.         if 1==0
  613. readchr
  614. ;b,g,r
  615. ;TODO с масштабированием и с учётом правого края картинки, не делящегося на 8
  616.         ;push bc
  617.         push af
  618.         push hl
  619.         ;call ahl_to_pgaddr ;set pages in 32K
  620.         rl h
  621.         rla
  622.         rl h
  623.         rla
  624.         srl h
  625.         scf
  626.         rr h
  627. ;a=page number in table (0..)
  628.         ld e,a
  629.         ld d,textpages/256
  630.         ld a,(de)
  631.         SETPG32KLOW
  632.         inc e
  633.         ld a,(de)
  634.         SETPG32KHIGH
  635.          call readchrlomem
  636.        
  637.         pop hl
  638.         pop af
  639.         if GIF_PIXELSIZE
  640.         ld bc,8
  641.         else
  642.         ld bc,24
  643.         endif
  644.         add hl,bc
  645.         ;pop bc
  646.         ret nc
  647.         inc a
  648.         ret
  649.         endif
  650.  
  651.         if 1==0
  652.         push bc
  653.         push de
  654.         push hl
  655.         ld hl,chrbuf
  656.         ld de,chrbuf+8
  657.         ld bc,16
  658.         ldir
  659.         pop hl
  660.         pop de
  661.         pop bc
  662.         endif
  663.  
  664. renderpng_pixels0
  665.         push bc
  666.         call readbyte
  667.         ex de,hl
  668.         ld (hl),c
  669.         inc hl
  670.         ex de,hl
  671.         call readbyte
  672.         ex de,hl
  673.         ld (hl),c
  674.         inc hl
  675.         ex de,hl
  676.         call readbyte
  677.         ex de,hl
  678.         ld (hl),c
  679.         inc hl
  680.         ex de,hl
  681.         call readbyte ;alpha
  682.         pop bc
  683.         dec hl
  684.         cpi
  685.         jp pe,renderpng_pixels0
  686.  
  687.        
  688.         ld a,(hl) ;R
  689.         inc hl
  690.         inc hl ;skip G
  691.         ldi ;B
  692.         inc de
  693.         ld (de),a ;R
  694.         inc de ;skip G
  695.