2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
5 Desc: Bitmap class for VGA hidd.
9 #define __OOP_NOATTRBASES__
11 #include <proto/oop.h>
12 #include <proto/utility.h>
14 #include <exec/memory.h>
15 #include <exec/lists.h>
17 #include <graphics/rastport.h>
18 #include <graphics/gfx.h>
21 #include <aros/symbolsets.h>
23 #include <hidd/graphics.h>
33 #include LC_LIBDEFS_FILE
35 /* Don't initialize static variables with "=0", otherwise they go into DATA segment */
37 static OOP_AttrBase HiddBitMapAttrBase
;
38 static OOP_AttrBase HiddPixFmtAttrBase
;
39 static OOP_AttrBase HiddGfxAttrBase
;
40 static OOP_AttrBase HiddSyncAttrBase
;
41 static OOP_AttrBase HiddVGAGfxAB
;
42 static OOP_AttrBase HiddVGABitMapAB
;
44 static struct OOP_ABDescr attrbases
[] =
46 { IID_Hidd_BitMap
, &HiddBitMapAttrBase
},
47 { IID_Hidd_PixFmt
, &HiddPixFmtAttrBase
},
48 { IID_Hidd_Gfx
, &HiddGfxAttrBase
},
49 { IID_Hidd_Sync
, &HiddSyncAttrBase
},
51 { IID_Hidd_VGAgfx
, &HiddVGAGfxAB
},
52 { IID_Hidd_VGABitMap
, &HiddVGABitMapAB
},
56 void vgaRestore(struct vgaHWRec
*, BOOL onlyDAC
);
57 void * vgaSave(struct vgaHWRec
*);
58 int vgaInitMode(struct vgaModeDesc
*, struct vgaHWRec
*);
59 void vgaLoadPalette(struct vgaHWRec
*, unsigned char *);
61 void free_onbmclass(struct vga_staticdata
*);
63 #define MNAME_ROOT(x) PCVGAOnBM__Root__ ## x
64 #define MNAME_BM(x) PCVGAOnBM__Hidd_BitMap__ ## x
68 #include <aros/debug.h>
71 #include "bitmap_common.c"
76 void scr_RawPutChars(char *, int);
80 #define rkprintf(x...) scr_RawPutChars(tab, sprintf(tab, x))
84 #define clr() /* eps */
85 #define rkprintf(x...) /* eps */
89 /*********** BitMap::New() *************************************/
91 OOP_Object
*PCVGAOnBM__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
93 EnterFunc(bug("VGAGfx.BitMap::New()\n"));
95 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
) msg
);
98 struct bitmap_data
*data
;
102 IPTR width
, height
, depth
;
104 data
= OOP_INST_DATA(cl
, o
);
107 memset(data
, 0, sizeof(struct bitmap_data
));
109 /* Get attr values */
110 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
111 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
112 OOP_GetAttr(o
, aHidd_BitMap_PixFmt
, &pf
);
113 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
115 ASSERT (width
!= 0 && height
!= 0 && depth
!= 0);
118 We must only create depths that are supported by the friend drawable
119 Currently we only support the default depth
123 data
->height
= height
;
125 data
->Regs
= AllocVec(sizeof(struct vgaHWRec
),MEMF_PUBLIC
|MEMF_CLEAR
);
127 width
=(width
+15) & ~15;
130 Here there is brand new method of getting pixelclock data.
131 It was introduced here to make the code more portable. Besides
132 it may now be used as a base for creating other low level
138 data
->VideoData
= AllocVec(width
*height
,MEMF_PUBLIC
|MEMF_CLEAR
);
141 struct vgaModeDesc mode
;
147 /* We should be able to get modeID from the bitmap */
148 OOP_GetAttr(o
, aHidd_BitMap_ModeID
, &modeid
);
150 if (modeid
!= vHidd_ModeID_Invalid
)
152 struct Box box
= {0, 0, width
-1, height
-1};
154 /* Get Sync and PixelFormat properties */
155 HIDD_Gfx_GetMode(XSD(cl
)->vgahidd
, modeid
, &sync
, &pf
);
158 mode
.Height
= height
;
160 OOP_GetAttr(sync
, aHidd_Sync_PixelClock
, &pixelc
);
162 mode
.clock
= (pixelc
> 26000000) ? 1 : 0;
165 OOP_GetAttr(sync
, aHidd_Sync_HDisp
, &mode
.HDisplay
);
166 OOP_GetAttr(sync
, aHidd_Sync_VDisp
, &mode
.VDisplay
);
167 OOP_GetAttr(sync
, aHidd_Sync_HSyncStart
, &mode
.HSyncStart
);
168 OOP_GetAttr(sync
, aHidd_Sync_VSyncStart
, &mode
.VSyncStart
);
169 OOP_GetAttr(sync
, aHidd_Sync_HSyncEnd
, &mode
.HSyncEnd
);
170 OOP_GetAttr(sync
, aHidd_Sync_VSyncEnd
, &mode
.VSyncEnd
);
171 OOP_GetAttr(sync
, aHidd_Sync_HTotal
, &mode
.HTotal
);
172 OOP_GetAttr(sync
, aHidd_Sync_VTotal
, &mode
.VTotal
);
174 ObtainSemaphore(&XSD(cl
)->HW_acc
);
176 /* Now, when the best display mode is chosen, we can build it */
177 vgaInitMode(&mode
, data
->Regs
);
178 vgaLoadPalette(data
->Regs
,(unsigned char *)NULL
);
181 Because of not defined BitMap_Show method show
185 vgaRestore(data
->Regs
, FALSE
);
186 vgaRefreshArea(data
, 1, &box
);
188 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
190 XSD(cl
)->visible
= data
; /* Set created object as visible */
192 ReturnPtr("VGAGfx.BitMap::New()", OOP_Object
*, o
);
195 } /* if got data->VideoData */
197 } /* if got data->Regs */
200 OOP_MethodID disp_mid
= OOP_GetMethodID(IID_Root
, moRoot_Dispose
);
201 OOP_CoerceMethod(cl
, o
, (OOP_Msg
) &disp_mid
);
205 } /* if created object */
207 ReturnPtr("VGAGfx.BitMap::New()", OOP_Object
*, o
);
210 /********** Bitmap::Dispose() ***********************************/
212 VOID
PCVGAOnBM__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
214 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
215 EnterFunc(bug("VGAGfx.BitMap::Dispose()\n"));
218 FreeVec(data
->VideoData
);
222 OOP_DoSuperMethod(cl
, o
, msg
);
224 ReturnVoid("VGAGfx.BitMap::Dispose");
227 /*** init_onbmclass *********************************************************/
229 static int PCVGAOnBM_Init(LIBBASETYPEPTR LIBBASE
)
231 EnterFunc(bug("PCVGAOnBM_Init\n"));
233 ReturnInt("PCVGAOnBM_Init", ULONG
, OOP_ObtainAttrBases(attrbases
));
236 /*** expunge_onbmclass *******************************************************/
238 static int PCVGAOnBM_Expunge(LIBBASETYPEPTR LIBBASE
)
240 EnterFunc(bug("PCVGAOnBM_Expunge\n"));
242 OOP_ReleaseAttrBases(attrbases
);
243 ReturnInt("PCVGAOnBM_Expunge", int, TRUE
);
246 /*****************************************************************************/
248 ADD2INITLIB(PCVGAOnBM_Init
, 0)
249 ADD2EXPUNGELIB(PCVGAOnBM_Expunge
, 0)