2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
9 #include <exec/alerts.h>
10 #include <string.h> // memset() prototype
14 #include <aros/debug.h>
17 /********* BitMap::Clear() *************************************/
18 VOID
MNAME_BM(Clear
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_Clear
*msg
)
21 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
22 struct Box box
= {0, 0, 0, 0};
24 /* Get width & height from bitmap superclass */
26 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
27 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
32 memset(data
->VideoData
, GC_BG(msg
->gc
), width
*height
);
35 ObtainSemaphore(&XSD(cl
)->HW_acc
);
36 vgaRefreshArea(data
, 1, &box
);
38 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
44 void vgaDACLoad(struct vgaHWRec
*, unsigned char, int);
46 BOOL
MNAME_BM(SetColors
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_SetColors
*msg
)
48 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
49 HIDDT_PixelFormat
*pf
;
53 HIDDT_Pixel red
, green
, blue
;
57 if ( vHidd_ColorModel_StaticPalette
== HIDD_PF_COLMODEL(pf
)
58 || vHidd_ColorModel_TrueColor
== HIDD_PF_COLMODEL(pf
) ) {
60 /* Superclass takes care of this case */
62 return OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
65 /* We have a vHidd_GT_Palette bitmap */
67 if (!OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
)) return FALSE
;
69 if ((msg
->firstColor
+ msg
->numColors
) > (1 << data
->bpp
))
72 for ( xc_i
= msg
->firstColor
, col_i
= 0;
73 col_i
< msg
->numColors
;
76 red
= msg
->colors
[col_i
].red
>> 8;
77 green
= msg
->colors
[col_i
].green
>> 8;
78 blue
= msg
->colors
[col_i
].blue
>> 8;
80 /* Set given color as allocated */
81 data
->cmap
[xc_i
] = 0x01000000 | red
| (green
<< 8) | (blue
<< 16);
83 /* Update DAC registers */
84 data
->Regs
->DAC
[xc_i
*3] = red
>> 2;
85 data
->Regs
->DAC
[xc_i
*3+1] = green
>> 2;
86 data
->Regs
->DAC
[xc_i
*3+2] = blue
>> 2;
88 msg
->colors
[col_i
].pixval
= xc_i
;
91 /* Restore palette if OnBitmap */
93 ObtainSemaphore(&XSD(cl
)->HW_acc
);
94 vgaDACLoad(data
->Regs
, msg
->firstColor
, msg
->numColors
);
95 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
101 /********* BitMap::PutPixel() ***************************/
103 VOID
MNAME_BM(PutPixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutPixel
*msg
)
105 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
113 #endif /* OnBitmap */
116 ptr
= (char *)(data
->VideoData
+ msg
->x
+ (msg
->y
* data
->width
));
121 ptr2
= (char *)(0xa0000 + (msg
->x
+ (msg
->y
* data
->width
)) / 8);
122 pix
= 0x8000 >> (msg
->x
% 8);
123 ObtainSemaphore(&XSD(cl
)->HW_acc
);
129 outw(0x3ce,(fg
<< 8));
132 *ptr2
|= 1; // This or'ed value isn't important
134 if (((msg
->x
>= XSD(cl
)->mouseX
) && (msg
->x
< (XSD(cl
)->mouseX
+ XSD(cl
)->mouseW
))) ||
135 ((msg
->y
>= XSD(cl
)->mouseY
) && (msg
->y
< (XSD(cl
)->mouseY
+ XSD(cl
)->mouseH
))))
138 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
140 #endif /* OnBitmap */
145 /********* BitMap::GetPixel() *********************************/
146 HIDDT_Pixel
MNAME_BM(GetPixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetPixel
*msg
)
149 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
153 ptr
= (char *)(data
->VideoData
+ msg
->x
+ (msg
->y
* data
->width
));
157 /* Get pen number from colortab */
161 /********* BitMap::PutImage() ***************************/
163 VOID
MNAME_BM(PutImage
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImage
*msg
)
165 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
166 struct Box box
= {0, 0, 0, 0};
167 BOOL done_by_superclass
= FALSE
;
170 EnterFunc(bug("VGAGfx.BitMap::PutImage(pa=%p, x=%d, y=%d, w=%d, h=%d)\n",
171 msg
->pixels
, msg
->x
, msg
->y
, msg
->width
, msg
->height
));
175 case vHidd_StdPixFmt_Native
:
176 HIDD_BM_CopyMemBox8(o
,
189 case vHidd_StdPixFmt_Native32
:
190 HIDD_BM_PutMem32Image8(o
,
202 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
203 done_by_superclass
= TRUE
;
208 if (data
->disp
&& !done_by_superclass
)
212 box
.x2
= box
.x1
+ msg
->width
- 1;
213 box
.y2
= box
.y1
+ msg
->height
- 1;
215 ObtainSemaphore(&XSD(cl
)->HW_acc
);
217 vgaRefreshArea(data
, 1, &box
);
219 if ( ( (XSD(cl
)->mouseX
+ XSD(cl
)->mouseW
- 1 >= box
.x1
) &&
220 (XSD(cl
)->mouseX
<= box
.x2
) ) ||
221 ( (XSD(cl
)->mouseY
+ XSD(cl
)->mouseH
- 1 >= box
.y1
) &&
222 (XSD(cl
)->mouseY
<= box
.y2
) ) )
225 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
229 ReturnVoid("VGAGfx.BitMap::PutImage");
232 /********* BitMap::GetImage() ***************************/
234 VOID
MNAME_BM(GetImage
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImage
*msg
)
236 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
241 case vHidd_StdPixFmt_Native
:
242 HIDD_BM_CopyMemBox8(o
,
255 case vHidd_StdPixFmt_Native32
:
256 HIDD_BM_GetMem32Image8(o
,
269 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
272 } /* switch(msg->pixFmt) */
276 /********* BitMap::PutImageLUT() ***************************/
278 VOID
MNAME_BM(PutImageLUT
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImageLUT
*msg
)
280 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
281 struct Box box
= {0, 0, 0, 0};
283 EnterFunc(bug("VGAGfx.BitMap::PutImageLUT(pa=%p, x=%d, y=%d, w=%d, h=%d)\n",
284 msg
->pixels
, msg
->x
, msg
->y
, msg
->width
, msg
->height
));
286 HIDD_BM_CopyMemBox8(o
,
302 box
.x2
= box
.x1
+ msg
->width
- 1;
303 box
.y2
= box
.y1
+ msg
->height
- 1;
305 ObtainSemaphore(&XSD(cl
)->HW_acc
);
307 vgaRefreshArea(data
, 1, &box
);
309 if ( ( (XSD(cl
)->mouseX
+ XSD(cl
)->mouseW
- 1 >= box
.x1
) &&
310 (XSD(cl
)->mouseX
<= box
.x2
) ) ||
311 ( (XSD(cl
)->mouseY
+ XSD(cl
)->mouseH
- 1 >= box
.y1
) &&
312 (XSD(cl
)->mouseY
<= box
.y2
) ) )
315 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
318 ReturnVoid("VGAGfx.BitMap::PutImageLUT");
321 /********* BitMap::GetImageLUT() ***************************/
323 VOID
MNAME_BM(GetImageLUT
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImageLUT
*msg
)
325 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
327 HIDD_BM_CopyMemBox8(o
,
341 /********* BitMap::FillRect() ***************************/
343 VOID
MNAME_BM(FillRect
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_DrawRect
*msg
)
345 struct bitmap_data
*data
=OOP_INST_DATA(cl
, o
);
346 struct Box box
= {0, 0, 0, 0};
347 HIDDT_Pixel fg
= GC_FG(msg
->gc
);
348 HIDDT_DrawMode mode
= GC_DRMD(msg
->gc
);
350 EnterFunc(bug("VGAGfx.BitMap::FillRect(%d,%d,%d,%d)\n",
351 msg
->minX
, msg
->minY
, msg
->maxX
, msg
->maxY
));
355 case vHidd_GC_DrawMode_Copy
:
356 HIDD_BM_FillMemRect8(o
,
366 case vHidd_GC_DrawMode_Invert
:
367 HIDD_BM_InvertMemRect(o
,
377 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
390 ObtainSemaphore(&XSD(cl
)->HW_acc
);
392 vgaRefreshArea(data
, 1, &box
);
393 if ( ( (XSD(cl
)->mouseX
+ XSD(cl
)->mouseW
- 1 >= box
.x1
) &&
394 (XSD(cl
)->mouseX
<= box
.x2
) ) ||
395 ( (XSD(cl
)->mouseY
+ XSD(cl
)->mouseH
- 1 >= box
.y1
) &&
396 (XSD(cl
)->mouseY
<= box
.y2
) ) )
399 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
403 ReturnVoid("VGAGfx.BitMap::FillRect");
406 /*** BitMap::BlitColorExpansion() **********************************************/
407 VOID
MNAME_BM(BlitColorExpansion
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_BlitColorExpansion
*msg
)
410 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
415 EnterFunc(bug("VGAGfx.BitMap::BlitColorExpansion(%p, %d, %d, %d, %d, %d, %d)\n"
416 , msg
->srcBitMap
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
));
420 cemd
= GC_COLEXP(msg
->gc
);
422 if (cemd
& vHidd_GC_ColExp_Opaque
)
424 for (y
= 0; y
< msg
->height
; y
++)
426 for (x
= 0; x
< msg
->width
; x
++)
430 is_set
= HIDD_BM_GetPixel(msg
->srcBitMap
, x
+ msg
->srcX
, y
+ msg
->srcY
);
432 *(data
->VideoData
+ x
+ msg
->destX
+ ((y
+ msg
->destY
) * data
->width
)) = is_set
? fg
: bg
;
441 for (y
= 0; y
< msg
->height
; y
++)
443 for (x
= 0; x
< msg
->width
; x
++)
447 is_set
= HIDD_BM_GetPixel(msg
->srcBitMap
, x
+ msg
->srcX
, y
+ msg
->srcY
);
450 *(data
->VideoData
+ x
+ msg
->destX
+ ((y
+ msg
->destY
) * data
->width
)) = fg
;
461 box
.x2
= box
.x1
+ msg
->width
- 1;
462 box
.y2
= box
.y1
+ msg
->height
- 1;
464 ObtainSemaphore(&XSD(cl
)->HW_acc
);
466 vgaRefreshArea(data
, 1, &box
);
467 if ( ( (XSD(cl
)->mouseX
+ XSD(cl
)->mouseW
- 1 >= box
.x1
) &&
468 (XSD(cl
)->mouseX
<= box
.x2
) ) ||
469 ( (XSD(cl
)->mouseY
+ XSD(cl
)->mouseH
- 1 >= box
.y1
) &&
470 (XSD(cl
)->mouseY
<= box
.y2
) ) )
473 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
476 ReturnVoid("VGAGfx.BitMap::BlitColorExpansion");
479 /*** BitMap::Get() *******************************************/
481 VOID
MNAME_ROOT(Get
)(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
483 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
485 if (IS_VGABM_ATTR(msg
->attrID
, idx
))
489 case aoHidd_VGABitMap_Drawable
:
490 *msg
->storage
= (ULONG
)data
->VideoData
;
494 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
500 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);