summaryrefslogtreecommitdiff
path: root/Examples/Grabber.S
blob: 3a3a91a831b1a8805c9a05b093bb7c1a31d55a35 (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
**
**	$Id: Grabber.S,v 21.1 92/06/02 18:09:22 chris Exp $
**	$Revision: 21.1 $
**
**	$Filename: Examples/Grabber.S $
**	$Authors: Christian Haller, CHW $
**	$Release: 23.2 $
**	$Date: 92/06/02 18:09:22 $
**
**	Example for low level Assembler hackers :-)
**
**	This program saves the contents of the first screen as an IFF file
**	with filename 'RAM:grabber.pic'. The iff.library is required.
**	If you use the DevPac assembler, type 'Genim2 Grabber' to assemble.
**	For simplicity, this program uses hard coded constants. You may wish
**	to use the appropriate standard header files instead.
**
**	THIS IS PD. NO WARRANTY. USE AT YOUR OWN RISK.
**

Main:		move.l	4,a6			; AbsExecBase
		lea	IFFName(PC),a1		; Library Name
		moveq	#16,d0			; Required library version
		jsr	-552(a6)		; OpenLibrary()
		move.l	d0,a4			; A4 : IFF Library Base
		tst.l	d0			; Did we get it ?
		bne.s	IFFOpen			; Yes --->
		moveq	#20,d0			; Return-code RETURN_FAIL
		rts				; Return to CLI
IFFOpen:
		lea	IntuiName(PC),a1	; Intuition Library Name
		jsr	-408(a6)		; OldOpenLibrary()
		move.l	d0,a5			; A5 : IntuitionBase

		move.l	60(a5),a0		; IntuitionBase->FirstScreen
		move.l	88(a0),d6		; Screen.BitMap

		move.l	48(a0),a1		; struct Colormap
		move.l	4(a1),d7		; struct ColorTable
		lea	44(a0),a1		; sc_ViewPort
		move.w	32(a1),d1		; vp_Modes
		moveq	#1,d0			; Set cruncher-flag
		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			; DOS return code
		rts

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