2000 ; PACKTOR Split screen RTTY/Packet/Amtor program ; Written entirely in A86 assembler ; by Mats Petersson SM5SXL ; ;************* FOSSIL version ************* DATA SEGMENT ORG 04000 pag db ? c_crdn dw ? m_crdn dw ? row_lim db ? win_y db ? c_flag db ? bkflag db ? fos_flag db ? cap_seg dw ? cap_offs dw ? f_hand dw ? f_hand2 dw ? color db ? com_port dw ? old_port dw ? bps db ? parity db ? stopb db ? wordlen db ? com_ndx dw ? bps_ndx dw ? par_ndx dw ? stop_ndx dw ? word_ndx dw ? v_buffer: db 4000 dup ? green db 0 blue db 0 red db 0 color_nmb db 0 DATA ENDS jmp main stackspace db 512 dup 0 newstack: db 0 cap_flag db 0 bufw_flag db 0 asc_flag db 0 scr_adr dd 0b800:00000 border: db 80*2 dup 020 ;Make border out of spaces b_len equ $-border stripe: db 79 dup 020 ;Make stripe out of spaces s_len equ $-stripe shadow: db 79 dup 223 shad_len equ $-shadow hdrtxt1: db ' * * * P A C K T O R * * * ' len1 equ $-hdrtxt1 hdrtxt2: db ' Amateur Radio Terminal Program v1.0 ' len2 equ $-hdrtxt2 time_str: db 'Time: ' time_len equ $-time_str main: mov fos_flag,0 call read_setup jnc >l1 mov com_port,01H ;If no setup file exists, mov bps,10100000xB ;default to COM1,2400,N,8,1 mov parity,00000000xB mov stopb,00000000xB mov wordlen,00000011xB mov com_ndx,0 mov bps_ndx,21 mov par_ndx,0 mov stop_ndx,0 mov word_ndx,9 l1: call com_xinit ;Initialize com port mov ax,0 by 3 ;Set text mode int 10H mov green,020 ;Customize colors mov red,00 mov blue,00 mov color_nmb,2 ;Color reg 2 call set_color mov green,0 mov red,0 mov blue,020 mov color_nmb,3 ;Color reg 3 call set_color call break_dis ;disable Ctrl-Break mov sp,newstack ;New stack pointer mov ah,4aH ;Mshrink mov bx,65535/16 ;Bytes left for program int 21H mov ah,48H ;Malloc mov bx,65535/16 int 21H mov cap_seg,ax ;Pointer to allocated segment mov cap_offs,0 mov ah,0fH ;Return Video State int 10H mov pag,bh ;Save Active Page mov ah,05H ;Select Page mov al,pag int 10H call clrscr ;Clear screen mov bl,17H ;Attribute (foreground & background color) mov cx,b_len ;Length of string mov dx,0 by 0 ;Row,column mov si,border ;Pointer to string call str_write mov dx,0 by 79 call setcur mov ax,09H by 220 ;Endshadow1 mov bh,pag mov bl,07H mov cx,1 int 10H mov dx,1 by 79 call setcur mov ax,09H by 219 ;Endshadow2 mov bh,pag mov bl,07H mov cx,1 int 10H mov bl,07H ; Show border undershadow mov cx,shad_len mov dx,2 by 1 mov si,shadow call str_write mov bl,17H ;Show middle stripe mov cx,s_len mov dx,18 by 0 mov si,stripe call str_write mov dx,18 by 79 call setcur mov ax,09 by 220 ;End shadow of border mov bh,pag mov bl,07H mov cx,1 int 10H mov bl,07H ;Show stripe shadow mov cx,shad_len mov dx,19 by 1 mov si,shadow call str_write mov bl,1bH ;Show border text 1 mov cx,len1 ;Length of string mov dx,0 by 0 ;Row,column mov si,hdrtxt1 ;Pointer to border text call str_write mov bl,1eH ;Show border text 2 mov cx,len2 ;Length of string mov dx,1 by 0 ;Row,column mov si,hdrtxt2 ;Pointer to border text call str_write mov bl,1eH ;Display "Time: " text mov cx,time_len ;Length of string mov dx,0 by 67 ;Row,column mov si,time_str ;Pointer to text call str_write mov c_crdn,20 by 0 ;Initialize cursor positions mov m_crdn,3 by 0 start: mov dx,c_crdn ;Place cursor in output window call setcur ;while nothing happens mov ah,01H ; Test Keyboard input status int 16H jnz >l1 call modem_inp ; No char, test COM4 port instead call clock_rout ; Check time for update of time string jmp start l1: mov ah,00H ; Get next character in keyboard buffer int 16H xchg ax,dx mov ah,12H ; Get extended shift status int 16H test ah,2 ; Alt key pressed? jz >l1 jmp altkeys l1: xchg ax,dx cmp al,0 jne >l2 cmp ah,59 jl >l2 cmp ah,68 jg >l2 jmp fk_out l2: cmp al,0D ; CR? jne >l3 xor c_flag,1 ; Set flag if CR comes from keyboard l3: call sendch ; (should be treated as CR/LF sequence) jmp start ;l1: cmp ah,75 ; Left arrow pressed? ; jne curr ; jmp curleft ;curr: cmp ah,77 ; Right arrow pressed? ; jne sendch ; jmp curright sendch: push ax mov row_lim,24 mov win_y,20 mov dx,c_crdn ; Use output coordinates call write ; Write character to screen mov c_crdn,dx ; Update coordinates mov c_flag,0 pop ax modem_out: mov dx,com_port ; Send character to Com port mov ah,01H int 14H call modem_inp ret ;------------------------------------------------------------------------- quitprmpt: db 'Are you sure you want to Quit (y,N)? $' quit_string: db 'Thanks for using PACKTOR.',13,10,'$' quit: call hidecur call getscr mov color,04fH call capwin mov dx,12 by 20 call setcur mov ah,09H mov dx,quitprmpt int 21H l1: mov ah,01 int 16H jz l1 mov ah,00H int 16H ;Get character cmp ah,21 ;Scancode 21? (y/Y) je quit_ok call putscr call showcur jmp start quit_ok: call clrscr push es mov es,cap_seg ;Mfree mov ah,49H int 21H pop es cmp fos_flag,1 jne >l1 mov dx,com_port ;Deinstall FOSSIL mov ah,05H int 14H l1: call break_ena ;Restore Ctrl-break interrupt mov ax,0 by 3 ;Set text mode int 10H mov dx,1 by 0 call setcur mov ah,09H mov dx,quit_string int 21H call showcur mov ax,04C00 ; Exit with no error int 21H ; Back to DOS ;-------------------------------------------------------------------------- modem_inp: mov dx,com_port ;get status of com port mov ah,03H int 14H test ah,1 ; Test if Data Ready jnz >l1 ret ; No,return l1: mov dx,com_port mov ah,02H ; read character int 14H test cap_flag,1 jz >l3 push es mov es,cap_seg mov bp,cap_offs es mov b[bp],al inc bp mov cap_offs,bp pop es cmp cap_offs,65035 jnae >l3 test bufw_flag,1 jnz >l3 jmp buf_warn l3: mov row_lim,17 ; Set row limit and upper y value mov win_y,3 mov dx,m_crdn ;Use input cursor call write mov m_crdn,dx ; Update input cursor values ret write: cmp al,07FH jbe no_special cmp al,086H ;† je outchar cmp al,08fH ; je outchar cmp al,084H ;„ je outchar cmp al,08EH ;Ž je outchar cmp al,094H ;” je outchar cmp al,099H ;™ je outchar no_special: cmp al,32 jae outchar cmp al,0dH ;If CR, place cursor column 0 jne >l2 test c_flag,1 ;If CR comes from terminal,go 1 row down jz >l1 ;as if a CR/LF sequence together jmp incrow l1: jmp carriage l2: cmp al,0aH ;If LF, go down one row jne >l3 jmp incrow l3: cmp al,08H ;If BS, take approp 2000 riate action jne >l4 jmp bkspace cmp al,07H jne >l4 jmp outchar l4: ret outchar: call setcur mov ah,0aH ;Write character to screen mov bh,pag ;Page number mov cx,1 ;Number of characters int 10H inc dl ;Advance cursor one column call setcur cmp dl,80 ;Column >80? je incrow ret bkspace: mov bkflag,1 curleft: dec dl ;Column -1 cmp dl,0 jge >l1 inc dl ;If column<0 set column=0 l1: call setcur cmp bkflag,1 je blank ret blank: mov ax,0a by 020 ;Blank out character with space mov bh,pag ;Page number mov cx,1 ;Number of characters int 10H mov bkflag,0 ret ;curright: ; inc col; ; cmp col,80 ; jle >l1 ; dec col ;l1: mov dh,row ; mov dl,col ; call setcur ; ret incrow: inc dh ;Increment row carriage: mov dl,0 ;Set column to 0 call setcur cmp dh,row_lim ;Cursor at row>24? jg scroll ;Yes, scroll window ret scroll: push dx push bp mov ax,06 by 1 ;Clear screen,1 line blanked mov bh,07H ;Attribute mov ch,win_y ;row (y) of upper left corner (save border!) mov cl,0 ;column (x) upper left corner mov dh,row_lim ;row (y) lower right corner mov dl,79 ;column(x) lower right corner int 10H pop bp pop dx mov dh,row_lim ;Put back row to where it should be... mov dl,0 ;And column 0 call setcur ret ;------------------------------------------------------------------------- altkeys: xchg ax,dx cmp ah,104 jb >l1 cmp ah,113 jg >l8 jmp fkeys l1: cmp ah,35 ; Alt-H scancode 0;35 jne >l2 jmp help l2: cmp ah,36 ; Alt-J scancode 0;36 jne >l3 jmp dosjump l3: cmp ah,22 ;Alt-U 0;22 jne >l4 jmp ascii_ul l4: cmp ah,50 ;Alt-M 0;50 jne >l5 jmp comm_set l5: cmp ah,38 ;Alt-L 0;38 jne >l6 jmp capture l6: cmp ah,45 ;Alt-X 0;45 jne >l7 jmp quit l7: cmp ah,31 ;Alt-S 0;31 jne >l8 jmp save_setup l8: jmp start ;--------------------------------------------------------------------------- helpscr: db ' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ' hlplen: db ' ³ <<< HELP SCREEN >>> ³ ' db ' ³ ³ ' db ' ³ ³ ' db ' ³ ³ ' db ' ³ Alt-M Set Comms Parameters ³ ' db ' ³ ³ ' db ' ³ Alt-L Capture buffer On/Off ³ ' db ' ³ ³ ' db ' ³ Alt F1- ³ ' db ' ³ Alt F10 Define Function Keys ³ ' db ' ³ ³ ' db ' ³ Alt-U Send ASCII File Alt-S Save Setup ³ ' db ' ³ ³ ' db ' ³ Alt-J Jump to DOS Alt-X Quit Program ³ ' db ' ³ ³ ' db ' ³ ³ ' db ' ³ ³ ' db ' ³ ESC - Exit Help Screen ³ ' db ' ³ ³ ' db ' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ' capbox: db ' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ' caplen: db ' ³ ³ ' db ' ³ ³ ' db ' ³ ³ ' db ' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ' fkbox: db ' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ' fklen : db ' ³ ³ ' db ' ³ ³ ' db ' ³ ³ ' db ' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ' combox :db ' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ' comlen: db ' ³ COMMS PARAMETERS ³ ' db ' ³ ³ ' db ' ³ ³ ' db ' ³ (C)OM Port : ³ ' db ' ³ ³ ' db ' ³ (B)aud Rate : ³ ' db ' ³ ³ ' db ' ³ (P)arity : ³ ' db ' ³ ³ ' db ' ³ (S)top Bits : ³ ' db ' ³ ³ ' db ' ³ (W)ord Length : ³ ' db ' ³ ³ ' db ' ³ ³ ' db ' ³ ESC - Exit without save CR - Exit with save ³ ' db ' ³ ³ ' db ' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ' ;----------------------------------------------------------------------------- help: call hidecur call getscr mov dx,2 by 2 mov si,helpscr mov cx,21 hlplp: push cx mov bl,6eH mov cx,hlplen-helpscr call str_write inc dh add si,hlplen-helpscr pop cx loop hlplp l1: mov ah,01H ;Check keystroke buffer int 16H jz l1 mov ah,00 ;Get character int 16H cmp al,27 jne l1 call putscr call showcur jmp start ;*************************** Commands **************************** capprompt: db 'Name of Capture File: $' capfbuf: db 31,0 capfname: db 31 dup 0 capclosed: db 'CAPTURE FILE CLOSED$' striptext: db 'Capture On$' stripclr: db ' $' capture: xor cap_flag,1 test cap_flag,1 jz capclose call getscr mov color,05fH call capwin mov dx,12 by 16 call setcur mov ah,09H mov dx,capprompt int 21H mov ah,0AH ;Buffered keyboard input mov dx,capfbuf int 21H mov bp,capfbuf sub dx,dx mov dl,b[bp+1] mov si,dx cmp si,0 jne >l2 xor cap_flag,1 jmp cap_abort l2: mov b[bp+si+2],0 mov ah,03CH ;Create and open capture file mov cx,00000H ;Normal file mov dx,capfname int 21H mov f_hand,ax ;Save file handle call putscr mov dx,18 by 68 call setcur mov bl,09e mov cx,10 call txt_color mov ah,09H mov dx,striptext ;Show message on strip int 21H jmp start capclose: call getscr mov color,05fH call capwin mov dx,12 by 29 call setcur call hidecur mov ah,09H ;Output message mov dx,capclosed int 21H push ds mov ah,040H ;Write buffer to file mov bx,f_hand mov cx,cap_offs mov ds,cap_seg mov dx,000 2000 00 int 21H pop ds mov ah,03eH ;Close capture file mov bx,f_hand int 21H mov ah,00H int 16H call showcur cap_abort: mov bp,capfname mov cap_offs,00000H mov bufw_flag,0 call putscr mov dx,18 by 68 call setcur mov bl,01eH mov cx,1 call txt_color mov ah,09H mov dx,stripclr ;Clear strip int 21H jmp start bufw_text1: db 'Warning! Only 1000 bytes left in buffer!$' bufw_text2: db ' Time to save...$' buf_warn: mov bufw_flag,1 call getscr call capwin mov dx,11 by 20 call setcur mov ah,09H ;Write warning text mov dx,bufw_text1 int 21H mov dx,13 by 20 call setcur mov ah,09H mov dx,bufw_text2 int 21H call delay call putscr jmp start ;-------------------------------------------------------------------------- ascii_text: db 'Upload ASCII filename: $' asc_errtext: db ' ERROR READING FILE $' ascfbuf: db 31,0 ascfname: db 31 dup 0 ascinbuf: db 0 del_counter dw 0 delay_flag db 0 ascii_ul: call getscr mov color,03fH call capwin mov dx,12 by 16 call setcur mov ah,09H mov dx,ascii_text int 21H mov ah,0AH ;Buffered keyboard input mov dx,ascfbuf int 21H mov bp,ascfbuf mov dx,00000H mov dl,b[bp+1] mov si,dx cmp si,0 ;Abort if null string jne >l2 call putscr jmp ascii_abort l2: mov b[bp+si+2],0 ;Put a NULL at the end of string mov ax,03D00H ;Open ASCII text file mov dx,ascfname int 21H jc ascii_error call putscr mov asc_flag,1 mov f_hand2,ax ;Save file handle asc_to_com: test delay_flag,1 jz nodelay inc del_counter cmp del_counter,0fe0 jae >l1 call modem_inp jmp asc_to_com l1: mov delay_flag,0 nodelay: mov ah,03fH ;Read file mov bx,f_hand2 mov cx,1 ;1 byte to read mov dx,ascinbuf int 21H cmp ax,0 ;EOF? je asc_ready sub ax,ax mov si,ascinbuf mov al,b[si] ;Get ASCII character back buffer cmp al,0AH ;Delay at end of line jne >l1 mov del_counter,0 mov delay_flag,1 jmp asc_to_com l1: mov c_flag,1 call sendch jmp asc_to_com asc_ready: mov ah,03eH ;Close ASCII file mov bx,f_hand2 int 21H ascii_abort: mov asc_flag,0 mov c_flag,0 jmp start ascii_error: mov dx,12 by 16 call setcur call hidecur mov ah,09H mov dx,asc_errtext ;Error message int 21H call delay call putscr call showcur jmp ascii_abort ;--------------------------------------------------------------------------- f_buffers: ;Buffers for function key texts db 40,0 db 40 dup 0 db 40,0 db 40 dup 0 db 40,0 db 40 dup 0 db 40,0 db 40 dup 0 db 40,0 db 40 dup 0 db 40,0 db 40 dup 0 db 40,0 db 40 dup 0 db 40,0 db 40 dup 0 db 40,0 db 40 dup 0 db 40,0 db 40 dup 0 fk_prompt: db 'F (E to edit): $' fk_blank: db 40 dup 020,'$' fkeys: push ax call getscr mov color,02eH call fkwin pop ax mov bp,f_buffers mov al,ah and ax,0ff sub al,103 mov bx,fk_prompt mov dl,al cmp dl,0aH jne >l1 mov w[bx+1],03031 jmp >l2 l1: mov dl,al and dl,0f add dl,030 mov b[bx+1],dl mov b[bx+2],0 l2: sub al,1 mov dx,42 mul dx add bp,ax mov dx,12 by 7 call setcur mov ah,09H mov dx,fk_prompt int 21H call hidecur mov bl,02fH mov cx,40 call txt_color cmp b[bp+2],0 je >l1 mov cx,bp add cx,2 mov ah,09H mov dx,cx int 21H l1: mov ah,00H int 16H cmp ah,18 ;E scancode je >l2 call showcur jmp fkey_abort l2: mov dx,12 by 24 call setcur mov ah,09H mov dx,fk_blank int 21H mov dx,12 by 24 call setcur call showcur fk_input: mov dl,b[bp+2] push dx mov ah,0AH ;Buffered keyboard input mov dx,bp int 21H sub dx,dx mov dl,b[bp+1] mov si,dx cmp si,0 jne >l1 pop dx mov b[bp+2],dl jmp fkey_abort l1: mov b[bp+si+2],'$' pop dx fkey_abort: call putscr jmp start ;-------------------------------------------------------------------------- fk_out: mov bp,f_buffers mov al,ah and ax,0ff sub al,59 mov dx,42 mul dx add bp,ax add bp,2 mov si,0 cmp b[bp+si],0 je fkout_ready fkoutlp: mov al,b[bp+si] cmp al,'\' jne >l1 cmp b[bp+si+1],'$' jne >l1 mov al,0dH l1: push bp,si,cx mov c_flag,1 call sendch pop cx,si,bp inc si cmp b[bp+si],'$' je fkout_ready jmp fkoutlp fkout_ready: mov c_flag,0 jmp start fkwin: mov dx,10 by 3 mov si,fkbox mov cx,5 fkwinlp: push cx mov bl,color mov cx,fklen-fkbox call str_write inc dh add si,fklen-fkbox pop cx loop fkwinlp ret capwin: mov dx,10 by 12 mov si,capbox mov cx,5 caplp: push cx mov bl,color mov cx,caplen-capbox call str_write inc dh add si,caplen-capbox pop cx loop caplp ret ;---------------------------------------------------------------------------- ; 010 = 300 baud ; 011 = 600 '' ; 100 = 1200 '' ; 101 = 2400 '' ; 110 = 4800 '' ; 111 = 9600 '' ; 000 = 19200 '' (Replaces old 110 baud mask) ; 001 = 38400 '' (Replaces old 150 baud mask) ; The low order 5 bits can be implemented or not by the FOSSIL, but in all ; cases, if the low order bits of AL are 00011, the result should be that ; the communications device should be set to eight data bits, one stop bit ; and no parity. This setting is a MINIMUM REQUIREMENT of Fido, Opus and ; SEAdog. For purposes of completeness, here are the IBM PC "compatible" ; bit settings: ; Bits 4-3 define parity: 0 0 no parity ; 1 0 no parity ; 0 1 odd parity ; 1 1 even parity ; Bit 2 defines stop bits: 0 1 stop bit; ; 1 1.5 bits for 5-bit char; ; 2 for others ; Bits 1-0 character length: 0 0 5 bits ; 0 1 6 bits ; 1 0 7 bits ; 1 1 8 bits com_ptr: db 'COM1$' dw 0 db 'COM2$' dw 1 db 'COM3$' dw 2 db 'COM4$' dw 3 bps_ptr: db '300 $',01000000xB db '600 $',01100000xB db '1200 $',10000000xB db '2400 $',10100000xB db '4800 $',11000000xB db '9600 $',11100000xB db '19200$',00000000xB db '38400$',00100000xB par_ptr: db 'None$',00000000xB db 'Even$',00011000xB db 'Odd $',00001000xB stop_ptr:db '1$',00000000xB db '2$',00000100xB word_ptr:db '5$',00000000xB db '6$',00000001xB db '7$',00000010xB db '8$',00000011xB comval_save: db 4 dup 0 ;Temporary save space for values ;if ESC pressed in menu comm_set: call hidecur call getscr push com_ndx,bps_ndx,par_ndx,stop_ndx,word_ndx,com_port mov bp,comval_save mov al,bps mov b[bp],al inc bp mov al,parity mov b[bp],al inc bp mov al,stopb mov b[bp],al inc bp mov al,wordlen mov b[bp],al mov dx,3 by 12 mov si,combox mov cx,18 comlp: ;Draw box push cx mov bl,04eH mov cx,comlen-combox call str_write inc dh add si,comlen-combox pop cx loop comlp mov bp,com_ptr ;Output current values mov si,com_ndx mov dx,7 by 41 call setcur call curcom_out mov bp,bps_ptr mov si,bps_ndx mov dx,9 by 41 call setcur call curcom_out mov bp,par_ptr mov si,par_ndx mov dx,11 by 41 cal 2000 l setcur call curcom_out mov bp,stop_ptr mov si,stop_ndx mov dx,13 by 41 call setcur call curcom_out mov bp,word_ptr mov si,word_ndx mov dx,15 by 41 call setcur call curcom_out jmp comset_lp curcom_out: mov bl,04fH mov cx,5 call txt_color newcom_out: add bp,si mov ah,09H mov dx,bp int 21H ret comset_lp: mov ah,00H ;Read key int 16H cmp ah,46 ;Scancode for 'C' key jne bkey mov bp,com_ptr mov si,com_ndx inc si,7 cmp si,28 jne >l1 sub si,si l1: mov com_ndx,si mov dx,7 by 41 call setcur call newcom_out mov ax,w[bp+5] mov com_port,ax jmp comset_lp bkey: cmp ah,48 ;'B' scancode jne pkey mov bp,bps_ptr mov si,bps_ndx inc si,7 cmp si,56 jne >l1 sub si,si l1: mov bps_ndx,si mov dx,9 by 41 call setcur call newcom_out mov al,b[bp+6] mov bps,al jmp comset_lp pkey: cmp ah,25 ;'P' scancode jne skey mov bp,par_ptr mov si,par_ndx inc si,6 cmp si,18 jne >l1 sub si,si l1: mov par_ndx,si mov dx,11 by 41 call setcur call newcom_out mov al,b[bp+5] mov parity,al jmp comset_lp skey: cmp ah,31 ;'S' scancode jne wkey mov bp,stop_ptr mov si,stop_ndx inc si,3 cmp si,6 jne >l1 sub si,si l1: mov stop_ndx,si mov dx,13 by 41 call setcur call newcom_out mov al,b[bp+2] mov stopb,al jmp comset_lp wkey: cmp ah,17 ;'W' scancode jne esckey mov bp,word_ptr mov si,word_ndx inc si,3 cmp si,12 jne >l1 sub si,si l1: mov word_ndx,si mov dx,15 by 41 call setcur call newcom_out mov al,b[bp+2] mov wordlen,al jmp comset_lp esckey: cmp al,27 jne crkey pop com_port,word_ndx,stop_ndx,par_ndx,bps_ndx,com_ndx ;Restore old values mov bp,comval_save mov al,b[bp] mov bps,al inc bp mov al,b[bp] mov parity,al inc bp mov al,b[bp] mov stopb,al inc bp mov al,b[bp] mov wordlen,al jmp com_abort ;Don't initialize com port crkey: cmp al,13 je >l1 jmp comset_lp l1: call com_init com_abort: call putscr call showcur jmp start no_comdriv: db 13,10,'No FOSSIL/MBBIOS/COMBIOS driver installed! Aborted...',13,10,'$' com_init: cmp fos_flag,1 jne >l2 mov dx,old_port ;Begin with deinstalling FOSSIL mov ah,05H ;on the old com port (if FOSSIL driver used) int 14H com_xinit: mov ah,04H ;And install FOSSIL on the new one mov dx,com_port ;(if FOSSIL driver used...) int 14H ;(Also used to check for any COM driver present) cmp ax,1954H jne >l1 mov fos_flag,1 jmp >l2 l1: cmp ax,0AA55H ;If not FOSSIL installed, check for MBBIOS/COMBIOS je >l2 mov ah,09H ; If no driver, output error message... mov dx,no_comdriv int 21H call delay mov ax,04c00 ; And abort program int 21H l2: mov ax,com_port ;Save port for later reference mov old_port,ax sub ax,ax ;Clear AX or al,bps ;Set the right bits in AL or al,parity or al,stopb or al,wordlen mov ah,00H ;Initialize COM port mov dx,com_port int 14H ret ;------------------------------------------------------------------------------ fcb1 : db 40 dup 0 fcb2 : db 40 dup 0 parmblk: dw 0 ; Segment address of environment string dd 0 ; Pointer to command line dd 0 ; Pointer to default FCB to be passed at PSP+5CH dd 0 ; Pointer to default FCB to be passed at PSP+6CH cmdline: db 0 com_spc : db 'COMSPEC=',0 ;Compare string com_val: db 128 dup 0 ;Buffer for COMSPEC value dosjump: call getscr call clrscr push es push ds mov ds,w[02C] ;Fetch environment mov si,0 one_more: es mov di,com_spc l1: ;Compare strings cmpsb je l1 sub si,1 es cmp di,com_spc+9 ;All characters match? je getval ;Yes, fetch value of COMSPEC next: inc si ;Search for next environmental variable ds cmp b[si],0 jne next inc si ds cmp b[si],0 jne one_more getval: movsb ds cmp b[si-1],0 jne getval pop ds mov bp,parmblk mov [bp+2],cmdline mov [bp+4],CS mov [bp+6],fcb1 mov [bp+8],CS mov [bp+10],fcb2 mov [bp+12],CS pop es mov ah,4BH ; EXEC mov al,00H ; Load and Execute mov dx,com_val mov bx,parmblk int 21H call putscr jmp start ;----------------------------------------------------------------------------- sreadname: db 'PACKTOR.SET',0 read_setup: mov ax,03d00 mov dx,sreadname int 21H jnc >l1 ret l1: xchg bx,ax mov ah,03fH ;Read com port number mov cx,2 mov dx,offset com_port int 21H mov ah,03fH ;Read com index mov cx,2 mov dx,offset com_ndx int 21H mov ah,03fH ;Read bps value mov cx,1 mov dx,offset bps int 21H mov ah,03fH ;Read bps index mov cx,2 mov dx,offset bps_ndx int 21H mov ah,03fH ;Read parity value mov cx,1 mov dx,offset parity int 21H mov ah,03fH ;Read parity index mov cx,2 mov dx,offset par_ndx int 21H mov ah,03fH ;Read stopbit value mov cx,1 mov dx,offset stopb int 21H mov ah,03fH ;Read stopbit index mov cx,2 mov dx,offset stop_ndx int 21H mov ah,03fH ;Read word value mov cx,1 mov dx,offset wordlen int 21H mov ah,03fH ;Read word index mov cx,2 mov dx,offset word_ndx int 21H mov ah,03fH ;Read fkey buffers mov cx,420 mov dx,f_buffers int 21H mov ah,03eH ;Close file int 21H clc ;Clear carry flag ret ;---------------------------------------------------------------------------- ssav_prompt: db 'Save Setup filename: $' ssavfbuf: db 31,0 ssavfname: db 31 dup 0 save_setup: call getscr mov color,05fH call capwin mov dx,12 by 16 call setcur mov ah,09H mov dx,ssav_prompt int 21H mov ah,0AH ;Buffered keyboard input mov dx,ssavfbuf int 21H mov bp,ssavfbuf sub dx,dx mov dl,b[bp+1] mov si,dx cmp si,0 jne >l2 jmp ssav_abort l2: mov b[bp+si+2],0 mov ah,03C ;Create and open capture file mov cx,00000H ;Normal file mov dx,ssavfname int 21H xchg bx,ax ;Move file handle to BX mov ah,040H mov cx,2 mov dx,offset com_port ;Save port number int 21H mov ah,040H mov cx,2 mov dx,offset com_ndx ;Save com index int 21H mov ah,040H mov cx,1 mov dx,offset bps ;Save bps value int 21H mov ah,040H mov cx,2 mov dx,offset bps_ndx ;Save bps index int 21H mov ah,040H mov cx,1 mov dx,offset parity ;Save parity value int 21H mov ah,040H mov cx,2 mov dx,offset par_ndx ;Save parity index int 21H mov ah,040H mov cx,1 mov dx,offset stopb ;Save stopbit value int 21H mov ah,040H mov cx,2 mov dx,offset stop_ndx ;Save stopbit index int 21H mov ah,040H mov cx,1 mov dx,offset wordlen ;Save wordlen value int 21H mov ah,040H mov cx,2 mov dx,offset word_ndx ;Save wordlen index int 21H mov ah,040H ;Save fkey buffers mov cx,420 mov dx,f_buffers int 21H mov ah,03eH ;Close file int 21H ssav_abort: call putscr jmp start ;--------------------------------------------------------------------------- delay: mov cx,-2 delay1: push cx mov cx,020 delay2: 1180 loop delay2 pop cx loop delay1 ret tmval_str: db 2 dup 0,':',2 dup 0,'$' old_min db 0ff clock_rout: mov ah,02H ;Read real time clock time int 1aH cmp cl,old_min ;Minutes changed? jne >l1 ret ;No, return l1: mov old_min,cl mov bp,tmval_str mov si,0 mov bl,ch call calc mov bl,cl call calc jmp out_time ;Yes, update time string calc: mov al,bl shr al,4 ;We want the high nibble... and al,0f add al,030 mov b[bp+si],al ;first character inc si mov al,bl and al,0f add al,030 mov b[bp+si],al ;second character inc si inc si ;skip over the ':' ret out_time: mov dx,0 by 73 ;Set cursor call setcur mov bl,01eH mov cx,5 call txt_color mov ah,09H mov dx,tmval_str int 21H ret ;-------------------------------------------------------------------------- getscr: push es push ds mov es,cs mov di,v_buffer lds si,scr_adr mov cx,4000 getlp: movsb loop getlp pop ds pop es ret putscr: push es push ds les di,scr_adr mov ds,cs mov si,v_buffer mov cx,4000 putlp: movsb loop putlp pop ds pop es ret ;------------------------------------------------------------------------- str_write: push dx push es push si les bp,scr_adr sub ax,ax mov al,dh mov dh,160 ;Each row has 160 bytes... mul dh shl dl,1 ;Take attribute bytes in account add al,dl mov di,ax lp: movsb ;First the character... es mov b[bp+di],bl ;then the attribute byte inc di loop lp pop si pop es pop dx ret ;------------------------------------------------------------------------- clrscr: push es les bp,scr_adr mov di,0 mov cx,2000 clr: es mov b[bp+di],0 inc di es mov b[bp+di],07H inc di loop clr pop es ret ;--------------------------------------------------------------------------- hidecur: mov ah,01H ;Hide cursor mov cx,00100110xB by 00000111xB int 10H ret showcur: mov ah,01H ;Hide cursor mov cx,00000110xB by 00000111xB int 10H ret setcur: mov ah,02H mov bh,0 int 10H ret ;------------------------------------------------------------------------- break_adr dd 0000:008C ;Cntrl-Break interrupt adress brkadr_save dw 0 brkseg_save dw 0 ascii_val db 20H break_dis: push es les si,break_adr es mov dx,w[si] ;Save interupt vector mov brkadr_save,dx es mov dx,w[si+2] mov brkseg_save,dx ;Save interrupt segment mov dx,my_break es mov w[si],dx mov dx,cs es mov w[si+2],dx pop es ret break_ena: push es les si,break_adr mov dx,brkadr_save es mov w[si],dx ;Retore irq adress mov dx,brkseg_save es mov w[si+2],dx ;restore irq segment pop es ret my_break: iret set_color: mov ax,010 by 010 ;Set individual DAC register mov ch,green ;ch=green value mov cl,blue ;cl=blue value mov dh,red ;dh=red value mov bh,00H mov bl,color_nmb ;Color number int 10H ret txt_color: mov ax,09 by 020 ;Set color for text mov bh,0 int 10H ret ; ;bios_vecadr dd 0000:0050 ;no_comdriv: db 13,10,'No FOSSIL/MBBIOS/COMBIOS driver present! Aborted...',13,10,'$' ;fossil_chk: ; mov fos_flag,0 ; ; push es ; ; les si,bios_vecadr ; ; mov di,si ; es mov si,w[di] ; es mov es,w[di+2] ; ; es cmp w[si+6],01954H ;FOSSIL driver installed? ; ; jne >l1 ;No, test for COMBIOS/MBBIOS driver ; ; mov fos_flag,1 ; pop es ; ret ;l1: ; mov ah,04H ;Check for MBBIOS/COMBIOS here ; mov dx,00H ; int 14H ; ; cmp ax,0AA55H ; jne >l2 ; ; pop es ; ret ; ;l2: ; mov ah,09H ; mov dx,no_comdriv ;Warning message ; int 21H ; call delay ; ; mov ax,04c00 ; int 21H ; . 0