Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / hidds / graphics / sync.c
blob8a03254946e948f25316089aa34da7515adeb2a0
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Sync info class
6 Lang: English.
7 */
9 /****************************************************************************************/
11 #include <proto/oop.h>
12 #include <proto/utility.h>
13 #include <exec/memory.h>
14 #include <oop/oop.h>
15 #include <utility/tagitem.h>
16 #include <hidd/graphics.h>
18 #define DEBUG 0
19 #include <aros/debug.h>
21 #include "graphics_intern.h"
23 /****************************************************************************************/
25 OOP_Object *Sync__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
27 struct sync_data *data;
28 BOOL ok = FALSE;
30 DECLARE_ATTRCHECK(sync);
32 EnterFunc(bug("Sync::New()\n"));
34 /* Get object from superclass */
35 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
36 if (NULL == o)
37 return NULL;
39 /* If we got a NULL attrlist we just allocate an empty object an exit */
40 if (NULL == msg->attrList)
41 return o;
43 data = OOP_INST_DATA(cl, o);
45 if (!parse_sync_tags(msg->attrList, data, ATTRCHECK(sync), CSD(cl) ))
47 D(bug("!!! ERROR PARSING SYNC ATTRS IN Sync::New() !!!\n"));
49 else
51 ok = TRUE;
54 if (!ok)
56 OOP_MethodID dispose_mid;
58 dispose_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
59 OOP_CoerceMethod(cl, o, (OOP_Msg)&dispose_mid);
60 o = NULL;
63 return o;
66 /****************************************************************************************/
68 VOID Sync__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
70 struct sync_data *data;
71 ULONG idx;
73 data = OOP_INST_DATA(cl, o);
75 if (IS_SYNC_ATTR(msg->attrID, idx))
77 switch (idx)
79 case aoHidd_Sync_PixelTime:
80 *msg->storage = (IPTR)data->pixtime;
81 break;
83 case aoHidd_Sync_PixelClock:
85 #if AROS_NOFPU
86 #warning Find code for non-FPU!
87 *msg->storage = (ULONG)0x12345678;
88 #else
89 DOUBLE pixtime, pixclock;
91 pixtime = (DOUBLE)data->pixtime;
93 pixtime /= 1000000000000; /* pixtime is in 10E-12 secs */
94 pixclock = 1 / pixtime; /* convert to Hz */
95 *msg->storage = (ULONG)pixclock;
96 #endif
97 break;
100 case aoHidd_Sync_LeftMargin:
101 *msg->storage = (IPTR)data->left_margin;
102 break;
104 case aoHidd_Sync_RightMargin:
105 *msg->storage = (IPTR)data->right_margin;
106 break;
108 case aoHidd_Sync_HSyncLength:
109 *msg->storage = (IPTR)data->hsync_length;
110 break;
112 case aoHidd_Sync_UpperMargin:
113 *msg->storage = (IPTR)data->upper_margin;
114 break;
116 case aoHidd_Sync_LowerMargin:
117 *msg->storage = (IPTR)data->lower_margin;
118 break;
120 case aoHidd_Sync_VSyncLength:
121 *msg->storage = (IPTR)data->vsync_length;
122 break;
124 case aoHidd_Sync_HDisp:
125 *msg->storage = (IPTR)data->hdisp;
126 break;
128 case aoHidd_Sync_VDisp:
129 *msg->storage = (IPTR)data->vdisp;
130 break;
132 case aoHidd_Sync_HSyncStart:
133 *msg->storage = (IPTR)(data->hdisp + data->right_margin);
134 break;
136 case aoHidd_Sync_HSyncEnd:
137 *msg->storage = (IPTR)(data->hdisp + data->right_margin + data->hsync_length);
138 break;
140 case aoHidd_Sync_HTotal:
141 *msg->storage = (IPTR)(data->hdisp + data->right_margin + data->hsync_length + data->left_margin);
142 break;
144 case aoHidd_Sync_VSyncStart:
145 *msg->storage = (IPTR)(data->vdisp + data->lower_margin);
146 break;
148 case aoHidd_Sync_VSyncEnd:
149 *msg->storage = (IPTR)(data->vdisp + data->lower_margin + data->vsync_length);
150 break;
152 case aoHidd_Sync_VTotal:
153 *msg->storage = (IPTR)(data->vdisp + data->lower_margin + data->vsync_length + data->upper_margin);
154 break;
156 case aoHidd_Sync_Description:
157 *msg->storage = (IPTR)data->description;
158 break;
160 default:
161 D(bug("!!! TRYING TO GET UNKNOWN ATTR FROM SYNC OBJECT !!!\n"));
162 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
163 break;
168 else
170 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
173 return;
177 /****************************************************************************************/