2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 #include <exec/alerts.h>
10 #include <asm/registers.h>
16 #include <aros/debug.h>
19 /********* BitMap::Clear() *************************************/
20 static VOID
MNAME(clear
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_Clear
*msg
)
23 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
24 struct Box box
= {0, 0, 0, 0};
26 /* Get width & height from bitmap superclass */
28 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
29 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
34 memset(data
->VideoData
, GC_BG(msg
->gc
), width
*height
);
37 ObtainSemaphore(&XSD(cl
)->HW_acc
);
38 DisplayRefreshArea(data
, 1, &box
);
39 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
45 //void vgaRestore(struct vgaHWRec *, BOOL onlyDAC);
47 static BOOL
MNAME(setcolors
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_SetColors
*msg
)
49 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
50 HIDDT_PixelFormat
*pf
;
54 HIDDT_Pixel red
, green
, blue
;
58 if ( vHidd_ColorModel_StaticPalette
== HIDD_PF_COLMODEL(pf
)
59 || vHidd_ColorModel_TrueColor
== HIDD_PF_COLMODEL(pf
) ) {
61 /* Superclass takes care of this case */
63 return OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
66 /* We have a vHidd_GT_Palette bitmap */
68 if (!OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
)) return FALSE
;
70 if ((msg
->firstColor
+ msg
->numColors
) > (1 << data
->bpp
))
73 for ( xc_i
= msg
->firstColor
, col_i
= 0;
74 col_i
< msg
->numColors
;
77 red
= msg
->colors
[col_i
].red
>> 8;
78 green
= msg
->colors
[col_i
].green
>> 8;
79 blue
= msg
->colors
[col_i
].blue
>> 8;
81 /* Set given color as allocated */
82 data
->cmap
[xc_i
] = 0x01000000 | red
| (green
<< 8) | (blue
<< 16);
84 msg
->colors
[col_i
].pixval
= xc_i
;
87 /* Restore palette if OnBitmap */
89 ObtainSemaphore(&XSD(cl
)->HW_acc
);
90 DisplayRestore((struct DisplayHWRec
*)data
->Regs
, TRUE
);
91 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
97 /********* BitMap::PutPixel() ***************************/
99 static VOID
MNAME(putpixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutPixel
*msg
)
101 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
108 #endif /* OnBitmap */
111 ptr
= (char *)(data
->VideoData
+ msg
->x
+ (msg
->y
* data
->width
));
117 ptr2
= (unsigned char *)(RREG_L(LSSA
) + (msg
->y
* RREG_B(LVPW
) * 2) + msg
->x
/ 8);
118 pix
= 0x80 >> (msg
->x
% 8);
128 /* ptr2 = (char *)(0xa0000 + (msg->x + (msg->y * data->width)) / 8);
129 pix = 0x8000 >> (msg->x % 8);
130 ObtainSemaphore(&XSD(cl)->HW_acc);
133 *ptr2 |= 1; // This or'ed value isn't important
135 ReleaseSemaphore(&XSD(cl)->HW_acc);
138 #endif /* OnBitmap */
143 /********* BitMap::GetPixel() *********************************/
144 static HIDDT_Pixel
MNAME(getpixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetPixel
*msg
)
147 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
151 ptr
= (char *)(data
->VideoData
+ msg
->x
+ (msg
->y
* data
->width
));
155 /* Get pen number from colortab */
159 /********* BitMap::PutImage() ***************************/
161 static VOID
MNAME(putimage
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImage
*msg
)
163 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
164 struct Box box
= {0, 0, 0, 0};
165 UBYTE
*buff
= data
->VideoData
+ msg
->x
+ (msg
->y
* data
->width
);
166 ULONG add
= data
->width
- msg
->width
;
167 ULONG cnt
= msg
->height
;
168 UBYTE
*s_start
= (UBYTE
*)msg
->pixels
;
169 BOOL done_by_superclass
= FALSE
;
172 EnterFunc(bug("DisplayGfx.BitMap::PutImage(pa=%p, x=%d, y=%d, w=%d, h=%d)\n",
173 msg
->pixels
, msg
->x
, msg
->y
, msg
->width
, msg
->height
));
177 case vHidd_StdPixFmt_Native
:
189 s_start
+= msg
->modulo
;
194 case vHidd_StdPixFmt_Native32
:
197 HIDDT_Pixel
*p
= (HIDDT_Pixel
*)s_start
;
202 *buff
++ = (UBYTE
)*p
++;
206 s_start
+= msg
->modulo
;
212 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
213 done_by_superclass
= TRUE
;
218 if (data
->disp
&& !done_by_superclass
)
222 box
.x2
= box
.x1
+ msg
->width
- 1;
223 box
.y2
= box
.y1
+ msg
->height
- 1;
225 ObtainSemaphore(&XSD(cl
)->HW_acc
);
227 DisplayRefreshArea(data
, 1, &box
);
229 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
233 ReturnVoid("DisplayGfx.BitMap::PutImage");
236 /********* BitMap::GetImage() ***************************/
238 static VOID
MNAME(getimage
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImage
*msg
)
240 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
241 UBYTE
*buff
= data
->VideoData
+ msg
->x
+ (msg
->y
* data
->width
);
242 ULONG add
= data
->width
- msg
->width
;
243 ULONG cnt
= msg
->height
;
244 UBYTE
*s_start
= (UBYTE
*)msg
->pixels
;
249 case vHidd_StdPixFmt_Native
:
261 s_start
+= msg
->modulo
;
266 case vHidd_StdPixFmt_Native32
:
269 HIDDT_Pixel
*p
= (HIDDT_Pixel
*)s_start
;
274 *p
++ = (HIDDT_Pixel
)*buff
++;
278 s_start
+= msg
->modulo
;
285 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
288 } /* switch(msg->pixFmt) */
292 /********* BitMap::PutImageLUT() ***************************/
294 static VOID
MNAME(putimagelut
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImageLUT
*msg
)
296 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
297 struct Box box
= {0, 0, 0, 0};
301 // start of Source data
302 unsigned char *buff
= data
->VideoData
+
303 msg
->x
+ (msg
->y
* data
->width
);
304 // adder for each line
305 ULONG add
= data
->width
- msg
->width
;
306 ULONG cnt
= msg
->height
;
308 unsigned char *s_start
= msg
->pixels
;
310 EnterFunc(bug("DisplayGfx.BitMap::PutImageLUT(pa=%p, x=%d, y=%d, w=%d, h=%d)\n",
311 msg
->pixels
, msg
->x
, msg
->y
, msg
->width
, msg
->height
));
318 *buff
++ = *s_start
++;
322 s_start
+= (msg
->modulo
- msg
->width
);
329 box
.x2
= box
.x1
+ msg
->width
- 1;
330 box
.y2
= box
.y1
+ msg
->height
- 1;
332 ObtainSemaphore(&XSD(cl
)->HW_acc
);
334 DisplayRefreshArea(data
, 1, &box
);
336 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
339 ReturnVoid("DisplayGfx.BitMap::PutImageLUT");
342 /********* BitMap::GetImageLUT() ***************************/
344 static VOID
MNAME(getimagelut
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImageLUT
*msg
)
346 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
350 // start of Source data
351 unsigned char *buff
= data
->VideoData
+
352 msg
->x
+ (msg
->y
* data
->width
);
353 // adder for each line
354 ULONG add
= data
->width
- msg
->width
;
355 ULONG cnt
= msg
->height
;
357 unsigned char *s_start
= msg
->pixels
;
364 *s_start
++ = *buff
++;
372 /********* BitMap::FillRect() ***************************/
374 static VOID
MNAME(fillrect
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_DrawRect
*msg
)
376 struct bitmap_data
*data
=OOP_INST_DATA(cl
, o
);
377 struct Box box
= {0, 0, 0, 0};
378 HIDDT_Pixel fg
= GC_FG(msg
->gc
);
379 HIDDT_DrawMode mode
= GC_DRMD(msg
->gc
);
382 ULONG width
= msg
->maxX
- msg
->minX
+ 1;
384 // start of video data
385 unsigned char *s_start
= data
->VideoData
+
386 msg
->minX
+ (msg
->minY
* data
->width
);
388 // adder for each line
389 ULONG s_add
= data
->width
- width
;
390 ULONG cnt
= msg
->maxY
- msg
->minY
+ 1;
392 EnterFunc(bug("DisplayGfx.BitMap::FillRect(%d,%d,%d,%d)\n",
393 msg
->minX
, msg
->minY
, msg
->maxX
, msg
->maxY
));
395 if ((phase
= (long)s_start
& 3L))
398 if (phase
> width
) phase
= width
;
404 case vHidd_GC_DrawMode_Copy
:
405 fg
|= ((char)fg
) << 8;
406 fg
|= ((short)fg
) << 16;
414 *(unsigned char*)s_start
++ = (char)fg
;
418 *((unsigned long*)s_start
) = fg
;
424 *(unsigned char*)s_start
++ = (char)fg
;
430 case vHidd_GC_DrawMode_Invert
:
434 unsigned long bglong
;
441 *(unsigned char*)s_start
++ = ~bg
;
445 bglong
= *(unsigned long *)s_start
;
446 *((unsigned long*)s_start
) = ~bglong
;
453 *(unsigned char*)s_start
++ = ~bg
;
460 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
473 ObtainSemaphore(&XSD(cl
)->HW_acc
);
475 DisplayRefreshArea(data
, 1, &box
);
477 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
481 ReturnVoid("DisplayGfx.BitMap::FillRect");
484 /*** BitMap::BlitColorExpansion() **********************************************/
485 static VOID
MNAME(blitcolorexpansion
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_BlitColorExpansion
*msg
)
488 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
493 EnterFunc(bug("DisplayGfx.BitMap::BlitColorExpansion(%p, %d, %d, %d, %d, %d, %d)\n"
494 , msg
->srcBitMap
, msg
->srcX
, msg
->srcY
, msg
->destX
, msg
->destY
, msg
->width
, msg
->height
));
498 cemd
= GC_COLEXP(msg
->gc
);
500 if (cemd
& vHidd_GC_ColExp_Opaque
)
502 for (y
= 0; y
< msg
->height
; y
++)
504 for (x
= 0; x
< msg
->width
; x
++)
508 is_set
= HIDD_BM_GetPixel(msg
->srcBitMap
, x
+ msg
->srcX
, y
+ msg
->srcY
);
510 *(data
->VideoData
+ x
+ msg
->destX
+ ((y
+ msg
->destY
) * data
->width
)) = is_set
? fg
: bg
;
519 for (y
= 0; y
< msg
->height
; y
++)
521 for (x
= 0; x
< msg
->width
; x
++)
525 is_set
= HIDD_BM_GetPixel(msg
->srcBitMap
, x
+ msg
->srcX
, y
+ msg
->srcY
);
528 *(data
->VideoData
+ x
+ msg
->destX
+ ((y
+ msg
->destY
) * data
->width
)) = fg
;
539 box
.x2
= box
.x1
+ msg
->width
- 1;
540 box
.y2
= box
.y1
+ msg
->height
- 1;
542 ObtainSemaphore(&XSD(cl
)->HW_acc
);
544 DisplayRefreshArea(data
, 1, &box
);
546 ReleaseSemaphore(&XSD(cl
)->HW_acc
);
549 ReturnVoid("DisplayGfx.BitMap::BlitColorExpansion");
552 /*** BitMap::Get() *******************************************/
554 static VOID
MNAME(get
)(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
556 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
559 if (IS_DisplayBM_ATTR(msg
->attrID
, idx
))
563 case aoHidd_DisplayBitMap_Drawable
:
564 *msg
->storage
= (ULONG
)data
->VideoData
;
568 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
574 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);