Sunteți pe pagina 1din 13

;

; FakeDriv.ASM Copyright (c) 1991-99 Kevin G. Rhoads. All Rights reserved.


;
; This software is provided "as-is".
;
; Distribution is permitted in accordance with the GNU Public License v2.0
; or later. See the file COPYING which should have come with this.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;---------------------------------------------------------------------
; FakeDriv provides "fake" BIOS drive numbers which reflect to actual
; BIOS floppy drive numbers, various disk parameters are set depending
; upon the "fake" number. This allows the use of the DOS DRIVER.SYS
; for alternate format disk support.
;
; Require modification of the "table" depending upon diskette drive
; configuration. This can be accomplished by
; 1) reassembly
; 2) byte-poking with (fer' instance) DEBUG
; table as given is for 5.25" HD drive as A: or B: and 3.5" HD drive as B: or A:
; Table would need changing only to support 720k drives or 360k drives
; (if you have 8" floppies, treat 'em as 5.25 HD)
;
; This loads as a TSR, it avoids multiple loading, and hooks INT 40H
; (optionally INT 13H). If modified to use INT 13H instead of INT 40H
; it is fully DOS 1.x compatible, although to no useful purpose as it
; isn't until DOS 3.2/3.3 that arbitrary configuration of floppies is
; support by MS-DOS(tm)/IBM(tm) DOS. It is DOS 2.x compatible as is,
; but is intended for use in DOS 3.2 or later.
;
; Basically it forces critical floppy parameters to prechosen values
; by indexing into the table of values based on the fake drive number.
; Although DOS "should" deal with non-standard formats, and often does,
; there are times it gets confused and munges the disk parameters.
;
; By using this TSR and DRIVER you can use DOS utilities with non-standard
; floppy formats with greater expectation of success.
;
;---------------------------------------------------------------------
;
;Table Index
;|
;v
; Format/Drive Line to add to CONFIG.SYS Assuming drive A is 5.25 HD (1.2Meg)
;0 1.2M / 1.2M and drive B is 3.5 HD (1.44 Meg)
;1 1.4M / 1.2M device=c:\dos\driver.sys /d:68 /s:17 /t:82
;2 360k / 1.2M
;3 800k / 1.2M device=c:\dos\driver.sys /d:76 /s:10 /t:82
;4 720k / 3.5" or QD device=c:\dos\driver.sys /d:81 /s:09 /t:80 /f:2
; (360k / DD device=c:\dos\driver.sys /d:81 /s:09 /t:40 /f:0 )
;5 800k / 3.5" or QD device=c:\dos\driver.sys /d:85 /s:10 /t:82
; (400k / DD device=c:\dos\driver.sys /d:85 /s:10 /t:42 )
;6 1.44M / 1.44M device=c:\dos\driver.sys /d:89 /s:18 /t:80 /f:7
;7 1.67M / 1.44M device=c:\dos\driver.sys /d:93 /s:20 /t:82
;8 999k / 3.5" or QD device=c:\dos\driver.sys /d:97 /s:12 /t:82
; (500k / DD device=c:\dos\driver.sys /d:97 /s:12 /t:42 )
;9 720k / 1.2M device=c:\dos\driver.sys /d:100/s:09 /t:80 /f:2
; ^
; | Drive number is 64 + 4*table index + 0 for A
; | Drive number is 64 + 4*table index + 1 for B
;---------------------------------------------------------------------

code_seg segment
assume cs:code_seg,ds:nothing,es:nothing
ORG 100H
entry_point proc near
jmp init
even
;olddisk label dword ;saved vector for int 13h
;olddisko dw ?
;olddisks dw ?
altdisk label dword ;saved vector for int 40h
altdisko dw ?
altdisks dw ?
;
established db 00h
;
;number of tracks is 40 for DD and 80 for HD & 3.5" but most DD will do 41 or 42 and most others 82
;
table label near ;format/drive type device assignments for system with A=5.25"HD B=3.5"HD
table0 db 0Fh,54h,05h,1Bh ; 1.2M / 1.2M
table1 db 11h,1Ah,07h,07h ; 1.4M / 1.2M device=c:\dos\driver.sys /d:68 /s:17 /t:82
table2 db 09h,50h,64h,2Ah ; 360k / 1.2M
table3 db 0Ah,1Ah,47h,07h ; 800k / 1.2M device=c:\dos\driver.sys /d:76 /s:10 /t:82
table4 db 09h,50h,83h,2Ah ;*720k / 3.5" or QD device=c:\dos\driver.sys /d:80 /s:09 /t:80 /f:2 *360k / DD device=c:\dos\driver.sys /d:81 /s:09 /t:40 /f:0
table5 db 0Ah,1Ah,87h,07h ;#800k / 3.5" or QD device=c:\dos\driver.sys /d:84 /s:10 /t:82 #400k / DD device=c:\dos\driver.sys /d:85 /s:10 /t:42
table6 db 12h,6Ch,07h,1Bh ;1.44M / 1.44M device=c:\dos\driver.sys /d:88 /s:18 /t:80 /f:7
table7 db 14h,0Ah,07h,03h ;1.67M / 1.44M device=c:\dos\driver.sys /d:92 /s:20 /t:82
table8 db 0ch,1Ah,47h,07h ;!999k / 3.5" or QD device=c:\dos\driver.sys /d:96 /s:12 /t:82 !500k / DD device=c:\dos\driver.sys /d:97 /s:12 /t:42
table9 db 09h,50h,47h,2ah ; 720k / 1.2M device=c:\dos\driver.sys /d:100/s:09 /t:80 /f:2
tablea db 15h,00h,00h,00h ;1.7/ 1.44 device=c:\dos\driver.sys /d:104/s:21 /t:80
tableb db 14h,0Ah,07h,03h ; available | Drive number is 64 + 4*table entry number + 0 for A
tablec db 14h,0Ah,07h,03h ; available | Drive number is 64 + 4*table entry number + 1 for B
tabled db 14h,0Ah,07h,03h ; available ^
tablee db 14h,0Ah,07h,03h ; available | Drive number is 64 + 4*table entry number + 0 for A
tablef db 14h,0Ah,07h,03h ; available | Drive number is 64 + 4*table entry number + 1 for B
;table10 db 14h,0Ah,07h,03h ; available
;table11 db 14h,0Ah,07h,03h ; available
;table12 db 14h,0Ah,07h,03h ; available
;table13 db 14h,0Ah,07h,03h ; available
;table14 db 14h,0Ah,07h,03h ; available
;table15 db 14h,0Ah,07h,03h ; available
;table16 db 14h,0Ah,07h,03h ; available
;table17 db 14h,0Ah,07h,03h ; available
;table18 db 14h,0Ah,07h,03h ; available
;table19 db 14h,0Ah,07h,03h ; available
;table1a db 14h,0Ah,07h,03h ; available
;table1b db 14h,0Ah,07h,03h ; available
;table1c db 14h,0Ah,07h,03h ; available
;table1d db 14h,0Ah,07h,03h ; available
;table1e db 14h,0Ah,07h,03h ; available
;table1f db 14h,0Ah,07h,03h ; available
;
;;
;table label near ;format/drive type device assignments for system with A=5.25"HD B=3.5"HD
;table0 db 0Fh,54h,15h,1Bh ; 1.2M / 1.2M
;table1 db 11h,1Ah,17h,07h ; 1.4M / 1.2M device=c:\dos\driver.sys /d:68 /s:17 /t:82
;table2 db 09h,50h,74h,2Ah ; 360k / 1.2M
;table3 db 0Ah,1Ah,57h,07h ; 800k / 1.2M device=c:\dos\driver.sys /d:76 /s:10 /t:82
;table4 db 09h,50h,93h,2Ah ;*720k / 3.5" or QD device=c:\dos\driver.sys /d:81 /s:09 /t:80 /f:2 *360k / DD device=c:\dos\driver.sys /d:81 /s:09 /t:40 /f:0
;table5 db 0Ah,1Ah,97h,07h ;#800k / 3.5" or QD device=c:\dos\driver.sys /d:85 /s:10 /t:82 #400k / DD device=c:\dos\driver.sys /d:85 /s:10 /t:42
;table6 db 12h,6Ch,17h,1Bh ;1.44M / 1.44M device=c:\dos\driver.sys /d:89 /s:18 /t:80 /f:7
;table7 db 14h,0Ah,17h,03h ;1.67M / 1.44M device=c:\dos\driver.sys /d:93 /s:20 /t:82
;table8 db 0ch,1Ah,57h,07h ;!999k / 3.5" or QD device=c:\dos\driver.sys /d:97 /s:12 /t:82 !500k / DD device=c:\dos\driver.sys /d:97 /s:12 /t:42
;table9 db 09h,50h,57h,2ah ; 720k / 1.2M device=c:\dos\driver.sys /d:100/s:09 /t:80 /f:2
;tablea db 14h,0Ah,17h,03h ; available ^
;tableb db 14h,0Ah,17h,03h ; available | Drive number is 64 + 4*table entry number + 0 for A
;tablec db 14h,0Ah,17h,03h ; available | Drive number is 64 + 4*table entry number + 1 for B
;tabled db 14h,0Ah,17h,03h ; available
;tablee db 14h,0Ah,17h,03h ; available
;tablef db 14h,0Ah,17h,03h ; available
;;table10 db 14h,0Ah,17h,03h ; available
;;table11 db 14h,0Ah,17h,03h ; available
;;table12 db 14h,0Ah,17h,03h ; available
;;table13 db 14h,0Ah,17h,03h ; available
;;table14 db 14h,0Ah,17h,03h ; available
;;table15 db 14h,0Ah,17h,03h ; available
;;table16 db 14h,0Ah,17h,03h ; available
;;table17 db 14h,0Ah,17h,03h ; available
;;table18 db 14h,0Ah,17h,03h ; available
;;table19 db 14h,0Ah,17h,03h ; available
;;table1a db 14h,0Ah,17h,03h ; available
;;table1b db 14h,0Ah,17h,03h ; available
;;table1c db 14h,0Ah,17h,03h ; available
;;table1d db 14h,0Ah,17h,03h ; available
;;table1e db 14h,0Ah,17h,03h ; available
;;table1f db 14h,0Ah,17h,03h ; available
;;
a_save db 0Fh,54h,15h,1Bh ;1.2M
b_save db 12h,6Ch,17h,1Bh ;1.44M
;current_crud db 0Fh,54h,15h,1Bh

;
;
ax_save dw ?
bx_save dw ?
cx_save dw ?
dx_save dw ?
ds_save dw ?
es_save dw ?
si_save dw ?
di_save dw ?
bp_save dw ?
it dw ?
;

install_check:
cmp bx,'Fa'
jne pass_it_on
cmp cx,'ke'
jne pass_it_on
cmp dl,7eh
je toggle_established
cmp dl,7fh
jne pass_it_on
bye_bye_:
mov bx,'fA'
mov cx,'KE'
mov ah,01
stc
db 0caH ;retf 2
dw 2
toggle_established:
mov dl,cs:established
xor dl,10h
mov cs:established,dl
jmp bye_bye_

;
;INT 40H handler
altd label near
mov cs:ax_save,ax
cmp ah,10h
jne pass_it_on
jmp install_check
pass_it_on:
call near ptr test_it
mov ax,cs:ax_save
pushf
call dword ptr altdisk
; pushf
; call near ptr post_process
; popf
db 0caH ;retf 2
dw 2
;
test_it label near
mov cs:dx_save,dx
test dl,80H
jz continue1
db 0c3h ; rets -- is hard drive (shouldn't get here)
continue1 label near
; comment out the next three lines if you want to mess with third and fourth floppies
; as well as first and second
; change jz continue2 to jnz continue2 if you want to do third and fourth floppies
; but not first and second
test dl,02H
jz continue2
db 0c3h ; rets -- physical drives 02 or 03 - we don't mess with
;
continue2 label near
test dl,40H
jnz continue3
db 0c3h ; rets -- hasn't our bit flag in drive number
continue3 label near
and dl,7fH
xor dl,40H
mov cs:dx_save,dx
and dl,01h
xchg cs:dx_save,dx
mov cs:ds_save,ds
mov cs:es_save,es
;have saved - set up addressing
mov ax,0
mov es,ax
assume cs:code_seg,ds:nothing,es:abs0
push cs
pop ds
assume cs:code_seg,ds:code_seg,es:abs0
mov bx_save,bx
mov cx_save,cx
mov si_save,si
mov di_save,di
mov bp_save,bp
and dx,03Ch
add dx,offset table
mov si,dx
;
;now do sectors/track
les bx,dword ptr es:[dskparm]
assume cs:code_seg,ds:code_seg,es:nothing
mov cx,word ptr es:[bx+4]
; mov current_crud,cl
mov cl,byte ptr ds:[si]
mov ch,byte ptr ds:[si+3]
cmp ch,byte ptr ds:[si+1]
jb rw_gap_ok
mov ch,byte ptr ds:[si+1]
shr ch,1
shr ch,1
or ch,01h
rw_gap_ok label near
mov word ptr es:[bx+4],cx
;now do format gap
mov cx,word ptr es:[bx+6]
; mov current_crud[1],ch
mov ch,byte ptr ds:[si+1]
mov cl,0ffH
mov word ptr es:[bx+6],cx
;setup addressing for BIOS DISK STATE MACHINE values
mov ax,40h
mov es,ax
assume cs:code_seg,ds:code_seg,es:bios_data
;set BIOS DISK STATE MACHINE values
mov cx,word ptr es:[90h]
mov ax,dx_save
test al,1
je we_do_a
; mov current_crud[2],ch
and ch,10h
or ch,byte ptr ds:[si+2]
or ch,established
; mov b_save[3],1
jmp dsm_all_done
we_do_a label near
; mov current_crud[2],ch
and cl,10h
or cl,byte ptr ds:[si+2]
or cl,established
; mov a_save[3],1
dsm_all_done label near
mov word ptr es:[90h],cx
; restore and exit
assume cs:code_seg,ds:nothing,es:nothing
restore_and_exit label near
mov es,cs:es_save
mov ds,cs:ds_save
mov bp,cs:bp_save
mov di,cs:di_save
mov si,cs:si_save
mov dx,cs:dx_save
mov cx,cs:cx_save
mov bx,cs:bx_save
db 0c3h ; rets
;
;;
;post_process label near
; mov cs:ds_save,ds
; mov cs:es_save,es
;;have saved - set up addressing
; mov ax,0
; mov es,ax
; assume cs:code_seg,ds:nothing,es:abs0
; push cs
; pop ds
; assume cs:code_seg,ds:code_seg,es:abs0
; mov bx_save,bx
; mov cx_save,cx
; mov si_save,si
; mov di_save,di
; mov bp_save,bp
; mov cx,dx_save
; mov dx_save,dx
; les bx,dword ptr es:[dskparm]
; assume cs:code_seg,ds:code_seg,es:bios_data
; test cl,01
; jz do_a
; jmp do_b
;do_a label near
; test a_save[3],1
; jnz restore_a
;save_a label near
; mov cx,word ptr es:[bx+4]
; mov a_save,cl
; mov cx,word ptr es:[bx+6]
; mov a_save[1],ch
;;setup addressing for BIOS DISK STATE MACHINE values
; mov ax,40h
; mov es,ax
; assume cs:code_seg,ds:code_seg,es:bios_data
;;set BIOS DISK STATE MACHINE values
; mov al,byte ptr es:a_state
; mov a_save[2],al
; jmp restore_and_exit
;;
;restore_a label near
; mov cx,word ptr es:[bx+4]
; mov cl,current_crud
; mov a_save,cl
; mov word ptr es:[bx+4],cx
; mov cx,word ptr es:[bx+6]
; mov ch,current_crud[1]
; mov a_save[1],ch
; mov word ptr es:[bx+6],cx
;;setup addressing for BIOS DISK STATE MACHINE values
; mov ax,40h
; mov es,ax
; assume cs:code_seg,ds:code_seg,es:bios_data
; mov al,current_crud[2]
; mov byte ptr es:a_state,al
; mov a_save[2],al
; mov a_save[3],0
; jmp restore_and_exit
;;
;do_b label near
; test b_save[3],1
; jnz restore_b
;save_b label near
; mov cx,word ptr es:[bx+4]
; mov b_save,cl
; mov cx,word ptr es:[bx+6]
; mov b_save[1],ch
;;setup addressing for BIOS DISK STATE MACHINE values
; mov ax,40h
; mov es,ax
; assume cs:code_seg,ds:code_seg,es:bios_data
;;set BIOS DISK STATE MACHINE values
; mov al,byte ptr es:b_state
; mov b_save[2],al
; jmp restore_and_exit
;;
;restore_b label near
; mov cx,word ptr es:[bx+4]
; mov cl,current_crud
; mov b_save,cl
; mov word ptr es:[bx+4],cx
; mov cx,word ptr es:[bx+6]
; mov ch,current_crud[1]
; mov b_save[1],ch
; mov word ptr es:[bx+6],cx
;;setup addressing for BIOS DISK STATE MACHINE values
; mov ax,40h
; mov es,ax
; assume cs:code_seg,ds:code_seg,es:bios_data
; mov al,current_crud[2]
; mov byte ptr es:b_state,al
; mov b_save[2],al
; mov b_save[3],0
; jmp restore_and_exit
;;
;;
;
;
;
init label near
assume cs:code_seg,ds:code_seg,es:nothing
mov bx,'Fa' ;install check, are we already installed?
mov cx,'ke'
mov dl,7fh
mov ah,10h
int 40h
cmp bx,'fA'
jne can_do_install
cmp cx,'KE'
jne can_do_install
push cs
pop ds
lea dx,id_mess
mov ah,9
int 21h

;
mov bx,'Fa' ;we are already installed
mov cx,'ke' ;toggle established state
mov dl,7eh
mov ah,10h
int 40h
mov ah,9
cmp dl,0
jne is_active
lea dx,is_off
jmp display_status
is_active:
lea dx,is_on
display_status:
int 21h

mov ax,4c01h ;
int 21h ; DOS 2+ Exit
int 20h ; DOS 1.x Exit (So?, I'm paranoid.)

can_do_install:
xor ax,ax
mov es,ax
assume cs:code_seg,ds:code_seg,es:abs0
les di,dword ptr es:[diskalt]
mov word ptr altdisko,di
mov di,es
mov word ptr altdisks,di
mov ax,40h
mov es,ax
assume cs:code_seg,ds:code_seg,es:bios_data
mov ax,es:[90h]
mov a_save[2],al
mov b_save[2],ah
xor ax,ax
mov es,ax
assume cs:code_seg,ds:code_seg,es:abs0
les bx,dword ptr es:[dskparm]
mov cx,word ptr es:[bx+4]
mov a_save,ch
mov b_save,ch
mov cx,word ptr es:[bx+6]
mov a_save[1],cl
mov b_save[1],cl
xor ax,ax
mov es,ax
cli
mov ax,offset altd
mov word ptr es:altoff,ax
mov ax,cs
mov word ptr es:altseg,ax
lea dx,sign_on
mov ah,09
int 21h

mov ah,30h ;DOS 2.0 or higher?


int 21h ; if so close handles 0 .. 4
cmp al,0
je bye_bye ; is DOS 1.x

mov bx,0 ; handle 0


mov ah,3eh ; close
int 21h
mov bx,1 ; handle 1
mov ah,3eh ; close
int 21h
mov bx,2 ; handle 2
mov ah,3eh ; close
int 21h
mov bx,3 ; handle 3
mov ah,3eh ; close
int 21h
mov bx,4 ; handle 4
mov ah,3eh ; close
int 21h

push cs
pop ds
push cs
pop es
assume cs:code_seg,ds:code_seg,es:code_seg
mov di,0081H ;copy an ID mess to command line buffer
mov si,offset id_mess
mov cx,(offset id_end) - (offset id_mess)
mov byte ptr ds:[080H],cl
cld
rep movsb

mov bx,ds:[2Ch] ; get environment seg from PSP


mov es,bx ; and free it
mov ah,49h
int 21h

mov dx,offset init ;get offset


add dx,0Fh ; will convert bytes to paragraphs
shr dx,1 ; so add 15 to avoid truncation
shr dx,1 ; error then divide by 16, implemented
shr dx,1 ; as four successive 1 bit shifts
shr dx,1
mov ax,3100h ; DOS 2.0+ TSR
int 21h

bye_bye label near ; wasn't DOS 2.0+, use INT 27


sti
mov dx,offset init
int 27h
entry_point endp

id_mess label near


db 'FakeDrive - BIOS Extension, Alternate Format Floppies',10d,13d
id_end label near
db 'is ALREADY INSTALLED - INSTALLATION ABORTING '
db 10d,13d,10d,13d,' Copyright (c) 1991-99 Kevin G. Rhoads. All rights reserved.',10d,13d
db ' version 0.011 ',10d,13d
db ' Distributable per GNU Public License v2.0'
db '$'
;id_len equ (offset id_end) - (offset id_mess)
is_on db 10d,10d,13d,'FakeDriv will set established',10d,13d,'$'
is_off db 10d,10d,13d,'FakeDriv will NOT set established',10d,13d,'$'
sign_on db 10d,13d,'FakeDriv - Floppy Disk State Machine and disk parameter override to support',10d,13d,'extended capacity floppy disk formats',10d,13d
db 10d,13d,' Copyright (c) 1991-96 Kevin G. Rhoads. All rights reserved.',10d,13d
db ' version 0.010 ',10d,13d
db ' Distributable per GNU Public License v2.0',10d,,10d,13d
db 'The Floppy DSM Established Bit can be forced on or not',10d,13d,'toggle mode by running FakeDriv again.',10d,13d,'$'

code_seg ends
;
;
abs0 segment at 0

org 4ch ;INT 13h we don't use this, though we could


romdisk label dword
diskoff dw ?
diskseg label word

org 70h ;INT 1ch


timertk label dword
tickoff dw ?
tickseg label word

org 78h ;"INT" 1eh floppy disk param pointer


dskparm label dword
parmoff dw ?
parmseg label word
org 100h ;INT 40h
diskalt label dword
altoff dw ?
altseg label word

abs0 ends
;
;
bios_data segment at 040h
org 090h
a_state db ?
b_state db ?
a_state_op db ?
b_state_op db ?
a_cyl db ?
b_cyl db ?
bios_data ends
end entry_point

S-ar putea să vă placă și