📄 genercfg.a86
字号:
inc ax
mov es,ax
xor di,di ; ES:DI -> "device" header
mov ax,0FFFFh
mov es:[di],ax
mov es:2[di],ax
call device_insert ; insert device into chain
mov dx,mem_max ; top of available memory
mov cx,mem_current ; base of available memory
sub dx,cx
mov ax,5500h ; AH = version, AL = all internal drives
mov bx,02h ; mount existing container files
call call_preload_entry
xor bx,bx ; complete initialisation (hook
call call_preload_entry ; interrupts etc.)
preload_exit:
push cs ! pop es
ret
func_hidevice: ; HIDEVICE=filename
; Look for /L:r1[,s1][;r2[,s2]] [/S] filename
; Look for SIZE=<hexnumber> filename
mov himem_region,0 ; assume no region supplied
mov himem_size,0 ; and no size
mov di,offset region_opt ; check out /L: region option
call compare
jc hidevice10
call parse_region ; get region and size
jnc hidevice20
xor si,si ; something wrong, give an error
mov dx,offset bad_filename
jmp config_error
hidevice10:
mov di,offset size_opt ; check out SIZE= option
call compare
jc hidevice20 ; if no SIZE= just try to load it
call parse_size ; else get supplied value
hidevice20:
call whitespace ; we may have a '=' lurking
hidevice30:
lodsb ; strip off optional '='
cmp al,'=' ; before the filename
je hidevice30
dec si ; it wasn't a '=' after all
call whitespace
mov ax,himem_size ; get size parameter
cmp ax,6000h ; should we just load low ?
jae func_device
push si
test ax,ax ; have we been given a size ?
jne hidevice40
call size_file ; get requirements from file size
hidevice40:
call himem_setup ; try and find some hi memory
pop si
jc func_device ; if we can't load low
push si
call func_device ; now try and install the device
call himem_cleanup ; clean up our hi memory
pop si
jc func_device ; error loading hi, try low
ret
func_device: ; DEVICE=filename
push si
mov di,offset dev_name ; Copy the Device Filename into a
mov byte ptr [di],0 ; local buffer and zero terminate
call copy_file
pop si ; Restore original SI
jc device_error
push es
push si
mov es,mem_current ; ES points at structure
call BuildHeader
pop si
push si
call FindName ; DS:SI -> leafname
call SetName ; Fill in name info
pop si
pop es
mov ax,mem_current ; Get Current Memory Base
inc ax ; allow a para for a header
mov dev_load_seg,ax ; Setup the Load Address and the
mov dev_reloc_seg,ax ; relocation factor to be applied to
; .EXE device drivers
mov ax,(MS_X_OPEN * 256)+0 ; open file r/o
mov dx,offset dev_name
int DOS_INT
jc device_error
mov bx,ax ; now find out how big the file is
mov ax,(MS_X_LSEEK * 256)+2
xor cx,cx
xor dx,dx ; by seeking to zero bytes from end
int DOS_INT
jc device_error
xchg ax,cx ; save lo byte of length
mov ah,MS_X_CLOSE ; close this file
int DOS_INT
jc device_error
mov ax,cx ; DX:AX file length
or cx,dx ; do we have a zero length file
jz device_error ; if so stop now
mov cl,4
shr ax,cl ; convert file size to para
mov cl,12
shl dx,cl ; ignore > 1 MByte portion
or dx,ax ; dx = file size in para
inc dx ; one for rounding error
add dx,mem_current ; top of area needed for the load
cmp dx,mem_max ; will file fit (really HIDEVICE check)
jb func_device10 ; no, stop now
ret
device_error:
mov error_level,ax ; save error code
mov al,0
mov si,offset dev_name
mov dx,offset bad_filename
jmp config_error
func_device10:
mov ax,(MS_X_EXEC * 256)+3 ; Use the Load Overlay function to
mov bx,offset dev_epb ; Read in and Relocate the Device
mov dx,offset dev_name ; driver
int DOS_INT ;
jc device_error
; mov dosVersion,ax ; set version number
push es
mov ax,mem_current ; Get Current Memory Base
push ax
inc ax ; skip the header
xor di,di ; Address of the first device header
mov es,ax ; in the device chain
if ADDDRV
test es:DH_ATTRIB[di],DA_CHARDEV
jnz f_dev30 ;Character device driver ?
; Can't install block device drivers so output error message and exit.
pop es
pop es
xor al,al
mov si,offset dev_name
mov dx,offset err_block_device
jmp config_error
f_dev30:
endif
call PreloadFixup ; fiddle things for preload
if DOS5
call ProtmanFixup ; fiddle int 12 memory for PROTMAN$
endif
call device_init ; initialise the device drivers
if DOS5
call ProtmanCleanup ; restore int 12 memory after PROTMAN$
endif
mov error_level,ax ; save error code
pop es ; by old EMM386.SYS
mov ax,mem_current
mov es:DMD_LEN,ax ; save memory field
mov ax,es
inc ax
sub es:DMD_LEN,ax
pop es
call PreloadCleanup ; cleanup after ourselves
ret
BuildHeader:
;-----------
; On Entry:
; ES:0 -> header
; On Exit:
; None
;
xor di,di
mov al,'D'
stosb ; ID_FIELD
mov ax,es
inc ax
stosw ; OWNER_FIELD
xor ax,ax
stosb ! stosw ! stosw ; zero rest up to name
ret
FindName:
;--------
; On Entry:
; DS:SI -> pathname of file
; On Exit:
; DS:SI -> final leaf name of file
; CX = length of leaf name
;
mov cx,si ; remember start of leaf
FindName10:
lodsb
cmp al,' ' ; end of the name ?
jbe FindName30
call dbcs_lead ; is it a double byte pair ?
jne FindName20
lodsb ; include the second byte
jmps FindName10
FindName20:
cmp al,'\' ; is it a seperator ?
je FindName
cmp al,'/'
je FindName
jmps FindName10
FindName30:
xchg cx,si ; SI -> start of leaf name
sub cx,si
dec cx ; CX = length
ret
SetName:
;-------
; On Entry:
; DS:SI -> leaf name to update
; ES = DMD to update
; On Exit:
; CX/SI preserved
;
push si
mov di,offset DMD_NAME ; point at the owners name field
SetName10:
lodsb
cmp al,' ' ; end of the name ?
jbe SetName30
call dbcs_lead ; is it a double byte pair ?
jne SetName20
stosb ; copy 1st byte of pair
cmp di,(offset DMD_NAME)+DMD_NAME_LEN
jae SetName30 ; don't overflow if name too long
movsb ; and the second
jmps SetName10
SetName20:
stosb
cmp al,'.' ; discard all following '.'
je SetName30
cmp di,(offset DMD_NAME)+DMD_NAME_LEN
jb SetName10 ; don't overflow if name too long
SetName30:
dec di
xor ax,ax
SetName40:
stosb ; zero the '.'
cmp di,(offset DMD_NAME)+DMD_NAME_LEN
jb SetName40 ; zero the rest of the name
SetName50:
pop si
ret
if DOS5
ROS_MEMORY equ .413h ; main memory on KB
protmanName db 'PROTMAN$'
protmanAdjust dw 0
ProtmanFixup:
;------------
; On Entry:
; ES:DI -> device driver header
; On Exit:
; All regs preserved
;
; fiddle int 12 memory for PROTMAN$
;
push cx
push si
push di
mov cs:protmanAdjust,0 ; assume it's not protman
mov si,offset protmanName
lea di,DH_NAME[di] ; ES:DI -> device driver name
mov cx,8/2
repe cmpsw ; does the name match ?
jne ProtmanFixup10
mov si,mem_max ; SI = top of memory in para
push ds
; xor cx,cx
mov ds,cx
mov cl,10-4
shr si,cl ; convert para to KBytes
mov cx,ds:ROS_MEMORY ; CX = existing top of memory
sub cx,si ; CX = amount to hide
sub ds:ROS_MEMORY,cx ; hide it
pop ds
mov cs:protmanAdjust,cx ; remember how much we hid
ProtmanFixup10:
pop di
pop si
pop cx
ret
ProtmanCleanup:
;--------------
; On Entry:
; None
; On Exit:
; All regs preserved
; restore int 12 memory after PROTMAN$
;
push ds
push ax
xor ax,ax
mov ds,ax
mov ax,cs:protmanAdjust ; normally zero..
add ds:ROS_MEMORY,ax
pop ax
pop ds
ret
endif
;
; The syntax currently supported is "COUNTRY=NNN,[YYY],[FILENAME]"
; where:-
; NNN is a valid country code based on
; the International Dialing Code
;
; YYY is the default CODEPAGE
;
; FILENAME is the location and name of the COUNTRY.SYS
; file containing the extended country info.
;
;
if not ADDDRV
func_country: ; COUNTRY=nnn,[yyy],[filename]
call atoi ; ax = country code
jc f_ctry50 ; check for error
mov country_code,ax ; save the Country Code
call separator ; look for ','
jc f_ctry20
call atoi ; Get the Code Page
jc f_ctry10 ; invalid or non existent code page
mov code_page,ax ; save default Code Page
f_ctry10:
call separator ; look for ','
jc f_ctry20 ; copy the supplied pathname
les bx,drdos_ptr ; Get the internal data area
mov di,es:DRDOS_COUNTRY_FILE[bx]
; ES:DI -> pcmode buffer for name
call copy_file
push cs ; restore ES
pop es
f_ctry20:
call nls_hook ; install our lang support
mov bx, country_code ; bx = country code
mov ah, MS_S_COUNTRY
mov al, 0FFh ; 16 bit country code
mov dx, 0FFFFh ; set country code subfunction
int DOS_INT
jc f_ctry40 ; check for error
mov bx, code_page ; bx = code page
or bx,bx
jz f_ctry30 ; No Code Page Set leave as 437
mov ax, MS_X_SETCP ; set codepage subfunction
int DOS_INT ; to set Current CodePage
f_ctry30:
jmp nls_unhook ; remove our lang support
; ret
f_ctry40:
call nls_unhook ; remove our lang support
f_ctry50:
; Bad or non-existant number in command tail. Display error message.
xor si,si
mov dx, offset bad_country
jmp config_error
func_shell: ; SHELL=filename
mov di,offset shell ; Copy the New Command Name
call copy_file ; into the BIOSINIT buffer
mov al,0 ! stosb ; Terminate the Environment Correctly
jc shell_error
mov di,offset shell_cline+1 ; Now copy the default command
mov al,' ' ! stosb ; into place
mov cx,0 ;
f_sh10:
lodsb ! stosb ; Copy the next Character
inc cx ; Increment the count
cmp al,CR ; Was this the end of string Char
jnz f_sh10 ; No so Repeat
mov shell_cline,cl ; Save Command Length
ret
shell_error:
mov al,CR
mov dx,offset bad_shell
jmp config_error
func_lastdrive: ; LASTDRIVE=d:
call atoi ; are we supplying a decimal number?
jc f_lastdrive10
cmp al,32 ; is it in range ?
jbe f_lastdrive20
lastdrv_error:
xor si,si ; Do not display Failing String
mov dx,offset bad_lastdrive ; and display an error message
jmp config_error
f_lastdrive10:
lodsb ; Get the Option Character
call toupper ; and convert to Upper Case
sub al, 'A' ; al should be between 0..25
jc lastdrv_error
cmp al, 'Z'-'A'
ja lastdrv_error
inc al ; al = number of drives in system
f_lastdrive20:
mov last_drv,al ; remember for later
ret
func_break: ; BREAK=ON/OFF
call check_onoff ; Check for ON or OFF
mov dl,al ; Get value found
jnc set_break ; and check for error
xor si,si ; Do not display Failing String
mov dx, offset bad_break ; Bad or non-existant ON/OFF string
jmp config_error ; in command tail. Display error message.
set_break:
mov ah,MS_S_BREAK ; Set the Default Break Flag
mov al,01 ; Set Sub-Function
int DOS_INT ; Execute function and return
ret
func_numlock: ; NUMLOCK=ON/OFF
call check_onoff ; Check for ON or OFF
jc numlock20
push ds
xor bx,bx
mov ds,bx
mov bx,417h ; DS:BX -> keyboard control
or ds:byte ptr [bx],20h ; set numlock bit
test al,al ; was it numlock on ?
jnz numlock10 ; if not, better clear the bit
and ds:byte ptr [bx],not 20h
numlock10:
pop ds
mov ah,MS_C_STAT ; get console status
int DOS_INT ; (usually int 16 update NUMLOCK state)
numlock20:
ret
func_hibuffers: ; HIBUFFERS=nn[,nn]
or buffersIn,BUFFERS_IN_HMA
; jmp func_buffers
func_buffers: ; BUFFERS=nn[,nn]
call atoi ; AX = # of buffers
jc buffer_error ; check for error
cmp ax,MIN_NUM_BUFFS ; check if less than minimum
jae func_buf1
mov ax,3 ; force to use minimum if less
func_buf1:
cmp ax,MAX_NUM_BUFFS ; check if more than maximum
jbe func_buf2
mov ax,MAX_NUM_BUFFS ; force to use maximum if more
func_buf2:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -