?login_element?

Subversion Repositories NedoOS

Rev

Rev 875 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.         DEVICE ZXSPECTRUM128
  2.         include "../_sdk/sys_h.asm"
  3.  
  4. WGETBUF=0x0800
  5. ;WGETBUFSZ=0x0400
  6. ;WGETBEGINADDR=WGETBUF+WGETBUFSZ
  7. ;WGETENDADDR=WGETBEGINADDR+2
  8.  
  9. end1=0x3500
  10.  
  11. DISKBUF=0x3500;0xb000
  12. DISKBUFsz=0x800;0x1000
  13.  
  14. LINEPIXELS=0x3d00 ;,wid8*2 (макс. размер = 512 для wid=2048) ;TODO раньше и поверх LINEGIF (чтобы pixels шли раньше, а attr затирал её в процессе конверсии)
  15.  
  16. SPOIL4B=0x4000 ;микростек на 4 байта, нельзя ниже 0x3b00 ;раньше было в невидимой части страницы экрана, но сейчас мы переключаем экран с этим стеком
  17. INTSTACK=0x3ffc
  18. STACK=0x3fc0
  19.  
  20. end2=0x7e00
  21.  
  22. depkbuf=0x7e00 ;32K+ for zip (match length of 3-258 bytes)
  23. buf64k=0
  24.  
  25. FREE=0x8000 ;динамическая память jpeg, буфер строки gif
  26. LINE1=0x9400 ;буфер строки 0x400*3? jpeg
  27. LINE1_sz=0x0c00
  28.  
  29.  
  30. COLOR=7
  31. STATUSCOLOR=0x38
  32.  
  33. GIF_PIXELSIZE=0
  34.  
  35. HTMLTOPY=0
  36. HTMLHGT=24
  37. SCROLLHGT=HTMLHGT*8;192;200
  38.  
  39. BACKGROUNDCOLORLEVEL=0 ;при очистке буфера строки (для правильного правого края в остатке знакоместа)
  40.  
  41. MAXLINKSZ=256+256-1-2 ;запас под терминатор и Yy
  42.  
  43. EDITLINEY=192
  44. EDITLINEMAXVISIBLEX=72
  45.  
  46. key_up_scroll=key_ssup ;=F7!
  47. key_down_scroll=key_ssdown ;=F6!
  48.  
  49.        MACRO rdbyte
  50.         INC LY
  51.         LD A,(IY)
  52.         CALL Z,RDBYH
  53.        ENDM
  54.  
  55.        MACRO ziprdbyte
  56.         INC LY
  57.         LD A,(IY)
  58.         CALL Z,ZIPRDBYH
  59.        ENDM
  60.  
  61. ;b=R/G/Bmin
  62. ;de на начале буфера R/G/B
  63. ;h=maxdistdiv
  64. ;в диферинге ходим только по одной составляющей, остальные не читаем:
  65.         macro DITHERMC1B ch0,ch1,ch2,ch3
  66.         ld a,(de) ;R(pixel)
  67.         inc e
  68.         sub b ;Rmin
  69.          rra ;maybe<0
  70.         ld l,a ;h=maxdistdiv
  71.         ld a,(hl) ;inklevel
  72.         cp ch0 ;chunklevel[x%4][y%4]
  73.         rl c ;bits
  74.         ld a,(de) ;R(pixel)
  75.         inc e
  76.         sub b ;Rmin
  77.          rra ;maybe<0
  78.         ld l,a ;h=maxdistdiv
  79.         ld a,(hl) ;inklevel
  80.         cp ch1 ;chunklevel[x%4][y%4]
  81.         rl c ;bits
  82.         ld a,(de) ;R(pixel)
  83.         inc e
  84.         sub b ;Rmin
  85.          rra ;maybe<0
  86.         ld l,a ;h=maxdistdiv
  87.         ld a,(hl) ;inklevel
  88.         cp ch2 ;chunklevel[x%4][y%4]
  89.         rl c ;bits
  90.         ld a,(de) ;R(pixel)
  91.         inc e
  92.         sub b ;Rmin
  93.          rra ;maybe<0
  94.         ld l,a ;h=maxdistdiv
  95.         ld a,(hl) ;inklevel
  96.         cp ch3 ;chunklevel[x%4][y%4]
  97.         rl c ;bits
  98.  
  99.         ld a,(de) ;R(pixel)
  100.         inc e
  101.         sub b ;Rmin
  102.          rra ;maybe<0
  103.         ld l,a ;h=maxdistdiv
  104.         ld a,(hl) ;inklevel
  105.         cp ch0 ;chunklevel[x%4][y%4]
  106.         rl c ;bits
  107.         ld a,(de) ;R(pixel)
  108.         inc e
  109.         sub b ;Rmin
  110.          rra ;maybe<0
  111.         ld l,a ;h=maxdistdiv
  112.         ld a,(hl) ;inklevel
  113.         cp ch1 ;chunklevel[x%4][y%4]
  114.         rl c ;bits
  115.         ld a,(de) ;R(pixel)
  116.         inc e
  117.         sub b ;Rmin
  118.          rra ;maybe<0
  119.         ld l,a ;h=maxdistdiv
  120.         ld a,(hl) ;inklevel
  121.         cp ch2 ;chunklevel[x%4][y%4]
  122.         rl c ;bits
  123.         ld a,(de) ;R(pixel)
  124.         inc e
  125.         sub b ;Rmin
  126.          rra ;maybe<0
  127.         ld l,a ;h=maxdistdiv
  128.         ld a,(hl) ;inklevel
  129.         cp ch3 ;chunklevel[x%4][y%4]
  130.         ld a,c
  131.         rla ;bits
  132.         exx
  133.         ld (de),a ;записать bits
  134.         ;exx
  135.         endm
  136.        
  137.         org PROGSTART
  138. cmd_begin
  139.         ld sp,STACK ;не должен опускаться ниже #3b00! иначе возможна порча OS
  140.         call init
  141.  
  142. ;curfulllink нужен для сохранения в истории и использования пути для относительных ссылок
  143. ;linkbuf содержит ссылку (может быть относительная)
  144.         if 1==0
  145.         call setpgs_scr
  146.         call setpgcode4000
  147.         ld de,0xc000;0x0801
  148.         call setxymc
  149.         ld de,curfulllink;COMMANDLINE
  150.         call prtextmc
  151.         call setpgtemp8000
  152.         endif
  153.  
  154.         ;call keepcurlink
  155.  
  156.         jp browser_go_curfulllink
  157.        
  158. browser_godownload
  159.         ld a,1
  160.         ld (downloadflag),a
  161. browser_go
  162. ;curfulllink содержит текущую ссылку (из неё брать путь), слеш в конце http://ser.ver уже есть
  163. ;в linkbuf лежит ссылка (может быть локальная)
  164. ;TODO перекодировать русские буквы в ссылке в %? только в набранной вручную?
  165.         ld hl,linkbuf
  166.         push hl
  167.         push hl
  168.         call strlen
  169.         inc hl
  170.         ;move block to end of buf:
  171.         pop de;ld de,linkbuf
  172.         ld b,h
  173.         ld c,l ;size
  174.         dec de ;linkbuf-1
  175.         add hl,de ;end of data
  176.         ld de,linkbuf+(MAXLINKSZ+1)-1
  177.         lddr
  178.         inc de ;begin of data
  179.         ex de,hl
  180.         pop de;ld de,linkbuf
  181. recodelinkamp0
  182.         ld a,(hl)
  183.         inc hl
  184.         ld (de),a
  185.         inc de
  186.         or a
  187.         jr z,recodelinkamp0q
  188.         cp '&'
  189.         jr nz,recodelinkamp0
  190.         ld a,(hl)
  191.         cp 'a'
  192.         jr nz,recodelinkamp0
  193.         inc hl
  194.         ld a,(hl)
  195.         cp 'm'
  196.         jr nz,recodelinkamp0dec1
  197.         inc hl
  198.         ld a,(hl)
  199.         cp 'p'
  200.         jr nz,recodelinkamp0dec2
  201.         inc hl
  202.         ld a,(hl)
  203.         cp ';'
  204.         inc hl
  205.         jr z,recodelinkamp0
  206.         dec hl
  207.         dec hl
  208. recodelinkamp0dec2
  209.         dec hl
  210. recodelinkamp0dec1
  211.         dec hl
  212.         jr recodelinkamp0
  213. recodelinkamp0q
  214.  
  215.         call keepcurlink
  216.  
  217.         call makefulllink
  218. ;curfulllink содержит полный url, собранный из старого curfullink и ссылки linkbuf
  219.  
  220.         if 1==0
  221.         call setpgs_scr
  222.         call setpgcode4000
  223.         ld de,0x0000
  224.         call setxymc
  225.         ld de,curfulllink;COMMANDLINE
  226.         call prtextmc
  227.         call setpgtemp8000
  228.         endif
  229.  
  230. browser_go_curfulllink
  231.  
  232.         jr browser_backspaceq
  233. keepcurlink
  234. ;для backspace: запомнить полный путь с протоколом и именем
  235. ;histaddr указывает на последний элемент истории
  236.         call setpghist
  237. histaddr=$+1
  238.         ld de,0xc000
  239.         ld a,d
  240.          cp -2 ;inc a
  241.         jr nz,keeptohist_nooverflow
  242.          ld hl,0xc100+256
  243.         ld de,0xc000
  244.          ld bc,0x3f00-256
  245.         ldir ;forget oldest link
  246. keeptohist_nooverflow
  247.         ld hl,curfulllink;linkbuf
  248.          ld bc,254+256
  249.         ldir
  250.         ld hl,html_curtopy
  251.         ld c,2
  252.         ldir
  253.         ld (histaddr),de
  254.         ld (html_curtopy),bc ;0
  255.         ret
  256.  
  257. remembercurlink
  258.         ld hl,(histaddr)
  259.         ld a,h
  260.         cp 0xc0
  261.         ret z ;jr z,browser_reload ;no history
  262.         dec h
  263.          dec h
  264.         ld (histaddr),hl
  265.         call setpghist
  266.         ld de,curfulllink;linkbuf
  267.          ld bc,256+254
  268.         ldir
  269.         ld de,html_curtopy
  270.         ldi
  271.         ldi
  272.         ret
  273.  
  274. browser_downloadthis
  275.         ld a,1
  276.         ld (downloadflag),a
  277. browser_reload
  278. ;histaddr указывает на последний элемент истории
  279.         ;ld hl,(histaddr)
  280.         ;call setpghist
  281.         ;ld de,curfulllink;linkbuf
  282.         ;call strcopy
  283.         jr browser_backspaceq
  284.  
  285. browser_backspace
  286. ;вспомнить старый путь с протоколом и именем, положить его в curfulllink
  287. ;сейчас histaddr указывает на последний элемент истории. идём назад и запомним новый указатель
  288.         call remembercurlink
  289.  
  290. browser_backspaceq
  291. ;curfulllink содержит полный url, собранный из старого curfullink и ссылки linkbuf        
  292.         ld sp,STACK ;не должен опускаться ниже #3b00! иначе возможна порча OS
  293.        
  294.         call unreservepages
  295.         xor a
  296.         ld h,a
  297.         ld l,a
  298.         ld (freemem_hl),hl
  299.         ld (freemem_a),a
  300.  
  301.         call cleanstatusline
  302.         call browser_editline_print
  303.          ;call setpgcode4000 ;само восстанавливается
  304.         call setpgtemp8000
  305.  
  306.          OS_GETTIMER ;hlde=timer
  307.          ld (timebegin),de
  308.  
  309.         ld hl,curfulllink
  310.         call isprotocolpresent
  311. ;a=protocol (0=file, 1=http, 2=gopher, 3=https), hl=after "//"
  312.         ld (curprotocol),a
  313.         push hl ;hl=after "//"
  314.  
  315. ;включить колбэки под нужный протокол
  316.         ld bc,readstream_file
  317.         ld de,closestream_file
  318.         ld hl,openstream_file
  319.          or a
  320.          jr z,browser_go_changeprotocol_nohttp
  321.         ld bc,readstream_http
  322.         ld de,closestream_http
  323.         ld hl,openstream_http
  324. browser_go_changeprotocol_nohttp
  325.         ld (openstream_patch),hl
  326.         ld (readstream_patch),bc
  327.         ld (closestream_patch),de
  328.        
  329.         pop hl
  330.  
  331. ;hl=начало path без протокола
  332. ;выкидываем #... (TODO сохранить и использовать для перехода на якорь)
  333.         push hl
  334.         call strlen_tobc_keephl
  335.         jr z,browser_open_skip
  336.         ld a,'#'
  337.         cpir
  338.         jr nz,browser_open_skip
  339.         dec hl
  340.         ld (hl),0
  341. browser_open_skip
  342.         pop hl
  343.  
  344.         ex de,hl ;de=filename
  345. openstream_patch=$+1
  346.         call openstream_file
  347.         or a
  348.         jp nz,LOADERROR
  349.  
  350.         xor a
  351. downloadflag=$+1
  352.         cp 0
  353.         ld (downloadflag),a
  354.         jp nz,downloadfile
  355.        
  356.         call initframes_time_scroll
  357.  
  358.        LD IY,DISKBUF+DISKBUFsz-1
  359.  
  360.         call RDBYTE
  361.         ;cp '<'
  362.         ;jp z,loadhtml
  363.          ;cp 0x0a ;speccy.info
  364.          ;jp z,loadhtml
  365.         cp 'G'
  366.         jp z,loadgif
  367.         cp 0x89
  368.         jp z,loadpng
  369.         cp 0xff
  370.         jp z,loadjpeg
  371.         cp 'B'
  372.         jr z,loadbmp
  373.          ld a,(DISKBUF+1)
  374.          cp '?' ;<?xml
  375.          ld a,(DISKBUF)
  376.          jp z,loadxml;svg ;надо искать !DOCTYPE HTML или svg
  377.         jp nz,loadhtml;loadbmp_fail
  378.         call RDBYTE
  379.         cp 'M'
  380.         jp nz,loadhtml;loadbmp_fail
  381. loadbmp
  382. ; I    1    0      2    Признак ВМР-файла - символы 'BM'       (+)
  383. ;      2    2      4    Размер ВМР-файла (байт)                (НАДО СФОРМИРОВАТЬ, ЧИТАТЬ НЕ НУЖНО)
  384. ;      3    6      4    Резерв (=0)                            (НАМ НЕ НУЖНО)
  385. ;      4   10      4    Смещение в байтах от начала файла до  
  386. ;                       начала описания растрового изображения (НАМ НЕ НУЖНО, у нас 118)
  387.                                                              
  388. ; II   5   14      4    Размер Описания Изображения (=40 WINDOWS) (НАМ НЕ НУЖНО, всегда 40 - в Linux больше!)
  389. ;      6   18      4    Ширина изображения (в пикселах)        (+)
  390. ;      7   22      4    Высота изображения (в пикселах)        (+)
  391. ;      8   26      2    Количество цветовых плоскостей (=1)    (НАМ НЕ НУЖНО, всегда 1)
  392. ;      9   28      2    Количество бит на пиксел               (+ 4, 8, 24 БИТ, ПОТОМ МОЖНО 1БИТ)
  393. ;     10   30      4    Вид сжатия информации (0,1 или 2)      (ПОКА ЧТО БЕЗ СЖАТИЯ)
  394. ;     11   34      4    Размер образа растрового изображения   (НАДО СФОРМИРОВАТЬ, ЧИТАТЬ НЕ НУЖНО)
  395. ;     12   38      4    Рекомендуемое горизон-ое разрешение    (НАМ НЕ НУЖНО)
  396. ;     13   42      4    Рекомендуемое вертикальное разрешение  (НАМ НЕ НУЖНО)
  397. ;     14   46      4    Количество цветов в палитре            (+)
  398. ;     15   50      4    Количество важных цветов в палитре     (НАМ НЕ НУЖНО)
  399.  
  400. ;дальше идёт палитра (B, G, R, 0)
  401.  
  402. ;дальше идёт картинка (длины строк в байтах кратны 4)
  403.  
  404.         ld b,18-2 -4+1
  405. ;loadbmp_skipheader0
  406. ;        call RDBYTE
  407. ;        djnz loadbmp_skipheader0
  408.         call read_b_bytes
  409.          call GETDWORD_slow
  410.          push de
  411.  
  412.         call GETDWORD_slow
  413.         ex de,hl ;hl=wid ;TODO защита
  414.         call setpicwid
  415.         call GETDWORD_slow
  416.         ;ld (curpichgt),de
  417.         ex de,hl ;TODO защита
  418.         call setpichgt
  419.        
  420.          pop hl
  421.          ld a,l
  422.          sub 12
  423.          ld b,a
  424.         ;ld b,54-26
  425.         call read_b_bytes
  426.        
  427.         ;ld de,0
  428.         ;ld hl,0 ;dehl=shift in file
  429.         ;ld a,(filehandle)
  430.         ;ld b,a
  431.         ;OS_SEEKHANDLE
  432.  
  433. ;TODO заказать блок памяти и грузить в него (можно грузить по одному байту, строчки конвертить по одной, тогда буфер bmp не нужен)
  434.        
  435.         call reservepage
  436.         ret nz ;no memory
  437.         ld hl,DISKBUF
  438.         ld de,0xc000
  439.         ld bc,DISKBUFsz
  440.         ldir ;beginning of file is already read
  441.         ld hl,0x4000-DISKBUFsz
  442.         jr nvview_loadbmp0go
  443.        
  444. nvview_loadbmp0
  445.         call reservepage
  446.         ret nz ;no memory
  447.  
  448.         ld de,0xc000
  449.         ld hl,0x4000
  450. nvview_loadbmp0go
  451. ;DE = Buffer address, HL = Number of bytes to read
  452.          push hl
  453.         call readstream
  454. ;HL = Number of bytes actually read
  455.         ld b,h
  456.         ld c,l
  457.          pop hl
  458.         xor a
  459.         sbc hl,bc ;NZ = bytes to read != bytes actually read
  460.         jr z,nvview_loadbmp0
  461.  
  462.         ld h,a
  463.         ld l,a ;0
  464.         ld a,(npages)
  465.         srl a
  466.         rr h
  467.         srl a
  468.         rr h
  469.         ld (freemem_hl),hl
  470.         ld (freemem_a),a ;костыль (TODO заказывать память под bmp нормально)
  471.  
  472.         call reservefirstframeaddr
  473.         call initframe ;один раз на картинку после setpicwid, setpichgt и после установки gifframetime ;заказывает память под конверченный кадр
  474. ;ahl=адрес памяти под конверченный кадр
  475.  
  476.         ld hl,54 ;TODO относительно начала bmp
  477.         xor a
  478. ;перейти на последнюю строчку (чтобы рисовать снизу вверх, нужно менять drawscreenline_frombuf):
  479.         if GIF_PIXELSIZE
  480.         ld de,(curpicwid)
  481.         else
  482.         ld de,(curpicwidx3)
  483.         endif
  484.         dec de
  485.         set 1,e
  486.         set 0,e
  487.         inc de ;округлили размер строки вверх до 4 байт: 0=>0, 1..3=>4, 4=>4...
  488.         ld (bmplinestep),de
  489.         ld bc,(curpichgt)
  490. bmpfindlastline0
  491.         add hl,de
  492.         adc a,0
  493.         dec hl
  494.         cpi
  495.         jp pe,bmpfindlastline0
  496.         ld (putchar_hl),hl
  497.         ld (putchar_a),a
  498.  
  499.         call setpgtemp8000
  500.  
  501.         ld bc,(curpichgt)
  502. fill0
  503.         push bc
  504.  
  505.         ld hl,(putchar_hl)
  506.         ld a,(putchar_a)
  507. bmplinestep=$+1
  508.         ld bc,0
  509.         or a
  510.         sbc hl,bc
  511.         sbc a,0
  512.         ld (putchar_hl),hl
  513.         ld (putchar_a),a        
  514.  
  515.         call islinevisible ;CY=invisible
  516.         jr c,bmpgetline_ifvisibleq
  517.         ld hl,(putchar_hl)
  518.         ld a,(putchar_a)
  519.         ld bc,(bmplinestep)
  520.         ld de,LINEGIF
  521.         call getfrommem
  522.         ld hl,LINEGIF
  523.         call drawscreenline_frombuf
  524.         call keepconvertedline ;запоминаем сконверченную строку из LINEPIXELS
  525. bmpgetline_ifvisibleq
  526.         call inccury
  527.  
  528.         pop bc
  529.         cpi
  530.         jp pe,fill0
  531.         jp showgif ;jp closequit
  532.  
  533. downloadfile
  534.         call reservepage
  535.         ret nz ;no memory
  536.  
  537.         ld de,downloadfilename ;TODO сгенерировать из урла или HTTP ответа + запросить редактирование
  538. ;de=filename
  539.         OS_CREATEHANDLE
  540. ;b=new file handle
  541.         ld a,b
  542.         ld (downloadfilehandle),a
  543.  
  544. downloadfile0
  545.         ld de,0xc000
  546.         ld hl,0x4000
  547. ;DE = Buffer address, HL = Number of bytes to read
  548.          push hl
  549.         call readstream
  550. ;HL = Number of bytes actually read, A=error
  551.  
  552.         push hl
  553.         ld de,0xc000
  554. downloadfilehandle=$+1
  555.         ld b,0
  556.         OS_WRITEHANDLE
  557.         pop hl
  558.  
  559.         ld b,h
  560.         ld c,l
  561.          pop hl
  562.         or a
  563.         sbc hl,bc ;NZ = bytes to read != bytes actually read
  564.         jr z,downloadfile0
  565.  
  566.         ld a,(downloadfilehandle)
  567.         ld b,a
  568.         OS_CLOSEHANDLE
  569.  
  570.         ld hl,downloadfilename
  571.         inc (hl) ;TODO ввод имени
  572.         jp closequit
  573.  
  574. DOCTYPEsz=9
  575. loadxml;svg
  576. ;надо искать !DOCTYPE HTML или svg
  577. ;a=first char
  578.          ld e,a
  579.         ld hl,DISKBUF
  580.         ld bc,DISKBUFsz-DOCTYPEsz
  581.         ld a,'!'
  582.         cpir ;костыль!
  583.         ld bc,DOCTYPEsz-1
  584.         add hl,bc
  585.         ld a,(hl)
  586.         or 0x20
  587.         cp 's'
  588.          ld a,e ;ld a,(iy) ;first char
  589.         jp nz,loadhtml
  590.  
  591.         push af
  592.         push iy
  593.         ld e,3 ;6912
  594.         OS_SETGFX
  595.          call setpgscr4000
  596.          call setpgtemp8000
  597.          call setpgsvgc000
  598.         LD      HL,#4000
  599.         LD      DE,#4001
  600.         LD      BC,#1800
  601.         LD      (HL),L
  602.         LDIR
  603.         LD      (HL),7
  604.         LD      BC,#2FF
  605.         LDIR
  606.         pop iy
  607.         pop af ;a=(iy)=first char
  608.         call readsvg
  609.          call setpgcode4000
  610. loadsvgq0
  611.         call yieldgetkeynolang ;z=nokey
  612.         jr z,loadsvgq0
  613.         cp key_enter
  614.         jr nz,loadsvgq0
  615.         ld e,2 ;MC hires mode
  616.         OS_SETGFX
  617.         ld e,0
  618.         OS_CLS
  619. loadsvgq1
  620.         call yieldgetkeynolang
  621.         call globalbuttons
  622.         ;jp browser_backspace
  623.         jr loadsvgq1
  624.         ;jr showgif
  625.  
  626. loadpng
  627.          call setpgtemp8000
  628.         call readpng
  629.         jr showgif
  630.  
  631. loadjpeg
  632.         ;call initframes_time_scroll
  633.         call readjpeg
  634.         jr showgif
  635.        
  636. loadgif
  637.         ;call initframes_time_scroll
  638.         call readgif
  639.  
  640. showgif
  641.         call showtime
  642.  
  643. showgif_firstframe
  644.         ;jr $
  645. nframes=$+1
  646.         ld bc,0 ;0 или 1 выключают управление
  647.         dec bc
  648.        
  649.         ld hl,(curpichgt_visible)
  650.         ld de,SCROLLHGT+1
  651.         or a
  652.         sbc hl,de
  653.         jr nc,showgif_drawevenifoneframe
  654.         ld hl,(keepframe_linesize)
  655.         ld de,80+1
  656.         or a
  657.         sbc hl,de
  658.         jr nc,showgif_drawevenifoneframe
  659.         dec bc
  660.         bit 7,b
  661.         inc bc
  662.         jp nz,closequit;showgifq ;если 0 или 1 кадр
  663. showgif_drawevenifoneframe
  664.  
  665. firstframeaddr=$+1
  666.         ld hl,0
  667. firstframeaddrHSB=$+1
  668.         ld a,0
  669. ;bc=число кадров-1
  670. showgif_frames0
  671.         push bc
  672.  
  673.         push hl
  674.         push af
  675.         OS_GETTIMER ;hlde=timer
  676.         pop af
  677.         ex de,hl
  678.         ex (sp),hl
  679.         call showframe ;читает showframetime из кадра
  680.  
  681.         pop de ;timer
  682.  
  683.         push af
  684.         push hl
  685.  
  686. showframetime=$+1
  687.         ld hl,0 ;in 1/100 s
  688.         inc hl
  689.         srl h
  690.         rr l
  691.         add hl,de ;max timer for this frame
  692.         ld (showframemaxtimer),hl
  693.  
  694. showframe_delay0
  695.         call yieldgetkeynolang ;z=nokey
  696.         ;cp key_enter
  697.         ;jp z,closequit ;TODO restore stack
  698.         ;cp 'z'
  699.         ;jr z,showframe_setzoom
  700.         call globalbuttons
  701.         ld hl,(xscroll)
  702.         cp key_left
  703.         jr z,showframe_left
  704.         cp key_right
  705.         jr z,showframe_right
  706.         ld hl,(yscroll)
  707.         cp key_down
  708.         jr z,showframe_down
  709.         cp key_up
  710.         jr z,showframe_up
  711. showframe_nokey
  712.         OS_GETTIMER ;hlde=timer
  713. showframemaxtimer=$+1
  714.         ld bc,0 ;max timer for this frame
  715.         ex de,hl
  716.         or a
  717.         sbc hl,bc
  718.         jp m,showframe_delay0 ;timer<maxtimer
  719.  
  720.         pop hl
  721.         pop af
  722.  
  723.         pop bc
  724.         dec bc
  725.         bit 7,b
  726.         jr z,showgif_frames0
  727.        
  728.         jp showgif_firstframe
  729.  
  730. showframe_setzoom
  731.         ld hl,setzoom_patch
  732.         ld a,(hl)
  733.         xor 0x80
  734.         ld (hl),a
  735.         jp browser_reload
  736.  
  737. ;TODO проблема, если задержка кадра слишком маленькая, успеем только один раз прочитать клавиши
  738.  
  739. showframe_left
  740. ;hl=xscroll
  741.         dec hl
  742.         res 0,l
  743.         bit 7,h
  744.         jr nz,showframe_nokey
  745.         jr showframe_leftrightq
  746.  
  747. showframe_right
  748. ;hl=xscroll
  749. ;не двигаем xscroll, если правая граница (=keepframe_linesize-xscroll) получается <80
  750.         inc hl
  751.         inc hl
  752.         ex de,hl
  753.         ld hl,(keepframe_linesize)
  754.         or a
  755.         sbc hl,de
  756.         ld bc,80
  757.         or a
  758.         sbc hl,bc
  759.         ex de,hl
  760.         jr nc,showframe_leftrightq
  761. ;предел скролла: xscroll=keepframe_linesize-80 >=0
  762.          ld hl,(keepframe_linesize)
  763.          or a
  764.          sbc hl,bc
  765.         jr c,showframe_nokey
  766. showframe_leftrightq
  767.         ld (xscroll),hl
  768.         jr showframe_nokey
  769.  
  770. showframe_up
  771. ;hl=yscroll
  772.         ld bc,8
  773.         xor a
  774.         sbc hl,bc
  775.         jr nc,showframe_updownq
  776.         ld h,a
  777.         ld l,a
  778.         jr showframe_updownq
  779.  
  780. showframe_down
  781. ;hl=yscroll
  782. ;не двигаем yscroll, если нижняя граница (=curpichgt_visible-yscroll) получается <SCROLLHGT(200)
  783.         ld bc,8
  784.         add hl,bc
  785.         ex de,hl
  786.         ld hl,(curpichgt_visible)
  787.         or a
  788.         sbc hl,de
  789.         ld bc,SCROLLHGT;200
  790.         or a
  791.         sbc hl,bc
  792.         ex de,hl
  793.         jr nc,showframe_updownq
  794. ;предел скролла: yscroll=curpichgt_visible-SCROLLHGT >=0
  795.          ld hl,(curpichgt_visible)
  796.          or a
  797.          sbc hl,bc
  798.         jr c,showframe_nokey
  799. showframe_updownq
  800.         ld (yscroll),hl
  801.         jr showframe_nokey
  802.  
  803. loadbmp_fail
  804. closequit
  805.         call closestream
  806.          jr getkeyquit
  807.  
  808. LOADERROR
  809.         call closestream
  810.         ld de,tloaderr
  811.         jr TYPE_ERROR
  812. CONNECTIONERROR
  813.         ld de,tconnerr
  814. TYPE_ERROR
  815.         push de
  816.         call setpgs_scr
  817.         call setpgcode4000
  818.         ld a,STATUSCOLOR
  819.         call initprcharmc
  820.         ld de,0xc048
  821.         call setxymc
  822.         pop de
  823.         call prtextmc
  824.  
  825. ERROR ;for jpeg
  826. ERROR2
  827. ERROR4
  828. getkeyquit
  829. getkeyquit0
  830.         ;YIELD ;halt ;если сделать просто di:rst #38, то 1.сдвинем таймер и 2.можем потерять кадровое прерывание, а если без ei, то будут глюки
  831.         ;GET_KEY ;OS_GETKEYNOLANG
  832.         ;ld a,c ;keynolang
  833.         call yieldgetkeynolang
  834.         call globalbuttons
  835.         jr getkeyquit0
  836.        
  837. globalbuttons
  838.         cp key_backspace
  839.         jp z,browser_backspace
  840.         cp '5'
  841.         jp z,browser_reload
  842.         cp 'z'
  843.         jp z,showframe_setzoom
  844.         cp 's'
  845.         jp z,browser_downloadthis
  846.         cp 'e'
  847.         jp z,browser_editline
  848.         cp key_esc
  849.         ret nz
  850. browser_quit
  851.         ld a,(wgetloaded_pid)
  852.         or a
  853.         jr z,browser_quitq
  854.  
  855. ;TODO проверить, что wget жив:
  856.         ld e,a
  857.         OS_CHECKPID
  858.         or a
  859.         jr z,browser_quitq ;dead
  860.  
  861.         ld a,(wgetmainpg)
  862.         SETPG32KHIGH
  863.         ld a,0xff
  864.         ld (0xc000+COMMANDLINE+2),a
  865. browser_quitq
  866.         QUIT
  867.  
  868. oraret
  869.         or a
  870.         ret
  871. yieldgetkeynolang
  872. ;out: z=no key, no action
  873.         YIELD ;halt ;если сделать просто di:rst 0x38, то 1.сдвинем таймер и 2.можем потерять кадровое прерывание, а если без ei, то будут глюки
  874.         GET_KEY
  875.         ld lx,a ;keylang
  876.         jr nz,oraret ;no focus (a=0, nz) => ret with Z
  877.         ;jr z,yieldgetkeynolang_focus
  878.         ;;ld de,(control_imer_oldmousecoords) ;no focus
  879.         ;xor a
  880.         ;ret
  881. ;yieldgetkeynolang_focus
  882.          cp key_redraw ;!=0
  883.          jr z,oraret ;a!=0 => ret with NZ ;эту кнопку нельзя подменять, иначе экран не перерисуется (NZ!)
  884. ;hl=(sysmousebuttons)
  885.         ld a,l
  886.         and 0xf0
  887. control_imer_oldmousewheel=$+2
  888.         ld hx,0
  889.         ld (control_imer_oldmousewheel),a
  890.         sub hx
  891.         ld (mouse_scrollvalue),a
  892.         jr z,yieldgetkeynolang_key
  893.         ;jp p,yieldgetkeynolang_scrollup
  894.         ;neg
  895.         ;ld (mouse_scrollvalue),a        
  896.         ld a,key_down_scroll
  897.         ret p;m ;nz        
  898. ;yieldgetkeynolang_scrollup
  899.         ld a,key_up_scroll
  900.         ret ;nz
  901. yieldgetkeynolang_key
  902.         ld a,0
  903.         ld (mouse_scrollvalue),a ;default scrollvalue
  904.         ld a,l
  905.         cpl
  906.         ld l,a
  907.         bit 0,l ;LMB
  908.         ld a,key_enter
  909.         ret nz
  910.         bit 1,l ;RMB
  911.         ld a,key_backspace
  912.         ret nz
  913.         ld a,lx ;keylang
  914.         or a ;cp NOKEY ;keylang==0?
  915.         ret nz ;jr nz,$+3
  916.         cp c ;keynolang==0?
  917.         ret nz
  918. ;no action? mouse coords change is also an action
  919.         push bc
  920. control_imer_oldmousecoords=$+1
  921.         ld bc,0
  922.         ld (control_imer_oldmousecoords),de
  923.         ld a,b
  924.         sub d
  925.         ld d,a
  926.         ld a,e
  927.         sub c
  928.         ld e,a
  929.         ld (control_imer_mousecoordsdelta),de
  930.         ld a,d
  931.         or e
  932.         ld a,0
  933.         pop bc
  934.         ret ;z/nz
  935.  
  936. closestream
  937. closestream_patch=$+1
  938.         jp closestream_file
  939.        
  940. tconnerr
  941.         db "conn.err",0
  942. tloaderr
  943.         db "load err",0
  944.  
  945. showtime
  946.          call setpgcode4000
  947.         ld a,STATUSCOLOR
  948.         call initprcharmc
  949.  
  950.          OS_GETTIMER ;hlde=timer
  951.          ex de,hl
  952. timebegin=$+1
  953.          ld de,0
  954.          or a
  955.          sbc hl,de
  956.          ld de,0xc04a
  957. ;d=y, e=x8
  958. ;hl=time (frames)
  959.          jp prnumfrac
  960.  
  961. showmem
  962.         ld a,(npages)
  963. npages_old=$+1
  964.         cp -1
  965.         ret z
  966.         ld (npages_old),a
  967.         ld l,a
  968.         ld h,0
  969.         push hl
  970.          call setpgcode4000
  971.         ld a,STATUSCOLOR
  972.         call initprcharmc
  973.         pop hl
  974.          ld de,0xc046
  975.         jp prnum123
  976.  
  977. cleanstatusline
  978.         call setpgs_scr
  979.         call setpgcode4000
  980.         xor a
  981.         ld (browser_editline_scroll),a
  982.         ld hl,EDITLINEY*256+(40*192)
  983.         ld a,STATUSCOLOR
  984.         call cleanlinemc
  985.         ;ld a,STATUSCOLOR
  986.         jp initprcharmc
  987.  
  988. ;hl = poi to filename in string
  989. ;out: de = after last slash
  990. findlastslash.
  991. nfopenfnslash.
  992.         ld d,h
  993.         ld e,l ;de = after last slash
  994. nfopenfnslash0.
  995.         ld a,[hl]
  996.         inc hl
  997.         or a
  998.         ret z
  999.         cp '/'
  1000.         jr nz,nfopenfnslash0.
  1001.         jr nfopenfnslash.
  1002.  
  1003. strcopy
  1004. ;hl->de
  1005. ;out: hl,de after terminator
  1006.         xor a
  1007. strcopy0
  1008.         cp (hl)
  1009.         ldi
  1010.         jr nz,strcopy0
  1011.         ret
  1012.  
  1013. makefulllink
  1014. ;curfulllink = curfulllink+linkbuf
  1015.         ld hl,linkbuf
  1016. ;если ссылка начинается со слеша, то надо отрезать весь путь, кроме сервера
  1017.         ld a,(hl)
  1018.         cp '/'
  1019.         jr z,browser_go_rootlink ;"/Timex"
  1020.  
  1021.         call isprotocolpresent
  1022. ;nz=protocol absent (hl=link), z=protocol present (a=protocol (0=file, 1=http), hl=after "//")
  1023.         jr z,browser_go_protocolpresent ;протокол есть - linkbuf содержит полную ссылку (к ней только добавить / в случае http://ser.ver)
  1024.         ld a,(linkbuf+1)
  1025.         sub ':'
  1026.         jr z,browser_go_defaultprotocolpresent ;1:/file... => file://1:/file...
  1027. ;нет протокола - взять текущий путь из curfulllink (т.е. отрезать всё после последнего слеша) и приклеить к нему эту ссылку (с учётом ../)
  1028. ;слеш в конце http://ser.ver уже есть? не всегда! если ввели вручную, то нет
  1029.         ld hl,curfulllink
  1030.         call isprotocolpresent
  1031. ;a=protocol (0=file, 1=http), hl=after "//"
  1032.          push hl
  1033.         call findlastslash. ;out: de = after last slash or beginning
  1034.          pop hl
  1035.          or a
  1036.          sbc hl,de
  1037.          jr nz,browser_go_noaddslashafterserver
  1038.          add hl,de
  1039.          push hl ;after "//"
  1040.          call addslashafterserver
  1041.          pop hl
  1042.          call findlastslash. ;out: de = after last slash
  1043. browser_go_noaddslashafterserver
  1044. ;de=curfulllink+...=end of curdir (after slash)
  1045.         ld hl,linkbuf
  1046. browser_go_chdir
  1047.         ld a,'.'
  1048.         cp (hl)
  1049.         jr nz,browser_go_chdirq
  1050.         inc hl ;skip dot
  1051.          ld a,(hl)
  1052.          cp '/'
  1053.         inc hl ;if nz,skip another dot supposed
  1054.          jr z,browser_go_dotslash
  1055.         ld a,(hl)
  1056.         or a
  1057.         jr z,$+3
  1058.         inc hl ;skip / supposed
  1059. ;hl=linkbuf+... (path/file without ../)
  1060. ;de=curfulllink+...=end of curdir (after slash)
  1061. ;remove last element of curdir = move de to previous slash
  1062.         dec de ;at slash
  1063.         dec de
  1064.         ld a,(de)
  1065.         inc de
  1066.         inc de ;after slash
  1067.         cp '/' ;is it "//"?
  1068.         jr z,browser_go_chdir_error
  1069.         dec de ;at slash
  1070.         ex de,hl ;hl=at slash
  1071.         dec hl
  1072.         ld a,'/'
  1073.         ld b,-1
  1074.         cpdr
  1075.         inc hl ;at previous slash (might be last slash of "//")
  1076.         inc hl ;after slash
  1077.         ex de,hl ;de=curfulllink+...=end of curdir (after slash)
  1078.          jr browser_go_chdir
  1079. browser_go_chdir_error
  1080. browser_go_chdirq
  1081. ;hl=linkbuf+... (path/file without ../)
  1082. ;de=curfulllink+...=end of curdir (after slash)
  1083.         call strcopy
  1084.         jr browser_go_protocolpresentq
  1085. browser_go_defaultprotocolpresent
  1086. ;1:/file... => file://1:/file...
  1087. ;a=0
  1088.         call adddefaultprotocol
  1089.         jr browser_go_protocolpresentq
  1090. browser_go_dotslash=browser_go_chdir ;"./Timex"
  1091.  
  1092. browser_go_rootlink
  1093. ;"/Timex"
  1094. ;hl=linkbuf+... at slash
  1095. ;если ссылка начинается с //, то надо отрезать весь путь, кроме протокола
  1096.          inc hl
  1097.          ld a,(hl)
  1098.          cp '/'
  1099.          jr z,browser_go_rootprotocol
  1100.          dec hl
  1101.          push hl
  1102.         ld hl,curfulllink
  1103.         call isprotocolpresent
  1104. ;a=protocol (0=file, 1=http), hl=after "//"
  1105.         call findslash
  1106.         dec hl ;at slash
  1107.         ex de,hl ;de=curfulllink+ after server (at slash)
  1108.          pop hl
  1109.         jr browser_go_copyto;linkbuf
  1110.  
  1111. browser_go_protocolpresent
  1112. ;a=protocol (0=file, 1=http), hl=after "//"
  1113.         call addslashafterserver ;add / after http://ser.ver
  1114.         ld de,curfulllink
  1115. ;browser_go_copytolinkbuf
  1116.         ld hl,linkbuf
  1117. browser_go_copyto
  1118.         call strcopy
  1119. browser_go_protocolpresentq
  1120. ;curfulllink содержит полный url, собранный из старого curfullink и ссылки linkbuf
  1121.         ret
  1122.  
  1123. browser_go_rootprotocol
  1124.         inc hl
  1125. ;hl=linkbuf+... after "//"
  1126.          push hl
  1127.         ld hl,curfulllink
  1128.         call isprotocolpresent
  1129. ;a=protocol (0=file, 1=http), hl=after "//"
  1130.         ex de,hl ;de=curfulllink+ after protocol://
  1131.          pop hl
  1132.         jr browser_go_copyto;linkbuf
  1133.  
  1134. adddefaultprotocol
  1135. ;1:/file... => file://1:/file...
  1136. ;ser.ver... => http://ser.ver...
  1137. ;a=protocol (0=file, 1=http)
  1138.         push af ;a=protocol (0=file, 1=http)
  1139.         or a
  1140.         ld hl,tfileprotocol
  1141.         jr z,$+5
  1142.          ld hl,thttpprotocol
  1143.         ld de,curfulllink
  1144.         call strcopy
  1145.         dec de
  1146.         push de
  1147.         ld hl,linkbuf
  1148.         call strcopy        
  1149.         pop hl
  1150.         pop af ;a=protocol (0=file, 1=http)
  1151.         ret
  1152.  
  1153. addslashafterserver
  1154. ;add / after http://ser.ver
  1155. ;hl=after "//"
  1156.         call findslash
  1157.         ret z ;слеш уже есть
  1158.          ld (hl),c;0
  1159.          dec hl
  1160.          ld (hl),a ;add / after http://ser.ver
  1161.         ret
  1162.  
  1163. findslash
  1164.         call strlen_tobc_keephl ;out: bc=len (Z: len==0)
  1165.          ret z
  1166.         ld a,'/'
  1167.         cpir
  1168.         ret
  1169.  
  1170. strlen_tobc_keephl
  1171. ;hl=string
  1172. ;out: bc=len (Z: len==0)
  1173.         push hl
  1174.         xor a
  1175.         ld b,-1
  1176.         cpir
  1177.         pop de
  1178.         sbc hl,de
  1179.         ld b,h
  1180.         ld c,l ;bc=strlen
  1181.         ex de,hl ;hl=string
  1182.         ret
  1183.  
  1184. isprotocolpresent
  1185. ;hl=link string
  1186. ;out: nz=protocol absent (hl=link), z=protocol present (a=protocol (0=file, 1=http), hl=after "//")
  1187.         ld de,tfileprotocol
  1188.         push hl
  1189.         call strcp_tillde0 ;if found, hl=after "//"
  1190.         pop de
  1191.         ld a,0
  1192.         ret z
  1193.         ex de,hl
  1194.         ld de,thttpprotocol
  1195.         push hl
  1196.         call strcp_tillde0 ;if found, hl=after "//"
  1197.         pop de
  1198.         ld a,1
  1199.         ret z
  1200.         ex de,hl
  1201.         ld de,tgopherprotocol
  1202.         push hl
  1203.         call strcp_tillde0 ;if found, hl=after "//"
  1204.         pop de
  1205.         ld a,2
  1206.         ret z
  1207.         ex de,hl
  1208.         ld de,thttpsprotocol
  1209.         push hl
  1210.         call strcp_tillde0 ;if found, hl=after "//"
  1211.         pop de
  1212.         ld a,3
  1213.         ret z
  1214.         ex de,hl
  1215.         ret ;nz=protocol absent (hl=start)
  1216.  
  1217. nextscreenline
  1218. ;out: de=старая строка, nc=out of screen
  1219. drawscreenline_frombuf_scr=$+1
  1220.         ld de,0
  1221.         ld hl,40
  1222.         add hl,de ;next line on screen
  1223.          ;push bc
  1224.          ld bc,40*(SCROLLHGT+1)+0x4000
  1225.          or a
  1226.          sbc hl,bc
  1227.          add hl,bc
  1228.          ;pop bc
  1229.          ret nc
  1230.         ;bit 5,h
  1231.         ;ret nz ;jr nz,drawscreenline_frombufq ;end of screen, current line doesn't fit
  1232.         ld (drawscreenline_frombuf_scr),hl
  1233.         ret
  1234.  
  1235. drawscreenline_frombuf
  1236. ;hl=from
  1237.         exx
  1238.         call nextscreenline
  1239.         ;exx
  1240.         ;ret nc ;end of screen, current line doesn't fit
  1241.  
  1242.         push ix
  1243.         push iy
  1244.        
  1245. drawscreenline_frombuf_ixaddr=$+2
  1246.         ld ix,(dithermcy0-2)
  1247. drawscreenline_frombuf_iyaddr=$+2
  1248.         ld iy,(colorlace0-2)
  1249.  
  1250.         ;exx
  1251.         push af ;nc=out of screen
  1252.         push de ;screen
  1253.         ld de,LINEPIXELS;-0x4000
  1254.         ld hl,(keepframe_linesize)
  1255.         ld b,h
  1256.         ld c,l
  1257.         add hl,de
  1258.         exx
  1259.          call setpgdiv4000
  1260.          call setpgtemp8000 ;такой нам дали адрес        
  1261.         jr drawscreenline_frombuf0go
  1262. drawscreenline_frombuf0
  1263.         exx
  1264.         pop hl
  1265. drawscreenline_frombuf0go
  1266. readchr_patch=$+1
  1267.         call readchrlomem
  1268.         push hl
  1269.         call convertchr ;jp=1980t (не делает exx в конце, для удобства)
  1270.         inc de
  1271.         cpi ;делает inc hl
  1272.         jp pe,drawscreenline_frombuf0
  1273.         pop af
  1274.  
  1275.         dec ix
  1276.         dec ix
  1277.         ld (drawscreenline_frombuf_ixaddr),ix
  1278.         dec iy
  1279.         dec iy
  1280.         ld (drawscreenline_frombuf_iyaddr),iy
  1281.  
  1282.          ;call setpgs_scr
  1283.         exx
  1284.         pop bc ;screen
  1285.         pop af ;nc=out of screen
  1286.         ld hl,LINEPIXELS;-0x4000
  1287. ;hl=data
  1288. ;bc=screen=0xc000+
  1289.         call c,prlinefast
  1290.  
  1291.          call setpgtemp8000
  1292.          call setpgcode4000
  1293.  
  1294.         pop iy
  1295.         pop ix
  1296.         ret;jp setpgtemp8000
  1297.  
  1298. read_b_bytes
  1299. read_b_bytes0
  1300.         call RDBYTE
  1301.         djnz read_b_bytes0
  1302.         ret
  1303.  
  1304. RDBYTE
  1305.         INC LY
  1306.         LD A,(IY)
  1307.         RET NZ
  1308. RDBYH
  1309. ;TODO проверка конца файла и возврат a=0, флаг CY=1?
  1310.         INC HY
  1311.         LD A,HY
  1312.         CP DISKBUF/256+(DISKBUFsz/256)
  1313.         LD A,(IY)
  1314.          ccf ;CY=0: OK
  1315.         RET nz
  1316.        PUSH HL
  1317.        PUSH DE
  1318.         PUSH BC
  1319.         push IX
  1320.        CALL rdCS
  1321.        ex af,af'
  1322.       PUSH AF
  1323.        exx
  1324.        push bc
  1325.        push de
  1326.        push hl
  1327.        ld de,DISKBUF
  1328.        ld hl,DISKBUFsz
  1329.        call readstream
  1330. ;hl=actual size (TODO if 0 then exit? сейчас конец последнего блока и пустого блока забивается нулями, нужно для html)
  1331. ;fill the rest of buffer with zeros
  1332.        ld de,DISKBUF
  1333.        add hl,de
  1334.        ex de,hl ;de=start of zeros
  1335.        ld hl,DISKBUF+DISKBUFsz
  1336.        xor a
  1337.        sbc hl,de
  1338.        ld b,h
  1339.        ld c,l ;bc=length of zeros (Z=no zeros)
  1340.        jr z,readdiskbuf_nozeros
  1341.        ld h,d
  1342.        ld l,e ;start of zeros
  1343.        ld (hl),a;0
  1344.        inc de
  1345.        dec bc
  1346.        ld a,b
  1347.        or c
  1348.        jr z,readdiskbuf_nozeros
  1349.        ldir
  1350. readdiskbuf_nozeros
  1351.        pop hl
  1352.        pop de
  1353.        pop bc
  1354.        exx
  1355.       POP AF
  1356.       ex af,af'
  1357.         POP IX
  1358.         pop BC
  1359.        POP DE
  1360.          pop hl
  1361.        ld iy,DISKBUF
  1362.        LD A,(IY)
  1363.        or a ;CY=0: OK
  1364.         RET
  1365.  
  1366. ZIPRDBYH
  1367. ;TODO читать столько, сколько осталось в IDAT (если это не больше DISKBUFsz), потом искать следующий IDAT
  1368.         INC HY
  1369.         LD A,HY
  1370.         CP DISKBUF/256+(DISKBUFsz/256)
  1371.         LD A,(IY)
  1372.          ccf ;CY=0: OK
  1373.         RET nz
  1374.  
  1375.        PUSH HL
  1376.        PUSH DE
  1377.         PUSH BC
  1378.         push IX
  1379.        ;CALL rdCS
  1380.        ex af,af'
  1381.       PUSH AF
  1382.        exx
  1383.        push bc
  1384.        push de
  1385.        push hl
  1386.  
  1387. pngIDATremainedHSW=$+1
  1388.        ld de,0
  1389. pngIDATremained=$+1
  1390.        ld hl,0
  1391. ZIPRDBYH0read
  1392.        ld a,d
  1393.        or e
  1394.        ld bc,DISKBUFsz
  1395.        call z,minhl_bc_tobc ;keeps hl
  1396. ;bc=size
  1397.        ;jr $
  1398.        ld a,b
  1399.        or c
  1400.        jr nz,ZIPRDBYHn0
  1401. ;прочитать CRC
  1402. ;прочитать chunksize
  1403. ;прочитать "IDAT"
  1404.        ld de,DISKBUF
  1405.        ld hl,12
  1406.        call readstream
  1407. ;вместо remained:
  1408.        ld hl,DISKBUF+4
  1409.        ld d,(hl)
  1410.        inc hl
  1411.        ld e,(hl)
  1412.        inc hl
  1413.        ld a,(hl)
  1414.        inc hl
  1415.        ld l,(hl)
  1416.        ld h,a
  1417. ;снова посчитать размер текущего блока
  1418.        jr ZIPRDBYH0read
  1419. ZIPRDBYHn0
  1420. ;bc=size
  1421.        or a
  1422.        sbc hl,bc
  1423.        ld (pngIDATremained),hl
  1424.        jr nc,$+3
  1425.        dec de
  1426.        ld (pngIDATremainedHSW),de
  1427.        ld d,b
  1428.        ld e,c
  1429. ;de=size
  1430.        ld hl,DISKBUF+DISKBUFsz
  1431.        or a
  1432.        sbc hl,de ;size
  1433.        ex de,hl ;de=addr = DISKBUF+; hl=size
  1434.         push de
  1435.        call readstream
  1436.         pop de
  1437.         push de ;addr
  1438. ;hl=actual size
  1439.         ld a,h
  1440.         or l
  1441.         jr z,ZIPRDBYHq;readerror
  1442. ;move block to end of buf:
  1443.        ld b,h
  1444.        ld c,l
  1445.        dec de ;ld de,DISKBUF-1
  1446.        add hl,de ;end of data
  1447.        ld de,DISKBUF+DISKBUFsz-1
  1448.        sbc hl,de
  1449.        add hl,de
  1450.        jr z,ZIPRDBYHq
  1451.         pop af
  1452.        lddr
  1453.        inc de ;begin of data
  1454.         push de
  1455. ZIPRDBYHq
  1456.         pop iy ;addr = DISKBUF+
  1457.  
  1458.        pop hl
  1459.        pop de
  1460.        pop bc
  1461.        exx
  1462.       POP AF
  1463.       ex af,af'
  1464.         POP IX
  1465.         pop BC
  1466.        POP DE
  1467.          pop hl
  1468.        LD A,(IY)
  1469.        or a ;CY=0: OK
  1470.         ret
  1471.  
  1472. readstream
  1473. readstream_patch=$+1
  1474.         jp readstream_file
  1475.  
  1476. rdCS    
  1477.         LD A,0
  1478.         OR A
  1479.         RET Z
  1480. rdCSU  
  1481.         LD A,0xfe
  1482.         IN A,(0xfe)
  1483.         LD (getCS+1),A
  1484. getCS
  1485.         LD A,0xff
  1486.         RRA
  1487.         RET        
  1488.  
  1489. GETDWORD_slow
  1490. ;hlde
  1491.         ;call RDBYTE
  1492.         ;ld e,a
  1493.         ;call RDBYTE
  1494.         ;ld d,a
  1495.         call GETWORD_slowhl
  1496.         ex de,hl
  1497. GETWORD_slowhl
  1498.         call RDBYTE
  1499.         ld l,a
  1500.         call RDBYTE
  1501.         ld h,a
  1502.         ret
  1503.        
  1504. RDWORDHSBLSBtohl
  1505.         CALL RDBYTE
  1506.         LD H,A
  1507.         CALL RDBYTE
  1508.         LD L,A
  1509.         RET  
  1510.  
  1511. readchrlomem
  1512. ;hl=from (BRG)
  1513.         ld d,chrbuf/256
  1514. _=0
  1515.         if GIF_PIXELSIZE
  1516.         dup 8
  1517.         ld a,(hl)
  1518.         inc hl
  1519.         ld (chrbuf+16+_),a
  1520.         ld (chrbuf+8+_),a
  1521.         ld (chrbuf+0+_),a
  1522. _=_+1
  1523.         edup
  1524.         else
  1525.         dup 8
  1526.         ld e,0xff&(chrbuf+16+_)
  1527.         ldi ;b
  1528.         ld e,0xff&(chrbuf+8+_)
  1529.         ldi ;g
  1530.         ld e,0xff&(chrbuf+0+_)
  1531.         ldi ;r
  1532. _=_+1
  1533.         edup
  1534.  
  1535.         endif
  1536.         ret
  1537.  
  1538. readchrlomemx2
  1539.         ld d,chrbuf/256
  1540. _=0
  1541.         if GIF_PIXELSIZE
  1542.         dup 4
  1543.         ld a,(hl)
  1544.         inc hl
  1545.         ld (chrbuf+16+_),a
  1546.         ld (chrbuf+8+_),a
  1547.         ld (chrbuf+0+_),a
  1548. _=_+1
  1549.         ld (chrbuf+16+_),a
  1550.         ld (chrbuf+8+_),a
  1551.         ld (chrbuf+0+_),a
  1552. _=_+1
  1553.         edup
  1554.         else
  1555.         dup 4
  1556.         ld e,0xff&(chrbuf+16+_)
  1557.         ld a,(hl)
  1558.         ld (de),a
  1559.         inc e
  1560.         ldi ;b
  1561.         ld e,0xff&(chrbuf+8+_)
  1562.         ld a,(hl)
  1563.         ld (de),a
  1564.         inc e
  1565.         ldi ;g
  1566.         ld e,0xff&(chrbuf+0+_)
  1567.         ld a,(hl)
  1568.         ld (de),a
  1569.         inc e
  1570.         ldi ;r
  1571. _=_+2
  1572.         edup
  1573.  
  1574.         endif
  1575.         ret
  1576.        
  1577. convertchr
  1578.  
  1579. chrbufG=64+8
  1580. ;поиск 2 цветов (запоминаем положения рекордных цветов, чтобы потом их прочитать):
  1581.         ld hl,chrbuf
  1582. _=chrbufG
  1583.         ld de,_*257
  1584.         ld c,(hl) ;Rmin
  1585.         ld b,c ;Rmax
  1586. _=_+1
  1587.         dup 7
  1588.         inc l
  1589.         ld a,(hl) ;R(pixel)
  1590.         cp c ;Rmin
  1591.         jr nc,$+2+1+2
  1592.          ld c,a ;Rmin
  1593.          ld e,_ ;Rmincolor = положение текущего цвета
  1594.         cp b ;Rmax
  1595.         jr c,$+2+1+2
  1596.          ld b,a ;Rmax
  1597.          ld d,_ ;Rmaxcolor = положение текущего цвета
  1598. _=_+1
  1599.         edup
  1600.         push de ;ld (Rminmaxcolor),de
  1601.         ld a,b
  1602.         sub c
  1603.         push af ;Rmax-Rmin
  1604.  
  1605.         inc l ;ld hl,chrbuf+8
  1606. _=chrbufG
  1607.         ld de,_*257
  1608.         ld c,(hl) ;Gmin
  1609.         ld b,c ;Gmax
  1610. _=_+1
  1611.         dup 7
  1612.         inc l
  1613.         ld a,(hl) ;G(pixel)
  1614.         cp c ;Gmin
  1615.         jr nc,$+2+1+2
  1616.          ld c,a ;Gmin
  1617.          ld e,_ ;Gmincolor = положение текущего цвета
  1618.         cp b ;Gmax
  1619.         jr c,$+2+1+2
  1620.          ld b,a ;Gmax
  1621.          ld d,_ ;Gmaxcolor = положение текущего цвета
  1622. _=_+1
  1623.         edup
  1624.         push de ;ld (Gminmaxcolor),de
  1625.         ld a,b
  1626.         sub c
  1627.         push af ;Gmax-Gmin
  1628.  
  1629.         inc l ;ld hl,chrbuf+16
  1630. _=chrbufG
  1631.         ld de,_*257
  1632.         ld c,(hl) ;Bmin
  1633.         ld b,c ;Bmax
  1634. _=_+1
  1635.         dup 7
  1636.         inc l
  1637.         ld a,(hl) ;B(pixel)
  1638.         cp c ;Bmin
  1639.         jr nc,$+2+1+2
  1640.          ld c,a ;Bmin
  1641.          ld e,_ ;Bmincolor = положение текущего цвета
  1642.         cp b ;Bmax
  1643.         jr c,$+2+1+2
  1644.          ld b,a ;Bmax
  1645.          ld d,_ ;Bmaxcolor = положение текущего цвета
  1646. _=_+1
  1647.         edup
  1648.         ld a,b
  1649.         sub c ;Bmax-Bmin
  1650.  
  1651. ;выбираем лучшую ось и её minmaxcolor:
  1652.         ld c,a ;maxdist
  1653.         pop af ;Gmax-Gmin
  1654.         pop hl ;Gminmaxcolor
  1655.         cp c ;>=maxdist?
  1656.         jr c,$+2+1+1
  1657.          ld c,a ;maxdist
  1658.          ex de,hl
  1659.         pop af ;Rmax-Rmin
  1660.         pop hl ;Rminmaxcolor
  1661.         cp c ;>=maxdist?
  1662.         jr c,$+2+1
  1663.          ex de,hl
  1664.  
  1665. ;d=maxcolor
  1666. ;e=mincolor
  1667. ;берём рекордные цвета (в виде color16):
  1668. ;чтобы получить color16, надо сначала color64(=BBGGRR), потом по таблице из него
  1669.         jp (iy) ;colorlace0 ;/1
  1670.  
  1671. ROUNDUP=32
  1672. ROUNDDOWN=32
  1673.         macro DOROUNDDOWN
  1674.          sub ROUNDDOWN
  1675.          jr nc,$+3
  1676.          xor a
  1677.         endm
  1678.  
  1679.         macro DOROUNDUP
  1680.          add a,d;ROUNDUP;d
  1681.          jr nc,$+3
  1682.          sbc a,a
  1683.         endm
  1684.  
  1685.         dw colorlace1
  1686. colorlace0
  1687. ;d=maxcolor
  1688. ;e=mincolor
  1689. ;берём рекордные цвета (в виде color16):
  1690. ;чтобы получить color16, надо сначала color64(=BBGGRR), потом по таблице из него
  1691.         ld h,chrbuf/256
  1692.         ld l,d ;maxcolor
  1693.         ld c,(hl) ;G
  1694.         res 3,l
  1695.         ld b,(hl) ;R
  1696.         set 4,l
  1697.         ld a,(hl) ;B
  1698.         rlca
  1699.         rlca
  1700.         rl c
  1701.         rla
  1702.         rl c ;g
  1703.         rla
  1704.         rl b
  1705.         rla
  1706.         rl b ;r
  1707.         rla ;BBGGRR
  1708.         or 0xc0
  1709.         ld l,a
  1710.        ld d,h ;e=mincolor
  1711.         ld a,(de);(hl) ;G
  1712.         DOROUNDDOWN
  1713.         ld c,a
  1714.         res 3,e
  1715.         ld a,(de);(hl) ;R
  1716.         DOROUNDDOWN
  1717.         ld b,a
  1718.         set 4,e
  1719.         ld a,(de);(hl) ;B
  1720.         DOROUNDDOWN
  1721.         rlca
  1722.         rlca
  1723.         rl c
  1724.         rla
  1725.         rl c ;g
  1726.         rla
  1727.         rl b
  1728.         rla
  1729.         rl b ;r
  1730.         rla ;BBGGRR
  1731.         and 0x3f
  1732.         ld e,a;l,a
  1733.        ld a,(de) ;paper(maxcolor)
  1734.        or (hl) ;ink(mincolor)    
  1735. ;a=attr
  1736.         exx
  1737.         ld (hl),a ;записать attr
  1738.         exx
  1739. ;по реальным атрибутам заново пересчитать maxaxis, min, maxdist! (проверено, что без этого получается пятнистость):
  1740.         ld d,h
  1741.         dec h ;ld h,tmaxaxis/256+2
  1742.         ld l,a ;будем ходить по этой цветовой составляющей
  1743.         ld e,(hl) ;maxaxis*8
  1744.         dec h
  1745.         ld b,(hl) ;min
  1746.         dec h
  1747.         ld h,(hl) ;maxdistdiv
  1748. ;b=R/G/Bmin
  1749. ;de на начале буфера R/G/B
  1750. ;h=maxdistdiv
  1751. ;в диферинге ходим только по одной составляющей, остальные не читаем:
  1752.         jp (ix) ;dithermcy0/1/2/3
  1753.  
  1754.         dw colorlace0
  1755. colorlace1
  1756. ;d=maxcolor
  1757. ;e=mincolor
  1758. ;берём рекордные цвета (в виде color16):
  1759. ;чтобы получить color16, надо сначала color64(=BBGGRR), потом по таблице из него
  1760.         ld h,chrbuf/256
  1761.         ld l,d ;maxcolor
  1762.          ld d,ROUNDUP
  1763.         ld a,(hl) ;G
  1764.         DOROUNDUP
  1765.         ld c,a
  1766.         res 3,l
  1767.         ld a,(hl) ;R
  1768.         DOROUNDUP
  1769.         ld b,a
  1770.         set 4,l
  1771.         ld a,(hl) ;B
  1772.         DOROUNDUP
  1773.         rlca
  1774.         rlca
  1775.         rl c
  1776.         rla
  1777.         rl c ;g
  1778.         rla
  1779.         rl b
  1780.         rla
  1781.         rl b ;r
  1782.         rla ;BBGGRR
  1783.         or 0xc0
  1784.         ld l,a
  1785.         ld d,(hl) ;paper(maxcolor)
  1786.         ld l,e ;mincolor
  1787.         ld c,(hl) ;G
  1788.         res 3,l
  1789.         ld b,(hl) ;R
  1790.         set 4,l
  1791.         ld a,(hl) ;B
  1792.         rlca
  1793.         rlca
  1794.         rl c
  1795.         rla
  1796.         rl c ;g
  1797.         rla
  1798.         rl b
  1799.         rla
  1800.         rl b ;r
  1801.         rla ;BBGGRR
  1802.         and 0x3f
  1803.         ld l,a
  1804.         ld a,(hl) ;ink(mincolor)
  1805.         or d ;paper(maxcolor)
  1806.         exx
  1807.         ld (hl),a ;записать attr
  1808.         exx
  1809. ;по реальным атрибутам заново пересчитать maxaxis, min, maxdist! (проверено, что без этого получается пятнистость):
  1810.         ld d,h
  1811.         dec h ;ld h,tmaxaxis/256+2
  1812.         ld l,a ;будем ходить по этой цветовой составляющей
  1813.         ld e,(hl) ;maxaxis*8
  1814.         dec h
  1815.         ld b,(hl) ;min
  1816.         dec h
  1817.         ld h,(hl) ;maxdistdiv
  1818. ;b=R/G/Bmin
  1819. ;de на начале буфера R/G/B
  1820. ;h=maxdistdiv
  1821. ;в диферинге ходим только по одной составляющей, остальные не читаем:
  1822.         jp (ix) ;dithermcy0/1/2/3
  1823.  
  1824.  ;0 бессмысленно (всегда NC), поэтому все значения увеличены на 1:
  1825.         dw dithermcy2
  1826. dithermcy3
  1827.         DITHERMC1B 0x1, 0xd, 0x3, 0xf
  1828.         ret;jp convertchrq
  1829.  
  1830.         dw dithermcy1
  1831. dithermcy2
  1832.         DITHERMC1B 0x9, 0x5, 0xb, 0x7
  1833.         ret;jp convertchrq
  1834.  
  1835.         dw dithermcy0
  1836. dithermcy1
  1837.         DITHERMC1B 0x4, 0x10, 0x2, 0xe
  1838.         ret;jp convertchrq
  1839.  
  1840.         dw dithermcy3
  1841. dithermcy0
  1842.         DITHERMC1B 0xc, 0x8, 0xa, 0x6
  1843.         ret;jp convertchrq
  1844.  
  1845. skipword
  1846. ;hl=string
  1847. ;out: hl=terminator/space addr
  1848. getword0
  1849.         ld a,(hl)
  1850.         or a
  1851.         ret z
  1852.         cp ' '
  1853.         ret z
  1854.         inc hl
  1855.         jr getword0
  1856.  
  1857. skipspaces
  1858. ;hl=string
  1859. ;out: hl=after last space
  1860.         ld a,(hl)
  1861.         cp ' '
  1862.         ret nz
  1863.         inc hl
  1864.         jr skipspaces
  1865.  
  1866. minhl_bc_tobc
  1867.         or a
  1868.         sbc hl,bc
  1869.         add hl,bc
  1870.         ret nc ;bc<=hl
  1871.         ld b,h
  1872.         ld c,l
  1873.         ret
  1874.  
  1875. MULWORD
  1876. ;out: HLBC=DE*BC
  1877.         LD HL,0
  1878.         LD A,17
  1879. MULWOR0 RR B
  1880.         RR C
  1881.         DEC A
  1882.         RET Z
  1883.         JR NC,$+3
  1884.         ADD HL,DE
  1885.         RR H
  1886.         RR L
  1887.         JR MULWOR0
  1888.  
  1889. putline
  1890. ;hl=откуда копируем строку
  1891. ;bc=сколько байт копируем
  1892. ;на выходе сдвигает указатель, куда копируем (putchar_hl, putchar_a)
  1893.         ex de,hl
  1894. putchar_hl=$+1
  1895.         ld hl,0
  1896. putchar_a=$+1
  1897.         ld a,0
  1898. ;de=from      
  1899. ;ahl=to
  1900. ;bc=size
  1901.         call puttomem
  1902. nextputlineaddr
  1903. ;keeps bc
  1904.         ld a,(putchar_a)
  1905.         ld hl,(putchar_hl)
  1906. curpicwidx3=$+1
  1907.         ld de,0
  1908.         add hl,de
  1909.         adc a,0
  1910. setputlineaddr
  1911.         ld (putchar_hl),hl
  1912.         ld (putchar_a),a
  1913.         ret
  1914.  
  1915. getline
  1916. ;de=куда достаём строку
  1917. ;bc=сколько байт достаём
  1918. gifwasdisposalmethod=$+1
  1919.         ld a,0 ;bit0 = transparent color present, bit4..2 = disposal method (0=not specified(?), 1=do not dispose(?), 2=overwrite with bg color, 3=overwrite with prev frame(?))
  1920.         and 0x1c
  1921.         cp 8
  1922.         jr z,getline_fill
  1923.         ld hl,(nframes)
  1924.         ld a,h
  1925.         or l
  1926.         jr nz,getline_frommem
  1927. getline_fill
  1928. ;фон первого кадра - заливка
  1929.         push de
  1930. gifbgcolor=$+1
  1931.          ld hl,PAL_GLOB
  1932.          ldi
  1933.          dec hl
  1934.          inc h
  1935.          ldi
  1936.          dec hl
  1937.          inc h
  1938.          ldi ;TODO проверить порядок компонент!
  1939.         pop hl
  1940.          ret po ;bc=0
  1941.         ldir
  1942.         ret
  1943.  
  1944. getline_frommem
  1945.         ld hl,(putchar_hl)
  1946.         ld a,(putchar_a)
  1947.         jp getfrommem
  1948.  
  1949. swapimer
  1950.         di
  1951.         ld de,0x0038
  1952.         ld hl,oldimer
  1953.         ld bc,3
  1954. swapimer0
  1955.         ld a,(de)
  1956.         ldi ;[oldimer] -> [0x0038]
  1957.         dec hl
  1958.         ld (hl),a ;[0x0038] -> [oldimer]
  1959.         inc hl
  1960.         jp pe,swapimer0
  1961.         ei
  1962.         ret
  1963. oldimer
  1964.         jp on_int ;заменится на код из 0x0038
  1965.         jp 0x0038+3
  1966.  
  1967. on_int
  1968. ;restore stack with de
  1969.         EX DE,HL
  1970.         EX (SP),HL ;de="hl", в стеке "de"
  1971.         LD (on_int_jp),HL
  1972.         LD (on_int_sp),SP
  1973.         LD SP,INTSTACK
  1974.         ex de,hl ;hl="hl"
  1975.  
  1976.         call oldimer ;ei
  1977.  
  1978. on_int_sp=$+1
  1979.         ld sp,0
  1980.         pop de
  1981.         ;ei
  1982. on_int_jp=$+1
  1983.         jp 0
  1984.  
  1985. curpicwid
  1986.         dw 0
  1987. curpichgt
  1988.         dw 0
  1989. curpichgt_visible
  1990.         dw 0
  1991.  
  1992. downloadfilename
  1993.         db "download.fil",0
  1994.  
  1995. tfileprotocol
  1996.         db "file://",0
  1997. thttpprotocol
  1998.         db "http://",0
  1999. tgopherprotocol
  2000.         db "gopher://",0
  2001. thttpsprotocol
  2002.         db "https://",0
  2003.  
  2004. linkbuf
  2005.         ds MAXLINKSZ+1
  2006.        
  2007. curfulllink
  2008.         ds MAXLINKSZ+1
  2009.  
  2010.         include "htmlview.asm"
  2011.         include "html.asm"
  2012.         include "prvirt.asm"
  2013.         include "mempgs.asm"
  2014.         include "dynmem.asm"
  2015.         include "../_sdk/file.asm"
  2016.         include "gif.asm"
  2017.         include "drawmc.asm"
  2018.         include "editline.asm"
  2019.  
  2020.         align 256
  2021. textpages
  2022.         ds 256
  2023. ;TODO ещё отдельно gfxpages (чтобы можно было удалять RGB после конверсии)
  2024.  
  2025.         align 256
  2026. tmaxaxis ;maxdistdiv_fromattr[256], min_fromattr[256], maxaxis_fromattr[256]
  2027.         incbin "tmaxaxis"
  2028.  
  2029.         ;align 256 ;непосредственно после tmaxaxis
  2030. t64to16ink
  2031.         incbin "t64to16i"
  2032. chrbuf
  2033.         ds 8 ;R
  2034. chrbufG=$&0xff
  2035.         ds 8 ;G
  2036.         ds 8 ;B
  2037.         ds 256-64-24-64
  2038. t64to16paper
  2039.         incbin "t64to16p"
  2040.        
  2041. twinto866
  2042.         incbin "../_sdk/codepage/winto866"
  2043.  
  2044. endcode=$
  2045.  
  2046.         ds end1-$
  2047.         display "free for code=",$-endcode
  2048.  
  2049.         ds 0x4000-$ ;stack
  2050.         align 256
  2051. fnt
  2052.         incbin "1125vert.fnt"
  2053.         include "http.asm"
  2054.         include "prmc.asm"
  2055.         include "jpeg.asm"
  2056.         include "png.asm"
  2057. depkbeg=$
  2058. initCRC
  2059. CRC32_
  2060.         ret
  2061. saveblock
  2062. savelastblock
  2063.         push af
  2064.         push bc
  2065.         push de
  2066.         push hl
  2067. ;TODO ускорить
  2068.         ld de,depkbuf        
  2069. pngdepktoaddr=$+1
  2070.         ld hl,0
  2071. pngdepktoaddrHSB=$+1
  2072.         ld a,0
  2073.         ld bc,(Z6546) ;сколько байт сохранить
  2074.         ld (TD198),bc ;сколько байт сохраняли
  2075.  
  2076.         inc bc
  2077.         jr saveblock0_go
  2078. ;адрес 0x7e00..0xffff
  2079. saveblock0
  2080.         push bc
  2081.          push af
  2082.          call gifsetpgLZW
  2083.          pop af
  2084.         ex de,hl
  2085.         ld c,(hl)
  2086.         inc hl
  2087.         ex de,hl
  2088.         call writebyte
  2089.         pop bc
  2090. saveblock0_go
  2091.         dec hl
  2092.         cpi
  2093.         jp pe,saveblock0
  2094.         ld (pngdepktoaddr),hl
  2095.         ld (pngdepktoaddrHSB),a
  2096.          call gifsetpgLZW
  2097.  
  2098.         ld hl,0
  2099.         ld (Z6546),hl
  2100.         pop hl
  2101.         pop de
  2102.         pop bc
  2103.         pop af
  2104.         ret
  2105. depkqerror=ERROR        
  2106. ziptrees
  2107.         ds 0xa60 + 2*288
  2108.         include "../pkunzip/depk.asm"
  2109.  
  2110.         ;display "depk size=",$-depkbeg
  2111.  
  2112. wgetfilename
  2113.         db "wget.com",0
  2114.  
  2115.         include "init.asm"
  2116.  
  2117. free2=end2-$;0x8000-$
  2118.         display "free for code in 0x4000=",free2
  2119.         ds 0x8000-$
  2120.  
  2121.         incbin "tdiv"
  2122. ;0xc000
  2123.         include "svg.asm"
  2124.         display "end=",$
  2125.  
  2126. cmd_end
  2127.         ;display "Size ",/d,cmd_end-cmd_begin," bytes"
  2128.  
  2129.         savebin "browser.com",cmd_begin,cmd_end-cmd_begin
  2130.  
  2131.         LABELSLIST "../../us/user.l"
  2132.