Subversion Repositories NedoOS

Rev

Rev 61 | Rev 403 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1. WORDBUFSIZE=128
  2.  
  3. CBOLD=1
  4. CITALIC=1;0x87;add a,a
  5. CUNDERLINE=1;0x2f;cpl
  6. CSTROKE=1;0xff
  7. CLINK=2
  8. CLINKIMG=4
  9. CMARK=8
  10. ;TODO visited link
  11.  
  12.  
  13.  
  14. loadhtml
  15.         push af ;first char
  16. ;skip spaces and line breaks
  17.         cp 0xef ;hippiman.16mb.com эрўшэрхЄё▀ ё ef bb bf (UTF-8 BOM)
  18.         jr z,loadhtml_html
  19.         call htmlskipspaces_go
  20.          cp '<'
  21. loadhtml_html
  22.          ld a,1
  23.          jr nz,$+3 ;not html
  24.          xor a ;html
  25.          ld (ispre),a
  26.          ;xor a
  27.          ld (printableflag),a ;header is invisible for html
  28. defaultunicodeflag=$+1
  29.          xor 1 ;ld a,1 ;utf-8 by default for html, windows-1251 for text
  30.          ld (utf8flag),a
  31.         call setdefaultfontweight
  32.  
  33.         xor a
  34.         ld (laststringx),a
  35.         ld h,a
  36.         ld l,a ;0
  37.         ld (laststringy),hl
  38.         ld (curprintvirtualy),hl
  39.  
  40.         dec a
  41.         dec hl
  42.         ld (lastpointer),hl
  43.         ld (lastpointerHSB),a
  44.         ld (last2pointer),hl
  45.         ld (last2pointerHSB),a
  46.         ld (firstpointer),hl
  47.         ld (firstpointerHSB),a
  48.         ld (first2pointer),hl
  49.         ld (first2pointerHSB),a
  50.  
  51.         call initstringbuf1 ;buf2 шэшЎшрышчшЁєхЄё  т Є¤ух a/img ;ёюфхЁцшЄ setfontweight
  52.        
  53.         ;ld de,0
  54.         ;call setxymc_stateful
  55.         pop af;ld a,'<' ;already read
  56.          ;jr $
  57.         call loadhtml_mainloop_go
  58.          call prcharvirtual_crlf_stateful
  59.          ;ld a,-2
  60.          ;in a,(-2)
  61.          ;rra
  62.          ;jr nc,$
  63.          ;jr $
  64.         call closestream
  65.         jp htmlview ;can exit to browser_go via Enter
  66.        
  67. loadhtml_mainloop_mangledcharq
  68.         call prcharvirtual_stateful
  69. loadhtml_mainloop
  70.         rdbyte
  71. loadhtml_mainloop_go
  72.          ;push af
  73.          ;call prcharvirtual_stateful
  74.          ;pop af
  75.          cp '<'+1
  76.          jp nc,loadhtml_mainloop_mangledcharq ;speedup
  77.         or a
  78.         ret z
  79.         cp '<'
  80.         jr z,loadhtml_mainloop_tag
  81.         cp '&'
  82.         jr z,loadhtml_mainloop_mangledchar
  83.         cp 0x0d
  84.         jr z,loadhtml_checkpremainloop
  85.         cp 0x0a
  86.         jr z,loadhtml_checkpremainloop
  87.         cp ' '
  88.         jr z,loadhtml_checkpremainloop
  89.         cp 0x09
  90.         jr z,loadhtml_checkpremainloop
  91.         jp loadhtml_mainloop_mangledcharq
  92. loadhtml_checkpremainloop
  93. ispre=$+1
  94.         ld b,0        
  95.         djnz loadhtml_spacemainloop
  96.          ;jr $
  97.         jr loadhtml_mainloop_mangledcharq
  98.  
  99. loadhtml_spacemainloop
  100.          ;jr $
  101.         ;call countlinewidth
  102.         ;ld a,h
  103.         ;or l ;р Єрь єцх єяЁрты ■∙шх ъюф√
  104.         ld a,(prcharvirtual_stateful_x)
  105.         or a
  106.         jr z,loadhtml_mainloop
  107.         ld a,' '
  108.         jr loadhtml_mainloop_mangledcharq
  109.  
  110. loadhtml_mainloop_mangledchar
  111. ;read until ;
  112.         ld hl,mangledcharslist
  113.         ld de,wordbuf
  114.         call getword_mangledchar ;hl=terminator/space addr,a=char
  115.         ld hl,mangledcharslist
  116. mangledcharstrcp0
  117.         ld a,(hl) ;decoded char
  118.         inc hl
  119.         or a
  120.         jr z,mangledchar_error
  121.         ld de,wordbuf
  122.         push hl
  123.         call strcp
  124.         pop hl
  125.         jr nz,mangledcharstrcp_fail
  126.         dec hl
  127.         ld a,(hl) ;decoded char
  128.         jp loadhtml_mainloop_mangledcharq
  129. mangledcharstrcp_fail
  130.         ld b,-1 ;ўЄюс√ Єюўэю эрщЄш ЄхЁьшэрЄюЁ
  131.         xor a
  132.         cpir ;эрщф╕ь юс чрЄхы№эю
  133.         jr mangledcharstrcp0
  134. mangledchar_error=loadhtml_mainloop
  135.        
  136. loadhtml_mainloop_tag
  137.         call RDBYTE;rdbyte
  138.         ld (loadhtml_tagcloser),a
  139.         cp '/'
  140.         jr nz,executetag
  141.         call RDBYTE;rdbyte
  142. executetag
  143.         ld de,wordbuf
  144.         call getword_tag_go ;hl=terminator/space addr,a=char ;first char already read
  145.         ld (executetag_endchar),a
  146.        
  147.         if 1==0
  148.          ld hl,wordbuf
  149. executetag_typetag0
  150.          ld a,(hl)
  151.          or a
  152.          jr z,executetag_typetagq
  153.          inc hl
  154.          push hl
  155.          call prcharvirtual_stateful
  156.          pop hl
  157.          jr executetag_typetag0
  158. executetag_typetagq
  159.         endif
  160.        
  161.         ;cp '>'
  162.         ;call skipspaces
  163.         ;ld (execcmd_pars),hl
  164.         ld hl,tagslist ;list of internal commands
  165. strcpexec0
  166.         ld c,(hl)
  167.         inc hl
  168.         ld b,(hl)
  169.         inc hl
  170.         ld a,b
  171.         cp -1
  172.         jr z,executetag_error ;a!=0: no such internal command
  173.         ld de,wordbuf
  174.         push hl
  175.         call strcp
  176.         pop hl
  177.         jr nz,strcpexec_fail
  178.         ld h,b
  179.         ld l,c
  180. loadhtml_tagcloser=$+1
  181.         ld a,0
  182.         cp '/'
  183.         call jphl ;execute command (Z=closing tag)
  184.  
  185. ;TODO read the rest of the tag?
  186.        
  187.         jp loadhtml_mainloop
  188. jphl
  189.         jp (hl) ;run internal command
  190. strcpexec_fail
  191.         ld b,-1 ;ўЄюс√ Єюўэю эрщЄш ЄхЁьшэрЄюЁ
  192.         xor a
  193.         cpir ;эрщф╕ь юс чрЄхы№эю
  194.         jr strcpexec0
  195.  
  196. executetag_error
  197. ;no such tag
  198.          call skiprestoftag
  199.         jp loadhtml_mainloop
  200.        
  201.        
  202. mangledcharslist
  203.         db "&"
  204.         db "amp",0
  205.         db "<"
  206.         db "lt",0
  207.         db ">"
  208.         db "gt",0
  209.         db " "
  210.         db "nbsp",0
  211.         db 34
  212.         db "quote",0
  213.         db 34
  214.         db "lquote",0
  215.         db 34
  216.         db "rquote",0
  217.  
  218.         db 0 ;end of mangled chars list
  219.  
  220. tagslist
  221.         dw tag_p
  222.         db "p",0
  223.         dw tag_pre
  224.         db "pre",0
  225.         dw tag_code
  226.         db "code",0
  227.         dw tag_div
  228.         db "div",0
  229.         dw tag_ul
  230.         db "ul",0
  231.         dw tag_li
  232.         db "li",0
  233.         dw tag_th
  234.         db "th",0
  235.         dw tag_center
  236.         db "center",0 ;deprecated
  237.         dw tag_h1
  238.         db "h1",0
  239.         dw tag_h2
  240.         db "h2",0
  241.         dw tag_h3
  242.         db "h3",0
  243.         dw tag_h4
  244.         db "h4",0
  245.         dw tag_h5
  246.         db "h5",0
  247.         dw tag_h6
  248.         db "h6",0
  249.         dw tag_ins
  250.         db "ins",0
  251.         dw tag_u
  252.         db "u",0
  253.         dw tag_b
  254.         db "b",0
  255.         dw tag_em
  256.         db "em",0
  257.         dw tag_cite
  258.         db "cite",0
  259.         dw tag_i
  260.         db "i",0
  261.         dw tag_del
  262.         db "del",0
  263.         dw tag_s
  264.         db "s",0
  265.         dw tag_a
  266.         db "a",0
  267.         dw tag_strong
  268.         db "strong",0
  269.         dw tag_img
  270.         db "img",0
  271.         dw tag_html
  272.         db "html",0
  273.         dw tag_head
  274.         db "head",0
  275.         dw tag_meta
  276.         db "meta",0
  277.         dw tag_title
  278.         db "title",0
  279.         dw tag_body
  280.         db "body",0
  281.         dw tag_font
  282.         db "font",0
  283.         dw tag_br
  284.         db "br",0
  285.         dw tag_table
  286.         db "table",0
  287.         dw tag_tbody
  288.         db "tbody",0
  289.         dw tag_tr
  290.         db "tr",0
  291.         dw tag_td
  292.         db "td",0
  293.         dw tag_mark
  294.         db "mark",0
  295.         dw tag_span
  296.         db "span",0
  297.         dw tag_script
  298.         db "script",0
  299.         dw tag_doctype
  300.         db "!doctype",0
  301.         dw tag_COMMENT
  302.         db "!--",0
  303.         dw tag_link
  304.         db "link",0
  305.         dw tag_style
  306.         db "style",0
  307.         dw tag_frameset
  308.         db "frameset",0
  309.         dw tag_frame
  310.         db "frame",0
  311.         dw tag_iframe
  312.         db "iframe",0
  313.         dw tag_label
  314.         db "label",0
  315.         dw tag_form
  316.         db "form",0
  317.         dw tag_input
  318.         db "input",0
  319.         dw tag_dl ;forum.nedopc.com
  320.         db "dl",0
  321.         dw tag_dd ;forum.nedopc.com
  322.         db "dd",0
  323.         dw tag_dt ;forum.nedopc.com
  324.         db "dt",0
  325.        
  326.         dw -1 ;end of tags list
  327.        
  328. ;Z=closing tag
  329.  
  330. tag_label
  331. ;<label for="searchInput">╧юшёъ</label>
  332. ;TODO
  333.         jp skiprestoftag
  334.  
  335. tag_form
  336. tag_input
  337. ;<form action="http://speccy.info/w/index.php" id="searchform">
  338. ;<input type="hidden" name="title" value="╤ыєцхсэр :╧юшёъ">
  339. ;<input type="search" name="search" placeholder="╧юшёъ" title="╚ёърЄ№ т SpeccyWiki [shift-esc-f]" accesskey="f" id="searchInput" autocomplete="off">
  340. ;<input type="submit" name="go" value="╧хЁхщЄш" title="╧хЁхщЄш ъ ёЄЁрэшЎх, шьх■∙хщ т ЄюўэюёЄш Єръюх эрчтрэшх" id="searchGoButton" class="searchButton">&nbsp;
  341. ;<input type="submit" name="fulltext" value="═рщЄш" title="═рщЄш ёЄЁрэшЎ√, ёюфхЁцр∙шх єърчрээ√щ ЄхъёЄ" id="mw-searchButton" class="searchButton">
  342. ;</form>
  343. ;TODO
  344.         jp skiprestoftag
  345.  
  346. tag_p
  347.         call prcharvirtual_crlf_stateful ;opening&closing
  348.         jp skiprestoftag
  349.  
  350. tag_code
  351. tag_pre
  352.         push af ;z/nz
  353.         call prcharvirtual_crlf_stateful ;opening&closing
  354.         call htmlinitbody ;zxdn Ёхъырьр т plain text
  355.         pop af ;z/nz
  356.         ld hl,ispre
  357.         ld a,1
  358.         jr tag_u_b_i
  359.  
  360. tag_center
  361.         ld hl,iscentered
  362.         ld a,1
  363.         jr tag_u_b_i
  364.  
  365. tag_h1
  366. tag_h2
  367. tag_h3
  368. tag_h4
  369. tag_h5
  370. tag_h6
  371.         jr z,tag_b
  372.         ld a,1
  373.         ld (iscentered),a
  374.         jr tag_b
  375.  
  376. tag_mark
  377.         ld hl,curmark
  378.         ld a,CMARK
  379.         jr tag_u_b_i
  380.        
  381. tag_del
  382. tag_s
  383.         ld hl,curstroke
  384.         ld a,CSTROKE
  385.         jr tag_u_b_i
  386. tag_ins
  387. tag_u
  388.         ld hl,curunderline
  389.         ld a,CUNDERLINE
  390.         jr tag_u_b_i
  391. tag_th ;table header: TODO also center in cell
  392. tag_b
  393. tag_strong
  394.         ld hl,curbold
  395.         ld a,CBOLD
  396.         jr tag_u_b_i
  397. tag_em
  398. tag_cite
  399. tag_i
  400.         ld hl,curitalic
  401.         ld a,CITALIC
  402. tag_u_b_i
  403.         ld (hl),0
  404.         jr z,$+3 ;Z=closing tag
  405.         ld (hl),a
  406.         call setfontweight
  407.         jp skiprestoftag
  408.        
  409. tag_ul ;list
  410.         jp nz,skiprestoftag ;opening (li does newline)
  411. tag_dd ;эр lib.ru ¤Єю яхЁхтюф ёЄЁюъш
  412. tag_div
  413. tag_table
  414. tag_br
  415.         call prcharvirtual_crlf_stateful
  416.         jp skiprestoftag
  417. tag_tr
  418. ;only closing tr works as crlf
  419.         call z,prcharvirtual_crlf_stateful
  420.         jp skiprestoftag
  421. tag_td
  422. ;only closing td works as tab
  423.         call z,prcharvirtual_tab_stateful
  424.         jp skiprestoftag
  425.  
  426. tag_head
  427. ;TODO read all tags inside (meta, title)
  428.         jp skiprestoftag
  429.  
  430. tag_iframe
  431. tag_frame
  432. ;TODO find src="..." (now we find last param)
  433.         ;jr $
  434.         call htmlskipspaces
  435. tag_frame0
  436.         ;ld a,(prcharvirtual_stateful_x)
  437.         ;jr $
  438.        
  439.         ld a,(executetag_endchar)
  440.         call htmlskipspaces_go
  441.  
  442.         ld de,wordbuf
  443.         call getword_param_go ;т ярЁрьхЄЁх ьюуєЄ с√Є№ чрърт√ўхээ√х яЁюсхы√!
  444.         ld (executetag_endchar),a
  445.         or a
  446.         ret z
  447.         cp '>'
  448.         jr nz,tag_frame0
  449.  
  450.         ld a,CLINKIMG
  451.         ld (curlinkimg),a
  452.         call setfontweight
  453.          call rememberhrefyxposition
  454.         call initstringbuf2
  455.  
  456.         ld a,'['
  457.         call prcharvirtual_stateful
  458. ;read link to stringbuf2 until doublequote
  459. ;print it
  460.         ld hl,wordbuf+5 ;after src="
  461. tag_frame_typetag0
  462.          ld a,(hl)
  463.          or a
  464.          jp z,tag_frame_typetagq
  465.          cp 34
  466.          jp z,tag_frame_typetagq
  467.           cp "'"
  468.           jp z,tag_frame_typetagq
  469.          inc hl
  470.          push hl
  471.          push af
  472.          call prcharvirtual_stateful
  473.          pop af
  474.         call printtostringbuf2
  475.          pop hl
  476.          jr tag_frame_typetag0
  477.  
  478. inithref
  479.          ld a,(curlink)
  480.          or a
  481.          call nz,savestringbuf2 ;хёыш img тэєЄЁш a
  482.         call initstringbuf2
  483.         ;ld a,CLINK
  484.         ;ld (curlink),a
  485.         call setfontweight
  486.          jp rememberhrefyxposition
  487.          
  488. tag_img
  489.         jp z,skiprestoftag ;Z=closing tag (does nothing)
  490.         ;jr $
  491.         call htmlskipspaces
  492. tag_img_readsrc
  493.         call htmlskipspaces_go
  494.         ld hl,tsrc
  495.         call eatgivenword_go
  496.         ;jr nz,tag_img_srcfail
  497.        
  498.         jr z,tag_img_srcq
  499. tag_img_srcfail
  500.         call htmlskipparam
  501.           or a
  502.           ret z
  503.          cp '>'
  504.         jr nz,tag_img_readsrc
  505.         jr tag_img_opening_readaltq
  506. tag_img_srcq
  507.        
  508.         ;ld hl,tsrc
  509.         ;call eatgivenword_go
  510.         ;jr nz,tag_img_opening_fail
  511. ;read link to stringbuf2 until doublequote
  512.         ld a,CLINKIMG
  513.         ld (curlinkimg),a
  514.         call inithref
  515.        
  516.         call RDBYTE;rdbyte
  517.          cp "'"
  518.          jr z,tag_img_opening_read0
  519.         cp 34
  520.         jr nz,tag_img_opening_read_go
  521.  
  522. tag_img_opening_read0
  523.         call RDBYTE;rdbyte
  524. tag_img_opening_read_go
  525.         or a
  526.         ret z
  527.         cp 34
  528.         jr z,tag_img_opening_readq
  529.          cp "'"
  530.          jr z,tag_img_opening_readq
  531.           cp " "
  532.           jr z,tag_img_opening_readq
  533.          ;push af
  534.          ;call prcharvirtual_stateful
  535.          ;pop af
  536.         call printtostringbuf2
  537.         jr tag_img_opening_read0
  538. tag_img_opening_readq
  539. tag_img_opening_fail
  540. ;a=last char read=quote
  541.          ;jr $
  542.         call htmlskipspaces
  543.         push af
  544.         ld a,'['
  545.         call prcharvirtual_stateful
  546.         pop af
  547. tag_img_opening_readalt
  548. ;a=last char read
  549.         call htmlskipspaces_go
  550.         ld hl,talt
  551.         call eatgivenword_go
  552.         jr nz,tag_img_opening_altfail
  553.        
  554.         call RDBYTE;rdbyte
  555.          cp "'"
  556.          jr z,tag_img_opening_readalt0
  557.         cp 34
  558.         jr nz,tag_img_opening_readalt_go
  559.  
  560. tag_img_opening_readalt0
  561.         call RDBYTE;rdbyte
  562. tag_img_opening_readalt_go
  563.         or a
  564.         ret z
  565.         cp 34
  566.         jr z,tag_img_opening_readaltq
  567.          cp "'"
  568.          jr z,tag_img_opening_readaltq
  569. ;TODO mangled symbols
  570.         call prcharvirtual_stateful
  571.         jr tag_img_opening_readalt0
  572. tag_img_opening_altfail
  573. ;find alt in next parameters
  574.         call htmlskipparam
  575.           or a
  576.           ret z
  577.          cp '>'
  578.         jr nz,tag_img_opening_readalt
  579. tag_img_opening_readaltq
  580.          ld (executetag_endchar),a
  581. tag_frame_typetagq ;TODO яюўхьє т√°х ё·хфрхЄ яхЁт√щ ЇЁхщь atmturbo?
  582.         ld a,']'
  583.         call prcharvirtual_stateful
  584.         xor a
  585.         ld (curlinkimg),a
  586.         jr closehrefq
  587.         ;call prcharvirtual_stateful
  588.         ;call savestringbuf2 ;after printing ']' to count full size
  589.         ;xor a
  590.         ;ld (curlink),a
  591.         ;call setfontweight
  592.         ;jp skiprestoftag
  593.  
  594. tag_a
  595.         jr nz,tag_a_opening
  596.         ld a,'}'
  597.         call prcharvirtual_stateful
  598.         xor a
  599.         ld (curlink),a
  600. closehrefq
  601.         call savestringbuf2 ;after printing '}' to count full size
  602.         ;xor a
  603.         ;ld (curlink),a
  604.         call setfontweight
  605.         jp skiprestoftag
  606. tag_a_opening
  607.          ;jr $
  608.         call htmlskipspaces
  609. tag_a_opening_readhref
  610.         call htmlskipspaces_go
  611.         ld hl,thref
  612.         call eatgivenword_go
  613.         jr nz,tag_a_opening_hreffail
  614.  
  615.         ld a,CLINK
  616.         ld (curlink),a
  617.         call inithref        
  618.        
  619.         ;zxdn: no quotes in href
  620.         call RDBYTE;rdbyte
  621.          cp "'"
  622.          jr z,tag_a_opening_read0
  623.         cp 34
  624.         jr nz,tag_a_opening_read_go
  625.  
  626. ;read link to stringbuf2 until doublequote
  627. tag_a_opening_read0
  628.         call RDBYTE;rdbyte
  629. tag_a_opening_read_go
  630.         or a
  631.         ret z
  632.         cp '>'
  633.         jr z,tag_a_opening_readq
  634.         cp 34
  635.         jr z,tag_a_opening_readq
  636.          cp "'"
  637.          jr z,tag_a_opening_readq
  638.         cp 0x0d
  639.         jr z,tag_a_opening_read0 ;lib.ru
  640.         cp 0x0a
  641.         jr z,tag_a_opening_read0 ;lib.ru
  642.          if 1==0
  643.          cp '&'
  644.          jr nz,tag_a_opening_read0ok
  645.         call printtostringbuf2
  646. ;TODO яЁютхЁшЄ№ &amp; (forum.nedopc.com)
  647.         call RDBYTE;rdbyte
  648.          cp 'a'
  649.          jr nz,tag_a_opening_read0ok
  650.         call RDBYTE;rdbyte
  651.         call RDBYTE;rdbyte
  652.         call RDBYTE;rdbyte        
  653.         jr tag_a_opening_read0
  654. tag_a_opening_read0ok
  655.          endif
  656.          ;push af
  657.          ;call prcharvirtual_stateful
  658.          ;pop af
  659.         call printtostringbuf2
  660.         jr tag_a_opening_read0
  661. tag_a_opening_hreffail
  662. ;find href in next parameters
  663.         call htmlskipparam
  664.           or a
  665.           ret z
  666.          cp '>'
  667.         jr nz,tag_a_opening_readhref
  668. tag_a_opening_readq
  669.          ld (executetag_endchar),a
  670. tag_a_opening_fail
  671.         ld a,'{'
  672.         call prcharvirtual_stateful
  673.         jp skiprestoftag
  674.  
  675.  
  676. ;skip until space/>/"/EOF
  677. ;if ", skip until another ", then skip space/>
  678. ;a=last char read
  679. ;out: a=last char (space/>/")
  680. htmlskipparam0
  681.         call RDBYTE;rdbyte
  682. htmlskipparam
  683.         or a
  684.         ret z
  685.         cp ' '
  686.         ret z
  687.         cp '>'
  688.         ret z
  689.         cp 34
  690.         jr nz,htmlskipparam0
  691. htmlskipparamquote0
  692.         call RDBYTE;rdbyte
  693.         or a
  694.         ret z
  695.         cp 34
  696.         jr nz,htmlskipparamquote0
  697.         jp RDBYTE;rdbyte ;skip space/>        
  698.  
  699. eatgivenword
  700. ;hl=word (asciiz)
  701. ;out: Z=OK (or else a=last char read)
  702. eatgivenword0
  703.         ld a,(hl)
  704.         or a
  705.         ret z
  706.         call RDBYTE;rdbyte
  707.         ;ld (executetag_endchar),a
  708. eatgivenword_go
  709.          or 0x20
  710.         cp (hl)
  711.         inc hl
  712.         jr z,eatgivenword0
  713.         ld (executetag_endchar),a
  714.         ret ;fail
  715.  
  716. getword_tag
  717. ;hl=string
  718. ;de=wordbuf
  719. ;out: hl=terminator/space/> addr, a=terminator/space/> char
  720. ;TODO яЁютхЁ Є№ яхЁхяюыэхэшх WORDBUFSIZE
  721. getword_tag0
  722.         call RDBYTE;rdbyte
  723. getword_tag_go
  724.         or a
  725.         jr z,getword_tagq
  726.         cp ' '
  727.         jr z,getword_tagq
  728.         cp '>'
  729.         jr z,getword_tagq
  730.          or 0x20
  731.         ld (de),a
  732.         inc de
  733.         jr getword_tag0
  734. getword_tagq
  735.         push af
  736.         xor a
  737.         ld (de),a
  738.         pop af
  739.         ret
  740.  
  741.  
  742. getword_mangledchar
  743. ;hl=string
  744. ;de=wordbuf
  745. ;out: hl=terminator/space/; addr, a=terminator/space/; char
  746. ;TODO яЁютхЁ Є№ яхЁхяюыэхэшх WORDBUFSIZE
  747. getword_mangledchar0
  748.         call RDBYTE;rdbyte
  749.         ;or a
  750.         ;jr z,getword_mangledcharq
  751.          cp "A"
  752.          jr c,getword_mangledcharq
  753.         ;cp ';'
  754.         ;jr z,getword_mangledcharq
  755.         ;cp '#'
  756.         ;jr z,getword_mangledcharq ;lib.ru &#97&#102&#114&#97&#110&#105&#117&#115&#64&#110&#101&#119&#109&#97&#105&#108&#46&#114&#117
  757.         ld (de),a
  758.         inc de
  759.         jr getword_mangledchar0
  760. getword_mangledcharq
  761.         push af
  762.         xor a
  763.         ld (de),a
  764.         pop af
  765.         ret
  766.  
  767. ;getword_param
  768. ;hl=string
  769. ;de=wordbuf
  770. ;out: hl=terminator/space/; addr, a=terminator/space/; char
  771. ;TODO яЁютхЁ Є№ яхЁхяюыэхэшх WORDBUFSIZE
  772. getword_param0
  773.         call RDBYTE;rdbyte
  774. getword_param_go ;т ярЁрьхЄЁх ьюуєЄ с√Є№ чрърт√ўхээ√х яЁюсхы√!
  775.         or a
  776.         jr z,getword_paramq
  777.          cp "'"
  778.          jr z,getword_paramquote
  779.          cp 34
  780.          jr z,getword_paramquote
  781.         cp ' '
  782.         jr z,getword_paramspaceq
  783.         ;cp ';'
  784.         ;jr z,getword_paramcharq
  785.         ;cp '#'
  786.         ;jr z,getword_paramcharq ;lib.ru &#97&#102&#114&#97&#110&#105&#117&#115&#64&#110&#101&#119&#109&#97&#105&#108&#46&#114&#117
  787.         cp '>'
  788.         jr z,getword_paramq
  789. getword_param0ok
  790.          or 0x20
  791.         ld (de),a
  792.         inc de
  793.         jr getword_param0
  794. getword_paramquote
  795.         ld c,a
  796. getword_paramquote0
  797.         ld (de),a
  798.         inc de
  799.         call RDBYTE;rdbyte
  800.         cp c
  801.         jr nz,getword_paramquote0 ;TODO р хёыш юэр эшъюуфр эх чръЁюхЄё▀???
  802.         jr getword_param0ok
  803. getword_paramspaceq
  804. ;шыш ЄєЄ яЁютхЁ▀Є№, т ърт√ўърї ыш ь√?
  805. getword_paramq
  806.         push af
  807.         xor a
  808.         ld (de),a
  809.         pop af
  810.         ret
  811.  
  812.  
  813.        
  814. strcp
  815. ;hl=s1
  816. ;de=s2
  817. ;out: Z (equal, hl=terminator of s1+1, de=terminator of s2+1), NZ (not equal, hl=erroraddr in s1, de=erroraddr in s2)
  818. strcp0.
  819.         ld a,[de] ;s2
  820.         cp [hl] ;s1
  821.         ret nz
  822.         inc hl
  823.         inc de
  824.         or a
  825.         jr nz,strcp0.
  826.         ret ;z
  827.  
  828. strcp_tillde0
  829. ;hl=s1
  830. ;de=s2
  831. ;out: Z (equal, hl=terminator of s1+1, de=terminator of s2+1), NZ (not equal, hl=erroraddr in s1, de=erroraddr in s2)
  832. strcp_tillde0_0.
  833.         ld a,[de] ;s2
  834.         or a
  835.         ret z
  836.         cp [hl] ;s1
  837.         ret nz
  838.         inc hl
  839.         inc de
  840.         jr strcp_tillde0_0.
  841.  
  842.        
  843. thref
  844.         db "href=",0
  845. tsrc
  846.         db "src=",0
  847. talt
  848.         db "alt=",0
  849.        
  850. rememberhrefyxposition
  851.         ld a,(prcharvirtual_stateful_x)
  852.         ld (hrefxposition),a
  853.         ld hl,(curprintvirtualy)
  854.         ld (hrefyposition),hl
  855.         ret
  856.  
  857. tag_title
  858. ;not used, because header is skipped (TODO)
  859.         ;jp z,tag_titleclose
  860.         jp nz,tag_h1 ;open
  861. ;tag_titleclose
  862.          ;ld a,1
  863.          ;ld (utf8flag),a ;эхы№ч▀, Є.ъ. title яюёых charset
  864.         call prcharvirtual_crlf_stateful ;</title> forces newline
  865.         xor a ;z
  866.         jp tag_h1
  867.  
  868. tag_li ;list line (no closing tag)
  869.         jp z,skiprestoftag ;closing
  870.         call prcharvirtual_crlf_stateful
  871.         ld a,'*';'Х';'*' ;TODO ё єў▐Єюь UTF8
  872.         call prcharvirtual_stateful
  873.         ld a,' '
  874.         call prcharvirtual_stateful
  875.         jp skiprestoftag
  876.  
  877. tag_meta
  878. ;TODO find "charset=UTF-8" or "charset=windows-1251"
  879. tag_meta0
  880.         ld b,a
  881.         push bc
  882.         call RDBYTE;rdbyte
  883.         pop bc
  884.         or a
  885.         ret z
  886.         cp '>'
  887.         jp z,skiprestoftag0
  888.         or 0x20
  889.         cp 'w'
  890.         jr nz,tag_meta0
  891.         ld a,b
  892.         cp '='
  893.          ld a,'w'
  894.          jr nz,tag_meta0
  895.          xor a;ld a,0
  896.          ld (utf8flag),a
  897.         jp skiprestoftag_go
  898.  
  899. tag_style
  900. tag_script
  901. ;TODO skip until </script>
  902. tag_script0
  903.         ld b,a
  904.         push bc
  905.         call RDBYTE;rdbyte
  906.         pop bc
  907.         or a
  908.         ret z
  909.         cp '/'
  910.         jr nz,tag_script0
  911.         ld a,b
  912.         cp '<'
  913.          ld a,'/'
  914.         jr nz,tag_script0
  915.         jp skiprestoftag_go
  916.  
  917. htmlskipspaces
  918. htmlskipspaces0
  919.         call RDBYTE;rdbyte
  920. htmlskipspaces_go
  921.         cp ' '
  922.         jr z,htmlskipspaces0
  923.         cp 0x0d
  924.         jr z,htmlskipspaces0
  925.         cp 0x0a
  926.         jr z,htmlskipspaces0
  927.         ld (executetag_endchar),a
  928.         ret
  929.        
  930. tag_font
  931. ;TODO push old font/pop old font
  932.  
  933. tag_link
  934. ;TODO find href
  935.  
  936. tag_dl
  937. tag_dt
  938. tag_COMMENT
  939. tag_doctype
  940. tag_span
  941. tag_html
  942. tag_tbody
  943.         jp skiprestoftag
  944.  
  945. tag_frameset ;before body
  946. tag_body
  947.         call htmlinitbody
  948.         jp skiprestoftag
  949.  
  950. htmlinitbody
  951.          xor a
  952.          ld (iscentered),a
  953.          inc a ;ld a,1
  954.          ld (printableflag),a
  955. ;¤Єш ьрэшяєы Ўшш чрЄЁєЄ єцх эряхўрЄрээ√х ЇЁхщь√:
  956.          ;call prcharvirtual_x0
  957.          call setdefaultfontweight
  958.          jp setfontweight;call initstringbuf1 ;схч ¤Єюую эх яш°хЄ ъюф√ єёЄрэютъш ЎтхЄр
  959.        
  960. skiprestoftag
  961. ;we can be at >/space/EOF (in executetag_endchar)
  962. executetag_endchar=$+1
  963.         ld a,0
  964. skiprestoftag0
  965.         cp '>'
  966.         ret z
  967. skiprestoftag_go
  968.         call RDBYTE;rdbyte
  969.         or a
  970.         ret z
  971.         jr skiprestoftag0
  972.  
  973.        
  974. wordbuf
  975.         ds WORDBUFSIZE
  976.