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 ID - ID of the best mode to use, or INVALID_ID if a match
46 graphics/modeid.h graphics/displayinfo.h
53 ******************************************************************************/
57 /* ULONG dipf_must_have = 0;
58 ULONG dipf_must_not_have = 0;
60 struct ViewPort
*vp
= NULL
;
61 UWORD nominal_width
= 640
62 , nominal_height
= 200
64 , desired_height
= 200;
66 ULONG monitorid
= INVALID_ID
, sourceid
= INVALID_ID
;
70 ULONG dipf_musthave
= 0
71 , dipf_mustnothave
= 0;
73 ULONG found_id
= INVALID_ID
;
74 HIDDT_ModeID hiddmode
;
76 /* ULONG maxdepth = 0;
77 ULONG maxwidth = 0, maxheight = 0;
78 UBYTE maxrb = 0, maxgb = 0, maxbb = 0;
80 /* First try to get viewport */
81 vp
= (struct ViewPort
*)GetTagData(BIDTAG_ViewPort
, (IPTR
)NULL
, TagItems
);
82 monitorid
= GetTagData(BIDTAG_MonitorID
, monitorid
, TagItems
);
83 sourceid
= GetTagData(BIDTAG_SourceID
, sourceid
, TagItems
);
84 depth
= GetTagData(BIDTAG_Depth
, depth
, TagItems
);
85 nominal_width
= GetTagData(BIDTAG_NominalWidth
, nominal_width
, TagItems
);
86 nominal_height
= GetTagData(BIDTAG_NominalHeight
, nominal_height
, TagItems
);
87 desired_width
= GetTagData(BIDTAG_DesiredWidth
, desired_width
, TagItems
);
88 desired_height
= GetTagData(BIDTAG_DesiredHeight
, desired_height
, TagItems
);
89 redbits
= GetTagData(BIDTAG_RedBits
, redbits
, TagItems
);
90 greenbits
= GetTagData(BIDTAG_GreenBits
, greenbits
, TagItems
);
91 bluebits
= GetTagData(BIDTAG_BlueBits
, bluebits
, TagItems
);
92 dipf_musthave
= GetTagData(BIDTAG_DIPFMustHave
, dipf_musthave
, TagItems
);
93 dipf_mustnothave
= GetTagData(BIDTAG_DIPFMustNotHave
, dipf_mustnothave
, TagItems
);
97 /* Set some new default values */
98 nominal_width
= desired_width
= vp
->DWidth
;
99 nominal_height
= desired_height
= vp
->DHeight
;
101 if (NULL
!= vp
->RasInfo
->BitMap
)
103 depth
= GetBitMapAttr(vp
->RasInfo
->BitMap
, BMA_DEPTH
);
107 D(bug("!!! Passing viewport with NULL vp->RasInfo->BitMap to BestModeIDA() !!!\n"));
111 if (INVALID_ID
!= sourceid
)
115 /* I do not understand what the docs state about this */
119 /* OK, now we try to search for a mode that has the supplied charateristics */
121 hiddmode
= vHidd_ModeID_Invalid
;
124 OOP_Object
*sync
, *pf
;
126 IPTR redmask
, greenmask
, bluemask
;
127 IPTR gm_depth
, gm_width
, gm_height
;
128 ULONG found_depth
, found_width
, found_height
;
129 hiddmode
= HIDD_Gfx_NextModeID(SDD(GfxBase
)->gfxhidd
, hiddmode
, &sync
, &pf
);
130 if (vHidd_ModeID_Invalid
== hiddmode
)
133 OOP_GetAttr(pf
, aHidd_PixFmt_RedMask
, &redmask
);
134 OOP_GetAttr(pf
, aHidd_PixFmt_GreenMask
, &greenmask
);
135 OOP_GetAttr(pf
, aHidd_PixFmt_BlueMask
, &bluemask
);
137 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &gm_depth
);
138 OOP_GetAttr(sync
, aHidd_Sync_HDisp
, &gm_width
);
139 OOP_GetAttr(sync
, aHidd_Sync_VDisp
, &gm_height
);
141 if ( /* compute_numbits(redmask) >= redbits
142 && compute_numbits(greenmask) >= greenbits
143 && compute_numbits(bluemask) >= bluebits
145 && */gm_depth
>= depth
146 && gm_width
>= desired_width
147 && gm_height
>= desired_height
)
150 /* We return the first modeid that fulfill the criterias.
151 Instead we should find the mode that has:
152 - largest possible depth.
155 (found_id
== INVALID_ID
) ||
157 (found_id
!= INVALID_ID
) &&
158 (gm_depth
< found_depth
) &&
159 (gm_width
< found_width
) &&
160 (gm_height
< found_height
)
164 found_id
= HIDD_TO_AMIGA_MODEID(hiddmode
);
165 found_depth
= gm_depth
;
166 found_width
= gm_width
;
167 found_height
= gm_height
;
171 } /* for (each HIDD modeid) */