Subversion Repositories NedoOS

Rev

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

  1. ;TODO в режиме wrap:
  2. ;- при стирании перерисовывать последнюю строку и всё за ней, если она уничтожена
  3. ;- при добавлении перерисовывать строки ниже, если изменилось число строк
  4. ;a) отслеживать последнюю позицию при печати (не годится для word wrap)
  5. ;б) отслеживать длину строки до и после (не годится для word wrap)
  6. ;в) отслеживать число подстрок до и после
  7. ;г) отслеживать список адресов всех подстрок на экране
  8.  
  9. texted_XYTOP=0x0000
  10. ;texted_HGT=24
  11. texted_WID=80
  12. _texted_PANELCOLOR=0x0700;0x38
  13.  
  14. textview
  15.         ;xor a
  16.         ;ld h,a
  17.         ;ld l,a
  18.         ;call texted_settop
  19.         ;ld (curlineaddr),hl
  20.         ;ld (curlineaddrHSB),a
  21.         ;ld hl,1
  22.         ;ld (texted_ncurline),hl
  23.         ;ld hl,0
  24.         ;ld (curxy),hl
  25.         call texted_gotobof
  26.        
  27.         call texted_panel        
  28.        
  29.         call texted_calclines
  30.  
  31. texted_redrawloop
  32.         call setredrawflag
  33. texted_mainloop
  34. texted_lineredrawflag=$
  35.         scf ;/or a
  36.         call c,texted_prcurline ;might set redrawflag
  37. texted_redrawflag=$
  38.         scf ;/or a
  39.         call c,texted_prcurpage
  40.  
  41. ;texted_waitkey_nokey
  42.         ld de,(curxy)
  43.         call nv_setxy
  44.        if 0
  45.         ld a,2
  46. mainloop_yieldkeep
  47.         ld (wasnokey),a
  48.         YIELDKEEP
  49.         ld a,55+128 ;"or a"
  50.         ld (texted_wasyield),a
  51.        endif
  52. texted_waitkey_nokey
  53.       if 0
  54.       else
  55.         YIELD
  56.       endif
  57.         GETKEY_ ;OS_GETKEYNOLANG
  58.         ;or a ;cp NOKEY ;keylang==0?
  59.         ;jr nz,texted_mainloop_keyq
  60.         ;cp c ;keynolang==0?
  61.         ;ld a,c ;keynolang
  62.         ;cp NOKEY ;TODO отличить от отсутствия фокуса nz? (не в фокусе клавиши не отдаются)
  63.         jr nz,texted_mainloop_keyq ;event
  64.         ;GETKEY_
  65.         ;jr nz,texted_mainloop_keyq ;event
  66.         ;GETKEY_
  67.         ;jr nz,texted_mainloop_keyq ;event бывает 3-символьный
  68.       if 0
  69.        ld a,(stdindatacount)
  70.        or a
  71.        jr nz,texted_mainloop
  72. ;если два раза подряд нет события, то делаем YIELD, иначе YIELDKEEP
  73. ;рисовать панельку только при отсутствии события после YIELD
  74. wasnokey=$+1
  75.         ld a,1
  76.         dec a
  77.         jr nz,mainloop_yieldkeep
  78. texted_wasyield=$
  79.         scf
  80.         jr nc,nopanel
  81.       endif
  82. texted_panelredrawflag=$
  83.         scf ;/or a
  84.         call c,texted_panel ;call c
  85.       if 0
  86.         ld de,(curxy)
  87.         call nv_setxy
  88. nopanel
  89.         YIELD
  90.         ld a,55 ;"scf"
  91.         ld (texted_wasyield),a
  92.         jr texted_waitkey_nokey
  93.       else
  94.         jr texted_mainloop
  95.       endif        
  96. texted_mainloop_keyq      
  97.  
  98.         cp key_redraw
  99.         jr z,texted_redrawloop
  100.        
  101.         ld hl,texted_mainloop
  102.         push hl
  103.         cp key_esc
  104.         jp z,texted_quit ;ret z
  105.         cp key_up
  106.         jp z,texted_up
  107.         cp key_down
  108.         jp z,texted_down
  109.         cp key_pgup
  110.         jp z,texted_pgup
  111.         cp key_pgdown
  112.         jp z,texted_pgdown
  113.          cp key_F10;extS
  114.          jp z,texted_changeencoding
  115.         cp key_home
  116.         jp z,texted_home
  117.         cp key_end
  118.         jp z,texted_end
  119.         cp key_left
  120.         jp z,texted_left
  121.         cp key_right
  122.         jp z,texted_right
  123.         cp key_sspgup;ext3
  124.         jp z,texted_gotobof;home
  125.         cp key_sspgdown;ext4
  126.         jp z,texted_gotoeof;end
  127.         ;cp extW
  128.         ;jp z,texted_wrap
  129.          cp key_ins
  130.          jp z,texted_wrap
  131.         cp key_backspace
  132.         jp z,texted_backspace
  133.         cp key_del
  134.         jp z,texted_del
  135.         cp key_enter
  136.         jp z,texted_enter
  137.         cp key_csenter
  138.         jp z,texted_save
  139.         cp key_F1
  140.         jp z,texted_help
  141.         cp key_F2
  142.         jp z,texted_save
  143.         cp key_F9
  144.         jp z,texted_build
  145.         cp 0x20
  146.         ret c ;прочие системные кнопки не нужны
  147. typein
  148.         ld c,a
  149.         ld a,(texted_prline_recodepatch)
  150.         or a
  151.         jr z,typein_nowin
  152.        ld h,t866towin/256
  153.        ld l,c
  154.        ld c,(hl)
  155. typein_nowin
  156.         call linesize_minus_x ;sz<x = error
  157.         call c,insert_minushl_spaces
  158.         call calccursoraddr
  159.         call insertbyte
  160. ;TODO wrap (reprint screen if needed)        
  161.         call setlineredrawflag;texted_prcurpage
  162.         jp texted_right
  163.  
  164. linesize_minus_x
  165. ;sz<x = CY
  166.         call calccurlinesz ;hl=sz
  167.         ex de,hl
  168.         call calccurlinex
  169.         ex de,hl
  170.         or a
  171.         sbc hl,de ;sz<x = error
  172.         ret
  173.  
  174. insert_minushl_spaces
  175.         push bc
  176. textinsertsymbol_pseudospace0
  177.         push hl ;sz-x < 0
  178.         call texted_end
  179.         call calccursoraddr
  180.         ld c,' '
  181.         call insertbyte
  182.         pop hl ;sz-x < 0
  183.         inc hl
  184.         inc h
  185.         dec h
  186.         jr nz,textinsertsymbol_pseudospace0
  187.         call texted_end
  188.         pop bc
  189.         ret
  190.  
  191. texted_quit
  192.         ld a,(fchanged)
  193.         cp ' '
  194.         jr z,texted_quit_ok
  195.         call setredrawflag;texted_prcurpage
  196.         ld de,_COLOR_RED
  197.        if PRSTDIO
  198.         SETCOLOR_
  199.        else
  200.         OS_SETCOLOR
  201.        endif
  202.         ld hl,winquit
  203.         call prwindow_waitkey ;CY=OK
  204.         push af
  205.         ld de,_COLOR
  206.        if PRSTDIO
  207.         SETCOLOR_
  208.        else
  209.         OS_SETCOLOR
  210.        endif
  211.         pop af
  212.         ret nc ;no quit
  213. texted_quit_ok
  214.         pop af
  215.         ret ;quit
  216.  
  217. texted_enter
  218.         call linesize_minus_x ;sz<x = error
  219.         ;jr nc,texted_enter_nopseudospaces
  220.         call c,texted_end
  221. ;texted_enter_nopseudospaces
  222.         call calccursoraddr
  223.         ld c,0x0d
  224.         call insertbyte
  225.         ld c,0x0a
  226.         call insertbyte
  227.         xor a
  228.         ld (curx),a
  229.         ld hl,0
  230.         ld (texted_prline_shift),hl
  231.  
  232.         call setredrawflag;texted_prcurpage
  233.  
  234.         call incnlines
  235.         jp texted_down
  236.        
  237. texted_save
  238. texted_filenameaddr=$+1
  239.         ld de,defaultfilename
  240.         OS_CREATEHANDLE
  241.         or a
  242.         ret nz
  243. ;b=new file handle
  244.         push bc
  245.         ld a,b
  246.         ld (cmd_savepage_handle),a
  247.  
  248.         ;ld de,(fcb+FCB_FSIZE)
  249.         ;ld hl,(fcb+FCB_FSIZE+2)
  250.         call getsize
  251.         ex de,hl
  252.         ld l,a
  253.         ld h,0
  254.         ld a,0 ;page number
  255. texted_save0
  256. ;a=page number in table (0..)
  257. ;hlde=remaining size
  258.         push af ;pg
  259.         push de ;remaining LSW
  260.         push hl ;remaining HSW
  261.         call setpg32k
  262.         ld a,d
  263.         and 0xc0
  264.         or h
  265.         or l
  266.         jr z,$+5 ;de=size
  267.         ld de,#4000
  268.         ex de,hl ;hl=pg size
  269.          push hl ;hl=pg size
  270.         call cmd_savepage
  271.          pop bc ;bc=pg size
  272.         pop hl ;remaining HSW
  273.         pop de ;remaining LSW
  274.         ex de,hl
  275.         or a
  276.         sbc hl,bc
  277.         ex de,hl
  278.         jr nc,$+3
  279.         dec hl ;size = size-pgsize
  280.         ld a,h
  281.         or l
  282.         or d
  283.         or e
  284.         jr z,texted_save_popq
  285.         pop af ;pg
  286.         inc a
  287.         jr texted_save0
  288. texted_save_popq
  289.         pop af
  290.         pop bc
  291.         OS_CLOSEHANDLE
  292.         call setunchanged
  293.         jp setpanelredrawflag
  294.  
  295. cmd_savepage
  296. ;hl=size
  297. ;out: a=error
  298. cmd_savepage_handle=$+1
  299.         ld b,0
  300.         ld de,#8000
  301. ;B = file handle, DE = Buffer address, HL = Number of bytes to write
  302.         OS_WRITEHANDLE
  303. ;HL = Number of bytes actually written, A=error
  304.         ret
  305.        
  306. setredrawflag
  307.         ld a,55 ;scf
  308.         ld (texted_redrawflag),a
  309.         ;ret
  310. setpanelredrawflag
  311.         ld a,55 ;scf
  312.         ld (texted_panelredrawflag),a
  313.         ret
  314. setlineredrawflag
  315.         ld a,55 ;scf
  316.         ld (texted_lineredrawflag),a
  317.         jr setpanelredrawflag;ret
  318.  
  319. calccurlinex
  320.         ld hl,(texted_prline_shift)
  321.         ld a,(curx)
  322.         add a,l
  323.         ld l,a
  324.         ret nc
  325.         inc h
  326.         ret
  327.        
  328. calccursoraddr
  329. ;TODO учитывать ширину строки (правее строки простое сложение бессмысленно)
  330.         call calccurlinex
  331.         ex de,hl
  332.         ld hl,(curlineaddr)
  333.         ld a,(curlineaddrHSB)
  334.         add hl,de
  335.         adc a,0
  336.         ret
  337.        
  338. texted_backspace
  339. ;TODO wrap (set y, reprint screen if needed)
  340.         call calccurlinex
  341.         ld a,h
  342.         or l
  343.         jr z,texted_backspace_startline
  344.  
  345.         call linesize_minus_x ;sz<x = error
  346.         jp c,texted_left
  347.  
  348.         call calccursoraddr
  349.         call prevbyte
  350.         ;call isbof
  351.         ;ret z
  352.         call deletebyte        
  353.         call setlineredrawflag
  354.         jp texted_left
  355. texted_backspace_startline
  356.         call calccursoraddr
  357.         call isbof
  358.         ret z
  359.         call prevbyte
  360.         call getbyte
  361.         push bc
  362.         call deletebyte
  363.         pop bc
  364.         ld b,a
  365.          ld a,c ;deleted byte
  366.          cp 0x0d
  367.          ld a,b
  368.          jr z,texted_backspace_startline_onlycr ;for CR texts
  369.         ld a,c
  370.         cp 0x0a
  371.         ld a,b
  372.         jr nz,texted_backspace_startline_onlycr
  373.         call isbof
  374.         jr z,texted_backspace_startline_onlycr
  375.         call prevbyte
  376.         call getbyte
  377.         ld b,a
  378.         ld a,c
  379.         cp 0x0d
  380.         ld a,b
  381.         ;jr nz,texted_backspace_startline_onlycr
  382.         call z,deletebyte ;0x0d
  383. texted_backspace_startline_onlycr
  384. ;ahl=at deleted CR/LF
  385. ;if not CR/LF before, go to "previous line" (after earlier CR/LF) and count difference
  386. ;else x=0
  387.          push af
  388.          push hl
  389.         call prevbyte
  390.         call getbyte ;c
  391.          pop hl
  392.          pop af
  393.          ld d,h
  394.          ld e,l
  395.         ld b,a
  396.         ld a,c
  397.         cp 0x0d
  398.         jr z,texted_backspace_startline_setxshift_hlminusde
  399.         cp 0x0a
  400.         jr z,texted_backspace_startline_setxshift_hlminusde
  401.         ld a,b
  402.  
  403.         ;push af
  404.         push hl
  405.         call texted_prevline ;CY=error (impossible?)
  406.         ex de,hl
  407.         ;ld c,a
  408.         pop hl ;hl=at deleted CR?,de=prevline
  409.         ;pop af
  410. texted_backspace_startline_setxshift_hlminusde
  411.         or a
  412.         sbc hl,de
  413.         ;sbc a,c
  414.         call setxshift_hl
  415.        
  416.         call setredrawflag
  417.  
  418.         call decnlines
  419.         jp texted_up
  420.  
  421. decnlines
  422.         push hl
  423.         ld hl,(nlines)
  424.         dec hl
  425.         ld (nlines),hl
  426.         pop hl
  427.         ret
  428. incnlines
  429.         push hl
  430.         ld hl,(nlines)
  431.         inc hl
  432.         ld (nlines),hl
  433.         pop hl
  434.         ret
  435.  
  436. texted_home
  437. ;TODO wrap (set y)
  438.         ld hl,0
  439.         call setxshift_hl
  440.         jp setredrawflag
  441.  
  442. texted_end
  443. ;TODO wrap (set y)
  444.         ;call calccursoraddr
  445.         call calccurlinesz ;hl=sz
  446.         call setxshift_hl
  447.         jp setredrawflag
  448.  
  449. calccurlinesz_nowrap
  450. ;out: hl=sz (keeps bc)
  451.         ld hl,(curlineaddr)
  452.         ld a,(curlineaddrHSB)
  453. ;ahl=line addr
  454.         push bc
  455.         call texted_nextline_nowrap ;CY=error
  456.         jr calccurlinesz_go
  457. calccurlinesz
  458. ;out: hl=sz (keeps bc)
  459.         ld hl,(curlineaddr)
  460.         ld a,(curlineaddrHSB)
  461. ;ahl=line addr
  462.         push bc
  463.         call texted_nextline ;CY=error
  464. calccurlinesz_go
  465.         call c,getsize
  466.         call nc,skipbackcrlf
  467.         ld bc,(curlineaddr)
  468.         or a
  469.         sbc hl,bc
  470.         pop bc
  471.         ret
  472.  
  473. skipbackcrlf
  474. ;out: ahl=eof or endline+1 (at cr/lf)
  475.         call isbof
  476.         ret z
  477.         call prevbyte
  478.         call getbyte
  479.         ld b,a
  480.          ld a,c
  481.          cp 0x0d
  482.          ld a,b
  483.          ret z ;for CR texts
  484.         ld a,c
  485.         cp 0x0a
  486.         ld a,b
  487.         jp nz,nextbyte
  488.         call isbof
  489.         ret z
  490.         call prevbyte
  491.         call getbyte
  492.         ld b,a
  493.         ld a,c
  494.         cp 0x0d
  495.         ld a,b
  496.         jp nz,nextbyte
  497.         ret
  498.        
  499. setxshift_hl
  500. ;X=hl=ahl-startline
  501. ;x+shift = X:
  502. ;x = min(X,texted_WID-1), но под mod8 должен совпадать с X
  503. ;shift = X-x
  504.         ld bc,texted_WID-1
  505.         call minhl_bc_tobc
  506.         ld a,c
  507.         xor l
  508.         and %11111000
  509.         xor l
  510.         ld c,a
  511.         ld (curx),a
  512.         or a
  513.         sbc hl,bc
  514.         ld (texted_prline_shift),hl
  515.         ret
  516.        
  517. texted_del
  518. ;TODO wrap (set y, reprint screen if needed)
  519.         call linesize_minus_x ;sz<x = error
  520.         jr c,texted_del_newline
  521.         jr z,texted_del_newline
  522.         call texted_right
  523.         jp texted_backspace
  524. texted_del_newline
  525. ;удаление ентера справа (backspace не умеет)
  526. ;hl=sz-x
  527.         call c,insert_minushl_spaces
  528.         call setredrawflag
  529.         call calccursoraddr
  530.         call iseof
  531.         ret z
  532.         call decnlines
  533.         call getbyte
  534.         push af
  535.         call deletebyte
  536.         pop bc ;b=deleted byte
  537.         ld c,a
  538.         ld a,b
  539.         cp 0x0a
  540.         ld a,c
  541.         ret z ;endline = 0x0a
  542.         call iseof
  543.         ret z
  544.         call getbyte
  545.         ld b,a
  546.         ld a,c
  547.         cp 0x0a
  548.         ld a,b
  549.         ret nz
  550.         call deletebyte        
  551.         ret
  552.        
  553. texted_wrap
  554.         ld a,(wrapflag)
  555.         xor 128
  556.         ld (wrapflag),a
  557.         ld hl,0
  558.         ld (texted_prline_shift),hl
  559.         ld (curxy),hl
  560.         call texted_calclines
  561.         ld hl,(curtoptextaddr)
  562.         ld a,(curtoptextHSB)
  563.         ld (curlineaddr),hl
  564.         ld (curlineaddrHSB),a
  565.         call texted_calccurline
  566.         jp setredrawflag;texted_prcurpage
  567.        
  568. texted_right
  569. ;TODO X<16384
  570.         call setpanelredrawflag
  571.         ld de,(curxy)
  572.         inc e
  573.         ld a,e
  574.         cp texted_WID
  575.         ld (curx),a
  576.         ret c
  577.          call iswrapon ;CY=on
  578.          jr c,texted_right_wrap
  579.         ld hl,(texted_prline_shift)
  580.         ld bc,8
  581.         add hl,bc
  582.         ld (texted_prline_shift),hl
  583.         ld a,e
  584.         sub c;8
  585.         ld (curx),a
  586.         jp setredrawflag;texted_prcurpage
  587.        
  588. texted_right_wrap
  589.         xor a
  590.         ld (curx),a
  591.         jp texted_down
  592.        
  593. texted_left
  594.         call setpanelredrawflag
  595.         ld de,(curxy)
  596.         ld a,e
  597.         sub 1
  598.         ld e,a
  599.         ld (curx),a
  600.         ret nc
  601.         xor a
  602.         ld (curx),a
  603.         ld hl,(texted_prline_shift)
  604.         ld bc,8
  605.         or a
  606.         sbc hl,bc
  607.         ret c
  608.         ld (texted_prline_shift),hl
  609.         ld a,e
  610.         add a,c;8
  611.         ld (curx),a
  612.         jp setredrawflag;texted_prcurpage
  613.        
  614. texted_prcurline
  615.         ld a,55+0x80 ;or a
  616.         ld (texted_lineredrawflag),a
  617.         ld de,(curxy)
  618.         ld e,0
  619.         ;push de
  620.         call nv_setxy ;keeps de
  621.         ;pop de
  622. ;print lines until CR or EOF
  623. ;TODO если изменилось число подстрок, то печатаем всё ниже
  624. ;костыль: печатаем всё ниже, если у текущей строки последняя позиция печати=0 (бывает при стирании) или 1 (бывает при добавлении). можно сделать делением длины строки на 80
  625.       push de
  626.        call calccurlinesz_nowrap ;out: hl=sz (keeps bc)
  627.       pop de
  628.        ld bc,-80
  629.        add hl,bc
  630.        jr c,$-1
  631. ;hl=-80..-1 for line remainder = 0..79
  632.        ld a,l
  633.        sub c
  634.        cp 2
  635.         ld hl,(curlineaddr)
  636.         ld a,(curlineaddrHSB)
  637.        jr c,texted_prcurline_allbelow
  638. texted_prcurline_continue0
  639.         call texted_prline_nextline_nooverflow    
  640.         call texted_prcurline_continue ;z=no continue
  641.        ret z
  642.         inc d
  643.        ld b,a
  644.         ;ld a,texted_HGT
  645.         ld a,(textedhgt)
  646.         cp d
  647.        ld a,b
  648.         jr nz,texted_prcurline_continue0
  649.         ret
  650. texted_prcurline_allbelow
  651. texted_prcurline_allbelow0
  652.         call texted_prline_nextline_nooverflow    
  653.         call texted_prcurline_continue ;z=no continue
  654.         inc d
  655.        ld b,a
  656.         ;ld a,texted_HGT
  657.         ld a,(textedhgt)
  658.         cp d
  659.        ld a,b
  660.         jr nz,texted_prcurline_allbelow0
  661.         ret
  662.  
  663. texted_prline_nextline_nooverflow
  664.         push de
  665.         call texted_prline_nextline
  666.         pop de
  667.         call c,getsize ;при переполнении ahl=filesize
  668.         ret
  669.  
  670. texted_prcurline_continue
  671. ;out: z=no continue
  672.         call iseof
  673.         ret z
  674.         call prevbyte
  675.         call getbyte ;to c
  676.        push bc
  677.         call nextbyte
  678.        pop bc
  679.         ld b,a
  680.         ld a,c
  681.         cp 0x0d
  682.         jr z,texted_prcurline_continue_ab_z
  683.         cp 0x0a
  684. texted_prcurline_continue_ab_z
  685.         ld a,b
  686.         ;ret z
  687.         ret
  688.  
  689. texted_prcurpage
  690.          ;ld e,0
  691.          ;OS_CLS
  692.         ld a,55+0x80 ;or a
  693.         ld (texted_redrawflag),a
  694.         ld hl,(curtoptextaddr)
  695.         ld a,(curtoptextHSB)
  696.         jp texted_prpage
  697.        
  698. texted_gotobof
  699.         xor a
  700.         ld h,a
  701.         ld l,a
  702. ;texted_gotobof_ok
  703.         call texted_settop
  704.         ld (curlineaddr),hl
  705.         ld (curlineaddrHSB),a
  706.         ;ld hl,1
  707.         ;ld (texted_ncurline),hl
  708. ;ahl=curtextline (kept)
  709.         call texted_calccurline
  710.         ld hl,0
  711.         ld (curxy),hl
  712.         jp setredrawflag;texted_prcurpage
  713.  
  714. getsize
  715.         ld hl,(filesize)
  716.         ld a,(filesizeHSW)
  717.         ret
  718.        
  719. texted_gotoeof
  720.         call getsize
  721.         ;ld b,texted_HGT
  722.         ld bc,(textedhgt-1) ;b
  723. texted_end0
  724.         push bc
  725.         call texted_prevline
  726.         pop bc
  727.         djnz texted_end0
  728. ;ahl=curtextline (kept)
  729.         call texted_calccurline
  730.         jp texted_pgdown_bottom
  731.  
  732.  
  733. deccurline
  734.         push hl
  735.         ld hl,(texted_ncurline)
  736.         dec hl
  737.         ld (texted_ncurline),hl
  738.         pop hl
  739.         ret
  740. deccury
  741.         push hl
  742.         ld hl,cury
  743.         dec (hl)
  744.         pop hl
  745.         ret
  746.        
  747. inccurline
  748.         push hl
  749.         ld hl,(texted_ncurline)
  750.         inc hl
  751.         ld (texted_ncurline),hl
  752.         pop hl
  753.         ret
  754. inccury
  755.         push hl
  756.         ld hl,cury
  757.         inc (hl)
  758.         pop hl
  759.         ret
  760.  
  761. texted_up
  762.         ld hl,(curlineaddr)
  763.         ld a,(curlineaddrHSB)
  764.         call texted_prevline
  765.         ret c
  766.         ld (curlineaddr),hl
  767.         ld (curlineaddrHSB),a
  768.         push af
  769.         push hl
  770.         call deccurline
  771.         call setpanelredrawflag
  772.         pop hl
  773.         pop af
  774.         ld c,a
  775.         ld a,(cury)
  776.         sub 1
  777.         ld (cury),a
  778.         ret nc
  779.         inc a
  780.         ld (cury),a
  781.         ld a,c
  782.         call texted_settop
  783.         push af
  784.         push hl
  785.         ld de,texted_XYTOP
  786.         ;ld hl,256*texted_HGT + texted_WID
  787.         ld hl,(textedhgt-1) ;h
  788.         ld l,texted_WID
  789.         call scrolldown ;OS_SCROLLDOWN
  790.         ld de,texted_XYTOP
  791.         call nv_setxy
  792.         pop hl
  793.         pop af
  794.         call texted_prline
  795.         ret
  796.  
  797. texted_down
  798.         ld hl,(curlineaddr)
  799.         ld a,(curlineaddrHSB)
  800.         call texted_nextline
  801.         ret c
  802.         ld (curlineaddr),hl
  803.         ld (curlineaddrHSB),a
  804.         push af
  805.         push hl
  806.         call inccurline
  807.         call setpanelredrawflag
  808.         pop hl
  809.         pop af
  810.         ld c,a
  811.         ld de,(curxy)
  812.         inc d
  813.         ;ld a,texted_HGT
  814.         ld a,(textedhgt)
  815.         cp d
  816.         ld (curxy),de
  817.         ret nz;c
  818.         dec d
  819.         ld (curxy),de
  820.         ld a,c
  821.         push af
  822.         push hl
  823.         ld de,texted_XYTOP
  824.         ;ld hl,256*texted_HGT + texted_WID
  825.         ld hl,(textedhgt-1) ;h
  826.         ld l,texted_WID
  827.        push de
  828.        push hl
  829.         call scrollup ;OS_SCROLLUP
  830.        pop hl
  831.        pop de
  832.        dec h
  833.        ld l,0
  834.        add hl,de
  835.        ex de,hl ;de=texted_XYTOP+((texted_HGT-1)*256)
  836.         call nv_setxy
  837.         pop hl
  838.         pop af
  839.         call texted_prline;_nextline
  840. curtoptextaddr=$+1
  841.         ld hl,0
  842. curtoptextHSB=$+1
  843.         ld a,0
  844.         call texted_nextline
  845. texted_settop        
  846.         ld (curtoptextaddr),hl
  847.         ld (curtoptextHSB),a
  848.         ret
  849.  
  850. texted_pgup
  851.         call setpanelredrawflag
  852.         ld a,(cury)
  853.         or a
  854.         ld b,a
  855.         ld hl,(curlineaddr)
  856.         ld a,(curlineaddrHSB)
  857.         jr z,texted_pgup_top
  858. texted_pgup_gotop0
  859.         push bc
  860.         call texted_prevline
  861.          call nc,deccurline
  862.          call nc,deccury
  863.         pop bc
  864.         djnz texted_pgup_gotop0
  865.         ld (curlineaddr),hl
  866.         ld (curlineaddrHSB),a
  867.         ret
  868. texted_pgup_top
  869.         ;ld b,texted_HGT-1
  870.         ld bc,(textedhgt-1) ;b
  871.         dec b
  872. texted_pgup0
  873.         push bc
  874.         call texted_prevline
  875.          call nc,deccurline
  876.         pop bc
  877.         djnz texted_pgup0
  878.         call texted_settop
  879.         ld (curlineaddr),hl
  880.         ld (curlineaddrHSB),a
  881.         call setredrawflag
  882.         ret
  883.        
  884. texted_pgdown
  885.         call setpanelredrawflag
  886.         ;ld a,(cury)
  887.         ;sub texted_HGT-1
  888.         ;neg
  889.         ;ld b,a
  890.         ld a,(textedhgt)
  891.         dec a
  892.         ld hl,cury
  893.         sub (hl)
  894.         ld b,a
  895.         ld hl,(curlineaddr)
  896.         ld a,(curlineaddrHSB)
  897.         jr z,texted_pgdown_bottom
  898. texted_pgdown_gobottom0
  899.         push bc
  900.         call texted_nextline
  901.          call nc,inccurline
  902.          call nc,inccury
  903.         pop bc
  904.         djnz texted_pgdown_gobottom0
  905.         ld (curlineaddr),hl
  906.         ld (curlineaddrHSB),a
  907.         ret
  908. texted_pgdown_bottom
  909.         push af
  910.         xor a
  911.         ld (cury),a
  912.         pop af
  913.         call texted_settop
  914.         ;ld b,texted_HGT-1
  915.         ld bc,(textedhgt-1) ;b
  916.         dec b
  917. texted_pgdown0
  918.         push bc
  919.         call texted_nextline
  920.          call nc,inccurline
  921.          call nc,inccury
  922.         pop bc
  923.         djnz texted_pgdown0
  924.         ld (curlineaddr),hl
  925.         ld (curlineaddrHSB),a
  926.         jp setredrawflag
  927.        
  928. texted_calccurline
  929. ;ahl=curtextline (kept)
  930.         push af
  931.         push hl
  932.         ld (texted_calccurline_old),hl
  933.         ld (texted_calccurline_oldHSB),a
  934.         ld ix,1;0
  935.          or h
  936.          or l
  937.          jr z,texted_calccurline_countq
  938.         xor a
  939.         ld h,a
  940.         ld l,a
  941. texted_calccurline_count0
  942.         call texted_nextline ;texted_pseudoprline
  943.  
  944.         if 1==0
  945.         jr c,texted_calccurline_countq ;не помогает
  946.         ex de,hl
  947. texted_calccurline_old=$+1
  948.         ld hl,0
  949.         or a
  950.         sbc hl,de ;nc: hl<=old
  951.         ld l,a
  952. texted_calccurline_oldHSB=$+1
  953.         ld a,0
  954.         sbc a,l
  955.         ld a,l
  956.         inc ix
  957.         jr nc,texted_calccurline_count0 ;nc: ahl<=old
  958.         else
  959.        
  960.         push hl
  961. texted_calccurline_old=$+1
  962.         ld bc,0
  963.         or a
  964.         sbc hl,bc ;nc: hl>=old
  965.         ld l,a
  966. texted_calccurline_oldHSB=$+1
  967.         sbc a,0
  968.         ld a,l
  969.         pop hl
  970.         inc ix
  971.         jr c,texted_calccurline_count0 ;cy: ahl<old
  972.         endif
  973. texted_calccurline_countq
  974.         ;push ix
  975.         ;pop hl
  976.         ld (texted_ncurline),ix;hl
  977.         pop hl
  978.         pop af
  979.         ret
  980.        
  981. texted_calclines
  982. ;sets nlines
  983.         xor a
  984.         ld h,a
  985.         ld l,a
  986.         ld (nlines),hl
  987. texted_calclines0
  988.         call incnlines
  989.         call texted_nextline
  990.         jr nc,texted_calclines0
  991.         ret
  992.        
  993. clear_keyboardbuffer
  994.         push bc
  995.         ld b,50;5
  996. clear_keyboardbuffer0
  997.         push bc
  998.         GETKEY_
  999.         pop bc
  1000.         djnz clear_keyboardbuffer0
  1001.         pop bc
  1002.         ret
  1003.        
  1004. texted_changeencoding
  1005.         ld hl,texted_prline_recodepatch
  1006.         ld a,(hl)
  1007.         xor 0x7e ;"ld a,(hl)"
  1008.         ld (hl),a
  1009.         call setredrawflag;texted_prcurpage
  1010.         ;call texted_prcurpage
  1011.         ;ret
  1012. texted_panel
  1013.         ld a,55+0x80 ;or a
  1014.         ld (texted_panelredrawflag),a
  1015.         ;ld de,0x1800
  1016.         ld a,(stdiohgt)
  1017.         dec a
  1018.         ld d,a
  1019.         ld e,0
  1020.         call nv_setxy
  1021.         ld de,_texted_PANELCOLOR
  1022.         SETCOLOR_
  1023.        
  1024.         ld a,(texted_prline_recodepatch)
  1025.         or a
  1026.         ld hl,t866
  1027.         jr z,$+5
  1028.         ld hl,twin
  1029.         call prtext
  1030.        
  1031. fchanged=$+1
  1032.         ld a,' '
  1033.         PRCHAR_
  1034.         call calccurlinex
  1035.         inc hl
  1036.         call prword
  1037.         ld a,','
  1038.         PRCHAR_
  1039. texted_ncurline=$+1
  1040.         ld hl,0
  1041.         call prword
  1042.         ld a,'/'
  1043.         PRCHAR_
  1044.         ld hl,(nlines)
  1045.         exx
  1046.         ld hl,0
  1047.         exx
  1048.         call prdword
  1049.         ld a,' '
  1050.         PRCHAR_
  1051.         call getsize
  1052.         exx
  1053.         ;ld hl,(fcb+FCB_FSIZE+2)
  1054.         ld l,a
  1055.         ld h,0
  1056.         exx
  1057.         ;ld hl,(fcb+FCB_FSIZE)
  1058.         call prdword
  1059.         ld de,tspaces_filename
  1060.         ld hl,TSPACES_FILENAME_SZ
  1061.         call sendchars
  1062.         ;ld de,_texted_PANELCOLOR;#38
  1063.         ;OS_PRATTR
  1064.         ld de,_COLOR
  1065.         SETCOLOR_
  1066.         ret
  1067.  
  1068. tspaces_filename
  1069.         db ' '
  1070. tshown_filename
  1071.         ds TSPACES_FILENAME_SZ,' '
  1072.        
  1073. twin
  1074.         db "WIN",0
  1075. t866
  1076.         db "866",0
  1077.  
  1078.      
  1079. isbof
  1080. ;out: z=bof
  1081.         push bc
  1082.         ld c,a
  1083.         or h
  1084.         or l
  1085.         ld a,c
  1086.         pop bc
  1087.         ret
  1088. iseof
  1089. ;out: z=eof
  1090.         push bc
  1091.         push de
  1092.         push hl
  1093.         ;ld de,(fcb+FCB_FSIZE)
  1094.         ;ld bc,(fcb+FCB_FSIZE+2)
  1095.         ;ld b,a
  1096.         ;or a
  1097.         ;sbc hl,de
  1098.         ;sbc a,c
  1099.         ;ld a,b
  1100.         ex de,hl
  1101.         ld c,a
  1102.         call getsize
  1103.         or a
  1104.         sbc hl,de
  1105.         sbc a,c
  1106.         or h
  1107.         or l
  1108.         ld a,c
  1109.         pop hl
  1110.         pop de
  1111.         pop bc
  1112.         ret
  1113.      
  1114. texted_prpage
  1115. ;ahl=addr
  1116.         ld (curtoptextaddr),hl
  1117.         ld (curtoptextHSB),a
  1118.         push af
  1119.         ld de,texted_XYTOP
  1120.         call nv_setxy
  1121.         pop af
  1122.         ;ld b,texted_HGT
  1123.         ld bc,(textedhgt-1) ;b
  1124. texted_prpage0
  1125.         push bc
  1126.         ;push de
  1127.         call texted_prline_nextline
  1128.         call c,getsize
  1129.         ;pop de
  1130.         pop bc
  1131.         ;inc d
  1132.         djnz texted_prpage0
  1133.         ;call clear_keyboardbuffer
  1134.         ret
  1135.        
  1136. texted_prevline
  1137. ;ahl=addr
  1138. ;line < 16K
  1139. ;out: ahl, CY=error
  1140.         call isbof
  1141.          scf
  1142.         ret z
  1143. ;перед нами может быть #0d или #0d,#0a или ничего
  1144.         ld (findprevline_old),hl
  1145.         ld (findprevline_oldHSB),a
  1146.        
  1147.         or a
  1148.         ld bc,0xffff
  1149.         jr nz,$+4
  1150.          ld b,h
  1151.          ld c,l
  1152.          
  1153.         ;push de
  1154.         ld de,0x4000
  1155.         or a
  1156.         sbc hl,de
  1157.         sbc a,e;0
  1158.         ;pop de
  1159.        
  1160.         push af
  1161.         push hl
  1162.         call ahl_to_pgaddr
  1163.         set 6,h
  1164. ;hl=c000+, можно уменьшать
  1165. ;bc=number of chars to go != 0
  1166.  
  1167. ;перед нами может быть #0d или #0d,#0a или ничего
  1168.         dec hl
  1169.         dec bc
  1170.         ld a,b
  1171.         or c
  1172.         jr z,texted_prevlineq
  1173.         ld a,0x0a
  1174.         cp (hl)
  1175.         jr nz,texted_prevline_nolf
  1176.         dec hl
  1177.         dec bc
  1178.         ld a,b
  1179.         or c
  1180.         jr z,texted_prevlineq
  1181. texted_prevline_nolf
  1182.         ld a,0x0d
  1183.         cp (hl)
  1184.         jr nz,texted_prevline_nocr
  1185.         dec hl
  1186.         dec bc
  1187.         ld a,b
  1188.         or c
  1189.         jr z,texted_prevlineq
  1190. texted_prevline_nocr
  1191. ;сейчас мы находимся перед символом конца предыдущей строки (не на нём)
  1192. texted_prevline0
  1193.         ld a,(hl)
  1194.         cp 0x0d
  1195.         jr z,texted_prevline_cr
  1196.         cp 0x0a
  1197.         jr z,texted_prevline_lf
  1198.         dec hl
  1199.         dec bc
  1200.         ld a,b
  1201.         or c
  1202.         jr nz,texted_prevline0
  1203. ;beginning of file
  1204.         jr texted_prevlineq
  1205. texted_prevline_cr
  1206. texted_prevline_lf
  1207. ;сейчас мы находимся на конце символа конца строки перед предыдущей
  1208.         inc hl
  1209. texted_prevlineq
  1210.         ex de,hl ;new addr (bits 13..0), bit 14 = overflow
  1211.         pop hl ;old addr
  1212.         pop af
  1213.         call pgaddr_to_ahl
  1214.         call iswrapon ;CY=on
  1215.         ret nc ;no wrap
  1216.  
  1217. findprevline_linewrap
  1218. ;ahl = в начале строки
  1219. ;перед ней может быть #0d или #0d,#0a
  1220. ;надо псевдонапечатать несколько псевдострок, пока не дойдём до текущей
  1221. findprevline_linewrap_count0
  1222.          push af
  1223.          push hl
  1224.         call texted_pseudoprline
  1225.         push hl
  1226. findprevline_old=$+1
  1227.         ld bc,0
  1228.         or a
  1229.         sbc hl,bc ;nc: hl>=old
  1230.         ld l,a
  1231. findprevline_oldHSB=$+1
  1232.         sbc a,0
  1233.         ld a,l
  1234.         pop hl
  1235.          pop de ;old addr
  1236.          pop bc ;b=old HSB
  1237.         jr c,findprevline_linewrap_count0
  1238.         ex de,hl
  1239.         ld a,b
  1240. ;ahl=на псевдострочку раньше
  1241.         ret ;nc
  1242.  
  1243. getmaxlinesize
  1244. ;ahl = addr
  1245. ;out: bc=max line size before eof, z=(bc==0) (keeps ahl)
  1246.          ;push de
  1247.         push af
  1248.         push hl
  1249.         ex de,hl
  1250.         ld c,a
  1251.         call getsize
  1252.         or a
  1253.         sbc hl,de
  1254.         sbc a,c
  1255.         ld bc,0
  1256.         jr c,getmaxlinesize_aftereof
  1257.         dec bc
  1258.         or a
  1259.         jr nz,$+4 ;filesize-addr >= 0x10000, will be 0xffff
  1260.          ld b,h
  1261.          ld c,l ;filesize-addr
  1262. getmaxlinesize_aftereof
  1263.         pop hl
  1264.         pop af
  1265.         ld e,a
  1266.         ld a,b
  1267.         or c
  1268.         ld a,e
  1269.          ;pop de
  1270.         ret
  1271.  
  1272. texted_prline_nextline
  1273.         push af
  1274.         push hl
  1275.         call texted_prline
  1276.         pop hl
  1277.         pop af
  1278. texted_nextline
  1279. ;if eof, returns CY and old addr (use call c,getsize) [eof addr]
  1280. ;ahl=addr
  1281. ;line < 16K
  1282. ;out: ahl, CY=error
  1283.         call iswrapon ;CY=on
  1284.         jp c,texted_pseudoprline
  1285. texted_nextline_nowrap ;для вычисления длины строки
  1286.         call getmaxlinesize ;bc=max line size before eof, z=(bc==0)
  1287.          scf
  1288.         ret z
  1289.         push af
  1290.         push hl
  1291.         call ahl_to_pgaddr
  1292. ;bc=number of chars to go != 0
  1293. texted_nextline0
  1294.         ld a,(hl)
  1295.         inc hl
  1296.         dec bc
  1297.         cp 0x0d
  1298.         jr z,texted_nextline_cr
  1299.         cp 0x0a
  1300.         jr z,texted_nextline_lf
  1301.         ld a,b
  1302.         or c
  1303.         jr nz,texted_nextline0
  1304. ;texted_nextline_eof
  1305.         pop hl ;old addr
  1306.         pop af
  1307.         scf ;error
  1308.         ret
  1309. texted_nextlineq
  1310.         ex de,hl ;new addr (bits 13..0), bit 14 = overflow
  1311.         pop hl ;old addr
  1312.         pop af
  1313.         jp pgaddr_to_ahl
  1314. texted_nextline_cr
  1315.         ld a,b
  1316.         or c
  1317.         jr z,texted_nextlineq
  1318.         ld a,(hl)
  1319.         cp 0x0a
  1320.         jr nz,texted_nextline_lf
  1321.         inc hl
  1322. texted_nextline_lf
  1323.         jr texted_nextlineq
  1324.        
  1325. texted_prline
  1326. ;ahl=addr
  1327. ;check for last line (vs. file size)
  1328. ;if filesize-addr < 80, then b=filesize-addr, else b=80
  1329.         call getmaxlinesize ;bc=max line size before eof, z=(bc==0)
  1330.         jr z,texted_prlinespc_all;ret z
  1331.         call ahl_to_pgaddr
  1332. ;hl=#8000+0..#3fff
  1333. ;bc=max line size before eof != 0
  1334. texted_prline_shift=$+1
  1335.         ld de,0
  1336.         call istherecr_or_lf ;add hl,de
  1337.         ;jr nz,$+3
  1338.         ;dec hl ;hl=cr/lf address
  1339.  
  1340.         push hl
  1341.         ld h,b
  1342.         ld l,c
  1343.         or a
  1344.         sbc hl,de
  1345.         ld b,h
  1346.         ld c,l ;bc=bc-lineshift
  1347.         pop hl
  1348.         ;ld a,texted_WID
  1349.         jr c,texted_prlinespc_all
  1350.         jr z,texted_prlinespc_all ;maxlinesize<=lineshift
  1351.  
  1352.         push hl
  1353.         ld hl,texted_WID
  1354.         call minhl_bc_tobc
  1355.         ld b,c
  1356.         pop hl
  1357. ;b=number of chars to print != 0
  1358.         ld de,prlinebuf
  1359.         ld c,texted_WID
  1360. texted_prline0
  1361.         ld a,(hl)
  1362.         inc hl
  1363.         cp 0x0d
  1364.         jr z,texted_prline_cr
  1365.         cp 0x0a
  1366.         jr z,texted_prline_cr;lf
  1367.         ;push bc
  1368.         push hl
  1369.         ld h,twinto866/256
  1370.         ld l,a
  1371. texted_prline_recodepatch=$
  1372.         nop ;/ld a,(hl)
  1373.         ld (de),a ;PRCHAR_
  1374.         inc de
  1375.         pop hl
  1376.         ;pop bc
  1377.         dec c
  1378.         djnz texted_prline0
  1379.         ;call print_prlinebuf
  1380.         ;jr nz,texted_prline_lf
  1381.         ;ret
  1382. texted_prline_cr
  1383.         call print_prlinebuf
  1384. ;texted_prline_lf
  1385. ;допечатать пробелы до конца строки
  1386.         jr texted_prlinespc
  1387. texted_prlinespc_all
  1388.         ld c,texted_WID
  1389. texted_prlinespc
  1390.         push af
  1391.         push hl
  1392.         ;ld l,b
  1393.         ;ld h,0
  1394.         ;ld de,tspaces
  1395.         ;call sendchars
  1396.          ld a,c
  1397.          or a
  1398.         call nz,clearrestofline_crlf
  1399.         pop hl
  1400.         pop af
  1401.         ret
  1402.  
  1403. print_prlinebuf
  1404.         push af
  1405.         push bc
  1406.         push hl
  1407. ;c=texted_WID-число символов
  1408.         ld de,prlinebuf
  1409.         ld a,texted_WID
  1410.         sub c
  1411.         ld l,a
  1412.         ld h,0
  1413.         call sendchars
  1414.         pop hl
  1415.         pop bc
  1416.         pop af
  1417.         ret
  1418.  
  1419. prlinebuf
  1420.         ds texted_WID
  1421.  
  1422. texted_pseudoprline
  1423. ;ahl=addr
  1424. ;out: ahl, CY=error
  1425. ;check for last line (vs. file size)
  1426. ;if filesize-addr < 80, then b=filesize-addr, else b=80
  1427.         call getmaxlinesize ;bc=max line size before eof, z=(bc==0)
  1428.          scf
  1429.         ret z
  1430.         push af
  1431.         push hl
  1432.         call ahl_to_pgaddr
  1433. ;hl=#8000+0..#3fff
  1434. ;bc=max line size before eof != 0
  1435.         push hl
  1436.         ld hl,texted_WID
  1437.         call minhl_bc_tobc
  1438.         ld b,c
  1439.         pop hl
  1440. ;b=number of chars to print != 0
  1441.         ld c,texted_WID
  1442. texted_pseudoprline0
  1443.         ld a,(hl)
  1444.         inc hl
  1445.         cp 0x0d
  1446.         jr z,texted_pseudoprline_cr
  1447.         cp 0x0a
  1448.         jr z,texted_pseudoprline_lf
  1449.         dec c
  1450.         djnz texted_pseudoprline0
  1451.          ld a,(hl)
  1452.          inc hl
  1453.          cp 0x0d
  1454.          jr z,texted_pseudoprline_crok
  1455.          cp 0x0a
  1456.          jr z,texted_pseudoprline_lf
  1457.          dec hl
  1458.         jp texted_nextlineq
  1459. texted_pseudoprline_cr
  1460.         dec b
  1461.         jp z,texted_nextlineq
  1462. texted_pseudoprline_crok
  1463.         ld a,(hl)
  1464.         cp 0x0a
  1465.         jr nz,texted_pseudoprline_lf
  1466.         inc hl
  1467. texted_pseudoprline_lf
  1468.         jp texted_nextlineq
  1469.        
  1470. ;по идее это псевдопечать N экранных позиций (там могут быть цветовые коды и т.п.)
  1471. istherecr_or_lf
  1472. ;hl=addr ;TODO ahl
  1473. ;de=length to search
  1474. ;out: z=found, hl=at match or after area (TODO ahl)
  1475.         ld a,d
  1476.         or e
  1477.         jr z,istherecr_or_lf_fail
  1478.          push hl
  1479.         ld a,0x0d
  1480.         call istherecrlfgo
  1481.         jr z,istherecr_or_lf_popafZret;ret z
  1482.          pop hl
  1483.         ld a,0x0a
  1484. istherecrlfgo
  1485.         push bc
  1486.         ld b,d
  1487.         ld c,e
  1488.         cpir ;TODO несколько раз через все блоки, если заканчиваются блоки, то их переключать
  1489.         pop bc
  1490.         ret nz ;nz=not found
  1491.          dec hl
  1492.         ret ;z=found
  1493. istherecr_or_lf_fail
  1494.         dec a
  1495.         ret ;nz=not found
  1496.        
  1497. istherecr_or_lf_popafZret
  1498.         pop af
  1499.         cp a ;Z
  1500.         ret
  1501.        
  1502. ;texted_closefcb
  1503. ;        ld de,fcb
  1504. ;        OS_FCLOSE
  1505. ;        ret
  1506.  
  1507. texted_help
  1508.         call clearterm
  1509.         ld hl,thelp
  1510.         call prtext
  1511.         call yieldgetkeyloop
  1512.         jp setredrawflag
  1513.  
  1514. thelp
  1515.         db "Keys in texted:\r\n"
  1516.         db "\r\n"
  1517.         db "стрелки, PageUp (Caps Shift+3), PageDown (Caps Shift+4) - движение курсора\r\n"
  1518.         db "Home (Symbol Shift+Q) - переход к началу строки\r\n"
  1519.         db "End (Symbol Shift+E) - переход к концу строки\r\n"
  1520.         db "Symbol Shift+PageUp - переход к началу текста\r\n"
  1521.         db "Symbol Shift+PageDown - переход к концу текста\r\n"
  1522.         db "BackSpace (Caps Shift+0) - удаление символа слева от курсора\r\n"
  1523.         db "Del (Caps Shift+9) - удаление символа справа от курсора\r\n"
  1524.         db "Break (Esc, Caps Shift+Space) - выход\r\n"
  1525.         db "Ins (Symbol Shift+W) - wrap on/off\r\n"
  1526.         db "F1 - help\r\n"
  1527.         db "F2 или Caps Shift+Enter - сохранение\r\n"
  1528.         db "F9 - запустить build.bat из директории с текстом\r\n"
  1529.         db "F10 - сменить кодировку (866/1251)"
  1530.         db 0
  1531.  
  1532.  
  1533. setunchanged
  1534.         ld a,' '
  1535.         jr setchanged_a
  1536. setchanged
  1537.         ld a,'*'
  1538. setchanged_a
  1539.         ld (fchanged),a
  1540.         ret
  1541.  
  1542. iswrapon
  1543. ;CY = on
  1544. wrapflag=$
  1545.         or a ;/scf
  1546.         ret
  1547.  
  1548. curlineaddr
  1549.         ds 3
  1550. curlineaddrHSB=$-1
  1551.  
  1552. nlines
  1553.         dw 0
  1554.  
  1555. curxy
  1556. curx
  1557.         db 0
  1558. cury
  1559.         db 0
  1560.        
  1561.         align 256
  1562. twinto866
  1563.         incbin "../_sdk/codepage/winto866"
  1564. t866towin
  1565.         ds 256,' ' ;incbin "../_sdk/codepage/866towin"
  1566.