summaryrefslogtreecommitdiff
path: root/Source/GetViewModes.S
blob: e6a10c6b23dec2c2e30b7a436b1afe22d8fc0f6e (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
**
**	$Id: $
**	$Revision: $
**
**	$Filename: GetViewModes.S $
**	$Author: Christian A. Weber $
**	$Release: 19.1 $
**	$Date: 92/05/11 21:11:27 $
**
**	iff.library/IFFLib_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	IFFLib_GetViewModes
		SECTION	text,CODE

		INCLUDE	"IffLib.i"

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


******* iff.library/IFFLib_GetViewModes **************************************
*
*    NAME
*	IFFLib_GetViewModes() -- Get Amiga-specific ViewModes
*
*    SYNOPSIS
*	viewmodes = IFFLib_GetViewModes( ifffile )
*	D0                               A1
*
*	ULONG IFFLib_GetViewModes( IFFFILE )
*
*    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 GetViewModes()
*	call into the ns_ViewModes field of a NewScreen structure. All
*	forbidden bits are masked out, as suggested by CBM.
*
*    INPUTS
*	ifffile - IFF file pointer, returned from OpenIFF()
*
*    RESULT
*	viewmodes - LONG containing the view modes (HAM, LACE, HIRES ...)
*	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
*
*****************************************************************************

	*** Flags, die nur in graphics/view.h aber nicht .i sind (!)

HAM:		EQU	$0800
SPRITES:	EQU	$4000
VP_HIDE:	EQU	$2000
GENLOCK_AUDIO:	EQU	$0100
GENLOCK_VIDEO:	EQU	$0002
EXTRA_HALFBRITE: EQU	$0080

MODESMASK:	EQU	~(SPRITES|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.s	CalcEm			; not found ---> Berechnen
		movea.l	d0,a0			; Zeiger auf CAMG....
		move.l	8(a0),d0		; ViewModes
		andi.l	#MODESMASK,d0		; Verbotene Bits ausmaskieren
		bra.s	Ende			; --->

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

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

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

	*** ViewModes berechnen, A0 = struct BitMapHeader
	*** Diese Routine wird auch von SaveClip() benutzt

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

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

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

		END