home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FreeWare Collection 2
/
FreeSoftwareCollection2pd199x-jp.img
/
ms_dos
/
xscrfm51
/
xscript.asm
< prev
next >
Wrap
Assembly Source File
|
1990-06-14
|
64KB
|
3,355 lines
title xscript version 1.4 for FMR series
page 66, 132
;
; Transcript service for PC-9801 MS-DOS (Ver 1.4)
; Trap int 29h.
; Written by Oka / Feb. 7, 1988.
; Modified for FMR by SHU on Jan. 1989
; Ver. 2.1 by SHU / Mar. 11, 1989
; Ver. 2.2 by SHU / Mar. 21, 1989
; Ver. 2.3 by SHU / Mar. 25, 1989
; Ver. 3.0 by SHU / Apr. 1, 1989
; Ver. 3.1 by SHU / Apr. 7, 1989
; Ver. 3.2 by SHU / Apr. 11, 1989
; Ver. 3.3 by SHU / Apr. 22, 1989
; Ver. 3.4 by SHU / May. 11, 1989
; Ver. 4.0 by SHU / May. 27, 1989
; Ver. 4.1 by SHU / Jun. 15, 1989
; Ver. 4.2 by SHU / Jan. 13, 1990
; Ver. 4.3 by SHU / Feb. 15, 1990
; Ver. 5.0 by SHU / Feb. 21, 1990
; Ver. 5.1 by SHU / Mar. 6, 1990
;
include xscript.h
include kbdrv.h
;=======================================;
; beginning of code ;
;=======================================;
code segment byte public
assume cs:code
org 100h
stack_top equ $
start:
extrn init : near
jmp init ; initialize
public my_name, my_name_len
my_name db 'Transcript service Ver 1.4'
db '5' ; FM version 5.x
my_name_len dw offset my_name_len - offset my_name
;=======================================;
; DATA SECTION ;
;=======================================;
public int18h_entry
public int29h_entry
public org_xint_entry
public tvram_seg
public txtbuf_seg
public tvbuf_seg
public xbank_on
public header_char
public always_paste
;public current_key
;public bottom_key
;public paste_key
;public disable_key
current_key db DOWN_ARROW
bottom_key db UP_ARROW
IFDEF FMR
paste_key db HOME
disable_key db CANCEL
ELSE
paste_key db HELP
disable_key db BS_KEY
ENDIF
busy_flag db OFF
mark_flag db OFF
exit_flag db OFF
access_flag db OFF
case_sensitive db OFF
IFDEF FMR
public use_gvram_flag
public use_mm_flag
use_gvram_flag db OFF
use_mm_flag db OFF
shift_status db 0
ENDIF
IFNDEF FMR
sys_seg dw 0 ; system area segment
ENDIF
tvram_seg dw TVRAM_SEG_R70
txtbuf_seg dw TXTBUF_SEG_R70
tvbuf_seg dw TVBUF_SEG_R70
banksel_w_port dw BANK_PORT_W
xbank_w_on db BANK_W_P0
xbank_w_off db BANK_OFF_NUM
banksel_port dw BANK_PORT
xbank_on db BANK_ON_NUM
xbank_off db BANK_OFF_NUM
IFDEF FMR
IFDEF FMR70
xbank_now db ? ; current bank save area
ENDIF
ENDIF
user_ax dw ?
user_bx dw ?
user_cx dw ?
user_dx dw ?
user_si dw ?
user_di dw ?
user_bp dw ?
user_sp dw ?
user_ds dw ?
user_es dw ?
user_ss dw ?
kb_sense_cnt dw 0
proc_addr dw offset trap29h_normal
str_top dw 0
txtbuf_end dw 0
last_page_top dw 0
page_top label word
line_top dw ROW_WIDTH dup (?)
page_bottom dw ?
curr_line_top dw ?
curr_line_leng dw ?
bottom_curs_row dw ?
curs_pos_row dw ?
curs_pos_col dw ?
curs_pos_col_s dw ?
curs_pos dw ?
old_curs_pos dw ?
current_ptr dw ?
mark_ptr dw ?
cutbuf_bgn dw ?
cutbuf_ptr dw ?
cutbuf_cnt dw 0
cutbuf_cnt_save dw 0
search_dir dw 1
search_end dw ?
read_ptr dw 0
write_ptr dw 0
int18h_entry dw ?
dw ?
int29h_entry dw ?
dw ?
org_xint_entry dw ?
dw ?
STR_BUF_SIZ = 16
WORK_BOX_COL = COLUMN_WIDTH - STR_BUF_SIZ-3
white_str db STR_BUF_SIZ+3 dup (' '), 0
str_buf db STR_BUF_SIZ dup (?)
str_len dw ?
label_msg db ' set label ', 0
goto_msg db ' goto label ', 0
clear_msg db ' ', 0
label_table dw (7fh - 20h) dup(0)
; ; 画面分割パラメータ
;screen_list label word
;divs_data dw XURAVRAM
;row_width_0 dw ROW_WIDTH
;row_width_3 dw ROW_WIDTH * COLUMN_WIDTH * 2
;row_width_4 dw 25 - ROW_WIDTH
; dw 3 dup (0,0)
;
;screen_list_save dw 1
; dw 0
; dw 25d
; dw 6 dup (0)
row_width_0_1 dw ROW_WIDTH
row_width_0_2 dw ROW_WIDTH
row_width_1 dw ROW_WIDTH - 1
row_width_2 dw ROW_WIDTH * COLUMN_WIDTH
header_char db '>'
this_line_hc db 0
this_paste_hc db 0
always_paste db 0 ; include header char with SHIFT key
lastpaste db 0
search_msg db ' search... ',0
found_msg db ' found. ',0
nfound_msg db ' not found. ',0
break_msg db ' broken. ',0
; dw 128 dup (?) ; stack area
;stack_top dw ?
;edit_buf db 260 dup (?)
;=======================================;
; CODE SECTION ;
;=======================================;
;---------------------------------------;
; BANK select routine ;
;---------------------------------------;
selbank: ; select bank for transcript buffer
IFDEF FMR
IFDEF FMR70
cmp cs:use_mm_flag, ON
je sel_bank9
cmp cs:use_gvram_flag, ON
jne sel_bank1
push dx
mov dx, cs:banksel_w_port ; set write plane port address
in al, dx
mov cs:xbank_w_off, al ; save old status
mov al, cs:xbank_w_on
out dx, al
pop dx
sel_bank1:
push dx
mov dx, cs:banksel_port
in al, dx
mov cs:xbank_off, al
mov al, cs:xbank_on
mov cs:xbank_now, al ; save current bank
out dx, al
pop dx
sel_bank9:
ENDIF
ELSE
push dx
mov dx, cs:banksel_port
mov al, cs:xbank_on
out dx, al
pop dx
ENDIF
ret
unselbank: ; select bank for other jobs
IFDEF FMR
IFDEF FMR70
cmp cs:use_mm_flag, ON
je unsel_bank9
cmp cs:use_gvram_flag, ON
jne unsel_bank1
push dx
mov dx, cs:banksel_w_port
mov al, cs:xbank_w_off
out dx, al
pop dx
unsel_bank1:
push dx
mov dx, cs:banksel_port
mov al, cs:xbank_off
mov cs:xbank_now, al ; save current bank
out dx, al
pop dx
unsel_bank9:
ENDIF
ELSE
push dx
mov dx, cs:banksel_port
mov al, cs:xbank_off
out dx, al
pop dx
ENDIF
ret
IFDEF FMR
IFDEF FMR70
refbank:
push dx
push ax
mov dx, cs:banksel_port
mov al, cs:xbank_now
out dx, al
pop ax
pop dx
ret
ENDIF
ENDIF
;---------------------------------------;
; int 18h trap routine ;
; int 90h trap routine for FM ;
;---------------------------------------;
public trap18h_entry
trap18h_entry:
IFDEF FMR
push ax
cmp cs:cutbuf_cnt, 0
jz trap18h_exit
cmp ah, 7 ; KB sense ?
je trap18h1
cmp ah, 9 ; KB read ?
jne trap18h_exit
trap18h1:
IFDEF FMR70
pushf ; save interrupt flag
cli ; mask interrupt
ENDIF
call selbank
call data_move
call unselbank
IFDEF FMR70
popf ; restore interrupt flag
ENDIF
trap18h_exit:
push dx
cmp ah, 9 ; 文字読込でなければ,無視
jne kb_thru
mov ah, 3 ; コード系読取
int 90h
test dh, 0c0h ; スキャンモードであれば,無視
jne kb_thru
pop dx
pop ax
push ax
pushf
call dword ptr cs:int18h_entry
test bl, 00010000b ; CTRL?
jz kbtrap9
test bl, 01101000b ; other bits except SHIFT ON?
jnz kbtrap9 ; Yes, skip
mov al, bh
mov ah, 3
cmp al, cs:paste_key
je short kbtrap3
test bl, 00000100b ; SHIFT bit ON?
jnz kbtrap9 ; Yes, skip
mov ah, 0
cmp al, cs:current_key
je short kbtrap3
mov ah, 1
cmp al, cs:bottom_key
je short kbtrap3
mov ah, 6
cmp al, cs:disable_key
jne short kbtrap9
kbtrap3:
mov cs:shift_status, bl ; save shift status
int XSERV_INT
pop ax
jmp trap18h_entry
kbtrap9:
add sp, 2 ; dummy pop for ax
iret
;
kb_thru:
pop dx
pop ax
jmp dword ptr cs:int18h_entry
ELSE
sti
cmp cs:cutbuf_cnt, 0
jz trap18h_exit
cmp ah, 1 ; KB read or sense or other ?
ja trap18h_exit
push es
mov es, cs:sys_seg
cmp byte ptr es:[KBUF_CNT], 0
pop es
jnz trap18h_exit
test ah, ah
jz trap18h1
cmp cs:kb_sense_cnt, 0 ; KB sense.
jz trap18h1
dec cs:kb_sense_cnt
jmp short trap18h_exit
trap18h1:
mov cs:kb_sense_cnt, 1
call selbank
call data_move
call unselbank
trap18h_exit:
jmp dword ptr cs:int18h_entry
ENDIF
;
data_move:
push ax
push si
push di
push ds
IFNDEF FMR
push es
ENDIF
mov ds, cs:txtbuf_seg
IFNDEF FMR
mov es, cs:sys_seg
ENDIF
mov si, cs:cutbuf_ptr
sub ax, ax
cld
mov al, cs:this_line_hc
cmp al, 0
je dtmove1
IFNDEF FMR
cmp byte ptr es:[KBUF_CNT], KBUF_SIZ
jae dtmove9
ENDIF
call putchar
IFDEF FMR
jne dtmove9 ; error ?
ENDIF
mov cs:this_paste_hc, al
mov cs:this_line_hc, 0
; inc cs:cutbuf_cnt
; jmp short dtmove3
dtmove1:
IFNDEF FMR
cmp byte ptr es:[KBUF_CNT], KBUF_SIZ
jae dtmove9
ENDIF
lodsb
dtmove3:
call putchar
IFDEF FMR
jne dtmove9 ; error ?
ENDIF
mov cs:cutbuf_ptr, si
dec cs:cutbuf_cnt
jz dtmove9
cmp al, CR
jne dtmove1
mov al, cs:this_paste_hc
mov cs:this_line_hc, al
dtmove9:
IFNDEF FMR
pop es
ENDIF
pop ds
pop di
pop si
pop ax
ret
;
putchar:
cmp ax, TAB_CHAR
je putch0_0
cmp ax, NTAB_CHAR
jne putch0
cmp cs:lastpaste, TAB
je putch2
putch0_0:
mov ax, TAB
putch0:
mov cs:lastpaste, al
IFDEF FMR
push cx
push ds
mov cs:kb_sense_cnt, ax ; save character
mov ah, 0bh ; 入力文字列の追加
mov al, 1 ; バッファの最後に追加
mov cx, 1 ; 1文字
mov di, cs
mov ds, di
mov di, offset kb_sense_cnt
int 90h
IFDEF FMR70
call refbank
ENDIF
pop ds
pop cx
test ah, ah ; if error, return not ZERO
mov ax, cs:kb_sense_cnt ; restore character
putch2:
ELSE
cli
cmp byte ptr es:[KBUF_CNT], KBUF_SIZ
jae putch2
mov di, es:[KBUF_WPTR] ; write pointer.
stosw
cmp di, KBUF_END
jb putch1
mov di, KBUF_BGN
putch1:
mov es:[KBUF_WPTR], di
inc byte ptr es:[KBUF_CNT]
putch2:
sti
ENDIF
ret
;---------------------------------------;
; int 29h trap routine ;
;---------------------------------------;
public trap29h_entry
trap29h_entry:
call cs:proc_addr
jmp dword ptr cs:int29h_entry
;
trap29h_thru:
cmp al, ESCAPE
je thru1
cmp al, CR
jne thru0
call show_thru_flag
thru0:
ret
thru1:
mov cs:proc_addr, offset trap29h_thru2
ret
;
trap29h_thru2:
cmp al, '1'
je thru2_1
mov cs:proc_addr, offset trap29h_thru
ret
thru2_1:
mov cs:proc_addr, offset trap29h_normal
call clear_thru_flag
ret
;
trap29h_normal:
push es
push di
push cx
IFDEF FMR
IFDEF FMR70
pushf ; save interrupt flag
cli ; mask interrupt
ENDIF
ENDIF
push ax
call selbank ; select trascript bank
mov es, cs:txtbuf_seg
mov di, cs:write_ptr
pop ax
push ax
cld
cmp al, ' '
jae trap29h5
cmp al, CR
je trap29h9
cmp al, BS
jne trap29h1
dec di
jmp short trap29h7
trap29h1:
cmp al, TAB
jne trap29h2
mov ax, di
sub ax, cs:str_top
and ax, 7
mov cx, 8
sub cx, ax
mov al, TAB_CHAR ; '->'
trap29hA:
stosb
cmp cs:read_ptr, di
jnz trap29hB
inc word ptr cs:read_ptr
trap29hB:
mov al, NTAB_CHAR
loop trap29hA
jmp short trap29h7
trap29h2:
cmp al, LF
jne trap29h3
mov al, CR
stosb
mov cs:str_top, di
jmp short trap29h7
trap29h3:
cmp al, FS
jne trap29h4
inc di
jmp short trap29h7
trap29h4:
cmp al, ESCAPE
jne trap29h9
mov cs:proc_addr, offset esc_proc
jmp short trap29h9
trap29h5:
stosb ; save character
trap29h7:
mov ax, di
sub ax, cs:str_top
cmp ax, COLUMN_WIDTH*20
jne trap29h8
mov al, CR
stosb
mov cs:str_top, di
trap29h8:
mov cs:write_ptr, di
cmp cs:read_ptr, di
jne trap29h9
mov cx, COLUMN_WIDTH
mov al, CR
repne scasb
mov cs:read_ptr, di
trap29h9:
call unselbank ; select normal bank
pop ax
IFDEF FMR
IFDEF FMR70
popf ; restore interrupt flag
ENDIF
ENDIF
pop cx
pop di
pop es
ret
;---------------------------------------;
; escape sequence procedure ;
;---------------------------------------;
esc_proc:
cmp al, '['
jne esc_proc1
mov cs:proc_addr, offset esc_proc6
ret
esc_proc1:
cmp al, '='
jne esc_proc2
mov cs:proc_addr, offset esc_proc3
ret
esc_proc2:
cmp al, ')'
jne esc_proc4
esc_proc3:
mov cs:proc_addr, offset esc_proc5
ret
esc_proc4:
cmp al, '0'
jne esc_proc5
mov cs:proc_addr, offset trap29h_thru
call show_thru_flag
ret
esc_proc5:
mov cs:proc_addr, offset trap29h_normal
ret
;
esc_proc6: ; '['
cmp al, 'A'
jb esc_proc7
cmp al, 'Z'
jbe esc_proc5
cmp al, 'a'
jb esc_proc7
cmp al, 'z'
jbe esc_proc5
esc_proc7:
ret
;=======================================;
; Transcript Service Entry ;
; In : AH = function code ;
;=======================================;
public xservice_entry
xservice_entry:
cmp cs:busy_flag, OFF
je xserv_ok
iret
xserv_ok:
mov cs:user_ax, ax ; レジスターの保存
mov cs:user_bx, bx
mov cs:user_cx, cx
mov cs:user_dx, dx
mov cs:user_si, si
mov cs:user_di, di
mov cs:user_bp, bp
mov cs:user_sp, sp
mov cs:user_ds, ds
mov cs:user_es, es
mov cs:user_ss, ss ;
mov ax, cs
mov ss, ax
mov sp, offset stack_top ; スタックの切り換え
IFDEF FMR
call clear_keybuf
ELSE
sub ax, ax
mov es, ax
mov word ptr es:[KBUF_RPTR], KBUF_BGN
mov word ptr es:[KBUF_WPTR], KBUF_BGN
mov byte ptr es:[KBUF_CNT], 0
ENDIF
mov cs:busy_flag, ON
mov cs:cutbuf_cnt, 0
sti
mov ax, cs:user_ax
cmp ah, FUNC_MAX
ja xserv_bad_func
sub bx, bx
mov bl, ah
add bx, bx
call word ptr cs:jump_tbl[bx] ; call each function.
xserv_bad_func:
cli
mov ax, cs:user_ax ; レジスターの回復
mov bx, cs:user_bx
mov cx, cs:user_cx
mov dx, cs:user_dx
mov si, cs:user_si
mov di, cs:user_di
mov bp, cs:user_bp
mov sp, cs:user_sp
mov ds, cs:user_ds
mov es, cs:user_es
mov ss, cs:user_ss ;
mov cs:busy_flag, OFF
iret
;
jump_tbl dw offset xserv0
dw offset xserv1
dw offset xserv2
dw offset xserv3
dw offset xserv4
dw offset xserv5
dw offset xserv6
dw offset xserv7
;
xserv2:
xserv4:
xserv5:
ret
;---------------------------------------;
; 透過/非透過モードの設定 ;
;---------------------------------------;
xserv6:
; mov es, cs:tvram_seg
cmp cs:proc_addr, offset trap29h_thru
je xserv6_1
mov cs:proc_addr, offset trap29h_thru
; mov byte ptr es:[COLUMN_WIDTH*24*2], '!'
call show_thru_flag
ret
xserv6_1:
mov cs:proc_addr, offset trap29h_normal
; mov byte ptr es:[COLUMN_WIDTH*24*2], ' '
call clear_thru_flag
ret
;---------------------------------------;
; transcriptバッファの読み出し ;
;---------------------------------------;
xserv7:
IFDEF FMR
IFDEF FMR70
pushf ; save interrupt flag
cli ; mask interrupt
ENDIF
ENDIF
call selbank ; select transcript bank
mov ds, cs:txtbuf_seg
mov cs:user_ax, 0
mov es, cs:user_ds
mov di, cs:user_dx
mov cx, cs:user_cx
mov ax, cs:cutbuf_cnt_save ; test cut region length
test ax, ax
jz xserv7_01 ; save all buffer
mov si, cs:cutbuf_bgn
jmp short xserv7_02
xserv7_01:
mov si, cs:read_ptr
mov ax, cs:write_ptr
sub ax, si
xserv7_02:
sub ax, cs:user_bx
jbe xserv7_2
add si, cs:user_bx
cmp ax, cx
jae xserv7_1
mov cx, ax
xserv7_1:
mov cs:user_ax, cx
cld
rep movsb
; ret
xserv7_2:
call unselbank ; select normal bank
IFDEF FMR
IFDEF FMR70
popf ; restore interrupt flag
ENDIF
ENDIF
ret
;---------------------------------------;
; カット領域のペースト ;
;---------------------------------------;
xserv3:
IFNDEF FMR
call check_ISR
jnz xserv3_9
ENDIF
IFDEF FMR
mov al, cs:shift_status
shr al, 1 ; move SHIFT bit to LSB
shr al, 1
ELSE
mov es, cs:sys_seg
mov al, byte ptr es:[SHIFT_STTS]
ENDIF
and al, 1
xor al, cs:always_paste
jz xserv3_1
mov al, cs:header_char
xserv3_1:
mov cs:this_line_hc, al
mov cs:this_paste_hc, 0
mov ax, cs:cutbuf_bgn
mov cs:cutbuf_ptr, ax
mov ax, cs:cutbuf_cnt_save
mov cs:cutbuf_cnt, ax
xserv3_9:
ret
;---------------------------------------;
; transcript画面の表示 ;
;---------------------------------------;
xserv0:
xserv1:
IFNDEF FMR
call check_ISR
jnz xserv0_9 ; other interrupt in-service.
ENDIF
IFDEF FMR
IFDEF FMR70
pushf ; save interrupt flag
cli ; mask interrupt
ENDIF
ENDIF
call selbank ; select GVRAM 1
call save_screen
call xserv_main
call restore_screen
call unselbank ; select GVRAM 0
IFDEF FMR
IFDEF FMR70
popf ; restore interrupt flag
ENDIF
ENDIF
xserv0_9:
ret
;
IFNDEF FMR
check_ISR:
mov al, 00001011b
out 00h, al
in al, 00h ; read ISR of master PIC
test al, 11111101b ; other interrupt in-service ?
ret
ENDIF
;---------------------------------------;
; transcript service main ;
;---------------------------------------;
xserv_main:
mov ds, cs:txtbuf_seg
mov es, cs:tvram_seg
mov cs:mark_flag, OFF
call find_last_page
cmp cs:access_flag, ON
jne xmain0
mov ax, cs:user_ax
cmp ah, 1
je xmain0
mov si, cs:page_top ; ゼンカイト オナジ イチノ ヒョウジ
jmp short xmain1
xmain0:
mov cs:access_flag, ON
mov ax, cs:bottom_curs_row
mov cs:curs_pos_row, ax
mov cs:curs_pos_col, 0
mov cs:curs_pos_col_s, 0
xmain1:
call disp_one_screen ; display one screen.
call adjust_curs_pos
call disp_cursor ; set cursor at the scroll region.
mov cs:exit_flag, OFF
xmain2:
call getchar ; get 1 character.
call clear_keybuf
call bifurcation
cmp cs:exit_flag, ON
jne xmain2
ret
;---------------------------------------;
; bifurcation table ;
; offset description ;
; 0 scan code ;
; 1 character code 1 ;
; 2 character code 2 ;
; 3 character code 3 ;
; 4 function offset ;
;---------------------------------------;
bifur_tbl label byte
IFDEF FMR
db PF6_KEY, -1, -1, -1
dw offset prev_page
db PF7_KEY, -1, -1, -1
dw offset next_page
db PF10_KEY, -1, -1, -1
dw offset set_mark
db ENTER, -1, -1, -1
dw offset cut_region
ENDIF
db UP_ARROW, 'E', 'e', CTRL_E
dw offset cursor_up
db LEFT_ARROW, 'S', 's', CTRL_S
dw offset cursor_left
db RIGHT_ARROW, 'D', 'd', CTRL_D
dw offset cursor_right
db DOWN_ARROW, 'X', 'x', CTRL_X
dw offset cursor_down
db -1, 'A', 'a', -1
dw offset cursor_prev_word
db -1, 'F', 'f', -1
dw offset cursor_next_word
db -1, -1, -1, CTRL_A
dw offset cursor_left_end
db -1, -1, -1, CTRL_F
dw offset cursor_right_end
IFDEF FMR
db ROLL_UP, 'Z', 'z', CTRL_Z
dw offset scroll_up
db ROLL_DOWN, 'W', 'w', CTRL_W
dw offset scroll_down
db -1, 'R', 'r', CTRL_R
dw offset prev_page
db -1, 'C', 'c', CTRL_C
dw offset next_page
ELSE
db -1, 'Z', 'z', CTRL_Z
dw offset scroll_up
db -1, 'W', 'w', CTRL_W
dw offset scroll_down
db ROLL_DOWN, 'R', 'r', CTRL_R
dw offset prev_page
db ROLL_UP, 'C', 'c', CTRL_C
dw offset next_page
ENDIF
db -1, 'B', 'b', -1
dw offset buf_bottom
db -1, 'T', 't', -1
dw offset buf_top
db -1, -1, -1, CTRL_T
dw offset to_page_top
db -1, -1, -1, CTRL_B
dw offset to_page_bottom
db INS, 'M', 'm', -1
dw offset set_mark
db DEL, 'O', 'o', -1
dw offset cut_region
db CR_KEY, 'P', 'p', CTRL_P
dw offset copy_region
IFDEF FMR
db HOME, -1, -1, 1Dh
dw offset show_help
ENDIF
db -1, -1, -1, CTRL_K
dw offset cut_to_eol
db -1, -1, -1, CTRL_U
dw offset cut_to_bol
db -1, 'K', 'k', -1
dw offset copy_to_eol
db -1, 'U', 'u', -1
dw offset copy_to_bol
db -1, '/', -1, -1
dw offset forw_search
db -1, '?', -1, -1
dw offset back_search
db -1, 'N', 'n', -1
dw offset forw_next
db -1, -1, -1, CTRL_N
dw offset back_next
db -1, 'L', 'l', -1
dw offset set_label
db -1, "'", -1, -1
dw offset goto_label
db -1, '>', ':', '-'
dw offset header_set
IFDEF FMR
db -1, -1, -1, ESCAPE
dw offset exit
ELSE
db HOME, -1, -1, ESCAPE
dw offset exit
db HELP, -1, -1, 1Dh
dw offset show_help
ENDIF
db 0, 0, 0, 0
dw 0
;---------------------------------------;
; ファンクションの分岐 ;
; In : AH = Keyboard scan code ;
; AL = character code ;
;---------------------------------------;
bifurcation:
;ifdef FMR
; mov cx, 29 ; added PF6, PF7, PF10 and ENTER
;else
; mov cx, 25
;endif
mov bx, offset bifur_tbl
bifur1:
cmp ah, cs:[bx]
je bifur2
cmp al, cs:[bx+1]
je bifur2
cmp al, cs:[bx+2]
je bifur2
cmp al, cs:[bx+3]
je bifur2
add bx, 6
cmp word ptr cs:[bx+4], 0 ; end of function ?
jne bifur1
ret
bifur2:
call word ptr cs:[bx+4]
ret
;---------------------------------------;
; 疑似カーソルを1行上に ;
;---------------------------------------;
cursor_up:
mov ax, cs:curr_line_top
cmp ax, cs:read_ptr
je curs_up9
cmp cs:curs_pos_row, 0
jne curs_up0
jmp scroll_down
curs_up0:
call clear_cursor
dec cs:curs_pos_row
call adjust_curs_pos
call reverse_region
call disp_cursor
curs_up9:
ret
;---------------------------------------;
; 疑似カーソルを1文字左に ;
;---------------------------------------;
cursor_left:
mov ax, cs:current_ptr
cmp ax, cs:read_ptr
je curs_l9
mov ax, cs:curs_pos_col
mov cs:curs_pos_col_s, ax
call clear_cursor
cmp cs:curs_pos_col_s, 0
jne curs_l1
call cursor_up
call cursor_right_end
ret
curs_l1:
dec cs:curs_pos_col_s
call adjust_curs_pos
call reverse_region
call disp_cursor
curs_l9:
ret
;---------------------------------------;
; 疑似カーソルを1文字右に ;
;---------------------------------------;
cursor_right:
mov ax, cs:current_ptr
cmp ax, cs:txtbuf_end
je curs_r9
mov ax, cs:curs_pos_col
mov cs:curs_pos_col_s, ax
cmp ax, cs:curr_line_leng
jb curs_r2
call cursor_down
call cursor_left_end
ret
curs_r2:
call clear_cursor
inc cs:curs_pos_col_s
call adjust_curs_pos
call reverse_region
call disp_cursor
curs_r9:
ret
;---------------------------------------;
; 疑似カーソルを1行下に ;
;---------------------------------------;
cursor_down:
mov ax, cs:curr_line_top
cmp ax, cs:txtbuf_end
je curs_dn9
cmp cs:curs_pos_row, ROW_WIDTH - 1
jnae curs_dn0
jmp scroll_up
curs_dn0:
call clear_cursor
inc cs:curs_pos_row
call adjust_curs_pos
call reverse_region
call disp_cursor
curs_dn9:
ret
;---------------------------------------;
; 疑似カーソルを前の単語に ;
;---------------------------------------;
cursor_prev_word:
mov ax, cs:current_ptr
cmp ax, cs:read_ptr
je curs_pw9
curs_pw1:
call cursor_left
mov bx, cs:current_ptr
cmp bx, cs:read_ptr
je curs_pw9
cmp byte ptr [bx], ' '
jbe curs_pw1
curs_pw2:
cmp byte ptr [bx-1], ' '
jbe curs_pw9
call cursor_left
mov bx, cs:current_ptr
cmp bx, cs:read_ptr
jne curs_pw2
curs_pw9:
ret
;---------------------------------------;
; 疑似カーソルを次の単語に ;
;---------------------------------------;
cursor_next_word:
mov bx, cs:current_ptr
cmp bx, cs:txtbuf_end
je curs_nw9
cmp byte ptr [bx], ' '
jbe curs_nw2
curs_nw1:
call cursor_right
mov bx, cs:current_ptr
cmp bx, cs:txtbuf_end
je curs_nw9
cmp byte ptr [bx], ' '
ja curs_nw1
curs_nw2:
call cursor_right
mov bx, cs:current_ptr
cmp bx, cs:txtbuf_end
je curs_nw9
cmp byte ptr [bx], ' '
jbe curs_nw2
curs_nw9:
ret
;---------------------------------------;
; 疑似カーソルを行頭に ;
;---------------------------------------;
cursor_left_end:
call clear_cursor
mov cs:curs_pos_col_s, 0
call adjust_curs_pos
call reverse_region
call disp_cursor
ret
;---------------------------------------;
; 疑似カーソルを行末に ;
;---------------------------------------;
cursor_right_end:
call clear_cursor
mov ax, cs:curr_line_leng
mov cs:curs_pos_col_s, ax
call adjust_curs_pos
call reverse_region
call disp_cursor
ret
;---------------------------------------;
; 画面を1行スクロールアップ ;
;---------------------------------------;
scroll_up:
mov ax, cs:last_page_top
cmp ax, cs:page_top
jne scrl_up0
jmp cursor_down
scrl_up0:
mov si, cs:page_bottom
call clear_cursor
call make_room_bottom
mov ax, ROW_WIDTH - 1 ; row position.
call disp_one_line ; display one line.
mov cs:page_bottom, si
call adjust_curs_pos
mov ax, cs:old_curs_pos
sub ax, COLUMN_WIDTH*2
ja scrl_up2
mov ax, 0
scrl_up2:
mov cs:old_curs_pos, ax
call clear_region
call draw_region
call disp_cursor
ret
;---------------------------------------;
; 画面を1行スクロールダウン ;
;---------------------------------------;
scroll_down:
mov si, cs:page_top
cmp si, cs:read_ptr
jne scrl_dn0
jmp cursor_up
scrl_dn0:
call clear_cursor
call make_room_top
call find_prev_line ; top of previous line.
mov ax, 0 ; row position.
call disp_one_line ; display one line.
call adjust_curs_pos
mov ax, cs:old_curs_pos
add ax, COLUMN_WIDTH*2
cmp ax, ROW_WIDTH*COLUMN_WIDTH*2
jb scrl_dn1
mov ax, ROW_WIDTH*COLUMN_WIDTH*2
scrl_dn1:
mov cs:old_curs_pos, ax
call clear_region
call draw_region
call disp_cursor
ret
;---------------------------------------;
; 前ページの画面を表示 ;
;---------------------------------------;
prev_page:
mov si, cs:page_top
cmp si, cs:read_ptr
jne prev_pg0
jmp to_page_top
prev_pg0:
call find_prev_page
call disp_one_screen
call adjust_curs_pos
call draw_region
call disp_cursor
ret
;---------------------------------------;
; 次ページの画面を表示 ;
;---------------------------------------;
next_page:
mov ax, cs:last_page_top
cmp ax, cs:page_top
jne next_pg0
mov cx, ROW_WIDTH - 1
next_pg00:
push cx
call cursor_down
pop cx
loop next_pg00
ret
next_pg0:
; mov si, cs:page_bottom
mov si, cs:line_top[(ROW_WIDTH-1)*2]
mov bx, si
sub ax, cs:read_ptr
sub bx, cs:read_ptr
cmp bx, ax ; page_bottom < last_page_top ?
jb next_pg1
mov si, cs:last_page_top
next_pg1:
call disp_one_screen
call adjust_curs_pos
call draw_region
call disp_cursor
ret
;---------------------------------------;
; テキストバッファの最後尾へ ;
;---------------------------------------;
buf_bottom:
mov si, cs:last_page_top
call disp_one_screen
mov ax, cs:bottom_curs_row
mov cs:curs_pos_row, ax
mov cs:curs_pos_col_s, 0
call adjust_curs_pos
call draw_region
call disp_cursor
ret
;---------------------------------------;
; テキストバッファの先頭へ ;
;---------------------------------------;
buf_top:
mov si, cs:read_ptr
call disp_one_screen
mov cs:curs_pos_row, 0
mov cs:curs_pos_col_s, 0
call adjust_curs_pos
call draw_region
call disp_cursor
ret
;---------------------------------------;
; 表示画面の先頭へ ;
;---------------------------------------;
to_page_top:
call clear_cursor
mov cs:curs_pos_row, 0
mov cs:curs_pos_col_s, 0
call adjust_curs_pos
call reverse_region
call disp_cursor
ret
;---------------------------------------;
; 表示画面の最後尾へ ;
;---------------------------------------;
to_page_bottom:
call clear_cursor
mov ax, cs:bottom_curs_row
mov cs:curs_pos_row, ax
add ax, ax
mov bx, ax
mov ax, cs:line_top[bx+2]
sub ax, cs:line_top[bx]
jz to_page_bot1
dec ax
to_page_bot1:
mov cs:curs_pos_col_s, ax
call adjust_curs_pos
call reverse_region
call disp_cursor
ret
;---------------------------------------;
; 領域マークを設定する ;
;---------------------------------------;
set_mark:
mov ax, cs:current_ptr
mov cs:mark_ptr, ax
not cs:mark_flag
mov cx, COLUMN_WIDTH*ROW_WIDTH
mov di, 0
set_mk1:
IFDEF FMR
IFDEF FMR70
mov word ptr es:[di+ATTR_OFF], ATR_WHITE
cmp word ptr es:[di], EOL_CHAR
je set_mk2
cmp word ptr es:[di], '~'
jne set_mk3
set_mk2:
mov word ptr es:[di+ATTR_OFF], ATR_CYAN
ELSE
mov al, es:[di+1]
and al, ATR_KANJI_1 or ATR_KANJI_2 ; reserve kanji attr.
or al, ATR_WHITE
mov byte ptr es:[di+1], al
cmp byte ptr es:[di], EOL_CHAR
je set_mk2
cmp byte ptr es:[di], '~'
jne set_mk3
test byte ptr es:[di-1], ATR_KANJI_1 or ATR_KANJI_2 ; check kanji
jne set_mk3
set_mk2:
mov byte ptr es:[di+1], ATR_CYAN
ENDIF
ELSE
mov word ptr es:[di+ATTR_OFF], ATR_WHITE
cmp word ptr es:[di], EOL_CHAR
je set_mk2
cmp word ptr es:[di], '~'
jne set_mk3
set_mk2:
mov word ptr es:[di+ATTR_OFF], ATR_CYAN
ENDIF
set_mk3:
add di, 2
loop set_mk1
call disp_cursor
ret
;---------------------------------------;
; 領域をカットする ;
;(実際には領域の先頭位置と大きさだけ) ;
;---------------------------------------;
cut_region:
cmp cs:mark_flag, ON
je cut_reg5
mov di, cs:current_ptr
cmp byte ptr [di], 20h
jbe cut_reg2
cut_reg1:
cmp di, cs:read_ptr
je cut_reg2
dec di
cmp byte ptr [di], 20h
ja cut_reg1
inc di
cut_reg2:
mov cs:cutbuf_bgn, di
cut_reg3:
cmp byte ptr [di], 20h
jbe cut_reg4
inc di
jmp short cut_reg3
cut_reg4:
sub di, cs:cutbuf_bgn
mov cs:cutbuf_cnt_save, di
jmp short cut_reg7
;
cut_reg5:
mov ax, cs:current_ptr
mov bx, cs:mark_ptr
sub ax, cs:read_ptr
sub bx, cs:read_ptr
sub ax, bx
jae cut_reg6
mov ax, cs:current_ptr
xchg ax, cs:mark_ptr
sub ax, cs:mark_ptr
cut_reg6:
mov cs:cutbuf_cnt_save, ax
mov ax, cs:mark_ptr
mov cs:cutbuf_bgn, ax
cut_reg7:
call x_exit
ret
;---------------------------------------;
; 領域のコピー ;
; (実際には、領域の位置と ;
; 大きさを指定するだけ) ;
;---------------------------------------;
copy_region:
call cut_region
IFDEF FMR
mov al, cs:shift_status
shr al, 1 ; move SHIFT bit to LSB
shr al, 1
ELSE
push es
mov es, cs:sys_seg
mov al, byte ptr es:[SHIFT_STTS]
pop es
ENDIF
and al, 1 ; shift ?
xor al, cs:always_paste
jz copy_reg1
mov al, cs:header_char
copy_reg1:
mov cs:this_line_hc, al
mov cs:this_paste_hc, 0
mov ax, cs:cutbuf_bgn
mov cs:cutbuf_ptr, ax
mov ax, cs:cutbuf_cnt_save
mov cs:cutbuf_cnt, ax
test ax, ax
jz copy_reg8
call data_move
copy_reg8:
ret
;-----------------------------------------------;
; カーソル位置から行末までをカット ;
;-----------------------------------------------;
cut_to_eol:
mov cs:mark_flag, OFF
call set_mark
call cursor_right_end
call cut_region
ret
;-----------------------------------------------;
; カーソル位置から行末までをコピー ;
;-----------------------------------------------;
cut_to_bol:
mov cs:mark_flag, OFF
call set_mark
call cursor_left_end
call cut_region
ret
;-----------------------------------------------;
; カーソル位置から行頭までをカット ;
;-----------------------------------------------;
copy_to_eol:
mov cs:mark_flag, OFF
call set_mark
call cursor_right_end
call copy_region
ret
;-----------------------------------------------;
; カーソル位置から行頭までをコピー ;
;-----------------------------------------------;
copy_to_bol:
mov cs:mark_flag, OFF
call set_mark
call cursor_left_end
call copy_region
ret
; Following search routines from
; Ver. 1.48eC1 by Appne / Feb. 20, 1989.
;---------------------------------------;
; 文字列を前方に検索 ;
;---------------------------------------;
forw_search:
push es
xor ax, ax
mov es, ax
; test byte ptr es:[SHIFT_STTS], 1
pop es
; jnz back_search
mov bx, ROW_WIDTH
; mov bx, word ptr cs:row_width_0
mov cx, WORK_BOX_COL
mov ax, offset white_str
call putstr
inc cx
mov ax, '/'
call putchr
inc cx
call getstr
cmp al, CTRL_C ; 中止?
jne forw_srch1
mov cx, WORK_BOX_COL
mov ax, offset break_msg
call putstr
ret
forw_srch1:
mov cs:case_sensitive, OFF
cmp al, CTRL_J
jne forw_next
mov cs:case_sensitive, ON
forw_next:
mov cs:search_dir, 1 ; forward search
mov ax, cs:txtbuf_end
dec ax
mov cs:search_end, ax
jmp short next_search
;---------------------------------------;
; 文字列を後方に検索 ;
;---------------------------------------;
back_search:
mov bx, ROW_WIDTH
; mov bx, word ptr cs:row_width_0
mov cx, WORK_BOX_COL
mov ax, offset white_str
call putstr
inc cx
mov ax, '?'
call putchr
inc cx
call getstr
cmp al, CTRL_C ; 中止?
jne back_srch1
mov cx, WORK_BOX_COL
mov ax, offset break_msg
call putstr
ret
back_srch1:
mov cs:case_sensitive, OFF
cmp al, CTRL_J
jne back_next
mov cs:case_sensitive, ON
back_next:
mov cs:search_dir, -1 ; backward search
mov ax, cs:read_ptr
mov cs:search_end, ax
; jmp short next_search
;---------------------------------------;
; 文字列をさらに検索 ;
;---------------------------------------;
next_search:
mov ax, offset search_msg
mov bx, ROW_WIDTH
; mov bx, word ptr cs:row_width_0
mov cx, WORK_BOX_COL
call putstr
cld
mov bx, cs:current_ptr
mov dx, offset str_buf
push es
push cs
pop es
cmp cs:search_dir, 1
jnz next_s1
cmp bx, cs:txtbuf_end
jnz next_s1
next_s09:
jmp next_s9
next_s1:
cmp bx, cs:search_end
je next_s09
add bx, cs:search_dir
mov cx, cs:str_len
mov si, bx
mov di, dx
next_s2:
lodsb
cmp al, es:[di]
je next_s4
cmp cs:case_sensitive, ON
je next_s1
cmp al, 'A'
jb next_s1
cmp al, 'Z'
ja next_s3
add al, 20h
cmp al, es:[di]
jne next_s1
jmp short next_s4
next_s3:
cmp al, 'a'
jb next_s1
cmp al, 'z'
ja next_s1
sub al, 20h
cmp al, es:[di]
jne next_s1
next_s4:
inc di
loop next_s2
;
pop es
mov cs:current_ptr, bx
call clear_cursor
call calc_curs_pos
jz next_s5
mov si, cs:current_ptr
; call find_prev_str
; call find_prev_str
; call find_prev_str
; call find_prev_str
; call find_prev_str
mov ax, word ptr cs:row_width_1
dec ax
jz next_s4_4
dec ax
jz next_s4_3
dec ax
jz next_s4_2
dec ax
jz next_s4_1
call find_prev_line
next_s4_1:
call find_prev_line
next_s4_2:
call find_prev_line
next_s4_3:
call find_prev_line
next_s4_4:
call find_prev_line
call disp_one_screen
call calc_curs_pos
next_s5:
call adjust_curs_pos
call clear_region
call draw_region
; call reverse_region
call disp_cursor
mov ax, offset found_msg
mov bx, ROW_WIDTH
; mov bx, word ptr cs:row_width_0
mov cx, WORK_BOX_COL
call putstr
ret
;
next_s9:
pop es
mov ax, offset nfound_msg
mov bx, ROW_WIDTH
; mov bx, word ptr cs:row_width_0
mov cx, WORK_BOX_COL
call putstr
ret
;---------------------------------------;
; ジャンプラベルの設定 ;
;---------------------------------------;
set_label:
mov ax, offset label_msg
mov bx, ROW_WIDTH
; mov bx, word ptr cs:row_width_0
mov cx, WORK_BOX_COL
call putstr
IFNDEF FMR
mov byte ptr cs:getchar_flag, ON
ENDIF
set_label_1:
call getchar
IFDEF FMR
call clear_keybuf
ENDIF
cmp al, 7fh
jnc set_label_1
sub al, 20h
jc set_label_1
IFNDEF FMR
mov byte ptr cs:getchar_flag, OFF
ENDIF
cbw
add ax, ax
mov si, ax
mov ax, cs:current_ptr
mov cs:[si][offset label_table], ax
mov ax, offset clear_msg
call putstr
ret
;---------------------------------------;
; ラベル位置へジャンプ ;
;---------------------------------------;
goto_label:
mov ax, offset goto_msg
mov bx, ROW_WIDTH
; mov bx, word ptr cs:row_width_0
mov cx, WORK_BOX_COL
call putstr
IFNDEF FMR
mov byte ptr cs:getchar_flag, ON
ENDIF
goto_label_1:
call getchar
IFDEF FMR
call clear_keybuf
ENDIF
cmp al, 7fh
jnc goto_label_1
sub al, 20h
jc goto_label_1
IFNDEF FMR
mov byte ptr cs:getchar_flag, OFF
ENDIF
cbw
add ax, ax
mov si, ax
push si
mov ax, offset clear_msg
call putstr
pop si
mov si, cs:[si][offset label_table]
mov cs:current_ptr, si
call clear_cursor
call calc_curs_pos
jz goto_5
mov si, cs:current_ptr
mov ax, word ptr cs:row_width_1
dec ax
jz goto_4
dec ax
jz goto_3
dec ax
jz goto_2
dec ax
jz goto_1
call find_prev_line
goto_1:
call find_prev_line
goto_2:
call find_prev_line
goto_3:
call find_prev_line
goto_4:
call find_prev_line
call disp_one_screen
call calc_curs_pos
goto_5:
call adjust_curs_pos
call clear_region
call draw_region
call disp_cursor
ret
;-----------------------------;
; 引用記号の設定 ;
;-----------------------------;
header_set:
cmp cs:header_char,al
jne header_set1
mov al,0
header_set1:
mov cs:header_char,al
; call disp_header
ret
;---------------------------------------;
; 終了フラグのセット ;
;---------------------------------------;
exit:
mov cs:cutbuf_cnt_save, 0 ; clear cut region length
x_exit:
mov cs:exit_flag, ON
ret
;---------------------------------------;
; ヘルプ画面の表示 ;
;---------------------------------------;
show_help:
mov si, offset help_msg
call show_help_p
call getchar
call clear_keybuf
call show_help_p
call getchar
call clear_keybuf
call show_help_p
call getchar
call clear_keybuf
mov si, cs:page_top
call disp_one_screen
call draw_region
call disp_cursor
ret
;
show_help_p:
push si
call clr_screen
pop si
push ds
mov ax, cs
mov ds, ax
sub ax, ax
sub dx, dx
sub di, di
cld
help1:
lodsb
test al, al
jz help3
cmp al, CR
je help2
stosb
inc di ; to unchange 2nd byte
jmp short help1
help2:
add dx, COLUMN_WIDTH*2
mov di, dx
jmp short help1
help3:
pop ds
ret
help_msg label byte
IFDEF FMR
db ' <<< Transcript (Ver 1.4 ',VERSION,') Help >>>', CR
db CR
db ' CTRL+DOWN ARROW : enter transcript mode. previous cursor position', CR
db ' CTRL+UP ARROW : enter transcript mode. initial cursor position', CR
db ' CTRL+HOME : paste region', CR
db ' ESC, CTRL+[ : leave transcript mode', CR
db ' CTRL+CANCEL : enable / disable logging', CR
ELSE
db ' <<< Transcript (Ver 1.4) Help >>>', CR
db CR
db ' CTRL+HOME, CTRL+1 : enter transcript mode. previous cursor position', CR
db ' CTRL+UP ARROW, CTRL+2 : enter transcript mode. initial cursor position', CR
db ' CTRL+HELP, CTRL+4 : paste region', CR
db ' HOME, ESC, CTRL+[ : leave transcript mode', CR
db ' CTRL+BS : enable / disable logging', CR
ENDIF
db CR
db ' UP ARROW, E, e, CTRL+E : move cursor up', CR
db ' LEFT ARROW, S, s, CTRL+S : move cursor left', CR
db ' RIGHT ARROW, D, d, CTRL+D : move cursor right', CR
db ' DOWN ARROW, X, x, CTRL+X : move cursor down', CR
db ' A, a : move cursor previous word', CR
db ' F, f : move cursor next word', CR
db ' CTRL+A : move cursor begin of line', CR
db ' CTRL+F : move cursor end of line', CR
db CR
IFDEF FMR
db ' ROLL DOWN, W, w, CTRL+W : scroll down 1 line', CR
db ' ROLL UP , Z, z, CTRL+Z : scroll up 1 line', CR
db ' R, r, CTRL+R : show previous page', CR
db ' C, c, CTRL+C : show next page', CR
ELSE
db ' W, w, CTRL+W : scroll down 1 line', CR
db ' Z, z, CTRL+Z : scroll up 1 line', CR
db ' ROLL DOWN, R, r, CTRL+R : show previous page', CR
db ' ROLL UP , C, c, CTRL+C : show next page', CR
ENDIF
db CR
db '--hit any key--', 0
db CR
db ' T, t : jump to top of buffer', CR
db ' B, b : jump to bottom of buffer', CR
db ' CTRL+T : jump to top of page', CR
db ' CTRL+B : jump to bottom of page', CR
db CR
db ' INS, M, m : set region mark', CR
db CR
db ' DEL, O, o : cut yellow reverse region', CR
db ' CR, P, p, CTRL+P : copy yellow reverse region or 1 word', CR
db CR
db ' CTRL+K : cut to end of line', CR
db ' CTRL+U : cut to begin of line', CR
db ' K, k : copy to end of line', CR
db ' U, u : copy to begin of line', CR
db CR
db ' >, :, - : set paste header char',CR
db ' shift+(paste key) : paste with header char', CR
db CR
db '--hit any key--', 0
db CR
db ' /<string>CR(CTRL+J) : forward search for string', CR
db ' ?<string>CR(CTRL+J) : backward search for string', CR
db ' N, n : forward next search for string', CR
db ' CTRL+N : backward next search for string', CR
db CR
db ' L, l : label set', CR
db " ' : goto label", CR
db CR
IFDEF FMR
db ' HOME CTRL+] : show help message', CR
ELSE
db ' HELP, CTRL+] : show help message', CR
ENDIF
db CR
db '--hit any key--', 0
;=======================================;
; サブルーチン群 ;
;=======================================;
;---------------------------------------;
; 最新画面の範囲を求める ;
;---------------------------------------;
find_last_page:
mov si, cs:write_ptr
cmp byte ptr ds:[si-1], CR
je find_lp1
call find_prev_str
find_lp1:
mov cs:txtbuf_end, si
call find_prev_page
mov cs:last_page_top, si
mov cs:bottom_curs_row, ax
cmp si, cs:read_ptr
je find_lp2
call find_prev_line
find_lp2:
ret
;---------------------------------------;
; 1ページ前の画面の範囲を求める ;
; In : SI = txtbuf ptr ;
; Out: SI = prev page top ;
; AX = number of lines ;
;---------------------------------------;
find_prev_page:
push bx
push dx
sub bx, bx
find_pp1:
mov ax, si
call find_prev_str
sub ax, si
jz find_pp2
add ax, COLUMN_WIDTH - 1
sub dx, dx
mov cx, COLUMN_WIDTH
div cx
add bx, ax
cmp bx, ROW_WIDTH - 1
jb find_pp1
je find_pp2
mov dx, bx
mov bx, ROW_WIDTH - 1
sub dx, bx
mov ax, COLUMN_WIDTH
mul dx
add si, ax
find_pp2:
mov ax, bx
pop dx
pop bx
ret
;---------------------------------------;
; 1つ前の文字列の位置を求める ;
; In : SI = current position ;
; Out: SI ;
;---------------------------------------;
find_prev_str:
cmp si, cs:read_ptr
je find_ps2
find_ps1:
dec si
cmp si, cs:read_ptr
je find_ps2
cmp byte ptr ds:[si-1], CR
jne find_ps1
find_ps2:
ret
;---------------------------------------;
; 1つ前の行の先頭位置を求める ;
; In : SI = current position ;
; Out: SI ;
;---------------------------------------;
find_prev_line:
push ax
push cx
push dx
mov ax, si
mov dx, si
call find_prev_str
sub ax, si
jz find_pl1
mov si, dx
dec ax
sub dx, dx
mov cx, COLUMN_WIDTH
div cx
inc dx
sub si, dx
find_pl1:
pop dx
pop cx
pop ax
ret
;---------------------------------------;
; 1画面の表示 ;
; In : SI = pointer ;
;---------------------------------------;
disp_one_screen:
push ax
call clr_screen ; clear the screen.
mov cx, ROW_WIDTH
mov ax, 0
disp_s2:
call disp_one_line
inc ax
loop disp_s2
mov cs:page_bottom, si
pop ax
ret
;---------------------------------------;
; 1行の表示 ;
; In : AX = row position. ;
; SI = string offset. ;
; Out: SI = next string position. ;
;---------------------------------------;
disp_one_line:
push ax
push bx
push cx
mov bx, ax
add bx, bx
mov cs:line_top[bx], si
mov ah, COLUMN_WIDTH*2
mul ah
mov di, ax
mov cx, COLUMN_WIDTH
cld
cmp si, cs:txtbuf_end
jne disp_ln1
mov ax, '~'
jmp short disp_ln7
disp_ln1:
sub ax, ax
lodsb
test al, al
jz disp_ln8
cmp al, CR
je disp_ln6
cmp al, LF
je disp_ln1
cmp al, 081h
jb disp_ln5
cmp al, 0A0h
jb disp_ln4
cmp al, 0E0h
jb disp_ln5
cmp al, 0FCh
ja disp_ln5
disp_ln4:
loop dislp_ln4_1
dec si
jmp short disp_ln8
dislp_ln4_1:
mov ah, al
lodsb
call sjis_to_vjis
IFDEF FMR
IFDEF FMTOWNS
mov byte ptr es:[di], CODE_KANJI_1
mov es:[di+ATTR_OFF], ah
inc di
mov byte ptr es:[di], ATR_KANJI_1 or ATR_WHITE
mov es:[di+ATTR_OFF], al
inc di
mov byte ptr es:[di], CODE_KANJI_1
mov byte ptr es:[di+ATTR_OFF], 21h ; NOT ah
inc di
mov byte ptr es:[di], ATR_KANJI_2 or ATR_WHITE
mov byte ptr es:[di+ATTR_OFF], 21h ; NOT al
inc di
jmp short disp_ln51
ELSE
IFDEF FMR50
mov byte ptr es:[di], CODE_KANJI_1
mov es:[di+ATTR_OFF], ah
inc di
mov byte ptr es:[di], ATR_KANJI_1 or ATR_WHITE
mov es:[di+ATTR_OFF], al
inc di
mov byte ptr es:[di], CODE_KANJI_1
mov es:[di+ATTR_OFF], ah
inc di
mov byte ptr es:[di], ATR_KANJI_2 or ATR_WHITE
mov es:[di+ATTR_OFF], al
inc di
jmp short disp_ln51
ELSE
cmp ah, 75h ; gaiji character ?
je disp_ln4_2
cmp ah, 76h ; gaiji character ?
je disp_ln4_2
add ah, 80h ; normal JIS kanji
jmp short disp_ln4_3
disp_ln4_2:
sub ah, 35h ; adjust gaiji CG code
disp_ln4_3:
stosw
add al, 80h
ENDIF
ENDIF
ELSE
sub ax, 2000h
xchg al, ah
stosw
add al, 80h
ENDIF
disp_ln5:
IFDEF FMR
IFDEF FMR70
stosw
ELSE
stosb
inc di
disp_ln51:
ENDIF
ELSE
stosw
ENDIF
loop disp_ln1
jmp short disp_ln8
disp_ln6:
mov al, EOL_CHAR ; down arrow.
disp_ln7:
IFDEF FMR
IFDEF FMR70
mov es:[di], ax
ELSE
mov byte ptr es:[di], al
mov byte ptr es:[di+1], ATR_CYAN
ENDIF
ELSE
mov es:[di], ax
ENDIF
IFDEF FMR
IFDEF FMR70
and word ptr es:[di+ATTR_OFF], 11111101b ; light blue
ENDIF
ELSE
and byte ptr es:[di+ATTR_OFF], 10111111b ; light blue
ENDIF
disp_ln8:
pop cx
pop bx
pop ax
ret
;---------------------------------------;
; 画面の消去 ;
;---------------------------------------;
clr_screen:
mov cx, COLUMN_WIDTH*ROW_WIDTH
mov di, 0
cld
IFDEF FMR
IFDEF FMR70
mov ax, VACANT_CHAR
rep stosw
ELSE
clr_scr1:
mov al, VACANT_CHAR
stosb
mov al, ATR_WHITE
stosb
loop clr_scr1
ENDIF
ELSE
mov ax, VACANT_CHAR
rep stosw
ENDIF
mov cx, COLUMN_WIDTH*ROW_WIDTH
mov di, ATTR_OFF
IFDEF FMR
IFDEF FMR70
mov ax, ATR_WHITE
rep stosw
ELSE
mov al, 21h
clr_scr2:
stosb
stosb
loop clr_scr2
ENDIF
ELSE
mov ax, ATR_WHITE
rep stosw
ENDIF
ret
;---------------------------------------;
; Shift JIS から JIS コード変換 ;
; In : AX = Shift JIS code. ;
; Out: AX = JIS kanji code. ;
;---------------------------------------;
sjis_to_vjis:
cmp al, 7Fh
jb sjis1
dec ax
sjis1:
sub ax, 1Fh
cmp ah, 0E0h
jb sjis2
sub ax, 4000h
sjis2:
sub ax, 8100h
add ah, ah
cmp al, 7Eh
jbe sjis3
add ax, 00A2h
sjis3:
add ax, 2100h
ret
;---------------------------------------;
; 領域を反転表示 ;
;---------------------------------------;
reverse_region:
push cx
cmp cs:mark_flag, ON
jne rev_reg9
mov di, cs:old_curs_pos
mov cx, cs:curs_pos
cmp di, cx
jbe rev_reg1
xchg di, cx
rev_reg1:
sub cx, di
shr cx, 1
jcxz rev_reg9
rev_reg2:
IFDEF FMR
IFDEF FMR70
cmp word ptr es:[di], VACANT_CHAR
je rev_reg5
ELSE
cmp byte ptr es:[di], VACANT_CHAR
je rev_reg5
ENDIF
ELSE
cmp word ptr es:[di], VACANT_CHAR
je rev_reg5
ENDIF
IFDEF FMR
IFDEF FMR70
mov ax, es:[di+ATTR_OFF]
and ax, ATR_WHITE
cmp ax, ATR_YELLOW ; yellow ?
ELSE
mov al, es:[di+1]
and al, ATR_WHITE
cmp al, ATR_YELLOW ; yellow ?
ENDIF
ELSE
mov al, es:[di+ATTR_OFF]
and al, 11100000b
cmp al, 11000000b ; yellow ?
ENDIF
je rev_reg3
IFDEF FMR
IFDEF FMR70
mov word ptr es:[di+ATTR_OFF], ATR_YELLOW or ATR_REVERSE ; yellow, reverse
ELSE
mov al, es:[di+1]
and al, ATR_KANJI_1 or ATR_KANJI_2 ; reserve kanji attr.
or al, ATR_YELLOW or ATR_REVERSE ; yellow, reverse
mov byte ptr es:[di+1], al
ENDIF
ELSE
mov word ptr es:[di+ATTR_OFF], ATR_YELLOW or ATR_REVERSE ; yellow, reverse
ENDIF
jmp short rev_reg5
rev_reg3:
IFDEF FMR
IFDEF FMR70
cmp word ptr es:[di], EOL_CHAR
ELSE
cmp byte ptr es:[di], EOL_CHAR
ENDIF
ELSE
cmp word ptr es:[di], EOL_CHAR
ENDIF
je rev_reg4
IFDEF FMR
IFDEF FMR70
mov word ptr es:[di+ATTR_OFF], ATR_WHITE ; normal
ELSE
mov al, es:[di+1]
and al, ATR_KANJI_1 or ATR_KANJI_2 ; reserve kanji attr.
or al, ATR_WHITE ; normal
mov byte ptr es:[di+1], al
ENDIF
ELSE
mov word ptr es:[di+ATTR_OFF], ATR_WHITE ; normal
ENDIF
jmp short rev_reg5
rev_reg4:
IFDEF FMR
IFDEF FMR70
mov word ptr es:[di+ATTR_OFF], ATR_CYAN ; light blue
ELSE
mov byte ptr es:[di+1], ATR_CYAN ; light blue
ENDIF
ELSE
mov word ptr es:[di+ATTR_OFF], ATR_CYAN ; light blue
ENDIF
rev_reg5:
add di, 2
loop rev_reg2
rev_reg9:
pop cx
ret
;---------------------------------------;
; 領域の表示 ;
;---------------------------------------;
draw_region:
push cx
cmp cs:mark_flag, ON
jne draw_reg9
call get_mark_pos
mov cx, cs:curs_pos
cmp di, cx
je draw_reg9
jb draw_reg1
xchg di, cx
draw_reg1:
sub cx, di
shr cx, 1
draw_reg2:
IFDEF FMR
IFDEF FMR70
cmp word ptr es:[di], VACANT_CHAR
je draw_reg3
mov word ptr es:[di+ATTR_OFF], ATR_YELLOW or ATR_REVERSE ; yellow, reverse
ELSE
cmp byte ptr es:[di], VACANT_CHAR
je draw_reg3
mov al, es:[di+1]
and al, ATR_KANJI_1 or ATR_KANJI_2 ; reserve kanji attr.
or al, ATR_YELLOW or ATR_REVERSE ; yellow, reverse
mov byte ptr es:[di+1], al
ENDIF
ELSE
cmp word ptr es:[di], VACANT_CHAR
je draw_reg3
mov word ptr es:[di+ATTR_OFF], ATR_YELLOW or ATR_REVERSE ; yellow, reverse
ENDIF
draw_reg3:
add di, 2
loop draw_reg2
draw_reg9:
pop cx
ret
;---------------------------------------;
; 領域の開始位置を求める ;
; Out: DI ;
;---------------------------------------;
get_mark_pos:
push bx
push dx
mov bx, cs:mark_ptr
sub bx, cs:read_ptr
mov cx, ROW_WIDTH - 1
sub dx, dx
sub di, di
mov ax, cs:page_top
sub ax, cs:read_ptr
cmp ax, bx
jae get_mp9
get_mp1:
mov ax, cs:line_top[di+2]
sub ax, cs:read_ptr
cmp ax, bx
jae get_mp2
add dx, COLUMN_WIDTH
add di, 2
loop get_mp1
mov di, COLUMN_WIDTH*ROW_WIDTH*2
jmp short get_mp9
get_mp2:
ja get_mp3
add dx, COLUMN_WIDTH
jmp short get_mp4
get_mp3:
add dx, cs:mark_ptr
sub dx, cs:line_top[di]
get_mp4:
add dx, dx
mov di, dx
get_mp9:
pop dx
pop bx
ret
;---------------------------------------;
; 領域を消去 ;
;---------------------------------------;
clear_region:
push cx
cmp cs:mark_flag, ON
jne clr_reg9
mov di, cs:curs_pos
mov cx, cs:old_curs_pos
cmp di, cx
je clr_reg9
jb clr_reg1
xchg di, cx
clr_reg1:
sub cx, di
shr cx, 1
clr_reg2:
IFDEF FMR
IFDEF FMR70
cmp word ptr es:[di], VACANT_CHAR
je clr_reg5
cmp word ptr es:[di], EOL_CHAR
je clr_reg4
mov word ptr es:[di+ATTR_OFF], ATR_WHITE ; normal
jmp short clr_reg5
clr_reg4:
mov word ptr es:[di+ATTR_OFF], ATR_CYAN ; light blue
ELSE
cmp byte ptr es:[di], VACANT_CHAR
je clr_reg5
mov al, es:[di+1]
and al, ATR_KANJI_1 or ATR_KANJI_2 ; reserve kanji attr.
or al, ATR_CYAN ; light blue
cmp byte ptr es:[di], EOL_CHAR
je clr_reg4
or al, ATR_WHITE ; normal
clr_reg4:
mov byte ptr es:[di+1], al
ENDIF
ELSE
cmp word ptr es:[di], VACANT_CHAR
je clr_reg5
cmp word ptr es:[di], EOL_CHAR
je clr_reg4
mov word ptr es:[di+ATTR_OFF], ATR_WHITE ; normal
jmp short clr_reg5
clr_reg4:
mov word ptr es:[di+ATTR_OFF], ATR_CYAN ; light blue
ENDIF
clr_reg5:
add di, 2
loop clr_reg2
clr_reg9:
pop cx
ret
;-----------------------------------------------;
; 現在の注目点とカーソル位置の計算 ;
;-----------------------------------------------;
adjust_curs_pos:
mov bx, cs:curs_pos_row
add bx, bx
mov ax, cs:line_top[bx]
mov cs:curr_line_top, ax ; current line top
mov ax, cs:line_top[bx+2]
sub ax, cs:line_top[bx]
test ax, ax
jz adj_cp0
dec ax
adj_cp0:
mov cs:curr_line_leng, ax ; current line length
cmp ax, cs:curs_pos_col_s
jbe adj_cp1
mov ax, cs:curs_pos_col_s
adj_cp1:
mov cs:curs_pos_col, ax ; cursor column position
add ax, cs:line_top[bx]
mov cs:current_ptr, ax ; current pointer
mov al, COLUMN_WIDTH
mul byte ptr cs:curs_pos_row
add ax, cs:curs_pos_col
add ax, ax
mov cs:curs_pos, ax ; cursor position
ret
;---------------------------------------;
; カーソル位置の計算 ;
; Out: zero flag ;
; ON .. found in current screen ;
; OFF .. not found ;
;---------------------------------------;
calc_curs_pos:
mov cx, ROW_WIDTH
; mov cx, word ptr cs:row_width_0
sub bx, bx
calc_cp1:
mov ax, cs:current_ptr
mov si, cs:line_top[bx]
sub ax, si
mov dx, cs:line_top[bx+2]
sub dx, si
cmp ax, dx
jb calc_cp2
add bx, 2
loop calc_cp1
or bx, bx ; not found.
ret
;
calc_cp2:
mov cs:curs_pos_col, ax
mov cs:curs_pos_col_s, ax
mov ax, ROW_WIDTH
; mov ax, word ptr cs:row_width_0
sub ax, cx
mov cs:curs_pos_row, ax
sub ax, ax ; found.
ret
;---------------------------------------;
; 文字列の入力 ;
; In : BX = Row ;
; CX = Column ;
;---------------------------------------;
getstr:
push bx
push cx
push dx
push si
push di
IFNDEF FMR
mov byte ptr cs:getchar_flag, ON
ENDIF
mov si, offset str_buf
sub dx, dx
getstr1:
mov ax, '$'
call putchr
call getchar
cmp al, CR
jne getstr1_0
getstr1_9:
jmp getstr9
getstr1_0:
cmp al, CTRL_J
je getstr1_9
cmp al, CTRL_C
je getstr1_9
IF 0
sub ah, HELP
jz getstr3
ENDIF
sub ah, ah
cmp al, BS
jne getstr2
test dx, dx
jz getstr1
xor di, di
getstr1_1: ; check kanji in str_buf
mov al, cs:str_buf[di]
inc di
xor ah, ah
call iskanji
jnc getstr1_2 ; not kanji
inc di
inc ah
getstr1_2:
cmp di, dx
jc getstr1_1
push ax
mov ax, ' '
call putchr
dec si
dec cx
dec dx
pop ax
test ah, ah
je getstr1
mov ax, ' '
call putchr
dec si
dec cx
dec dx
jmp short getstr1
getstr2:
cmp dx, STR_BUF_SIZ
jnc getstr1
call iskanji
jnc getstr2_2 ; no
cmp dx, STR_BUF_SIZ-1
jne getstr2_1
call getchar
jmp short getstr1
getstr2_1:
mov di, ax ; save 1st byte
call getchar ; get 2nd byte
mov ah, al
sub al, al
add ax, di
mov cs:[si], ax ; put kanji into str_buf
add si, 2
add dx, 2
xchg ah, al ; swap bytes
call sjis_to_vjis
push ax
mov al, ah
mov ah, 01h
call putchr
inc cx
pop ax
mov ah, 03h
call putchr
inc cx
jmp getstr1
getstr2_2:
call putchr
mov cs:[si], al
inc si
inc cx
inc dx
jmp getstr1
;
IF 0
getstr3:
mov di, cs:current_ptr
getstr4:
cmp dx, STR_BUF_SIZ
je getstr1
mov ax, [di]
cmp al, 20h
jbe getstr1
cmp al, 7fh
jc getstr6
cmp al, 81h
jc getstr1
cmp al, 0a0h
jc getstr5
cmp al, 0e0h
jc getstr6
cmp al, 0fch
jne getstr_5_0
mov al, '\'
jmp short getstr6
getstr_5_0:
jnc getstr1
getstr5:
xchg ah, al
cmp al, 40h
jc getstr1
cmp al, 7fh
jc getstr5_1
cmp al, 81h
jc getstr1
cmp al, 0fdh
jnc getstr1
getstr5_1:
cmp dx, STR_BUF_SIZ - 1
je getstr1
xchg ah, al
mov cs:[si], ax
xchg ah, al
inc si
inc si
inc di
inc di
inc dx
inc dx
call sjis_to_vjis
sub ax, 2000h
xchg ah, al
call putchr
add al, 80h
inc cx
call putchr
inc cx
jmp short getstr4
;
getstr6:
mov cs:[si], al
xor ah, ah
call putchr
inc cx
inc si
inc di
inc dx
jmp short getstr4
ENDIF
getstr9:
mov cs:str_len, dx
; mov byte ptr cs:getchar_flag, OFF
pop di
pop si
pop dx
pop cx
pop bx
ret
;-----------------------------------------------;
; 画面上の特定位置への文字列の表示 ;
; In : AX = String offset ;
; BX = Row ;
; CX = Column ;
;-----------------------------------------------;
putstr:
push ax
push cx
mov si, ax
sub ax, ax
putstr1:
mov al, cs:[si]
inc si
test ax, ax
jz putstr2
call putchr
inc cx
jmp short putstr1
putstr2:
pop cx
pop ax
ret
;=======================================;
; 機種依存部分 ;
;=======================================;
;---------------------------------------;
; Show/Clear through mode flag ;
;---------------------------------------;
show_thru_flag:
push ax
push es
mov es, cs:tvram_seg
test byte ptr es:[COLUMN_WIDTH*24*2], not 20h ; blank ?
jne show_thru_f1 ; no, skip
; mov al, '!'
mov byte ptr es:[COLUMN_WIDTH*24*2], '!'
IFDEF FMR
IFDEF FMR70
mov word ptr es:[COLUMN_WIDTH*24*2+ATTR_OFF], ATR_WHITE
ELSE
mov byte ptr es:[COLUMN_WIDTH*24*2+1], ATR_WHITE
ENDIF
ELSE
mov word ptr es:[COLUMN_WIDTH*24*2+ATTR_OFF], ATR_WHITE
ENDIF
show_thru_f1:
pop es
pop ax
ret
clear_thru_flag:
push ax
push es
mov es, cs:tvram_seg
; mov al, ' '
mov byte ptr es:[COLUMN_WIDTH*24*2], ' '
pop es
pop ax
ret
;---------------------------------------;
; キーボード入力を得る ;
; Out: AH = scan code ;
; AL = character code ;
;---------------------------------------;
getchar:
IFDEF FMR
push bx
push dx
mov ah, 7 ; 入力のチェック
int 90h
cmp al, 0 ; バッファ内に文字存在?
je getch1 ; 存在しない
mov al, 1 ; バッファから入力
getch1:
mov ah, 9 ; 文字の読込
int 90h
IFDEF FMR70
call refbank
ENDIF
mov ah, bh ; スキャンコードを設定
mov al, dl ; 文字コードを設定
mov cs:shift_status, bl ; シフト状態を設定
pop dx
pop bx
ELSE
push es
push bx
sub ax, ax
mov es, ax
getch0:
cli
cmp byte ptr es:[KBUF_CNT], 0
jne getch1
sti
jmp short getch0
getch1:
mov bx, es:[KBUF_RPTR]
mov ax, es:[bx] ; get key input data.
add bx, 2
cmp bx, KBUF_END
jb getch2
mov bx, KBUF_BGN
getch2:
mov es:[KBUF_RPTR], bx
dec byte ptr es:[KBUF_CNT]
sti
pop bx
pop es
ENDIF
ret
;---------------------------------------;
; 画面上の特定位置への文字の表示 ;
; In : AX = Char code ;
; BX = Row ;
; CX = Column ;
;---------------------------------------;
putchr:
push ax
push bx
push cx
push dx
IFDEF FMR
mov dh, bl ; set row
inc dh
mov dl, cl ; set column
inc dl
mov bh, ah ; set char type
mov bl, al ; set char code
mov al, 1 ; use old attribute
mov ah, 13h ; putchar
int 91h ; call BIOS display
IFDEF FMR70
call refbank
ENDIF
ELSE
mov dx, ax
mov al, COLUMN_WIDTH
; cmp cs:xchange_job, OFF
; jz putchr_1
; dec bl
putchr_1:
mul bl
add ax, cx
add ax, ax
mov bx, ax
mov es:[bx], dx
ENDIF
pop dx
pop cx
pop bx
pop ax
ret
;-------------------------------------------------------;
; 画面をスクロールダウンして最上行に空きを作る ;
;-------------------------------------------------------;
make_room_top:
push ax
push cx
push si
push di
push ds
push es
mov cx, es
mov ds, cx
std
mov cx, COLUMN_WIDTH*(ROW_WIDTH-1) ; text area.
IFDEF FMR
IFDEF FMR70
mov di, COLUMN_WIDTH*2*ROW_WIDTH-2
mov si, COLUMN_WIDTH*2*(ROW_WIDTH-1)-2
rep movsw
mov ax, VACANT_CHAR
mov cx, COLUMN_WIDTH
rep stosw
ELSE
mov di, COLUMN_WIDTH*2*ROW_WIDTH-1
mov si, COLUMN_WIDTH*2*(ROW_WIDTH-1)-1
make_room_t1:
movsb
movsb
loop make_room_t1
mov cx, COLUMN_WIDTH
make_room_t2:
mov al, ATR_WHITE
stosb
mov al, 20h
stosb
loop make_room_t2
ENDIF
ELSE
mov di, COLUMN_WIDTH*2*ROW_WIDTH-2
mov si, COLUMN_WIDTH*2*(ROW_WIDTH-1)-2
rep movsw
mov ax, VACANT_CHAR
mov cx, COLUMN_WIDTH
rep stosw
ENDIF
mov cx, COLUMN_WIDTH*(ROW_WIDTH-1) ; attribute area.
IFDEF FMR
IFDEF FMR70
mov di, COLUMN_WIDTH*2*ROW_WIDTH-2 + ATTR_OFF
mov si, COLUMN_WIDTH*2*(ROW_WIDTH-1)-2 + ATTR_OFF
rep movsw
mov ax, ATR_WHITE
mov cx, COLUMN_WIDTH
rep stosw
ELSE
mov di, COLUMN_WIDTH*2*ROW_WIDTH-1 + ATTR_OFF
mov si, COLUMN_WIDTH*2*(ROW_WIDTH-1)-1 + ATTR_OFF
make_room_t5:
movsb
movsb
loop make_room_t5
mov al, 21h ; upper/lower byte of kanji blank '2121h'
mov cx, COLUMN_WIDTH
make_room_t6:
stosb
stosb
loop make_room_t6
ENDIF
ELSE
mov di, COLUMN_WIDTH*2*ROW_WIDTH-2 + ATTR_OFF
mov si, COLUMN_WIDTH*2*(ROW_WIDTH-1)-2 + ATTR_OFF
rep movsw
mov ax, ATR_WHITE
mov cx, COLUMN_WIDTH
rep stosw
ENDIF
mov cx, cs
mov ds, cx
mov es, cx
mov cx, ROW_WIDTH
mov di, offset page_bottom
mov si, offset page_bottom - 2
rep movsw
cld
pop es
pop ds
pop di
pop si
pop cx
pop ax
ret
;-------------------------------------------------------;
; 画面をスクロールアップして最下行に空きを作る ;
;-------------------------------------------------------;
make_room_bottom:
push ax
push cx
push si
push di
push ds
push es
mov cx, es
mov ds, cx
cld
mov cx, COLUMN_WIDTH*(ROW_WIDTH-1) ; text area.
mov di, 0
mov si, COLUMN_WIDTH*2
IFDEF FMR
IFDEF FMR70
rep movsw
mov ax, VACANT_CHAR
mov cx, COLUMN_WIDTH
rep stosw
ELSE
make_room_b1:
movsb
movsb
loop make_room_b1
mov cx, COLUMN_WIDTH
make_room_b2:
mov al, 20h
stosb
mov al, ATR_WHITE
stosb
loop make_room_b2
ENDIF
ELSE
rep movsw
mov ax, VACANT_CHAR
mov cx, COLUMN_WIDTH
rep stosw
ENDIF
mov cx, COLUMN_WIDTH*(ROW_WIDTH-1) ; attribute area.
mov di, ATTR_OFF
mov si, COLUMN_WIDTH*2 + ATTR_OFF
IFDEF FMR
IFDEF FMR70
rep movsw
mov ax, ATR_WHITE
mov cx, COLUMN_WIDTH
rep stosw
ELSE
make_room_b5:
movsb
movsb
loop make_room_b5
mov al, 21h ; upper/lower byte of kanji blank '2121h'
mov cx, COLUMN_WIDTH
make_room_b6:
stosb
stosb
loop make_room_b6
ENDIF
ELSE
rep movsw
mov ax, ATR_WHITE
mov cx, COLUMN_WIDTH
rep stosw
ENDIF
mov cx, cs
mov ds, cx
mov es, cx
mov cx, ROW_WIDTH
mov di, offset page_top
mov si, offset page_top + 2
rep movsw
pop es
pop ds
pop di
pop si
pop cx
pop ax
ret
;---------------------------------------;
; save screen ;
;---------------------------------------;
save_screen:
mov ds, cs:tvram_seg
mov es, cs:tvbuf_seg
sub ax, ax
mov si, ax
mov di, ax
IFDEF FMR
IFDEF FMR70
mov cx, 1000h/2
cld
rep movsw
mov si, ATTR_OFF
mov cx, 1000h/2
rep movsw
ELSE
mov cx, 1000h
cld
rep movsb
mov si, ATTR_OFF
mov cx, 1000h
rep movsb
ENDIF
ELSE
mov cx, 1000h/2
cld
rep movsw
mov si, ATTR_OFF
mov cx, 1000h/2
rep movsw
ENDIF
ret
;---------------------------------------;
; restore screen ;
;---------------------------------------;
restore_screen:
mov ds, cs:tvbuf_seg
mov es, cs:tvram_seg
sub ax, ax
mov si, ax
mov di, ax
IFDEF FMR
IFDEF FMR70
mov cx, 1000h/2
cld
rep movsw
mov di, ATTR_OFF
mov cx, 1000h/2
rep movsw
ELSE
mov cx, 1000h
cld
rep movsb
mov di, ATTR_OFF
mov cx, 1000h
rep movsb
ENDIF
ELSE
mov cx, 1000h/2
cld
rep movsw
mov di, ATTR_OFF
mov cx, 1000h/2
rep movsw
ENDIF
ret
;---------------------------------------;
; display quasi-cursor ;
;---------------------------------------;
disp_cursor:
push bx
mov bx, cs:curs_pos
mov cs:old_curs_pos, bx
IFDEF FMR
IFDEF FMR70
or word ptr es:[bx+ATTR_OFF], ATR_REVERSE ; set reverse flag.
ELSE
or byte ptr es:[bx+1], ATR_REVERSE ; set reverse flag.
ENDIF
ELSE
or word ptr es:[bx+ATTR_OFF], ATR_REVERSE ; set reverse flag.
ENDIF
pop bx
ret
;---------------------------------------;
; clear quasi-cursor ;
;---------------------------------------;
clear_cursor:
push bx
mov bx, cs:curs_pos
IFDEF FMR
IFDEF FMR70
mov ax, es:[bx+ATTR_OFF]
and ax, ATR_WHITE
cmp ax, ATR_YELLOW ; yellow ?
ELSE
mov al, es:[bx+1]
and al, ATR_WHITE
cmp al, ATR_YELLOW ; yellow ?
ENDIF
ELSE
mov al, es:[bx+ATTR_OFF]
and al, 11100000b
cmp al, 11000000b ; yellow ?
ENDIF
je clr_curs1
IFDEF FMR
IFDEF FMR70
and word ptr es:[bx+ATTR_OFF], not ATR_REVERSE ; clear reverse flag.
ELSE
and byte ptr es:[bx+1], not ATR_REVERSE ; clear reverse flag.
ENDIF
ELSE
and word ptr es:[bx+ATTR_OFF], not ATR_REVERSE ; clear reverse flag.
ENDIF
clr_curs1:
pop bx
ret
;-------------------------------;
; clear keyboard buffer ;
;-------------------------------;
clear_keybuf:
IFDEF FMR
push dx
push cx
push bx
push ax
mov ah, 6 ; バッファのクリア
mov al, 0
int 90h
IFDEF FMR70
call refbank
ENDIF
pop ax
pop bx
pop cx
pop dx
ENDIF
ret
;---------------------------------------;
; 漢字の第一バイトをチェック ;
; In : AL = Char code ;
; Out: Carry = 1 : True ;
; 0 : False ;
;---------------------------------------;
iskanji:
cmp al, 0fdh
jnc iskanji0
cmp al, 0e0h
jnc iskanji1
cmp al, 0a0h
jnc iskanji0
cmp al, 81h
jnc iskanji1
clc
iskanji0:
ret
iskanji1:
stc
ret
code ends
end start