revert 213 commits (to 56092) from the last month. 10 still need work to resolve...
[AROS.git] / arch / m68k-amiga / hidd / p96gfx / p96gfx_bitmapclass.c
blob81061f90fcaa66b83eb7f70e33865e51f1165269
1 /*
2 Copyright 1995-2019, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Bitmap class for p96 rtg card drivers.
6 Lang: English.
8 */
10 /****************************************************************************************/
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <string.h>
16 #include <proto/oop.h>
17 #include <proto/utility.h>
18 #include <exec/alerts.h>
19 #include <aros/macros.h>
20 #include <exec/memory.h>
21 #include <exec/lists.h>
22 #include <graphics/rastport.h>
23 #include <graphics/gfx.h>
24 #include <graphics/gfxbase.h>
25 #include <oop/oop.h>
26 #include <hidd/gfx.h>
27 #include <aros/symbolsets.h>
29 #include <hardware/custom.h>
31 #define DEBUG 0
32 #define DB2(x)
33 #define DEBUG_TEXT(x)
34 #define DVRAM(x)
35 #define DCLUT(x)
36 #include <aros/debug.h>
38 #include LC_LIBDEFS_FILE
40 #include "p96gfx_intern.h"
41 #include "p96gfx_bitmap.h"
42 #include "p96gfx_rtg.h"
44 /* LOCK_BITMAP_MULTI:
46 swap bitmap between RAM <-> VRAM allowed only if this lock is held
48 the bitmap being swapped must also get LOCK_BITMAP lock, otherwise
49 gfx functions (done by other tasks) could render into wrong place while
50 bitmap is moved around.
54 /* poke 0xFF into the videodata for debugging purposes - may be dangerous on some cards! */
55 /*#define DEBUG_POKE_VIDEODATA*/
57 static BOOL P96GFXBitmap__ToFRAM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm);
59 static APTR P96GFXBitmap__AllocVRAM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm)
61 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
62 struct p96gfx_carddata *cid = data->gfxCardData;
63 struct p96gfx_staticdata *csd = CSD(cl);
64 APTR vmem;
66 DVRAM(bug("[P96Gfx:Bitmap] %s()\n", __func__));
68 SetMemoryMode(cid, RGBFB_CLUT);
69 vmem = Allocate(cid->vmem, bm->memsize);
70 SetMemoryMode(cid, bm->rgbformat);
71 if (vmem)
73 DVRAM(bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p (%dx%dx%d %d): %p,%d bytes VRAM allocated.\n", __func__, bm, bm->width, bm->height, bm->bytesperpixel*8, bm->bytesperline, vmem, bm->memsize));
75 return vmem;
78 static BOOL P96GFXBitmap__AllocBM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm, BOOL usevram)
80 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
81 struct p96gfx_carddata *cid = data->gfxCardData;
82 struct p96gfx_staticdata *csd = CSD(cl);
83 bm->memsize = (bm->bytesperline * bm->height + 7) & ~7;
85 if (!(bm->VideoData = P96GFXBitmap__AllocVRAM(cl, o, bm)))
87 if (usevram && bm->memsize < cid->vram_size)
89 struct P96GfxBitMapData *bmnode;
90 ForeachNode(&cid->bitmaplist, bmnode)
92 if (bmnode != bm && bmnode->invram && !bmnode->locked)
94 if (P96GFXBitmap__ToFRAM(cl, o, bmnode))
96 if ((bm->VideoData = P96GFXBitmap__AllocVRAM(cl, o, bm)))
98 cid->vram_used += bm->memsize;
99 bm->invram = TRUE;
100 break;
107 if (!bm->VideoData)
109 bm->VideoData = AllocMem(bm->memsize, MEMF_ANY);
110 if (bm->VideoData)
112 cid->fram_used += bm->memsize;
116 else
118 cid->vram_used += bm->memsize;
119 bm->invram = TRUE;
121 DVRAM(bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p (%p:%d) bytes allocated from %s. VRAM=%d\n", __func__, bm, bm->VideoData, bm->memsize, bm->invram ? "VRAM" : "RAM", cid->vram_used));
123 #ifdef DEBUG_POKE_VIDEODATA
124 /* poke 0xFF into the videodata for debugging purposes - may be dangerous on some cards! */
125 if (bm->VideoData != NULL)
127 int i;
129 for(i = 0; i < bm->memsize; i++) bm->VideoData[i] = 0xFF;
131 #endif
132 return bm->VideoData != NULL;
135 static void P96GFXBitmap__FreeBM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm)
137 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
138 struct p96gfx_carddata *cid = data->gfxCardData;
139 struct p96gfx_staticdata *csd = CSD(cl);
141 DVRAM(
142 bug("[P96Gfx:Bitmap] %s()\n", __func__);
143 bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p: freeing %p:%d from %s\n", __func__, bm, bm->VideoData, bm->memsize, bm->invram ? "VRAM" : "RAM");
146 if (bm->invram)
148 SetMemoryMode(cid, RGBFB_CLUT);
149 Deallocate(cid->vmem, bm->VideoData, bm->memsize);
150 SetMemoryMode(cid, bm->rgbformat);
151 cid->vram_used -= bm->memsize;
153 else if (bm->VideoData)
155 FreeMem(bm->VideoData, bm->memsize);
156 cid->fram_used -= bm->memsize;
158 bm->VideoData = NULL;
159 bm->invram = FALSE;
162 static BOOL P96GFXBitmap__ToFRAM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm)
164 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
165 struct p96gfx_carddata *cid = data->gfxCardData;
166 struct p96gfx_staticdata *csd = CSD(cl);
167 BOOL ok = FALSE;
168 APTR vmem;
170 DVRAM(bug("[P96Gfx:Bitmap] %s()\n", __func__));
172 /* TRYLOCK here as we are in wrong locking order (could deadlock):
174 LOCK_BITMAP_MULTI -> LOCK_HW -> [...] <- UNLOCK_HW <- UNLOCK_BITMAP_MULTI
175 (Correct locking order is: LOCK_BM_MULTI -> LOCK_BM -> LOCK_HW)
177 Alternative would be to always lock all (swappable) bitmaps during bitmap
178 allocation/freeing routines. */
180 if (TRYLOCK_BITMAP(bm))
182 vmem = AllocMem(bm->memsize, MEMF_ANY);
183 if (vmem)
185 SetMemoryMode(cid, bm->rgbformat);
186 CopyMemQuick(bm->VideoData, vmem, bm->memsize);
187 P96GFXBitmap__FreeBM(cl, o, bm);
188 bm->VideoData = vmem;
189 bm->invram = FALSE;
190 cid->fram_used += bm->memsize;
191 ok = TRUE;
193 DVRAM(bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p (%p:%d) %d x %d moved to RAM . VRAM=%d\n", __func__, bm->VideoData, bm->memsize, bm, bm->width, bm->height, cid->vram_used));
195 UNLOCK_BITMAP(bm)
198 return ok;
201 static BOOL P96GFXBitmap__BMToVRAM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm)
203 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
204 struct p96gfx_carddata *cid = data->gfxCardData;
205 struct p96gfx_staticdata *csd = CSD(cl);
206 APTR vmem;
208 DVRAM(bug("[P96Gfx:Bitmap] %s()\n", __func__));
210 vmem = P96GFXBitmap__AllocVRAM(cl, o, bm);
211 if (vmem)
213 SetMemoryMode(cid, bm->rgbformat);
214 CopyMemQuick(bm->VideoData, vmem, bm->memsize);
215 P96GFXBitmap__FreeBM(cl, o, bm);
216 bm->VideoData = vmem;
217 bm->invram = TRUE;
218 cid->vram_used += bm->memsize;
219 DVRAM(bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p (%p:%d) %d x %d moved back to VRAM\n", __func__, bm, bm->VideoData, bm->memsize, bm->width, bm->height));
220 return TRUE;
222 return FALSE;
225 static BOOL P96GFXBitmap__ToVRAM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm)
227 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
228 struct p96gfx_carddata *cid = data->gfxCardData;
229 struct p96gfx_staticdata *csd = CSD(cl);
230 struct P96GfxBitMapData *bmnode;
232 DVRAM(bug("[P96Gfx:Bitmap] %s()\n", __func__));
234 if (bm->invram)
235 return TRUE;
237 DVRAM(bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p (%p:%d) needs to be in VRAM...\n", __func__, bm, bm->VideoData, bm->memsize));
239 ForeachNode(&cid->bitmaplist, bmnode)
241 if (bmnode != bm && bmnode->invram && !bmnode->locked)
243 if (P96GFXBitmap__ToFRAM(cl, o, bmnode))
245 if (P96GFXBitmap__BMToVRAM(cl, o, bm))
247 return TRUE;
253 DVRAM(bug("[P96Gfx:Bitmap] %s: -> not enough memory, VRAM=%d\n", __func__, cid->vram_used));
255 return FALSE;
258 #if 0
259 static BOOL maybeputinvram(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm)
261 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
262 struct p96gfx_carddata *cid = data->gfxCardData;
263 struct p96gfx_staticdata *csd = CSD(cl);
264 if (bm->invram)
265 return TRUE;
266 if (bm->memsize >= cid->vram_size - cid->vram_used)
267 return FALSE;
268 return P96GFXBitmap__BMToVRAM(cl, o, bm);
270 #endif
272 static void P96GFXBitmap__HideScreen(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm)
274 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
275 struct p96gfx_carddata *cid = data->gfxCardData;
276 struct p96gfx_staticdata *csd = CSD(cl);
278 D(bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p (%p:%d)\n",
279 __func__, bm, bm->VideoData, bm->memsize));
281 SetInterrupt(cid, FALSE);
282 SetDisplay(cid, FALSE);
283 SetSwitch(cid, FALSE);
284 cid->dmodeid = 0;
285 bm->locked--;
286 cid->disp = NULL;
289 /****************************************************************************************/
291 #define AO(x) (aoHidd_BitMap_ ## x)
292 #define GOT_BM_ATTR(code) GOT_ATTR(code, aoHidd_BitMap, bitmap)
294 /****************************************************************************************/
296 OOP_Object *P96GFXBitmap__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
298 struct p96gfx_staticdata *csd = CSD(cl);
299 BOOL ok = TRUE;
300 struct P96GfxBitMapData *data;
301 struct p96gfx_carddata *cid;
302 IPTR width, height, multi;
303 IPTR displayable;
304 struct TagItem tags[2];
305 ULONG softsflags;
307 DB2(bug("[P96Gfx:Bitmap] %s(%x)\n", __func__, o));
309 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
310 if (NULL == o)
312 return NULL;
315 data = OOP_INST_DATA(cl, o);
316 memset(data, 0, sizeof (*data));
317 InitSemaphore(&data->bmLock);
319 OOP_GetAttr(o, aHidd_BitMap_Width, &width);
320 OOP_GetAttr(o, aHidd_BitMap_Height, &height);
321 OOP_GetAttr(o, aHidd_BitMap_Displayable, &displayable);
322 OOP_GetAttr(o, aHidd_BitMap_GfxHidd, (APTR)&data->gfxhidd);
323 OOP_GetAttr(o, aHidd_BitMap_PixFmt, (APTR)&data->pixfmtobj);
324 OOP_GetAttr(data->pixfmtobj, aHidd_PixFmt_BytesPerPixel, &multi);
326 OOP_GetAttr(data->gfxhidd, aHidd_P96Gfx_CardData, (APTR)&data->gfxCardData);
327 DB2(bug("[P96Gfx:Bitmap] %s: Card Data @ 0x%p\n", __func__, data->gfxCardData));
328 cid = data->gfxCardData;
330 data->rgbformat = P96GFXRTG__GetFormat(csd, cid, data->pixfmtobj);
332 data->align = displayable ? 32 : 16;
333 width = (width + data->align - 1) & ~(data->align - 1);
334 data->bytesperline = CalculateBytesPerRow(cid, width, data->rgbformat);
335 data->width = width;
336 data->height = height;
337 data->bytesperpixel = multi;
339 LOCK_MULTI_BITMAP
341 LOCK_HW /* alloc routines call SetMemoryMode */
342 WaitBlitter(cid); /* in case bitmaps are swapped between RAM <-> VRAM during allocation */
343 P96GFXBitmap__AllocBM(cl, o, data, TRUE);
344 UNLOCK_HW
346 AddTail(&cid->bitmaplist, (struct Node*)&data->node);
348 UNLOCK_MULTI_BITMAP
350 tags[0].ti_Tag = aHidd_BitMap_BytesPerRow;
351 tags[0].ti_Data = data->bytesperline;
352 tags[1].ti_Tag = TAG_DONE;
353 OOP_SetAttrs(o, tags);
355 DB2(bug("[P96Gfx:Bitmap] %s: %dx%dx%d %d RGBF=%08x P=%08x\n", __func__, width, height, multi, data->bytesperline, data->rgbformat, data->VideoData));
357 if (data->VideoData == NULL)
358 ok = FALSE;
360 if (!ok) {
361 OOP_MethodID dispose_mid;
362 dispose_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
363 OOP_CoerceMethod(cl, o, (OOP_Msg)&dispose_mid);
364 o = NULL;
367 DB2(bug("[P96Gfx:Bitmap] %s: ret=%x bm=%p (%p:%d)\n", __func__, o, data, data->VideoData, data->memsize));
369 return o;
372 VOID P96GFXBitmap__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
374 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
375 struct p96gfx_carddata *cid = data->gfxCardData;
376 struct p96gfx_staticdata *csd = CSD(cl);
378 D(bug("[P96Gfx:Bitmap] %s(%x)\n", __func__, o));
380 LOCK_HW
381 WaitBlitter(cid);
383 DB2(bug("[P96Gfx:Bitmap] %s: bm=%x (%p,%d)\n", __func__, data, data->VideoData, data->memsize));
384 if (cid->disp == data)
385 P96GFXBitmap__HideScreen(cl, o, data);
387 UNLOCK_HW
389 FreeVec(data->palette);
391 LOCK_MULTI_BITMAP
393 LOCK_HW /* free functions call SetMemoryMode */
394 P96GFXBitmap__FreeBM(cl, o, data);
395 UNLOCK_HW
397 Remove((struct Node*)&data->node);
399 UNLOCK_MULTI_BITMAP
401 OOP_DoSuperMethod(cl, o, msg);
404 VOID P96GFXBitmap__Root__Set(OOP_Class *cl, OOP_Object *o, struct pRoot_Set *msg)
406 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
407 struct p96gfx_carddata *cid = data->gfxCardData;
408 struct p96gfx_staticdata *csd = CSD(cl);
409 struct TagItem *tag, *tstate;
410 ULONG idx;
411 BOOL moved = FALSE;
413 DB2(bug("[P96Gfx:Bitmap] %s: %p (%p:%d)\n", __func__, data, data->VideoData, data->memsize));
414 tstate = msg->attrList;
415 while((tag = NextTagItem(&tstate)))
417 DB2(bug("[P96Gfx:Bitmap] %s: Tag %d/%d\n", __func__, tag->ti_Tag, tag->ti_Data));
418 if(IS_BITMAP_ATTR(tag->ti_Tag, idx))
420 DB2(bug("[P96Gfx:Bitmap] %s: BitMap Attr ->%d\n", __func__, idx));
421 switch(idx)
423 case aoHidd_BitMap_Focus:
425 ULONG boardType = gl(data->gfxCardData->boardinfo + PSSO_BoardInfo_BoardType);
426 DB2(bug("[P96Gfx:Bitmap] %s: aoHidd_BitMap_Focus\n", __func__);)
427 if (boardType == P96BoardType_Vampire)
429 struct GfxBase *GfxBase = (struct GfxBase *)csd->cs_GfxBase;
430 volatile struct Custom *custom = (struct Custom*)0xdff000;
431 /* Tell the Vampire SAGA chipset we are visible */
432 custom->bplcon0 = GfxBase->system_bplcon0 | 0x80;
435 break;
437 case aoHidd_BitMap_Visible:
438 LOCK_MULTI_BITMAP
439 LOCK_BITMAP(data)
440 LOCK_HW
441 if (tag->ti_Data) {
442 OOP_Object *gfxhidd, *sync, *pf;
443 IPTR modeid = vHidd_ModeID_Invalid;
444 IPTR dwidth, dheight, depth, width, height;
445 struct ModeInfo *modeinfo;
447 width = data->width;
448 height = data->height;
449 OOP_GetAttr(o, aHidd_BitMap_ModeID , &modeid);
450 OOP_GetAttr(o, aHidd_BitMap_GfxHidd, (IPTR *)&gfxhidd);
451 HIDD_Gfx_GetMode(gfxhidd, modeid, &sync, &pf);
452 OOP_GetAttr(sync, aHidd_Sync_HDisp, &dwidth);
453 OOP_GetAttr(sync, aHidd_Sync_VDisp, &dheight);
454 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
455 data->rgbformat = P96GFXRTG__GetFormat(csd, cid, pf);
456 modeinfo = P96GFXRTG__GetModeInfo(csd, cid, sync, pf, cid->fakemodeinfo);
457 cid->modeinfo = modeinfo;
458 *cid->rgbformat = data->rgbformat;
459 pw(cid->bitmapextra + PSSO_BitMapExtra_Width, width);
460 pw(cid->bitmapextra + PSSO_BitMapExtra_Height, height);
461 D(bug("[P96Gfx:Bitmap] %s: Show %p: (%p:%d) %dx%dx%d (%dx%d) BF=%08x\n",
462 __func__, data, data->VideoData, data->memsize,
463 dwidth, dheight, depth, width, height, data->rgbformat));
465 if (!data->invram)
467 WaitBlitter(cid); /* in case other bitmaps are swapped from VRAM to RAM */
468 if (!P96GFXBitmap__ToVRAM(cl, o, data))
470 struct P96GfxBitMapData *bmnode;
472 /* Second try. Now lock all bitmaps first. UNLOCK_HW first, to ensure
473 correct locking order: multibm -> bm -> hw */
475 UNLOCK_HW
477 ForeachNode(&cid->bitmaplist, bmnode)
479 if (bmnode != data) LOCK_BITMAP(bmnode)
482 LOCK_HW
483 WaitBlitter(cid); /* in case other bitmaps are swapped from VRAM to RAM */
484 P96GFXBitmap__ToVRAM(cl, o, data); /* shouldn't fail this time. If it does we are screwed ... */
485 UNLOCK_HW
487 ForeachNode(&cid->bitmaplist, bmnode)
489 if (bmnode != data) UNLOCK_BITMAP(bmnode)
492 LOCK_HW
496 cid->dwidth = dwidth;
497 cid->dheight = dheight;
498 cid->dmodeid = modeid;
500 if (cid->hardwaresprite && depth <= 8) {
501 HIDDT_Color c;
502 UWORD i;
503 UBYTE *clut = data->gfxCardData->boardinfo + PSSO_BoardInfo_CLUT;
504 for (i = cid->spritepencnt + 1; i < cid->spritepencnt + 4; i++)
506 c.red = clut[i * 3 + 0];
507 c.green = clut[i * 3 + 1];
508 c.blue = clut[i * 3 + 2];
509 HIDD_P96GFX_SetCursorPen(gfxhidd, i, c);
512 SetInterrupt(cid, FALSE);
513 SetColorArray(cid, 0, 256);
514 SetDisplay(cid, FALSE);
515 SetGC(cid, modeinfo, 0);
516 SetClock(cid);
517 SetDAC(cid);
518 SetPanning(cid, data->VideoData, width, 0, 0);
519 SetDisplay(cid, TRUE);
520 SetSwitch(cid, TRUE);
521 SetInterrupt(cid, TRUE);
522 cid->disp = data;
523 cid->disp->locked++;
524 } else {
525 P96GFXBitmap__HideScreen(cl, o, data);
527 UNLOCK_HW
528 UNLOCK_BITMAP(data)
529 UNLOCK_MULTI_BITMAP
531 break;
532 case aoHidd_BitMap_LeftEdge:
533 if (data->leftedge != tag->ti_Data) {
534 data->leftedge = tag->ti_Data;
535 moved = TRUE;
537 break;
538 case aoHidd_BitMap_TopEdge:
539 if (data->topedge != tag->ti_Data) {
540 data->topedge = tag->ti_Data;
541 moved = TRUE;
543 break;
547 D(bug("[P96Gfx:Bitmap] %s: Exit\n", __func__));
548 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
549 #if 0
550 if (moved && cid->disp == data)
551 setscroll(cid, data);
552 #else
553 (void)moved;
554 #endif
557 VOID P96GFXBitmap__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
559 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
560 struct p96gfx_carddata *cid = data->gfxCardData;
561 struct p96gfx_staticdata *csd = CSD(cl);
562 ULONG idx;
564 //DB2(bug("P96GFXBitmap__Root__Get\n"));
565 if (IS_BITMAP_ATTR(msg->attrID, idx)) {
566 //DB2(bug("=%d\n", idx));
567 switch (idx) {
568 case aoHidd_BitMap_LeftEdge:
569 *msg->storage = 0;//data->leftedge;
570 return;
571 case aoHidd_BitMap_TopEdge:
572 *msg->storage = 0;//data->topedge;
573 return;
574 case aoHidd_BitMap_Visible:
575 *msg->storage = cid->disp == data;
576 return;
577 case aoHidd_BitMap_Align:
578 *msg->storage = data->align;
579 return;
580 case aoHidd_BitMap_BytesPerRow:
581 *msg->storage = data->bytesperline;
582 return;
583 case aoHidd_BitMap_IsLinearMem:
584 *msg->storage = TRUE;
585 return;
588 //DB2(bug("P96GFXBitmap__Root__Get Exit\n"));
589 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
592 /****************************************************************************************/
594 static int P96GFXBitmap_Init(LIBBASETYPEPTR LIBBASE)
596 D(bug("[P96Gfx:Bitmap] %s()\n", __func__));
597 return TRUE; //return OOP_ObtainAttrBases(attrbases);
600 /****************************************************************************************/
602 static int P96GFXBitmap_Expunge(LIBBASETYPEPTR LIBBASE)
604 D(bug("[P96Gfx:Bitmap] %s()\n", __func__));
605 //OOP_ReleaseAttrBases(attrbases);
606 return TRUE;
609 /****************************************************************************************/
611 ADD2INITLIB(P96GFXBitmap_Init, 0);
612 ADD2EXPUNGELIB(P96GFXBitmap_Expunge, 0);
614 BOOL P96GFXBitmap__Hidd_BitMap__ObtainDirectAccess(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_ObtainDirectAccess *msg)
616 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
617 struct p96gfx_carddata *cid = data->gfxCardData;
618 struct p96gfx_staticdata *csd = CSD(cl);
620 LOCK_BITMAP(data)
622 #if 0
623 if (!data->invram) {
624 if (!P96GFXBitmap__ToVRAM(cl, o, data))
625 return FALSE;
627 #endif
629 *msg->addressReturn = data->VideoData;
630 *msg->widthReturn = data->width;
631 *msg->heightReturn = data->height;
632 /* undocumented, just a guess.. */
633 *msg->bankSizeReturn = *msg->memSizeReturn = data->bytesperline * data->height;
634 data->locked++;
636 LOCK_HW
637 WaitBlitter(cid);
638 UNLOCK_HW
640 return TRUE;
643 VOID P96GFXBitmap__Hidd_BitMap__ReleaseDirectAccess(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_ReleaseDirectAccess *msg)
645 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
646 struct p96gfx_carddata *cid = data->gfxCardData;
647 struct p96gfx_staticdata *csd = CSD(cl);
649 data->locked--;
651 UNLOCK_BITMAP(data)
654 BOOL P96GFXBitmap__Hidd_BitMap__SetColors(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_SetColors *msg)
656 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
657 struct p96gfx_carddata *cid = data->gfxCardData;
658 struct p96gfx_staticdata *csd = CSD(cl);
659 WORD i, j;
660 UBYTE *clut;
662 DCLUT(bug("[P96Gfx:Bitmap] %s()\n", __func__));
664 if (!OOP_DoSuperMethod(cl, o, (OOP_Msg)msg))
665 return FALSE;
667 LOCK_HW
669 WaitBlitter(cid);
670 clut = data->gfxCardData->boardinfo + PSSO_BoardInfo_CLUT;
671 DCLUT(bug("[P96Gfx:Bitmap] %s: CLUT @ %p\n", __func__, clut));
673 for (i = msg->firstColor, j = 0; j < msg->numColors; i++, j++) {
674 clut[i * 3 + 0] = msg->colors[j].red >> 8;
675 clut[i * 3 + 1] = msg->colors[j].green >> 8;
676 clut[i * 3 + 2] = msg->colors[j].blue >> 8;
677 DCLUT(bug("[P96Gfx:Bitmap] %s: color %d %02x%02x%02x\n", __func__, i, msg->colors[j].red >> 8, msg->colors[j].green >> 8, msg->colors[j].blue >> 8));
679 SetColorArray(cid, msg->firstColor, msg->numColors);
681 UNLOCK_HW
683 return TRUE;
686 VOID P96GFXBitmap__Hidd_BitMap__PutPixel(OOP_Class *cl, OOP_Object *o,
687 struct pHidd_BitMap_PutPixel *msg)
689 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
690 struct p96gfx_carddata *cid = data->gfxCardData;
691 struct p96gfx_staticdata *csd = CSD(cl);
692 ULONG offset;
693 HIDDT_Pixel pixel = msg->pixel;
694 UBYTE *mem;
696 LOCK_BITMAP(data)
698 LOCK_HW
699 WaitBlitter(cid);
700 UNLOCK_HW
702 offset = (msg->x * data->bytesperpixel) + (msg->y * data->bytesperline);
703 mem = data->VideoData + offset;
705 switch(data->bytesperpixel)
707 case 1:
708 *(UBYTE *)mem = pixel;
709 break;
711 case 2:
712 *(UWORD *)mem = pixel;
713 break;
715 case 3:
716 *(UBYTE *)(mem) = pixel >> 16;
717 *(UBYTE *)(mem + 1) = pixel >> 8;
718 *(UBYTE *)(mem + 2) = pixel;
719 break;
721 case 4:
722 *(ULONG *)mem = pixel;
723 break;
726 UNLOCK_BITMAP(data)
728 return;
731 /****************************************************************************************/
733 ULONG P96GFXBitmap__Hidd_BitMap__GetPixel(OOP_Class *cl, OOP_Object *o,
734 struct pHidd_BitMap_GetPixel *msg)
736 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
737 struct p96gfx_carddata *cid = data->gfxCardData;
738 struct p96gfx_staticdata *csd = CSD(cl);
739 HIDDT_Pixel pixel = 0;
740 ULONG offset;
741 UBYTE *mem;
743 LOCK_BITMAP(data)
745 LOCK_HW
746 WaitBlitter(cid);
747 UNLOCK_HW
749 offset = (msg->x * data->bytesperpixel) +(msg->y * data->bytesperline);
750 mem = data->VideoData + offset;
752 switch(data->bytesperpixel)
754 case 1:
755 pixel = *(UBYTE *)mem;
756 break;
758 case 2:
759 pixel = *(UWORD *)mem;
760 break;
762 case 3:
763 pixel = (mem[0] << 16) | (mem[1] << 8) | mem[2];
764 break;
766 case 4:
767 pixel = *(ULONG *)mem;
768 break;
771 UNLOCK_BITMAP(data)
773 return pixel;
776 /****************************************************************************************/
778 VOID P96GFXBitmap__Hidd_BitMap__DrawLine(OOP_Class *cl, OOP_Object *o,
779 struct pHidd_BitMap_DrawLine *msg)
781 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
782 struct p96gfx_carddata *cid = data->gfxCardData;
783 struct p96gfx_staticdata *csd = CSD(cl);
784 BOOL v = FALSE;
786 D(bug("[P96Gfx:Bitmap] %s()\n", __func__));
788 LOCK_HW
789 WaitBlitter(cid);
790 #if (0)
791 if (data->invram) {
792 struct RenderInfo ri;
793 struct Line renderLine;
794 P96GFXRTG__MakeRenderInfo(csd, cid, &ri, data);
795 renderline.FgPen = GC_FG(msg->gc);
796 renderline.BgPen = GC_BG(msg->gc);
797 renderline.LinePtrn = GC_LINEPAT(gc);
798 renderline.X = msg->x1;
799 renderline.Y = msg->y1;
800 renderline.dX = msg->x2;
801 renderline.dY = msg->y2;
802 v = DrawLine(cid, &ri, &renderLine, data->rgbformat);
804 #endif
805 UNLOCK_HW
807 if (!v) OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
810 /****************************************************************************************/
812 VOID P96GFXBitmap__Hidd_BitMap__GetImage(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_GetImage *msg)
814 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
815 struct p96gfx_carddata *cid = data->gfxCardData;
816 struct p96gfx_staticdata *csd = CSD(cl);
818 D(bug("[P96Gfx:Bitmap] %s()\n", __func__));
820 LOCK_BITMAP(data)
822 LOCK_HW
823 WaitBlitter(cid);
824 UNLOCK_HW
826 switch(msg->pixFmt)
828 case vHidd_StdPixFmt_Native:
829 switch(data->bytesperpixel)
831 case 1:
832 HIDD_BM_CopyMemBox8(o,
833 data->VideoData,
834 msg->x,
835 msg->y,
836 msg->pixels,
839 msg->width,
840 msg->height,
841 data->bytesperline,
842 msg->modulo);
843 break;
845 case 2:
846 HIDD_BM_CopyMemBox16(o,
847 data->VideoData,
848 msg->x,
849 msg->y,
850 msg->pixels,
853 msg->width,
854 msg->height,
855 data->bytesperline,
856 msg->modulo);
857 break;
859 case 3:
860 HIDD_BM_CopyMemBox24(o,
861 data->VideoData,
862 msg->x,
863 msg->y,
864 msg->pixels,
867 msg->width,
868 msg->height,
869 data->bytesperline,
870 msg->modulo);
871 break;
873 case 4:
874 HIDD_BM_CopyMemBox32(o,
875 data->VideoData,
876 msg->x,
877 msg->y,
878 msg->pixels,
881 msg->width,
882 msg->height,
883 data->bytesperline,
884 msg->modulo);
885 break;
886 } /* switch(data->bytesperpix) */
887 break;
889 case vHidd_StdPixFmt_Native32:
890 switch(data->bytesperpixel)
892 case 1:
893 HIDD_BM_GetMem32Image8(o,
894 data->VideoData,
895 msg->x,
896 msg->y,
897 msg->pixels,
898 msg->width,
899 msg->height,
900 data->bytesperline,
901 msg->modulo);
902 break;
904 case 2:
905 HIDD_BM_GetMem32Image16(o,
906 data->VideoData,
907 msg->x,
908 msg->y,
909 msg->pixels,
910 msg->width,
911 msg->height,
912 data->bytesperline,
913 msg->modulo);
914 break;
916 case 3:
917 HIDD_BM_GetMem32Image24(o,
918 data->VideoData,
919 msg->x,
920 msg->y,
921 msg->pixels,
922 msg->width,
923 msg->height,
924 data->bytesperline,
925 msg->modulo);
926 break;
928 case 4:
929 HIDD_BM_CopyMemBox32(o,
930 data->VideoData,
931 msg->x,
932 msg->y,
933 msg->pixels,
936 msg->width,
937 msg->height,
938 data->bytesperline,
939 msg->modulo);
940 break;
941 } /* switch(data->bytesperpix) */
942 break;
944 default:
946 APTR pixels = msg->pixels;
947 APTR srcPixels = data->VideoData + msg->y * data->bytesperline + msg->x * data->bytesperpixel;
948 OOP_Object *dstpf;
950 dstpf = HIDD_Gfx_GetPixFmt(data->gfxhidd, msg->pixFmt);
952 HIDD_BM_ConvertPixels(o, &srcPixels, (HIDDT_PixelFormat *)data->pixfmtobj, data->bytesperline,
953 &pixels, (HIDDT_PixelFormat *)dstpf, msg->modulo,
954 msg->width, msg->height, NULL);
956 break;
957 } /* switch(msg->pixFmt) */
959 UNLOCK_BITMAP(data)
962 /****************************************************************************************/
964 VOID P96GFXBitmap__Hidd_BitMap__PutImage(OOP_Class *cl, OOP_Object *o,
965 struct pHidd_BitMap_PutImage *msg)
967 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
968 struct p96gfx_carddata *cid = data->gfxCardData;
969 struct p96gfx_staticdata *csd = CSD(cl);
970 BOOL v = FALSE;
972 D(bug("[P96Gfx:Bitmap] %s()\n", __func__));
974 LOCK_BITMAP(data)
976 LOCK_HW
977 WaitBlitter(cid);
978 UNLOCK_HW
980 if (data->invram)
982 if ((msg->pixFmt == vHidd_StdPixFmt_Native
983 || msg->pixFmt == vHidd_StdPixFmt_Native32
984 || msg->pixFmt == vHidd_StdPixFmt_BGRA32
985 || msg->pixFmt == vHidd_StdPixFmt_BGR032))
987 #if (0)
988 struct RenderInfo ri;
989 WORD sx, sy, dx, dy;
991 P96GFXRTG__MakeRenderInfo(csd, cid, &ri, data);
992 if (msg->pixels < data->VideoData)
996 LOCK_HW
998 // v =BlitRect(cid, &ri,
999 // WORD sx, WORD sy, WORD dx, WORD dy, msg->width, msg->height, UBYTE mask, data->rgbformat);
1001 UNLOCK_HW
1002 #endif
1006 if (!v) switch(msg->pixFmt)
1008 case vHidd_StdPixFmt_Native:
1009 switch(data->bytesperpixel)
1011 case 1:
1012 HIDD_BM_CopyMemBox8(o,
1013 msg->pixels,
1016 data->VideoData,
1017 msg->x,
1018 msg->y,
1019 msg->width,
1020 msg->height,
1021 msg->modulo,
1022 data->bytesperline);
1023 break;
1025 case 2:
1026 HIDD_BM_CopyMemBox16(o,
1027 msg->pixels,
1030 data->VideoData,
1031 msg->x,
1032 msg->y,
1033 msg->width,
1034 msg->height,
1035 msg->modulo,
1036 data->bytesperline);
1037 break;
1039 case 3:
1040 HIDD_BM_CopyMemBox24(o,
1041 msg->pixels,
1044 data->VideoData,
1045 msg->x,
1046 msg->y,
1047 msg->width,
1048 msg->height,
1049 msg->modulo,
1050 data->bytesperline);
1051 break;
1053 case 4:
1054 HIDD_BM_CopyMemBox32(o,
1055 msg->pixels,
1058 data->VideoData,
1059 msg->x,
1060 msg->y,
1061 msg->width,
1062 msg->height,
1063 msg->modulo,
1064 data->bytesperline);
1065 break;
1066 } /* switch(data->bytesperpix) */
1067 break;
1069 case vHidd_StdPixFmt_Native32:
1070 switch(data->bytesperpixel)
1072 case 1:
1073 HIDD_BM_PutMem32Image8(o,
1074 msg->pixels,
1075 data->VideoData,
1076 msg->x,
1077 msg->y,
1078 msg->width,
1079 msg->height,
1080 msg->modulo,
1081 data->bytesperline);
1082 break;
1084 case 2:
1085 HIDD_BM_PutMem32Image16(o,
1086 msg->pixels,
1087 data->VideoData,
1088 msg->x,
1089 msg->y,
1090 msg->width,
1091 msg->height,
1092 msg->modulo,
1093 data->bytesperline);
1094 break;
1096 case 3:
1097 HIDD_BM_PutMem32Image24(o,
1098 msg->pixels,
1099 data->VideoData,
1100 msg->x,
1101 msg->y,
1102 msg->width,
1103 msg->height,
1104 msg->modulo,
1105 data->bytesperline);
1106 break;
1108 case 4:
1109 HIDD_BM_CopyMemBox32(o,
1110 msg->pixels,
1113 data->VideoData,
1114 msg->x,
1115 msg->y,
1116 msg->width,
1117 msg->height,
1118 msg->modulo,
1119 data->bytesperline);
1120 break;
1121 } /* switch(data->bytesperpix) */
1122 break;
1124 default:
1126 APTR pixels = msg->pixels;
1127 APTR dstBuf = data->VideoData + msg->y * data->bytesperline + msg->x * data->bytesperpixel;
1128 OOP_Object *srcpf;
1130 srcpf = HIDD_Gfx_GetPixFmt(data->gfxhidd, msg->pixFmt);
1132 HIDD_BM_ConvertPixels(o, &pixels, (HIDDT_PixelFormat *)srcpf, msg->modulo,
1133 &dstBuf, (HIDDT_PixelFormat *)data->pixfmtobj, data->bytesperline,
1134 msg->width, msg->height, NULL);
1136 break;
1137 } /* switch(msg->pixFmt) */
1139 UNLOCK_BITMAP(data)
1142 /****************************************************************************************/
1144 VOID P96GFXBitmap__Hidd_BitMap__PutImageLUT(OOP_Class *cl, OOP_Object *o,
1145 struct pHidd_BitMap_PutImageLUT *msg)
1147 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
1148 struct p96gfx_carddata *cid = data->gfxCardData;
1149 struct p96gfx_staticdata *csd = CSD(cl);
1151 D(bug("[P96Gfx:Bitmap] %s()\n", __func__));
1153 LOCK_BITMAP(data)
1155 LOCK_HW
1156 WaitBlitter(cid);
1157 UNLOCK_HW
1159 switch(data->bytesperpixel)
1161 case 2:
1162 HIDD_BM_CopyLUTMemBox16(o,
1163 msg->pixels,
1166 data->VideoData,
1167 msg->x,
1168 msg->y,
1169 msg->width,
1170 msg->height,
1171 msg->modulo,
1172 data->bytesperline,
1173 msg->pixlut);
1174 break;
1176 case 3:
1177 HIDD_BM_CopyLUTMemBox24(o,
1178 msg->pixels,
1181 data->VideoData,
1182 msg->x,
1183 msg->y,
1184 msg->width,
1185 msg->height,
1186 msg->modulo,
1187 data->bytesperline,
1188 msg->pixlut);
1189 break;
1191 case 4:
1192 HIDD_BM_CopyLUTMemBox32(o,
1193 msg->pixels,
1196 data->VideoData,
1197 msg->x,
1198 msg->y,
1199 msg->width,
1200 msg->height,
1201 msg->modulo,
1202 data->bytesperline,
1203 msg->pixlut);
1204 break;
1206 default:
1207 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1208 break;
1209 } /* switch(data->bytesperpix) */
1211 UNLOCK_BITMAP(data)
1214 /****************************************************************************************/
1216 VOID P96GFXBitmap__Hidd_BitMap__GetImageLUT(OOP_Class *cl, OOP_Object *o,
1217 struct pHidd_BitMap_GetImageLUT *msg)
1219 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
1220 struct p96gfx_carddata *cid = data->gfxCardData;
1221 struct p96gfx_staticdata *csd = CSD(cl);
1223 D(bug("[P96Gfx:Bitmap] %s()\n", __func__));
1225 LOCK_HW
1226 WaitBlitter(cid);
1227 UNLOCK_HW
1229 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1232 /****************************************************************************************/
1234 VOID P96GFXBitmap__Hidd_BitMap__FillRect(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_DrawRect *msg)
1236 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
1237 struct p96gfx_carddata *cid = data->gfxCardData;
1238 HIDDT_DrawMode mode = GC_DRMD(msg->gc);
1239 HIDDT_Pixel fg = GC_FG(msg->gc);
1240 struct p96gfx_staticdata *csd = CSD(cl);
1241 BOOL v = FALSE;
1243 D(bug("[P96Gfx:Bitmap] %s()\n", __func__));
1245 LOCK_BITMAP(data)
1247 LOCK_HW
1248 WaitBlitter(cid);
1249 UNLOCK_HW
1250 #if 0
1251 maybeputinvram(cid, data);
1252 #endif
1254 if (data->invram) {
1255 struct RenderInfo ri;
1257 P96GFXRTG__MakeRenderInfo(csd, cid, &ri, data);
1259 LOCK_HW
1261 if (mode == vHidd_GC_DrawMode_Clear || mode == vHidd_GC_DrawMode_Set) {
1262 ULONG pen = mode == vHidd_GC_DrawMode_Clear ? 0x00000000 : 0xffffffff;
1263 v = FillRect(cid, &ri, msg->minX, msg->minY, msg->maxX - msg->minX + 1, msg->maxY - msg->minY + 1, pen, 0xff, data->rgbformat);
1264 } else if (mode == vHidd_GC_DrawMode_Copy) {
1265 v = FillRect(cid, &ri, msg->minX, msg->minY, msg->maxX - msg->minX + 1, msg->maxY - msg->minY + 1, fg, 0xff, data->rgbformat);
1266 } else if (mode == vHidd_GC_DrawMode_Invert) {
1267 v = InvertRect(cid, &ri, msg->minX, msg->minY, msg->maxX - msg->minX + 1, msg->maxY - msg->minY + 1, 0xff, data->rgbformat);
1270 UNLOCK_HW
1273 if (!v) switch(mode)
1275 case vHidd_GC_DrawMode_Copy:
1276 switch(data->bytesperpixel)
1278 case 1:
1279 HIDD_BM_FillMemRect8(o,
1280 data->VideoData,
1281 msg->minX,
1282 msg->minY,
1283 msg->maxX,
1284 msg->maxY,
1285 data->bytesperline,
1286 fg);
1287 break;
1289 case 2:
1290 HIDD_BM_FillMemRect16(o,
1291 data->VideoData,
1292 msg->minX,
1293 msg->minY,
1294 msg->maxX,
1295 msg->maxY,
1296 data->bytesperline,
1297 fg);
1298 break;
1300 case 3:
1301 HIDD_BM_FillMemRect24(o,
1302 data->VideoData,
1303 msg->minX,
1304 msg->minY,
1305 msg->maxX,
1306 msg->maxY,
1307 data->bytesperline,
1308 fg);
1309 break;
1311 case 4:
1312 HIDD_BM_FillMemRect32(o,
1313 data->VideoData,
1314 msg->minX,
1315 msg->minY,
1316 msg->maxX,
1317 msg->maxY,
1318 data->bytesperline,
1319 fg);
1320 break;
1322 break;
1324 case vHidd_GC_DrawMode_Invert:
1325 HIDD_BM_InvertMemRect(o,
1326 data->VideoData,
1327 msg->minX * data->bytesperpixel,
1328 msg->minY,
1329 msg->maxX * data->bytesperpixel + data->bytesperpixel - 1,
1330 msg->maxY,
1331 data->bytesperline);
1332 break;
1334 default:
1335 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1336 break;
1337 } /* switch(mode) */
1339 UNLOCK_BITMAP(data)
1342 /****************************************************************************************/
1344 VOID P96GFXBitmap__Hidd_BitMap__PutPattern(OOP_Class *cl, OOP_Object *o,
1345 struct pHidd_BitMap_PutPattern *msg)
1347 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
1348 struct p96gfx_carddata *cid = data->gfxCardData;
1349 struct p96gfx_staticdata *csd = CSD(cl);
1350 HIDDT_Pixel fg = GC_FG(msg->gc);
1351 HIDDT_Pixel bg = GC_BG(msg->gc);
1352 struct Pattern pat;
1353 UBYTE drawmode;
1354 BOOL v = FALSE;
1356 D(bug("[P96Gfx:Bitmap] %s(%d,%d)(%d,%d)(%x,%d,%d,%d,%d,%d)\n", __func__,
1357 msg->x, msg->y, msg->width, msg->height,
1358 msg->pattern, msg->patternsrcx, msg->patternsrcy, fg, bg, msg->patternheight));
1360 LOCK_BITMAP(data)
1362 LOCK_HW
1363 WaitBlitter(cid);
1364 UNLOCK_HW
1366 if ((msg->mask == NULL) && (msg->patterndepth == 1))
1368 switch (msg->patternheight)
1370 case 1:
1371 pat.Size = 0;
1372 break;
1373 case 2:
1374 pat.Size = 1;
1375 break;
1376 case 4:
1377 pat.Size = 2;
1378 break;
1379 case 8:
1380 pat.Size = 3;
1381 break;
1382 case 16:
1383 pat.Size = 4;
1384 break;
1385 case 32:
1386 pat.Size = 5;
1387 break;
1388 case 64:
1389 pat.Size = 6;
1390 break;
1391 case 128:
1392 pat.Size = 7;
1393 break;
1394 case 256:
1395 pat.Size = 8;
1396 break;
1397 default:
1398 pat.Size = 0xff;
1401 if (pat.Size <= 8)
1403 #if 0
1404 maybeputinvram(cid, data);
1405 #endif
1406 if (data->invram)
1408 struct RenderInfo ri;
1410 P96GFXRTG__MakeRenderInfo(csd, cid, &ri, data);
1412 if (GC_COLEXP(msg->gc) == vHidd_GC_ColExp_Transparent)
1413 drawmode = JAM1;
1414 else if (GC_DRMD(msg->gc) == vHidd_GC_DrawMode_Invert)
1415 drawmode = COMPLEMENT;
1416 else
1417 drawmode = JAM2;
1418 if (msg->invertpattern)
1419 drawmode |= INVERSVID;
1421 pat.Memory = msg->pattern;
1422 pat.XOffset = msg->patternsrcx;
1423 pat.YOffset = msg->patternsrcy;
1424 pat.FgPen = fg;
1425 pat.BgPen = bg;
1426 pat.DrawMode = drawmode;
1428 LOCK_HW
1430 v = BlitPattern(cid, &ri, &pat, msg->x, msg->y, msg->width, msg->height, 0xff, data->rgbformat);
1432 UNLOCK_HW
1437 if (!v) switch(data->bytesperpixel)
1439 case 1:
1440 HIDD_BM_PutMemPattern8(o,
1441 msg->gc,
1442 msg->pattern,
1443 msg->patternsrcx,
1444 msg->patternsrcy,
1445 msg->patternheight,
1446 msg->patterndepth,
1447 msg->patternlut,
1448 msg->invertpattern,
1449 msg->mask,
1450 msg->maskmodulo,
1451 msg->masksrcx,
1452 data->VideoData,
1453 data->bytesperline,
1454 msg->x,
1455 msg->y,
1456 msg->width,
1457 msg->height);
1458 break;
1460 case 2:
1461 HIDD_BM_PutMemPattern16(o,
1462 msg->gc,
1463 msg->pattern,
1464 msg->patternsrcx,
1465 msg->patternsrcy,
1466 msg->patternheight,
1467 msg->patterndepth,
1468 msg->patternlut,
1469 msg->invertpattern,
1470 msg->mask,
1471 msg->maskmodulo,
1472 msg->masksrcx,
1473 data->VideoData,
1474 data->bytesperline,
1475 msg->x,
1476 msg->y,
1477 msg->width,
1478 msg->height);
1479 break;
1481 case 3:
1482 HIDD_BM_PutMemPattern24(o,
1483 msg->gc,
1484 msg->pattern,
1485 msg->patternsrcx,
1486 msg->patternsrcy,
1487 msg->patternheight,
1488 msg->patterndepth,
1489 msg->patternlut,
1490 msg->invertpattern,
1491 msg->mask,
1492 msg->maskmodulo,
1493 msg->masksrcx,
1494 data->VideoData,
1495 data->bytesperline,
1496 msg->x,
1497 msg->y,
1498 msg->width,
1499 msg->height);
1500 break;
1502 case 4:
1503 HIDD_BM_PutMemPattern32(o,
1504 msg->gc,
1505 msg->pattern,
1506 msg->patternsrcx,
1507 msg->patternsrcy,
1508 msg->patternheight,
1509 msg->patterndepth,
1510 msg->patternlut,
1511 msg->invertpattern,
1512 msg->mask,
1513 msg->maskmodulo,
1514 msg->masksrcx,
1515 data->VideoData,
1516 data->bytesperline,
1517 msg->x,
1518 msg->y,
1519 msg->width,
1520 msg->height);
1521 break;
1523 default:
1524 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1525 break;
1526 } /* switch(data->bytesperpixel) */
1528 UNLOCK_BITMAP(data)
1531 /****************************************************************************************/
1533 VOID P96GFXBitmap__Hidd_BitMap__PutTemplate(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_PutTemplate *msg)
1535 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
1536 struct p96gfx_carddata *cid = data->gfxCardData;
1537 struct p96gfx_staticdata *csd = CSD(cl);
1538 HIDDT_Pixel fg = GC_FG(msg->gc);
1539 HIDDT_Pixel bg = GC_BG(msg->gc);
1540 BOOL v = FALSE;
1542 D(bug("[P96Gfx:Bitmap] %s()\n", __func__));
1544 LOCK_BITMAP(data)
1546 LOCK_HW
1547 WaitBlitter(cid);
1548 UNLOCK_HW
1550 #if 0
1551 maybeputinvram(cid, data);
1552 #endif
1554 if (data->invram) {
1555 struct Template tmpl;
1556 struct RenderInfo ri;
1557 UBYTE drawmode;
1559 P96GFXRTG__MakeRenderInfo(csd, cid, &ri, data);
1561 if (GC_COLEXP(msg->gc) == vHidd_GC_ColExp_Transparent)
1562 drawmode = JAM1;
1563 else if (GC_DRMD(msg->gc) == vHidd_GC_DrawMode_Invert)
1564 drawmode = COMPLEMENT;
1565 else
1566 drawmode = JAM2;
1567 if (msg->inverttemplate)
1568 drawmode |= INVERSVID;
1570 /* tmpl.XOffset has only UBYTE size so we must fix params up [1] [2] */
1572 tmpl.Memory = msg->masktemplate + ((msg->srcx / 8) & ~1); /* [1] */
1573 tmpl.BytesPerRow = msg->modulo;
1574 tmpl.XOffset = msg->srcx & 0XF; /* [2] */
1575 tmpl.DrawMode = drawmode;
1576 tmpl.FgPen = fg;
1577 tmpl.BgPen = bg;
1579 LOCK_HW
1580 v = BlitTemplate(cid, &ri, &tmpl, msg->x, msg->y, msg->width, msg->height, 0xff, data->rgbformat);
1581 UNLOCK_HW
1584 if (!v) switch(data->bytesperpixel)
1586 case 1:
1587 HIDD_BM_PutMemTemplate8(o,
1588 msg->gc,
1589 msg->masktemplate,
1590 msg->modulo,
1591 msg->srcx,
1592 data->VideoData,
1593 data->bytesperline,
1594 msg->x,
1595 msg->y,
1596 msg->width,
1597 msg->height,
1598 msg->inverttemplate);
1599 break;
1601 case 2:
1602 HIDD_BM_PutMemTemplate16(o,
1603 msg->gc,
1604 msg->masktemplate,
1605 msg->modulo,
1606 msg->srcx,
1607 data->VideoData,
1608 data->bytesperline,
1609 msg->x,
1610 msg->y,
1611 msg->width,
1612 msg->height,
1613 msg->inverttemplate);
1614 break;
1616 case 3:
1617 HIDD_BM_PutMemTemplate24(o,
1618 msg->gc,
1619 msg->masktemplate,
1620 msg->modulo,
1621 msg->srcx,
1622 data->VideoData,
1623 data->bytesperline,
1624 msg->x,
1625 msg->y,
1626 msg->width,
1627 msg->height,
1628 msg->inverttemplate);
1629 break;
1631 case 4:
1632 HIDD_BM_PutMemTemplate32(o,
1633 msg->gc,
1634 msg->masktemplate,
1635 msg->modulo,
1636 msg->srcx,
1637 data->VideoData,
1638 data->bytesperline,
1639 msg->x,
1640 msg->y,
1641 msg->width,
1642 msg->height,
1643 msg->inverttemplate);
1644 break;
1646 default:
1647 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1648 break;
1649 } /* switch(data->bytesperpixel) */
1651 UNLOCK_BITMAP(data)
1654 /****************************************************************************************/
1656 VOID P96GFXBitmap__Hidd_BitMap__UpdateRect(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_UpdateRect *msg)
1658 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
1659 struct p96gfx_carddata *cid = data->gfxCardData;
1660 struct p96gfx_staticdata *csd = CSD(cl);
1662 D(bug("[P96Gfx:Bitmap] %s()\n", __func__));
1664 LOCK_HW
1665 WaitBlitter(cid);
1666 UNLOCK_HW
1668 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1671 /****************************************************************************************/
1673 BOOL P96GFXBitmap__Hidd_PlanarBM__SetBitMap(OOP_Class *cl, OOP_Object *o,
1674 struct pHidd_PlanarBM_SetBitMap *msg)
1676 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
1677 struct p96gfx_carddata *cid = data->gfxCardData;
1678 struct p96gfx_staticdata *csd = CSD(cl);
1680 D(bug("[P96Gfx:Bitmap] %s()\n", __func__));
1682 LOCK_HW
1683 WaitBlitter(cid);
1684 UNLOCK_HW
1686 return OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
1689 /****************************************************************************************/
1691 BOOL P96GFXBitmap__Hidd_PlanarBM__GetBitMap(OOP_Class *cl, OOP_Object *o,
1692 struct pHidd_PlanarBM_GetBitMap *msg)
1694 struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o);
1695 struct p96gfx_carddata *cid = data->gfxCardData;
1696 struct p96gfx_staticdata *csd = CSD(cl);
1698 D(bug("[P96Gfx:Bitmap] %s()\n", __func__));
1700 LOCK_HW
1701 WaitBlitter(cid);
1702 UNLOCK_HW
1704 return OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);