
;
;   DOSError V2.0
;
;   Assembly Language by Robert Lang. 23/5/90.
;   (C) Edgeware (Robert Lang)
;
;   This program simply outputs a little message
;   explaining the input dos error number!
;
;   If you use ANY part of this source, contact me, and
;   put my name in your own source unless you persuade me
;   otherwise !
;
;   If you reassemble this program with different messages,
;   you MUST leave my name in the usage text.
;
;   REMEMBER : This source is still 100% my own property.
;   I am simply lending it to the public.
;
;   Contact me at the address in the listing with any questions or
;   problems.
;
; V2.0 Updates :
;
; Added an extra line description to make things a little more useful,
; and added a heading to the ALL option.
; Added the workbench routine, including the question for the argument.
; Added an icon !

; Label definitions

execbase=4
getmsg=-372
findtask=-294
waitport=-384

; Exec Functions

openlib=-408
closelib=-414

; Dos Functions

mode_oldfile=1005
write=-48
read=-42 
output=-60
open=-30
close=-36

; Setting up Program

	section begin,code_c 

begin:	move.b	d0,d5		;Save the argument pointer
	move.l	execbase,a6	;This checks if it was run from
	suba.l	a1,a1		;the workbench or the CLI....
	jsr	findtask(a6)
	move.l	d0,a4
	tst.l	$ac(a4)
	bne	cli		; Its from the CL, so read argument
wbench:	lea	$5c(a4),a0	; Its from the Workbench,
	jsr	waitport(a6)	; so handle messages....
	lea	$5c(a4),a0	; (Otherwise visit from guru....)
	jsr	getmsg(a6)
	bra	workbench	; and open console etc...
cli:	move.b	#0,wbflag
	move.b	d5,d0		; Retrieve the argument pointer
	subq	#1,d0		; All of this is to read the
	beq	ok		; arguments off the CLI line
search:	cmp.b	#$20,(a0)+
	bne	oky
	dbra	d0,search
	bra	ok
oky:	sub.l	#1,a0
ok:	move.b	d0,paramno	; And store pointers for my use !
	move.l	a0,paramaddr

none:	move.l	execbase,a6	; This opens the dos.library
	lea	dosname(pc),a1
	moveq	#0,d0
	jsr	openlib(a6)
	move.l	d0,dosbase
	beq 	error		; Can't open library...exit!
	
; Main Program

	move.l	dosbase,a6	; Find the handle of the
	jsr	output(a6)	; output channel for text !
	move.l	d0,conhandle
		
	move.b	paramno,d0	; Check that a parameter was entered
	cmp.b	#0,d0
	beq	question	; NO! Ask for one.....

	move.l	#useend-1,d2	; YES! Output a linefeed
	move.l	#1,d3
	bsr	text
	
join:	move.l	paramaddr,a1	; Check for common ? argument
	cmp.b	#'?',(a1)	; to find usage of CLI command
	beq	usage		; YES! show usage....

	move.l	paramaddr,a1	; YES! Setup for finding a match
	move.l	#errorlist,a2	; points to my errorlist
	move.l	#err103,d2	; the first error in the list
	move.l	#31,d3		; there are 31 errors in the list

	move.l	(a1),d0		; read the 4 bytes from input
loop:	move.l	(a2),d1		; and the 4 from the error list
	cmp.l	d0,d1		; the same ?
	beq	found		; YES ! Display the message
	add.l	#4,a2		; No, so move to next error in list
	add.l	#41*2,d2	; and next error message
	sub.b	#1,d3		; Is this our last error check ?
	bne	loop		; NO! Do some more

	move.b	(a1)+,d0	; Check for all case variations of ALL
	cmp.b	#'A',d0		; Check A
	beq	Aok
	cmp.b	#'a',d0		; or a
	bne	unk
Aok:	move.b	(a1)+,d0
	cmp.b	#'L',d0		; Check L
	beq	Lok
	cmp.b	#'l',d0		; or l
	bne	unk
Lok:	move.b	(a1)+,d0	
	cmp.b	#'L',d0		; Check L
	beq	L2ok
	cmp.b	#'l',d0		; or l
	bne	unk
L2ok:	move.b	(a1)+,d0	; Check Return
	cmp.b	#$0a,d0
	bne	unk		
all:	move.l	#fulllist,d2	; OK! display whole error list
	move.l	#unknown-fulllist,d3
	bsr	text
	bra	end			; and exit....

unk:	move.l	#unknown,d2	; Argument unknown
	move.l	#41*2,d3	; So output message !
	bsr	text		
	bra	usage		; And the usage text....

found:	move.l	#41*2,d3	; Length of all messages
	bsr	text		; Show the message
	bra	end

usage:	move.l	#use,d2		; Show the usage text
	move.l	#useend-use,d3
	bsr	text

end:	move.b	wbflag,d0	; Was it from Workbench?
	cmp.b	#1,d0
	beq	closecon	; Yes! Close our console....

	move.l	#useend-1,d2	; Output a linefeed
	move.l	#1,d3
	bsr	text
	
	move.l	execbase,a6	; Close dos.library
	move.l	dosbase,a1
	jsr	closelib(a6)
	clr.l	d0		; No probs.
error:	rts			; Exit Program

workbench:
	move.b	#1,wbflag

	move.l	execbase,a6	; This opens the dos.library
	lea	dosname(pc),a1
	moveq	#0,d0
	jsr	openlib(a6)
	move.l	d0,dosbase
	beq 	error		; Can't open library...exit!

	move.l	#conname,d1		; Open Console Window
	move.l	#mode_oldfile,d2
	bsr	openfile
	beq	error			; Oops....error !
	move.l	d0,conhandle

question:				; Ask for an argument
	move.l	#welcome,d2
	move.l	#return-welcome,d3
	bsr	text
	
	bsr	readin			; Read in argument
	
	move.l	#useend-1,d2		; Print Carriage Return
	move.l	#1,d3
	bsr	text

	move.l	#buff,paramaddr		; Point to buffer,
	bra	join			; and handle data....
	

closecon:				; This closes my con:
	move.l	#return,d2	
	move.l	#use-return,d3		; First asks to press Return....
	bsr	text
	bsr	readin			; Wait for return....
	move.l	conhandle,d1
	move.l	dosbase,a6
	jsr	close(a6)		; Close console....
	clr.l	d0
	rts

; Subroutines

text:	move.l	conhandle,d1	; This routine displays text in
	move.l	dosbase,a6
	jsr	write(a6)	; the output found earlier
	rts
	
openfile:
	move.l	dosbase,a6	; This opens a file,
	jsr	open(a6)	; is used here to open a 
	tst.l	d0		; CON: screen for input/ouput.
	rts			

readin:	move	#4,d3		; Reads in text
	move.l	#buff,d2	; 4 long, into 'buff'
	move.l	dosbase,a6	
	move.l	conhandle,d1
	jsr	read(a6)
	rts

; Program Data

dosname:	dc.b	'dos.library',0
		even
conname:	dc.b	'CON:100/5/440/195/DOSError V2.0 by Robert Lang 23/5/90',0
wbflag:		dc.b	0
		even
buff:		dc.b	'?   ',0
		even
dosbase:	dc.l	0
conhandle:	dc.l	0
welcome:	dc.b	$0a,'Welcome to DOSError V2.0 !'
		dc.b	$0a,'Please enter the DOS error number : '
return:		dc.b	$0a,'Press RETURN to return to WorkBench....'
use:		dc.b	$0a,'DOSError V2.0 by Robert Lang (c) Edgeware 23/5/90'
		dc.b	$0a,'~~~~~~~~ ~~~~    ~~~~~~~~~~~     ~~~~~~~~',$0a
		dc.b	' This program gives a two-line description',$0a
		dc.b	' of what a DOS error number means.',$0a
		dc.b	$0a,' Example Usage : DOSError 205',$0a
		dc.b	$0a,' (Use DOSError ALL to get a list of',$0a
		dc.b	'  all the DOS messages known.)',$0a
		dc.b	$0a,' Write to me : Robert Lang',$0a
	        dc.b	'               (EDGEWARE)',$0a
	        dc.b	'               P.O. Box 127',$0a
		dc.b	'               CARDIFF NSW 2285',$0a
		dc.b	'               AUSTRALIA',$0a,$0a
		dc.b	'   DOSError is dedicated to Suzanne Day !',$0a,$0a
useend:

		even

paramno:	dc.l	0
paramaddr:	dc.l	0

errorlist:	dc.b	'103',$0a,'105',$0a,'120',$0a,'121',$0a,'122',$0a
		dc.b	'201',$0a,'202',$0a,'203',$0a,'204',$0a,'205',$0a
		dc.b	'206',$0a,'207',$0a,'209',$0a,'210',$0a,'211',$0a
		dc.b	'212',$0a,'213',$0a,'214',$0a,'215',$0a,'216',$0a 
		dc.b	'217',$0a,'218',$0a,'219',$0a,'220',$0a,'221',$0a
		dc.b	'222',$0a,'223',$0a,'224',$0a,'225',$0a,'226',$0a 
		dc.b	'232',$0a
		even

fulllist:	dc.b	'----------------------------------------',$0a
		dc.b	'  DOSError V2.0 by Robert Lang 23/5/90  ',$0a
		dc.b	'----------------------------------------',$0a
err103:		dc.b	'DOS Error 103 : INSUFFICIENT FREE STORE ',$0a
		dc.b	'Not Enough Memory is available.         ',$0a
err105:		dc.b	'DOS Error 105 : TASK TABLE FULL         ',$0a
		dc.b	'There are already 20 processes runnning.',$0a
err120:		dc.b	'DOS Error 120 : LINE TOO LONG OR INVALID',$0a
		dc.b	'Too many or invalid arguments used.     ',$0a
err121:		dc.b	'DOS Error 121 : FILE NOT OBJECT         ',$0a
		dc.b	'The called file cannot be executed.     ',$0a
err122:		dc.b	'DOS Error 122 : INVALID RESIDENT LIBRARY',$0a
		dc.b	'The resident library called was invalid.',$0a
err201:		dc.b	'DOS Error 201 : NO DEFAULT DIRECTORY    ',$0a
		dc.b	'A default directory could not be found! ',$0a
err202:		dc.b	'DOS Error 202 : OBJECT IN USE           ',$0a
		dc.b	'The file or directory is being used.    ',$0a
err203:		dc.b	'DOS Error 203 : OBJECT EXISTS           ',$0a
		dc.b	'The specified file already exists.      ',$0a
err204:		dc.b	'DOS Error 204 : DIRECTORY NOT FOUND     ',$0a
		dc.b	'The specified directory does not exist. ',$0a
err205:		dc.b	'DOS Error 205 : OBJECT NOT FOUND        ',$0a
		dc.b	'The channel specified does not exist.   ',$0a
err206:		dc.b	'DOS Error 206 : INVALID WINDOW          ',$0a
		dc.b	'Incorrect parameters for the window.    ',$0a
err207:		dc.b	'DOS Error 207 : OBJECT TOO LARGE        ',$0a
		dc.b	'The specified file is too big.          ',$0a
err209:		dc.b	'DOS Error 209 : ACTION NOT KNOWN        ',$0a
		dc.b	'The device cannot do the desired action.',$0a
err210:		dc.b	'DOS Error 210 : INVALID COMPONENT NAME  ',$0a
		dc.b	'The filename is too long or invalid.    ',$0a
err211:		dc.b	'DOS Error 211 : INVALID LOCK            ',$0a
		dc.b	'The specified lock structure is invalid.',$0a
err212:		dc.b	'DOS Error 212 : OBJECT WRONG TYPE       ',$0a
		dc.b	'Directory and filename interchanged.    ',$0a
err213:		dc.b	'DOS Error 213 : DISK NOT VALIDATED      ',$0a
		dc.b	'The disk is not recognised by the system',$0a
err214:		dc.b	'DOS Error 214 : DISK WRITE PROTECTED    ',$0a
		dc.b	'Writing is not possible to that device. ',$0a
err215:		dc.b	'DOS Error 215 : RENAME ACROSS DEVICES   ',$0a
		dc.b	'Devices in rename must be same.         ',$0a
err216:		dc.b	'DOS Error 216 : DIRECTORY NOT EMPTY     ',$0a
		dc.b	'Non-Empty directories cannot be deleted.',$0a
err217:		dc.b	'DOS Error 217 : TOO MANY LEVELS         ',$0a
		dc.b	'Too many directory names used.          ',$0a
err218:		dc.b	'DOS Error 218 : DEVICE NOT MOUNTED      ',$0a
		dc.b	'That device is not currently available. ',$0a
err219:		dc.b	'DOS Error 219 : SEEK ERROR              ',$0a
		dc.b	'Error in the Seek() function parameters.',$0a
err220:		dc.b	'DOS Error 220 : COMMENT TOO BIG         ',$0a
		dc.b	'The File Comment was too large.         ',$0a
err221:		dc.b	'DOS Error 221 : DISK FULL               ',$0a
		dc.b	'Not enough space on the specified disk. ',$0a
err222:		dc.b	'DOS Error 222 : DELETE PROTECTED        ',$0a
		dc.b	'The file cannot be deleted.             ',$0a
err223:		dc.b	'DOS Error 223 : WRITE PROTECTED         ',$0a
		dc.b	'The file cannot be overwritten.         ',$0a
err224:		dc.b	'DOS Error 224 : READ PROTECTED          ',$0a
		dc.b	'The file cannot be read.                ',$0a
err225:		dc.b	'DOS Error 225 : NOT A DOS DISK          ',$0a
		dc.b	'AmigaDOS does not recognise this disk.  ',$0a
err226:		dc.b	'DOS Error 226 : NO DISK                 ',$0a
		dc.b	'There is no disk in the specified drive.',$0a
err232:		dc.b	'DOS Error 232 : NO MORE ENTRIES         ',$0a
		dc.b	'Last valid file found in the directory. ',$0a
		dc.b	'----------------------------------------',$0a
		dc.b	'  (c) Edgeware 1990 -- Australian Made  ',$0a
		dc.b	'----------------------------------------',$0a
unknown:	dc.b	'Unknown Argument !                      ',$0a
		dc.b	'Usage of DOSError V2.0 is as follows :  ',$0a

Programend:

