⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0cd.asm

📁 硬盘模拟光驱,可以模拟多达八个光驱
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	cmp	al,'Q'	;	Quiet	mode option ?
	je	@@Quiet	;	Yes	-->	@@Quiet
	cmp	al,'?'	;	Help option ?
	je	@@Usage	;	Yes	-->	@@Usage
	cmp	al,'W'	;	Write-protect option ?
	je	@@WriteProt	;	Yes	-->	@@WriteProt
	cmp	al,'S'	;	Speed	option ?
	je	@@SetSpeed	;	Yes	-->	@@SetSpeed
@@NotRedir:
	mov	[cs:Quiet],0	;	Turn off quiet mode
	call	LStrWrite, offset UnknownOp	;	Write	error message
	call	LStrWrite, offset Line	;	Write	offending option
	call	LStrWrite, offset CRLF	;	Newline
	call	CleanUp	;	Clean	up
	ExitCode	0001h	;	Exit to	dos
@@ShowRev:
	call	LStrWrite, offset RevMsg	;	Show revision	message
	call	CleanUp	;	Clean	up
	ExitCode	0000h	;	Exit to	dos
@@MSCDEX:
	mov	al,[ds:Line+2]	;	Get	mscdex selection
	cmp	al,'0'	;	Default	?
	je	@@Exit	;	Yes	-->	@@Exit
	cmp	al,'1'	;	Audio	through-put	?
	je	@@Tru	;	Yes	-->	@@Tru
	cmp	al,'2'	;	Coexist	?
	je	@@CoExist	;	Yes	-->	@@Coexist
	cmp	al,'3'	;	Coexist	+	audio	through-put ?
	je	@@CoExistTru	;	Yes	-->	@@CoExistTru

	call	LStrWrite, offset UnknownMSC	;	Write	error	message
	call	LStrWrite, offset Line	;	Write	offending	option
	call	LStrWrite, offset CRLF	;	Newline
	call	CleanUp	;	Clean	up
	ExitCode	0001h	;	Exit to	dos
@@CoExist:
	mov	[cs:CoMSCDEX],01h	;	Set	coexist	flag
	jmp	@@Exit	;	Exit
@@CoExistTru:
	mov	[cs:CoMSCDEX],01h	;	Set	coexist	flag
@@Tru:
	mov	[cs:AudioTru],01h	;	Set	audio	throughput flag
	jmp	@@Exit	;	Exit
@@Alt:
	mov	[cs:AltSimul],01h	;	Set	alternate	simulation flag
	jmp	@@Exit	;	Exit
@@Failure:
	mov	[cs:DoFailure],01h	;	Set	failure	flag
	jmp	@@Exit
@@Simulate:
	mov	al,[ds:Line+2]	;	Get	simulation selection
	sub	al,'0'	;	Calculate	simulation no
	mov	[cs:SimType],al	;	Save it
	add	al,'0'	;	Adjust back	to digits
	cmp	al,'0'	;	Physical simulation	?
	je	@@SimPhys	;	Yes	-->	@@SimPhys
	cmp	al,'1'	;	Subst	simulation ?
	je	@@SimSubst	;	Yes	-->	@@SimSubst
	cmp	al,'2'	;	Remote simulation	?
	je	@@SimRemote	;	Yes	-->	@@SimRemote
	call	LStrWrite, offset UnknownSim	;	Write	error	message
	call	LStrWrite, offset Line	;	Write	offending	option
	call	LStrWrite, offset CRLF	;	Newline
	call	CleanUp	;	Clean	up
	ExitCode	0001h	;	Exit to	dos
@@SimPhys:
	mov	[cs:SimFlag],0100000000000000b	;	Save flags
	jmp	@@Exit	;	Exit
@@SimSubst:
	mov	[cs:SimFlag],0101000000000000b	;	Save flags
	jmp	@@Exit	;	Exit
@@SimRemote:
	mov	[cs:SimFlag],0100000010000000b	;	Save flags
	jmp	@@Exit	;	Exit
@@SetSpeed:
	mov	al,[ds:Line+2]	;	Get	speed	selection
	sub	al,'0'	;	Calculate	speed no
	mov	[cs:CurSpeed],al	;	Save it
	add	al,'0'	;	Adjust back	to characters
	cmp	al,'s'	;	Super	speed mode ?
	je	@@Super	;	Yes	-->	@@Super
	cmp	al,'S'	;	Super	speed mode ?
	je	@@Super	;	Yes	-->	@@Super
	cmp	al,'1'	;	Single spin ?
	je	@@Single	;	Yes	-->	@@Single
	cmp	al,'2'	;	Double spin ?
	je	@@Double	;	Yes	-->	@@Double
	cmp	al,'3'	;	Triple spin ?
	je	@@Triple	;	Yes	-->	@@Triple
	cmp	al,'4'	;	Quadra spin ?
	je	@@Quadra	;	Yes	-->	@@Quadra
	cmp	al,'6'	;	Sexa spin	?
	je	@@Sexa	;	Yes	-->	@@Sexa
	cmp	al,'8'	;	Octa spin	?
	je	@@Octa	;	Yes	-->	@@Octa
	mov	[cs:Quiet],0	;	Turn off quiet mode
	call	LStrWrite, offset UnknownSpd	;	Write	error message
	call	LStrWrite, offset Line	;	Write	offending option
	call	LStrWrite, offset CRLF	;	Newline
	call	CleanUp	;	Clean	up
	ExitCode	0001h	;	Exit to	dos
@@Super:
	mov	[cs:CurSpeed],0	;	Set	super	speed mode
	mov	[cs:CurDelay],0	;	Set	super	speed delay
	jmp	@@Exit	;	Exit
@@Single:
	mov	[cs:CurDelay],13000	;	Set	single spin delay
	jmp	@@Exit	;	Exit
@@Double:
	mov	[cs:CurDelay],6200	;	Set	double spin delay
	jmp	@@Exit	;	Exit
@@Triple:
	mov	[cs:CurDelay],4200	;	Set	triple spin delay
	jmp	@@Exit	;	Exit
@@Quadra:
	mov	[cs:CurDelay],3100	;	Set	quadra spin delay
	jmp	@@Exit	;	Exit
@@Sexa:
	mov	[cs:CurDelay],2000	;	Set	sexa spin delay
	jmp	@@Exit	;	Exit
@@Octa:
	mov	[cs:CurDelay],1700	;	Set	octa spin delay
	jmp	@@Exit	;	Exit
@@Data:
	lea	si,[Line+2]	;	/Dxxx, xxx in ds:si
	lea	di,[DataName]	;	DataName in ds:di
	cld		;	Forward	copy
@@DataLoop:
	lodsb		;	Get	character
	mov	[ds:di],al	;	Store	character
	inc	di	;	Skip character
	test	al,al	;	End	of parameter ?
	jnz	@@DataLoop	;	No --> @@DataLoop
	call	TrueName, ds offset DataName	; Fix
	jmp	@@Exit	;	Exit
@@SetRun:
	lea	si,[Line+2]	;	/Rxxx, xxx in ds:si
	lea	di,[RunName]	;	RunName	in ds:di
	cld		;	Forward	copy
@@SetRunLoop:
	lodsb		;	Get	character
	mov	[cs:di],al	;	Store	character
	inc	di	;	Skip character
	test	al,al	;	End	of parameter ?
	jnz	@@SetRunLoop	;	No --> @@SetRunLoop
	call	TrueName, cs offset RunName	; Fix
	jmp	@@Exit	;	Exit
@@ZeroRet:
	mov	[cs:RetZero],1	;	Set	zero free flag
	jmp	@@Exit	;	Exit
@@WriteProt:
	mov	[cs:WriteProt],1	;	Set	write-protect flag
	jmp	@@Exit	;	Exit
@@NewLetter:
	cmp	[AnyRedir],01h	;	Any	redirections already ?
	je	@@OnlyBeforeFirst	;	Yes	-->	@@OnlyBeforeFirst
	mov	al,[byte ptr ds:Line+2]	;	Get	drive	letter
	call	UpCase, ax	;	Convert	to uppercase
	cmp	al,'D'	;	<D ?
	jb	@@NotOk	;	Yes	-->	@@NotOk
	cmp	al,'Z'	;	>Z ?
	ja	@@NotOk	;	Yes	-->	@@NotOk
	mov	[cs:FirstID],al	;	Save first id to use
	mov	[DriveID],al	;	Save current id to use
	jmp	@@Exit	;	Exit
@@OnlyBeforeFirst:
	mov	[cs:Quiet],0	;	Turn off quiet mode
	call	LStrWrite, offset InvDrive	;	Write	error message
	call	LStrWrite, offset Line	;	Write	offending option
	call	LStrWrite, offset CRLF	;	Newline
	call	CleanUp	;	Clean	up
	ExitCode	0001h	;	Exit to	dos
@@NotOk:
	mov	[cs:Quiet],0	;	Turn off quiet mode
	call	LStrWrite, offset InvOption	;	Write	error message
	call	LStrWrite, offset Line	;	Write	offending option
	call	LStrWrite, offset CRLF	;	Newline
	call	CleanUp	;	Clean	up
	ExitCode	0001h	;	Exit to	dos
@@Quiet:
	mov	[cs:Quiet],01h	;	Turn on quiet mode
	jmp	@@Exit	;	Exit
@@Usage:
	mov	[cs:Quiet],0	;	Turn off quiet mode
	call	LStrWrite, offset UsageMsg	;	Write	error message
	Call	CleanUp	;	Clean	up
	ExitCode	0000h	;	Exit to	dos
@@Exit:
	ret		;	Return to	caller
endp

; Redirect procedure
proc	Redirect	far
uses	si, ax, es, bx
local	@@TempCDS:dword
	cmp	[cs:DriveCount],MaxCDs	;	Already	redirected max ?
	jb	@@RoomForMore	;	No --> @@RoomForMore
	mov	[cs:Quiet],0	;	Turn off quiet mode
	call	LStrWrite, offset TooManyCDs	;	Write	error message
	call	CleanUp	;	Clean	up
	ExitCode	0001h	;	Exit to	dos
@@RoomForMore:
	cmp	[DriveID],'['	;	Exhausted	drive letters ?
	jb	@@OkDrives	;	No --> @@OkDrives
	mov	[cs:Quiet],0	;	Turn off quiet mode
	call	LStrWrite, offset NotRoom	;	Write	error message
	call	CleanUp	;	Clean	up
	ExitCode	0001h	;	Exit to	dos
@@OkDrives:
	mov	[AnyRedir],1	;	Set	redirected flag
	call	LStrWrite, offset Prompt1	;	Write	message
	call	LStrWrite, offset DriveID	;	Write	new drive id
	call	LStrWrite, offset Prompt2	;	Write	rest of message
	call	StrCopy, ds offset PathName, ds offset Line	;	Copy path
	call	TrueName, ds offset PathName	;	Fix	it
	push	si	;	Save si
	lea	si,[PathName]	;	Pathname in	ds:si
@@CheckBackslash:
	cmp	[byte ptr ds:si],00h	;	End	of pathname	?
	je	@@OkEnd	;	Yes	-->	@@OkEnd
	inc	si	;	Next character
	jmp	@@CheckBackslash	;	Loop
@@OkEnd:
	cmp	[byte ptr ds:si-1],00h	;	Last character was \
	jne	@@OkBackslash	;	No --> @@OkBackslash
	mov	[byte ptr ds:si-1],'\'	;	Remove last	\
	mov	[byte ptr ds:si],00h	;	Remove last	\
@@OkBackslash:
	pop	si	;	Restore	si
	call	LStrWrite, offset PathName	;	Write	pathname
	call	LStrWrite, offset CRLF	;	Newline

	mov	al,[byte ptr PathName]	;	Get	drive	letter
	call	GetCDS, ax	;	Get	CDS	pointer
	mov	[word ptr @@TempCDS],bx	;	Save offset
	mov	[word ptr @@TempCDS+2],es	;	Save segment

	mov	al,[DriveID]	;	Get	drive	id
	call	GetCDS, ax	;	Get	CDS	pointer
	cmp	[word ptr es:bx+67],0000h	;	Drive	letter available
	jne	@@NotAvail	;	No --> @@NotAvail
	cmp	[word ptr es:bx+69],0000h	;	Drive	letter available
	jne	@@NotAvail	;	No --> @@NotAvail
	cmp	[word ptr es:bx+71],0000h	;	Drive	letter available
	jne	@@NotAvail	;	No --> @@NotAvail
	call	CopyData, [@@TempCDS], es bx, 88	;	Copy host	CDS

	call	StrCopy, es bx, ds offset PathName	;	Copy pathname
	call	StrLen, ds offset PathName	;	Calculate	length of	path

	mov	si,ax	;	Get	length
	add	si,bx	;	Adjust into	CDS
	cmp	[byte ptr es:si-1],'\'	;	Last was \ ?
	jne	@@OkLength	;	No --> @@OkLength
	dec	ax	;	Adjust path
@@OkLength:
	mov	[es:bx+79],ax	;	Hide redirected	path
	mov	ax,[cs:SimFlag]	;	Get	flags
	xor	ax,1111111111111111b	;	Make mask
	and	[es:bx+67],ax	;	Mask out bits	to set
	xor	ax,1111111111111111b	;	Make flag
	or	[es:bx+67],ax	;	Set	bits

	mov	al,[DriveID]	;	Get	drive	id
	mov	[SimDrv],al	;	Update simulation	message
	call	LStrWrite, offset SimMsg1	;	Write	simulation message
	cmp	[cs:SimType],00h	;	Simulate physical	?
	je	@@Sim00	;	Yes	-->	@@Sim00
	cmp	[cs:SimType],01h	;	Simulate substed ?
	je	@@Sim01	;	Yes	-->	@@Sim01
@@Sim02:
	call	LStrWrite, offset SimMsg4	;	Write	physical message
	jmp	@@SimOk	;	Ok
@@NotAvail:
	call	LStrWrite, offset TooFew	;	Write	error	message
	call	CleanUp	;	Clean	up
	ExitCode	0001h	;	Exit to	dos
@@Sim00:
	call	LStrWrite, offset SimMsg2	;	Write	substed	message
	jmp	@@SimOk	;	Ok
@@Sim01:
	call	LStrWrite, offset SimMsg3	;	Write	remote message
@@SimOk:
	mov	al,[DriveID]	;	Get	drive	id
	call	SetSpeed,ax	;	Set	speed	of drive
	call	FixDrive	;	Update dos buffers for	drive
	mov	al,[DriveID]	;	Get	drive	id
	mov	[cs:LastID],al	;	Update LastID
	call	GetCDData, ax	;	Read data	from file
	mov	al,[DriveID]	;	Get	drive	id
	inc	[byte ptr DriveID]	;	Update DriveID
	inc	[byte ptr cs:DriveCount]	;	Update DriveCount

	mov	[SpeedDrv],al	;	Update message
	call	LStrWrite, offset SpeedMsg1	;	Write	message
	cmp	[cs:CurSpeed],0	;	Superspeed ?
	jne	@@NotSuper	;	No --> @@NotSuper
	call	LStrWrite, offset SuperMsg	;	Write	super	message
	jmp	@@SpeedOk	;	-->	@@SpeedOk
@@NotSuper:
	cmp	[cs:CurSpeed],1	;	Single spin	?
	jne	@@NotSingle	;	No --> @@NotSingle
	call	LStrWrite, offset SingleMsg	;	Write	single message
	jmp	@@SpeedOk	;	-->	@@SpeedOk
@@NotSingle:
	cmp	[cs:CurSpeed],2	;	Double spin	?
	jne	@@NotDouble	;	No --> @@NotDouble
	call	LStrWrite, offset DoubleMsg	;	Write	double message
	jmp	@@SpeedOk	;	-->	@@SpeedOk
@@NotDouble:
	cmp	[cs:CurSpeed],3	;	Triple spin	?
	jne	@@NotTriple	;	No --> @@NotTriple
	call	LStrWrite, offset TripleMsg	;	Write	triple message
	jmp	@@SpeedOk	;	-->	@@SpeedOk
@@NotTriple:
	cmp	[cs:CurSpeed],4	;	Quadra spin	?
	jne	@@NotQuadra	;	No --> @@NotQuadra
	call	LStrWrite, offset QuadraMsg	;	Write	quadra message
	jmp	@@SpeedOk	;	-->	@@SpeedOk
@@NotQuadra:
	cmp	[cs:CurSpeed],6	;	Sexa spin	?
	jne	@@NotSexa	;	No --> @@NotSexa
	call	LStrWrite, offset SexaMsg	;	Write	sexa message
	jmp	@@SpeedOk	;	-->	@@SpeedOk
@@NotSexa:
	call	LStrWrite, offset OctaMsg	;	Write	octa message
@@SpeedOk:
	call	LStrWrite, offset SpeedMsg2	;	Write	end	of message
	ret		;	Return to	caller
endp

; SetSpeed procedure
proc	SetSpeed
arg	@@DriveID:word
uses	ax, bx
	mov	bl,[byte ptr @@DriveID]	;	Get	drive	id
	sub	bl,[cs:FirstID]	;	Make 0-based
	xor	bh,bh	;	Make 16-bit
	shl	bx,1	;	Multiply with	2	(make	index)
	mov	ax,[CurDelay]	;	Get	current	delay
	mov	[cs:DriveSpeeds+bx],ax	;	Save in	DriveSpeeds
	ret		;	Return to	caller
endp

; FixDrive procedure
proc	FixDrive
uses	ax, dx
	lea	dx,[PathName]	;	PathName in	ds:dx
	mov	al,[DriveID]	;	Get	drive	id
	mov	[PathName],al	;	Store	in pathname
	mov	[byte ptr PathName+1],':'	;	Make into	'D:\',0
	mov	[byte ptr PathName+2],'\'	;	...
	mov	[byte ptr PathName+3],0	;	...
	mov	ah,3bh	;	Dos	Fn 3bh = ChDir
	int	21h	;	Call DOS interrupt
	ret		;	Return to	caller
endp

; CopyData procedure
proc	CopyData	far
arg	@@Source:dword, @@Dest:dword, @@Length:word
uses	ds, si, es, di, cx
	cld		;	Forward	copy
	lds	si,[dword ptr @@Source]	;	Source in	ds:si
	les	di,[dword ptr @@Dest]	;	Destination	in es:di
	mov	cx,[@@Length]	;	Length in	cx
	rep	movsb	;	Copy it
	ret		;	Return to	caller
endp

; TrueName procedure
proc	TrueName	far
arg	@@Dest:dword
uses	ax, ds, es, si, di
	mov	ah,60h	;	Dos	Fn 60h = TrueName
	lds	si,[dword ptr @@Dest]	;	Source in	ds:si
	les	di,[dword ptr @@Dest]	;	Destination	in es:di
	int	21h	;	Call DOS interrupt
	ret		;	Return to	caller
endp

; ZeroDefault procedure
proc	ZeroDefault
arg	@@DriveNo:word
	mov	al,[byte ptr @@DriveNo]
	cmp	al,0	;	Default	drive	(0)	?
	je	@@IsDefault	;	Yes	-->	@@IsDefault
	add	al,'@'	;	Convert	to A-Z
	jmp	@@Exit	;	Exit
@@IsDefault:
	mov	ah,19h	;	Dos	Fn 19h = GetCurDrive
	int	21h	;	Call DOS interrupt
	add	al,'A'	;	Convert	to A-Z
@@Exit:
	ret		;	Return to	caller
endp

; IsOwn procedure
proc	IsOwn
arg	@@DriveID:word, @@Redirect:word
uses	ax, es, bx, dx
	call	UpCase, [@@DriveID]	;	Convert	id to	uppercase
	mov	[@@DriveID],ax	;	Store	new	id
	cmp	[@@Redirect],0	;	Redirect before	checking ?
	jne	@@CheckIt	;	No --> @@CheckIt

	mov	al,[byte ptr @@DriveID]	;	Get	drive	id in	al

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -