 IFND ERROR_I
ERROR_I=1
;*---------------------------------------------------------------------------
;  :Author.	Bert Jahn
;  :Contens.	macros for error handling
;  :EMail.	wepl@kagi.com
;  :Address.	Franz-Liszt-Straße 16, Rudolstadt, 07404, Germany
;  :Version.	$Id: error.i 1.1 1998/11/22 14:16:01 jah Exp jah $
;  :History.	30.12.95 separated from WRip.asm
;		18.01.96 IFD Label replaced by IFD Symbol
;			 because Barfly optimize problems
;  :Requires.	-
;  :Copyright.	© 1995,1996,1997,1998 Bert Jahn, All Rights Reserved
;  :Language.	68000 Assembler
;  :Translator.	Barfly V1.130
;---------------------------------------------------------------------------*
*##
*##	error.i
*##
*##	_PrintError	subsystem(d0) error(a0) operation(a1)
*##	_PrintErrorDOS	operation(a0)
*##	_PrintErrorTD	error(d0.b) operation(a0)

		IFND	DOSIO_I
			INCLUDE	dosio.i
		ENDC
		IFND	STRINGS_I
			INCLUDE	strings.i
		ENDC
		IFND	DEVICES_I
			INCLUDE	devices.i
		ENDC

;----------------------------------------
; Ausgabe eines Fehlers
; Übergabe :	D0 = CPTR Subsystem | NIL
;		A0 = CPTR Art des Fehlers | NIL
;		A1 = CPTR bei Operation | NIL
; Rückgabe :	-

PrintError	MACRO
	IFND	PRINTERROR
PRINTERROR = 1
		IFND	PRINT
			Print
		ENDC
		IFND	PRINTLN
			PrintLn
		ENDC

_PrintError	move.l	d0,-(a7)
		move.l	a1,-(a7)

		move.l	a0,-(a7)		;print error
		beq	.noerr
		lea	(.error),a0
		bsr	_Print			;header
		move.l	(a7),a0
		bsr	_Print			;msg
		bsr	_PrintLn
.noerr		addq.l	#4,a7

		tst.l	(a7)			;print operation
		beq	.noop
		lea	(.operation),a0
		bsr	_Print
		move.l	(a7),a0
		bsr	_Print
		bsr	_PrintLn
.noop		addq.l	#4,a7

		tst.l	(a7)			;print subsystem
		beq	.nosub
		lea	(.subsys),a0
		bsr	_Print
		move.l	(a7),a0
		bsr	_Print
		bsr	_PrintLn
.nosub		addq.l	#4,a7

		rts

.error		dc.b	155,"1mError     : ",155,"22m",0
.subsys		dc.b	155,"1mSubsystem : ",155,"22m",0
.operation	dc.b	155,"1mOperation : ",155,"22m",0
		EVEN
	ENDC
		ENDM

;----------------------------------------
; Ausgabe eines DOS-Fehlers
; Übergabe :	A0 = CPTR Operation die zu Fehler führte | NIL
; Rückgabe :	-

PrintErrorDOS	MACRO
	IFND	PRINTERRORDOS
PRINTERRORDOS = 1
		IFND	PRINTERROR
			PrintError
		ENDC

_PrintErrorDOS	movem.l	d2/a0/a6,-(a7)
		move.l	(gl_dosbase,GL),a6
		jsr	(_LVOIoErr,a6)
		move.l	d0,d1
		lea	(.error),a0
		move.l	a0,d2
		jsr	(_LVOPrintFault,a6)
		movem.l	(a7)+,d2/a0/a6
		
		move.l	a0,a1			;operation
		lea	(_dosname),a0
		move.l	a0,d0			;subsystem
		sub.l	a0,a0			;error
		bra	_PrintError

.error		dc.b	155,"1mError     ",155,"22m",0
		EVEN
	ENDC
		ENDM

;----------------------------------------
; Ausgabe eines Trackdisk Errors
; Übergabe :	D0 = BYTE errcode
;		A0 = CPTR Operation | NIL
; Rückgabe :	-

PrintErrorTD	MACRO
	IFND	PRINTERRORTD
PRINTERRORTD=1
		IFND	DOSTRING
			DoString
		ENDC
		IFND	PRINTERROR
			PrintError
		ENDC

_PrintErrorTD	move.l	a0,-(a7)
		ext.w	d0
		lea	(_trackdiskerrors),a0
		bsr	_DoString
		move.l	d0,a0			;error
		lea	(.devaccess),a1
		move.l	a1,d0			;subsystem
		move.l	(a7)+,a1		;operation
		bra	_PrintError

.devaccess	dc.b	'device access',0
		EVEN
		IFND	TRACKDISKERRORS
			trackdiskerrors
		ENDC
	ENDC
		ENDM
 ENDC
