?login_element?

Subversion Repositories NedoOS

Rev

Rev 1135 | 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 ;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. strcopy
  1001. ;hl->de
  1002. ;out: hl,de after terminator
  1003.         xor a
  1004. strcopy0
  1005.         cp (hl)
  1006.         ldi
  1007.         jr nz,strcopy0
  1008.         ret
  1009.  
  1010. makefulllink
  1011. ;curfulllink = curfulllink+linkbuf
  1012.         ld hl,linkbuf
  1013. ;если ссылка начинается со слеша, то надо отрезать весь путь, кроме сервера
  1014.         ld a,(hl)
  1015.         cp '/'
  1016.         jr z,browser_go_rootlink ;"/Timex"
  1017.  
  1018.         call isprotocolpresent
  1019. ;nz=protocol absent (hl=link), z=protocol present (a=protocol (0=file, 1=http), hl=after "//")
  1020.         jr z,browser_go_protocolpresent ;протокол есть - linkbuf содержит полную ссылку (к ней только добавить / в случае http://ser.ver)
  1021.         ld a,(linkbuf+1)
  1022.         sub ':'
  1023.         jr z,browser_go_defaultprotocolpresent ;1:/file... => file://1:/file...
  1024. ;нет протокола - взять текущий путь из curfulllink (т.е. отрезать всё после последнего слеша) и приклеить к нему эту ссылку (с учётом ../)
  1025. ;слеш в конце http://ser.ver уже есть? не всегда! если ввели вручную, то нет
  1026.         ld hl,curfulllink
  1027.         call isprotocolpresent
  1028. ;a=protocol (0=file, 1=http), hl=after "//"
  1029.          push hl
  1030.         call findlastslash. ;out: de = after last slash or beginning
  1031.          pop hl
  1032.          or a
  1033.          sbc hl,de
  1034.          jr nz,browser_go_noaddslashafterserver
  1035.          add hl,de
  1036.          push hl ;after "//"
  1037.          call addslashafterserver
  1038.          pop hl
  1039.          call findlastslash. ;out: de = after last slash
  1040. browser_go_noaddslashafterserver
  1041. ;de=curfulllink+...=end of curdir (after slash)
  1042.         ld hl,linkbuf
  1043. browser_go_chdir
  1044.         ld a,'.'
  1045.         cp (hl)
  1046.         jr nz,browser_go_chdirq
  1047.         inc hl ;skip dot
  1048.          ld a,(hl)
  1049.          cp '/'
  1050.         inc hl ;if nz,skip another dot supposed
  1051.          jr z,browser_go_dotslash
  1052.         ld a,(hl)
  1053.         or a
  1054.         jr z,$+3
  1055.         inc hl ;skip / supposed
  1056. ;hl=linkbuf+... (path/file without ../)
  1057. ;de=curfulllink+...=end of curdir (after slash)
  1058. ;remove last element of curdir = move de to previous slash
  1059.         dec de ;at slash
  1060.         dec de
  1061.         ld a,(de)
  1062.         inc de
  1063.         inc de ;after slash
  1064.         cp '/' ;is it "//"?
  1065.         jr z,browser_go_chdir_error
  1066.         dec de ;at slash
  1067.         ex de,hl ;hl=at slash
  1068.         dec hl
  1069.         ld a,'/'
  1070.         ld b,-1
  1071.         cpdr
  1072.         inc hl ;at previous slash (might be last slash of "//")
  1073.         inc hl ;after slash
  1074.         ex de,hl ;de=curfulllink+...=end of curdir (after slash)
  1075.          jr browser_go_chdir
  1076. browser_go_chdir_error
  1077. browser_go_chdirq
  1078. ;hl=linkbuf+... (path/file without ../)
  1079. ;de=curfulllink+...=end of curdir (after slash)
  1080.         call strcopy
  1081.         jr browser_go_protocolpresentq
  1082. browser_go_defaultprotocolpresent
  1083. ;1:/file... => file://1:/file...
  1084. ;a=0
  1085.         call adddefaultprotocol
  1086.         jr browser_go_protocolpresentq
  1087. browser_go_dotslash=browser_go_chdir ;"./Timex"
  1088.  
  1089. browser_go_rootlink
  1090. ;"/Timex"
  1091. ;hl=linkbuf+... at slash
  1092. ;если ссылка начинается с //, то надо отрезать весь путь, кроме протокола
  1093.          inc hl
  1094.          ld a,(hl)
  1095.          cp '/'
  1096.          jr z,browser_go_rootprotocol
  1097.          dec hl
  1098.          push hl
  1099.         ld hl,curfulllink
  1100.         call isprotocolpresent
  1101. ;a=protocol (0=file, 1=http), hl=after "//"
  1102.         call findslash
  1103.         dec hl ;at slash
  1104.         ex de,hl ;de=curfulllink+ after server (at slash)
  1105.          pop hl
  1106.         jr browser_go_copyto;linkbuf
  1107.  
  1108. browser_go_protocolpresent
  1109. ;a=protocol (0=file, 1=http), hl=after "//"
  1110.         call addslashafterserver ;add / after http://ser.ver
  1111.         ld de,curfulllink
  1112. ;browser_go_copytolinkbuf
  1113.         ld hl,linkbuf
  1114. browser_go_copyto
  1115.         call strcopy
  1116. browser_go_protocolpresentq
  1117. ;curfulllink содержит полный url, собранный из старого curfullink и ссылки linkbuf
  1118.         ret
  1119.  
  1120. browser_go_rootprotocol
  1121.         inc hl
  1122. ;hl=linkbuf+... after "//"
  1123.          push hl
  1124.         ld hl,curfulllink
  1125.         call isprotocolpresent
  1126. ;a=protocol (0=file, 1=http), hl=after "//"
  1127.         ex de,hl ;de=curfulllink+ after protocol://
  1128.          pop hl
  1129.         jr browser_go_copyto;linkbuf
  1130.  
  1131. adddefaultprotocol
  1132. ;1:/file... => file://1:/file...
  1133. ;ser.ver... => http://ser.ver...
  1134. ;a=protocol (0=file, 1=http)
  1135.         push af ;a=protocol (0=file, 1=http)
  1136.         or a
  1137.         ld hl,tfileprotocol
  1138.         jr z,$+5
  1139.          ld hl,thttpprotocol
  1140.         ld de,curfulllink
  1141.         call strcopy
  1142.         dec de
  1143.         push de
  1144.         ld hl,linkbuf
  1145.         call strcopy        
  1146.         pop hl
  1147.         pop af ;a=protocol (0=file, 1=http)
  1148.         ret
  1149.  
  1150. addslashafterserver
  1151. ;add / after http://ser.ver
  1152. ;hl=after "//"
  1153.         call findslash
  1154.         ret z ;слеш уже есть
  1155.          ld (hl),c;0
  1156.          dec hl
  1157.          ld (hl),a ;add / after http://ser.ver
  1158.         ret
  1159.  
  1160. findslash
  1161.         call strlen_tobc_keephl ;out: bc=len (Z: len==0)
  1162.          ret z
  1163.         ld a,'/'
  1164.         cpir
  1165.         ret
  1166.  
  1167. strlen_tobc_keephl
  1168. ;hl=string
  1169. ;out: bc=len (Z: len==0)
  1170.         push hl
  1171.         xor a
  1172.         ld b,-1
  1173.         cpir
  1174.         pop de
  1175.         sbc hl,de
  1176.         ld b,h
  1177.         ld c,l ;bc=strlen
  1178.         ex de,hl ;hl=string
  1179.         ret
  1180.  
  1181. isprotocolpresent
  1182. ;hl=link string
  1183. ;out: nz=protocol absent (hl=link), z=protocol present (a=protocol (0=file, 1=http), hl=after "//")
  1184.         ld de,tfileprotocol
  1185.         push hl
  1186.         call strcp_tillde0 ;if found, hl=after "//"
  1187.         pop de
  1188.         ld a,0
  1189.         ret z
  1190.         ex de,hl
  1191.         ld de,thttpprotocol
  1192.         push hl
  1193.         call strcp_tillde0 ;if found, hl=after "//"
  1194.         pop de
  1195.         ld a,1
  1196.         ret z
  1197.         ex de,hl
  1198.         ld de,tgopherprotocol
  1199.         push hl
  1200.         call strcp_tillde0 ;if found, hl=after "//"
  1201.         pop de
  1202.         ld a,2
  1203.         ret z
  1204.         ex de,hl
  1205.         ld de,thttpsprotocol
  1206.         push hl
  1207.         call strcp_tillde0 ;if found, hl=after "//"
  1208.         pop de
  1209.         ld a,3
  1210.         ret z
  1211.         ex de,hl
  1212.         ret ;nz=protocol absent (hl=start)
  1213.  
  1214. nextscreenline
  1215. ;out: de=старая строка, nc=out of screen
  1216. drawscreenline_frombuf_scr=$+1
  1217.         ld de,0
  1218.         ld hl,40
  1219.         add hl,de ;next line on screen
  1220.          ;push bc
  1221.          ld bc,40*(SCROLLHGT+1)+0x4000
  1222.          or a
  1223.          sbc hl,bc
  1224.          add hl,bc
  1225.          ;pop bc
  1226.          ret nc
  1227.         ;bit 5,h
  1228.         ;ret nz ;jr nz,drawscreenline_frombufq ;end of screen, current line doesn't fit
  1229.         ld (drawscreenline_frombuf_scr),hl
  1230.         ret
  1231.  
  1232. drawscreenline_frombuf
  1233. ;hl=from
  1234.         exx
  1235.         call nextscreenline
  1236.         ;exx
  1237.         ;ret nc ;end of screen, current line doesn't fit
  1238.  
  1239.         push ix
  1240.         push iy
  1241.        
  1242. drawscreenline_frombuf_ixaddr=$+2
  1243.         ld ix,(dithermcy0-2)
  1244. drawscreenline_frombuf_iyaddr=$+2
  1245.         ld iy,(colorlace0-2)
  1246.  
  1247.         ;exx
  1248.         push af ;nc=out of screen
  1249.         push de ;screen
  1250.         ld de,LINEPIXELS;-0x4000
  1251.         ld hl,(keepframe_linesize)
  1252.         ld b,h
  1253.         ld c,l
  1254.         add hl,de
  1255.         exx
  1256.          call setpgdiv4000
  1257.          call setpgtemp8000 ;такой нам дали адрес        
  1258.         jr drawscreenline_frombuf0go
  1259. drawscreenline_frombuf0
  1260.         exx
  1261.         pop hl
  1262. drawscreenline_frombuf0go
  1263. readchr_patch=$+1
  1264.         call readchrlomem
  1265.         push hl
  1266.         call convertchr ;jp=1980t (не делает exx в конце, для удобства)
  1267.         inc de
  1268.         cpi ;делает inc hl
  1269.         jp pe,drawscreenline_frombuf0
  1270.         pop af
  1271.  
  1272.         dec ix
  1273.         dec ix
  1274.         ld (drawscreenline_frombuf_ixaddr),ix
  1275.         dec iy
  1276.         dec iy
  1277.         ld (drawscreenline_frombuf_iyaddr),iy
  1278.  
  1279.          ;call setpgs_scr
  1280.         exx
  1281.         pop bc ;screen
  1282.         pop af ;nc=out of screen
  1283.         ld hl,LINEPIXELS;-0x4000
  1284. ;hl=data
  1285. ;bc=screen=0xc000+
  1286.         call c,prlinefast
  1287.  
  1288.          call setpgtemp8000
  1289.          call setpgcode4000
  1290.  
  1291.         pop iy
  1292.         pop ix
  1293.         ret;jp setpgtemp8000
  1294.  
  1295. read_b_bytes
  1296. read_b_bytes0
  1297.         call RDBYTE
  1298.         djnz read_b_bytes0
  1299.         ret
  1300.  
  1301. RDBYTE
  1302.         INC LY
  1303.         LD A,(IY)
  1304.         RET NZ
  1305. RDBYH
  1306. ;TODO проверка конца файла и возврат a=0, флаг CY=1?
  1307.         INC HY
  1308.         LD A,HY
  1309.         CP DISKBUF/256+(DISKBUFsz/256)
  1310.         LD A,(IY)
  1311.          ccf ;CY=0: OK
  1312.         RET nz
  1313.        PUSH HL
  1314.        PUSH DE
  1315.         PUSH BC
  1316.         push IX
  1317.        CALL rdCS
  1318.        ex af,af'
  1319.       PUSH AF
  1320.        exx
  1321.        push bc
  1322.        push de
  1323.        push hl
  1324.        ld de,DISKBUF
  1325.        ld hl,DISKBUFsz
  1326.        call readstream
  1327. ;hl=actual size (TODO if 0 then exit? сейчас конец последнего блока и пустого блока забивается нулями, нужно для html)
  1328. ;fill the rest of buffer with zeros
  1329.        ld de,DISKBUF
  1330.        add hl,de
  1331.        ex de,hl ;de=start of zeros
  1332.        ld hl,DISKBUF+DISKBUFsz
  1333.        xor a
  1334.        sbc hl,de
  1335.        ld b,h
  1336.        ld c,l ;bc=length of zeros (Z=no zeros)
  1337.        jr z,readdiskbuf_nozeros
  1338.        ld h,d
  1339.        ld l,e ;start of zeros
  1340.        ld (hl),a;0
  1341.        inc de
  1342.        dec bc
  1343.        ld a,b
  1344.        or c
  1345.        jr z,readdiskbuf_nozeros
  1346.        ldir
  1347. readdiskbuf_nozeros
  1348.        pop hl
  1349.        pop de
  1350.        pop bc
  1351.        exx
  1352.       POP AF
  1353.       ex af,af'
  1354.         POP IX
  1355.         pop BC
  1356.        POP DE
  1357.          pop hl
  1358.        ld iy,DISKBUF
  1359.        LD A,(IY)
  1360.        or a ;CY=0: OK
  1361.         RET
  1362.  
  1363. ZIPRDBYH
  1364. ;TODO читать столько, сколько осталось в IDAT (если это не больше DISKBUFsz), потом искать следующий IDAT
  1365.         INC HY
  1366.         LD A,HY
  1367.         CP DISKBUF/256+(DISKBUFsz/256)
  1368.         LD A,(IY)
  1369.          ccf ;CY=0: OK
  1370.         RET nz
  1371.  
  1372.        PUSH HL
  1373.        PUSH DE
  1374.         PUSH BC
  1375.         push IX
  1376.        ;CALL rdCS
  1377.        ex af,af'
  1378.       PUSH AF
  1379.        exx
  1380.        push bc
  1381.        push de
  1382.        push hl
  1383.  
  1384. pngIDATremainedHSW=$+1
  1385.        ld de,0
  1386. pngIDATremained=$+1
  1387.        ld hl,0
  1388. ZIPRDBYH0read
  1389.        ld a,d
  1390.        or e
  1391.        ld bc,DISKBUFsz
  1392.        call z,minhl_bc_tobc ;keeps hl
  1393. ;bc=size
  1394.        ;jr $
  1395.        ld a,b
  1396.        or c
  1397.        jr nz,ZIPRDBYHn0
  1398. ;прочитать CRC
  1399. ;прочитать chunksize
  1400. ;прочитать "IDAT"
  1401.        ld de,DISKBUF
  1402.        ld hl,12
  1403.        call readstream
  1404. ;вместо remained:
  1405.        ld hl,DISKBUF+4
  1406.        ld d,(hl)
  1407.        inc hl
  1408.        ld e,(hl)
  1409.        inc hl
  1410.        ld a,(hl)
  1411.        inc hl
  1412.        ld l,(hl)
  1413.        ld h,a
  1414. ;снова посчитать размер текущего блока
  1415.        jr ZIPRDBYH0read
  1416. ZIPRDBYHn0
  1417. ;bc=size
  1418.        or a
  1419.        sbc hl,bc
  1420.        ld (pngIDATremained),hl
  1421.        jr nc,$+3
  1422.        dec de
  1423.        ld (pngIDATremainedHSW),de
  1424.        ld d,b
  1425.        ld e,c
  1426. ;de=size
  1427.        ld hl,DISKBUF+DISKBUFsz
  1428.        or a
  1429.        sbc hl,de ;size
  1430.        ex de,hl ;de=addr = DISKBUF+; hl=size
  1431.         push de
  1432.        call readstream
  1433.         pop de
  1434.         push de ;addr
  1435. ;hl=actual size
  1436.         ld a,h
  1437.         or l
  1438.         jr z,ZIPRDBYHq;readerror
  1439. ;move block to end of buf:
  1440.        ld b,h
  1441.        ld c,l
  1442.        dec de ;ld de,DISKBUF-1
  1443.        add hl,de ;end of data
  1444.        ld de,DISKBUF+DISKBUFsz-1
  1445.        sbc hl,de
  1446.        add hl,de
  1447.        jr z,ZIPRDBYHq
  1448.         pop af
  1449.        lddr
  1450.        inc de ;begin of data
  1451.         push de
  1452. ZIPRDBYHq
  1453.         pop iy ;addr = DISKBUF+
  1454.  
  1455.        pop hl
  1456.        pop de
  1457.        pop bc
  1458.        exx
  1459.       POP AF
  1460.       ex af,af'
  1461.         POP IX
  1462.         pop BC
  1463.        POP DE
  1464.          pop hl
  1465.        LD A,(IY)
  1466.        or a ;CY=0: OK
  1467.         ret
  1468.  
  1469. readstream
  1470. readstream_patch=$+1
  1471.         jp readstream_file
  1472.  
  1473. rdCS    
  1474.         LD A,0
  1475.         OR A
  1476.         RET Z
  1477. rdCSU  
  1478.         LD A,0xfe
  1479.         IN A,(0xfe)
  1480.         LD (getCS+1),A
  1481. getCS
  1482.         LD A,0xff
  1483.         RRA
  1484.         RET        
  1485.  
  1486. GETDWORD_slow
  1487. ;hlde
  1488.         ;call RDBYTE
  1489.         ;ld e,a
  1490.         ;call RDBYTE
  1491.         ;ld d,a
  1492.         call GETWORD_slowhl
  1493.         ex de,hl
  1494. GETWORD_slowhl
  1495.         call RDBYTE
  1496.         ld l,a
  1497.         call RDBYTE
  1498.         ld h,a
  1499.         ret
  1500.        
  1501. RDWORDHSBLSBtohl
  1502.         CALL RDBYTE
  1503.         LD H,A
  1504.         CALL RDBYTE
  1505.         LD L,A
  1506.         RET  
  1507.  
  1508. readchrlomem
  1509. ;hl=from (BRG)
  1510.         ld d,chrbuf/256
  1511. _=0
  1512.         if GIF_PIXELSIZE
  1513.         dup 8
  1514.         ld a,(hl)
  1515.         inc hl
  1516.         ld (chrbuf+16+_),a
  1517.         ld (chrbuf+8+_),a
  1518.         ld (chrbuf+0+_),a
  1519. _=_+1
  1520.         edup
  1521.         else
  1522.         dup 8
  1523.         ld e,0xff&(chrbuf+16+_)
  1524.         ldi ;b
  1525.         ld e,0xff&(chrbuf+8+_)
  1526.         ldi ;g
  1527.         ld e,0xff&(chrbuf+0+_)
  1528.         ldi ;r
  1529. _=_+1
  1530.         edup
  1531.  
  1532.         endif
  1533.         ret
  1534.  
  1535. readchrlomemx2
  1536.         ld d,chrbuf/256
  1537. _=0
  1538.         if GIF_PIXELSIZE
  1539.         dup 4
  1540.         ld a,(hl)
  1541.         inc hl
  1542.         ld (chrbuf+16+_),a
  1543.         ld (chrbuf+8+_),a
  1544.         ld (chrbuf+0+_),a
  1545. _=_+1
  1546.         ld (chrbuf+16+_),a
  1547.         ld (chrbuf+8+_),a
  1548.         ld (chrbuf+0+_),a
  1549. _=_+1
  1550.         edup
  1551.         else
  1552.         dup 4
  1553.         ld e,0xff&(chrbuf+16+_)
  1554.         ld a,(hl)
  1555.         ld (de),a
  1556.         inc e
  1557.         ldi ;b
  1558.         ld e,0xff&(chrbuf+8+_)
  1559.         ld a,(hl)
  1560.         ld (de),a
  1561.         inc e
  1562.         ldi ;g
  1563.         ld e,0xff&(chrbuf+0+_)
  1564.         ld a,(hl)
  1565.         ld (de),a
  1566.         inc e
  1567.         ldi ;r
  1568. _=_+2
  1569.         edup
  1570.  
  1571.         endif
  1572.         ret
  1573.        
  1574. convertchr
  1575.  
  1576. chrbufG=64+8
  1577. ;поиск 2 цветов (запоминаем положения рекордных цветов, чтобы потом их прочитать):
  1578.         ld hl,chrbuf
  1579. _=chrbufG
  1580.         ld de,_*257
  1581.         ld c,(hl) ;Rmin
  1582.         ld b,c ;Rmax
  1583. _=_+1
  1584.         dup 7
  1585.         inc l
  1586.         ld a,(hl) ;R(pixel)
  1587.         cp c ;Rmin
  1588.         jr nc,$+2+1+2
  1589.          ld c,a ;Rmin
  1590.          ld e,_ ;Rmincolor = положение текущего цвета
  1591.         cp b ;Rmax
  1592.         jr c,$+2+1+2
  1593.          ld b,a ;Rmax
  1594.          ld d,_ ;Rmaxcolor = положение текущего цвета
  1595. _=_+1
  1596.         edup
  1597.         push de ;ld (Rminmaxcolor),de
  1598.         ld a,b
  1599.         sub c
  1600.         push af ;Rmax-Rmin
  1601.  
  1602.         inc l ;ld hl,chrbuf+8
  1603. _=chrbufG
  1604.         ld de,_*257
  1605.         ld c,(hl) ;Gmin
  1606.         ld b,c ;Gmax
  1607. _=_+1
  1608.         dup 7
  1609.         inc l
  1610.         ld a,(hl) ;G(pixel)
  1611.         cp c ;Gmin
  1612.         jr nc,$+2+1+2
  1613.          ld c,a ;Gmin
  1614.          ld e,_ ;Gmincolor = положение текущего цвета
  1615.         cp b ;Gmax
  1616.         jr c,$+2+1+2
  1617.          ld b,a ;Gmax
  1618.          ld d,_ ;Gmaxcolor = положение текущего цвета
  1619. _=_+1
  1620.         edup
  1621.         push de ;ld (Gminmaxcolor),de
  1622.         ld a,b
  1623.         sub c
  1624.         push af ;Gmax-Gmin
  1625.  
  1626.         inc l ;ld hl,chrbuf+16
  1627. _=chrbufG
  1628.         ld de,_*257
  1629.         ld c,(hl) ;Bmin
  1630.         ld b,c ;Bmax
  1631. _=_+1
  1632.         dup 7
  1633.         inc l
  1634.         ld a,(hl) ;B(pixel)
  1635.         cp c ;Bmin
  1636.         jr nc,$+2+1+2
  1637.          ld c,a ;Bmin
  1638.          ld e,_ ;Bmincolor = положение текущего цвета
  1639.         cp b ;Bmax
  1640.         jr c,$+2+1+2
  1641.          ld b,a ;Bmax
  1642.          ld d,_ ;Bmaxcolor = положение текущего цвета
  1643. _=_+1
  1644.         edup
  1645.         ld a,b
  1646.         sub c ;Bmax-Bmin
  1647.  
  1648. ;выбираем лучшую ось и её minmaxcolor:
  1649.         ld c,a ;maxdist
  1650.         pop af ;Gmax-Gmin
  1651.         pop hl ;Gminmaxcolor
  1652.         cp c ;>=maxdist?
  1653.         jr c,$+2+1+1
  1654.          ld c,a ;maxdist
  1655.          ex de,hl
  1656.         pop af ;Rmax-Rmin
  1657.         pop hl ;Rminmaxcolor
  1658.         cp c ;>=maxdist?
  1659.         jr c,$+2+1
  1660.          ex de,hl
  1661.  
  1662. ;d=maxcolor
  1663. ;e=mincolor
  1664. ;берём рекордные цвета (в виде color16):
  1665. ;чтобы получить color16, надо сначала color64(=BBGGRR), потом по таблице из него
  1666.         jp (iy) ;colorlace0 ;/1
  1667.  
  1668. ROUNDUP=32
  1669. ROUNDDOWN=32
  1670.         macro DOROUNDDOWN
  1671.          sub ROUNDDOWN
  1672.          jr nc,$+3
  1673.          xor a
  1674.         endm
  1675.  
  1676.         macro DOROUNDUP
  1677.          add a,d;ROUNDUP;d
  1678.          jr nc,$+3
  1679.          sbc a,a
  1680.         endm
  1681.  
  1682.         dw colorlace1
  1683. colorlace0
  1684. ;d=maxcolor
  1685. ;e=mincolor
  1686. ;берём рекордные цвета (в виде color16):
  1687. ;чтобы получить color16, надо сначала color64(=BBGGRR), потом по таблице из него
  1688.         ld h,chrbuf/256
  1689.         ld l,d ;maxcolor
  1690.         ld c,(hl) ;G
  1691.         res 3,l
  1692.         ld b,(hl) ;R
  1693.         set 4,l
  1694.         ld a,(hl) ;B
  1695.         rlca
  1696.         rlca
  1697.         rl c
  1698.         rla
  1699.         rl c ;g
  1700.         rla
  1701.         rl b
  1702.         rla
  1703.         rl b ;r
  1704.         rla ;BBGGRR
  1705.         or 0xc0
  1706.         ld l,a
  1707.        ld d,h ;e=mincolor
  1708.         ld a,(de);(hl) ;G
  1709.         DOROUNDDOWN
  1710.         ld c,a
  1711.         res 3,e
  1712.         ld a,(de);(hl) ;R
  1713.         DOROUNDDOWN
  1714.         ld b,a
  1715.         set 4,e
  1716.         ld a,(de);(hl) ;B
  1717.         DOROUNDDOWN
  1718.         rlca
  1719.         rlca
  1720.         rl c
  1721.         rla
  1722.         rl c ;g
  1723.         rla
  1724.         rl b
  1725.         rla
  1726.         rl b ;r
  1727.         rla ;BBGGRR
  1728.         and 0x3f
  1729.         ld e,a;l,a
  1730.        ld a,(de) ;paper(maxcolor)
  1731.        or (hl) ;ink(mincolor)    
  1732. ;a=attr
  1733.         exx
  1734.         ld (hl),a ;записать attr
  1735.         exx
  1736. ;по реальным атрибутам заново пересчитать maxaxis, min, maxdist! (проверено, что без этого получается пятнистость):
  1737.         ld d,h
  1738.         dec h ;ld h,tmaxaxis/256+2
  1739.         ld l,a ;будем ходить по этой цветовой составляющей
  1740.         ld e,(hl) ;maxaxis*8
  1741.         dec h
  1742.         ld b,(hl) ;min
  1743.         dec h
  1744.         ld h,(hl) ;maxdistdiv
  1745. ;b=R/G/Bmin
  1746. ;de на начале буфера R/G/B
  1747. ;h=maxdistdiv
  1748. ;в диферинге ходим только по одной составляющей, остальные не читаем:
  1749.         jp (ix) ;dithermcy0/1/2/3
  1750.  
  1751.         dw colorlace0
  1752. colorlace1
  1753. ;d=maxcolor
  1754. ;e=mincolor
  1755. ;берём рекордные цвета (в виде color16):
  1756. ;чтобы получить color16, надо сначала color64(=BBGGRR), потом по таблице из него
  1757.         ld h,chrbuf/256
  1758.         ld l,d ;maxcolor
  1759.          ld d,ROUNDUP
  1760.         ld a,(hl) ;G
  1761.         DOROUNDUP
  1762.         ld c,a
  1763.         res 3,l
  1764.         ld a,(hl) ;R
  1765.         DOROUNDUP
  1766.         ld b,a
  1767.         set 4,l
  1768.         ld a,(hl) ;B
  1769.         DOROUNDUP
  1770.         rlca
  1771.         rlca
  1772.         rl c
  1773.         rla
  1774.         rl c ;g
  1775.         rla
  1776.         rl b
  1777.         rla
  1778.         rl b ;r
  1779.         rla ;BBGGRR
  1780.         or 0xc0
  1781.         ld l,a
  1782.         ld d,(hl) ;paper(maxcolor)
  1783.         ld l,e ;mincolor
  1784.         ld c,(hl) ;G
  1785.         res 3,l
  1786.         ld b,(hl) ;R
  1787.         set 4,l
  1788.         ld a,(hl) ;B
  1789.         rlca
  1790.         rlca
  1791.         rl c
  1792.         rla
  1793.         rl c ;g
  1794.         rla
  1795.         rl b
  1796.         rla
  1797.         rl b ;r
  1798.         rla ;BBGGRR
  1799.         and 0x3f
  1800.         ld l,a
  1801.         ld a,(hl) ;ink(mincolor)
  1802.         or d ;paper(maxcolor)
  1803.         exx
  1804.         ld (hl),a ;записать attr
  1805.         exx
  1806. ;по реальным атрибутам заново пересчитать maxaxis, min, maxdist! (проверено, что без этого получается пятнистость):
  1807.         ld d,h
  1808.         dec h ;ld h,tmaxaxis/256+2
  1809.         ld l,a ;будем ходить по этой цветовой составляющей
  1810.         ld e,(hl) ;maxaxis*8
  1811.         dec h
  1812.         ld b,(hl) ;min
  1813.         dec h
  1814.         ld h,(hl) ;maxdistdiv
  1815. ;b=R/G/Bmin
  1816. ;de на начале буфера R/G/B
  1817. ;h=maxdistdiv
  1818. ;в диферинге ходим только по одной составляющей, остальные не читаем:
  1819.         jp (ix) ;dithermcy0/1/2/3
  1820.  
  1821.  ;0 бессмысленно (всегда NC), поэтому все значения увеличены на 1:
  1822.         dw dithermcy2
  1823. dithermcy3
  1824.         DITHERMC1B 0x1, 0xd, 0x3, 0xf
  1825.         ret;jp convertchrq
  1826.  
  1827.         dw dithermcy1
  1828. dithermcy2
  1829.         DITHERMC1B 0x9, 0x5, 0xb, 0x7
  1830.         ret;jp convertchrq
  1831.  
  1832.         dw dithermcy0
  1833. dithermcy1
  1834.         DITHERMC1B 0x4, 0x10, 0x2, 0xe
  1835.         ret;jp convertchrq
  1836.  
  1837.         dw dithermcy3
  1838. dithermcy0
  1839.         DITHERMC1B 0xc, 0x8, 0xa, 0x6
  1840.         ret;jp convertchrq
  1841.  
  1842. skipword
  1843. ;hl=string
  1844. ;out: hl=terminator/space addr
  1845. getword0
  1846.         ld a,(hl)
  1847.         or a
  1848.         ret z
  1849.         cp ' '
  1850.         ret z
  1851.         inc hl
  1852.         jr getword0
  1853.  
  1854. skipspaces
  1855. ;hl=string
  1856. ;out: hl=after last space
  1857.         ld a,(hl)
  1858.         cp ' '
  1859.         ret nz
  1860.         inc hl
  1861.         jr skipspaces
  1862.  
  1863. minhl_bc_tobc
  1864.         or a
  1865.         sbc hl,bc
  1866.         add hl,bc
  1867.         ret nc ;bc<=hl
  1868.         ld b,h
  1869.         ld c,l
  1870.         ret
  1871.  
  1872. MULWORD
  1873. ;out: HLBC=DE*BC
  1874.         LD HL,0
  1875.         LD A,17
  1876. MULWOR0 RR B
  1877.         RR C
  1878.         DEC A
  1879.         RET Z
  1880.         JR NC,$+3
  1881.         ADD HL,DE
  1882.         RR H
  1883.         RR L
  1884.         JR MULWOR0
  1885.  
  1886. putline
  1887. ;hl=откуда копируем строку
  1888. ;bc=сколько байт копируем
  1889. ;на выходе сдвигает указатель, куда копируем (putchar_hl, putchar_a)
  1890.         ex de,hl
  1891. putchar_hl=$+1
  1892.         ld hl,0
  1893. putchar_a=$+1
  1894.         ld a,0
  1895. ;de=from      
  1896. ;ahl=to
  1897. ;bc=size
  1898.         call puttomem
  1899. nextputlineaddr
  1900. ;keeps bc
  1901.         ld a,(putchar_a)
  1902.         ld hl,(putchar_hl)
  1903. curpicwidx3=$+1
  1904.         ld de,0
  1905.         add hl,de
  1906.         adc a,0
  1907. setputlineaddr
  1908.         ld (putchar_hl),hl
  1909.         ld (putchar_a),a
  1910.         ret
  1911.  
  1912. getline
  1913. ;de=куда достаём строку
  1914. ;bc=сколько байт достаём
  1915. gifwasdisposalmethod=$+1
  1916.         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(?))
  1917.         and 0x1c
  1918.         cp 8
  1919.         jr z,getline_fill
  1920.         ld hl,(nframes)
  1921.         ld a,h
  1922.         or l
  1923.         jr nz,getline_frommem
  1924. getline_fill
  1925. ;фон первого кадра - заливка
  1926.         push de
  1927. gifbgcolor=$+1
  1928.          ld hl,PAL_GLOB
  1929.          ldi
  1930.          dec hl
  1931.          inc h
  1932.          ldi
  1933.          dec hl
  1934.          inc h
  1935.          ldi ;TODO проверить порядок компонент!
  1936.         pop hl
  1937.          ret po ;bc=0
  1938.         ldir
  1939.         ret
  1940.  
  1941. getline_frommem
  1942.         ld hl,(putchar_hl)
  1943.         ld a,(putchar_a)
  1944.         jp getfrommem
  1945.  
  1946. swapimer
  1947.         di
  1948.         ld de,0x0038
  1949.         ld hl,oldimer
  1950.         ld bc,3
  1951. swapimer0
  1952.         ld a,(de)
  1953.         ldi ;[oldimer] -> [0x0038]
  1954.         dec hl
  1955.         ld (hl),a ;[0x0038] -> [oldimer]
  1956.         inc hl
  1957.         jp pe,swapimer0
  1958.         ei
  1959.         ret
  1960. oldimer
  1961.         jp on_int ;заменится на код из 0x0038
  1962.         jp 0x0038+3
  1963.  
  1964. on_int
  1965. ;restore stack with de
  1966.         EX DE,HL
  1967.         EX (SP),HL ;de="hl", в стеке "de"
  1968.         LD (on_int_jp),HL
  1969.         LD (on_int_sp),SP
  1970.         LD SP,INTSTACK
  1971.         ex de,hl ;hl="hl"
  1972.  
  1973.         call oldimer ;ei
  1974.  
  1975. on_int_sp=$+1
  1976.         ld sp,0
  1977.         pop de
  1978.         ;ei
  1979. on_int_jp=$+1
  1980.         jp 0
  1981.  
  1982. curpicwid
  1983.         dw 0
  1984. curpichgt
  1985.         dw 0
  1986. curpichgt_visible
  1987.         dw 0
  1988.  
  1989. downloadfilename
  1990.         db "download.fil",0
  1991.  
  1992. tfileprotocol
  1993.         db "file://",0
  1994. thttpprotocol
  1995.         db "http://",0
  1996. tgopherprotocol
  1997.         db "gopher://",0
  1998. thttpsprotocol
  1999.         db "https://",0
  2000.  
  2001. linkbuf
  2002.         ds MAXLINKSZ+1
  2003.        
  2004. curfulllink
  2005.         ds MAXLINKSZ+1
  2006.  
  2007.         include "htmlview.asm"
  2008.         include "html.asm"
  2009.         include "prvirt.asm"
  2010.         include "mempgs.asm"
  2011.         include "dynmem.asm"
  2012.         include "../_sdk/file.asm"
  2013.         include "gif.asm"
  2014.         include "drawmc.asm"
  2015.         include "editline.asm"
  2016.  
  2017.         align 256
  2018. textpages
  2019.         ds 256
  2020. ;TODO ещё отдельно gfxpages (чтобы можно было удалять RGB после конверсии)
  2021.  
  2022.         align 256
  2023. tmaxaxis ;maxdistdiv_fromattr[256], min_fromattr[256], maxaxis_fromattr[256]
  2024.         incbin "tmaxaxis"
  2025.  
  2026.         ;align 256 ;непосредственно после tmaxaxis
  2027. t64to16ink
  2028.         incbin "t64to16i"
  2029. chrbuf
  2030.         ds 8 ;R
  2031. chrbufG=$&0xff
  2032.         ds 8 ;G
  2033.         ds 8 ;B
  2034.         ds 256-64-24-64
  2035. t64to16paper
  2036.         incbin "t64to16p"
  2037.        
  2038. twinto866
  2039.         incbin "../_sdk/codepage/winto866"
  2040.  
  2041. endcode=$
  2042.  
  2043.         ds end1-$
  2044.         display "free for code=",$-endcode
  2045.  
  2046.         ds 0x4000-$ ;stack
  2047.         align 256
  2048. fnt
  2049.         incbin "1125vert.fnt"
  2050.         include "http.asm"
  2051.         include "prmc.asm"
  2052.         include "jpeg.asm"
  2053.         include "png.asm"
  2054. depkbeg=$
  2055. initCRC
  2056. CRC32_
  2057.         ret
  2058. saveblock
  2059. savelastblock
  2060.         push af
  2061.         push bc
  2062.         push de
  2063.         push hl
  2064. ;TODO ускорить
  2065.         ld de,depkbuf        
  2066. pngdepktoaddr=$+1
  2067.         ld hl,0
  2068. pngdepktoaddrHSB=$+1
  2069.         ld a,0
  2070.         ld bc,(Z6546) ;сколько байт сохранить
  2071.         ld (TD198),bc ;сколько байт сохраняли
  2072.  
  2073.         inc bc
  2074.         jr saveblock0_go
  2075. ;адрес 0x7e00..0xffff
  2076. saveblock0
  2077.         push bc
  2078.          push af
  2079.          call gifsetpgLZW
  2080.          pop af
  2081.         ex de,hl
  2082.         ld c,(hl)
  2083.         inc hl
  2084.         ex de,hl
  2085.         call writebyte
  2086.         pop bc
  2087. saveblock0_go
  2088.         dec hl
  2089.         cpi
  2090.         jp pe,saveblock0
  2091.         ld (pngdepktoaddr),hl
  2092.         ld (pngdepktoaddrHSB),a
  2093.          call gifsetpgLZW
  2094.  
  2095.         ld hl,0
  2096.         ld (Z6546),hl
  2097.         pop hl
  2098.         pop de
  2099.         pop bc
  2100.         pop af
  2101.         ret
  2102. depkqerror=ERROR        
  2103. ziptrees
  2104.         ds 0xa60 + 2*288
  2105.         include "../pkunzip/depk.asm"
  2106.  
  2107.         ;display "depk size=",$-depkbeg
  2108.  
  2109. wgetfilename
  2110.         db "wget.com",0
  2111.  
  2112.         include "init.asm"
  2113.  
  2114. free2=end2-$;0x8000-$
  2115.         display "free for code in 0x4000=",free2
  2116.         ds 0x8000-$
  2117.  
  2118.         incbin "tdiv"
  2119. ;0xc000
  2120.         include "svg.asm"
  2121.         display "end=",$
  2122.  
  2123. cmd_end
  2124.         ;display "Size ",/d,cmd_end-cmd_begin," bytes"
  2125.  
  2126.         savebin "browser.com",cmd_begin,cmd_end-cmd_begin
  2127.  
  2128.         LABELSLIST "../../us/user.l"
  2129.