summaryrefslogtreecommitdiff
path: root/Source/GetViewModes.S
blob: c59900afbdcfe175f058fcdd3f24e602d87c278f (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
**
**	$Id: GetViewModes.S,v 21.2 92/05/18 02:18:15 chris Exp $
**	$Revision: 21.2 $
**
**	$Filename: GetViewModes.S $
**	$Author: chris $
**	$Date: 92/05/18 02:18:15 $
**
**	iff.library/IFFL_GetViewModes
**
**	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_GetViewModes
		SECTION	text,CODE

		INCLUDE	"graphics/view.i"
		INCLUDE	"IffLib.i"

		XREF	FindChunkFunc,GetBMHDFunc
		XDEF	CalcViewModes			; für SaveClip.S
		XDEF	GetViewModesFunc


******* iff.library/IFFL_GetViewModes ***************************************
*
*    NAME
*	IFFL_GetViewModes() -- Get Amiga-specific ViewModes
*
*    SYNOPSIS
*	viewmodes = IFFL_GetViewModes( iff )
*	D0                             A1
*
*	ULONG IFFL_GetViewModes( IFFL_HANDLE )
*
*    FUNCTION
*	Searches the IFF file for a 'CAMG' chunk which holds the view modes
*	information. If there is no CAMG chunk, the view modes are calcu-
*	lated using the information in the BitMapHeader structure.
*	You can directly put the low WORD of the result of a call to
*	IFFL_ GetViewModes() into the ns_ViewModes field of a NewScreen
*	structure, or you can use the whole ULONG for the SA_DisplayID tag
*	under OS 2.x.
*
*    INPUTS
*	iff - IFF file handle, from OpenIFF()
*
*    RESULT
*	viewmodes - ULONG containing the view modes (HAM, LACE, HIRES ...)
*	All forbidden bits are masked out, as suggested by CBM.
*	Under Kickstart V1.3, only the lower WORD is used.
*
*    BUGS
*	If the IFF file has no CAMG chunk and 6 bitplanes, the HAM bit
*	will be set. This is not always correct since the picture could
*	be in the Extra Halfbrite mode. You can load such Halfbrite
*	pictures into DPaint III and save them again, DPaint will generate
*	the correct CAMG chunk.
*
*    SEE ALSO
*	<graphics/displayinfo.h>
*
*****************************************************************************


MODESMASK	EQU	~(V_SPRITES|V_VP_HIDE|GENLOCK_AUDIO|GENLOCK_VIDEO)

GetViewModesFunc:
		move.l	a2,-(SP)

		movea.l	a1,a2			; A2 :  IFFFile
		move.l	#'CAMG',d0
		bsr	FindChunkFunc		; setzt Z-Flag wenn not found
		beq.b	CalcEm			; not found ---> Berechnen
		movea.l	d0,a0			; Zeiger auf CAMG....
		move.l	8(a0),d0		; ViewModes
		tst.w	8(a0)			; Oberes WORD == 0 ?
		bne.b	1$			; Nein ---> Nix ausmaskieren
		andi.l	#MODESMASK,d0		; Verbotene Bits ausmaskieren
1$:		bra.b	Ende			; --->

	*** ViewModes aus BMHD berechnen, 0 falls kein BMHD

CalcEm:		movea.l	a2,a1			; IFFFile
		bsr	GetBMHDFunc		; BitMapHeader suchen
	;;	tst.l	d0			; nicht gefunden?
		beq.b	Ende			; dann 0 zurückgeben
		movea.l	d0,a0			; A0 :  BMHD-Struktur
		bsr.b	CalcViewModes		; ViewModes nach D0

	IFD OLDBADHAMPICTURES
		cmpi.b	#6,bmh_nPlanes(a0)	; 6 Bitplanes ?
		blt.b	Ende			; nein --->
		bset	#11,d0			; ViewModes |= HAM
	ENDC
Ende:
		movea.l	(SP)+,a2
		rts


*****i* iff.library/CalcViewModes *******************************************
*
*    NAME
*	CalcViewModes() -- Calculate Amiga-specific ViewModes from a BMHD
*
*    SYNOPSIS
*	viewmodes = CalcViewModes( bmhd )
*	D0                         A0
*
*	ULONG CalcViewModes( struct IFFL_BMHD )
*
*    FUNCTION
*	Tries to calculate the viewmodes for a CAMG chunk by looking at
*	the bmh_Width, bmh_Height and bmh_Depth entries of a bmhd.
*	This is not always satisfactory, but we're stuck with it.
*
*    INPUTS
*	bmhd - BitMapHeader describing the picture's dimensions
*
*    RESULT
*	viewmodes - ULONG containing the view modes (LACE, HIRES)
*
*    BUGS
*	Knows nothing about Monitor IDs or new View modes like SUPERHIRES
*	or HAM8. You should not use this function in new code.
*
*    SEE ALSO
*	IFFL_GetViewModes(), IFFL_SaveClip()
*
*****************************************************************************

CalcViewModes:	moveq.l	#0,d0			; D0 :  ViewModes

		cmpi.b	#4,bmh_nPlanes(a0)	; mehr als 4 Planes ?
		bgt.b	NotHiRes		; ja ---> nicht HiRes

		cmpi.w	#400,bmh_Width(a0)	; Bildbreite > 400 ?
		ble.b	NotHiRes		; nein --->
		bset	#15,d0			; ViewModes |= HiRes
NotHiRes:
		cmpi.w	#320,bmh_Height(a0)	; Bildhöhe > 320 ?
		blt.b	NotInterlace		; nein --->
		bset	#2,d0			; ViewModes |= Interlace
NotInterlace:
		rts


		END