grub2: bring back build of aros-side grub2 tools
[AROS.git] / test / hidds / graphics / hiddmodeid.c
blob27605caffb109c843f4344e63cd317d5543d6bab
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <graphics/gfxbase.h>
7 #include <intuition/screens.h>
8 #include <hidd/graphics.h>
9 #include <proto/intuition.h>
10 #include <proto/oop.h>
12 #include <stdio.h>
14 OOP_AttrBase HiddBitMapAttrBase;
15 OOP_AttrBase HiddSyncAttrBase;
17 static void PrintMode(HIDDT_ModeID m, OOP_Object *sync, OOP_Object *pixfmt)
19 STRPTR desc = "No description";
21 if (m == vHidd_ModeID_Invalid)
22 desc = "End of list";
23 else {
24 if (sync) {
25 OOP_GetAttr(sync, aHidd_Sync_Description, (IPTR *)&desc);
26 } else
27 desc = "NULL sync";
30 printf("ModeID: 0x%08lX %s\n", m, desc);
33 int main(void)
35 struct Screen *scr;
36 struct BitMap *bm;
38 HiddBitMapAttrBase = OOP_ObtainAttrBase(IID_Hidd_BitMap);
39 if (!HiddBitMapAttrBase) {
40 printf("Failed to obtain IID_Hidd_BitMap\n");
41 return RETURN_FAIL;
44 HiddSyncAttrBase = OOP_ObtainAttrBase(IID_Hidd_Sync);
45 if (!HiddSyncAttrBase) {
46 printf("Failed to obtain IID_Hidd_Sync\n");
47 OOP_ReleaseAttrBase(IID_Hidd_BitMap);
48 return RETURN_FAIL;
51 scr = LockPubScreen(NULL);
53 if (!scr) {
54 printf("Failed to lock default public screen\n");
55 OOP_ReleaseAttrBase(IID_Hidd_Sync);
56 OOP_ReleaseAttrBase(IID_Hidd_BitMap);
57 return RETURN_FAIL;
60 bm = scr->RastPort.BitMap;
62 if (IS_HIDD_BM(bm)) {
63 OOP_Object *bmobj = HIDD_BM_OBJ(bm);
64 OOP_Object *gfxhidd = NULL;
66 OOP_GetAttr(bmobj, aHidd_BitMap_GfxHidd, (IPTR *)&gfxhidd);
68 if (gfxhidd) {
69 HIDDT_ModeID *modes;
70 HIDDT_ModeID mode;
71 OOP_Object *sync, *pixfmt;
73 printf("Checking QueryModeIDs()...\n");
74 modes = HIDD_Gfx_QueryModeIDs(gfxhidd, NULL);
75 if (modes) {
76 HIDDT_ModeID *m = modes;
78 do {
79 sync = NULL;
80 pixfmt = NULL;
81 if ((*m == vHidd_ModeID_Invalid) ||
82 HIDD_Gfx_GetMode(gfxhidd, *m, &sync, &pixfmt))
83 PrintMode(*m, sync, pixfmt);
84 else
85 printf("ModeID 0x%08lX GetMode() failed\n", *m);
86 } while (*m++ != vHidd_ModeID_Invalid);
88 HIDD_Gfx_ReleaseModeIDs(gfxhidd, modes);
89 } else
90 printf("Failed to obtain ModeID list\n");
92 printf("Checking NextModeID()...\n");
93 mode = vHidd_ModeID_Invalid;
95 do {
96 sync = NULL;
97 pixfmt = NULL;
98 mode = HIDD_Gfx_NextModeID(gfxhidd, mode, &sync, &pixfmt);
99 PrintMode(mode, sync, pixfmt);
100 } while (mode != vHidd_ModeID_Invalid);
102 } else
103 printf("Public screen bitmap does not have aHidd_BitMap_GfxHidd, weird\n");
104 } else
105 printf("Public screen bitmap is not a HIDD bitmap, unsupported for now\n");
107 UnlockPubScreen(NULL, scr);
108 OOP_ReleaseAttrBase(IID_Hidd_Sync);
109 OOP_ReleaseAttrBase(IID_Hidd_BitMap);
110 return 0;