2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Graphics function BestModeIDA()
8 #include <aros/debug.h>
9 #include <graphics/modeid.h>
10 #include <hidd/graphics.h>
11 #include <proto/graphics.h>
12 #include <proto/utility.h>
13 #include <proto/oop.h>
15 #include "graphics_intern.h"
17 /*****************************************************************************
20 #include <proto/graphics.h>
22 AROS_LH1(ULONG
, BestModeIDA
,
25 AROS_LHA(struct TagItem
*, TagItems
, A0
),
28 struct GfxBase
*, GfxBase
, 175, Graphics
)
33 TagItems - pointer to an array of TagItems
36 BIDTAG_ViewPort (struct ViewPort *) - Viewport for which a mode is searched. Default: NULL
37 BIDTAG_MonitorID (ULONG) - Returned ID must use this monitor
38 BIDTAG_SourceID (ULONG) - Use this ModeID instead of a ViewPort.
39 DIPFMustHave mask is made up of the
40 ((DisplayInfo->PropertyFlags of this ID & SPECIAL_FLAGS) |
43 if BIDTAG_ViewPort was passed: VPModeID(vp), else the
44 DIPFMustHave and DIPFMustNotHave are unchanged.
45 BIDTAG_Depth (UBYTE) - Minimal depth. Default:
46 if BIDTAG_ViewPort is passed: vp->RasInfo->BitMap->Depth,
48 BIDTAG_NominalWidth (UWORD),
49 BIDTAG_NominalHeight (UWORD) - Aspect radio. Default:
50 if BIDTAG_SourceID: SourceID NominalDimensionInfo
51 if BIDTAG_ViewPort: vp->DWidth and vp->DHeight
53 BIDTAG_DesiredWidth (UWORD) - Width. Default: DIBTAG_NominalWidth.
54 BIDTAG_DesiredHeight (UWORD) - Height. Default: BIDTAG_NominalHeight.
55 BIDTAG_RedBits (UBYTE),
56 BIDTAG_GreenBits (UBYTE),
57 BIDTAG_BlueBits (UBYTE) - Bits per gun the mode must support. Default: 4
58 BIDTAG_DIPFMustHave (ULONG) - DIPF flags the resulting mode must have
59 BIDTAG_DIPFMustNotHave (ULONG) - DIPF flags the resulting mode must not have
62 ID - ID of the best mode to use, or INVALID_ID if a match
72 graphics/modeid.h, graphics/displayinfo.h
79 ******************************************************************************/
83 /* ULONG dipf_must_have = 0;
84 ULONG dipf_must_not_have = 0;
86 struct ViewPort
*vp
= NULL
;
87 UWORD nominal_width
= 640
88 , nominal_height
= 200
90 , desired_height
= 200;
92 ULONG monitorid
= INVALID_ID
, sourceid
= INVALID_ID
;
96 ULONG dipf_musthave
= 0
97 , dipf_mustnothave
= 0;
99 ULONG found_id
= INVALID_ID
;
100 HIDDT_ModeID hiddmode
;
102 /* ULONG maxdepth = 0;
103 ULONG maxwidth = 0, maxheight = 0;
104 UBYTE maxrb = 0, maxgb = 0, maxbb = 0;
106 /* First try to get viewport */
107 vp
= (struct ViewPort
*)GetTagData(BIDTAG_ViewPort
, (IPTR
)NULL
, TagItems
);
108 monitorid
= GetTagData(BIDTAG_MonitorID
, monitorid
, TagItems
);
109 sourceid
= GetTagData(BIDTAG_SourceID
, sourceid
, TagItems
);
110 depth
= GetTagData(BIDTAG_Depth
, depth
, TagItems
);
111 nominal_width
= GetTagData(BIDTAG_NominalWidth
, nominal_width
, TagItems
);
112 nominal_height
= GetTagData(BIDTAG_NominalHeight
, nominal_height
, TagItems
);
113 desired_width
= GetTagData(BIDTAG_DesiredWidth
, desired_width
, TagItems
);
114 desired_height
= GetTagData(BIDTAG_DesiredHeight
, desired_height
, TagItems
);
115 redbits
= GetTagData(BIDTAG_RedBits
, redbits
, TagItems
);
116 greenbits
= GetTagData(BIDTAG_GreenBits
, greenbits
, TagItems
);
117 bluebits
= GetTagData(BIDTAG_BlueBits
, bluebits
, TagItems
);
118 dipf_musthave
= GetTagData(BIDTAG_DIPFMustHave
, dipf_musthave
, TagItems
);
119 dipf_mustnothave
= GetTagData(BIDTAG_DIPFMustNotHave
, dipf_mustnothave
, TagItems
);
123 /* Set some new default values */
124 nominal_width
= desired_width
= vp
->DWidth
;
125 nominal_height
= desired_height
= vp
->DHeight
;
127 if (NULL
!= vp
->RasInfo
->BitMap
)
129 depth
= GetBitMapAttr(vp
->RasInfo
->BitMap
, BMA_DEPTH
);
133 D(bug("!!! Passing viewport with NULL vp->RasInfo->BitMap to BestModeIDA() !!!\n"));
137 if (INVALID_ID
!= sourceid
)
141 /* I do not understand what the docs state about this */
145 /* OK, now we try to search for a mode that has the supplied charateristics */
147 hiddmode
= vHidd_ModeID_Invalid
;
150 OOP_Object
*sync
, *pf
;
152 IPTR redmask
, greenmask
, bluemask
;
153 IPTR gm_depth
, gm_width
, gm_height
;
154 ULONG found_depth
, found_width
, found_height
;
155 hiddmode
= HIDD_Gfx_NextModeID(SDD(GfxBase
)->gfxhidd
, hiddmode
, &sync
, &pf
);
156 if (vHidd_ModeID_Invalid
== hiddmode
)
159 OOP_GetAttr(pf
, aHidd_PixFmt_RedMask
, &redmask
);
160 OOP_GetAttr(pf
, aHidd_PixFmt_GreenMask
, &greenmask
);
161 OOP_GetAttr(pf
, aHidd_PixFmt_BlueMask
, &bluemask
);
163 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &gm_depth
);
164 OOP_GetAttr(sync
, aHidd_Sync_HDisp
, &gm_width
);
165 OOP_GetAttr(sync
, aHidd_Sync_VDisp
, &gm_height
);
167 if ( /* compute_numbits(redmask) >= redbits
168 && compute_numbits(greenmask) >= greenbits
169 && compute_numbits(bluemask) >= bluebits
171 && */gm_depth
>= depth
172 && gm_width
>= desired_width
173 && gm_height
>= desired_height
)
176 /* We return the first modeid that fulfill the criterias.
177 Instead we should find the mode that has:
178 - largest possible depth.
181 (found_id
== INVALID_ID
) ||
183 (found_id
!= INVALID_ID
) &&
184 (gm_depth
< found_depth
) &&
185 (gm_width
< found_width
) &&
186 (gm_height
< found_height
)
190 found_id
= HIDD_TO_AMIGA_MODEID(hiddmode
);
191 found_depth
= gm_depth
;
192 found_width
= gm_width
;
193 found_height
= gm_height
;
197 } /* for (each HIDD modeid) */