Subversion Repositories NedoOS

Rev

Rev 1484 | 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.         ld de,0
  1046.         call prdword_dehl
  1047.         ld a,' '
  1048.         PRCHAR_
  1049.         call getsize
  1050.         ld e,a
  1051.         ld d,0
  1052.         call prdword_dehl
  1053.         ld de,tspaces_filename
  1054.         ld hl,TSPACES_FILENAME_SZ
  1055.         call sendchars
  1056.         ;ld de,_texted_PANELCOLOR;#38
  1057.         ;OS_PRATTR
  1058.         ld de,_COLOR
  1059.         SETCOLOR_
  1060.         ret
  1061.  
  1062. tspaces_filename
  1063.         db ' '
  1064. tshown_filename
  1065.         ds TSPACES_FILENAME_SZ,' '
  1066.        
  1067. twin
  1068.         db "WIN",0
  1069. t866
  1070.         db "866",0
  1071.  
  1072.      
  1073. isbof
  1074. ;out: z=bof
  1075.         push bc
  1076.         ld c,a
  1077.         or h
  1078.         or l
  1079.         ld a,c
  1080.         pop bc
  1081.         ret
  1082. iseof
  1083. ;out: z=eof
  1084.         push bc
  1085.         push de
  1086.         push hl
  1087.         ;ld de,(fcb+FCB_FSIZE)
  1088.         ;ld bc,(fcb+FCB_FSIZE+2)
  1089.         ;ld b,a
  1090.         ;or a
  1091.         ;sbc hl,de
  1092.         ;sbc a,c
  1093.         ;ld a,b
  1094.         ex de,hl
  1095.         ld c,a
  1096.         call getsize
  1097.         or a
  1098.         sbc hl,de
  1099.         sbc a,c
  1100.         or h
  1101.         or l
  1102.         ld a,c
  1103.         pop hl
  1104.         pop de
  1105.         pop bc
  1106.         ret
  1107.      
  1108. texted_prpage
  1109. ;ahl=addr
  1110.         ld (curtoptextaddr),hl
  1111.         ld (curtoptextHSB),a
  1112.         push af
  1113.         ld de,texted_XYTOP
  1114.         call nv_setxy
  1115.         pop af
  1116.         ;ld b,texted_HGT
  1117.         ld bc,(textedhgt-1) ;b
  1118. texted_prpage0
  1119.         push bc
  1120.         ;push de
  1121.         call texted_prline_nextline
  1122.         call c,getsize
  1123.         ;pop de
  1124.         pop bc
  1125.         ;inc d
  1126.         djnz texted_prpage0
  1127.         ;call clear_keyboardbuffer
  1128.         ret
  1129.        
  1130. texted_prevline
  1131. ;ahl=addr
  1132. ;line < 16K
  1133. ;out: ahl, CY=error
  1134.         call isbof
  1135.          scf
  1136.         ret z
  1137. ;перед нами может быть #0d или #0d,#0a или ничего
  1138.         ld (findprevline_old),hl
  1139.         ld (findprevline_oldHSB),a
  1140.        
  1141.         or a
  1142.         ld bc,0xffff
  1143.         jr nz,$+4
  1144.          ld b,h
  1145.          ld c,l
  1146.          
  1147.         ;push de
  1148.         ld de,0x4000
  1149.         or a
  1150.         sbc hl,de
  1151.         sbc a,e;0
  1152.         ;pop de
  1153.        
  1154.         push af
  1155.         push hl
  1156.         call ahl_to_pgaddr
  1157.         set 6,h
  1158. ;hl=c000+, можно уменьшать
  1159. ;bc=number of chars to go != 0
  1160.  
  1161. ;перед нами может быть #0d или #0d,#0a или ничего
  1162.         dec hl
  1163.         dec bc
  1164.         ld a,b
  1165.         or c
  1166.         jr z,texted_prevlineq
  1167.         ld a,0x0a
  1168.         cp (hl)
  1169.         jr nz,texted_prevline_nolf
  1170.         dec hl
  1171.         dec bc
  1172.         ld a,b
  1173.         or c
  1174.         jr z,texted_prevlineq
  1175. texted_prevline_nolf
  1176.         ld a,0x0d
  1177.         cp (hl)
  1178.         jr nz,texted_prevline_nocr
  1179.         dec hl
  1180.         dec bc
  1181.         ld a,b
  1182.         or c
  1183.         jr z,texted_prevlineq
  1184. texted_prevline_nocr
  1185. ;сейчас мы находимся перед символом конца предыдущей строки (не на нём)
  1186. texted_prevline0
  1187.         ld a,(hl)
  1188.         cp 0x0d
  1189.         jr z,texted_prevline_cr
  1190.         cp 0x0a
  1191.         jr z,texted_prevline_lf
  1192.         dec hl
  1193.         dec bc
  1194.         ld a,b
  1195.         or c
  1196.         jr nz,texted_prevline0
  1197. ;beginning of file
  1198.         jr texted_prevlineq
  1199. texted_prevline_cr
  1200. texted_prevline_lf
  1201. ;сейчас мы находимся на конце символа конца строки перед предыдущей
  1202.         inc hl
  1203. texted_prevlineq
  1204.         ex de,hl ;new addr (bits 13..0), bit 14 = overflow
  1205.         pop hl ;old addr
  1206.         pop af
  1207.         call pgaddr_to_ahl
  1208.         call iswrapon ;CY=on
  1209.         ret nc ;no wrap
  1210.  
  1211. findprevline_linewrap
  1212. ;ahl = в начале строки
  1213. ;перед ней может быть #0d или #0d,#0a
  1214. ;надо псевдонапечатать несколько псевдострок, пока не дойдём до текущей
  1215. findprevline_linewrap_count0
  1216.          push af
  1217.          push hl
  1218.         call texted_pseudoprline
  1219.         push hl
  1220. findprevline_old=$+1
  1221.         ld bc,0
  1222.         or a
  1223.         sbc hl,bc ;nc: hl>=old
  1224.         ld l,a
  1225. findprevline_oldHSB=$+1
  1226.         sbc a,0
  1227.         ld a,l
  1228.         pop hl
  1229.          pop de ;old addr
  1230.          pop bc ;b=old HSB
  1231.         jr c,findprevline_linewrap_count0
  1232.         ex de,hl
  1233.         ld a,b
  1234. ;ahl=на псевдострочку раньше
  1235.         ret ;nc
  1236.  
  1237. getmaxlinesize
  1238. ;ahl = addr
  1239. ;out: bc=max line size before eof, z=(bc==0) (keeps ahl)
  1240.          ;push de
  1241.         push af
  1242.         push hl
  1243.         ex de,hl
  1244.         ld c,a
  1245.         call getsize
  1246.         or a
  1247.         sbc hl,de
  1248.         sbc a,c
  1249.         ld bc,0
  1250.         jr c,getmaxlinesize_aftereof
  1251.         dec bc
  1252.         or a
  1253.         jr nz,$+4 ;filesize-addr >= 0x10000, will be 0xffff
  1254.          ld b,h
  1255.          ld c,l ;filesize-addr
  1256. getmaxlinesize_aftereof
  1257.         pop hl
  1258.         pop af
  1259.         ld e,a
  1260.         ld a,b
  1261.         or c
  1262.         ld a,e
  1263.          ;pop de
  1264.         ret
  1265.  
  1266. texted_prline_nextline
  1267.         push af
  1268.         push hl
  1269.         call texted_prline
  1270.         pop hl
  1271.         pop af
  1272. texted_nextline
  1273. ;if eof, returns CY and old addr (use call c,getsize) [eof addr]
  1274. ;ahl=addr
  1275. ;line < 16K
  1276. ;out: ahl, CY=error
  1277.         call iswrapon ;CY=on
  1278.         jp c,texted_pseudoprline
  1279. texted_nextline_nowrap ;для вычисления длины строки
  1280.         call getmaxlinesize ;bc=max line size before eof, z=(bc==0)
  1281.          scf
  1282.         ret z
  1283.         push af
  1284.         push hl
  1285.         call ahl_to_pgaddr
  1286. ;bc=number of chars to go != 0
  1287. texted_nextline0
  1288.         ld a,(hl)
  1289.         inc hl
  1290.         dec bc
  1291.         cp 0x0d
  1292.         jr z,texted_nextline_cr
  1293.         cp 0x0a
  1294.         jr z,texted_nextline_lf
  1295.         ld a,b
  1296.         or c
  1297.         jr nz,texted_nextline0
  1298. ;texted_nextline_eof
  1299.         pop hl ;old addr
  1300.         pop af
  1301.         scf ;error
  1302.         ret
  1303. texted_nextlineq
  1304.         ex de,hl ;new addr (bits 13..0), bit 14 = overflow
  1305.         pop hl ;old addr
  1306.         pop af
  1307.         jp pgaddr_to_ahl
  1308. texted_nextline_cr
  1309.         ld a,b
  1310.         or c
  1311.         jr z,texted_nextlineq
  1312.         ld a,(hl)
  1313.         cp 0x0a
  1314.         jr nz,texted_nextline_lf
  1315.         inc hl
  1316. texted_nextline_lf
  1317.         jr texted_nextlineq
  1318.        
  1319. texted_prline
  1320. ;ahl=addr
  1321. ;check for last line (vs. file size)
  1322. ;if filesize-addr < 80, then b=filesize-addr, else b=80
  1323.         call getmaxlinesize ;bc=max line size before eof, z=(bc==0)
  1324.         jr z,texted_prlinespc_all;ret z
  1325.         call ahl_to_pgaddr
  1326. ;hl=#8000+0..#3fff
  1327. ;bc=max line size before eof != 0
  1328. texted_prline_shift=$+1
  1329.         ld de,0
  1330.         call istherecr_or_lf ;add hl,de
  1331.         ;jr nz,$+3
  1332.         ;dec hl ;hl=cr/lf address
  1333.  
  1334.         push hl
  1335.         ld h,b
  1336.         ld l,c
  1337.         or a
  1338.         sbc hl,de
  1339.         ld b,h
  1340.         ld c,l ;bc=bc-lineshift
  1341.         pop hl
  1342.         ;ld a,texted_WID
  1343.         jr c,texted_prlinespc_all
  1344.         jr z,texted_prlinespc_all ;maxlinesize<=lineshift
  1345.  
  1346.         push hl
  1347.         ld hl,texted_WID
  1348.         call minhl_bc_tobc
  1349.         ld b,c
  1350.         pop hl
  1351. ;b=number of chars to print != 0
  1352.         ld de,prlinebuf
  1353.         ld c,texted_WID
  1354. texted_prline0
  1355.         ld a,(hl)
  1356.         inc hl
  1357.         cp 0x0d
  1358.         jr z,texted_prline_cr
  1359.         cp 0x0a
  1360.         jr z,texted_prline_cr;lf
  1361.         ;push bc
  1362.         push hl
  1363.         ld h,twinto866/256
  1364.         ld l,a
  1365. texted_prline_recodepatch=$
  1366.         nop ;/ld a,(hl)
  1367.         ld (de),a ;PRCHAR_
  1368.         inc de
  1369.         pop hl
  1370.         ;pop bc
  1371.         dec c
  1372.         djnz texted_prline0
  1373.         ;call print_prlinebuf
  1374.         ;jr nz,texted_prline_lf
  1375.         ;ret
  1376. texted_prline_cr
  1377.         call print_prlinebuf
  1378. ;texted_prline_lf
  1379. ;допечатать пробелы до конца строки
  1380.         jr texted_prlinespc
  1381. texted_prlinespc_all
  1382.         ld c,texted_WID
  1383. texted_prlinespc
  1384.         push af
  1385.         push hl
  1386.         ;ld l,b
  1387.         ;ld h,0
  1388.         ;ld de,tspaces
  1389.         ;call sendchars
  1390.          ld a,c
  1391.          or a
  1392.         call nz,clearrestofline_crlf
  1393.         pop hl
  1394.         pop af
  1395.         ret
  1396.  
  1397. print_prlinebuf
  1398.         push af
  1399.         push bc
  1400.         push hl
  1401. ;c=texted_WID-число символов
  1402.         ld de,prlinebuf
  1403.         ld a,texted_WID
  1404.         sub c
  1405.         ld l,a
  1406.         ld h,0
  1407.         call sendchars
  1408.         pop hl
  1409.         pop bc
  1410.         pop af
  1411.         ret
  1412.  
  1413. prlinebuf
  1414.         ds texted_WID
  1415.  
  1416. texted_pseudoprline
  1417. ;ahl=addr
  1418. ;out: ahl, CY=error
  1419. ;check for last line (vs. file size)
  1420. ;if filesize-addr < 80, then b=filesize-addr, else b=80
  1421.         call getmaxlinesize ;bc=max line size before eof, z=(bc==0)
  1422.          scf
  1423.         ret z
  1424.         push af
  1425.         push hl
  1426.         call ahl_to_pgaddr
  1427. ;hl=#8000+0..#3fff
  1428. ;bc=max line size before eof != 0
  1429.         push hl
  1430.         ld hl,texted_WID
  1431.         call minhl_bc_tobc
  1432.         ld b,c
  1433.         pop hl
  1434. ;b=number of chars to print != 0
  1435.         ld c,texted_WID
  1436. texted_pseudoprline0
  1437.         ld a,(hl)
  1438.         inc hl
  1439.         cp 0x0d
  1440.         jr z,texted_pseudoprline_cr
  1441.         cp 0x0a
  1442.         jr z,texted_pseudoprline_lf
  1443.         dec c
  1444.         djnz texted_pseudoprline0
  1445.          ld a,(hl)
  1446.          inc hl
  1447.          cp 0x0d
  1448.          jr z,texted_pseudoprline_crok
  1449.          cp 0x0a
  1450.          jr z,texted_pseudoprline_lf
  1451.          dec hl
  1452.         jp texted_nextlineq
  1453. texted_pseudoprline_cr
  1454.         dec b
  1455.         jp z,texted_nextlineq
  1456. texted_pseudoprline_crok
  1457.         ld a,(hl)
  1458.         cp 0x0a
  1459.         jr nz,texted_pseudoprline_lf
  1460.         inc hl
  1461. texted_pseudoprline_lf
  1462.         jp texted_nextlineq
  1463.        
  1464. ;по идее это псевдопечать N экранных позиций (там могут быть цветовые коды и т.п.)
  1465. istherecr_or_lf
  1466. ;hl=addr ;TODO ahl
  1467. ;de=length to search
  1468. ;out: z=found, hl=at match or after area (TODO ahl)
  1469.         ld a,d
  1470.         or e
  1471.         jr z,istherecr_or_lf_fail
  1472.          push hl
  1473.         ld a,0x0d
  1474.         call istherecrlfgo
  1475.         jr z,istherecr_or_lf_popafZret;ret z
  1476.          pop hl
  1477.         ld a,0x0a
  1478. istherecrlfgo
  1479.         push bc
  1480.         ld b,d
  1481.         ld c,e
  1482.         cpir ;TODO несколько раз через все блоки, если заканчиваются блоки, то их переключать
  1483.         pop bc
  1484.         ret nz ;nz=not found
  1485.          dec hl
  1486.         ret ;z=found
  1487. istherecr_or_lf_fail
  1488.         dec a
  1489.         ret ;nz=not found
  1490.        
  1491. istherecr_or_lf_popafZret
  1492.         pop af
  1493.         cp a ;Z
  1494.         ret
  1495.        
  1496. ;texted_closefcb
  1497. ;        ld de,fcb
  1498. ;        OS_FCLOSE
  1499. ;        ret
  1500.  
  1501. texted_help
  1502.         call clearterm
  1503.         ld hl,thelp
  1504.         call prtext
  1505.         call yieldgetkeyloop
  1506.         jp setredrawflag
  1507.  
  1508. thelp
  1509.         db "Keys in texted:\r\n"
  1510.         db "\r\n"
  1511.         db "стрелки, PageUp (Caps Shift+3), PageDown (Caps Shift+4) - движение курсора\r\n"
  1512.         db "Home (Symbol Shift+Q) - переход к началу строки\r\n"
  1513.         db "End (Symbol Shift+E) - переход к концу строки\r\n"
  1514.         db "Symbol Shift+PageUp - переход к началу текста\r\n"
  1515.         db "Symbol Shift+PageDown - переход к концу текста\r\n"
  1516.         db "BackSpace (Caps Shift+0) - удаление символа слева от курсора\r\n"
  1517.         db "Del (Caps Shift+9) - удаление символа справа от курсора\r\n"
  1518.         db "Break (Esc, Caps Shift+Space) - выход\r\n"
  1519.         db "Ins (Symbol Shift+W) - wrap on/off\r\n"
  1520.         db "F1 - help\r\n"
  1521.         db "F2 или Caps Shift+Enter - сохранение\r\n"
  1522.         db "F9 - запустить build.bat из директории с текстом\r\n"
  1523.         db "F10 - сменить кодировку (866/1251)"
  1524.         db 0
  1525.  
  1526.  
  1527. setunchanged
  1528.         ld a,' '
  1529.         jr setchanged_a
  1530. setchanged
  1531.         ld a,'*'
  1532. setchanged_a
  1533.         ld (fchanged),a
  1534.         ret
  1535.  
  1536. iswrapon
  1537. ;CY = on
  1538. wrapflag=$
  1539.         or a ;/scf
  1540.         ret
  1541.  
  1542. curlineaddr
  1543.         ds 3
  1544. curlineaddrHSB=$-1
  1545.  
  1546. nlines
  1547.         dw 0
  1548.  
  1549. curxy
  1550. curx
  1551.         db 0
  1552. cury
  1553.         db 0
  1554.        
  1555.         align 256
  1556. twinto866
  1557.         incbin "../_sdk/codepage/winto866"
  1558. t866towin
  1559.         ds 256,' ' ;incbin "../_sdk/codepage/866towin"
  1560.