home *** CD-ROM | disk | FTP | other *** search
/ FreeWare Collection 2 / FreeSoftwareCollection2pd199x-jp.img / ms_dos / xscrfm51 / xscript.asm < prev    next >
Assembly Source File  |  1990-06-14  |  64KB  |  3,355 lines

  1.     title    xscript version 1.4 for FMR series
  2.     page    66, 132
  3. ;
  4. ;    Transcript service for PC-9801 MS-DOS (Ver 1.4)
  5. ;    Trap int 29h.
  6. ;    Written by  Oka  /  Feb. 7, 1988.
  7. ;    Modified for FMR by SHU on Jan. 1989
  8. ;    Ver. 2.1 by SHU  /  Mar. 11, 1989
  9. ;    Ver. 2.2 by SHU  /  Mar. 21, 1989
  10. ;    Ver. 2.3 by SHU  /  Mar. 25, 1989
  11. ;    Ver. 3.0 by SHU  /  Apr.  1, 1989
  12. ;    Ver. 3.1 by SHU  /  Apr.  7, 1989
  13. ;    Ver. 3.2 by SHU  /  Apr. 11, 1989
  14. ;    Ver. 3.3 by SHU  /  Apr. 22, 1989
  15. ;    Ver. 3.4 by SHU  /  May. 11, 1989
  16. ;    Ver. 4.0 by SHU  /  May. 27, 1989
  17. ;    Ver. 4.1 by SHU  /  Jun. 15, 1989
  18. ;    Ver. 4.2 by SHU  /  Jan. 13, 1990
  19. ;    Ver. 4.3 by SHU  /  Feb. 15, 1990
  20. ;    Ver. 5.0 by SHU  /  Feb. 21, 1990
  21. ;    Ver. 5.1 by SHU  /  Mar.  6, 1990
  22. ;
  23.  
  24. include xscript.h
  25. include kbdrv.h
  26.  
  27.  
  28. ;=======================================;
  29. ;    beginning of code        ;
  30. ;=======================================;
  31. code    segment  byte  public
  32.     assume    cs:code
  33.  
  34.     org    100h
  35.  
  36. stack_top    equ    $
  37.  
  38. start:
  39.     extrn    init : near
  40.     jmp    init        ; initialize
  41.  
  42. public  my_name, my_name_len
  43. my_name        db    'Transcript service Ver 1.4'
  44.         db    '5'            ; FM version 5.x
  45. my_name_len    dw    offset my_name_len - offset my_name
  46.  
  47.  
  48. ;=======================================;
  49. ;        DATA SECTION        ;
  50. ;=======================================;
  51.  
  52. public    int18h_entry
  53. public    int29h_entry
  54. public    org_xint_entry
  55. public    tvram_seg
  56. public    txtbuf_seg
  57. public    tvbuf_seg
  58. public    xbank_on
  59. public    header_char
  60. public    always_paste
  61.  
  62. ;public    current_key
  63. ;public    bottom_key
  64. ;public    paste_key
  65. ;public    disable_key
  66.  
  67. current_key    db    DOWN_ARROW
  68. bottom_key    db    UP_ARROW
  69. IFDEF    FMR
  70.   paste_key    db    HOME
  71.   disable_key    db    CANCEL
  72. ELSE
  73.   paste_key    db    HELP
  74.   disable_key    db    BS_KEY
  75. ENDIF
  76.  
  77. busy_flag    db    OFF
  78. mark_flag    db    OFF
  79. exit_flag    db    OFF
  80. access_flag    db    OFF
  81. case_sensitive    db    OFF
  82. IFDEF    FMR
  83.   public    use_gvram_flag
  84.   public    use_mm_flag
  85.   use_gvram_flag db    OFF
  86.   use_mm_flag    db    OFF
  87.   shift_status    db    0
  88. ENDIF
  89.  
  90. IFNDEF    FMR
  91.   sys_seg    dw    0        ; system area segment
  92. ENDIF
  93. tvram_seg    dw    TVRAM_SEG_R70
  94. txtbuf_seg    dw    TXTBUF_SEG_R70
  95. tvbuf_seg    dw    TVBUF_SEG_R70
  96. banksel_w_port    dw    BANK_PORT_W
  97. xbank_w_on    db    BANK_W_P0
  98. xbank_w_off    db    BANK_OFF_NUM
  99. banksel_port    dw    BANK_PORT
  100. xbank_on    db    BANK_ON_NUM
  101. xbank_off    db    BANK_OFF_NUM
  102. IFDEF    FMR
  103.   IFDEF    FMR70
  104. xbank_now    db    ?        ; current bank save area
  105.   ENDIF
  106. ENDIF
  107.  
  108. user_ax        dw    ?
  109. user_bx        dw    ?
  110. user_cx        dw    ?
  111. user_dx        dw    ?
  112. user_si        dw    ?
  113. user_di        dw    ?
  114. user_bp        dw    ?
  115. user_sp        dw    ?
  116. user_ds        dw    ?
  117. user_es        dw    ?
  118. user_ss        dw    ?
  119.  
  120. kb_sense_cnt    dw    0
  121.  
  122. proc_addr    dw    offset trap29h_normal
  123. str_top        dw    0
  124.  
  125. txtbuf_end    dw    0
  126. last_page_top    dw    0
  127. page_top    label    word
  128. line_top    dw    ROW_WIDTH dup (?)
  129. page_bottom    dw    ?
  130. curr_line_top    dw    ?
  131. curr_line_leng    dw    ?
  132.  
  133. bottom_curs_row    dw    ?
  134. curs_pos_row    dw    ?
  135. curs_pos_col    dw    ?
  136. curs_pos_col_s    dw    ?
  137. curs_pos    dw    ?
  138. old_curs_pos    dw    ?
  139.  
  140. current_ptr    dw    ?
  141. mark_ptr    dw    ?
  142. cutbuf_bgn    dw    ?
  143. cutbuf_ptr    dw    ?
  144. cutbuf_cnt    dw    0
  145. cutbuf_cnt_save    dw    0
  146.  
  147. search_dir    dw    1
  148. search_end    dw    ?
  149.  
  150. read_ptr    dw    0
  151. write_ptr    dw    0
  152.  
  153. int18h_entry    dw    ?
  154.         dw    ?
  155.  
  156. int29h_entry    dw    ?
  157.         dw    ?
  158.  
  159. org_xint_entry    dw    ?
  160.         dw    ?
  161.  
  162. STR_BUF_SIZ    =    16
  163. WORK_BOX_COL    =    COLUMN_WIDTH - STR_BUF_SIZ-3
  164. white_str    db    STR_BUF_SIZ+3  dup (' '), 0
  165. str_buf        db    STR_BUF_SIZ  dup (?)
  166. str_len        dw    ?
  167.  
  168. label_msg    db    ' set label  ', 0
  169. goto_msg    db    ' goto label ', 0
  170. clear_msg    db    '            ', 0
  171.  
  172. label_table    dw    (7fh - 20h) dup(0)
  173.  
  174. ;                    ; 画面分割パラメータ
  175. ;screen_list    label    word
  176. ;divs_data    dw    XURAVRAM
  177. ;row_width_0    dw    ROW_WIDTH
  178. ;row_width_3    dw    ROW_WIDTH * COLUMN_WIDTH * 2
  179. ;row_width_4    dw    25 - ROW_WIDTH
  180. ;        dw    3 dup (0,0)
  181. ;
  182. ;screen_list_save  dw    1
  183. ;        dw    0
  184. ;        dw    25d
  185. ;        dw    6 dup (0)
  186.  
  187. row_width_0_1    dw    ROW_WIDTH
  188. row_width_0_2    dw    ROW_WIDTH
  189. row_width_1    dw    ROW_WIDTH - 1
  190. row_width_2    dw    ROW_WIDTH * COLUMN_WIDTH
  191.  
  192. header_char    db    '>'
  193. this_line_hc    db    0
  194. this_paste_hc    db      0
  195. always_paste    db    0        ; include header char with SHIFT key
  196. lastpaste    db    0
  197.  
  198. search_msg    db    '  search...        ',0
  199. found_msg    db    '  found.           ',0
  200. nfound_msg    db    '  not found.       ',0
  201. break_msg    db    '  broken.          ',0
  202.  
  203. ;        dw    128 dup (?)        ; stack area
  204. ;stack_top    dw    ?
  205.  
  206. ;edit_buf    db    260 dup (?)
  207.  
  208.  
  209. ;=======================================;
  210. ;        CODE SECTION        ;
  211. ;=======================================;
  212.  
  213. ;---------------------------------------;
  214. ;    BANK select routine        ;
  215. ;---------------------------------------;
  216. selbank:                ; select bank for transcript buffer
  217. IFDEF    FMR
  218.   IFDEF    FMR70
  219.     cmp    cs:use_mm_flag, ON
  220.     je    sel_bank9
  221.     cmp    cs:use_gvram_flag, ON
  222.     jne    sel_bank1
  223.     
  224.     push    dx
  225.     mov    dx, cs:banksel_w_port    ; set write plane port address
  226.     in    al, dx
  227.     mov    cs:xbank_w_off, al    ; save old status
  228.     mov    al, cs:xbank_w_on
  229.     out    dx, al
  230.     pop    dx
  231. sel_bank1:
  232.     push    dx
  233.     mov    dx, cs:banksel_port
  234.     in    al, dx
  235.     mov    cs:xbank_off, al
  236.     mov    al, cs:xbank_on
  237.     mov    cs:xbank_now, al    ; save current bank
  238.     out    dx, al
  239.     pop    dx
  240. sel_bank9:
  241.   ENDIF
  242. ELSE
  243.     push    dx
  244.     mov    dx, cs:banksel_port
  245.     mov    al, cs:xbank_on
  246.     out    dx, al
  247.     pop    dx
  248. ENDIF
  249.     ret
  250.  
  251.  
  252. unselbank:                ; select bank for other jobs
  253. IFDEF    FMR
  254.   IFDEF    FMR70
  255.     cmp    cs:use_mm_flag, ON
  256.     je    unsel_bank9
  257.     cmp    cs:use_gvram_flag, ON
  258.     jne    unsel_bank1
  259.     
  260.     push    dx
  261.     mov    dx, cs:banksel_w_port
  262.     mov    al, cs:xbank_w_off
  263.     out    dx, al
  264.     pop    dx
  265. unsel_bank1:
  266.     push    dx
  267.     mov    dx, cs:banksel_port
  268.     mov    al, cs:xbank_off
  269.     mov    cs:xbank_now, al    ; save current bank
  270.     out    dx, al
  271.     pop    dx
  272. unsel_bank9:
  273.   ENDIF
  274. ELSE
  275.     push    dx
  276.     mov    dx, cs:banksel_port
  277.     mov    al, cs:xbank_off
  278.     out    dx, al
  279.     pop    dx
  280. ENDIF
  281.     ret
  282.  
  283. IFDEF    FMR
  284.   IFDEF    FMR70
  285. refbank:
  286.     push    dx
  287.     push    ax
  288.     mov    dx, cs:banksel_port
  289.     mov    al, cs:xbank_now
  290.     out    dx, al
  291.     pop    ax
  292.     pop    dx
  293.     ret
  294.   ENDIF
  295. ENDIF
  296.  
  297.  
  298. ;---------------------------------------;
  299. ;    int 18h trap routine        ;
  300. ;    int 90h trap routine for FM    ;
  301. ;---------------------------------------;
  302. public    trap18h_entry
  303. trap18h_entry:
  304. IFDEF    FMR
  305.     push    ax
  306.     cmp    cs:cutbuf_cnt, 0
  307.     jz    trap18h_exit
  308.     cmp    ah, 7            ; KB sense ?
  309.     je    trap18h1
  310.     cmp    ah, 9            ; KB read ?
  311.     jne    trap18h_exit
  312. trap18h1:
  313.   IFDEF    FMR70
  314.       pushf                ; save interrupt flag
  315.       cli                ; mask interrupt
  316.   ENDIF
  317.     call    selbank
  318.     call    data_move
  319.     call    unselbank
  320.   IFDEF    FMR70
  321.       popf                ; restore interrupt flag
  322.   ENDIF
  323. trap18h_exit:
  324.     push    dx
  325.     cmp    ah, 9            ; 文字読込でなければ,無視
  326.     jne    kb_thru
  327.     mov    ah, 3            ; コード系読取
  328.     int    90h
  329.     test    dh, 0c0h        ; スキャンモードであれば,無視
  330.     jne    kb_thru
  331.     pop    dx
  332.     pop    ax
  333.     push    ax
  334.     pushf
  335.     call    dword ptr cs:int18h_entry
  336.     test    bl, 00010000b        ; CTRL?
  337.     jz    kbtrap9
  338.     test    bl, 01101000b        ; other bits except SHIFT ON?
  339.     jnz    kbtrap9            ; Yes, skip
  340.     mov    al, bh
  341.     mov    ah, 3
  342.     cmp    al, cs:paste_key
  343.     je    short kbtrap3
  344.     test    bl, 00000100b        ; SHIFT bit ON?
  345.     jnz    kbtrap9            ; Yes, skip
  346.     mov    ah, 0
  347.     cmp    al, cs:current_key
  348.     je    short kbtrap3
  349.     mov    ah, 1
  350.     cmp    al, cs:bottom_key
  351.     je    short kbtrap3
  352.     mov    ah, 6
  353.     cmp    al, cs:disable_key
  354.     jne    short kbtrap9
  355. kbtrap3:
  356.     mov    cs:shift_status, bl    ; save shift status
  357.     int    XSERV_INT
  358.     pop    ax
  359.     jmp    trap18h_entry
  360. kbtrap9:
  361.     add    sp, 2            ; dummy pop for ax
  362.     iret
  363. ;
  364. kb_thru:
  365.     pop    dx
  366.     pop    ax
  367.     jmp    dword ptr cs:int18h_entry
  368. ELSE
  369.     sti
  370.     cmp    cs:cutbuf_cnt, 0
  371.     jz    trap18h_exit
  372.     cmp    ah, 1            ; KB read or sense or other ?
  373.     ja    trap18h_exit
  374.     push    es
  375.     mov    es, cs:sys_seg
  376.     cmp    byte ptr es:[KBUF_CNT], 0
  377.     pop    es
  378.     jnz    trap18h_exit
  379.     test    ah, ah
  380.     jz    trap18h1
  381.     cmp    cs:kb_sense_cnt, 0    ; KB sense.
  382.     jz    trap18h1
  383.     dec    cs:kb_sense_cnt
  384.     jmp    short trap18h_exit
  385. trap18h1:
  386.     mov    cs:kb_sense_cnt, 1
  387.     call    selbank
  388.     call    data_move
  389.     call    unselbank
  390. trap18h_exit:
  391.     jmp    dword ptr cs:int18h_entry
  392. ENDIF
  393. ;
  394. data_move:
  395.     push    ax
  396.     push    si
  397.     push    di
  398.     push    ds
  399. IFNDEF    FMR
  400.     push    es
  401. ENDIF
  402.  
  403.     mov    ds, cs:txtbuf_seg
  404. IFNDEF    FMR
  405.     mov    es, cs:sys_seg
  406. ENDIF
  407.     mov    si, cs:cutbuf_ptr
  408.     sub    ax, ax
  409.     cld
  410.     
  411.     mov    al, cs:this_line_hc
  412.     cmp    al, 0
  413.     je    dtmove1
  414. IFNDEF    FMR
  415.     cmp    byte ptr es:[KBUF_CNT], KBUF_SIZ
  416.     jae    dtmove9
  417. ENDIF
  418.     call    putchar
  419. IFDEF    FMR
  420.     jne    dtmove9            ; error ?
  421. ENDIF
  422.     mov    cs:this_paste_hc, al
  423.     mov    cs:this_line_hc, 0
  424. ;    inc    cs:cutbuf_cnt
  425. ;    jmp    short dtmove3
  426. dtmove1:
  427. IFNDEF    FMR
  428.     cmp    byte ptr es:[KBUF_CNT], KBUF_SIZ
  429.     jae    dtmove9
  430. ENDIF
  431.     lodsb
  432. dtmove3:
  433.     call    putchar
  434. IFDEF    FMR
  435.     jne    dtmove9            ; error ?
  436. ENDIF
  437.     mov    cs:cutbuf_ptr, si
  438.     dec    cs:cutbuf_cnt
  439.     jz    dtmove9
  440.     cmp    al, CR
  441.     jne    dtmove1
  442.     
  443.     mov    al, cs:this_paste_hc
  444.     mov    cs:this_line_hc, al
  445.     
  446. dtmove9:
  447. IFNDEF    FMR
  448.     pop    es
  449. ENDIF
  450.     pop    ds
  451.     pop    di
  452.     pop    si
  453.     pop    ax
  454.     ret
  455. ;
  456. putchar:
  457.     cmp    ax, TAB_CHAR
  458.     je    putch0_0
  459.     cmp    ax, NTAB_CHAR
  460.     jne    putch0
  461.     cmp    cs:lastpaste, TAB
  462.     je    putch2
  463. putch0_0:
  464.     mov    ax, TAB
  465. putch0:
  466.     mov    cs:lastpaste, al
  467. IFDEF    FMR
  468.     push    cx
  469.     push    ds
  470.     mov    cs:kb_sense_cnt, ax    ; save character
  471.     mov    ah, 0bh            ; 入力文字列の追加
  472.     mov    al, 1            ; バッファの最後に追加
  473.     mov    cx, 1            ; 1文字
  474.     mov    di, cs
  475.     mov    ds, di
  476.     mov    di, offset kb_sense_cnt
  477.     int    90h
  478.   IFDEF    FMR70
  479.       call    refbank
  480.   ENDIF
  481.     pop    ds
  482.     pop    cx
  483.     test    ah, ah            ; if error, return not ZERO
  484.     mov    ax, cs:kb_sense_cnt    ; restore character
  485. putch2:
  486. ELSE
  487.     cli
  488.     cmp    byte ptr es:[KBUF_CNT], KBUF_SIZ
  489.     jae    putch2
  490.     mov    di, es:[KBUF_WPTR]    ; write pointer.
  491.     stosw
  492.     cmp    di, KBUF_END
  493.     jb    putch1
  494.     mov    di, KBUF_BGN
  495. putch1:
  496.     mov    es:[KBUF_WPTR], di
  497.     inc    byte ptr es:[KBUF_CNT]
  498. putch2:
  499.     sti
  500. ENDIF
  501.     ret
  502.  
  503.  
  504. ;---------------------------------------;
  505. ;    int 29h trap routine        ;
  506. ;---------------------------------------;
  507. public    trap29h_entry
  508. trap29h_entry:
  509.     call    cs:proc_addr
  510.     jmp    dword ptr cs:int29h_entry
  511.  
  512. ;
  513. trap29h_thru:
  514.     cmp    al, ESCAPE
  515.     je    thru1
  516.     cmp    al, CR
  517.     jne    thru0
  518.     call    show_thru_flag
  519. thru0:
  520.     ret
  521. thru1:
  522.     mov    cs:proc_addr, offset trap29h_thru2
  523.     ret
  524. ;
  525. trap29h_thru2:
  526.     cmp    al, '1'
  527.     je    thru2_1
  528.     mov    cs:proc_addr, offset trap29h_thru
  529.     ret
  530. thru2_1:
  531.     mov    cs:proc_addr, offset trap29h_normal
  532.     call    clear_thru_flag
  533.     ret
  534.  
  535. ;
  536. trap29h_normal:
  537.     push    es
  538.     push    di
  539.     push    cx
  540. IFDEF    FMR
  541.   IFDEF    FMR70
  542.       pushf                ; save interrupt flag
  543.       cli                ; mask interrupt
  544.   ENDIF
  545. ENDIF
  546.     push    ax
  547.  
  548.     call    selbank            ; select trascript bank
  549.     mov    es, cs:txtbuf_seg
  550.     mov    di, cs:write_ptr
  551.     pop    ax
  552.     push    ax
  553.     cld
  554.     cmp    al, ' '
  555.     jae    trap29h5
  556.     cmp    al, CR
  557.     je    trap29h9
  558.     cmp    al, BS
  559.     jne    trap29h1
  560.     dec    di
  561.     jmp    short trap29h7
  562. trap29h1:
  563.     cmp    al, TAB
  564.     jne    trap29h2
  565.     mov    ax, di
  566.     sub    ax, cs:str_top
  567.     and    ax, 7
  568.     mov    cx, 8
  569.     sub    cx, ax
  570.     mov    al, TAB_CHAR        ; '->'
  571. trap29hA:
  572.     stosb
  573.     cmp    cs:read_ptr, di
  574.     jnz    trap29hB
  575.     inc    word ptr cs:read_ptr
  576. trap29hB:
  577.     mov    al, NTAB_CHAR
  578.     loop    trap29hA
  579.     jmp    short trap29h7
  580. trap29h2:
  581.     cmp    al, LF
  582.     jne    trap29h3
  583.     mov    al, CR
  584.     stosb
  585.     mov    cs:str_top, di
  586.     jmp    short trap29h7
  587. trap29h3:
  588.     cmp    al, FS
  589.     jne    trap29h4
  590.     inc    di
  591.     jmp    short trap29h7
  592. trap29h4:
  593.     cmp    al, ESCAPE
  594.     jne    trap29h9
  595.     mov    cs:proc_addr, offset esc_proc
  596.     jmp    short trap29h9
  597. trap29h5:
  598.     stosb                ; save character
  599. trap29h7:
  600.     mov    ax, di
  601.     sub    ax, cs:str_top
  602.     cmp    ax, COLUMN_WIDTH*20
  603.     jne    trap29h8
  604.     mov    al, CR
  605.     stosb
  606.     mov    cs:str_top, di
  607. trap29h8:
  608.     mov    cs:write_ptr, di
  609.     cmp    cs:read_ptr, di
  610.     jne    trap29h9
  611.     mov    cx, COLUMN_WIDTH
  612.     mov    al, CR
  613.     repne    scasb
  614.     mov    cs:read_ptr, di
  615. trap29h9:
  616.     call    unselbank        ; select normal bank
  617.  
  618.     pop    ax
  619. IFDEF    FMR
  620.   IFDEF    FMR70
  621.       popf                ; restore interrupt flag
  622.   ENDIF
  623. ENDIF
  624.     pop    cx
  625.     pop    di
  626.     pop    es
  627.     ret
  628.  
  629.  
  630. ;---------------------------------------;
  631. ;    escape sequence procedure    ;
  632. ;---------------------------------------;
  633. esc_proc:
  634.     cmp    al, '['
  635.     jne    esc_proc1
  636.     mov    cs:proc_addr, offset esc_proc6
  637.     ret
  638. esc_proc1:
  639.     cmp    al, '='
  640.     jne    esc_proc2
  641.     mov    cs:proc_addr, offset esc_proc3
  642.     ret
  643. esc_proc2:
  644.     cmp    al, ')'
  645.     jne    esc_proc4
  646. esc_proc3:
  647.     mov    cs:proc_addr, offset esc_proc5
  648.     ret
  649. esc_proc4:
  650.     cmp    al, '0'
  651.     jne    esc_proc5
  652.     mov    cs:proc_addr, offset trap29h_thru
  653.     call    show_thru_flag
  654.     ret
  655. esc_proc5:
  656.     mov    cs:proc_addr, offset trap29h_normal
  657.     ret
  658. ;
  659. esc_proc6:                    ; '['
  660.     cmp    al, 'A'
  661.     jb    esc_proc7
  662.     cmp    al, 'Z'
  663.     jbe    esc_proc5
  664.     cmp    al, 'a'
  665.     jb    esc_proc7
  666.     cmp    al, 'z'
  667.     jbe    esc_proc5
  668. esc_proc7:
  669.     ret
  670.  
  671.  
  672. ;=======================================;
  673. ;    Transcript Service Entry    ;
  674. ;  In : AH = function code        ;
  675. ;=======================================;
  676. public    xservice_entry
  677. xservice_entry:
  678.     cmp    cs:busy_flag, OFF
  679.     je    xserv_ok
  680.     iret
  681. xserv_ok:
  682.     mov    cs:user_ax, ax        ; レジスターの保存
  683.     mov    cs:user_bx, bx
  684.     mov    cs:user_cx, cx
  685.     mov    cs:user_dx, dx
  686.     mov    cs:user_si, si
  687.     mov    cs:user_di, di
  688.     mov    cs:user_bp, bp
  689.     mov    cs:user_sp, sp
  690.     mov    cs:user_ds, ds
  691.     mov    cs:user_es, es
  692.     mov    cs:user_ss, ss        ;
  693.  
  694.     mov    ax, cs
  695.     mov    ss, ax
  696.     mov    sp, offset stack_top    ; スタックの切り換え
  697.  
  698. IFDEF    FMR
  699.     call    clear_keybuf
  700. ELSE
  701.     sub    ax, ax
  702.     mov    es, ax
  703.     mov    word ptr es:[KBUF_RPTR], KBUF_BGN
  704.     mov    word ptr es:[KBUF_WPTR], KBUF_BGN
  705.     mov    byte ptr es:[KBUF_CNT], 0
  706. ENDIF
  707.  
  708.     mov    cs:busy_flag, ON
  709.     mov    cs:cutbuf_cnt, 0
  710.     sti
  711.  
  712.     mov    ax, cs:user_ax
  713.     cmp    ah, FUNC_MAX
  714.     ja    xserv_bad_func
  715.     sub    bx, bx
  716.     mov    bl, ah
  717.     add    bx, bx
  718.     call    word ptr cs:jump_tbl[bx]    ; call each function.
  719. xserv_bad_func:
  720.     cli
  721.     mov    ax, cs:user_ax        ; レジスターの回復
  722.     mov    bx, cs:user_bx
  723.     mov    cx, cs:user_cx
  724.     mov    dx, cs:user_dx
  725.     mov    si, cs:user_si
  726.     mov    di, cs:user_di
  727.     mov    bp, cs:user_bp
  728.     mov    sp, cs:user_sp
  729.     mov    ds, cs:user_ds
  730.     mov    es, cs:user_es
  731.     mov    ss, cs:user_ss        ;
  732.  
  733.     mov    cs:busy_flag, OFF
  734.     iret
  735.  
  736. ;
  737. jump_tbl   dw    offset xserv0
  738.        dw    offset xserv1
  739.        dw    offset xserv2
  740.        dw    offset xserv3
  741.        dw    offset xserv4
  742.        dw    offset xserv5
  743.        dw    offset xserv6
  744.        dw    offset xserv7
  745.  
  746. ;
  747. xserv2:
  748. xserv4:
  749. xserv5:
  750.     ret
  751.  
  752.  
  753. ;---------------------------------------;
  754. ;    透過/非透過モードの設定    ;
  755. ;---------------------------------------;
  756. xserv6:
  757. ;    mov    es, cs:tvram_seg
  758.     cmp    cs:proc_addr, offset trap29h_thru
  759.     je    xserv6_1
  760.     mov    cs:proc_addr, offset trap29h_thru
  761. ;    mov    byte ptr es:[COLUMN_WIDTH*24*2], '!'
  762.     call    show_thru_flag
  763.     ret
  764. xserv6_1:
  765.     mov    cs:proc_addr, offset trap29h_normal
  766. ;    mov    byte ptr es:[COLUMN_WIDTH*24*2], ' '
  767.     call    clear_thru_flag
  768.     ret
  769.  
  770.  
  771. ;---------------------------------------;
  772. ;    transcriptバッファの読み出し    ;
  773. ;---------------------------------------;
  774. xserv7:
  775. IFDEF    FMR
  776.   IFDEF    FMR70
  777.       pushf                ; save interrupt flag
  778.       cli                ; mask interrupt
  779.   ENDIF
  780. ENDIF
  781.     call    selbank            ; select transcript bank
  782.     mov    ds, cs:txtbuf_seg
  783.     mov    cs:user_ax, 0
  784.     mov    es, cs:user_ds
  785.     mov    di, cs:user_dx
  786.     mov    cx, cs:user_cx
  787.     mov    ax, cs:cutbuf_cnt_save    ; test cut region length
  788.     test    ax, ax
  789.     jz    xserv7_01        ; save all buffer
  790.     mov    si, cs:cutbuf_bgn
  791.     jmp    short xserv7_02
  792. xserv7_01:
  793.     mov    si, cs:read_ptr
  794.     mov    ax, cs:write_ptr
  795.     sub    ax, si
  796. xserv7_02:
  797.     sub    ax, cs:user_bx
  798.     jbe    xserv7_2
  799.     add    si, cs:user_bx
  800.     cmp    ax, cx
  801.     jae    xserv7_1
  802.     mov    cx, ax
  803. xserv7_1:
  804.     mov    cs:user_ax, cx
  805.     cld
  806.     rep    movsb
  807. ;    ret
  808. xserv7_2:
  809.     call    unselbank        ; select normal bank
  810. IFDEF    FMR
  811.   IFDEF    FMR70
  812.       popf                ; restore interrupt flag
  813.   ENDIF
  814. ENDIF
  815.     ret
  816.  
  817.  
  818. ;---------------------------------------;
  819. ;    カット領域のペースト        ;
  820. ;---------------------------------------;
  821. xserv3:
  822. IFNDEF    FMR
  823.     call    check_ISR
  824.     jnz    xserv3_9
  825. ENDIF
  826. IFDEF    FMR
  827.     mov    al, cs:shift_status
  828.     shr    al, 1            ; move SHIFT bit to LSB
  829.     shr    al, 1
  830. ELSE
  831.     mov    es, cs:sys_seg
  832.     mov    al, byte ptr es:[SHIFT_STTS]
  833. ENDIF
  834.     and    al, 1
  835.     xor    al, cs:always_paste
  836.     jz    xserv3_1
  837.     mov    al, cs:header_char
  838. xserv3_1:
  839.     mov    cs:this_line_hc, al
  840.     mov    cs:this_paste_hc, 0
  841.     mov    ax, cs:cutbuf_bgn
  842.     mov    cs:cutbuf_ptr, ax
  843.     mov    ax, cs:cutbuf_cnt_save
  844.     mov    cs:cutbuf_cnt, ax
  845. xserv3_9:
  846.     ret
  847.  
  848.  
  849. ;---------------------------------------;
  850. ;    transcript画面の表示        ;
  851. ;---------------------------------------;
  852. xserv0:
  853. xserv1:
  854. IFNDEF    FMR
  855.     call    check_ISR
  856.     jnz    xserv0_9        ; other interrupt in-service.
  857. ENDIF
  858. IFDEF    FMR
  859.   IFDEF    FMR70
  860.       pushf                ; save interrupt flag
  861.       cli                ; mask interrupt
  862.   ENDIF
  863. ENDIF
  864.     call    selbank            ; select GVRAM 1
  865.     call    save_screen
  866.     call    xserv_main
  867.     call    restore_screen
  868.     call    unselbank        ; select GVRAM 0
  869. IFDEF    FMR
  870.   IFDEF    FMR70
  871.       popf                ; restore interrupt flag
  872.   ENDIF
  873. ENDIF
  874. xserv0_9:
  875.     ret
  876. ;
  877. IFNDEF    FMR
  878. check_ISR:
  879.     mov    al, 00001011b
  880.     out    00h, al
  881.     in    al, 00h            ; read ISR of master PIC
  882.     test    al, 11111101b        ; other interrupt in-service ?
  883.     ret
  884. ENDIF
  885.  
  886.  
  887. ;---------------------------------------;
  888. ;    transcript service main        ;
  889. ;---------------------------------------;
  890. xserv_main:
  891.     mov    ds, cs:txtbuf_seg
  892.     mov    es, cs:tvram_seg
  893.     mov    cs:mark_flag, OFF
  894.  
  895.     call    find_last_page
  896.     cmp    cs:access_flag, ON
  897.     jne    xmain0
  898.     mov    ax, cs:user_ax
  899.     cmp    ah, 1
  900.     je    xmain0
  901.     mov    si, cs:page_top        ; ゼンカイト オナジ イチノ ヒョウジ
  902.     jmp    short xmain1
  903. xmain0:
  904.     mov    cs:access_flag, ON
  905.     mov    ax, cs:bottom_curs_row
  906.     mov    cs:curs_pos_row, ax
  907.     mov    cs:curs_pos_col, 0
  908.     mov    cs:curs_pos_col_s, 0
  909. xmain1:
  910.     call    disp_one_screen        ; display one screen.
  911.     call    adjust_curs_pos
  912.     call    disp_cursor        ; set cursor at the scroll region.
  913.     mov    cs:exit_flag, OFF
  914. xmain2:
  915.     call    getchar            ; get 1 character.
  916.     call    clear_keybuf
  917.     call    bifurcation
  918.     cmp    cs:exit_flag, ON
  919.     jne    xmain2
  920.  
  921.     ret
  922.  
  923.  
  924. ;---------------------------------------;
  925. ;    bifurcation table        ;
  926. ;    offset    description        ;
  927. ;      0     scan code        ;
  928. ;      1     character code 1    ;
  929. ;      2     character code 2    ;
  930. ;      3     character code 3    ;
  931. ;      4     function offset    ;
  932. ;---------------------------------------;
  933. bifur_tbl  label  byte
  934. IFDEF    FMR
  935.     db    PF6_KEY, -1, -1, -1
  936.     dw                    offset prev_page
  937.     db    PF7_KEY, -1, -1, -1
  938.     dw                    offset next_page
  939.     db    PF10_KEY, -1, -1, -1
  940.     dw                    offset set_mark    
  941.     db    ENTER, -1, -1, -1
  942.     dw                    offset cut_region  
  943. ENDIF
  944.     db    UP_ARROW, 'E', 'e', CTRL_E
  945.     dw                    offset cursor_up   
  946.     db    LEFT_ARROW, 'S', 's', CTRL_S
  947.     dw                    offset cursor_left 
  948.     db    RIGHT_ARROW, 'D', 'd', CTRL_D
  949.     dw                    offset cursor_right
  950.     db    DOWN_ARROW, 'X', 'x', CTRL_X
  951.     dw                    offset cursor_down 
  952.     db    -1, 'A', 'a', -1
  953.     dw                    offset cursor_prev_word 
  954.     db    -1, 'F', 'f', -1
  955.     dw                    offset cursor_next_word 
  956.     db    -1,  -1,  -1, CTRL_A
  957.     dw                    offset cursor_left_end 
  958.     db    -1,  -1,  -1, CTRL_F
  959.     dw                    offset cursor_right_end 
  960. IFDEF    FMR
  961.     db    ROLL_UP, 'Z', 'z', CTRL_Z
  962.     dw                    offset scroll_up   
  963.     db    ROLL_DOWN, 'W', 'w', CTRL_W
  964.     dw                    offset scroll_down 
  965.     db    -1, 'R', 'r', CTRL_R
  966.     dw                    offset prev_page
  967.     db    -1, 'C', 'c', CTRL_C
  968.     dw                    offset next_page
  969. ELSE
  970.     db    -1, 'Z', 'z', CTRL_Z
  971.     dw                    offset scroll_up   
  972.     db    -1, 'W', 'w', CTRL_W
  973.     dw                    offset scroll_down 
  974.     db    ROLL_DOWN, 'R', 'r', CTRL_R
  975.     dw                    offset prev_page   
  976.     db    ROLL_UP, 'C', 'c', CTRL_C
  977.     dw                    offset next_page   
  978. ENDIF
  979.     db    -1, 'B', 'b', -1
  980.     dw                    offset buf_bottom  
  981.     db    -1, 'T', 't', -1
  982.     dw                    offset buf_top     
  983.     db    -1,  -1,  -1, CTRL_T
  984.     dw                    offset to_page_top 
  985.     db    -1,  -1,  -1, CTRL_B
  986.     dw                    offset to_page_bottom 
  987.     db    INS, 'M', 'm', -1
  988.     dw                    offset set_mark    
  989.     db    DEL, 'O', 'o', -1
  990.     dw                    offset cut_region  
  991.     db    CR_KEY, 'P', 'p', CTRL_P
  992.     dw                    offset copy_region 
  993. IFDEF    FMR
  994.     db    HOME, -1, -1, 1Dh
  995.     dw                    offset show_help
  996. ENDIF
  997.     db    -1,  -1,  -1, CTRL_K
  998.     dw                    offset cut_to_eol  
  999.     db    -1,  -1,  -1, CTRL_U
  1000.     dw                    offset cut_to_bol  
  1001.     db    -1, 'K', 'k', -1
  1002.     dw                    offset copy_to_eol 
  1003.     db    -1, 'U', 'u', -1
  1004.     dw                    offset copy_to_bol 
  1005.     db    -1, '/', -1, -1
  1006.     dw                    offset forw_search
  1007.     db    -1, '?', -1, -1
  1008.     dw                    offset back_search
  1009.     db    -1, 'N', 'n', -1
  1010.     dw                    offset forw_next
  1011.     db    -1, -1, -1, CTRL_N
  1012.     dw                    offset back_next
  1013.     db    -1, 'L', 'l', -1
  1014.     dw                    offset set_label
  1015.     db    -1, "'", -1, -1
  1016.     dw                    offset goto_label
  1017.         db      -1, '>', ':', '-'
  1018.         dw                                      offset header_set
  1019. IFDEF    FMR
  1020.     db    -1, -1, -1, ESCAPE
  1021.     dw                    offset exit      
  1022. ELSE
  1023.     db    HOME, -1, -1, ESCAPE
  1024.     dw                    offset exit      
  1025.     db    HELP, -1, -1, 1Dh
  1026.     dw                    offset show_help
  1027. ENDIF
  1028.     db    0, 0, 0, 0
  1029.     dw    0
  1030.  
  1031.  
  1032. ;---------------------------------------;
  1033. ;    ファンクションの分岐        ;
  1034. ;  In : AH = Keyboard scan code        ;
  1035. ;    AL = character code        ;
  1036. ;---------------------------------------;
  1037. bifurcation:
  1038. ;ifdef    FMR
  1039. ;    mov    cx, 29            ; added PF6, PF7, PF10 and ENTER
  1040. ;else
  1041. ;    mov    cx, 25
  1042. ;endif
  1043.     mov    bx, offset bifur_tbl
  1044. bifur1:
  1045.     cmp    ah, cs:[bx]
  1046.     je    bifur2
  1047.     cmp    al, cs:[bx+1]
  1048.     je    bifur2
  1049.     cmp    al, cs:[bx+2]
  1050.     je    bifur2
  1051.     cmp    al, cs:[bx+3]
  1052.     je    bifur2
  1053.     add    bx, 6
  1054.     cmp    word ptr cs:[bx+4], 0    ; end of function ?
  1055.     jne    bifur1
  1056.     ret
  1057. bifur2:
  1058.     call    word ptr cs:[bx+4]
  1059.     ret
  1060.  
  1061.  
  1062. ;---------------------------------------;
  1063. ;    疑似カーソルを1行上に        ;
  1064. ;---------------------------------------;
  1065. cursor_up:
  1066.     mov    ax, cs:curr_line_top
  1067.     cmp    ax, cs:read_ptr
  1068.     je    curs_up9
  1069.     cmp    cs:curs_pos_row, 0
  1070.     jne    curs_up0
  1071.     jmp    scroll_down
  1072. curs_up0:
  1073.     call    clear_cursor
  1074.     dec    cs:curs_pos_row
  1075.     call    adjust_curs_pos
  1076.     call    reverse_region
  1077.     call    disp_cursor
  1078. curs_up9:
  1079.     ret
  1080.  
  1081.  
  1082. ;---------------------------------------;
  1083. ;    疑似カーソルを1文字左に    ;
  1084. ;---------------------------------------;
  1085. cursor_left:
  1086.     mov    ax, cs:current_ptr
  1087.     cmp    ax, cs:read_ptr
  1088.     je    curs_l9
  1089.     mov    ax, cs:curs_pos_col
  1090.     mov    cs:curs_pos_col_s, ax
  1091.     call    clear_cursor
  1092.     cmp    cs:curs_pos_col_s, 0
  1093.     jne    curs_l1
  1094.     call    cursor_up
  1095.     call    cursor_right_end
  1096.     ret
  1097. curs_l1:
  1098.     dec    cs:curs_pos_col_s
  1099.     call    adjust_curs_pos
  1100.     call    reverse_region
  1101.     call    disp_cursor
  1102. curs_l9:
  1103.     ret
  1104.  
  1105.  
  1106. ;---------------------------------------;
  1107. ;    疑似カーソルを1文字右に    ;
  1108. ;---------------------------------------;
  1109. cursor_right:
  1110.     mov    ax, cs:current_ptr
  1111.     cmp    ax, cs:txtbuf_end
  1112.     je    curs_r9
  1113.     mov    ax, cs:curs_pos_col
  1114.     mov    cs:curs_pos_col_s, ax
  1115.     cmp    ax, cs:curr_line_leng
  1116.     jb    curs_r2
  1117.     call    cursor_down
  1118.     call    cursor_left_end
  1119.     ret
  1120. curs_r2:
  1121.     call    clear_cursor
  1122.     inc    cs:curs_pos_col_s
  1123.     call    adjust_curs_pos
  1124.     call    reverse_region
  1125.     call    disp_cursor
  1126. curs_r9:
  1127.     ret
  1128.  
  1129.  
  1130. ;---------------------------------------;
  1131. ;    疑似カーソルを1行下に        ;
  1132. ;---------------------------------------;
  1133. cursor_down:
  1134.     mov    ax, cs:curr_line_top
  1135.     cmp    ax, cs:txtbuf_end
  1136.     je    curs_dn9
  1137.     cmp    cs:curs_pos_row, ROW_WIDTH - 1
  1138.     jnae    curs_dn0
  1139.     jmp    scroll_up
  1140. curs_dn0:
  1141.     call    clear_cursor
  1142.     inc    cs:curs_pos_row
  1143.     call    adjust_curs_pos
  1144.     call    reverse_region
  1145.     call    disp_cursor
  1146. curs_dn9:
  1147.     ret
  1148.  
  1149.  
  1150. ;---------------------------------------;
  1151. ;    疑似カーソルを前の単語に    ;
  1152. ;---------------------------------------;
  1153. cursor_prev_word:
  1154.     mov    ax, cs:current_ptr
  1155.     cmp    ax, cs:read_ptr
  1156.     je    curs_pw9
  1157. curs_pw1:
  1158.     call    cursor_left
  1159.     mov    bx, cs:current_ptr
  1160.     cmp    bx, cs:read_ptr
  1161.     je    curs_pw9
  1162.     cmp    byte ptr [bx], ' '
  1163.     jbe    curs_pw1
  1164. curs_pw2:
  1165.     cmp    byte ptr [bx-1], ' '
  1166.     jbe    curs_pw9
  1167.     call    cursor_left
  1168.     mov    bx, cs:current_ptr
  1169.     cmp    bx, cs:read_ptr
  1170.     jne    curs_pw2
  1171. curs_pw9:
  1172.     ret
  1173.  
  1174.  
  1175. ;---------------------------------------;
  1176. ;    疑似カーソルを次の単語に    ;
  1177. ;---------------------------------------;
  1178. cursor_next_word:
  1179.     mov    bx, cs:current_ptr
  1180.     cmp    bx, cs:txtbuf_end
  1181.     je    curs_nw9
  1182.     cmp    byte ptr [bx], ' '
  1183.     jbe    curs_nw2
  1184. curs_nw1:
  1185.     call    cursor_right
  1186.     mov    bx, cs:current_ptr
  1187.     cmp    bx, cs:txtbuf_end
  1188.     je    curs_nw9
  1189.     cmp    byte ptr [bx], ' '
  1190.     ja    curs_nw1
  1191. curs_nw2:
  1192.     call    cursor_right
  1193.     mov    bx, cs:current_ptr
  1194.     cmp    bx, cs:txtbuf_end
  1195.     je    curs_nw9
  1196.     cmp    byte ptr [bx], ' '
  1197.     jbe    curs_nw2
  1198. curs_nw9:
  1199.     ret
  1200.  
  1201.  
  1202. ;---------------------------------------;
  1203. ;    疑似カーソルを行頭に        ;
  1204. ;---------------------------------------;
  1205. cursor_left_end:
  1206.     call    clear_cursor
  1207.     mov    cs:curs_pos_col_s, 0
  1208.     call    adjust_curs_pos
  1209.     call    reverse_region
  1210.     call    disp_cursor
  1211.     ret
  1212.  
  1213.  
  1214. ;---------------------------------------;
  1215. ;    疑似カーソルを行末に        ;
  1216. ;---------------------------------------;
  1217. cursor_right_end:
  1218.     call    clear_cursor
  1219.     mov    ax, cs:curr_line_leng
  1220.     mov    cs:curs_pos_col_s, ax
  1221.     call    adjust_curs_pos
  1222.     call    reverse_region
  1223.     call    disp_cursor
  1224.     ret
  1225.  
  1226.  
  1227. ;---------------------------------------;
  1228. ;    画面を1行スクロールアップ    ;
  1229. ;---------------------------------------;
  1230. scroll_up:
  1231.     mov    ax, cs:last_page_top
  1232.     cmp    ax, cs:page_top
  1233.     jne    scrl_up0
  1234.     jmp    cursor_down
  1235. scrl_up0:
  1236.     mov    si, cs:page_bottom
  1237.     call    clear_cursor
  1238.     call    make_room_bottom
  1239.     mov    ax, ROW_WIDTH - 1        ; row position.
  1240.     call    disp_one_line            ; display one line.
  1241.     mov    cs:page_bottom, si
  1242.     call    adjust_curs_pos
  1243.     mov    ax, cs:old_curs_pos
  1244.     sub    ax, COLUMN_WIDTH*2
  1245.     ja    scrl_up2
  1246.     mov    ax, 0
  1247. scrl_up2:
  1248.     mov    cs:old_curs_pos, ax
  1249.     call    clear_region
  1250.     call    draw_region
  1251.     call    disp_cursor
  1252.     ret
  1253.  
  1254.  
  1255. ;---------------------------------------;
  1256. ;    画面を1行スクロールダウン    ;
  1257. ;---------------------------------------;
  1258. scroll_down:
  1259.     mov    si, cs:page_top
  1260.     cmp    si, cs:read_ptr
  1261.     jne    scrl_dn0
  1262.     jmp    cursor_up
  1263. scrl_dn0:
  1264.     call    clear_cursor
  1265.     call    make_room_top
  1266.     call    find_prev_line        ; top of previous line.
  1267.     mov    ax, 0            ; row position.
  1268.     call    disp_one_line        ; display one line.
  1269.     call    adjust_curs_pos
  1270.     mov    ax, cs:old_curs_pos
  1271.     add    ax, COLUMN_WIDTH*2
  1272.     cmp    ax, ROW_WIDTH*COLUMN_WIDTH*2
  1273.     jb    scrl_dn1
  1274.     mov    ax, ROW_WIDTH*COLUMN_WIDTH*2
  1275. scrl_dn1:
  1276.     mov    cs:old_curs_pos, ax
  1277.     call    clear_region
  1278.     call    draw_region
  1279.     call    disp_cursor
  1280.     ret
  1281.  
  1282.  
  1283. ;---------------------------------------;
  1284. ;    前ページの画面を表示        ;
  1285. ;---------------------------------------;
  1286. prev_page:
  1287.     mov    si, cs:page_top
  1288.     cmp    si, cs:read_ptr
  1289.     jne    prev_pg0
  1290.     jmp    to_page_top
  1291. prev_pg0:
  1292.     call    find_prev_page
  1293.     call    disp_one_screen
  1294.     call    adjust_curs_pos
  1295.     call    draw_region
  1296.     call    disp_cursor
  1297.     ret
  1298.  
  1299.  
  1300. ;---------------------------------------;
  1301. ;    次ページの画面を表示        ;
  1302. ;---------------------------------------;
  1303. next_page:
  1304.     mov    ax, cs:last_page_top
  1305.     cmp    ax, cs:page_top
  1306.     jne    next_pg0
  1307.     mov    cx, ROW_WIDTH - 1
  1308. next_pg00:
  1309.     push    cx
  1310.     call    cursor_down
  1311.     pop    cx
  1312.     loop    next_pg00
  1313.     ret
  1314. next_pg0:
  1315. ;    mov    si, cs:page_bottom
  1316.     mov    si, cs:line_top[(ROW_WIDTH-1)*2]
  1317.     mov    bx, si
  1318.     sub    ax, cs:read_ptr
  1319.     sub    bx, cs:read_ptr
  1320.     cmp    bx, ax            ; page_bottom < last_page_top ?
  1321.     jb    next_pg1
  1322.     mov    si, cs:last_page_top
  1323. next_pg1:
  1324.     call    disp_one_screen
  1325.     call    adjust_curs_pos
  1326.     call    draw_region
  1327.     call    disp_cursor
  1328.     ret
  1329.  
  1330.  
  1331. ;---------------------------------------;
  1332. ;    テキストバッファの最後尾へ    ;
  1333. ;---------------------------------------;
  1334. buf_bottom:
  1335.     mov    si, cs:last_page_top
  1336.     call    disp_one_screen
  1337.     mov    ax, cs:bottom_curs_row
  1338.     mov    cs:curs_pos_row, ax
  1339.     mov    cs:curs_pos_col_s, 0
  1340.     call    adjust_curs_pos
  1341.     call    draw_region
  1342.     call    disp_cursor
  1343.     ret
  1344.  
  1345.  
  1346. ;---------------------------------------;
  1347. ;    テキストバッファの先頭へ    ;
  1348. ;---------------------------------------;
  1349. buf_top:
  1350.     mov    si, cs:read_ptr
  1351.     call    disp_one_screen
  1352.     mov    cs:curs_pos_row, 0
  1353.     mov    cs:curs_pos_col_s, 0
  1354.     call    adjust_curs_pos
  1355.     call    draw_region
  1356.     call    disp_cursor
  1357.     ret
  1358.  
  1359.  
  1360. ;---------------------------------------;
  1361. ;    表示画面の先頭へ        ;
  1362. ;---------------------------------------;
  1363. to_page_top:
  1364.     call    clear_cursor
  1365.     mov    cs:curs_pos_row, 0
  1366.     mov    cs:curs_pos_col_s, 0
  1367.     call    adjust_curs_pos
  1368.     call    reverse_region
  1369.     call    disp_cursor
  1370.     ret
  1371.  
  1372.  
  1373. ;---------------------------------------;
  1374. ;    表示画面の最後尾へ        ;
  1375. ;---------------------------------------;
  1376. to_page_bottom:
  1377.     call    clear_cursor
  1378.     mov    ax, cs:bottom_curs_row
  1379.     mov    cs:curs_pos_row, ax
  1380.     add    ax, ax
  1381.     mov    bx, ax
  1382.     mov    ax, cs:line_top[bx+2]
  1383.     sub    ax, cs:line_top[bx]
  1384.     jz    to_page_bot1
  1385.     dec    ax
  1386. to_page_bot1:
  1387.     mov    cs:curs_pos_col_s, ax
  1388.     call    adjust_curs_pos
  1389.     call    reverse_region
  1390.     call    disp_cursor
  1391.     ret
  1392.  
  1393.  
  1394. ;---------------------------------------;
  1395. ;    領域マークを設定する        ;
  1396. ;---------------------------------------;
  1397. set_mark:
  1398.     mov    ax, cs:current_ptr
  1399.     mov    cs:mark_ptr, ax
  1400.     not    cs:mark_flag
  1401.  
  1402.     mov    cx, COLUMN_WIDTH*ROW_WIDTH
  1403.     mov    di, 0
  1404. set_mk1:
  1405. IFDEF    FMR
  1406.   IFDEF    FMR70
  1407.     mov    word ptr es:[di+ATTR_OFF], ATR_WHITE
  1408.     cmp    word ptr es:[di], EOL_CHAR
  1409.     je    set_mk2
  1410.     cmp    word ptr es:[di], '~'
  1411.     jne    set_mk3
  1412. set_mk2:
  1413.     mov    word ptr es:[di+ATTR_OFF], ATR_CYAN
  1414.   ELSE
  1415.     mov    al, es:[di+1]
  1416.     and    al, ATR_KANJI_1 or ATR_KANJI_2        ; reserve kanji attr.
  1417.     or    al, ATR_WHITE
  1418.     mov    byte ptr es:[di+1], al
  1419.     cmp    byte ptr es:[di], EOL_CHAR
  1420.     je    set_mk2
  1421.     cmp    byte ptr es:[di], '~'
  1422.     jne    set_mk3
  1423.     test    byte ptr es:[di-1], ATR_KANJI_1 or ATR_KANJI_2    ; check kanji
  1424.     jne    set_mk3
  1425. set_mk2:
  1426.     mov    byte ptr es:[di+1], ATR_CYAN
  1427.   ENDIF
  1428. ELSE
  1429.     mov    word ptr es:[di+ATTR_OFF], ATR_WHITE
  1430.     cmp    word ptr es:[di], EOL_CHAR
  1431.     je    set_mk2
  1432.     cmp    word ptr es:[di], '~'
  1433.     jne    set_mk3
  1434. set_mk2:
  1435.     mov    word ptr es:[di+ATTR_OFF], ATR_CYAN
  1436. ENDIF
  1437. set_mk3:
  1438.     add    di, 2
  1439.     loop    set_mk1
  1440.  
  1441.     call    disp_cursor
  1442.     ret
  1443.  
  1444.  
  1445. ;---------------------------------------;
  1446. ;    領域をカットする        ;
  1447. ;(実際には領域の先頭位置と大きさだけ)    ;
  1448. ;---------------------------------------;
  1449. cut_region:
  1450.     cmp    cs:mark_flag, ON
  1451.     je    cut_reg5
  1452.     mov    di, cs:current_ptr
  1453.     cmp    byte ptr [di], 20h
  1454.     jbe    cut_reg2
  1455. cut_reg1:
  1456.     cmp    di, cs:read_ptr
  1457.     je    cut_reg2
  1458.     dec    di
  1459.     cmp    byte ptr [di], 20h
  1460.     ja    cut_reg1
  1461.     inc    di
  1462. cut_reg2:
  1463.     mov    cs:cutbuf_bgn, di
  1464. cut_reg3:
  1465.     cmp    byte ptr [di], 20h
  1466.     jbe    cut_reg4
  1467.     inc    di
  1468.     jmp    short cut_reg3
  1469. cut_reg4:
  1470.     sub    di, cs:cutbuf_bgn
  1471.     mov    cs:cutbuf_cnt_save, di
  1472.     jmp    short cut_reg7
  1473. ;
  1474. cut_reg5:
  1475.     mov    ax, cs:current_ptr
  1476.     mov    bx, cs:mark_ptr
  1477.     sub    ax, cs:read_ptr
  1478.     sub    bx, cs:read_ptr
  1479.     sub    ax, bx
  1480.     jae    cut_reg6
  1481.     mov    ax, cs:current_ptr
  1482.     xchg    ax, cs:mark_ptr
  1483.     sub    ax, cs:mark_ptr
  1484. cut_reg6:
  1485.     mov    cs:cutbuf_cnt_save, ax
  1486.     mov    ax, cs:mark_ptr
  1487.     mov    cs:cutbuf_bgn, ax
  1488. cut_reg7:
  1489.     call    x_exit
  1490.     ret
  1491.  
  1492.  
  1493. ;---------------------------------------;
  1494. ;    領域のコピー            ;
  1495. ;    (実際には、領域の位置と    ;
  1496. ;      大きさを指定するだけ)    ;
  1497. ;---------------------------------------;
  1498. copy_region:
  1499.     call    cut_region
  1500. IFDEF    FMR
  1501.     mov    al, cs:shift_status
  1502.     shr    al, 1            ; move SHIFT bit to LSB
  1503.     shr    al, 1
  1504. ELSE
  1505.     push    es
  1506.     mov    es, cs:sys_seg
  1507.     mov    al, byte ptr es:[SHIFT_STTS]
  1508.     pop    es
  1509. ENDIF
  1510.     and    al, 1            ; shift ?
  1511.     xor    al, cs:always_paste
  1512.     jz    copy_reg1
  1513.     mov    al, cs:header_char
  1514. copy_reg1:
  1515.     mov    cs:this_line_hc, al
  1516.     mov    cs:this_paste_hc, 0
  1517.     mov    ax, cs:cutbuf_bgn
  1518.     mov    cs:cutbuf_ptr, ax
  1519.     mov    ax, cs:cutbuf_cnt_save
  1520.     mov    cs:cutbuf_cnt, ax
  1521.     test    ax, ax
  1522.     jz    copy_reg8
  1523.     call    data_move
  1524. copy_reg8:
  1525.     ret
  1526.  
  1527.  
  1528. ;-----------------------------------------------;
  1529. ;    カーソル位置から行末までをカット    ;
  1530. ;-----------------------------------------------;
  1531. cut_to_eol:
  1532.     mov    cs:mark_flag, OFF
  1533.     call    set_mark
  1534.     call    cursor_right_end
  1535.     call    cut_region
  1536.     ret
  1537.  
  1538.  
  1539. ;-----------------------------------------------;
  1540. ;    カーソル位置から行末までをコピー    ;
  1541. ;-----------------------------------------------;
  1542. cut_to_bol:
  1543.     mov    cs:mark_flag, OFF
  1544.     call    set_mark
  1545.     call    cursor_left_end
  1546.     call    cut_region
  1547.     ret
  1548.  
  1549.  
  1550. ;-----------------------------------------------;
  1551. ;    カーソル位置から行頭までをカット    ;
  1552. ;-----------------------------------------------;
  1553. copy_to_eol:
  1554.     mov    cs:mark_flag, OFF
  1555.     call    set_mark
  1556.     call    cursor_right_end
  1557.     call    copy_region
  1558.     ret
  1559.  
  1560.  
  1561. ;-----------------------------------------------;
  1562. ;    カーソル位置から行頭までをコピー    ;
  1563. ;-----------------------------------------------;
  1564. copy_to_bol:
  1565.     mov    cs:mark_flag, OFF
  1566.     call    set_mark
  1567.     call    cursor_left_end
  1568.     call    copy_region
  1569.     ret
  1570.  
  1571.  
  1572. ;    Following search routines from
  1573. ;    Ver. 1.48eC1 by Appne / Feb. 20, 1989.
  1574.  
  1575. ;---------------------------------------;
  1576. ;    文字列を前方に検索        ;
  1577. ;---------------------------------------;
  1578. forw_search:
  1579.     push    es
  1580.     xor    ax, ax
  1581.     mov    es, ax
  1582. ;    test    byte ptr es:[SHIFT_STTS], 1
  1583.     pop    es
  1584. ;    jnz    back_search
  1585.     mov    bx, ROW_WIDTH
  1586. ;    mov    bx, word ptr cs:row_width_0
  1587.     mov    cx, WORK_BOX_COL
  1588.     mov    ax, offset white_str
  1589.     call    putstr
  1590.     inc    cx
  1591.     mov    ax, '/'
  1592.     call    putchr
  1593.     inc    cx
  1594.     call    getstr
  1595.     cmp    al, CTRL_C        ; 中止?
  1596.     jne    forw_srch1
  1597.     mov    cx, WORK_BOX_COL
  1598.     mov    ax, offset break_msg
  1599.     call    putstr
  1600.     ret
  1601. forw_srch1:
  1602.     mov    cs:case_sensitive, OFF
  1603.     cmp    al, CTRL_J
  1604.     jne    forw_next
  1605.     mov    cs:case_sensitive, ON
  1606. forw_next:
  1607.     mov    cs:search_dir, 1    ; forward search
  1608.     mov    ax, cs:txtbuf_end
  1609.     dec    ax
  1610.     mov    cs:search_end, ax
  1611.     jmp    short next_search
  1612.  
  1613.  
  1614. ;---------------------------------------;
  1615. ;    文字列を後方に検索        ;
  1616. ;---------------------------------------;
  1617. back_search:
  1618.     mov    bx, ROW_WIDTH
  1619. ;    mov    bx, word ptr cs:row_width_0
  1620.     mov    cx, WORK_BOX_COL
  1621.     mov    ax, offset white_str
  1622.     call    putstr
  1623.     inc    cx
  1624.     mov    ax, '?'
  1625.     call    putchr
  1626.     inc    cx
  1627.     call    getstr
  1628.     cmp    al, CTRL_C        ; 中止?
  1629.     jne    back_srch1
  1630.     mov    cx, WORK_BOX_COL
  1631.     mov    ax, offset break_msg
  1632.     call    putstr
  1633.     ret
  1634. back_srch1:
  1635.     mov    cs:case_sensitive, OFF
  1636.     cmp    al, CTRL_J
  1637.     jne    back_next
  1638.     mov    cs:case_sensitive, ON
  1639. back_next:
  1640.     mov    cs:search_dir, -1    ; backward search
  1641.     mov    ax, cs:read_ptr
  1642.     mov    cs:search_end, ax
  1643. ;    jmp    short next_search
  1644.  
  1645.  
  1646. ;---------------------------------------;
  1647. ;    文字列をさらに検索        ;
  1648. ;---------------------------------------;
  1649. next_search:
  1650.     mov    ax, offset search_msg
  1651.     mov    bx, ROW_WIDTH
  1652. ;    mov    bx, word ptr cs:row_width_0
  1653.     mov    cx, WORK_BOX_COL
  1654.     call    putstr
  1655.     cld
  1656.     mov    bx, cs:current_ptr
  1657.     mov    dx, offset str_buf
  1658.     push    es
  1659.     push    cs
  1660.     pop    es
  1661.     cmp    cs:search_dir, 1
  1662.     jnz    next_s1
  1663.     cmp    bx, cs:txtbuf_end
  1664.     jnz    next_s1
  1665. next_s09:
  1666.     jmp    next_s9
  1667. next_s1:
  1668.     cmp    bx, cs:search_end
  1669.     je    next_s09
  1670.     add    bx, cs:search_dir
  1671.     mov    cx, cs:str_len
  1672.     mov    si, bx
  1673.     mov    di, dx
  1674. next_s2:
  1675.     lodsb
  1676.     cmp    al, es:[di]
  1677.     je    next_s4
  1678.     cmp    cs:case_sensitive, ON
  1679.     je    next_s1
  1680.     cmp    al, 'A'
  1681.     jb    next_s1
  1682.     cmp    al, 'Z'
  1683.     ja    next_s3
  1684.     add    al, 20h
  1685.     cmp    al, es:[di]
  1686.     jne    next_s1
  1687.     jmp    short next_s4
  1688. next_s3:
  1689.     cmp    al, 'a'
  1690.     jb    next_s1
  1691.     cmp    al, 'z'
  1692.     ja    next_s1
  1693.     sub    al, 20h
  1694.     cmp    al, es:[di]
  1695.     jne    next_s1
  1696. next_s4:
  1697.     inc    di
  1698.     loop    next_s2
  1699. ;
  1700.     pop    es
  1701.     mov    cs:current_ptr, bx
  1702.     call    clear_cursor
  1703.     call    calc_curs_pos
  1704.     jz    next_s5
  1705.     mov    si, cs:current_ptr
  1706. ;    call    find_prev_str
  1707. ;    call    find_prev_str
  1708. ;    call    find_prev_str
  1709. ;    call    find_prev_str
  1710. ;    call    find_prev_str
  1711.     mov    ax, word ptr cs:row_width_1
  1712.     dec    ax
  1713.     jz    next_s4_4
  1714.     dec    ax
  1715.     jz    next_s4_3
  1716.     dec    ax
  1717.     jz    next_s4_2
  1718.     dec    ax
  1719.     jz    next_s4_1
  1720.     call    find_prev_line
  1721. next_s4_1:
  1722.     call    find_prev_line
  1723. next_s4_2:
  1724.     call    find_prev_line
  1725. next_s4_3:
  1726.     call    find_prev_line
  1727. next_s4_4:
  1728.     call    find_prev_line
  1729.     call    disp_one_screen
  1730.     call    calc_curs_pos
  1731. next_s5:
  1732.     call    adjust_curs_pos
  1733.     call    clear_region
  1734.     call    draw_region
  1735. ;    call    reverse_region
  1736.     call    disp_cursor
  1737.     mov    ax, offset found_msg
  1738.     mov    bx, ROW_WIDTH
  1739. ;    mov    bx, word ptr cs:row_width_0
  1740.     mov    cx, WORK_BOX_COL
  1741.     call    putstr
  1742.     ret
  1743. ;
  1744. next_s9:
  1745.     pop    es
  1746.     mov    ax, offset nfound_msg
  1747.     mov    bx, ROW_WIDTH
  1748. ;    mov    bx, word ptr cs:row_width_0
  1749.     mov    cx, WORK_BOX_COL
  1750.     call    putstr
  1751.     ret
  1752.  
  1753.  
  1754. ;---------------------------------------;
  1755. ;    ジャンプラベルの設定        ;
  1756. ;---------------------------------------;
  1757. set_label:
  1758.     mov    ax, offset label_msg
  1759.     mov    bx, ROW_WIDTH
  1760. ;    mov    bx, word ptr cs:row_width_0
  1761.     mov    cx, WORK_BOX_COL
  1762.     call    putstr
  1763. IFNDEF    FMR
  1764.     mov    byte ptr cs:getchar_flag, ON
  1765. ENDIF
  1766. set_label_1:
  1767.     call    getchar
  1768. IFDEF    FMR
  1769.     call    clear_keybuf
  1770. ENDIF
  1771.     cmp    al, 7fh
  1772.     jnc    set_label_1
  1773.     sub    al, 20h
  1774.     jc    set_label_1
  1775. IFNDEF    FMR
  1776.     mov    byte ptr cs:getchar_flag, OFF
  1777. ENDIF
  1778.     cbw
  1779.     add    ax, ax
  1780.     mov    si, ax
  1781.     mov    ax, cs:current_ptr
  1782.     mov    cs:[si][offset label_table], ax
  1783.     mov    ax, offset clear_msg
  1784.     call    putstr
  1785.     ret
  1786.  
  1787.  
  1788. ;---------------------------------------;
  1789. ;    ラベル位置へジャンプ        ;
  1790. ;---------------------------------------;
  1791. goto_label:
  1792.     mov    ax, offset goto_msg
  1793.     mov    bx, ROW_WIDTH
  1794. ;    mov    bx, word ptr cs:row_width_0
  1795.     mov    cx, WORK_BOX_COL
  1796.     call    putstr
  1797. IFNDEF    FMR
  1798.     mov    byte ptr cs:getchar_flag, ON
  1799. ENDIF
  1800. goto_label_1:
  1801.     call    getchar
  1802. IFDEF    FMR
  1803.     call    clear_keybuf
  1804. ENDIF
  1805.     cmp    al, 7fh
  1806.     jnc    goto_label_1
  1807.     sub    al, 20h
  1808.     jc    goto_label_1
  1809. IFNDEF    FMR
  1810.     mov    byte ptr cs:getchar_flag, OFF
  1811. ENDIF
  1812.     cbw
  1813.     add    ax, ax
  1814.     mov    si, ax
  1815.     push    si
  1816.     mov    ax, offset clear_msg
  1817.     call    putstr
  1818.     pop    si
  1819.     mov    si, cs:[si][offset label_table]
  1820.     mov    cs:current_ptr, si
  1821.     call    clear_cursor
  1822.     call    calc_curs_pos
  1823.     jz    goto_5
  1824.     mov    si, cs:current_ptr
  1825.     mov    ax, word ptr cs:row_width_1
  1826.     dec    ax
  1827.     jz    goto_4
  1828.     dec    ax
  1829.     jz    goto_3
  1830.     dec    ax
  1831.     jz    goto_2
  1832.     dec    ax
  1833.     jz    goto_1
  1834.     call    find_prev_line
  1835. goto_1:
  1836.     call    find_prev_line
  1837. goto_2:
  1838.     call    find_prev_line
  1839. goto_3:
  1840.     call    find_prev_line
  1841. goto_4:
  1842.     call    find_prev_line
  1843.     call    disp_one_screen
  1844.     call    calc_curs_pos
  1845. goto_5:
  1846.     call    adjust_curs_pos
  1847.     call    clear_region
  1848.     call    draw_region
  1849.     call    disp_cursor
  1850.     ret
  1851.  
  1852.  
  1853. ;-----------------------------;
  1854. ;       引用記号の設定        ;
  1855. ;-----------------------------;
  1856. header_set:
  1857.     cmp    cs:header_char,al
  1858.     jne    header_set1
  1859.     mov    al,0
  1860. header_set1:
  1861.     mov    cs:header_char,al
  1862. ;    call    disp_header
  1863.     ret
  1864.  
  1865.  
  1866. ;---------------------------------------;
  1867. ;    終了フラグのセット        ;
  1868. ;---------------------------------------;
  1869. exit:
  1870.     mov    cs:cutbuf_cnt_save, 0    ; clear cut region length
  1871. x_exit:
  1872.     mov    cs:exit_flag, ON
  1873.     ret
  1874.  
  1875.  
  1876. ;---------------------------------------;
  1877. ;    ヘルプ画面の表示        ;
  1878. ;---------------------------------------;
  1879. show_help:
  1880.     mov    si, offset help_msg
  1881.     call    show_help_p
  1882.     call    getchar
  1883.     call    clear_keybuf
  1884.     call    show_help_p
  1885.     call    getchar
  1886.     call    clear_keybuf
  1887.     call    show_help_p
  1888.     call    getchar
  1889.     call    clear_keybuf
  1890.  
  1891.     mov    si, cs:page_top
  1892.     call    disp_one_screen
  1893.     call    draw_region
  1894.     call    disp_cursor
  1895.     ret
  1896.  
  1897. ;
  1898. show_help_p:
  1899.     push    si
  1900.     call    clr_screen
  1901.     pop    si
  1902.     push    ds
  1903.     mov    ax, cs
  1904.     mov    ds, ax
  1905.     sub    ax, ax
  1906.     sub    dx, dx
  1907.     sub    di, di
  1908.     cld
  1909. help1:
  1910.     lodsb
  1911.     test    al, al
  1912.     jz    help3
  1913.     cmp    al, CR
  1914.     je    help2
  1915.     stosb
  1916.     inc    di            ; to unchange 2nd byte
  1917.     jmp    short help1
  1918. help2:
  1919.     add    dx, COLUMN_WIDTH*2
  1920.     mov    di, dx
  1921.     jmp    short help1
  1922. help3:
  1923.     pop    ds
  1924.     ret
  1925.  
  1926.  
  1927. help_msg  label  byte
  1928. IFDEF    FMR
  1929. db    '           <<<  Transcript (Ver 1.4 ',VERSION,') Help  >>>', CR
  1930. db    CR
  1931. db    '           CTRL+DOWN ARROW : enter transcript mode. previous cursor position', CR
  1932. db    '             CTRL+UP ARROW : enter transcript mode. initial cursor position', CR
  1933. db    '                 CTRL+HOME : paste region', CR
  1934. db    '               ESC, CTRL+[ : leave transcript mode', CR
  1935. db    '               CTRL+CANCEL : enable / disable logging', CR
  1936. ELSE
  1937. db    '           <<<  Transcript (Ver 1.4) Help  >>>', CR
  1938. db    CR
  1939. db    '         CTRL+HOME, CTRL+1 : enter transcript mode. previous cursor position', CR
  1940. db    '     CTRL+UP ARROW, CTRL+2 : enter transcript mode. initial cursor position', CR
  1941. db    '         CTRL+HELP, CTRL+4 : paste region', CR
  1942. db    '         HOME, ESC, CTRL+[ : leave transcript mode', CR
  1943. db    '                   CTRL+BS : enable / disable logging', CR
  1944. ENDIF
  1945. db    CR
  1946. db    '    UP ARROW, E, e, CTRL+E : move cursor up', CR
  1947. db    '  LEFT ARROW, S, s, CTRL+S : move cursor left', CR
  1948. db    ' RIGHT ARROW, D, d, CTRL+D : move cursor right', CR
  1949. db    '  DOWN ARROW, X, x, CTRL+X : move cursor down', CR
  1950. db    '              A, a         : move cursor previous word', CR
  1951. db    '              F, f         : move cursor next word', CR
  1952. db    '                    CTRL+A : move cursor begin of line', CR
  1953. db    '                    CTRL+F : move cursor end of line', CR
  1954. db    CR
  1955. IFDEF    FMR
  1956. db    '   ROLL DOWN, W, w, CTRL+W : scroll down 1 line', CR
  1957. db    '   ROLL UP  , Z, z, CTRL+Z : scroll up 1 line', CR
  1958. db    '              R, r, CTRL+R : show previous page', CR
  1959. db    '              C, c, CTRL+C : show next page', CR
  1960. ELSE
  1961. db    '              W, w, CTRL+W : scroll down 1 line', CR
  1962. db    '              Z, z, CTRL+Z : scroll up 1 line', CR
  1963. db    '   ROLL DOWN, R, r, CTRL+R : show previous page', CR
  1964. db    '   ROLL UP  , C, c, CTRL+C : show next page', CR
  1965. ENDIF
  1966. db    CR
  1967. db    '--hit any key--', 0
  1968.  
  1969. db    CR
  1970. db    '              T, t         : jump to top of buffer', CR
  1971. db    '              B, b         : jump to bottom of buffer', CR
  1972. db    '                    CTRL+T : jump to top of page', CR
  1973. db    '                    CTRL+B : jump to bottom of page', CR
  1974. db    CR
  1975. db    '         INS, M, m         : set region mark', CR
  1976. db    CR
  1977. db    '         DEL, O, o         : cut yellow reverse region', CR
  1978. db    '          CR, P, p, CTRL+P : copy yellow reverse region or 1 word', CR
  1979. db    CR
  1980. db    '                    CTRL+K : cut to end of line', CR
  1981. db    '                    CTRL+U : cut to begin of line', CR
  1982. db    '              K, k         : copy to end of line', CR
  1983. db    '              U, u         : copy to begin of line', CR
  1984. db    CR
  1985. db    '              >, :, -      : set paste header char',CR
  1986. db    '         shift+(paste key) : paste with header char', CR
  1987. db    CR
  1988. db    '--hit any key--', 0
  1989.  
  1990. db    CR
  1991. db    '       /<string>CR(CTRL+J) : forward search for string', CR
  1992. db    '       ?<string>CR(CTRL+J) : backward search for string', CR
  1993. db    '              N, n         : forward next search for string', CR
  1994. db    '                    CTRL+N : backward next search for string', CR
  1995. db    CR
  1996. db    '              L, l         : label set', CR
  1997. db    "                 '         : goto label", CR
  1998. db    CR
  1999. IFDEF    FMR
  2000. db    '        HOME        CTRL+] : show help message', CR
  2001. ELSE
  2002. db    '        HELP,       CTRL+] : show help message', CR
  2003. ENDIF
  2004. db    CR
  2005. db    '--hit any key--', 0
  2006.  
  2007.  
  2008. ;=======================================;
  2009. ;    サブルーチン群            ;
  2010. ;=======================================;
  2011.  
  2012. ;---------------------------------------;
  2013. ;    最新画面の範囲を求める        ;
  2014. ;---------------------------------------;
  2015. find_last_page:
  2016.     mov    si, cs:write_ptr
  2017.     cmp    byte ptr ds:[si-1], CR
  2018.     je    find_lp1
  2019.     call    find_prev_str
  2020. find_lp1:
  2021.     mov    cs:txtbuf_end, si
  2022.     call    find_prev_page
  2023.     mov    cs:last_page_top, si
  2024.     mov    cs:bottom_curs_row, ax
  2025.     cmp    si, cs:read_ptr
  2026.     je    find_lp2
  2027.     call    find_prev_line
  2028. find_lp2:
  2029.     ret
  2030.  
  2031.  
  2032. ;---------------------------------------;
  2033. ;    1ページ前の画面の範囲を求める    ;
  2034. ;  In : SI = txtbuf ptr            ;
  2035. ;  Out: SI = prev page top        ;
  2036. ;    AX = number of lines        ;
  2037. ;---------------------------------------;
  2038. find_prev_page:
  2039.     push    bx
  2040.     push    dx
  2041.     sub    bx, bx
  2042. find_pp1:
  2043.     mov    ax, si
  2044.     call    find_prev_str
  2045.     sub    ax, si
  2046.     jz    find_pp2
  2047.     add    ax, COLUMN_WIDTH - 1
  2048.     sub    dx, dx
  2049.     mov    cx, COLUMN_WIDTH
  2050.     div    cx
  2051.     add    bx, ax
  2052.     cmp    bx, ROW_WIDTH - 1
  2053.     jb    find_pp1
  2054.     je    find_pp2
  2055.     mov    dx, bx
  2056.     mov    bx, ROW_WIDTH - 1
  2057.     sub    dx, bx
  2058.     mov    ax, COLUMN_WIDTH
  2059.     mul    dx
  2060.     add    si, ax
  2061. find_pp2:
  2062.     mov    ax, bx
  2063.     pop    dx
  2064.     pop    bx
  2065.     ret
  2066.  
  2067.  
  2068. ;---------------------------------------;
  2069. ;    1つ前の文字列の位置を求める    ;
  2070. ;  In : SI = current position        ;
  2071. ;  Out:    SI                ;
  2072. ;---------------------------------------;
  2073. find_prev_str:
  2074.     cmp    si, cs:read_ptr
  2075.     je    find_ps2
  2076. find_ps1:
  2077.     dec    si
  2078.     cmp    si, cs:read_ptr
  2079.     je    find_ps2
  2080.     cmp    byte ptr ds:[si-1], CR
  2081.     jne    find_ps1
  2082. find_ps2:
  2083.     ret
  2084.  
  2085.  
  2086. ;---------------------------------------;
  2087. ;    1つ前の行の先頭位置を求める    ;
  2088. ;  In : SI = current position        ;
  2089. ;  Out:    SI                ;
  2090. ;---------------------------------------;
  2091. find_prev_line:
  2092.     push    ax
  2093.     push    cx
  2094.     push    dx
  2095.     mov    ax, si
  2096.     mov    dx, si
  2097.     call    find_prev_str
  2098.     sub    ax, si
  2099.     jz    find_pl1
  2100.     mov    si, dx
  2101.     dec    ax
  2102.     sub    dx, dx
  2103.     mov    cx, COLUMN_WIDTH
  2104.     div    cx
  2105.     inc    dx
  2106.     sub    si, dx
  2107. find_pl1:
  2108.     pop    dx
  2109.     pop    cx
  2110.     pop    ax
  2111.     ret
  2112.  
  2113.  
  2114. ;---------------------------------------;
  2115. ;    1画面の表示            ;
  2116. ;  In : SI = pointer            ;
  2117. ;---------------------------------------;
  2118. disp_one_screen:
  2119.     push    ax
  2120.     call    clr_screen        ; clear the screen.
  2121.     mov    cx, ROW_WIDTH
  2122.     mov    ax, 0
  2123. disp_s2:
  2124.     call    disp_one_line
  2125.     inc    ax
  2126.     loop    disp_s2
  2127.     mov    cs:page_bottom, si
  2128.     pop    ax
  2129.     ret
  2130.  
  2131.  
  2132. ;---------------------------------------;
  2133. ;    1行の表示            ;
  2134. ;  In : AX = row position.        ;
  2135. ;    SI = string offset.        ;
  2136. ;  Out: SI = next string position.    ;
  2137. ;---------------------------------------;
  2138. disp_one_line:
  2139.     push    ax
  2140.     push    bx
  2141.     push    cx
  2142.  
  2143.     mov    bx, ax
  2144.     add    bx, bx
  2145.     mov    cs:line_top[bx], si
  2146.     mov    ah, COLUMN_WIDTH*2
  2147.     mul    ah
  2148.     mov    di, ax
  2149.     mov    cx, COLUMN_WIDTH
  2150.     cld
  2151.     cmp    si, cs:txtbuf_end
  2152.     jne    disp_ln1
  2153.     mov    ax, '~'
  2154.     jmp    short disp_ln7
  2155. disp_ln1:
  2156.     sub    ax, ax
  2157.     lodsb
  2158.     test    al, al
  2159.     jz    disp_ln8
  2160.     cmp    al, CR
  2161.     je    disp_ln6
  2162.     cmp    al, LF
  2163.     je    disp_ln1
  2164.     cmp    al, 081h
  2165.     jb    disp_ln5
  2166.     cmp    al, 0A0h
  2167.     jb    disp_ln4
  2168.     cmp    al, 0E0h
  2169.     jb    disp_ln5
  2170.     cmp    al, 0FCh
  2171.     ja    disp_ln5
  2172. disp_ln4:
  2173.     loop    dislp_ln4_1
  2174.     dec    si
  2175.     jmp    short disp_ln8
  2176. dislp_ln4_1:
  2177.     mov    ah, al
  2178.     lodsb
  2179.     call    sjis_to_vjis
  2180. IFDEF    FMR
  2181.   IFDEF    FMTOWNS
  2182.     mov    byte ptr es:[di], CODE_KANJI_1
  2183.     mov    es:[di+ATTR_OFF], ah
  2184.     inc    di
  2185.     mov    byte ptr es:[di], ATR_KANJI_1 or ATR_WHITE
  2186.     mov    es:[di+ATTR_OFF], al
  2187.     inc    di
  2188.     mov    byte ptr es:[di], CODE_KANJI_1
  2189.     mov    byte ptr es:[di+ATTR_OFF], 21h        ; NOT ah
  2190.     inc    di
  2191.     mov    byte ptr es:[di], ATR_KANJI_2 or ATR_WHITE
  2192.     mov    byte ptr es:[di+ATTR_OFF], 21h        ; NOT al
  2193.     inc    di
  2194.     jmp    short disp_ln51
  2195.   ELSE
  2196.     IFDEF  FMR50
  2197.     mov    byte ptr es:[di], CODE_KANJI_1
  2198.     mov    es:[di+ATTR_OFF], ah
  2199.     inc    di
  2200.     mov    byte ptr es:[di], ATR_KANJI_1 or ATR_WHITE
  2201.     mov    es:[di+ATTR_OFF], al
  2202.     inc    di
  2203.     mov    byte ptr es:[di], CODE_KANJI_1
  2204.     mov    es:[di+ATTR_OFF], ah
  2205.     inc    di
  2206.     mov    byte ptr es:[di], ATR_KANJI_2 or ATR_WHITE
  2207.     mov    es:[di+ATTR_OFF], al
  2208.     inc    di
  2209.     jmp    short disp_ln51
  2210.     ELSE
  2211.     cmp    ah, 75h            ; gaiji character ?
  2212.     je    disp_ln4_2
  2213.     cmp    ah, 76h            ; gaiji character ?
  2214.     je    disp_ln4_2
  2215.     add    ah, 80h            ; normal JIS kanji
  2216.     jmp    short disp_ln4_3
  2217. disp_ln4_2:
  2218.     sub    ah, 35h            ; adjust gaiji CG code
  2219. disp_ln4_3:
  2220.     stosw
  2221.     add    al, 80h
  2222.     ENDIF
  2223.   ENDIF
  2224. ELSE
  2225.     sub    ax, 2000h
  2226.     xchg    al, ah
  2227.     stosw
  2228.     add    al, 80h
  2229. ENDIF
  2230. disp_ln5:
  2231. IFDEF    FMR
  2232.   IFDEF    FMR70
  2233.     stosw
  2234.   ELSE
  2235.     stosb
  2236.     inc    di
  2237. disp_ln51:
  2238.   ENDIF
  2239. ELSE
  2240.     stosw
  2241. ENDIF
  2242.     loop    disp_ln1
  2243.     jmp    short disp_ln8
  2244. disp_ln6:
  2245.     mov    al, EOL_CHAR            ; down arrow.
  2246. disp_ln7:
  2247. IFDEF    FMR
  2248.   IFDEF    FMR70
  2249.     mov    es:[di], ax
  2250.   ELSE
  2251.     mov    byte ptr es:[di], al
  2252.     mov    byte ptr es:[di+1], ATR_CYAN
  2253.   ENDIF
  2254. ELSE
  2255.     mov    es:[di], ax
  2256. ENDIF
  2257. IFDEF    FMR
  2258.   IFDEF    FMR70
  2259.     and    word ptr es:[di+ATTR_OFF], 11111101b    ; light blue
  2260.   ENDIF
  2261. ELSE
  2262.     and    byte ptr es:[di+ATTR_OFF], 10111111b    ; light blue
  2263. ENDIF
  2264. disp_ln8:
  2265.     pop    cx
  2266.     pop    bx
  2267.     pop    ax
  2268.     ret
  2269.  
  2270.  
  2271. ;---------------------------------------;
  2272. ;    画面の消去            ;
  2273. ;---------------------------------------;
  2274. clr_screen:
  2275.     mov    cx, COLUMN_WIDTH*ROW_WIDTH
  2276.     mov    di, 0
  2277.     cld
  2278. IFDEF    FMR
  2279.   IFDEF    FMR70
  2280.     mov    ax, VACANT_CHAR
  2281.     rep    stosw
  2282.   ELSE
  2283. clr_scr1:
  2284.     mov    al, VACANT_CHAR
  2285.     stosb
  2286.     mov    al, ATR_WHITE
  2287.     stosb
  2288.     loop    clr_scr1
  2289.   ENDIF
  2290. ELSE
  2291.     mov    ax, VACANT_CHAR
  2292.     rep    stosw
  2293. ENDIF
  2294.     mov    cx, COLUMN_WIDTH*ROW_WIDTH
  2295.     mov    di, ATTR_OFF
  2296. IFDEF    FMR
  2297.   IFDEF    FMR70
  2298.     mov    ax, ATR_WHITE
  2299.     rep    stosw
  2300.   ELSE
  2301.       mov    al, 21h
  2302. clr_scr2:
  2303.       stosb
  2304.       stosb
  2305.       loop    clr_scr2
  2306.   ENDIF
  2307. ELSE
  2308.     mov    ax, ATR_WHITE
  2309.     rep    stosw
  2310. ENDIF
  2311.     ret
  2312.  
  2313.  
  2314. ;---------------------------------------;
  2315. ;    Shift JIS から JIS コード変換    ;
  2316. ;  In : AX = Shift JIS code.        ;
  2317. ;  Out: AX = JIS kanji code.        ;
  2318. ;---------------------------------------;
  2319. sjis_to_vjis:
  2320.     cmp    al, 7Fh
  2321.     jb    sjis1
  2322.     dec    ax
  2323. sjis1:
  2324.     sub    ax, 1Fh
  2325.     cmp    ah, 0E0h
  2326.     jb    sjis2
  2327.     sub    ax, 4000h
  2328. sjis2:
  2329.     sub    ax, 8100h
  2330.     add    ah, ah
  2331.     cmp    al, 7Eh
  2332.     jbe    sjis3
  2333.     add    ax, 00A2h
  2334. sjis3:
  2335.     add    ax, 2100h
  2336.     ret
  2337.  
  2338.  
  2339. ;---------------------------------------;
  2340. ;    領域を反転表示            ;
  2341. ;---------------------------------------;
  2342. reverse_region:
  2343.     push    cx
  2344.     cmp    cs:mark_flag, ON
  2345.     jne    rev_reg9
  2346.     mov    di, cs:old_curs_pos
  2347.     mov    cx, cs:curs_pos
  2348.     cmp    di, cx
  2349.     jbe    rev_reg1
  2350.     xchg    di, cx
  2351. rev_reg1:
  2352.     sub    cx, di
  2353.     shr    cx, 1
  2354.     jcxz    rev_reg9
  2355. rev_reg2:
  2356. IFDEF    FMR
  2357.   IFDEF    FMR70
  2358.     cmp    word ptr es:[di], VACANT_CHAR
  2359.     je    rev_reg5
  2360.   ELSE
  2361.     cmp    byte ptr es:[di], VACANT_CHAR
  2362.     je    rev_reg5
  2363.   ENDIF
  2364. ELSE
  2365.     cmp    word ptr es:[di], VACANT_CHAR
  2366.     je    rev_reg5
  2367. ENDIF
  2368. IFDEF    FMR
  2369.   IFDEF    FMR70
  2370.     mov    ax, es:[di+ATTR_OFF]
  2371.     and    ax, ATR_WHITE
  2372.     cmp    ax, ATR_YELLOW                ; yellow ?
  2373.   ELSE
  2374.     mov    al, es:[di+1]
  2375.     and    al, ATR_WHITE
  2376.     cmp    al, ATR_YELLOW                ; yellow ?
  2377.   ENDIF
  2378. ELSE
  2379.     mov    al, es:[di+ATTR_OFF]
  2380.     and    al, 11100000b
  2381.     cmp    al, 11000000b                ; yellow ?
  2382. ENDIF
  2383.     je    rev_reg3
  2384. IFDEF    FMR
  2385.   IFDEF    FMR70
  2386.     mov    word ptr es:[di+ATTR_OFF], ATR_YELLOW or ATR_REVERSE    ; yellow, reverse
  2387.   ELSE
  2388.     mov    al, es:[di+1]
  2389.     and    al, ATR_KANJI_1 or ATR_KANJI_2        ; reserve kanji attr.
  2390.     or    al, ATR_YELLOW or ATR_REVERSE        ; yellow, reverse
  2391.     mov    byte ptr es:[di+1], al
  2392.   ENDIF
  2393. ELSE
  2394.     mov    word ptr es:[di+ATTR_OFF], ATR_YELLOW or ATR_REVERSE    ; yellow, reverse
  2395. ENDIF
  2396.     jmp    short rev_reg5
  2397. rev_reg3:
  2398. IFDEF    FMR
  2399.   IFDEF    FMR70
  2400.     cmp    word ptr es:[di], EOL_CHAR
  2401.   ELSE
  2402.     cmp    byte ptr es:[di], EOL_CHAR
  2403.   ENDIF
  2404. ELSE
  2405.     cmp    word ptr es:[di], EOL_CHAR
  2406. ENDIF
  2407.     je    rev_reg4
  2408. IFDEF    FMR
  2409.   IFDEF    FMR70
  2410.     mov    word ptr es:[di+ATTR_OFF], ATR_WHITE    ; normal
  2411.   ELSE
  2412.     mov    al, es:[di+1]
  2413.     and    al, ATR_KANJI_1 or ATR_KANJI_2        ; reserve kanji attr.
  2414.     or    al, ATR_WHITE                ; normal
  2415.     mov    byte ptr es:[di+1], al
  2416.   ENDIF
  2417. ELSE
  2418.     mov    word ptr es:[di+ATTR_OFF], ATR_WHITE    ; normal
  2419. ENDIF
  2420.     jmp    short rev_reg5
  2421. rev_reg4:
  2422. IFDEF    FMR
  2423.   IFDEF    FMR70
  2424.     mov    word ptr es:[di+ATTR_OFF], ATR_CYAN    ; light blue
  2425.   ELSE
  2426.     mov    byte ptr es:[di+1], ATR_CYAN        ; light blue
  2427.   ENDIF
  2428. ELSE
  2429.     mov    word ptr es:[di+ATTR_OFF], ATR_CYAN    ; light blue
  2430. ENDIF
  2431. rev_reg5:
  2432.     add    di, 2
  2433.     loop    rev_reg2
  2434. rev_reg9:
  2435.     pop    cx
  2436.     ret
  2437.  
  2438.  
  2439. ;---------------------------------------;
  2440. ;    領域の表示            ;
  2441. ;---------------------------------------;
  2442. draw_region:
  2443.     push    cx
  2444.     cmp    cs:mark_flag, ON
  2445.     jne    draw_reg9
  2446.     call    get_mark_pos
  2447.     mov    cx, cs:curs_pos
  2448.     cmp    di, cx
  2449.     je    draw_reg9
  2450.     jb    draw_reg1
  2451.     xchg    di, cx
  2452. draw_reg1:
  2453.     sub    cx, di
  2454.     shr    cx, 1
  2455. draw_reg2:
  2456. IFDEF    FMR
  2457.   IFDEF    FMR70
  2458.     cmp    word ptr es:[di], VACANT_CHAR
  2459.     je    draw_reg3
  2460.     mov    word ptr es:[di+ATTR_OFF], ATR_YELLOW or ATR_REVERSE    ; yellow, reverse
  2461.   ELSE
  2462.     cmp    byte ptr es:[di], VACANT_CHAR
  2463.     je    draw_reg3
  2464.     mov    al, es:[di+1]
  2465.     and    al, ATR_KANJI_1 or ATR_KANJI_2        ; reserve kanji attr.
  2466.     or    al, ATR_YELLOW or ATR_REVERSE        ; yellow, reverse
  2467.     mov    byte ptr es:[di+1], al
  2468.   ENDIF
  2469. ELSE
  2470.     cmp    word ptr es:[di], VACANT_CHAR
  2471.     je    draw_reg3
  2472.     mov    word ptr es:[di+ATTR_OFF], ATR_YELLOW or ATR_REVERSE    ; yellow, reverse
  2473. ENDIF
  2474. draw_reg3:
  2475.     add    di, 2
  2476.     loop    draw_reg2
  2477. draw_reg9:
  2478.     pop    cx
  2479.     ret
  2480.  
  2481.  
  2482. ;---------------------------------------;
  2483. ;    領域の開始位置を求める        ;
  2484. ;  Out: DI                ;
  2485. ;---------------------------------------;
  2486. get_mark_pos:
  2487.     push    bx
  2488.     push    dx
  2489.     mov    bx, cs:mark_ptr
  2490.     sub    bx, cs:read_ptr
  2491.     mov    cx, ROW_WIDTH - 1
  2492.     sub    dx, dx
  2493.     sub    di, di
  2494.     mov    ax, cs:page_top
  2495.     sub    ax, cs:read_ptr
  2496.     cmp    ax, bx
  2497.     jae    get_mp9
  2498. get_mp1:
  2499.     mov    ax, cs:line_top[di+2]
  2500.     sub    ax, cs:read_ptr
  2501.     cmp    ax, bx
  2502.     jae    get_mp2
  2503.     add    dx, COLUMN_WIDTH
  2504.     add    di, 2
  2505.     loop    get_mp1
  2506.     mov    di, COLUMN_WIDTH*ROW_WIDTH*2
  2507.     jmp    short get_mp9
  2508. get_mp2:
  2509.     ja    get_mp3
  2510.     add    dx, COLUMN_WIDTH
  2511.     jmp    short get_mp4
  2512. get_mp3:
  2513.     add    dx, cs:mark_ptr
  2514.     sub    dx, cs:line_top[di]
  2515. get_mp4:
  2516.     add    dx, dx
  2517.     mov    di, dx
  2518. get_mp9:
  2519.     pop    dx
  2520.     pop    bx
  2521.     ret
  2522.  
  2523.  
  2524. ;---------------------------------------;
  2525. ;    領域を消去            ;
  2526. ;---------------------------------------;
  2527. clear_region:
  2528.     push    cx
  2529.     cmp    cs:mark_flag, ON
  2530.     jne    clr_reg9
  2531.     mov    di, cs:curs_pos
  2532.     mov    cx, cs:old_curs_pos
  2533.     cmp    di, cx
  2534.     je    clr_reg9
  2535.     jb    clr_reg1
  2536.     xchg    di, cx
  2537. clr_reg1:
  2538.     sub    cx, di
  2539.     shr    cx, 1
  2540. clr_reg2:
  2541. IFDEF    FMR
  2542.   IFDEF    FMR70
  2543.     cmp    word ptr es:[di], VACANT_CHAR
  2544.     je    clr_reg5
  2545.     cmp    word ptr es:[di], EOL_CHAR
  2546.     je    clr_reg4
  2547.     mov    word ptr es:[di+ATTR_OFF], ATR_WHITE    ; normal
  2548.     jmp    short clr_reg5
  2549. clr_reg4:
  2550.     mov    word ptr es:[di+ATTR_OFF], ATR_CYAN    ; light blue
  2551.   ELSE
  2552.     cmp    byte ptr es:[di], VACANT_CHAR
  2553.     je    clr_reg5
  2554.     mov    al, es:[di+1]
  2555.     and    al, ATR_KANJI_1 or ATR_KANJI_2        ; reserve kanji attr.
  2556.     or    al, ATR_CYAN                ; light blue
  2557.     cmp    byte ptr es:[di], EOL_CHAR
  2558.     je    clr_reg4
  2559.     or    al, ATR_WHITE                ; normal
  2560. clr_reg4:
  2561.     mov    byte ptr es:[di+1], al
  2562.   ENDIF
  2563. ELSE
  2564.     cmp    word ptr es:[di], VACANT_CHAR
  2565.     je    clr_reg5
  2566.     cmp    word ptr es:[di], EOL_CHAR
  2567.     je    clr_reg4
  2568.     mov    word ptr es:[di+ATTR_OFF], ATR_WHITE    ; normal
  2569.     jmp    short clr_reg5
  2570. clr_reg4:
  2571.     mov    word ptr es:[di+ATTR_OFF], ATR_CYAN    ; light blue
  2572. ENDIF
  2573. clr_reg5:
  2574.     add    di, 2
  2575.     loop    clr_reg2
  2576. clr_reg9:
  2577.     pop    cx
  2578.     ret
  2579.  
  2580.  
  2581. ;-----------------------------------------------;
  2582. ;    現在の注目点とカーソル位置の計算    ;
  2583. ;-----------------------------------------------;
  2584. adjust_curs_pos:
  2585.     mov    bx, cs:curs_pos_row
  2586.     add    bx, bx
  2587.  
  2588.     mov    ax, cs:line_top[bx]
  2589.     mov    cs:curr_line_top, ax        ; current line top
  2590.  
  2591.     mov    ax, cs:line_top[bx+2]
  2592.     sub    ax, cs:line_top[bx]
  2593.     test    ax, ax
  2594.     jz    adj_cp0
  2595.     dec    ax
  2596. adj_cp0:
  2597.     mov    cs:curr_line_leng, ax        ; current line length
  2598.  
  2599.     cmp    ax, cs:curs_pos_col_s
  2600.     jbe    adj_cp1
  2601.     mov    ax, cs:curs_pos_col_s
  2602. adj_cp1:
  2603.     mov    cs:curs_pos_col, ax        ; cursor column position
  2604.  
  2605.     add    ax, cs:line_top[bx]
  2606.     mov    cs:current_ptr, ax        ; current pointer
  2607.  
  2608.     mov    al, COLUMN_WIDTH
  2609.     mul    byte ptr cs:curs_pos_row
  2610.     add    ax, cs:curs_pos_col
  2611.     add    ax, ax
  2612.     mov    cs:curs_pos, ax            ; cursor position
  2613.  
  2614.     ret
  2615.  
  2616.  
  2617. ;---------------------------------------;
  2618. ;    カーソル位置の計算        ;
  2619. ;  Out: zero flag            ;
  2620. ;      ON .. found in current screen    ;
  2621. ;     OFF .. not found        ;
  2622. ;---------------------------------------;
  2623. calc_curs_pos:
  2624.     mov    cx, ROW_WIDTH
  2625. ;    mov    cx, word ptr cs:row_width_0
  2626.     sub    bx, bx
  2627. calc_cp1:
  2628.     mov    ax, cs:current_ptr
  2629.     mov    si, cs:line_top[bx]
  2630.     sub    ax, si
  2631.     mov    dx, cs:line_top[bx+2]
  2632.     sub    dx, si
  2633.     cmp    ax, dx
  2634.     jb    calc_cp2
  2635.     add    bx, 2
  2636.     loop    calc_cp1
  2637.     or    bx, bx            ; not found.
  2638.     ret
  2639. ;
  2640. calc_cp2:
  2641.     mov    cs:curs_pos_col, ax
  2642.     mov    cs:curs_pos_col_s, ax
  2643.     mov    ax, ROW_WIDTH
  2644. ;    mov    ax, word ptr cs:row_width_0
  2645.     sub    ax, cx
  2646.     mov    cs:curs_pos_row, ax
  2647.     sub    ax, ax            ; found.
  2648.     ret
  2649.  
  2650.  
  2651. ;---------------------------------------;
  2652. ;    文字列の入力            ;
  2653. ;  In : BX = Row            ;
  2654. ;    CX = Column            ;
  2655. ;---------------------------------------;
  2656. getstr:
  2657.     push    bx
  2658.     push    cx
  2659.     push    dx
  2660.     push    si
  2661.     push    di
  2662. IFNDEF    FMR
  2663.     mov    byte ptr cs:getchar_flag, ON
  2664. ENDIF
  2665.     mov    si, offset str_buf
  2666.     sub    dx, dx
  2667. getstr1:
  2668.     mov    ax, '$'
  2669.     call    putchr
  2670.     call    getchar
  2671.     cmp    al, CR
  2672.     jne    getstr1_0
  2673. getstr1_9:
  2674.     jmp    getstr9
  2675. getstr1_0:
  2676.     cmp    al, CTRL_J
  2677.     je    getstr1_9
  2678.     cmp    al, CTRL_C
  2679.     je    getstr1_9
  2680. IF 0
  2681.     sub    ah, HELP
  2682.     jz    getstr3
  2683. ENDIF
  2684.     sub    ah, ah
  2685.     cmp    al, BS
  2686.     jne    getstr2
  2687.     test    dx, dx
  2688.     jz    getstr1
  2689.     xor    di, di
  2690. getstr1_1:                ; check kanji in str_buf
  2691.     mov    al, cs:str_buf[di]
  2692.     inc    di
  2693.     xor    ah, ah
  2694.     call    iskanji
  2695.     jnc    getstr1_2        ; not kanji
  2696.     inc    di
  2697.     inc    ah
  2698. getstr1_2:
  2699.     cmp    di, dx
  2700.     jc    getstr1_1
  2701.     push    ax
  2702.     mov    ax, ' '
  2703.     call    putchr
  2704.     dec    si
  2705.     dec    cx
  2706.     dec    dx
  2707.     pop    ax
  2708.     test    ah, ah
  2709.     je    getstr1
  2710.     mov    ax, ' '
  2711.     call    putchr
  2712.     dec    si
  2713.     dec    cx
  2714.     dec    dx
  2715.     jmp    short    getstr1
  2716. getstr2:
  2717.     cmp    dx, STR_BUF_SIZ
  2718.     jnc    getstr1
  2719.     call    iskanji
  2720.     jnc    getstr2_2        ; no
  2721.     cmp    dx, STR_BUF_SIZ-1
  2722.     jne    getstr2_1
  2723.     call    getchar
  2724.     jmp    short getstr1
  2725. getstr2_1:
  2726.     mov    di, ax            ; save 1st byte
  2727.     call    getchar            ; get 2nd byte
  2728.     mov    ah, al
  2729.     sub    al, al
  2730.     add    ax, di
  2731.     mov    cs:[si], ax        ; put kanji into str_buf
  2732.     add    si, 2
  2733.     add    dx, 2
  2734.     xchg    ah, al            ; swap bytes
  2735.     call    sjis_to_vjis
  2736.     push    ax
  2737.     mov    al, ah
  2738.     mov    ah, 01h
  2739.     call    putchr
  2740.     inc    cx
  2741.     pop    ax
  2742.     mov    ah, 03h
  2743.     call    putchr
  2744.     inc     cx
  2745.     jmp    getstr1
  2746. getstr2_2:
  2747.     call    putchr
  2748.     mov    cs:[si], al
  2749.     inc    si
  2750.     inc    cx
  2751.     inc    dx
  2752.     jmp    getstr1
  2753. ;
  2754. IF    0
  2755. getstr3:
  2756.     mov    di, cs:current_ptr
  2757. getstr4:
  2758.     cmp    dx, STR_BUF_SIZ
  2759.     je    getstr1
  2760.     mov    ax, [di]
  2761.     cmp    al, 20h
  2762.     jbe    getstr1
  2763.     cmp    al, 7fh
  2764.     jc    getstr6
  2765.     cmp    al, 81h
  2766.     jc    getstr1
  2767.     cmp    al, 0a0h
  2768.     jc    getstr5
  2769.     cmp    al, 0e0h
  2770.     jc    getstr6
  2771.     cmp    al, 0fch
  2772.     jne    getstr_5_0
  2773.     mov    al, '\'
  2774.     jmp    short getstr6
  2775. getstr_5_0:
  2776.     jnc    getstr1
  2777. getstr5:
  2778.     xchg    ah, al
  2779.     cmp    al, 40h
  2780.     jc    getstr1
  2781.     cmp    al, 7fh
  2782.     jc    getstr5_1
  2783.     cmp    al, 81h
  2784.     jc    getstr1
  2785.     cmp    al, 0fdh
  2786.     jnc    getstr1
  2787. getstr5_1:
  2788.     cmp    dx, STR_BUF_SIZ - 1
  2789.     je    getstr1
  2790.     xchg    ah, al
  2791.     mov    cs:[si], ax
  2792.     xchg    ah, al
  2793.     inc    si
  2794.     inc    si
  2795.     inc    di
  2796.     inc    di
  2797.     inc    dx
  2798.     inc    dx
  2799.     call    sjis_to_vjis
  2800.     sub    ax, 2000h
  2801.     xchg    ah, al
  2802.     call    putchr
  2803.     add    al, 80h
  2804.     inc    cx
  2805.     call    putchr
  2806.     inc    cx
  2807.     jmp    short getstr4
  2808. ;
  2809. getstr6:
  2810.     mov    cs:[si], al
  2811.     xor    ah, ah
  2812.     call    putchr
  2813.     inc    cx
  2814.     inc    si
  2815.     inc    di
  2816.     inc    dx
  2817.     jmp    short getstr4
  2818. ENDIF
  2819.  
  2820. getstr9:
  2821.     mov    cs:str_len, dx
  2822. ;    mov    byte ptr cs:getchar_flag, OFF
  2823.     pop    di
  2824.     pop    si
  2825.     pop    dx
  2826.     pop    cx
  2827.     pop    bx
  2828.     ret
  2829.  
  2830.  
  2831. ;-----------------------------------------------;
  2832. ;    画面上の特定位置への文字列の表示    ;
  2833. ;  In : AX = String offset            ;
  2834. ;    BX = Row                ;
  2835. ;    CX = Column                ;
  2836. ;-----------------------------------------------;
  2837. putstr:
  2838.     push    ax
  2839.     push    cx
  2840.     mov    si, ax
  2841.     sub    ax, ax
  2842. putstr1:
  2843.     mov    al, cs:[si]
  2844.     inc    si
  2845.     test    ax, ax
  2846.     jz    putstr2
  2847.     call    putchr
  2848.     inc    cx
  2849.     jmp    short putstr1
  2850. putstr2:
  2851.     pop    cx
  2852.     pop    ax
  2853.     ret
  2854.  
  2855.  
  2856. ;=======================================;
  2857. ;        機種依存部分        ;
  2858. ;=======================================;
  2859.  
  2860. ;---------------------------------------;
  2861. ;    Show/Clear through mode flag    ;
  2862. ;---------------------------------------;
  2863. show_thru_flag:
  2864.     push    ax
  2865.     push    es
  2866.     mov    es, cs:tvram_seg
  2867.     test    byte ptr es:[COLUMN_WIDTH*24*2], not 20h    ; blank ?
  2868.     jne    show_thru_f1                    ; no, skip
  2869. ;    mov    al, '!'
  2870.     mov    byte ptr es:[COLUMN_WIDTH*24*2], '!'
  2871. IFDEF    FMR
  2872.   IFDEF    FMR70
  2873.     mov    word ptr es:[COLUMN_WIDTH*24*2+ATTR_OFF], ATR_WHITE
  2874.   ELSE
  2875.     mov    byte ptr es:[COLUMN_WIDTH*24*2+1], ATR_WHITE
  2876.   ENDIF
  2877. ELSE
  2878.     mov    word ptr es:[COLUMN_WIDTH*24*2+ATTR_OFF], ATR_WHITE
  2879. ENDIF
  2880. show_thru_f1:
  2881.     pop    es
  2882.     pop    ax
  2883.     ret
  2884.  
  2885. clear_thru_flag:
  2886.     push    ax
  2887.     push    es
  2888.     mov    es, cs:tvram_seg
  2889. ;    mov    al, ' '
  2890.     mov    byte ptr es:[COLUMN_WIDTH*24*2], ' '
  2891.     pop    es
  2892.     pop    ax
  2893.     ret
  2894.  
  2895.  
  2896. ;---------------------------------------;
  2897. ;    キーボード入力を得る        ;
  2898. ;  Out: AH = scan code            ;
  2899. ;    AL = character code        ;
  2900. ;---------------------------------------;
  2901. getchar:
  2902. IFDEF    FMR
  2903.     push    bx
  2904.     push    dx
  2905.     mov    ah, 7        ; 入力のチェック
  2906.     int    90h
  2907.     cmp    al, 0        ; バッファ内に文字存在?
  2908.     je    getch1        ; 存在しない
  2909.     mov    al, 1        ; バッファから入力
  2910. getch1:
  2911.     mov    ah, 9        ; 文字の読込
  2912.     int    90h
  2913.   IFDEF    FMR70
  2914.       call    refbank
  2915.   ENDIF
  2916.     mov    ah, bh        ; スキャンコードを設定
  2917.     mov    al, dl        ; 文字コードを設定
  2918.     mov    cs:shift_status, bl    ; シフト状態を設定
  2919.     pop    dx
  2920.     pop    bx
  2921. ELSE
  2922.     push    es
  2923.     push    bx
  2924.     sub    ax, ax
  2925.     mov    es, ax
  2926. getch0:
  2927.     cli
  2928.     cmp    byte ptr es:[KBUF_CNT], 0
  2929.     jne    getch1
  2930.     sti
  2931.     jmp    short getch0
  2932. getch1:
  2933.     mov    bx, es:[KBUF_RPTR]
  2934.     mov    ax, es:[bx]        ; get key input data.
  2935.     add    bx, 2
  2936.     cmp    bx, KBUF_END
  2937.     jb    getch2
  2938.     mov    bx, KBUF_BGN
  2939. getch2:
  2940.     mov    es:[KBUF_RPTR], bx
  2941.     dec    byte ptr es:[KBUF_CNT]
  2942.     sti
  2943.  
  2944.     pop    bx
  2945.     pop    es
  2946. ENDIF
  2947.     ret
  2948.  
  2949.  
  2950. ;---------------------------------------;
  2951. ;    画面上の特定位置への文字の表示     ;
  2952. ;    In : AX = Char code                ;
  2953. ;         BX = Row                      ;
  2954. ;         CX = Column                   ;
  2955. ;---------------------------------------;
  2956. putchr:
  2957.     push    ax
  2958.     push    bx
  2959.     push    cx
  2960.     push    dx
  2961. IFDEF    FMR
  2962.     mov    dh, bl        ; set row
  2963.     inc    dh
  2964.     mov    dl, cl        ; set column
  2965.     inc    dl
  2966.     mov    bh, ah        ; set char type
  2967.     mov    bl, al        ; set char code
  2968.     mov    al, 1        ; use old attribute
  2969.     mov    ah, 13h        ; putchar
  2970.     int    91h        ; call BIOS display
  2971.   IFDEF    FMR70
  2972.       call    refbank
  2973.   ENDIF
  2974. ELSE
  2975.     mov    dx, ax
  2976.     mov    al, COLUMN_WIDTH
  2977. ;    cmp    cs:xchange_job, OFF
  2978. ;    jz    putchr_1
  2979. ;    dec    bl
  2980. putchr_1:
  2981.     mul    bl
  2982.     add    ax, cx
  2983.     add    ax, ax
  2984.     mov    bx, ax
  2985.     mov    es:[bx], dx
  2986. ENDIF
  2987.     pop    dx
  2988.     pop    cx
  2989.     pop    bx
  2990.     pop    ax
  2991.     ret
  2992.  
  2993.  
  2994. ;-------------------------------------------------------;
  2995. ;    画面をスクロールダウンして最上行に空きを作る    ;
  2996. ;-------------------------------------------------------;
  2997. make_room_top:
  2998.     push    ax
  2999.     push    cx
  3000.     push    si
  3001.     push    di
  3002.     push    ds
  3003.     push    es
  3004.  
  3005.     mov    cx, es
  3006.     mov    ds, cx
  3007.     std
  3008.  
  3009.     mov    cx, COLUMN_WIDTH*(ROW_WIDTH-1)        ; text area.
  3010. IFDEF    FMR
  3011.   IFDEF    FMR70
  3012.     mov    di, COLUMN_WIDTH*2*ROW_WIDTH-2
  3013.     mov    si, COLUMN_WIDTH*2*(ROW_WIDTH-1)-2
  3014.     rep    movsw
  3015.     mov    ax, VACANT_CHAR
  3016.     mov    cx, COLUMN_WIDTH
  3017.     rep    stosw
  3018.   ELSE
  3019.     mov    di, COLUMN_WIDTH*2*ROW_WIDTH-1
  3020.     mov    si, COLUMN_WIDTH*2*(ROW_WIDTH-1)-1
  3021. make_room_t1:
  3022.     movsb
  3023.     movsb
  3024.     loop    make_room_t1
  3025.     mov    cx, COLUMN_WIDTH
  3026. make_room_t2:
  3027.     mov    al, ATR_WHITE
  3028.     stosb
  3029.     mov    al, 20h
  3030.     stosb
  3031.     loop    make_room_t2
  3032.   ENDIF
  3033. ELSE
  3034.     mov    di, COLUMN_WIDTH*2*ROW_WIDTH-2
  3035.     mov    si, COLUMN_WIDTH*2*(ROW_WIDTH-1)-2
  3036.     rep    movsw
  3037.     mov    ax, VACANT_CHAR
  3038.     mov    cx, COLUMN_WIDTH
  3039.     rep    stosw
  3040. ENDIF
  3041.     mov    cx, COLUMN_WIDTH*(ROW_WIDTH-1)        ; attribute area.
  3042. IFDEF    FMR
  3043.   IFDEF    FMR70
  3044.     mov    di, COLUMN_WIDTH*2*ROW_WIDTH-2 + ATTR_OFF
  3045.     mov    si, COLUMN_WIDTH*2*(ROW_WIDTH-1)-2 + ATTR_OFF
  3046.     rep    movsw
  3047.     mov    ax, ATR_WHITE
  3048.     mov    cx, COLUMN_WIDTH
  3049.     rep    stosw
  3050.   ELSE
  3051.     mov    di, COLUMN_WIDTH*2*ROW_WIDTH-1 + ATTR_OFF
  3052.     mov    si, COLUMN_WIDTH*2*(ROW_WIDTH-1)-1 + ATTR_OFF
  3053. make_room_t5:
  3054.     movsb
  3055.     movsb
  3056.     loop    make_room_t5
  3057.     mov    al, 21h                ; upper/lower byte of kanji blank '2121h'
  3058.     mov    cx, COLUMN_WIDTH
  3059. make_room_t6:
  3060.     stosb
  3061.     stosb
  3062.     loop    make_room_t6
  3063.   ENDIF
  3064. ELSE
  3065.     mov    di, COLUMN_WIDTH*2*ROW_WIDTH-2 + ATTR_OFF
  3066.     mov    si, COLUMN_WIDTH*2*(ROW_WIDTH-1)-2 + ATTR_OFF
  3067.     rep    movsw
  3068.     mov    ax, ATR_WHITE
  3069.     mov    cx, COLUMN_WIDTH
  3070.     rep    stosw
  3071. ENDIF
  3072.     mov    cx, cs
  3073.     mov    ds, cx
  3074.     mov    es, cx
  3075.     mov    cx, ROW_WIDTH
  3076.     mov    di, offset page_bottom
  3077.     mov    si, offset page_bottom - 2
  3078.     rep    movsw
  3079.  
  3080.     cld
  3081.     pop    es
  3082.     pop    ds
  3083.     pop    di
  3084.     pop    si
  3085.     pop    cx
  3086.     pop    ax
  3087.     ret
  3088.  
  3089.  
  3090. ;-------------------------------------------------------;
  3091. ;    画面をスクロールアップして最下行に空きを作る    ;
  3092. ;-------------------------------------------------------;
  3093. make_room_bottom:
  3094.     push    ax
  3095.     push    cx
  3096.     push    si
  3097.     push    di
  3098.     push    ds
  3099.     push    es
  3100.  
  3101.     mov    cx, es
  3102.     mov    ds, cx
  3103.     cld
  3104.  
  3105.     mov    cx, COLUMN_WIDTH*(ROW_WIDTH-1)        ; text area.
  3106.     mov    di, 0
  3107.     mov    si, COLUMN_WIDTH*2
  3108. IFDEF    FMR
  3109.   IFDEF    FMR70
  3110.     rep    movsw
  3111.     mov    ax, VACANT_CHAR
  3112.     mov    cx, COLUMN_WIDTH
  3113.     rep    stosw
  3114.   ELSE
  3115. make_room_b1:
  3116.     movsb
  3117.     movsb
  3118.     loop    make_room_b1
  3119.     mov    cx, COLUMN_WIDTH
  3120. make_room_b2:
  3121.     mov    al, 20h
  3122.     stosb
  3123.     mov    al, ATR_WHITE
  3124.     stosb
  3125.     loop    make_room_b2
  3126.   ENDIF
  3127. ELSE
  3128.     rep    movsw
  3129.     mov    ax, VACANT_CHAR
  3130.     mov    cx, COLUMN_WIDTH
  3131.     rep    stosw
  3132. ENDIF
  3133.     mov    cx, COLUMN_WIDTH*(ROW_WIDTH-1)        ; attribute area.
  3134.     mov    di, ATTR_OFF
  3135.     mov    si, COLUMN_WIDTH*2 + ATTR_OFF
  3136. IFDEF    FMR
  3137.   IFDEF    FMR70
  3138.     rep    movsw
  3139.     mov    ax, ATR_WHITE
  3140.     mov    cx, COLUMN_WIDTH
  3141.     rep    stosw
  3142.   ELSE
  3143. make_room_b5:
  3144.     movsb
  3145.     movsb
  3146.     loop    make_room_b5
  3147.     mov    al, 21h                ; upper/lower byte of kanji blank '2121h'
  3148.     mov    cx, COLUMN_WIDTH
  3149. make_room_b6:
  3150.     stosb
  3151.     stosb
  3152.     loop    make_room_b6
  3153.   ENDIF
  3154. ELSE
  3155.     rep    movsw
  3156.     mov    ax, ATR_WHITE
  3157.     mov    cx, COLUMN_WIDTH
  3158.     rep    stosw
  3159. ENDIF
  3160.     mov    cx, cs
  3161.     mov    ds, cx
  3162.     mov    es, cx
  3163.     mov    cx, ROW_WIDTH
  3164.     mov    di, offset page_top
  3165.     mov    si, offset page_top + 2
  3166.     rep    movsw
  3167.  
  3168.     pop    es
  3169.     pop    ds
  3170.     pop    di
  3171.     pop    si
  3172.     pop    cx
  3173.     pop    ax
  3174.     ret
  3175.  
  3176.  
  3177. ;---------------------------------------;
  3178. ;    save screen            ;
  3179. ;---------------------------------------;
  3180. save_screen:
  3181.     mov    ds, cs:tvram_seg
  3182.     mov    es, cs:tvbuf_seg
  3183.     sub    ax, ax
  3184.     mov    si, ax
  3185.     mov    di, ax
  3186. IFDEF    FMR
  3187.   IFDEF    FMR70
  3188.     mov    cx, 1000h/2
  3189.     cld
  3190.     rep    movsw
  3191.     mov    si, ATTR_OFF
  3192.     mov    cx, 1000h/2
  3193.     rep    movsw
  3194.   ELSE
  3195.     mov    cx, 1000h
  3196.     cld
  3197.     rep    movsb
  3198.     mov    si, ATTR_OFF
  3199.     mov    cx, 1000h
  3200.     rep    movsb
  3201.   ENDIF
  3202. ELSE
  3203.     mov    cx, 1000h/2
  3204.     cld
  3205.     rep    movsw
  3206.     mov    si, ATTR_OFF
  3207.     mov    cx, 1000h/2
  3208.     rep    movsw
  3209. ENDIF
  3210.     ret
  3211.  
  3212.  
  3213. ;---------------------------------------;
  3214. ;    restore screen            ;
  3215. ;---------------------------------------;
  3216. restore_screen:
  3217.     mov    ds, cs:tvbuf_seg
  3218.     mov    es, cs:tvram_seg
  3219.     sub    ax, ax
  3220.     mov    si, ax
  3221.     mov    di, ax
  3222. IFDEF    FMR
  3223.   IFDEF    FMR70
  3224.     mov    cx, 1000h/2
  3225.     cld
  3226.     rep    movsw
  3227.     mov    di, ATTR_OFF
  3228.     mov    cx, 1000h/2
  3229.     rep    movsw
  3230.   ELSE
  3231.     mov    cx, 1000h
  3232.     cld
  3233.     rep    movsb
  3234.     mov    di, ATTR_OFF
  3235.     mov    cx, 1000h
  3236.     rep    movsb
  3237.   ENDIF
  3238. ELSE
  3239.     mov    cx, 1000h/2
  3240.     cld
  3241.     rep    movsw
  3242.     mov    di, ATTR_OFF
  3243.     mov    cx, 1000h/2
  3244.     rep    movsw
  3245. ENDIF
  3246.     ret
  3247.  
  3248.  
  3249. ;---------------------------------------;
  3250. ;    display quasi-cursor        ;
  3251. ;---------------------------------------;
  3252. disp_cursor:
  3253.     push    bx
  3254.     mov    bx, cs:curs_pos
  3255.     mov    cs:old_curs_pos, bx
  3256. IFDEF    FMR
  3257.   IFDEF    FMR70
  3258.     or    word ptr es:[bx+ATTR_OFF], ATR_REVERSE    ; set reverse flag.
  3259.   ELSE
  3260.     or    byte ptr es:[bx+1], ATR_REVERSE        ; set reverse flag.
  3261.   ENDIF
  3262. ELSE
  3263.     or    word ptr es:[bx+ATTR_OFF], ATR_REVERSE    ; set reverse flag.
  3264. ENDIF
  3265.     pop    bx
  3266.     ret
  3267.  
  3268.  
  3269. ;---------------------------------------;
  3270. ;    clear quasi-cursor        ;
  3271. ;---------------------------------------;
  3272. clear_cursor:
  3273.     push    bx
  3274.     mov    bx, cs:curs_pos
  3275. IFDEF    FMR
  3276.   IFDEF    FMR70
  3277.     mov    ax, es:[bx+ATTR_OFF]
  3278.     and    ax, ATR_WHITE
  3279.     cmp    ax, ATR_YELLOW                ; yellow ?
  3280.   ELSE
  3281.     mov    al, es:[bx+1]
  3282.     and    al, ATR_WHITE
  3283.     cmp    al, ATR_YELLOW                ; yellow ?
  3284.   ENDIF
  3285. ELSE
  3286.     mov    al, es:[bx+ATTR_OFF]
  3287.     and    al, 11100000b
  3288.     cmp    al, 11000000b                ; yellow ?
  3289. ENDIF
  3290.     je    clr_curs1
  3291. IFDEF    FMR
  3292.   IFDEF    FMR70
  3293.     and    word ptr es:[bx+ATTR_OFF], not ATR_REVERSE    ; clear reverse flag.
  3294.   ELSE
  3295.     and    byte ptr es:[bx+1], not ATR_REVERSE        ; clear reverse flag.
  3296.   ENDIF
  3297. ELSE
  3298.     and    word ptr es:[bx+ATTR_OFF], not ATR_REVERSE    ; clear reverse flag.
  3299. ENDIF
  3300. clr_curs1:
  3301.     pop    bx
  3302.     ret
  3303.  
  3304.  
  3305. ;-------------------------------;
  3306. ;    clear keyboard buffer    ;
  3307. ;-------------------------------;
  3308. clear_keybuf:
  3309. IFDEF    FMR
  3310.     push    dx
  3311.     push    cx
  3312.     push    bx
  3313.     push    ax
  3314.     mov    ah, 6        ; バッファのクリア
  3315.     mov    al, 0
  3316.     int    90h
  3317.   IFDEF    FMR70
  3318.       call    refbank
  3319.   ENDIF
  3320.     pop    ax
  3321.     pop    bx
  3322.     pop    cx
  3323.     pop    dx
  3324. ENDIF
  3325.     ret
  3326.  
  3327.  
  3328. ;---------------------------------------;
  3329. ;    漢字の第一バイトをチェック    ;
  3330. ;  In :    AL = Char code            ;
  3331. ;  Out: Carry = 1 : True        ;
  3332. ;        0 : False        ;
  3333. ;---------------------------------------;
  3334. iskanji:
  3335.     cmp    al, 0fdh
  3336.     jnc    iskanji0
  3337.     cmp    al, 0e0h
  3338.     jnc    iskanji1
  3339.     cmp    al, 0a0h
  3340.     jnc    iskanji0
  3341.     cmp    al, 81h
  3342.     jnc    iskanji1
  3343.     clc
  3344. iskanji0:
  3345.     ret
  3346. iskanji1:
  3347.     stc
  3348.     ret
  3349.  
  3350.  
  3351. code    ends
  3352.  
  3353.     end    start
  3354.  
  3355.