*****************************************************************************
* Various                                                                   *
*****************************************************************************
EqCCR	Equ	%0000000000000100
NeCCR	Equ	%0000000000000000

;CustomBase	= $dff000	Base Address of Custom Chips

;;; With hindsight, these Bxx_ErrorX_xxx macros could have been implemented as
;;; one or two more generic macros which took the type of branch as one of
;;; their arguments. Still, I'd already typed out most of the different cases
;;; when this fact dawned upon me, and the output is the same, so I've left it,
;;; for now at least.

Bra_ErrorE_Int	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bra	ErrorE_Internal		Fatal Error, ignore DOS error code.
	OPT O+
	ENDM


Bgt_ErrorE_Int	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Ble.s	BEGTI_S\@		Skip if no error.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bra	ErrorE_Internal		Fatal Error, ignore DOS error code.
	OPT O+
BEGTI_S\@
	ENDM


Blt_ErrorE_Int	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Bge.s	BELTI_S\@		Skip if no error.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bra	ErrorE_Internal		Fatal Error, ignore DOS error code.
	OPT O+
BELTI_S\@
	ENDM


Beq_ErrorE_Int	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Bne.s	BEEEI_S\@		Skip if no error.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bra	ErrorE_Internal		Fatal Error, ignore DOS error code.
	OPT O+
BEEEI_S\@
	ENDM


Bne_ErrorE_Int	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Beq.s	BNEEI_S\@		Skip if no error.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename), or NULL.
	OPT O-
	Bra	ErrorE_Internal		Fatal Error, ignore DOS error code.
	OPT O+
BNEEI_S\@
	ENDM


Bra_ErrorE	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bra	ErrorE			Fatal Error.
	OPT O+
	ENDM

Beq_ErrorE	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Bne.s	BEEE_S\@		Skip if no error.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bra	ErrorE			Fatal Error.
	OPT O+
BEEE_S\@
	ENDM

Bne_ErrorE	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Beq.s	BNEE_S\@		Skip if no error.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bra	ErrorE			Fatal Error.
	OPT O+
BNEE_S\@
	ENDM

Bsr_ErrorW	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bsr	ErrorW			Warning.
	OPT O+
	ENDM

Bsreq_ErrorW	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Bne.s	BSEW_S\@		Skip if no error.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bsr	ErrorW			Warning.
	OPT O+
BSEW_S\@
	ENDM

Bsrne_ErrorW	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Beq.s	BSNW_S\@		Skip if no error.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bsr	ErrorW			Warning.
	OPT O+
BSNW_S\@
	ENDM

Bsr_ErrorN	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bsr	ErrorN			Note.
	OPT O+
	ENDM

Bsreq_ErrorN	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Bne.s	BSEN_S\@		Skip if no error.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bsr	ErrorN			Note.
	OPT O+
BSEN_S\@
	ENDM

Bsrne_ErrorN	MACRO			Arg1 = Adr Action. (eg. "MyAction(pc)")
;					Arg2 = Ptr to Active NIB (eg. "MyNIB_Adr(a5)")
;					       or Null.
	Beq.s	BSNN_S\@		Skip if no error.
	Lea	\1,a0			-._ Setup current action from
	Move.l	a0,CAction(a5)		-'  the first argument.
	Move.l	\2,Active_NIB(a5)	Setup current NIB (filename).
	OPT O-
	Bsr	ErrorN			Note.
	OPT O+
BSNN_S\@
	ENDM

;	This macro is like EVEN, but it makes things ODDly aligned!
;	It should be called with one argument: the lable of a known EVEN
;	address (which is before the macro is used!).
ODD	MACRO
ERP\@	Equ	*-\1
	IFEQ	(((ERP\@)*10)/2)-(((ERP\@)/2)*10)
	Dc.b	0
	ENDC
	ENDM

;	This macro is like EVEN, but it inserts a space instead of a null.
;	It should be called with one argument: the lable of a known EVEN
;	address (which is before the macro is used!).
SPACEEVEN	MACRO
SEERP\@	Equ	*-\1
	IFNE	(((SEERP\@)*10)/2)-(((SEERP\@)/2)*10)
	Dc.b	" "
	ENDC
	ENDM

;	This macro is like EVEN, but for RS-Tables. It ensures an Even
;	RS counter by reserving an extra byte if it's odd.
;	Note that when reserving a long or a word in an RS-Table, DevPac
;	automatically aligns it. This is only useful for .b reserves
;	(Eg text...)
RSEven	MACRO
	IFNE	(((__RS)*10)/2)-(((__RS)/2)*10)
	Rs.b	1
	ENDC
	ENDM

CopyEm	MACRO			Copy d7 chars a0 -> a1
	Bra.s	COPE2\@
COPEM\@	Move.b	(a0)+,(a1)+
COPE2\@	DBra	d7,COPEM\@
	ENDM

CopyCN4	MACRO			Copy nullterminated including null.
CCN4\@	Move.b	(a0)+,(a1)+
	Bne.s	CCN4\@
	ENDM

SetReqDefault MACRO
	IFD	Default_Req
	BSet	#SF1_ErrorReq,STD_F_1(a5)
	ELSE
	BClr	#SF1_ErrorReq,STD_F_1(a5)
	ENDC
	ENDM


;=====================================================================================;
; NUDEL-INFO-BLOCK STRUCTURE							      ;
;=====================================================================================;
		RSReset
NIB_Next	Rs.l	1		Pointer to next NIB - Null if this is the last.
NIB_Previous	Rs.l	1		Pointer to previous NIB, Null if the first.
NIB_MemSize	Rs.l	1		Size of allocation - Null if none.
NIB_MemAdrs	Rs.l	1		Address of allocation - Null if none.
NIB_NameAdrs	Rs.l	1		Address of null-term (file)name - Null if none.
NIB_Handle	Rs.l	1		Handle if file is open - Null if not.
NIB_Lock	Rs.l	1		Lock if file is locked - Null if not.
NIB_FIB		Rs.l	1		Pointer to FileInfoBlock - Null if none.
NIB_SizeOf	Equ	__RS
;=====================================================================================;

***************************************************************************************
* Rexx Sys Lib library								      *
***************************************************************************************
N_CallRexSysLib MACRO
	Move.l	N_RexBase(a5),a6
	Jsr	_LVO\1(a6)
	ENDM
N_JumpRexSysLib	MACRO
	Move.l	N_RexBase(a5),a6
	Jmp	_LVO\1(a6)
	ENDM

REXXSYSLIBNAME	MACRO
	Dc.b	"rexxsyslib.library",0
	ENDM
***************************************************************************************
N_CallDOS	MACRO
	Move.l	N_DOSBase(a5),a6
	Jsr	_LVO\1(a6)
	ENDM
N_JumpDOS	MACRO
	Move.l	N_DOSBase(a5),a6
	Jmp	_LVO\1(a6)
	ENDM
*****************************************************************************
N_CallInt	MACRO
	Move.l	N_IntBase(a5),a6
	Jsr	_LVO\1(a6)
	ENDM
N_JumpInt	MACRO
	Move.l	N_IntBase(a5),a6
	Jmp	_LVO\1(a6)
	ENDM
*****************************************************************************
N_CallIFFParse	MACRO
	Move.l	N_IFFBase(a5),a6
	Jsr	_LVO\1(a6)
	ENDM
IFFPARSENAME	MACRO
	Dc.b	"iffparse.library",0
	ENDM
*****************************************************************************
N_Callmathieeedoubbas	MACRO
	Move.l	N_mathieeedoubbasBase(a5),a6
	Jsr	_LVO\1(a6)
	ENDM
mathieeedoubbasNAME	MACRO
	Dc.b	"mathieeedoubbas.library",0
	ENDM
*****************************************************************************
N_CallGfx	MACRO
	Move.l	N_GfxBase(a5),a6
	Jsr	_LVO\1(a6)
	ENDM
GFXNAME	MACRO
	Dc.b	"graphics.library",0
	ENDM
*****************************************************************************
AbsExecBase	=  $4
;---------------------------------------------------------------------------;
N_CallExec	MACRO
	Move.l	(AbsExecBase).w,a6
	Jsr	_LVO\1(a6)
	ENDM
N_JumpExec	MACRO
	Move.l	(AbsExecBase).w,a6
	Jmp	_LVO\1(a6)
	ENDM
*****************************************************************************
