;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ;± ± ;± BAUD.ASP (C) 1991 DATASTORM TECHNOLOGIES, INC. ± ;± ± ;± An ASPECT script file that will change the current baud rate. ± ;± The change will not be reflected on the status line. The new ± ;± baud rate will stay in effect until ALT-P is pressed or Alt-X ± ;± is pressed to exit the program. ± ;± ± ;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± integer base_address, irq, comport integer IER,IIR,LCR,MCR,LSR,MSR integer ier_val,iir_val,lcr_val,mcr_val,lsr_val,msr_val integer anykey, vidseg, rowbytes, choice long baud_rate string msg, envstr integer lo_baud, hi_baud, set_dlab, unset_dlab, divisor ;± ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ± proc main clear 7 ; blank screen curoff ; turn off the cursor set keys on ; process all keys if mono ; set up video segment value vidseg = 0xB000 ; mono base address else vidseg = 0xB800 ; color base address endif rowbytes = $scrncols * 2 ; initialize number of bytes per row call read_port ; get current port settings call read_reg ; read the I/O registers call menu call get_divisor ; call menu routine lo_baud=divisor & 0xFF ; AND divisor with FFh to get low byte hi_baud=divisor>>8 ; SHIFT RIGHT 8 to get high byte set_dlab = lcr_val | 0x80 ; OR current LCR value with 80h outport LCR set_dlab ; OUT new LCR with DLAB set mspause 100 ; wait outport base_address lo_baud ; OUT low byte of baud rate divisor mspause 100 ; wait outport IER hi_baud ; OUT high byte of baud rate divisor mspause 100 ; wait unset_dlab= lcr_val & 0x7F ; AND LCR with 7Fh to turn off DLAB outport LCR unset_dlab ; OUT new LCR with DLAB off clear ; clear screen strfmt msg "BAUDRATE CHANGED TO %ld BAUD" baud_rate call terminate ; cleanup and quit endproc ;± ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ± proc menu_bar intparm row, col, length, attrib integer vidoff, vidlen string vidline vidoff = (row * rowbytes) + (col << 1) ; video offset into VIDSEG vidlen = length << 1 memread vidseg vidoff vidline vidlen length += col - 1 for col upto length ; loop LENGTH number of putvattr row col attrib ; times to write attr. endfor ; characters keyget anykey ; get user's menu choice memwrite vidseg vidoff vidline vidlen endproc ;± ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ± proc menu integer row = 3 ; starting row on screen box 2 30 20 39 79 ; make box for menu ;atsay 1 28 15 "New Line Settings" atsay 3 32 79 " 50" ; atsay 4 32 79 " 75" ; atsay 5 32 79 " 110" ; atsay 6 32 79 " 150" ; atsay 7 32 79 " 300" ; layout menu choices atsay 8 32 79 " 600" ; atsay 9 32 79 " 1200" ; atsay 10 32 79 " 1800" ; atsay 11 32 79 " 2400" ; atsay 12 32 79 " 3600" ; atsay 13 32 79 " 4800" ; atsay 14 32 79 " 7200" ; atsay 15 32 79 " 9600" ; atsay 16 32 79 " 19200" ; atsay 17 32 79 " 38400" ; atsay 18 32 79 " 57600" ; atsay 19 32 79 "115200" ; while 1 ; always true call menu_bar with row 31 8 112 switch anykey ; check the keystroke case 0x50E0 ; grey DOWN arrow case 0x5000 ; keypad DOWN arrow if row == 19 row = 3 else row += 1 endif endcase case 0x48E0 ; grey UP arrow case 0x4800 ; keypad UP arrow if row == 3 row = 19 else row -= 1 endif endcase case 0x0D ; enter key case 0xE00D ; keypad enter choice = row-2 exitwhile endcase case 0x1B ; ESC key msg = "BAUD.ASP aborted!!" call terminate ; cleanup and quit endcase endswitch endwhile endproc ;± ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ± proc read_port ; Note: This procedure reads data integer portnum ; from particular file offsets in integer hi_byte, lo_byte ; PCPLUS.PRM; this practice, long position ; however, is not recommended fetch port portnum ; fopen 0 "PCPLUS.PRM" "rb" ; open PCPLUS.PRM for read only binary if failure ; if not in current directory getenv "PCPLUS" envstr ; check PCPLUS environment variable strlen envstr hi_byte if hi_byte ; if environment variable exists hi_byte-- ; format new path strpeek envstr hi_byte hi_byte if hi_byte != '\' strcat envstr "\" endif strcat envstr "PCPLUS.PRM" endif fopen 0 envstr "rb" ; open PCPLUS.PRM for read only binary if failure ; if still unable to open file clear msg = "Unable to open PCPLUS.PRM" call terminate ; terminate script endif endif position = ((portnum-1) * 2) + 372 ; calculate offset of base address fseek 0 position 0 fgetc 0 lo_byte fgetc 0 hi_byte position = ((portnum-1) * 2) + 388 ; calculate offset of IRQ number fseek 0 position 0 fgetc 0 irq base_address = (hi_byte * 0x100) + lo_byte fclose 0 comport = portnum IER = base_address + 1 IIR = base_address + 2 LCR = base_address + 3 MCR = base_address + 4 LSR = base_address + 5 MSR = base_address + 6 endproc ;± ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ± proc read_reg inport IER ier_val inport IIR iir_val inport LCR lcr_val inport MCR mcr_val inport LSR lsr_val inport MSR msr_val endproc ;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ;± ± ;± ± ;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± proc get_divisor switch choice case 1 divisor= 2304 baud_rate = 50 endcase case 2 divisor= 1536 baud_rate = 75 endcase case 3 divisor= 1047 baud_rate = 110 endcase case 4 divisor= 768 baud_rate = 150 endcase case 5 divisor= 384 baud_rate = 300 endcase case 6 divisor= 192 baud_rate = 600 endcase case 7 divisor= 96 baud_rate = 1200 endcase case 8 divisor= 64 baud_rate = 1800 endcase case 9 divisor= 48 baud_rate = 2400 endcase case 10 divisor= 32 baud_rate = 3600 endcase case 11 divisor= 24 baud_rate = 4800 endcase case 12 divisor= 16 baud_rate = 7200 endcase case 13 divisor= 12 baud_rate = 9600 endcase case 14 divisor= 6 baud_rate = 19200 endcase case 15 divisor= 3 baud_rate = 38400 endcase case 16 divisor= 2 baud_rate = 57600 endcase case 17 divisor= 1 baud_rate = 115200 endcase endswitch endproc ;± ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ± proc terminate clear message msg terminal endproc