		IFND	SNOOPY_I
SNOOPY_I	equ	1

;--------------	enable COOL coding style.... ;-)
		mc68040
		mc68851
		mc68882
		escapestr
		super
		readmodwriteok

;--------------	version/revision information
VERSION		equ	1
REVISION	equ	0
VERSINFOSTRING	equstr	_VALOF(VERSION),".",_VALOF(REVISION)
PROGRAMSTRING	equstr	"Snoopy"
DATE		equstr	"June 14,1993"
IDSTRING	equstr	PROGRAMSTRING," ",VERSINFOSTRING," (",DATE,")"
AUTHORSTRING	equstr	"G.Kurz in June 1993"
DEFAULTSCRIPT	equstr	"S:SNOOPY.SCRIPT"

;--------------	Voreinstellungen für StringToValue()
STVFORMAT_DEC	equ	0
STVFORMAT_HEX	equ	1
STVFORMAT_OCT	equ	2
STVFORMAT_BIN	equ	3

;--------------	Identifikatoren für StringToValue()
STVTYPE_DEC	equ	'#'
STVTYPE_HEX	equ	'$'
STVTYPE_OCT	equ	'@'
STVTYPE_BIN	equ	'%'


;--------------	program global defines
MAX_REGS	equ	32
MAX_TEMPLATE	equ	80
MAX_BASENAME	equ	32
MAX_OUTPUTARGS	equ	32
MAX_HIDENAME	equ	80
MASK_SIGNALS	equ	SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D|SIGBREAKF_CTRL_E|SIGBREAKF_CTRL_F

COMMENT_LINE	equ	"#"	; whole line is a comment
COMMENT		equ	";"	; everything following this is a comment

;--------------	used internally to describe a patch 
		STRUCTURE PatchInfo,LN_SIZE
		APTR	pin_LibraryBase			; Base adress of the library
		WORD	pin_Offset			; function offset (negative)
		STRUCT	pin_Template,MAX_TEMPLATE	; pointer to the output template string
		STRUCT	pin_Arguments,MAX_REGS		; the argument definition : max. 32 bytes
		LABEL	pin_SIZEOF

;--------------	this structure describes a library base used by Snoopy
		STRUCTURE LibraryBaseInfo,LN_SIZE
		APTR	lbi_Base			; base address
		STRUCT	lbi_BaseName,MAX_BASENAME
		LABEL	lbi_SIZEOF

;--------------	this structure is the top of each patched function
		STRUCTURE PatchInfoHead,0
		ULONG	pih_Ident		; == PATCH_IDSTRING
		APTR	pih_OriginalFunction	; original function vector
		APTR	pih_Info		; pointer to a PatchInfo structure
		LABEL	pih_SIZEOF

;--------------	structure for all hidden tasks
		STRUCTURE HideInfo,LN_SIZE
		STRUCT	hide_Name,MAX_HIDENAME
		LABEL	hide_SIZEOF

;--------------	the register number is coded in the lower 4 bits of the infobyte
ARG_D0		equ	%00000000
ARG_D1		equ	%00000001
ARG_D2		equ	%00000010
ARG_D3		equ	%00000011
ARG_D4		equ	%00000100
ARG_D5		equ	%00000101
ARG_D6		equ	%00000110
ARG_D7		equ	%00000111
ARG_A0		equ	%00001000
ARG_A1		equ	%00001001
ARG_A2		equ	%00001010
ARG_A3		equ	%00001011
ARG_A4		equ	%00001100
ARG_A5		equ	%00001101
ARG_DONE	equ	%11111111 ; both a6 and a7(=SP) are not to be monitored anyway!

;--------------	if this bit is set, the argument will be analysed after the function call
ARG_RESULT	equ	%00010000 
ARGB_RESULT	equ	4

;--------------	if this bit is set, the register data is treated as a LONG, else as
;--------------	a WORD. (Note A: Byte values should be treated as WORDs)
;--------------	(Note B: You must use %l in the output template if you use ARG_LONG)
;--------------	
ARG_LONG	equ	%00100000
ARGB_LONG	equ	5

;--------------	4 bytes used as a patch identifier
PATCH_IDSTRING	equstr	"LOVE"

;--------------	the function arguments are stored in a structure like this
		STRUCTURE PatchCallRegisters,0
		ULONG	pcr_D0
		ULONG	pcr_D1
		ULONG	pcr_D2
		ULONG	pcr_D3
		ULONG	pcr_D4
		ULONG	pcr_D5
		ULONG	pcr_D6
		ULONG	pcr_D7
		ULONG	pcr_A0
		ULONG	pcr_A1
		ULONG	pcr_A2
		ULONG	pcr_A3
		ULONG	pcr_A4
		ULONG	pcr_A5
		LABEL	pcr_SIZEOF

;--------------	each patch sends the following message to the main loop
		STRUCTURE PatchCallMessage,MN_SIZE ; msgport from exec/ports.i
		APTR	pcm_Info		; pointer to a PatchInfo structure
		STRUCT	pcm_RegsBeforeCall,pcr_SIZEOF
		STRUCT	pcm_RegsAfterCall,pcr_SIZEOF
		APTR	pcm_Task		; the task that called this function
		LABEL	pcm_SIZEOF

;--------------	give out a message in \1
SHOWMSG		MACRO
		lea	(\1.msg,pc),a0
		bsr	ShowMessage
		ENDM

;--------------	save all registers to pcr-Data structure
SAVEREGS	MACRO
		move.l	D0,(\1+pcr_D0,a6)
		move.l	D1,(\1+pcr_D1,a6)
		move.l	D2,(\1+pcr_D2,a6)
		move.l	D3,(\1+pcr_D3,a6)
		move.l	D4,(\1+pcr_D4,a6)
		move.l	D5,(\1+pcr_D5,a6)
		move.l	D6,(\1+pcr_D6,a6)
		move.l	D7,(\1+pcr_D7,a6)
		move.l	A0,(\1+pcr_A0,a6)
		move.l	A1,(\1+pcr_A1,a6)
		move.l	A2,(\1+pcr_A2,a6)
		move.l	A3,(\1+pcr_A3,a6)
		move.l	A4,(\1+pcr_A4,a6)
		move.l	A5,(\1+pcr_A5,a6)
		ENDM

		ENDC	;SNOOPY_I
;--------------	
