* Easy Picture Grabber by CHH & CHW
* This program saves the contents of the first screen as an iff file
* with filename 'grabber.pic'. The iff.library is required.


main:		move.l	4,a6			; AbsExecBase
		lea	IffName(PC),a1		; Library Name
		moveq	#15,d0			; Library Version
		jsr	-552(a6)		; OpenLibrary()
		move.l	d0,a4			; A4 : IFF Base
		tst.l	d0
		bne.s	IffOpen
		moveq	#10,d0			; return-code
		rts				; can't open iff.library

IffOpen:	lea	IntuiName(PC),a1	; Library Name
		jsr	-408(a6)		; OldOpenLibrary()
		move.l	d0,a5			; A5 : IntuitionBase

		move.l	60(a5),a0		; FirstScreen
		move.l	88(a0),d6		; BitMap

		move.l	48(a0),a1		; struct ColorTable
		move.l	4(a1),d7		; struct Colormap
		lea	44(a0),a1		; sc_ViewPort
		move.w	32(a1),d1		; vp_Modes
		moveq	#1,d0			; Cruncher-Flag setzen
		btst	#11,d1			; Hold And Modify ?
		beq.s	NoHam			; no --->
		bset	#7,d0			; Set HAM-Flag for iff.lib

NoHam:		move.l	a4,a6			; IffBase
		lea	FileName(PC),a0		; Name of file to save
		move.l	d6,a1			; Pointer to BitMap
		move.l	d7,a2			; Pointer to ColorMap
		jsr	-66(a6)			; SaveBitMap() !!!

		move.l	4,a6			; AbsExecBase
		move.l	a4,a1			; IffBase
		jsr	-414(a6)		; CloseLibrary() (IMPORTANT)

		move.l	a5,a1			; IntuitionBase
		jsr	-414(a6)		; CloseLibrary()

		moveq	#0,d0
		rts

IffName:	dc.b	"iff.library",0
IntuiName:	dc.b	"intuition.library",0
FileName:	dc.b	"grabber.pic",0

