home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
txtutl
/
td120.arc
/
TDOODLE.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-01-23
|
77KB
|
2,788 lines
comment * WordStar Tab Ruler
L-------!-------!---------------!----!----!----!----!----!----!----!---------------------------R
12-30-85
*
cseg segment para public 'code'
assume cs:cseg,ds:cseg,es:cseg,ss:cseg
len_picture=1688
org 0h
Zero: ;ret to DOS
org 100h
start: jmp init ;goto initialization routine
buffer db 256 dup(?)
handle dw ?
char db ?
filespec_ptr dw ?
filespec_buffer1 db 256 dup(?)
filespec_buffer2 db 256 dup(?)
space_count db ?
write db ?
save_attribs db ?
screen_no db ?
filename1 db 65 dup(?)
filename2 db 65 dup(?)
screen_page db ?
attrib db ?
mode db ?
say_color_flag db 0
cursor dw ?
max_line db ?
cur_line db ?
max_col db ?
cur_col db ?
create db ?
rotate db ?
space_size db ?
ins_del_flag db ?
cursor_size dw ?
screen_seg dw ?
screen_buffer dw ?
paste_size dw ? ; y/x size of paste_buffer
last_x db ?
last_y db ?
block_cursor label word
cursor_x db ?
cursor_y db ?
quad db ?
wrap_flag db ?
cmd_cmd db ?
esc=27
yes=255
no=0
dos macro function
mov ah,function
int 21h
endm
getkey macro
call get_keystroke
endm
wait_for_key macro
local wfk_1
wfk_1: getkey
jz wfk_1
endm
get_keystroke:
mov ah,1
int 16h
jz GK_ret
pushf
mov ah,0
int 16h
popf
GK_ret: ret
jump macro table,item
mov bx,offset table
mov al,item
call table_jump
endm
;
search macro table,item
mov bx,offset table
mov ax,item
call table_search
endm
;
table_jump:
cmp cs:[bx],al ;too big an offset?
jc TJ_end
dec bx
mov ah,0
add ax,ax ;prep offset
add bx,ax ;get actual addr of routine
jmp word ptr cs:[bx] ;go to routine
TJ_end: ret
;
table_search:
push bx
push cx ;search table @ BX for AL
push dx
push di
or al,al ;2-byter
jz TS_10 ;yes, don't clear top
mov ah,0 ;otherwise...
call capit_al
TS_10: mov cl,[bx] ;get len of $ to search
mov ch,0
mov di,bx
TS_5: inc di ;skip length
mov dx,[di] ;get table entry
or dl,dl ;test for 2-byter
jnz TS_2 ;no
inc di
jmp short TS_3
TS_2: mov dh,0 ;clear top byte for cmp
TS_3: cmp ax,dx ;are they the same?
je TS_4 ;go if they are
loop TS_5 ;else go to end of table
jmp short TS_1 ;done but not found
TS_4: mov ch,[bx] ;get len of table again
sub ch,cl ;get offset into table
mov ah,ch ;get offset into ah
inc ah ;make go from 1
xor bx,bx ;set flags
TS_1: pop di
pop dx
pop cx
pop bx
ret
;
capit_al:
cmp al,'a'
jc CA_1
cmp al,'z'+1
jnc CA_1
sub al,32
CA_1: ret
retf macro pop_value
ifb <pop_value>
db 0cbH ;far ret w/no [pop-value]
else
db 0caH ;far ret w/pop-value
dw pop_value
endif
endm
;
ceol db esc,'[K$'
print_cs_space:
mov ah,9
int 21h
mov dl,32
mov ah,2
int 21h
ret
print_cs:
mov ah,9
int 21h
mov dx,offset ceol
mov ah,9
int 21h
ret
save_screen:
mov si,0
mov di,[screen_buffer]
mov ax,screen_seg
mov ds,ax
mov cx,1760
rep movsw
mov ax,es
mov ds,ax
ret
MU_undo:
restore_screen:
pushf
push ax
push cx
push si
push di
mov ax,screen_seg
mov es,ax
mov si,[screen_buffer]
mov di,0
mov cx,1760
rep movsw
mov ax,ds
mov es,ax
pop di
pop si
pop cx
pop ax
popf
ret
memory_error db 'Memory allocation error (not enough, or bad allocation blocks)',13,10,10
ansi_test db esc,'[H',8,8,8,' ',8,8,8,'$'
ansi_error db 13,10,'tDoodle 1.11',13,10,'Please add the following line to your '
db 'CONFIG.SYS file:',13,10,10
db 'DEVICE=ANSI.SYS',13,10,10,'$'
break_handler:
iret
No_parm:
call cls
mov cx,len_picture
mov dx,offset screen_buffer_1
mov bx,0 ;CON
mov ah,40h ;write to file
int 21h
np_1: getkey
jnz np_1
np_2: getkey
jz np_2
call cls
jmp editor
bad_dos_version db 'tDoodle 1.00: Incorrect DOS Version.$'
;************* Start *********************
init: mov ah,30h
int 21h ;get DOS ver #
cmp al,2
jae init_9
mov dx,offset bad_dos_version
mov ah,9
int 21h
jmp zero
init_9: mov bh,0
mov ah,3
int 10h ;get curpos
push dx
mov dh,24
mov dl,0
mov ah,2
int 10h ;set curpos
mov dx,offset ansi_test
dos 9
mov ah,3
int 10h
or dx,dx
pop dx
pushf
mov ah,2
int 10h ;restore cursor
popf
jz ansi_installed
mov dx,offset ansi_error
dos 9
jmp zero ;terminate (no ANSI.SYS)
parm_error_so:
jmp parm_error
ansi_installed:
mov bx,offset end_of_code
mov cl,4
shr bx,cl ;turn byte count into para's
inc bx
mov ah,4Ah
int 21h
jnc init_10
mov dx,offset Memory_error
call print_cs
jmp zero
no_parm_so:
jmp no_parm
init_10:
mov ah,25h ;get ^Break addr
mov al,23h ;^BREAK int #
mov dx,offset Break_handler
int 21h
mov ah,3
int 10h ;get cursor size
mov cursor_size,cx
call fix_cursor_block
mov screen_buffer,offset screen_buffer_1
mov al,0 ;set display_ctrls filename(s) to ""
mov byte ptr filename1,al
mov byte ptr filename2,al
mov filespec_ptr,offset filespec_buffer1
mov filespec_buffer1+1,al
mov filespec_buffer2+1,al
mov al,64
mov filespec_buffer1,al
mov filespec_buffer2,al
mov screen_no,1
mov di,filespec_ptr
inc di ;skip input len
mov si,80h ;parameter addr
lodsb ;get len of command$
mov bl,al
mov bh,0
or bl,bh ;is len(parm)=0?
jz No_Parm_so
mov byte ptr [si+bx],0 ;terminate ASCIIZ
init_loop_1:
lodsb ;get char of $
or al,al ;EOS?
jz Parm_error_so
cmp al,13 ;EOS?
jz Parm_error_so
cmp al,9 ;nothing?
jz init_loop_1
cmp al,32 ;space?
jz init_loop_1
dec si
push si
mov cl,0
inc di
init_1: lodsb
stosb
inc cl
cmp al,0 ;EOS?
jne init_1
dec cl
mov byte ptr [filespec_buffer1+1],cl
pop si
mov dx,si
mov al,2 ;open for r/w
mov ah,3Dh
int 21h ;open file
jnc Load_File_so
cmp al,2
jnz File_open_error
mov dx,si
mov ah,3Ch
mov cx,0
int 21h
jc File_open_error
Load_file_so:
jmp Load_file
Parm_error_message db 'Bad parameter line',13,10,'$'
File_open_error_message db 'Couldn',27h,'t open file',13,10,'$'
Load_error_message db 'Had trouble loading file.',13,10,'$'
Parm_error:
mov dx,offset Parm_error_message
call print_cs
jmp ret_to_dos
File_open_error:
mov dx,offset File_open_error_message
call print_cs
jmp ret_to_dos
Load_error:
mov byte ptr [di-1],13
mov bx,handle
mov ah,3Eh
int 21h
mov dx,offset Load_error_message
call print_cs
Ret_to_DOS_2:
Ret_to_DOS:
jmp Zero
cls_string db esc,'[=2h',esc,'[?7h',esc,'[0m',esc,'[2J','$'
cls: mov dx,offset cls_string
call print_cs
mov attrib,7
call fix_cursor_block
ret
Load_File:
mov handle,ax
call cls
Load_loop:
mov bx,handle
mov ah,3Fh
mov cx,1
mov dx,offset buffer
int 21h
jc Load_Error
or ax,ax
jz Load_Ended
mov dl,byte ptr [buffer]
cmp dl,26 ;^Z terminating?
jz Load_Ended
mov ah,2
int 21h
jmp Load_loop
Load_Ended:
mov bx,handle
mov ah,3Eh
int 21h ;close file
mov cx,0 ;home cursor
call set_cur_pos
call move_filename ;setup filename on ctrl-line
jmp Editor
text_table db 17
db 8 ;bksp
db 13 ;RET
db 0,71 ;HOME
db 0,72 ;up
db 0,73 ;PgUp
db 0,75 ;lt
db 0,77 ;rt
db 0,79 ;END
db 0,80 ;dn
db 0,81 ;PgDn
db 27 ;ESC
db 0,82 ;INS
db 0,83 ;DEL
db 9 ;TAB
db 0,115 ;^lt
db 0,116 ;^rt
db 0,119 ;^HOME
text_jmp_table db 17
dw offset key_bksp
dw offset key_cr
dw offset key_home
dw offset key_up
dw offset key_pgup
dw offset key_lt
dw offset key_rt
dw offset key_end
dw offset key_dn
dw offset key_pgdn
dw offset key_esc
dw offset key_ins
dw offset key_del
dw offset key_tab
dw offset key_ctrl_lt
dw offset key_ctrl_rt
dw offset key_ctrl_home
cmd_key db 10, esc,'GRCSLQWFU'
cmd_table db 10
dw offset cmd_esc ;toggle to/from text/cmd
dw offset cmd_G ;replace IBM graphics
dw offset cmd_R ;replace (not implemented)
dw offset cmd_C ;set Colors
dw offset cmd_S ;Save file
dw offset cmd_L ;Load file
dw offset cmd_Q ;Quit tDoodle
dw offset cmd_W ;Wipe out screen (cls)
dw offset cmd_F ;Flip between screens
dw offset cmd_U ;Undo (edit: F9)
box_key_table db 22, '12345678QWEASDZXC-_\| '
box_table_list label word
dw offset box_table_1
dw offset box_table_2
dw offset box_table_3
dw offset box_table_4
box_table_1 db 176,177,178,219,220,223,221,222
db 218,194,191,195,197,180,192,193,217,196,196,179,179,32
box_table_2 db 176,177,178,219,220,223,221,222
db 201,203,187,204,206,185,200,202,188,205,205,186,186,32
box_table_3 db 176,177,178,219,220,223,221,222
db 213,209,184,198,216,181,212,207,190,205,205,179,179,32
box_table_4 db 176,177,178,219,220,223,221,222
db 214,210,183,199,215,182,211,208,189,196,196,186,186,32
fn_table db 10
db 0,59 ;F1: rotate box modes
db 0,60 ;F2: set csr attr to cur attr
db 0,61 ;F3: reverse screen attribs
db 0,62 ;F4: rotate paint/text/both
db 0,63 ;F5: show colors
db 0,64 ;F6: Flip from one screen to the other
db 0,65 ;F7: Pickup
db 0,66 ;F8: PutDown
db 0,67 ;F9: Undo
db 0,68 ;F0: ASCII table
mode_update_table db 10
dw offset MU_boxes
dw offset MU_attrib
dw offset MU_reverse
dw offset MU_put_mode
dw offset MU_show_colors
dw offset MU_flip
dw offset MU_Pickup
dw offset MU_PutDown
dw offset MU_Undo
dw offset MU_ascii
key_ctrl_home:
call get_cur
mov cl,39
jmp set_cur_pos
key_ctrl_rt:
call get_cur
mov cl,78
jmp set_cur_pos
key_ctrl_lt:
call get_cur
mov cl,0
jmp set_cur_pos
key_lt: call get_cur
cmp cl,0
jz KL_1
dec cl
SCP: jmp Set_cur_pos
KL_1: cmp wrap_flag,255
jne scp
mov cl,78
Key_up_2:
or ch,ch
jz Set_cur_pos
dec ch
jmp Set_Cur_pos
Key_cr:
call get_cur
cmp ch,21
jz Set_Cur_pos
inc ch
mov cl,0
jmp Set_Cur_pos
Key_rt: call get_cur
cmp cl,78
jne KR_1
cmp wrap_flag,255
jne set_cur_pos
jmp Key_cr
KR_1: inc cl
Set_cur_pos:
mov ah,2
mov bh,screen_page
mov dx,cx
int 10h
cmp say_color_flag,0
jz SCP_ret
call say_color
SCP_ret:
ret
Key_up: call get_cur
jmp Key_up_2
Key_dn: call get_cur
cmp ch,21
jz Set_cur_pos
inc ch
jmp Set_cur_pos
Key_home:
mov cx,0
jmp Set_cur_pos
Key_PgUp:
call Key_up
call key_rt
ret
Key_PgDn:
call Key_dn
call key_rt
ret
Key_End:
mov cx,21*256
jmp Set_cur_pos
key_bksp:
call key_lt
mov al,32 ;print space
mov ah,attrib ;in current attrib
call alt_modes
mov bh,0
mov cx,1
mov ah,9
int 10h
ret
get_cur:
mov ah,3
mov bh,screen_page
int 10h
mov cx,dx
ret
key_esc:
clc
call save_cur
pop ax
ret
key_ins:
mov bh,screen_page
mov ah,3
int 10h
mov cursor,dx
mov al,attrib
push ax
mov ins_del_flag,255
push dx ;save it for later
mov dl,78 ;last col
KI_1: dec dl
mov ah,2 ;set curpos
int 10h
mov ah,8
int 10h ;read c/a
mov attrib,ah
push ax
inc dl
mov ah,2
int 10h
pop ax
push dx
call alt_modes
pop dx
mov cx,1
mov ah,9
int 10h ;write c/a
dec dl
pop cx
cmp dl,cl
push cx
jne KI_1
pop cx
mov ah,2
int 10h ;reset cursor
pop ax
mov attrib,al
mov al,32
call alt_modes
mov cx,1
mov ah,9
int 10h
mov ins_del_flag,0
ret
key_del:
mov bh,screen_page
mov ah,3
int 10h ;get curpos
mov cursor,dx
mov al,attrib
push ax
mov ins_del_flag,255
kd_1: inc dl ;next col over
mov ah,2
int 10h
mov ah,8
int 10h ;get c/a
mov attrib,ah
push ax
dec dl
mov ah,2
int 10h
pop ax
push dx
call alt_modes
pop dx
mov cx,1
mov ah,9
int 10h
inc dl
cmp dl,78
jne kd_1
mov ah,2
int 10h
pop ax
mov attrib,al
mov al,32
call alt_modes
mov cx,1
mov ah,9
int 10h
mov dx,cursor
mov ah,2
int 10h
mov ins_del_flag,0
ret
key_tab:
mov bh,screen_page
mov ah,3
int 10h ;get curpos
mov cl,3
sar dl,cl
inc dl
sal dl,cl
and dl,255-7
cmp dl,78
jbe kt_cont
mov dl,78
cmp dh,22
je kt_cont
inc dh
mov dl,0
kt_cont:
mov ah,2
int 10h
ret
fix_cursor_block:
mov ah,15
int 10h ;get screen mode
mov screen_page,bh
mov cx,12
mov dx,0B000h ;mono seg
mov say_color_flag,255
cmp al,7 ;monochrome
jz set_cursor_block
mov cl,7
mov dx,0B800h ;cga seg
mov say_color_flag,0
set_cursor_block:
mov screen_seg,dx
mov ah,1
int 10h ;set new cursor
ret
restore_cursor_block:
mov cx,cursor_size
mov ah,1
int 10h
ret
Editor: mov attrib,7 ;default, white on black
mov mode,0 ;text mode
call cmd_f
call cls
call cmd_f
Editor_loop:
mov wrap_flag,255
mov save_attribs,yes ;use ANSI's for menus
call display_ctrls
call mode_text ;go update screen
call mode_cmd
jnc Editor_loop
call cls
call restore_cursor_block
jmp Ret_to_DOS_2
mode_text:
getkey
jz mode_text
push ax
search text_table,ax
jnz MT_text
pop dx
jump text_jmp_table,ah
jmp mode_text
MT_text:
pop ax ;get back key
push ax ;and save it back
search fn_table,ax
je mode_update
pop ax
or al,al
jz mode_text ;bad keystroke
cmp al,32
jb mode_text
call alt_modes
mov cx,1
mov ah,9
int 10h
call key_rt
jmp mode_text
mode_update:
pop dx ;clear stack
jump mode_update_table,ah
mov wrap_flag,255
jmp mode_text
MU_boxes:
mov ah,mode
test ah,128
jz F1_start
mov al,ah
and al,252
inc ah
and ah,3
or ah,ah
jz F1_end
or ah,al
mov mode,ah
call display_ctrls
ret
F1_end: and al,127
mov mode,al
call display_ctrls
ret
F1_start:
or ah,128
and ah,252
mov mode,ah
call display_ctrls
ret
MU_attrib:
mov ah,8
mov bh,screen_page
int 10h
mov attrib,ah
call display_ctrls
ret
MU_reverse:
mov ah,attrib
mov al,ah
mov cl,4
ror ah,cl
and ah,255-(128+8) ;clear int/blnk bits
and al,128+8
or ah,al ;move old blnk/int into attribs
mov attrib,ah
call display_ctrls
ret
MU_put_mode:
mov ah,mode
mov cl,5
ror ah,cl
and ah,3
test ah,1 ;not "both"?
jnz MU_pm_1 ;go if not "both"
mov ah,1
MU_pm_3:
mov al,mode
and al,255-96 ;clear out current mode
rol ah,cl
or al,ah
mov mode,al ;set new one
call display_ctrls
ret
MU_pm_1:
xor ah,2 ;set 0 to 1
test ah,2 ;is it 0
jz MU_pm_2
jmp MU_pm_3
MU_pm_2:
mov ah,0
jmp MU_pm_3
mu_sc_setup db esc,'[24;1f$'
mu_sc_colors db 8
dw offset mu_black
dw offset mu_blue
dw offset mu_green
dw offset mu_cyan
dw offset mu_red
dw offset mu_magenta
dw offset mu_yellow
dw offset mu_white
mu_black db 'Black$'
mu_blue db 'Blue$'
mu_green db 'Green$'
mu_cyan db 'Cyan$'
mu_red db 'Red$'
mu_magenta db 'Magenta$'
mu_yellow db 'Yellow$'
mu_white db 'White$'
mu_blinking db 'Blinking$'
mu_bright db 'Bright$'
mu_on db 'on$'
mu_comma db 8,',$'
MU_show_colors:
xor say_color_flag,255
cmp say_color_flag,0
jne say_color
ret
say_color:
push ax
push bx
push cx
push dx
push si
push di
mov bh,screen_page
mov ah,8
int 10h ;get c/a
push ax
mov ah,3
int 10h ;get curpos
mov cursor,dx
mov dx,offset mu_sc_setup
call print_cs
pop ax ;get c/a
push ax
test ah,8 ;bright?
jz MU_sc_1
mov dx,offset mu_bright
call print_cs_space
pop ax
push ax
test ah,128 ;blinking?
jz mu_sc_1
mov dx,offset mu_comma
call print_cs_space
pop ax
push ax
mu_sc_1:
test ah,128 ;blinking?
jz mu_sc_2
mov dx,offset mu_blinking
call print_cs_space
pop ax
push ax
mu_sc_2:
and ah,7 ;get foreground color
mov al,ah
mov ah,0
add ax,ax
mov bx,ax
inc bx
mov si,offset mu_sc_colors
mov dx,[si+bx]
call print_cs_space
mov dx,offset mu_on
call print_cs_space
pop ax
mov cl,4
ror ah,cl
and ah,7
mov al,ah
mov ah,0
add ax,ax
mov bx,ax
inc bx
mov dx,[si+bx]
call print_cs
mov dx,cursor
mov ah,2
mov bh,screen_page
int 10h
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
alt_modes:
test mode,128 ;is graphic active?
jz AM_paint ;no, go check attr only
test ins_del_flag,1 ;no box conv?
jnz AM_paint
search box_key_table,ax
je AM_1
pop ax ;clear stack
jmp mode_text
AM_1: mov dl,mode
mov dh,0
and dl,3
add dx,dx
mov bx,offset box_table_list
add bx,dx
mov bx,cs:[bx] ;get addr of xlat table
dec ah
mov al,ah
mov ah,0
add bx,ax
mov al,cs:[bx] ;get xlated box part
AM_paint: ;t/a lockout?
push ax
test mode,32
jz AM_normal
mov bh,screen_page
mov ah,8
int 10h ;get c/a
test mode,64 ;text only?
jz AM_attr ;no, attr only.
mov bl,ah ;set attr to what's under cur
mov bh,screen_page
pop ax ;recover text
ret
AM_attr:
pop dx ;scrap old text
mov bh,screen_page
mov bl,attrib
ret
AM_normal:
pop ax
mov bh,screen_page
mov bl,attrib
ret
mup_inst db esc,'[24;1fUse ',24,' ',25,' ',26,' and ',27,' to move,',13,10
db 'F7 to set other end of block, ESC to abort CUT.$'
mu_Pickup:
call save_screen
call save_cur
mov al,say_color_flag
mov ah,attrib
push ax
mov say_color_flag,0
mov wrap_flag,0
mov di,0700h
mov si,00FFh ;setup for CLS2
mov dx,0 ;csrpos
mov bh,screen_page
push cursor
call cls2
pop cursor
mov dx,offset mup_inst
call print_cs
call restore_cur
mov dx,cursor
mov block_cursor,dx
mov last_x,dl
mov last_y,dh
call fix_block
mup_1: getkey
jz mup_1
cmp ax,4100h ;F7?
je mup_2
search text_table,ax
jne mup_1
cmp ah,2
je mup_1
cmp ah,3
je mup_1
cmp ah,8
je mup_1
cmp ah,12
je mup_1
cmp ah,13
je mup_1
cmp ah,11
je mup_esc
cmp ah,14
jnc mup_1
jump text_jmp_table,ah
call fix_block
jmp mup_1
mup_esc:
pop ax
mov say_color_flag,al
mov attrib,ah
call restore_screen
call display_ctrls
call restore_cur
ret
mup_2: mov bh,screen_page
mov ah,3 ;read curpos
int 10h
mov cx,block_cursor
cmp ch,dh ;make DX hold bigger y/x
jbe mup_3
xchg ch,dh
mup_3: cmp cl,dl
jbe mup_4
xchg cl,dl
mup_4: push dx ;save bigger values
sub dx,cx
inc dl
inc dh ;make go from 1
mov paste_size,dx ;set y/x of block size
pop dx
call restore_screen
mov di,offset paste_buffer
xchg cx,dx ;move small curpos to cursor register
mup_6: push dx
mup_5: mov ah,2
int 10h
mov ah,8
int 10h
stosw
cmp dl,cl
je mup_next_line
inc dl
jmp mup_5
mup_next_line:
pop dx
cmp dh,ch
je mup_end
inc dh
jmp mup_6
mup_end:
jmp mup_esc
fb_y_more:
jmp fb_y_more_routine
fix_block:
mov bh,screen_page
mov ah,3
int 10h ;get curpos
cmp dl,last_x
jb fb_x_less
ja fb_x_more
call fb_center
fb_1: cmp dh,last_y
jb fb_y_less
ja fb_y_more
call fb_center
fb_2: mov last_x,dl
mov last_y,dh
mov ah,2
int 10h ;reset curpos
ret
fb_x_less:
cmp dl,cursor_x
jb fbxl_less
mov cl,last_x
cmp dl,cl
push dx
mov attrib,7
mov dh,last_y
jbe fbxl_1
xchg dl,cl
fbxl_1: inc dl
call fb_v_line
cmp dl,cl
jne fbxl_1
pop dx
jmp fb_1
fbxl_less:
mov cl,last_x
cmp dl,cl
push dx
mov attrib,7*16
jae fbxl_2
xchg dl,cl
fbxl_2: call fb_v_line
cmp dl,cl
je fbxl_3
dec dl
jmp fbxl_2
fbxl_3: pop dx
jmp fb_1
fb_x_more:
cmp dl,cursor_x
ja fbxl_less
mov cl,last_x
push dx
mov attrib,7
mov dh,last_y
cmp dl,cl
jbe fbxm_1
xchg dl,cl
fbxm_1: call fb_v_line
inc dl
cmp dl,cl
jne fbxm_1
pop dx
jmp fb_1
fb_y_less:
mov quad,0
cmp dh,cursor_y
mov quad,0
jb fbyl_less
mov quad,255
fbym_1: mov ch,last_y
cmp dh,ch
push dx
mov attrib,7
mov dl,last_x
jbe fbyl_1
xchg dh,ch
fbyl_1: call fbyl_fix_quad_3_4
fbyl_2: call fb_h_line
inc dh
cmp dh,ch
jne fbyl_2
pop dx
jmp fb_2
fbyl_less:
mov ch,last_y
cmp dh,ch
push dx
mov attrib,7*16
jae fbyl_4
xchg dh,ch
fbyl_4: dec ch
fbyl_3: call fb_h_line
dec dh
cmp dh,ch
jne fbyl_3
pop dx
jmp fb_2
fb_y_more_routine:
cmp dh,cursor_y
mov quad,255
ja fbyl_less
mov quad,0
jmp fbym_1
fbyl_fix_quad_3_4:
test quad,255
jz fbylfq34_ret
inc ch
inc dh
fbylfq34_ret:
ret
fb_v_line:
push dx
push cx
mov bh,screen_page
mov ch,cursor_y
cmp dh,ch
jbe fbvl_1
xchg dh,ch
fbvl_1: mov ah,2 ;set curpos
int 10h
mov ah,8
int 10h ;read c/a
push cx
mov bl,attrib
mov cx,1
mov ah,9
int 10h ;write new attrib
pop cx
cmp dh,ch
je fbvl_2
inc dh
jmp fbvl_1
fbvl_2: pop cx
pop dx
ret
fb_h_line:
push dx
push cx
mov bh,screen_page
mov cl,cursor_x
cmp dl,cl
jbe fbhl_1
xchg dl,cl
fbhl_1: mov ah,2 ;set curpos
int 10h
mov ah,8
int 10h ;read c/a
push cx
mov bl,attrib
mov cx,1
mov ah,9
int 10h ;write new attrib
pop cx
cmp dl,cl
je fbhl_2
inc dl
jmp fbhl_1
fbhl_2: pop cx
pop dx
ret
fb_center:
push dx
mov ah,3
int 10h
pop cx
push dx
mov dx,cx
mov ah,2
int 10h
mov ah,8
int 10h
push cx
mov bl,7*16
mov cx,1
mov ah,9
int 10h
pop cx
pop dx
mov ah,2
int 10h
mov dx,cx
ret
mu_putdown:
call save_screen ;save for later undo
mov al,attrib
push ax
mov ins_del_flag,255
mov bh,screen_page
mov ah,3
int 10h ;get curpos
push dx ;save it
mov ah,22
xchg ah,dh
sub dh,ah
mov al,79
xchg al,dl
sub dl,al
mov cx,paste_size
cmp dh,ch ;take smaller of two
jbe mupd_1
mov dh,ch
mupd_1: cmp dl,cl
jbe mupd_2
mov dl,cl
mupd_2: mov si,offset paste_buffer
mov cl,dh ;get # lines to do
mov ch,0 ;into CX
mov bl,dl ;get # cols
mov bh,0 ;into BX
pop dx ;get cursor pos
push dx
mupd_4: push dx ;save cursor pos
push cx ;save # lines to do
push si ;save current paste_buffer position
mov cx,bx ;get # cols to do
mupd_3: push cx ;save # cols left
push bx ;save total cols to do
mov bh,screen_page
mov ah,2 ;set curpos
int 10h
lodsw ;get c/a from p_buff
mov attrib,ah
push dx
push si
call alt_modes
pop si
pop dx
mov cx,1
mov ah,9
int 10h ;write c/a from buffer
pop bx
pop cx ;get # chrs to do
inc dl ;next csr col
loop mupd_3
pop si ;restore start of line in paste buffer
mov cx,paste_size
mov ch,0
add cx,cx
add si,cx
pop cx ;get # lines left to do
pop dx ;restore cursor pos
inc dh
loop mupd_4
pop dx
mov bh,screen_page
mov ah,2
int 10h ;restore curpos
pop ax
mov attrib,al
mov ins_del_flag,0
ret
Macro_mess_1 db esc,'[24;1f',esc,'I give up. If you want macros, use ProKey or something.$'
MU_ascii:
call save_cur
call save_screen
mov dx,offset ascii_table_data
dos 9
wait_for_key
call restore_screen
call restore_cur
ret
MU_flip:
call cmd_f
call display_ctrls
ret
cmd_f:
mov dx,offset screen_buffer_2
mov screen_no,2
mov filespec_ptr,offset filespec_buffer2
cmp screen_buffer, offset screen_buffer_1
je MUF_set
mov dx,offset screen_buffer_1
mov screen_no,1
mov filespec_ptr,offset filespec_buffer1
MUF_set:
push dx
call save_screen
pop dx
mov screen_buffer,dx
call restore_screen
ret
wipe_prompt_1 db esc,'[24;1fAttributes, Text or Both (a/t/b)? $'
wipe_prompt_2 label byte
quit_prompt db esc,'[24;1fAre you sure (y/n)? $'
command_prompt db esc,'[24;1f',esc,'[0mCommand: $'
save_prompt db esc,'[24;1fSave to $'
CL_prompt db esc,'[24;1fLoad from $'
home db esc,'[1;1f$'
CL_err_mess db esc,'[24;1fError in Loading of file. Hit key to resume editing. ( )',esc,'[5D$'
CS_err_mess db esc,'[24;1fError: Couldn',27h,'t save file. Hit key to resume editing. ( )',esc,'[5D$'
crlf db 13,10
ctrl_z db 26
save_cur:
mov bh,screen_page
mov ah,3
int 10h
mov cursor,dx
ret
restore_cur:
mov bh,screen_page
mov ah,2
mov dx,cursor
int 10h
ret
no_bak_error db esc,'[24;1fError in renaming to .BAK; continue anyway (y/n)? $'
get_filespec:
call print_cs
call save_screen
push si
mov dx,filespec_ptr
mov si,dx
mov bl,[si+1]
mov bh,0
mov byte ptr [si+bx+2],13
xchg bx,si
pop si
push dx
mov ah,0Ah
int 21h ;input filename
pop bx
add bx,2
mov dx,bx
mov al,[bx-1]
mov ah,0
or ax,ax
jz GF_err
add bx,ax
mov byte ptr [bx],0
push bx
;open file for r/w
test create,255
jnz GF_create
mov al,2
push dx
mov ah,3Dh
int 21h
pop dx
pop bx
jnc get_fs_ret
GF_err: jmp get_fs_ret_err
GF_create:
mov al,2
push dx
mov ah,3dh
int 21h ;open file for read/write
pop dx
push di
jc GFC_1 ;go create if not found
push dx ;save $ addr
mov bx,ax ;get handle
dos 3Eh ;close file
pop dx ;get $ addr
mov bx,dx ;get $ addr
mov di,offset buffer
GFC_2: mov al,[bx] ;get char
cmp al,0 ;eos?
jz GF_bak
cmp al,'.' ;start of .EXT?
je GF_bak
inc bx
stosb ;save byte of $
jmp GFC_2
GF_bak: mov al,'.' ;ext marker
stosb
mov al,'B'
stosb
mov al,'A'
stosb
mov al,'K'
stosb
mov al,0
stosb
mov di,offset buffer ;get ptr to .bak $
push dx ;save $ addr
mov dx,di ;get .bak filespec
dos 41h ;delete .bak
pop dx
push dx
dos 56H ;rename file to .BAK
pop dx
jnc GFC_1
push dx
mov dx,offset no_bak_error
dos 9
pop dx
GFC_3: wait_for_key
call capit_al
cmp al,'Y'
je GFC_1
cmp al,'N'
jne GFC_3
pop di
pop bx
jmp short get_fs_ret_err
GFC_1: pop di ;restore di
mov ah,3Ch
mov cx,0
mov al,2
int 21h
pop bx
jnc get_fs_ret
get_fs_ret_err:
stc
jmp short gfr_1
get_fs_ret:
call move_filename ;set filename to be printed on CTRL-line
gfr_1: mov byte ptr [bx],13 ;set buffer back to normal
call restore_screen
ret
move_filename:
pushf
push ax
push bx
push cx
push dx
push si
push di
mov di,offset filename1
cmp screen_no,1
je mf_1
mov di,offset filename2
mf_1: mov bx,filespec_ptr
add bx,2
cmp byte ptr [bx+1],':' ;device specified?
mov al,[bx] ;get dev name
je mf_2
dos 19h ;get current drive #
add al,65 ;make a letter of #
mf_2: stosb ;put char in buffer
mov al,':' ;with colon
stosb
dec bx ;bump to $ len
mov dx,bx ;dx=start of $
mov al,[bx] ;get input len
inc bx ;move to $
xor ah,ah ;ax=$ len
add bx,ax ;bx=eo$
mf_loop1:
dec bx
mov al,[bx] ;get char
cmp al,':' ;start of filename?
je mf_sos
cmp al,'\'
je mf_sos
dec bx
cmp bx,dx ;start of $?
je mf_sos
inc bx
inc cx
jmp mf_loop1
mf_sos: inc cx
inc cx
inc bx
loop mf_loop2
jmp short mf_exit
mf_loop2:
mov al,[bx]
stosb
inc bx
loop mf_loop2
mf_exit:
mov al,0 ;terminate $
stosb
pop di
pop si
pop dx
pop cx
pop bx
pop ax
popf
ret
adjust:
mov dl,max_col
mov dh,cur_line
adjust_loop:
dec dl
cmp dl,255
jz adjust_end
mov ah,2
mov bh,screen_page
int 10h ;set cur_pos
mov ah,8
mov bh,screen_page
int 10h
and ah,16+32+64 ;background attrib active?
jnz adjust_end
cmp al,0 ;foreground nil?
je adjust_loopB
cmp al,255
je adjust_loopB
cmp al,32
je adjust_loopB
adjust_end:
inc dl
mov max_col,dl
A_ret:
ret
adjust_loopB:
and ah,7*16 ;test for background color on.
jz adjust_loop
jmp adjust_end
write_spaces:
cmp space_count,6 ;more than 5 spaces queued?
jc WS_no ;no
push ax
push dx
mov byte ptr [bp],esc
inc bp
mov byte ptr [bp],'['
inc bp
mov al,space_count
mov ah,0
mov dl,10
div dl
or al,al
jz WS_skip_1st
add al,48 ;make ASCII #
mov [bp],al
inc bp
WS_skip_1st:
add ah,48
mov byte ptr [bp],ah
inc bp
mov byte ptr [bp],'C'
inc bp
mov space_count,0
pop dx
pop ax
ret
WS_no: push cx
push ax
mov al,32
mov cl,space_count
xor ch,ch
jcxz WS_1_ret
WS_1: mov [bp],al
inc bp
loop WS_1
mov space_count,0
WS_1_ret:
pop ax
pop cx
Another_return:
ret
FA_1: test space_count,255 ;any spaces queued?
jnz FA_2
test ah,16+32+64 ;background 0?
jnz FA_1b
FA_2: push ax
mov al,attrib
and al,240-128 ;mask all but background
and ah,240-128
cmp al,ah ;are they the same
pop ax ;restore c/a
jne FA_1_no_leave
inc space_count
jmp A_ret_2 ;return w/o writing
FA_1_no_leave:
call write_spaces
test ah,70h ;background=0?
mov space_count,1
jz FA_1c
mov space_count,0
jmp FA_1b
A_ret_2:
pop bp
jmp A_ret_3
fix_attrib:
mov write,yes
cmp save_attribs,no ;return if not using ANSI chars
je another_return
push dx
push cx
push bx
push ax ;save c/a
mov bp,offset buffer
push bp
mov write,no
cmp al,32 ;is char a space?
je FA_1 ;yes, go process
test space_count,255 ;are spaces queued?
jz FA_1b
call write_spaces
FA_1b: mov write,yes
FA_1c: cmp ah,attrib
je FA_save
mov byte ptr [bp],esc
inc bp
mov byte ptr [bp],'['
inc bp
mov attrib,ah
mov byte ptr [bp],'0'
inc bp
mov byte ptr [bp],';'
inc bp
mov byte ptr [bp],'3'
inc bp
and ah,7
call xlat_colors
add ah,30h ;make decimal
mov byte ptr [bp],ah
inc bp
mov byte ptr [bp],';'
inc bp
test attrib,16+32+64 ;background set?
jz no_background
mov byte ptr [bp],'4'
inc bp
mov ah,attrib
mov cl,4
ror ah,cl
and ah,7
call xlat_colors
add ah,30h
mov byte ptr [bp],ah
inc bp
mov byte ptr [bp],';'
inc bp
no_background:
test attrib,8
jz no_intensity
mov byte ptr [bp],'1'
inc bp
mov byte ptr [bp],';'
inc bp
no_intensity:
test attrib,128
jz no_blinking
mov byte ptr [bp],'5'
inc bp
inc bp
no_blinking:
dec bp
mov byte ptr [bp],'m'
inc bp
FA_save:
pop cx
push cx ;save pointer to buffer
xchg cx,bp
sub cx,bp
pop bp ;restore ptr
jcxz A_ret_3
mov dx,offset buffer
mov ah,40h
mov bx,handle
int 21h
A_ret_3:
pop ax
pop bx
pop cx
pop dx
ret
colors db 0,4,2,6,1,5,3,7
Xlat_Colors:
push bx
push ax
mov al,ah
mov bx,offset colors
xlat colors
pop bx
mov ah,al
mov al,bl
pop bx
ret
color_list db esc,'[24;1f'
db esc,'[0;30;5;47mB',esc,'[0;30;47mlack' ;Black
db esc,'[0;34;1;40m b',esc,'[0;34;1;5mL',esc,'[0;34;1mue ' ;bLue
db esc,'[0;32;1;5;40mG',esc,'[0;32;1mreen ' ;Green
db esc,'[0;36;1;5;40mC',esc,'[0;36;1myan ' ;Cyan
db esc,'[0;31;1;5;40mR',esc,'[0;31;1med ' ;Red
db esc,'[0;35;1;5;40mM',esc,'[0;35;1magenta ' ;Magenta
db esc,'[0;33;1;5;40mY',esc,'[0;33;1mellow ' ;Yellow
db esc,'[0;37;1;5;40mW',esc,'[0;37;1mhite ' ;White
db '$'
colors_table db 9, 'BLGCRMYW',ESC
color_fore_back db esc,'[24;1fForeground or Background (f/b)? $'
color_blinking_mess db esc,'[24;1fBlinking (y/n)? $'
color_int_mess db esc,'[24;1fBright (y/n)? $'
save_prompt2 db esc,'[24;1fAnnex "Clear-Screen" to file (y/n)? ',esc,'[K$'
save_prompt3 db esc,'[24;1fSave with ANSI ESCape sequences (y/n)? ',esc,'[K$'
cls_file db esc,'[2J'
len_cls_file=4
replace_mess1 db esc,'[24;1fReplace what char? $'
replace_mess2 db esc,'[24;1fReplace with what? $'
replace_mess3 db esc,'[24;1fReplace $'
replace_mess3b db esc,'[C with $'
replace_mess3c db esc,'[C (y/n)? $'
char_to_replace db ?
char_with_which_to_replace db ?
outchr: push bx
push ax
push cx
mov bh,0
mov bl,attrib
mov cx,1
mov ah,9
int 10h
pop cx
pop ax
pop bx
ret
cmdr_esc:
ret
cmd_R:
mov dx,offset replace_mess1
dos 9
cr_1a: wait_for_key ;go get key from BIOS
cmp al,esc ;esc from routine
je cmdr_esc
cmp al,32
jc cr_1a
mov char_to_replace,al
mov dx,offset replace_mess2
dos 9
CR_1: wait_for_key
cmp al,esc
je cmdr_esc
cmp al,32
jc CR_1
mov char_with_which_to_replace,al
mov dx,offset replace_mess3
dos 9
mov al,char_to_replace
call outchr
mov dx,offset replace_mess3b
dos 9
mov al,char_with_which_to_replace
call outchr
mov dx,offset replace_mess3c
dos 9
CR_2: wait_for_key
call capit_al
cmp al,'N'
je CR_exit
cmp al,'Y'
jne CR_2
call replacement_routine
cr_exit:
ret
replacement_routine:
mov dx,0 ;screen pos
CR_3: mov bh,0
mov ah,2
int 10h ;set curpos
mov ah,8 ;read char
int 10h
cmp al,char_to_replace
jne CR_4
mov al,char_with_which_to_replace
mov bl,ah
mov cx,1
mov ah,9
int 10h ;write replacement char
CR_4: inc dl ;next column
cmp dl,79 ;last one?
jne CR_3 ;loop until done
mov dl,0
inc dh
cmp dh,22 ;last line?
jne cr_3
ret
graphics_prompt db esc,'[24;1fReplace IBM graphic with others (y/n)? $'
CG_try2_mess db esc,'[24;1fReplace all ASCII codes >128 with spaces (y/n)? $'
cmd_g:
mov dx,offset graphics_prompt
dos 9
cg_1: wait_for_key
call capit_al
cmp al,esc
je cg_exit
cmp al,'N'
je cg_try2
cmp al,'Y'
jne cg_1
mov dx,0
mov bh,0
CG_2: mov ah,2
int 10h
mov ah,8
int 10h
cmp al,128
jc CG_3
mov bl,ah ;xfer attrib
push bx
mov bx,offset ibm_list
mov ah,0
sub al,128
add bx,ax
mov al,[bx] ;get replacement char
pop bx
mov cx,1
mov ah,9
int 10h ;write new char out
CG_3: inc dl
cmp dl,79
jne CG_2
mov dl,0
inc dh
cmp dh,22
jne cg_2
CG_exit:
ret
CG_try2:
mov dx,offset CG_try2_mess
dos 9
CG_4: getkey
jz CG_4
call capit_al
cmp al,'N'
je CG_exit
cmp al,esc
je CG_exit
cmp al,'Y'
jne CG_4
mov dx,0
mov bh,0
CG_5: mov ah,2
int 10h
mov ah,8
int 10h
cmp al,128
jc CG_6
mov bl,ah
mov al,32
mov cx,1
mov ah,9
int 10h
CG_6: inc dl
cmp dl,79
jne CG_5
mov dl,0
inc dh
cmp dh,22
jne CG_5
jmp CG_exit
ibm_list db 'CueaaaaceeeiiiAAEaAooouuyOU$$$$$aiounN ?[] !""@@@'
db '|++++++|+++++++++-++++++++-+++++++++++++'
db '@@@@@', 255-224+1 dup(32)
cmd_U:
call restore_screen
ret
cmd_C:
mov dx,offset color_fore_back
call print_cs
CC_1: getkey
jz cc_1
or al,al
jz cc_1
call capit_al
cmp al,27
je cc_ret
cmp al,'F'
mov cl,0 ;rotate no bits.
je cc_get_color
cmp al,'B'
mov cl,4
je cc_get_color
jmp cc_1
cc_ret: ret
cc_get_color:
mov rotate,cl ;save distance to rotate
mov dx,offset color_list
call print_cs
cc_2: getkey
jz cc_2
or al,al
jz cc_2
search colors_table,ax
JNE CC_2
CMP AH,9
JZ CC_RET
dec ah ;make a color
mov cl,rotate
rol ah,cl ;set for attrib pos
mov al,attrib
mov dl,7 ;a mask
rol dl,cl ;pos it
or al,dl
xor al,dl ;remove unwanted bits
or al,ah ;put in new bits
mov attrib,al
or cl,cl ;doing foreground?
jnz cc_ret ;no, skip other questions
and al,7+7*16 ;eliminate blink+intensity bits
mov attrib,al
mov dx,offset color_int_mess
call print_cs
cc_3: getkey
jz cc_3
or al,al
jz cc_3
call capit_al
cmp al,esc
jz cc_ret
cmp al,'N'
jz cc_4
cmp al,'Y'
jne cc_3
or attrib,8
cc_4: mov dx,offset color_blinking_mess
call print_cs
cc_5: getkey
jz cc_5
or al,al
jz cc_5
call capit_al
cmp al,esc
jz cc_ret2
cmp al,'N'
jz cc_ret2
cmp al,'Y'
jne cc_5
or attrib,128
cc_ret2:
ret
CS_error:
jmp Save_error
cmd_S:
mov create,255
mov dx,offset save_prompt
call get_filespec
jc CS_error
mov handle,ax
mov attrib,7 ;set attrib to default
mov cur_line,21
mov dx,offset save_prompt2
mov ah,9
int 21h
CS_p2: wait_for_key ;read char
cmp al,esc ;don't save?
je CS_error
call capit_al
cmp al,'Y' ;clear screen at start?
jne CS_p1
mov bx,handle
mov dx,offset cls_file
mov cx,len_cls_file
dos 40h ;write into file
jmp CS_a1 ;go on and check for saving attribs
CS_p1: cmp al,'N'
jne CS_p2
CS_a1: mov dx,offset save_prompt3
dos 9
cs_a2: wait_for_key
cmp al,esc
je CS_error
call capit_al
cmp al,'Y'
jne CS_a3
mov save_attribs,yes
jmp save_start
CS_a3: cmp al,'N'
jne cs_a2
mov save_attribs,no
save_start:
cmp cur_line,0FFh ;-1? (past top of screen?)
jnz ss_1
jmp nothing_to_save
ss_1: mov max_col,79
call adjust
dec cur_line
cmp max_col,0
jz save_start
mov al,cur_line
inc al
inc al
mov max_line,al
mov cur_line,0
Save_loop:
mov max_col,79
mov cur_col,0
call adjust
inc max_col
mov cl,max_col
mov ch,0
mov space_count,0
mov write,yes
push cx
Save_line:
pop cx
dec cx
jcxz Save_line_done
push cx
mov dl,cur_col
mov dh,cur_line
mov bh,screen_page
mov ah,2
int 10h
mov ah,8
int 10h ;get c/a from screen
call fix_attrib
cmp write,no ;should we write this char?
je sl_1
mov byte ptr [buffer],al
mov cx,1
mov dx,offset buffer
mov ah,40h
mov bx,handle
int 21h ;write chr to file
SL_1: inc cur_col
jmp Save_line
Save_line_done:
inc cur_line
mov dx,offset crlf
mov cx,2
mov bx,handle
mov ah,40h
int 21h
mov al,cur_line
cmp al,max_line
jz Save_done
jmp Save_loop
Save_done:
Nothing_to_save:
mov dx,offset ctrl_z
mov cx,1
mov ah,40h
mov bx,handle
int 21h
jc Save_error
or ax,ax
jz Save_error
call CL_Ended
ret
Save_error:
push ax ;save error
mov dx,offset CS_err_mess
call print_cs
pop ax
call print_ax
mov ah,0Ch
mov al,1
int 21h
jmp CL_ended
print_ax:
push ax
push cx
push dx
push ax
mov cl,4
shr ax,cl
push ax
shr ax,cl
push ax
shr ax,cl
push ax
mov cx,4
printax_1:
pop ax
push cx
and al,15
add al,48 ;make a number
cmp al,'9' ;bigger than number
jbe printax_2
add al,7
printax_2:
mov dl,al
dos 2 ;output char
pop cx
loop printax_1
pop dx
pop cx
pop ax
ret
cmd_L:
mov create,0
mov dx,offset CL_prompt
call get_filespec
jc CL_error_2
mov handle,ax
mov dx,offset home
call print_cs
CL_loop:
mov bx,handle
mov ah,3Fh
mov cx,1
mov dx,offset buffer
int 21h
jc CL_Error
or ax,ax
jz CL_Ended
mov dl,byte ptr [buffer]
cmp dl,26 ;^Z terminating?
jz CL_Ended
mov ah,2
int 21h
jmp CL_loop
CL_Ended:
push ax
mov bx,handle
cmp bx,4
jbe CLe_1 ;go if system handle
mov ah,3Eh
int 21h ;close file
CLe_1: pop ax
ret
CL_Error:
call CL_ended ;close file
CL_error_2:
push ax
mov dx,offset CL_err_mess
call print_cs
pop ax
call print_ax
mov ah,0Ch
mov al,1
int 21h
ret
cmd_Q:
mov dx,offset quit_prompt
call print_cs
quit_loop:
getkey
jz quit_loop
or al,al
jz quit_loop
call capit_al
cmp al,'N'
je quit_end
cmp al,esc
je quit_end
cmp al,'Y'
jne quit_loop
pop ax
stc
ret
quit_end:
ret
cmd_M:
ret
cmd_W:
mov dx,offset wipe_prompt_1
call print_cs
wl_1: getkey
jz wl_1
or al,al
jz wl_1
call capit_al
cmp al,esc ;ESC key hit?
jz wipe_end
mov dx,00FFh ;attribs?
mov cx,0700h
cmp al,'A'
jz wl_2
mov dx,0FF00h ;text
mov cx,0020h
cmp al,'T'
jz wl_2
mov dx,0000 ;both
mov cx,0720h
cmp al,'B'
jnz wl_1
wl_2: push dx
push cx
mov dx,offset wipe_prompt_2
call print_cs
wipe_loop:
getkey
jz wipe_loop
or al,al
jz wipe_loop
call capit_al
cmp al,'N'
je wipe_end
cmp al,esc
je wipe_end
cmp al,'Y'
jne wipe_loop
pop di
pop si
mov dx,0 ;new cursor pos
mov bh,screen_page
cls2: mov ah,2 ;set curpos
int 10h
mov ah,8 ;read c/a
int 10h
and ax,si ;clear unwanted part
or ax,di ;move in new replacement
mov bl,ah
mov cx,1
mov ah,9
int 10h ;write new c/a
inc dl
cmp dl,79
jne cls2
mov dl,0
inc dh
cmp dh,22
jne cls2
mov cursor,0
mov attrib,7
wipe_end:
ret
cmd_esc:
clc
pop ax
call restore_cur
ret
mode_cmd_status_line:
call display_ctrls
mode_cmd:
mov dx,offset command_prompt
call print_cs
MC_key_loop:
getkey
jz MC_key_loop
search cmd_key,ax
jne MC_key_loop
mov cmd_cmd,ah
jump cmd_table,ah
mov ah,cmd_cmd
cmp ah,4
je mode_cmd_status_line
cmp ah,5
je mode_cmd_status_line
cmp ah,6
je mode_cmd_status_line
cmp ah,9
je mode_cmd_status_line
jmp mode_cmd
status_line_1 db esc,'[23;1f',esc,'[0;40;33;7mtDoodle 1.20 '
db 'Mode: $'
status_line_2 db 'Current Color$'
status_line_3 db esc,'[K',esc,'[0m',13,10,esc,'[K$'
status_line_4 db 'Paint $'
status_line_5 db 'Text $'
status_line_6 db 'Both $'
status_line_10 db esc,'[0;40;33;7m File-- $'
status_line_help db esc,'[25;1H'
db esc,'[0;1m1',esc,'[0;7mBox '
db esc,'[0;1m 2',esc,'[0;7mGetClr'
db esc,'[0;1m 3',esc,'[0;7mRevers'
db esc,'[0;1m 4',esc,'[0;7mMode '
db esc,'[0;1m 5',esc,'[0;7mSayClr'
db esc,'[0;1m 6',esc,'[0;7mFlip '
db esc,'[0;1m 7',esc,'[0;7mCut '
db esc,'[0;1m 8',esc,'[0;7mPaste '
db esc,'[0;1m 9',esc,'[0;7mUndo '
db esc,'[0;1m 0',esc,'[0;7mASCII '
db esc,'[0m$'
display_ctrls:
push bx
push cursor
call save_cur
mov dx,offset status_line_1
call print_cs
mov al,'S'
call alt_modes
cmp al,'S'
jnz DC_1
mov al,'T'
DC_1: mov dl,al
mov ah,02
int 21h
mov dl,' '
dos 2
mov ah,mode
mov cl,5
ror ah,cl
mov dx,offset status_line_6
and ah,3
jz DC_2
mov dx,offset status_line_4
dec ah
jz DC_2
mov dx,offset status_line_5
DC_2: call print_cs
mov handle,0 ;con:
mov ah,attrib
push ax
mov ah,0 ;force attrib change
call fix_attrib
pop ax
call fix_attrib
mov dx,offset status_line_2
call print_cs
mov dx,offset status_line_10
dos 9
mov bx,offset filename1 ;print filename
cmp screen_no,1
je DC_3
mov bx,offset filename2
DC_3: mov dl,[bx] ;get file char
or dl,dl ;eos?
je DC_4
dos 2 ;output char
inc bx ;bump to next char
jmp DC_3
dc_4: mov dx,offset status_line_3
dos 9
mov dx,offset status_line_help
mov ah,9
int 21h ;print mess w/no crlf
call restore_cur
pop cursor
pop bx
ret
ascii_table_data label byte
db esc,'[H'
db 27,91,48,59,51,50,109,201,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,187,13,10,186,32,27,91,48,59,51,54,59
db 49,109,49,50,56,32,128,32,32,49,52,52,32,144,32,32,49,54,48
db 32,160,32,32,49,55,54,32,176,32,32,49,57,50,32,192,32,32,50
db 48,56,32,208,32,32,50,50,52,32,224,32,32,50,52,48,32,240,32
db 27,91,48,59,51,50,109,186,13,10,186,32,27,91,48,59,51,51,109
db 49,50,57,32,129,32,32,49,52,53,32,145,32,32,49,54,49,32,161
db 32,32,49,55,55,32,177,32,32,49,57,51,32,193,32,32,50,48,57
db 32,209,32,32,50,50,53,32,225,32,32,50,52,49,32,241,32,27,91
db 48,59,51,50,109,186,13,10,186,32,27,91,48,59,51,54,59,49,109
db 49,51,48,32,130,32,32,49,52,54,32,146,32,32,49,54,50,32,162
db 32,32,49,55,56,32,178,32,32,49,57,52,32,194,32,32,50,49,48
db 32,210,32,32,50,50,54,32,226,32,32,50,52,50,32,242,32,27,91
db 48,59,51,50,109,186,13,10,186,32,27,91,48,59,51,51,109,49,51
db 49,32,131,32,32,49,52,55,32,147,32,32,49,54,51,32,163,32,32
db 49,55,57,32,179,32,32,49,57,53,32,195,32,32,50,49,49,32,211
db 32,32,50,50,55,32,227,32,32,50,52,51,32,243,32,27,91,48,59
db 51,50,109,186,13,10,186,32,27,91,48,59,51,54,59,49,109,49,51
db 50,32,132,32,32,49,52,56,32,148,32,32,49,54,52,32,164,32,32
db 49,56,48,32,180,32,32,49,57,54,32,196,32,32,50,49,50,32,212
db 32,32,50,50,56,32,228,32,32,50,52,52,32,244,32,27,91,48,59
db 51,50,109,186,13,10,186,32,27,91,48,59,51,51,109,49,51,51,32
db 133,32,32,49,52,57,32,149,32,32,49,54,53,32,165,32,32,49,56
db 49,32,181,32,32,49,57,55,32,197,32,32,50,49,51,32,213,32,32
db 50,50,57,32,229,32,32,50,52,53,32,245,32,27,91,48,59,51,50
db 109,186,13,10,186,32,27,91,48,59,51,54,59,49,109,49,51,52,32
db 134,32,32,49,53,48,32,150,32,32,49,54,54,32,166,32,32,49,56
db 50,32,182,32,32,49,57,56,32,198,32,32,50,49,52,32,214,32,32
db 50,51,48,32,230,32,32,50,52,54,32,246,32,27,91,48,59,51,50
db 109,186,13,10,186,32,27,91,48,59,51,51,109,49,51,53,32,135,32
db 32,49,53,49,32,151,32,32,49,54,55,32,167,32,32,49,56,51,32
db 183,32,32,49,57,57,32,199,32,32,50,49,53,32,215,32,32,50,51
db 49,32,231,32,32,50,52,55,32,247,32,27,91,48,59,51,50,109,186
db 13,10,186,32,27,91,48,59,51,54,59,49,109,49,51,54,32,136,32
db 32,49,53,50,32,152,32,32,49,54,56,32,168,32,32,49,56,52,32
db 184,32,32,50,48,48,32,200,32,32,50,49,54,32,216,32,32,50,51
db 50,32,232,32,32,50,52,56,32,248,32,27,91,48,59,51,50,109,186
db 13,10,186,32,27,91,48,59,51,51,109,49,51,55,32,137,32,32,49
db 53,51,32,153,32,32,49,54,57,32,169,32,32,49,56,53,32,185,32
db 32,50,48,49,32,201,32,32,50,49,55,32,217,32,32,50,51,51,32
db 233,32,32,50,52,57,32,249,32,27,91,48,59,51,50,109,186,13,10
db 186,32,27,91,48,59,51,54,59,49,109,49,51,56,32,138,32,32,49
db 53,52,32,154,32,32,49,55,48,32,170,32,32,49,56,54,32,186,32
db 32,50,48,50,32,202,32,32,50,49,56,32,218,32,32,50,51,52,32
db 234,32,32,50,53,48,32,250,32,27,91,48,59,51,50,109,186,13,10
db 186,32,27,91,48,59,51,51,109,49,51,57,32,139,32,32,49,53,53
db 32,155,32,32,49,55,49,32,171,32,32,49,56,55,32,187,32,32,50
db 48,51,32,203,32,32,50,49,57,32,219,32,32,50,51,53,32,235,32
db 32,50,53,49,32,251,32,27,91,48,59,51,50,109,186,13,10,186,32
db 27,91,48,59,51,54,59,49,109,49,52,48,32,140,32,32,49,53,54
db 32,156,32,32,49,55,50,32,172,32,32,49,56,56,32,188,32,32,50
db 48,52,32,204,32,32,50,50,48,32,220,32,32,50,51,54,32,236,32
db 32,50,53,50,32,252,32,27,91,48,59,51,50,109,186,13,10,186,32
db 27,91,48,59,51,51,109,49,52,49,32,141,32,32,49,53,55,32,157
db 32,32,49,55,51,32,173,32,32,49,56,57,32,189,32,32,50,48,53
db 32,205,32,32,50,50,49,32,221,32,32,50,51,55,32,237,32,32,50
db 53,51,32,253,32,27,91,48,59,51,50,109,186,13,10,186,32,27,91
db 48,59,51,54,59,49,109,49,52,50,32,142,32,32,49,53,56,32,158
db 32,32,49,55,52,32,174,32,32,49,57,48,32,190,32,32,50,48,54
db 32,206,32,32,50,50,50,32,222,32,32,50,51,56,32,238,32,32,50
db 53,52,32,254,32,27,91,48,59,51,50,109,186,13,10,186,32,27,91
db 48,59,51,51,109,49,52,51,32,143,32,32,49,53,57,32,159,32,32
db 49,55,53,32,175,32,32,49,57,49,32,191,32,32,50,48,55,32,207
db 32,32,50,50,51,32,223,32,32,50,51,57,32,239,32,32,50,53,53
db 32,255,32,27,91,48,59,51,50,109,186,13,10,200,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,188,13,10
db 36
screen_buffer_1 label word
db 27,91,50,74,27,91,48,59,51,55,59,49,109,213,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,184,13,10,179
db 27,91,56,67,27,91,48,59,51,54,109,219,223,223,223,223,220,220,27
db 91,50,53,67,223,219,27,91,49,53,67,220,219,32,32,32,32,220,223
db 223,223,223,220,32,220,223,223,223,223,220,32,27,91,48,59,51,55,59
db 49,109,179,13,10,179,32,32,32,27,91,48,59,51,54,109,219,32,32
db 32,32,219,27,91,54,67,223,220,27,91,50,49,67,219,32,32,219,27
db 91,49,54,67,219,27,91,57,67,219,32,219,32,32,32,32,219,32,27
db 91,48,59,51,55,59,49,109,179,13,10,179,32,27,91,48,59,51,54
db 109,220,220,219,220,220,32,32,219,32,32,74,97,110,32,32,219,32,32
db 220,220,220,220,32,32,32,220,220,220,220,32,32,32,220,220,220,220,32
db 219,32,32,219,32,32,32,220,220,220,220,27,91,57,67,219,27,91,57
db 67,219,32,219,32,32,32,32,219,32,27,91,48,59,51,55,59,49,109
db 179,13,10,179,32,32,32,27,91,48,59,51,54,109,219,32,32,32,32
db 219,32,32,32,50,48,32,32,219,32,219,32,32,32,32,219,32,219,32
db 32,32,32,219,32,219,32,32,32,32,223,219,32,32,219,32,32,219,32
db 32,32,32,219,27,91,56,67,219,32,32,32,32,220,223,223,223,223,32
db 32,219,32,32,32,32,219,32,27,91,48,59,51,55,59,49,109,179,13
db 10,179,32,32,32,27,91,48,59,51,53,109,219,32,32,32,32,219,32
db 49,57,56,54,32,32,219,32,219,32,32,32,32,219,32,219,32,32,32
db 32,219,32,219,32,32,32,32,32,219,32,32,219,32,32,219,223,223,223
db 223,223,27,91,56,67,219,32,32,32,32,219,27,91,54,67,219,32,32
db 32,32,219,32,27,91,48,59,51,55,59,49,109,179,13,10,179,32,32
db 32,27,91,48,59,51,49,109,219,32,32,220,32,219,32,32,32,32,220
db 220,223,32,32,219,32,32,32,32,219,32,219,32,32,32,32,219,32,219
db 32,32,32,32,220,219,32,32,219,32,32,219,32,32,32,32,220,27,91
db 56,67,219,32,32,32,32,219,27,91,54,67,219,32,32,32,32,219,32
db 27,91,48,59,51,55,59,49,109,179,13,10,179,32,32,32,32,27,91
db 48,59,51,52,109,223,223,32,32,223,223,223,223,223,27,91,54,67,223
db 223,223,223,32,32,32,223,223,223,223,32,32,32,223,223,223,223,32,223
db 32,223,223,223,32,32,223,223,223,223,27,91,56,67,223,223,223,32,223
db 32,223,223,223,223,223,223,32,32,223,223,223,223,32,32,27,91,48,59
db 51,55,59,49,109,179,13,10,198,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,181,13,10,179,27,91,50,52,67
db 27,91,48,59,51,51,109,84,69,88,84,32,83,67,82,69,69,78,32
db 68,79,79,68,76,73,78,71,32,66,79,65,82,68,27,91,50,55,67
db 27,91,48,59,51,55,59,49,109,179,13,10,179,27,91,49,55,67,27
db 91,48,59,51,51,109,119,114,105,116,116,101,110,32,97,110,100,32,100
db 101,115,105,103,110,101,100,32,98,121,32,27,91,48,59,51,50,109,68
db 97,110,105,101,108,32,69,46,32,66,101,110,110,101,116,116,27,91,49
db 57,67,27,91,48,59,51,55,59,49,109,179,13,10,179,27,91,51,48
db 67,27,91,48,59,51,50,109,80,46,79,46,66,111,120,32,55,56,50
db 48,27,91,51,53,67,27,91,48,59,51,55,59,49,109,179,13,10,179
db 27,91,50,55,67,27,91,48,59,51,50,109,76,97,32,86,101,114,110
db 101,44,32,67,65,32,57,49,55,53,48,27,91,51,50,67,27,91,48
db 59,51,55,59,49,109,179,13,10,179,27,91,55,55,67,179,13,10,179
db 27,91,54,67,27,91,48,59,51,51,109,80,108,101,97,115,101,32,103
db 105,118,101,32,97,32,99,111,112,121,32,116,111,32,97,110,121,111,110
db 101,32,119,104,111,32,119,97,110,116,115,32,111,110,101,46,32,73,102
db 32,121,111,117,32,102,105,110,100,32,105,116,32,117,115,101,102,117,108
db 44,32,32,32,32,32,27,91,48,59,51,55,59,49,109,179,13,10,179
db 32,27,91,48,59,51,51,109,97,32,36,49,50,167,167,32,114,101,103
db 105,115,116,114,97,116,105,111,110,32,102,101,101,32,119,111,117,108,100
db 32,98,101,32,103,114,101,97,116,108,121,32,97,112,112,114,101,99,105
db 97,116,101,100,46,32,73,116,32,119,105,108,108,32,97,108,115,111,32
db 103,101,116,32,121,111,117,32,27,91,48,59,51,55,59,49,109,179,13
db 10,179,27,91,49,50,67,27,91,48,59,51,51,109,105,110,102,111,114
db 109,97,116,105,111,110,32,111,110,32,102,117,116,117,114,101,32,117,112
db 100,97,116,101,115,44,32,102,105,120,101,115,44,32,97,110,100,32,97
db 100,100,105,116,105,111,110,115,46,27,91,49,51,67,27,91,48,59,51
db 55,59,49,109,179,13,10,179,32,32,32,32,32,27,91,48,59,51,50
db 109,89,111,117,32,99,97,110,32,103,101,116,32,116,104,101,32,108,97
db 116,101,115,116,32,118,101,114,115,105,111,110,32,111,102,32,116,68,111
db 111,100,108,101,32,102,114,111,109,32,76,97,32,86,101,114,110,101,32
db 38,32,80,67,32,83,116,114,101,101,116,32,32,32,32,32,27,91,48
db 59,51,55,59,49,109,179,13,10,179,27,91,49,53,67,27,91,48,59
db 51,50,109,66,66,83,46,32,32,67,97,108,108,32,50,52,32,72,111
db 117,114,115,32,97,116,32,56,44,110,44,49,46,32,32,27,91,48,59
db 51,50,59,49,109,55,49,52,45,53,57,54,45,48,48,56,52,27,91
db 49,57,67,27,91,48,59,51,55,59,49,109,179,13,10,179,32,32,32
db 32,32,27,91,48,59,51,51,109,70,111,114,32,105,110,115,116,114,117
db 99,116,105,111,110,115,32,111,110,32,117,115,101,44,32,112,108,101,97
db 115,101,32,101,120,105,116,32,40,27,91,48,59,51,52,59,49,109,69
db 83,67,32,81,32,89,27,91,48,59,51,51,109,41,32,97,110,100,32
db 114,101,97,100,32,27,91,48,59,51,52,59,49,109,116,68,111,111,100
db 108,101,46,84,120,116,32,32,32,32,32,27,91,48,59,51,55,59,49
db 109,179,13,10,212,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205
db 205,205,205,205,205,205,190,13,10,27,91,50,52,67,27,91,48,59,51
db 49,59,49,59,53,109,83,116,114,105,107,101,32,97,110,121,32,107,101
db 121,32,116,111,32,99,111,110,116,105,110,117,101,46,46,46,13,10
org $+1760*2+2
screen_buffer_2 label word
org $+1760*2+2
paste_buffer label byte
org $+1760*2+2
end_of_code label byte
cseg ends
end start