?login_element?

Subversion Repositories NedoOS

Rev

Rev 1510 | 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 ;dehl=timer
  307.          ld (timebegin),hl
  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 ;dehl=timer
  676.         pop af
  677.         ex (sp),hl
  678.         call showframe ;читает showframetime из кадра
  679.  
  680.         pop de ;timer
  681.  
  682.         push af
  683.         push hl
  684.  
  685. showframetime=$+1
  686.         ld hl,0 ;in 1/100 s
  687.         inc hl
  688.         srl h
  689.         rr l
  690.         add hl,de ;max timer for this frame
  691.         ld (showframemaxtimer),hl
  692.  
  693. showframe_delay0
  694.         call yieldgetkeynolang ;z=nokey
  695.         ;cp key_enter
  696.         ;jp z,closequit ;TODO restore stack
  697.         ;cp 'z'
  698.         ;jr z,showframe_setzoom
  699.         call globalbuttons
  700.         ld hl,(xscroll)
  701.         cp key_left
  702.         jr z,showframe_left
  703.         cp key_right
  704.         jr z,showframe_right
  705.         ld hl,(yscroll)
  706.         cp key_down
  707.         jr z,showframe_down
  708.         cp key_up
  709.         jr z,showframe_up
  710. showframe_nokey
  711.         OS_GETTIMER ;dehl=timer
  712. showframemaxtimer=$+1
  713.         ld bc,0 ;max timer for this frame
  714.         or a
  715.         sbc hl,bc
  716.         jp m,showframe_delay0 ;timer<maxtimer
  717.  
  718.         pop hl
  719.         pop af
  720.  
  721.         pop bc
  722.         dec bc
  723.         bit 7,b
  724.         jr z,showgif_frames0
  725.        
  726.         jp showgif_firstframe
  727.  
  728. showframe_setzoom
  729.         ld hl,setzoom_patch
  730.         ld a,(hl)
  731.         xor 0x80
  732.         ld (hl),a
  733.         jp browser_reload
  734.  
  735. ;TODO проблема, если задержка кадра слишком маленькая, успеем только один раз прочитать клавиши
  736.  
  737. showframe_left
  738. ;hl=xscroll
  739.         dec hl
  740.         res 0,l
  741.         bit 7,h
  742.         jr nz,showframe_nokey
  743.         jr showframe_leftrightq
  744.  
  745. showframe_right
  746. ;hl=xscroll
  747. ;не двигаем xscroll, если правая граница (=keepframe_linesize-xscroll) получается <80
  748.         inc hl
  749.         inc hl
  750.         ex de,hl
  751.         ld hl,(keepframe_linesize)
  752.         or a
  753.         sbc hl,de
  754.         ld bc,80
  755.         or a
  756.         sbc hl,bc
  757.         ex de,hl
  758.         jr nc,showframe_leftrightq
  759. ;предел скролла: xscroll=keepframe_linesize-80 >=0
  760.          ld hl,(keepframe_linesize)
  761.          or a
  762.          sbc hl,bc
  763.         jr c,showframe_nokey
  764. showframe_leftrightq
  765.         ld (xscroll),hl
  766.         jr showframe_nokey
  767.  
  768. showframe_up
  769. ;hl=yscroll
  770.         ld bc,8
  771.         xor a
  772.         sbc hl,bc
  773.         jr nc,showframe_updownq
  774.         ld h,a
  775.         ld l,a
  776.         jr showframe_updownq
  777.  
  778. showframe_down
  779. ;hl=yscroll
  780. ;не двигаем yscroll, если нижняя граница (=curpichgt_visible-yscroll) получается <SCROLLHGT(200)
  781.         ld bc,8
  782.         add hl,bc
  783.         ex de,hl
  784.         ld hl,(curpichgt_visible)
  785.         or a
  786.         sbc hl,de
  787.         ld bc,SCROLLHGT;200
  788.         or a
  789.         sbc hl,bc
  790.         ex de,hl
  791.         jr nc,showframe_updownq
  792. ;предел скролла: yscroll=curpichgt_visible-SCROLLHGT >=0
  793.          ld hl,(curpichgt_visible)
  794.          or a
  795.          sbc hl,bc
  796.         jr c,showframe_nokey
  797. showframe_updownq
  798.         ld (yscroll),hl
  799.         jr showframe_nokey
  800.  
  801. loadbmp_fail
  802. closequit
  803.         call closestream
  804.          jr getkeyquit
  805.  
  806. LOADERROR
  807.         call closestream
  808.         ld de,tloaderr
  809.         jr TYPE_ERROR
  810. CONNECTIONERROR
  811.         ld de,tconnerr
  812. TYPE_ERROR
  813.         push de
  814.         call setpgs_scr
  815.         call setpgcode4000
  816.         ld a,STATUSCOLOR
  817.         call initprcharmc
  818.         ld de,0xc048
  819.         call setxymc
  820.         pop de
  821.         call prtextmc
  822.  
  823. ERROR ;for jpeg
  824. ERROR2
  825. ERROR4
  826. getkeyquit
  827. getkeyquit0
  828.         ;YIELD ;halt ;если сделать просто di:rst #38, то 1.сдвинем таймер и 2.можем потерять кадровое прерывание, а если без ei, то будут глюки
  829.         ;GET_KEY ;OS_GETKEYNOLANG
  830.         ;ld a,c ;keynolang
  831.         call yieldgetkeynolang
  832.         call globalbuttons
  833.         jr getkeyquit0
  834.        
  835. globalbuttons
  836.         cp key_backspace
  837.         jp z,browser_backspace
  838.         cp '5'
  839.         jp z,browser_reload
  840.         cp 'z'
  841.         jp z,showframe_setzoom
  842.         cp 's'
  843.         jp z,browser_downloadthis
  844.         cp 'e'
  845.         jp z,browser_editline
  846.         cp key_esc
  847.         ret nz
  848. browser_quit
  849.         ld a,(wgetloaded_pid)
  850.         or a
  851.         jr z,browser_quitq
  852.  
  853. ;TODO проверить, что wget жив:
  854.         ld e,a
  855.         OS_CHECKPID
  856.         or a
  857.         jr z,browser_quitq ;dead
  858.  
  859.         ld a,(wgetmainpg)
  860.         SETPG32KHIGH
  861.         ld a,0xff
  862.         ld (0xc000+COMMANDLINE+2),a
  863. browser_quitq
  864.         QUIT
  865.  
  866. oraret
  867.         or a
  868.         ret
  869. yieldgetkeynolang
  870. ;out: z=no key, no action
  871.         YIELD ;halt ;если сделать просто di:rst 0x38, то 1.сдвинем таймер и 2.можем потерять кадровое прерывание, а если без ei, то будут глюки
  872.         GET_KEY
  873.         ld lx,a ;keylang
  874.         jr nz,oraret ;no focus (a=0, nz) => ret with Z
  875.         ;jr z,yieldgetkeynolang_focus
  876.         ;;ld de,(control_imer_oldmousecoords) ;no focus
  877.         ;xor a
  878.         ;ret
  879. ;yieldgetkeynolang_focus
  880.          cp key_redraw ;!=0
  881.          jr z,oraret ;a!=0 => ret with NZ ;эту кнопку нельзя подменять, иначе экран не перерисуется (NZ!)
  882. ;hl=(sysmousebuttons)
  883.         ld a,l
  884.         and 0xf0
  885. control_imer_oldmousewheel=$+2
  886.         ld hx,0
  887.         ld (control_imer_oldmousewheel),a
  888.         sub hx
  889.         ld (mouse_scrollvalue),a
  890.         jr z,yieldgetkeynolang_key
  891.         ;jp p,yieldgetkeynolang_scrollup
  892.         ;neg
  893.         ;ld (mouse_scrollvalue),a        
  894.         ld a,key_down_scroll
  895.         ret p;m ;nz        
  896. ;yieldgetkeynolang_scrollup
  897.         ld a,key_up_scroll
  898.         ret ;nz
  899. yieldgetkeynolang_key
  900.         ld a,0
  901.         ld (mouse_scrollvalue),a ;default scrollvalue
  902.         ld a,l
  903.         cpl
  904.         ld l,a
  905.         bit 0,l ;LMB
  906.         ld a,key_enter
  907.         ret nz
  908.         bit 1,l ;RMB
  909.         ld a,key_backspace
  910.         ret nz
  911.         ld a,lx ;keylang
  912.         or a ;cp NOKEY ;keylang==0?
  913.         ret nz ;jr nz,$+3
  914.         cp c ;keynolang==0?
  915.         ret nz
  916. ;no action? mouse coords change is also an action
  917.         push bc
  918. control_imer_oldmousecoords=$+1
  919.         ld bc,0
  920.         ld (control_imer_oldmousecoords),de
  921.         ld a,b
  922.         sub d
  923.         ld d,a
  924.         ld a,e
  925.         sub c
  926.         ld e,a
  927.         ld (control_imer_mousecoordsdelta),de
  928.         ld a,d
  929.         or e
  930.         ld a,0
  931.         pop bc
  932.         ret ;z/nz
  933.  
  934. closestream
  935. closestream_patch=$+1
  936.         jp closestream_file
  937.        
  938. tconnerr
  939.         db "conn.err",0
  940. tloaderr
  941.         db "load err",0
  942.  
  943. showtime
  944.          call setpgcode4000
  945.         ld a,STATUSCOLOR
  946.         call initprcharmc
  947.  
  948.          OS_GETTIMER ;dehl=timer
  949. timebegin=$+1
  950.          ld de,0
  951.          or a
  952.          sbc hl,de
  953.          ld de,0xc04a
  954. ;d=y, e=x8
  955. ;hl=time (frames)
  956.          jp prnumfrac
  957.  
  958. showmem
  959.         ld a,(npages)
  960. npages_old=$+1
  961.         cp -1
  962.         ret z
  963.         ld (npages_old),a
  964.         ld l,a
  965.         ld h,0
  966.         push hl
  967.          call setpgcode4000
  968.         ld a,STATUSCOLOR
  969.         call initprcharmc
  970.         pop hl
  971.          ld de,0xc046
  972.         jp prnum123
  973.  
  974. cleanstatusline
  975.         call setpgs_scr
  976.         call setpgcode4000
  977.         xor a
  978.         ld (browser_editline_scroll),a
  979.         ld hl,EDITLINEY*256+(40*192)
  980.         ld a,STATUSCOLOR
  981.         call cleanlinemc
  982.         ;ld a,STATUSCOLOR
  983.         jp initprcharmc
  984.  
  985. ;hl = poi to filename in string
  986. ;out: de = after last slash
  987. findlastslash.
  988. nfopenfnslash.
  989.         ld d,h
  990.         ld e,l ;de = after last slash
  991. nfopenfnslash0.
  992.         ld a,[hl]
  993.         inc hl
  994.         or a
  995.         ret z
  996.         cp '/'
  997.         jr nz,nfopenfnslash0.
  998.         jr nfopenfnslash.
  999.  
  1000.  
  1001.  
  1002. strcopy
  1003. ;hl->de
  1004. ;out: hl,de after terminator
  1005.         xor a
  1006. strcopy0
  1007.         cp (hl)
  1008.         ldi
  1009.         jr nz,strcopy0
  1010.         ret
  1011.                
  1012. makefulllink
  1013. ;curfulllink = curfulllink+linkbuf
  1014.         ld hl,linkbuf
  1015. ;если ссылка начинается со слеша, то надо отрезать весь путь, кроме сервера
  1016.         ld a,(hl)
  1017.         cp '/'
  1018.         jr z,browser_go_rootlink ;"/Timex"
  1019.  
  1020.         call isprotocolpresent
  1021. ;nz=protocol absent (hl=link), z=protocol present (a=protocol (0=file, 1=http), hl=after "//")
  1022.         jr z,browser_go_protocolpresent ;протокол есть - linkbuf содержит полную ссылку (к ней только добавить / в случае http://ser.ver)
  1023.         ld a,(linkbuf+1)
  1024.         sub ':'
  1025.         jr z,browser_go_defaultprotocolpresent ;1:/file... => file://1:/file...
  1026. ;нет протокола - взять текущий путь из curfulllink (т.е. отрезать всё после последнего слеша) и приклеить к нему эту ссылку (с учётом ../)
  1027. ;слеш в конце http://ser.ver уже есть? не всегда! если ввели вручную, то нет
  1028.         ld hl,curfulllink
  1029.         call isprotocolpresent
  1030. ;a=protocol (0=file, 1=http), hl=after "//"
  1031.          push hl
  1032.         call findlastslash. ;out: de = after last slash or beginning
  1033.          pop hl
  1034.          or a
  1035.          sbc hl,de
  1036.          jr nz,browser_go_noaddslashafterserver
  1037.          add hl,de
  1038.          push hl ;after "//"
  1039.          call addslashafterserver
  1040.          pop hl
  1041.          call findlastslash. ;out: de = after last slash
  1042. browser_go_noaddslashafterserver
  1043. ;de=curfulllink+...=end of curdir (after slash)
  1044.         ld hl,linkbuf
  1045. browser_go_chdir
  1046.         ld a,'.'
  1047.         cp (hl)
  1048.         jr nz,browser_go_chdirq
  1049.         inc hl ;skip dot
  1050.          ld a,(hl)
  1051.          cp '/'
  1052.         inc hl ;if nz,skip another dot supposed
  1053.          jr z,browser_go_dotslash
  1054.         ld a,(hl)
  1055.         or a
  1056.         jr z,$+3
  1057.         inc hl ;skip / supposed
  1058. ;hl=linkbuf+... (path/file without ../)
  1059. ;de=curfulllink+...=end of curdir (after slash)
  1060. ;remove last element of curdir = move de to previous slash
  1061.         dec de ;at slash
  1062.         dec de
  1063.         ld a,(de)
  1064.         inc de
  1065.         inc de ;after slash
  1066.         cp '/' ;is it "//"?
  1067.         jr z,browser_go_chdir_error
  1068.         dec de ;at slash
  1069.         ex de,hl ;hl=at slash
  1070.         dec hl
  1071.         ld a,'/'
  1072.         ld b,-1
  1073.         cpdr
  1074.         inc hl ;at previous slash (might be last slash of "//")
  1075.         inc hl ;after slash
  1076.         ex de,hl ;de=curfulllink+...=end of curdir (after slash)
  1077.          jr browser_go_chdir
  1078. browser_go_chdir_error
  1079. browser_go_chdirq
  1080. ;hl=linkbuf+... (path/file without ../)
  1081. ;de=curfulllink+...=end of curdir (after slash)
  1082.         call strcopy
  1083.         jr browser_go_protocolpresentq
  1084. browser_go_defaultprotocolpresent
  1085. ;1:/file... => file://1:/file...
  1086. ;a=0
  1087.         call adddefaultprotocol
  1088.         jr browser_go_protocolpresentq
  1089. browser_go_dotslash=browser_go_chdir ;"./Timex"
  1090.  
  1091. browser_go_rootlink
  1092. ;"/Timex"
  1093. ;hl=linkbuf+... at slash
  1094. ;если ссылка начинается с //, то надо отрезать весь путь, кроме протокола
  1095.          inc hl
  1096.          ld a,(hl)
  1097.          cp '/'
  1098.          jr z,browser_go_rootprotocol
  1099.          dec hl
  1100.          push hl
  1101.         ld hl,curfulllink
  1102.         call isprotocolpresent
  1103. ;a=protocol (0=file, 1=http), hl=after "//"
  1104.         call findslash
  1105.         dec hl ;at slash
  1106.         ex de,hl ;de=curfulllink+ after server (at slash)
  1107.          pop hl
  1108.         jr browser_go_copyto;linkbuf
  1109.  
  1110. browser_go_protocolpresent
  1111. ;a=protocol (0=file, 1=http), hl=after "//"
  1112.         call addslashafterserver ;add / after http://ser.ver
  1113.         ld de,curfulllink
  1114. ;browser_go_copytolinkbuf
  1115.         ld hl,linkbuf
  1116. browser_go_copyto
  1117.         call strcopy
  1118. browser_go_protocolpresentq
  1119. ;curfulllink содержит полный url, собранный из старого curfullink и ссылки linkbuf
  1120.         ret
  1121.  
  1122. browser_go_rootprotocol
  1123.         inc hl
  1124. ;hl=linkbuf+... after "//"
  1125.          push hl
  1126.         ld hl,curfulllink
  1127.         call isprotocolpresent
  1128. ;a=protocol (0=file, 1=http), hl=after "//"
  1129.         ex de,hl ;de=curfulllink+ after protocol://
  1130.          pop hl
  1131.         jr browser_go_copyto;linkbuf
  1132.  
  1133. adddefaultprotocol
  1134. ;1:/file... => file://1:/file...
  1135. ;ser.ver... => http://ser.ver...
  1136. ;a=protocol (0=file, 1=http)
  1137.         push af ;a=protocol (0=file, 1=http)
  1138.         or a
  1139.         ld hl,tfileprotocol
  1140.         jr z,$+5
  1141.          ld hl,thttpprotocol
  1142.         ld de,curfulllink
  1143.         call strcopy
  1144.         dec de
  1145.         push de
  1146.         ld hl,linkbuf
  1147.         call strcopy        
  1148.         pop hl
  1149.         pop af ;a=protocol (0=file, 1=http)
  1150.         ret
  1151.  
  1152. addslashafterserver
  1153. ;add / after http://ser.ver
  1154. ;hl=after "//"
  1155.         call findslash
  1156.         ret z ;слеш уже есть
  1157.          ld (hl),c;0
  1158.          dec hl
  1159.          ld (hl),a ;add / after http://ser.ver
  1160.         ret
  1161.  
  1162. findslash
  1163.         call strlen_tobc_keephl ;out: bc=len (Z: len==0)
  1164.          ret z
  1165.         ld a,'/'
  1166.         cpir
  1167.         ret
  1168.  
  1169. strlen_tobc_keephl
  1170. ;hl=string
  1171. ;out: bc=len (Z: len==0)
  1172.         push hl
  1173.         xor a
  1174.         ld b,-1
  1175.         cpir
  1176.         pop de
  1177.         sbc hl,de
  1178.         ld b,h
  1179.         ld c,l ;bc=strlen
  1180.         ex de,hl ;hl=string
  1181.         ret
  1182.  
  1183. isprotocolpresent
  1184. ;hl=link string
  1185. ;out: nz=protocol absent (hl=link), z=protocol present (a=protocol (0=file, 1=http), hl=after "//")
  1186.         ld de,tfileprotocol
  1187.         push hl
  1188.         call strcp_tillde0 ;if found, hl=after "//"
  1189.         pop de
  1190.         ld a,0
  1191.         ret z
  1192.         ex de,hl
  1193.         ld de,thttpprotocol
  1194.         push hl
  1195.         call strcp_tillde0 ;if found, hl=after "//"
  1196.         pop de
  1197.         ld a,1
  1198.         ret z
  1199.         ex de,hl
  1200.         ld de,tgopherprotocol
  1201.         push hl
  1202.         call strcp_tillde0 ;if found, hl=after "//"
  1203.         pop de
  1204.         ld a,2
  1205.         ret z
  1206.         ex de,hl
  1207.         ld de,thttpsprotocol
  1208.         push hl
  1209.         call strcp_tillde0 ;if found, hl=after "//"
  1210.         pop de
  1211.         ld a,3
  1212.         ret z
  1213.         ex de,hl
  1214.         ret ;nz=protocol absent (hl=start)
  1215.  
  1216. nextscreenline
  1217. ;out: de=старая строка, nc=out of screen
  1218. drawscreenline_frombuf_scr=$+1
  1219.         ld de,0
  1220.         ld hl,40
  1221.         add hl,de ;next line on screen
  1222.          ;push bc
  1223.          ld bc,40*(SCROLLHGT+1)+0x4000
  1224.          or a
  1225.          sbc hl,bc
  1226.          add hl,bc
  1227.          ;pop bc
  1228.          ret nc
  1229.         ;bit 5,h
  1230.         ;ret nz ;jr nz,drawscreenline_frombufq ;end of screen, current line doesn't fit
  1231.         ld (drawscreenline_frombuf_scr),hl
  1232.         ret
  1233.  
  1234. drawscreenline_frombuf
  1235. ;hl=from
  1236.         exx
  1237.         call nextscreenline
  1238.         ;exx
  1239.         ;ret nc ;end of screen, current line doesn't fit
  1240.  
  1241.         push ix
  1242.         push iy
  1243.        
  1244. drawscreenline_frombuf_ixaddr=$+2
  1245.         ld ix,(dithermcy0-2)
  1246. drawscreenline_frombuf_iyaddr=$+2
  1247.         ld iy,(colorlace0-2)
  1248.  
  1249.         ;exx
  1250.         push af ;nc=out of screen
  1251.         push de ;screen
  1252.         ld de,LINEPIXELS;-0x4000
  1253.         ld hl,(keepframe_linesize)
  1254.         ld b,h
  1255.         ld c,l
  1256.         add hl,de
  1257.         exx
  1258.          call setpgdiv4000
  1259.          call setpgtemp8000 ;такой нам дали адрес        
  1260.         jr drawscreenline_frombuf0go
  1261. drawscreenline_frombuf0
  1262.         exx
  1263.         pop hl
  1264. drawscreenline_frombuf0go
  1265. readchr_patch=$+1
  1266.         call readchrlomem
  1267.         push hl
  1268.         call convertchr ;jp=1980t (не делает exx в конце, для удобства)
  1269.         inc de
  1270.         cpi ;делает inc hl
  1271.         jp pe,drawscreenline_frombuf0
  1272.         pop af
  1273.  
  1274.         dec ix
  1275.         dec ix
  1276.         ld (drawscreenline_frombuf_ixaddr),ix
  1277.         dec iy
  1278.         dec iy
  1279.         ld (drawscreenline_frombuf_iyaddr),iy
  1280.  
  1281.          ;call setpgs_scr
  1282.         exx
  1283.         pop bc ;screen
  1284.         pop af ;nc=out of screen
  1285.         ld hl,LINEPIXELS;-0x4000
  1286. ;hl=data
  1287. ;bc=screen=0xc000+
  1288.         call c,prlinefast
  1289.  
  1290.          call setpgtemp8000
  1291.          call setpgcode4000
  1292.  
  1293.         pop iy
  1294.         pop ix
  1295.         ret;jp setpgtemp8000
  1296.  
  1297. read_b_bytes
  1298. read_b_bytes0
  1299.         call RDBYTE
  1300.         djnz read_b_bytes0
  1301.         ret
  1302.  
  1303. RDBYTE
  1304.         INC LY
  1305.         LD A,(IY)
  1306.         RET NZ
  1307. RDBYH
  1308. ;TODO проверка конца файла и возврат a=0, флаг CY=1?
  1309.         INC HY
  1310.         LD A,HY
  1311.         CP DISKBUF/256+(DISKBUFsz/256)
  1312.         LD A,(IY)
  1313.          ccf ;CY=0: OK
  1314.         RET nz
  1315.        PUSH HL
  1316.        PUSH DE
  1317.         PUSH BC
  1318.         push IX
  1319.        CALL rdCS
  1320.        ex af,af'
  1321.       PUSH AF
  1322.        exx
  1323.        push bc
  1324.        push de
  1325.        push hl
  1326.        ld de,DISKBUF
  1327.        ld hl,DISKBUFsz
  1328.        call readstream
  1329. ;hl=actual size (TODO if 0 then exit? сейчас конец последнего блока и пустого блока забивается нулями, нужно для html)
  1330. ;fill the rest of buffer with zeros
  1331.        ld de,DISKBUF
  1332.        add hl,de
  1333.        ex de,hl ;de=start of zeros
  1334.        ld hl,DISKBUF+DISKBUFsz
  1335.        xor a
  1336.        sbc hl,de
  1337.        ld b,h
  1338.        ld c,l ;bc=length of zeros (Z=no zeros)
  1339.        jr z,readdiskbuf_nozeros
  1340.        ld h,d
  1341.        ld l,e ;start of zeros
  1342.        ld (hl),a;0
  1343.        inc de
  1344.        dec bc
  1345.        ld a,b
  1346.        or c
  1347.        jr z,readdiskbuf_nozeros
  1348.        ldir
  1349. readdiskbuf_nozeros
  1350.        pop hl
  1351.        pop de
  1352.        pop bc
  1353.        exx
  1354.       POP AF
  1355.       ex af,af'
  1356.         POP IX
  1357.         pop BC
  1358.        POP DE
  1359.          pop hl
  1360.        ld iy,DISKBUF
  1361.        LD A,(IY)
  1362.        or a ;CY=0: OK
  1363.         RET
  1364.  
  1365. ZIPRDBYH
  1366. ;TODO читать столько, сколько осталось в IDAT (если это не больше DISKBUFsz), потом искать следующий IDAT
  1367.         INC HY
  1368.         LD A,HY
  1369.         CP DISKBUF/256+(DISKBUFsz/256)
  1370.         LD A,(IY)
  1371.          ccf ;CY=0: OK
  1372.         RET nz
  1373.  
  1374.        PUSH HL
  1375.        PUSH DE
  1376.         PUSH BC
  1377.         push IX
  1378.        ;CALL rdCS
  1379.        ex af,af'
  1380.       PUSH AF
  1381.        exx
  1382.        push bc
  1383.        push de
  1384.        push hl
  1385.  
  1386. pngIDATremainedHSW=$+1
  1387.        ld de,0
  1388. pngIDATremained=$+1
  1389.        ld hl,0
  1390. ZIPRDBYH0read
  1391.        ld a,d
  1392.        or e
  1393.        ld bc,DISKBUFsz
  1394.        call z,minhl_bc_tobc ;keeps hl
  1395. ;bc=size
  1396.        ;jr $
  1397.        ld a,b
  1398.        or c
  1399.        jr nz,ZIPRDBYHn0
  1400. ;прочитать CRC
  1401. ;прочитать chunksize
  1402. ;прочитать "IDAT"
  1403.        ld de,DISKBUF
  1404.        ld hl,12
  1405.        call readstream
  1406. ;вместо remained:
  1407.        ld hl,DISKBUF+4
  1408.        ld d,(hl)
  1409.        inc hl
  1410.        ld e,(hl)
  1411.        inc hl
  1412.        ld a,(hl)
  1413.        inc hl
  1414.        ld l,(hl)
  1415.        ld h,a
  1416. ;снова посчитать размер текущего блока
  1417.        jr ZIPRDBYH0read
  1418. ZIPRDBYHn0
  1419. ;bc=size
  1420.        or a
  1421.        sbc hl,bc
  1422.        ld (pngIDATremained),hl
  1423.        jr nc,$+3
  1424.        dec de
  1425.        ld (pngIDATremainedHSW),de
  1426.        ld d,b
  1427.        ld e,c
  1428. ;de=size
  1429.        ld hl,DISKBUF+DISKBUFsz
  1430.        or a
  1431.        sbc hl,de ;size
  1432.        ex de,hl ;de=addr = DISKBUF+; hl=size
  1433.         push de
  1434.        call readstream
  1435.         pop de
  1436.         push de ;addr
  1437. ;hl=actual size
  1438.         ld a,h
  1439.         or l
  1440.         jr z,ZIPRDBYHq;readerror
  1441. ;move block to end of buf:
  1442.        ld b,h
  1443.        ld c,l
  1444.        dec de ;ld de,DISKBUF-1
  1445.        add hl,de ;end of data
  1446.        ld de,DISKBUF+DISKBUFsz-1
  1447.        sbc hl,de
  1448.        add hl,de
  1449.        jr z,ZIPRDBYHq
  1450.         pop af
  1451.        lddr
  1452.        inc de ;begin of data
  1453.         push de
  1454. ZIPRDBYHq
  1455.         pop iy ;addr = DISKBUF+
  1456.  
  1457.        pop hl
  1458.        pop de
  1459.        pop bc
  1460.        exx
  1461.       POP AF
  1462.       ex af,af'
  1463.         POP IX
  1464.         pop BC
  1465.        POP DE
  1466.          pop hl
  1467.        LD A,(IY)
  1468.        or a ;CY=0: OK
  1469.         ret
  1470.  
  1471. readstream
  1472. readstream_patch=$+1
  1473.         jp readstream_file
  1474.  
  1475. rdCS    
  1476.         LD A,0
  1477.         OR A
  1478.         RET Z
  1479. rdCSU  
  1480.         LD A,0xfe
  1481.         IN A,(0xfe)
  1482.         LD (getCS+1),A
  1483. getCS
  1484.         LD A,0xff
  1485.         RRA
  1486.         RET        
  1487.  
  1488. GETDWORD_slow
  1489. ;hlde
  1490.         ;call RDBYTE
  1491.         ;ld e,a
  1492.         ;call RDBYTE
  1493.         ;ld d,a
  1494.         call GETWORD_slowhl
  1495.         ex de,hl
  1496. GETWORD_slowhl
  1497.         call RDBYTE
  1498.         ld l,a
  1499.         call RDBYTE
  1500.         ld h,a
  1501.         ret
  1502.        
  1503. RDWORDHSBLSBtohl
  1504.         CALL RDBYTE
  1505.         LD H,A
  1506.         CALL RDBYTE
  1507.         LD L,A
  1508.         RET  
  1509.  
  1510. readchrlomem
  1511. ;hl=from (BRG)
  1512.         ld d,chrbuf/256
  1513. _=0
  1514.         if GIF_PIXELSIZE
  1515.         dup 8
  1516.         ld a,(hl)
  1517.         inc hl
  1518.         ld (chrbuf+16+_),a
  1519.         ld (chrbuf+8+_),a
  1520.         ld (chrbuf+0+_),a
  1521. _=_+1
  1522.         edup
  1523.         else
  1524.         dup 8
  1525.         ld e,0xff&(chrbuf+16+_)
  1526.         ldi ;b
  1527.         ld e,0xff&(chrbuf+8+_)
  1528.         ldi ;g
  1529.         ld e,0xff&(chrbuf+0+_)
  1530.         ldi ;r
  1531. _=_+1
  1532.         edup
  1533.  
  1534.         endif
  1535.         ret
  1536.  
  1537. readchrlomemx2
  1538.         ld d,chrbuf/256
  1539. _=0
  1540.         if GIF_PIXELSIZE
  1541.         dup 4
  1542.         ld a,(hl)
  1543.         inc hl
  1544.         ld (chrbuf+16+_),a
  1545.         ld (chrbuf+8+_),a
  1546.         ld (chrbuf+0+_),a
  1547. _=_+1
  1548.         ld (chrbuf+16+_),a
  1549.         ld (chrbuf+8+_),a
  1550.         ld (chrbuf+0+_),a
  1551. _=_+1
  1552.         edup
  1553.         else
  1554.         dup 4
  1555.         ld e,0xff&(chrbuf+16+_)
  1556.         ld a,(hl)
  1557.         ld (de),a
  1558.         inc e
  1559.         ldi ;b
  1560.         ld e,0xff&(chrbuf+8+_)
  1561.         ld a,(hl)
  1562.         ld (de),a
  1563.         inc e
  1564.         ldi ;g
  1565.         ld e,0xff&(chrbuf+0+_)
  1566.         ld a,(hl)
  1567.         ld (de),a
  1568.         inc e
  1569.         ldi ;r
  1570. _=_+2
  1571.         edup
  1572.  
  1573.         endif
  1574.         ret
  1575.        
  1576. convertchr
  1577.  
  1578. chrbufG=64+8
  1579. ;поиск 2 цветов (запоминаем положения рекордных цветов, чтобы потом их прочитать):
  1580.         ld hl,chrbuf
  1581. _=chrbufG
  1582.         ld de,_*257
  1583.         ld c,(hl) ;Rmin
  1584.         ld b,c ;Rmax
  1585. _=_+1
  1586.         dup 7
  1587.         inc l
  1588.         ld a,(hl) ;R(pixel)
  1589.         cp c ;Rmin
  1590.         jr nc,$+2+1+2
  1591.          ld c,a ;Rmin
  1592.          ld e,_ ;Rmincolor = положение текущего цвета
  1593.         cp b ;Rmax
  1594.         jr c,$+2+1+2
  1595.          ld b,a ;Rmax
  1596.          ld d,_ ;Rmaxcolor = положение текущего цвета
  1597. _=_+1
  1598.         edup
  1599.         push de ;ld (Rminmaxcolor),de
  1600.         ld a,b
  1601.         sub c
  1602.         push af ;Rmax-Rmin
  1603.  
  1604.         inc l ;ld hl,chrbuf+8
  1605. _=chrbufG
  1606.         ld de,_*257
  1607.         ld c,(hl) ;Gmin
  1608.         ld b,c ;Gmax
  1609. _=_+1
  1610.         dup 7
  1611.         inc l
  1612.         ld a,(hl) ;G(pixel)
  1613.         cp c ;Gmin
  1614.         jr nc,$+2+1+2
  1615.          ld c,a ;Gmin
  1616.          ld e,_ ;Gmincolor = положение текущего цвета
  1617.         cp b ;Gmax
  1618.         jr c,$+2+1+2
  1619.          ld b,a ;Gmax
  1620.          ld d,_ ;Gmaxcolor = положение текущего цвета
  1621. _=_+1
  1622.         edup
  1623.         push de ;ld (Gminmaxcolor),de
  1624.         ld a,b
  1625.         sub c
  1626.         push af ;Gmax-Gmin
  1627.  
  1628.         inc l ;ld hl,chrbuf+16
  1629. _=chrbufG
  1630.         ld de,_*257
  1631.         ld c,(hl) ;Bmin
  1632.         ld b,c ;Bmax
  1633. _=_+1
  1634.         dup 7
  1635.         inc l
  1636.         ld a,(hl) ;B(pixel)
  1637.         cp c ;Bmin
  1638.         jr nc,$+2+1+2
  1639.          ld c,a ;Bmin
  1640.          ld e,_ ;Bmincolor = положение текущего цвета
  1641.         cp b ;Bmax
  1642.         jr c,$+2+1+2
  1643.          ld b,a ;Bmax
  1644.          ld d,_ ;Bmaxcolor = положение текущего цвета
  1645. _=_+1
  1646.         edup
  1647.         ld a,b
  1648.         sub c ;Bmax-Bmin
  1649.  
  1650. ;выбираем лучшую ось и её minmaxcolor:
  1651.         ld c,a ;maxdist
  1652.         pop af ;Gmax-Gmin
  1653.         pop hl ;Gminmaxcolor
  1654.         cp c ;>=maxdist?
  1655.         jr c,$+2+1+1
  1656.          ld c,a ;maxdist
  1657.          ex de,hl
  1658.         pop af ;Rmax-Rmin
  1659.         pop hl ;Rminmaxcolor
  1660.         cp c ;>=maxdist?
  1661.         jr c,$+2+1
  1662.          ex de,hl
  1663.  
  1664. ;d=maxcolor
  1665. ;e=mincolor
  1666. ;берём рекордные цвета (в виде color16):
  1667. ;чтобы получить color16, надо сначала color64(=BBGGRR), потом по таблице из него
  1668.         jp (iy) ;colorlace0 ;/1
  1669.  
  1670. ROUNDUP=32
  1671. ROUNDDOWN=32
  1672.         macro DOROUNDDOWN
  1673.          sub ROUNDDOWN
  1674.          jr nc,$+3
  1675.          xor a
  1676.         endm
  1677.  
  1678.         macro DOROUNDUP
  1679.          add a,d;ROUNDUP;d
  1680.          jr nc,$+3
  1681.          sbc a,a
  1682.         endm
  1683.  
  1684.         dw colorlace1
  1685. colorlace0
  1686. ;d=maxcolor
  1687. ;e=mincolor
  1688. ;берём рекордные цвета (в виде color16):
  1689. ;чтобы получить color16, надо сначала color64(=BBGGRR), потом по таблице из него
  1690.         ld h,chrbuf/256
  1691.         ld l,d ;maxcolor
  1692.         ld c,(hl) ;G
  1693.         res 3,l
  1694.         ld b,(hl) ;R
  1695.         set 4,l
  1696.         ld a,(hl) ;B
  1697.         rlca
  1698.         rlca
  1699.         rl c
  1700.         rla
  1701.         rl c ;g
  1702.         rla
  1703.         rl b
  1704.         rla
  1705.         rl b ;r
  1706.         rla ;BBGGRR
  1707.         or 0xc0
  1708.         ld l,a
  1709.        ld d,h ;e=mincolor
  1710.         ld a,(de);(hl) ;G
  1711.         DOROUNDDOWN
  1712.         ld c,a
  1713.         res 3,e
  1714.         ld a,(de);(hl) ;R
  1715.         DOROUNDDOWN
  1716.         ld b,a
  1717.         set 4,e
  1718.         ld a,(de);(hl) ;B
  1719.         DOROUNDDOWN
  1720.         rlca
  1721.         rlca
  1722.         rl c
  1723.         rla
  1724.         rl c ;g
  1725.         rla
  1726.         rl b
  1727.         rla
  1728.         rl b ;r
  1729.         rla ;BBGGRR
  1730.         and 0x3f
  1731.         ld e,a;l,a
  1732.        ld a,(de) ;paper(maxcolor)
  1733.        or (hl) ;ink(mincolor)    
  1734. ;a=attr
  1735.         exx
  1736.         ld (hl),a ;записать attr
  1737.         exx
  1738. ;по реальным атрибутам заново пересчитать maxaxis, min, maxdist! (проверено, что без этого получается пятнистость):
  1739.         ld d,h
  1740.         dec h ;ld h,tmaxaxis/256+2
  1741.         ld l,a ;будем ходить по этой цветовой составляющей
  1742.         ld e,(hl) ;maxaxis*8
  1743.         dec h
  1744.         ld b,(hl) ;min
  1745.         dec h
  1746.         ld h,(hl) ;maxdistdiv
  1747. ;b=R/G/Bmin
  1748. ;de на начале буфера R/G/B
  1749. ;h=maxdistdiv
  1750. ;в диферинге ходим только по одной составляющей, остальные не читаем:
  1751.         jp (ix) ;dithermcy0/1/2/3
  1752.  
  1753.         dw colorlace0
  1754. colorlace1
  1755. ;d=maxcolor
  1756. ;e=mincolor
  1757. ;берём рекордные цвета (в виде color16):
  1758. ;чтобы получить color16, надо сначала color64(=BBGGRR), потом по таблице из него
  1759.         ld h,chrbuf/256
  1760.         ld l,d ;maxcolor
  1761.          ld d,ROUNDUP
  1762.         ld a,(hl) ;G
  1763.         DOROUNDUP
  1764.         ld c,a
  1765.         res 3,l
  1766.         ld a,(hl) ;R
  1767.         DOROUNDUP
  1768.         ld b,a
  1769.         set 4,l
  1770.         ld a,(hl) ;B
  1771.         DOROUNDUP
  1772.         rlca
  1773.         rlca
  1774.         rl c
  1775.         rla
  1776.         rl c ;g
  1777.         rla
  1778.         rl b
  1779.         rla
  1780.         rl b ;r
  1781.         rla ;BBGGRR
  1782.         or 0xc0
  1783.         ld l,a
  1784.         ld d,(hl) ;paper(maxcolor)
  1785.         ld l,e ;mincolor
  1786.         ld c,(hl) ;G
  1787.         res 3,l
  1788.         ld b,(hl) ;R
  1789.         set 4,l
  1790.         ld a,(hl) ;B
  1791.         rlca
  1792.         rlca
  1793.         rl c
  1794.         rla
  1795.         rl c ;g
  1796.         rla
  1797.         rl b
  1798.         rla
  1799.         rl b ;r
  1800.         rla ;BBGGRR
  1801.         and 0x3f
  1802.         ld l,a
  1803.         ld a,(hl) ;ink(mincolor)
  1804.         or d ;paper(maxcolor)
  1805.         exx
  1806.         ld (hl),a ;записать attr
  1807.         exx
  1808. ;по реальным атрибутам заново пересчитать maxaxis, min, maxdist! (проверено, что без этого получается пятнистость):
  1809.         ld d,h
  1810.         dec h ;ld h,tmaxaxis/256+2
  1811.         ld l,a ;будем ходить по этой цветовой составляющей
  1812.         ld e,(hl) ;maxaxis*8
  1813.         dec h
  1814.         ld b,(hl) ;min
  1815.         dec h
  1816.         ld h,(hl) ;maxdistdiv
  1817. ;b=R/G/Bmin
  1818. ;de на начале буфера R/G/B
  1819. ;h=maxdistdiv
  1820. ;в диферинге ходим только по одной составляющей, остальные не читаем:
  1821.         jp (ix) ;dithermcy0/1/2/3
  1822.  
  1823.  ;0 бессмысленно (всегда NC), поэтому все значения увеличены на 1:
  1824.         dw dithermcy2
  1825. dithermcy3
  1826.         DITHERMC1B 0x1, 0xd, 0x3, 0xf
  1827.         ret;jp convertchrq
  1828.  
  1829.         dw dithermcy1
  1830. dithermcy2
  1831.         DITHERMC1B 0x9, 0x5, 0xb, 0x7
  1832.         ret;jp convertchrq
  1833.  
  1834.         dw dithermcy0
  1835. dithermcy1
  1836.         DITHERMC1B 0x4, 0x10, 0x2, 0xe
  1837.         ret;jp convertchrq
  1838.  
  1839.         dw dithermcy3
  1840. dithermcy0
  1841.         DITHERMC1B 0xc, 0x8, 0xa, 0x6
  1842.         ret;jp convertchrq
  1843.  
  1844. skipword
  1845. ;hl=string
  1846. ;out: hl=terminator/space addr
  1847. getword0
  1848.         ld a,(hl)
  1849.         or a
  1850.         ret z
  1851.         cp ' '
  1852.         ret z
  1853.         inc hl
  1854.         jr getword0
  1855.  
  1856. skipspaces
  1857. ;hl=string
  1858. ;out: hl=after last space
  1859.         ld a,(hl)
  1860.         cp ' '
  1861.         ret nz
  1862.         inc hl
  1863.         jr skipspaces
  1864.  
  1865. minhl_bc_tobc
  1866.         or a
  1867.         sbc hl,bc
  1868.         add hl,bc
  1869.         ret nc ;bc<=hl
  1870.         ld b,h
  1871.         ld c,l
  1872.         ret
  1873.  
  1874. MULWORD
  1875. ;out: HLBC=DE*BC
  1876.         LD HL,0
  1877.         LD A,17
  1878. MULWOR0 RR B
  1879.         RR C
  1880.         DEC A
  1881.         RET Z
  1882.         JR NC,$+3
  1883.         ADD HL,DE
  1884.         RR H
  1885.         RR L
  1886.         JR MULWOR0
  1887.  
  1888. putline
  1889. ;hl=откуда копируем строку
  1890. ;bc=сколько байт копируем
  1891. ;на выходе сдвигает указатель, куда копируем (putchar_hl, putchar_a)
  1892.         ex de,hl
  1893. putchar_hl=$+1
  1894.         ld hl,0
  1895. putchar_a=$+1
  1896.         ld a,0
  1897. ;de=from      
  1898. ;ahl=to
  1899. ;bc=size
  1900.         call puttomem
  1901. nextputlineaddr
  1902. ;keeps bc
  1903.         ld a,(putchar_a)
  1904.         ld hl,(putchar_hl)
  1905. curpicwidx3=$+1
  1906.         ld de,0
  1907.         add hl,de
  1908.         adc a,0
  1909. setputlineaddr
  1910.         ld (putchar_hl),hl
  1911.         ld (putchar_a),a
  1912.         ret
  1913.  
  1914. getline
  1915. ;de=куда достаём строку
  1916. ;bc=сколько байт достаём
  1917. gifwasdisposalmethod=$+1
  1918.         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(?))
  1919.         and 0x1c
  1920.         cp 8
  1921.         jr z,getline_fill
  1922.         ld hl,(nframes)
  1923.         ld a,h
  1924.         or l
  1925.         jr nz,getline_frommem
  1926. getline_fill
  1927. ;фон первого кадра - заливка
  1928.         push de
  1929. gifbgcolor=$+1
  1930.          ld hl,PAL_GLOB
  1931.          ldi
  1932.          dec hl
  1933.          inc h
  1934.          ldi
  1935.          dec hl
  1936.          inc h
  1937.          ldi ;TODO проверить порядок компонент!
  1938.         pop hl
  1939.          ret po ;bc=0
  1940.         ldir
  1941.         ret
  1942.  
  1943. getline_frommem
  1944.         ld hl,(putchar_hl)
  1945.         ld a,(putchar_a)
  1946.         jp getfrommem
  1947.  
  1948. swapimer
  1949.         di
  1950.         ld de,0x0038
  1951.         ld hl,oldimer
  1952.         ld bc,3
  1953. swapimer0
  1954.         ld a,(de)
  1955.         ldi ;[oldimer] -> [0x0038]
  1956.         dec hl
  1957.         ld (hl),a ;[0x0038] -> [oldimer]
  1958.         inc hl
  1959.         jp pe,swapimer0
  1960.         ei
  1961.         ret
  1962. oldimer
  1963.         jp on_int ;заменится на код из 0x0038
  1964.         jp 0x0038+3
  1965.  
  1966. on_int
  1967. ;restore stack with de
  1968.         EX DE,HL
  1969.         EX (SP),HL ;de="hl", в стеке "de"
  1970.         LD (on_int_jp),HL
  1971.         LD (on_int_sp),SP
  1972.         LD SP,INTSTACK
  1973.         ex de,hl ;hl="hl"
  1974.  
  1975.         call oldimer ;ei
  1976.  
  1977. on_int_sp=$+1
  1978.         ld sp,0
  1979.         pop de
  1980.         ;ei
  1981. on_int_jp=$+1
  1982.         jp 0
  1983.  
  1984. curpicwid
  1985.         dw 0
  1986. curpichgt
  1987.         dw 0
  1988. curpichgt_visible
  1989.         dw 0
  1990.  
  1991. downloadfilename
  1992.         db "download.fil",0
  1993.  
  1994. tfileprotocol
  1995.         db "file://",0
  1996. thttpprotocol
  1997.         db "http://",0
  1998. tgopherprotocol
  1999.         db "gopher://",0
  2000. thttpsprotocol
  2001.         db "https://",0
  2002.  
  2003. linkbuf
  2004.         ds MAXLINKSZ+1
  2005. curfulllink
  2006.         ds MAXLINKSZ+1
  2007.  
  2008.         include "htmlview.asm"
  2009.         include "html.asm"
  2010.         include "prvirt.asm"
  2011.         include "mempgs.asm"
  2012.         include "dynmem.asm"
  2013.         include "../_sdk/file.asm"
  2014.         include "gif.asm"
  2015.         include "drawmc.asm"
  2016.         include "editline.asm"
  2017.  
  2018.         align 256
  2019. textpages
  2020.         ds 256
  2021. ;TODO ещё отдельно gfxpages (чтобы можно было удалять RGB после конверсии)
  2022.  
  2023.         align 256
  2024. tmaxaxis ;maxdistdiv_fromattr[256], min_fromattr[256], maxaxis_fromattr[256]
  2025.         incbin "tmaxaxis"
  2026.  
  2027.         ;align 256 ;непосредственно после tmaxaxis
  2028. t64to16ink
  2029.         incbin "t64to16i"
  2030. chrbuf
  2031.         ds 8 ;R
  2032. chrbufG=$&0xff
  2033.         ds 8 ;G
  2034.         ds 8 ;B
  2035.         ds 256-64-24-64
  2036. t64to16paper
  2037.         incbin "t64to16p"
  2038.        
  2039. twinto866
  2040.         incbin "../_sdk/codepage/winto866"
  2041.  
  2042. endcode=$
  2043.  
  2044.         ds end1-$
  2045.         display "free for code=",$-endcode
  2046.  
  2047.         ds 0x4000-$ ;stack
  2048.         align 256
  2049. fnt
  2050.         incbin "1125vert.fnt"
  2051.         include "http.asm"
  2052.         include "prmc.asm"
  2053.         include "jpeg.asm"
  2054.         include "png.asm"
  2055. depkbeg=$
  2056. initCRC
  2057. CRC32_
  2058.         ret
  2059. saveblock
  2060. savelastblock
  2061.         push af
  2062.         push bc
  2063.         push de
  2064.         push hl
  2065. ;TODO ускорить
  2066.         ld de,depkbuf        
  2067. pngdepktoaddr=$+1
  2068.         ld hl,0
  2069. pngdepktoaddrHSB=$+1
  2070.         ld a,0
  2071.         ld bc,(Z6546) ;сколько байт сохранить
  2072.         ld (TD198),bc ;сколько байт сохраняли
  2073.  
  2074.         inc bc
  2075.         jr saveblock0_go
  2076. ;адрес 0x7e00..0xffff
  2077. saveblock0
  2078.         push bc
  2079.          push af
  2080.          call gifsetpgLZW
  2081.          pop af
  2082.         ex de,hl
  2083.         ld c,(hl)
  2084.         inc hl
  2085.         ex de,hl
  2086.         call writebyte
  2087.         pop bc
  2088. saveblock0_go
  2089.         dec hl
  2090.         cpi
  2091.         jp pe,saveblock0
  2092.         ld (pngdepktoaddr),hl
  2093.         ld (pngdepktoaddrHSB),a
  2094.          call gifsetpgLZW
  2095.  
  2096.         ld hl,0
  2097.         ld (Z6546),hl
  2098.         pop hl
  2099.         pop de
  2100.         pop bc
  2101.         pop af
  2102.         ret
  2103. depkqerror=ERROR        
  2104. ziptrees
  2105.         ds 0xa60 + 2*288
  2106.         include "../pkunzip/depk.asm"
  2107.  
  2108.         ;display "depk size=",$-depkbeg
  2109.  
  2110. wgetfilename
  2111.         db "wget.com",0
  2112.  
  2113.         include "init.asm"
  2114.  
  2115. free2=end2-$;0x8000-$
  2116.         display "free for code in 0x4000=",free2
  2117.         ds 0x8000-$
  2118.  
  2119.         incbin "tdiv"
  2120. ;0xc000
  2121.         include "svg.asm"
  2122.         display "end=",$
  2123.  
  2124. cmd_end
  2125.         ;display "Size ",/d,cmd_end-cmd_begin," bytes"
  2126.  
  2127.         savebin "browser.com",cmd_begin,cmd_end-cmd_begin
  2128.  
  2129.         LABELSLIST "../../us/user.l"
  2130.