summaryrefslogtreecommitdiff
path: root/Source/IFFError.S
blob: a4d51b9b59e4a2d42280a7af56f03636441209d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
**
**	$Id: IFFError.S,v 21.1 92/05/15 03:21:40 chris Exp $
**	$Revision: 21.1 $
**
**	$Filename: IFFError.S $
**	$Author: chris $
**	$Date: 92/05/15 03:21:40 $
**
**	iff.library/IFFL_IFFError
**
**	COPYRIGHT (C) 1987-1992 BY CHRISTIAN A. WEBER, BRUGGERWEG 2,
**	CH-8037 ZUERICH, SWITZERLAND.  ALL RIGHTS RESERVED.  NO PART
**	OF THIS SOFTWARE MAY BE COPIED, REPRODUCED,  OR  TRANSMITTED
**	IN ANY FORM OR BY ANY MEANS,  WITHOUT THE PRIOR WRITTEN PER-
**	MISSION OF THE AUTHOR. USE AT YOUR OWN RISK.
**


		IDNT	IFFL_IFFError
		SECTION	text,CODE

		INCLUDE	"IFFLib.i"

		XDEF	FindOurNode,SetError,ClearError
		XDEF	IFFErrorFunc


******* iff.library/IFFL_IFFError *******************************************
*
*    NAME
*	IFFL_IFFError -- Get detailed error descrpition after an error
*
*    SYNOPSIS
*	error = IFFL_IFFError()
*	D0
*
*	LONG IFFL_IFFError( VOID )
*
*    FUNCTION
*	If one of the iff.library functions returns zero, you can call
*	IFFL_IFFError() to know the reason for the failure. An error
*	code is returned, please refer to the files 'iff.h' or 'iff.i'
*	for the complete list of errors.
*
*    INPUTS
*	none
*
*    RESULT
*	Error-number generated by the latest function call, or zero if
*	no error.
*
*    BUGS
*	If you don't close the IFF library at the end of your program
*	(using CloseLibrary()) the error node will not be freed. The
*	same task will then not be able to re-open the iff.library.
*	(This is not a bug, it's a feature ;-))
*
*    SEE ALSO
*	<iff.h>
*
*****************************************************************************

	*** Unseren Node nach D0 und A0 bringen, Set Z-Flag if not found

FindOurNode:	movea.l	iffb_SysBase(a5),a6
		move.l	ThisTask(a6),d1
		move.l	iffb_ErrList(a5),d0	; 1. Node in Error Liste

.findloop:	movea.l	d0,a0			; next node
		move.l	LN_SUCC(a0),d0
		beq.s	.findend		; ---> Ende (Z-Flag gesetzt)
		cmp.l	ifferr_Task(a0),d1	; Unser Node ?
		bne.s	.findloop
		move.l	a0,d0			; unser Node, Clear Z-Flag
.findend:	rts


*****************************************************************************

ClearError:	bsr	FindOurNode		; Node nach D0 und A0
	;;	tst.l	d0
		beq.s	1$			; no node ---> nichts eintragen
		clr.l	ifferr_Error(a0)
1$:		moveq	#1,d0			; Code für 'OK'
		rts

*****************************************************************************

SetError:	move.l	d0,-(SP)		; Error-Nummer retten
		bsr	FindOurNode		; Node nach D0 und A0
	;;	tst.l	d0
		beq.s	1$			; kein Node ---> nichts eintragen
		move.l	(SP),ifferr_Error(a0)
1$:
		addq.l	#4,SP
		moveq	#0,d0			; Code für 'Error'
		rts
		

*****************************************************************************

IFFErrorFunc:	movem.l	a5-a6,-(SP)
		movea.l	a6,a5			; IFFBase
		bsr	FindOurNode		; Node nach D0 und A0
	;;	tst.l	d0
		beq.s	1$			; kein Node ---> Fehler!!
		move.l	ifferr_Error(a0),d0
		clr.l	ifferr_Error(a0)	; Error rücksetzen
2$:		movem.l	(SP)+,a5-a6
		rts
1$:
		moveq	#IFFL_ERROR_BADTASK,d0
		bra.s	2$

		END