2 Copyright © 1995-2001, 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 ******************************************************************************/
56 AROS_LIBBASE_EXT_DECL(struct GfxBase
*,GfxBase
)
58 /* ULONG dipf_must_have = 0;
59 ULONG dipf_must_not_have = 0;
61 struct ViewPort
*vp
= NULL
;
62 UWORD nominal_width
= 640
63 , nominal_height
= 200
65 , desired_height
= 200;
67 ULONG monitorid
= INVALID_ID
, sourceid
= INVALID_ID
;
71 ULONG dipf_musthave
= 0
72 , dipf_mustnothave
= 0;
74 ULONG found_id
= INVALID_ID
;
75 HIDDT_ModeID hiddmode
;
77 /* ULONG maxdepth = 0;
78 ULONG maxwidth = 0, maxheight = 0;
79 UBYTE maxrb = 0, maxgb = 0, maxbb = 0;
81 /* First try to get viewport */
82 vp
= (struct ViewPort
*)GetTagData(BIDTAG_ViewPort
, (IPTR
)NULL
, TagItems
);
83 monitorid
= GetTagData(BIDTAG_MonitorID
, monitorid
, TagItems
);
84 sourceid
= GetTagData(BIDTAG_SourceID
, sourceid
, TagItems
);
85 depth
= GetTagData(BIDTAG_Depth
, depth
, TagItems
);
86 nominal_width
= GetTagData(BIDTAG_NominalWidth
, nominal_width
, TagItems
);
87 nominal_height
= GetTagData(BIDTAG_NominalHeight
, nominal_height
, TagItems
);
88 desired_width
= GetTagData(BIDTAG_DesiredWidth
, desired_width
, TagItems
);
89 desired_height
= GetTagData(BIDTAG_DesiredHeight
, desired_height
, TagItems
);
90 redbits
= GetTagData(BIDTAG_RedBits
, redbits
, TagItems
);
91 greenbits
= GetTagData(BIDTAG_GreenBits
, greenbits
, TagItems
);
92 bluebits
= GetTagData(BIDTAG_BlueBits
, bluebits
, TagItems
);
93 dipf_musthave
= GetTagData(BIDTAG_DIPFMustHave
, dipf_musthave
, TagItems
);
94 dipf_mustnothave
= GetTagData(BIDTAG_DIPFMustNotHave
, dipf_mustnothave
, TagItems
);
98 /* Set some new default values */
99 nominal_width
= desired_width
= vp
->DWidth
;
100 nominal_height
= desired_height
= vp
->DHeight
;
102 if (NULL
!= vp
->RasInfo
->BitMap
)
104 depth
= GetBitMapAttr(vp
->RasInfo
->BitMap
, BMA_DEPTH
);
108 D(bug("!!! Passing viewport with NULL vp->RasInfo->BitMap to BestModeIDA() !!!\n"));
112 if (INVALID_ID
!= sourceid
)
116 /* I do not understand what the docs state about this */
120 /* OK, now we try to search for a mode that has the supplied charateristics */
122 hiddmode
= vHidd_ModeID_Invalid
;
125 OOP_Object
*sync
, *pf
;
127 ULONG redmask
, greenmask
, bluemask
;
128 ULONG gm_depth
, gm_width
, gm_height
;
129 ULONG found_depth
, found_width
, found_height
;
130 hiddmode
= HIDD_Gfx_NextModeID(SDD(GfxBase
)->gfxhidd
, hiddmode
, &sync
, &pf
);
131 if (vHidd_ModeID_Invalid
== hiddmode
)
134 OOP_GetAttr(pf
, aHidd_PixFmt_RedMask
, &redmask
);
135 OOP_GetAttr(pf
, aHidd_PixFmt_GreenMask
, &greenmask
);
136 OOP_GetAttr(pf
, aHidd_PixFmt_BlueMask
, &bluemask
);
138 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &gm_depth
);
139 OOP_GetAttr(sync
, aHidd_Sync_HDisp
, &gm_width
);
140 OOP_GetAttr(sync
, aHidd_Sync_VDisp
, &gm_height
);
142 if ( /* compute_numbits(redmask) >= redbits
143 && compute_numbits(greenmask) >= greenbits
144 && compute_numbits(bluemask) >= bluebits
146 && */gm_depth
>= depth
147 && gm_width
>= desired_width
148 && gm_height
>= desired_height
)
151 /* We return the first modeid that fulfill the criterias.
152 Instead we should find the mode that has:
153 - largest possible depth.
156 (found_id
== INVALID_ID
) ||
158 (found_id
!= INVALID_ID
) &&
159 (gm_depth
< found_depth
) &&
160 (gm_width
< found_width
) &&
161 (gm_height
< found_height
)
165 found_id
= HIDD_TO_AMIGA_MODEID(hiddmode
);
166 found_depth
= gm_depth
;
167 found_width
= gm_width
;
168 found_height
= gm_height
;
172 } /* for (each HIDD modeid) */