2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
9 #include <aros/debug.h>
10 #include <cybergraphx/cybergraphics.h>
11 #include <exec/memory.h>
13 #include <proto/cybergraphics.h>
14 #include <proto/graphics.h>
15 #include <proto/oop.h>
16 #include <proto/utility.h>
19 #include "cybergraphics_intern.h"
20 #include "gfxfuncsupport.h"
22 /*****************************************************************************
25 #include <proto/cybergraphics.h>
27 AROS_LH1(struct List
*, AllocCModeListTagList
,
30 AROS_LHA(struct TagItem
*, tags
, A1
),
33 struct Library
*, CyberGfxBase
, 12, Cybergraphics
)
36 Retrieves a list of RTG screenmodes that match the criteria specified
37 in a taglist. The supported tags are as follows:
38 CYBRMREQ_MinWidth (ULONG) - the minimum acceptable display width
40 CYBRMREQ_MaxWidth (ULONG) - the maximum acceptable display width.
42 CYBRMREQ_MinHeight (ULONG) - the minimum acceptable display
43 height (defaults to 240).
44 CYBRMREQ_MaxHeight (ULONG) - the maximum acceptable display
45 height (defaults to 1200).
46 CYBRMREQ_MinDepth (UWORD) - the minimum acceptable display depth
48 CYBRMREQ_MaxDepth (UWORD) - the minimum acceptable display depth
50 CYBRMREQ_CModelArray (UWORD *) - array of permitted pixel formats.
51 Any of the PIXFMT_#? constants may be specified (see
52 LockBitMapTagList()), and the array must be terminated by ~0.
53 By default, all pixel formats are acceptable.
56 tags - mode selection criteria (may be NULL).
59 result - a list of matching screenmodes, or NULL if there are none.
71 The function relies on pixelformat object being passed in
72 DimensionInfo.reserved[1] by graphics.library/GetDisplayInfoData().
74 *****************************************************************************/
78 /* TODO: Implement Display mode attributes */
80 struct TagItem
*tstate
;
84 ULONG maxwidth
= 1600;
85 ULONG minheight
= 240;
86 ULONG maxheight
= 1200;
90 struct List
*cybermlist
= NULL
;
92 UWORD
*cmodelarray
= NULL
;
93 ULONG mode
= INVALID_ID
;
95 for (tstate
= tags
; (tag
= NextTagItem(&tstate
)); ) {
96 switch (tag
->ti_Tag
) {
97 case CYBRMREQ_MinWidth
:
98 minwidth
= (ULONG
)tag
->ti_Data
;
101 case CYBRMREQ_MaxWidth
:
102 maxwidth
= (ULONG
)tag
->ti_Data
;
105 case CYBRMREQ_MinHeight
:
106 minheight
= (ULONG
)tag
->ti_Data
;
109 case CYBRMREQ_MaxHeight
:
110 maxheight
= (ULONG
)tag
->ti_Data
;
113 case CYBRMREQ_MinDepth
:
114 mindepth
= (ULONG
)tag
->ti_Data
;
117 case CYBRMREQ_MaxDepth
:
118 maxdepth
= (ULONG
)tag
->ti_Data
;
121 case CYBRMREQ_CModelArray
:
122 cmodelarray
= (UWORD
*)tag
->ti_Data
;
126 D(bug("!!! UNKNOWN TAG PASSED TO AllocCModeListTagList\n"));
131 /* Allocate the exec list */
132 cybermlist
= AllocMem(sizeof (struct List
), MEMF_CLEAR
);
133 if (NULL
== cybermlist
)
139 while ((mode
= NextDisplayInfo(mode
)) != INVALID_ID
)
141 struct CyberModeNode
*cmnode
;
144 struct DimensionInfo info
;
145 struct NameInfo name
;
149 if (GetDisplayInfoData(NULL
, (UBYTE
*)&info
, sizeof(info
), DTAG_DIMS
, mode
) != sizeof(info
)) {
150 /* This should never happen because NextDisplayInfo() should
151 only return valid modes
153 D(bug("!!! UNABLE TO GET MODE INFO IN AllocCModeListTagList() !!!\n"));
154 D(bug("!!! THIS SHOULD *NEVER* HAPPEN !!!\n"));
158 if (GetDisplayInfoData(NULL
, (UBYTE
*)&name
, sizeof(name
), DTAG_NAME
, mode
) != sizeof(name
)) {
159 D(bug("!!! UNABLE TO GET MODE NAME IN AllocCModeListTagList() !!!\n"));
160 D(bug("!!! THIS SHOULD *NEVER* HAPPEN !!!\n"));
164 width
= info
.Nominal
.MaxX
- info
.Nominal
.MinX
+ 1;
165 height
= info
.Nominal
.MaxY
- info
.Nominal
.MinY
+ 1;
167 if ( width
< minwidth
169 || height
< minheight
170 || height
> maxheight
) {
174 if (info
.MaxDepth
< mindepth
|| info
.MaxDepth
> maxdepth
)
177 /* Get the gfxmode pixelf format */
178 pf
= (OOP_Object
*)info
.reserved
[1];
179 OOP_GetAttr(pf
, aHidd_PixFmt_StdPixFmt
, &cyberpf
);
180 /* ignore non-CGX modes */
184 /* Check whether the gfxmode is the correct pixel format */
185 if (NULL
!= cmodelarray
)
189 for (cyberpixfmts
= cmodelarray
; *cyberpixfmts
; cyberpixfmts
++) {
190 /* See if the stdpixfmt is present in the array */
191 if (*cyberpixfmts
== cyberpf
) {
195 } /* for (each supplied pixelformat in the cmodelarray) */
198 continue; /* PixFmt not wanted, just continue with next node */
200 } /* if (cmodelarray supplied in the taglist) */
202 /* Allocate a cybergfx modeinfo struct */
203 cmnode
= AllocMem(sizeof (struct CyberModeNode
), MEMF_CLEAR
);
207 cmnode
->Width
= width
;
208 cmnode
->Height
= height
;
209 cmnode
->Depth
= info
.MaxDepth
;
210 cmnode
->DisplayID
= mode
;
211 cmnode
->DisplayTagList
= NULL
;
212 CopyMem("CGFX:", cmnode
->ModeText
, 5);
213 CopyMem(name
.Name
, cmnode
->ModeText
+ 5, DISPLAYNAMELEN
- 5);
215 /* Keep track of the node */
216 AddTail(cybermlist
, (struct Node
*)cmnode
);
218 } /* for (modeids returned from the HIDD) */
223 if (NULL
!= cybermlist
)
224 FreeCModeList(cybermlist
);
229 } /* AllocCModeListTagList */