2 Copyright © 2004-2010, The AROS Development Team. All rights reserved.
5 Desc: NVidia bitmap class
9 #include <exec/types.h>
10 #include <exec/memory.h>
12 #include <hidd/hidd.h>
13 #include <hidd/graphics.h>
15 #include <proto/exec.h>
16 #include <proto/oop.h>
17 #include <proto/utility.h>
19 #include <aros/symbolsets.h>
25 #include <aros/debug.h>
27 #define _sd (&((LIBBASETYPEPTR)cl->UserData)->sd)
29 #undef HiddPCIDeviceAttrBase
30 #undef HiddGfxAttrBase
31 #undef HiddPixFmtAttrBase
32 #undef HiddSyncAttrBase
33 #undef HiddBitMapAttrBase
34 #define HiddPCIDeviceAttrBase (_sd->pciAttrBase)
35 #define HiddNVidiaBitMapAttrBase (_sd->nvBitMapAttrBase)
36 #define HiddBitMapAttrBase (_sd->bitMapAttrBase)
37 #define HiddPixFmtAttrBase (_sd->pixFmtAttrBase)
38 #define HiddGfxAttrBase (_sd->gfxAttrBase)
39 #define HiddSyncAttrBase (_sd->syncAttrBase)
43 OOP_Object
*NVOnBM__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
45 EnterFunc(bug("[NVBitMap] OnBitmap::New()\n"));
47 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
48 D(bug("o=%p, cl=%p\n", o
, cl
));
52 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
55 IPTR width
, height
, depth
;
60 InitSemaphore(&bm
->bmLock
);
62 D(bug("[NVBitMap] Super called. o=%p\n", o
));
66 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
67 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
68 OOP_GetAttr(o
, aHidd_BitMap_PixFmt
, (APTR
)&pf
);
69 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
71 fb
= GetTagData(aHidd_BitMap_FrameBuffer
, FALSE
, msg
->attrList
);
73 D(bug("[NVBitmap] width=%d height=%d depth=%d\n", width
, height
, depth
));
75 if (width
== 0 || height
== 0 || depth
== 0)
77 bug("[NVBitMap] size mismatch!\n");
97 bm
->pitch
= (width
* bytesPerPixel
+ 63) & ~63;
99 bm
->bpp
= bytesPerPixel
;
101 bm
->framebuffer
= AllocBitmapArea(_sd
, bm
->width
, bm
->height
,
112 bm
->surface_format
= SURFACE_FORMAT_DEPTH24
;
113 bm
->pattern_format
= PATTERN_FORMAT_DEPTH24
;
114 bm
->rect_format
= RECT_FORMAT_DEPTH24
;
115 bm
->line_format
= LINE_FORMAT_DEPTH24
;
119 bm
->surface_format
= SURFACE_FORMAT_DEPTH16
;
120 bm
->pattern_format
= PATTERN_FORMAT_DEPTH16
;
121 bm
->rect_format
= RECT_FORMAT_DEPTH16
;
122 bm
->line_format
= LINE_FORMAT_DEPTH16
;
125 bm
->surface_format
= SURFACE_FORMAT_DEPTH8
;
126 bm
->pattern_format
= PATTERN_FORMAT_DEPTH8
;
127 bm
->rect_format
= RECT_FORMAT_DEPTH8
;
128 bm
->line_format
= LINE_FORMAT_DEPTH8
;
132 if (fb
&& bm
->framebuffer
!= 0xffffffff)
134 bm
->state
= (struct CardState
*)AllocPooled(_sd
->memPool
,
135 sizeof(struct CardState
));
137 bzero(_sd
->Card
.FrameBuffer
+ bm
->framebuffer
, 640*480*2);
143 InitMode(_sd
, bm
->state
, 640, 480, 16, 25200, bm
->framebuffer
,
148 LoadState(_sd
, bm
->state
);
149 DPMS(_sd
, _sd
->dpms
);
156 else if (bm
->framebuffer
!= 0xffffffff)
161 /* We should be able to get modeID from the bitmap */
162 OOP_GetAttr(o
, aHidd_BitMap_ModeID
, &modeid
);
164 D(bug("[NVBitMap] BM_ModeID=%x\n", modeid
));
166 if (modeid
!= vHidd_ModeID_Invalid
)
169 IPTR hdisp
, vdisp
, hstart
, hend
, htotal
, vstart
, vend
, vtotal
;
171 /* Get Sync and PixelFormat properties */
172 struct pHidd_Gfx_GetMode __getmodemsg
= {
176 }, *getmodemsg
= &__getmodemsg
;
178 getmodemsg
->mID
= OOP_GetMethodID(IID_Hidd_Gfx
, moHidd_Gfx_GetMode
);
179 OOP_DoMethod(_sd
->nvobject
, (OOP_Msg
)getmodemsg
);
181 OOP_GetAttr(sync
, aHidd_Sync_PixelClock
, &pixel
);
182 OOP_GetAttr(sync
, aHidd_Sync_HDisp
, &hdisp
);
183 OOP_GetAttr(sync
, aHidd_Sync_VDisp
, &vdisp
);
184 OOP_GetAttr(sync
, aHidd_Sync_HSyncStart
, &hstart
);
185 OOP_GetAttr(sync
, aHidd_Sync_VSyncStart
, &vstart
);
186 OOP_GetAttr(sync
, aHidd_Sync_HSyncEnd
, &hend
);
187 OOP_GetAttr(sync
, aHidd_Sync_VSyncEnd
, &vend
);
188 OOP_GetAttr(sync
, aHidd_Sync_HTotal
, &htotal
);
189 OOP_GetAttr(sync
, aHidd_Sync_VTotal
, &vtotal
);
191 bm
->state
= (struct CardState
*)AllocPooled(_sd
->memPool
,
192 sizeof(struct CardState
));
200 InitMode(_sd
, bm
->state
, bm
->pitch
/bytesPerPixel
, height
, depth
, pixel
, bm
->framebuffer
,
202 hstart
, hend
, htotal
,
203 vstart
, vend
, vtotal
);
205 LoadState(_sd
, bm
->state
);
206 DPMS(_sd
, _sd
->dpms
);
214 OOP_MethodID disp_mid
= OOP_GetMethodID(IID_Root
, moRoot_Dispose
);
215 OOP_CoerceMethod(cl
, o
, (OOP_Msg
) &disp_mid
);
221 OOP_Object
*NVOffBM__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
223 EnterFunc(bug("[NVBitMap] OffBitmap::New()\n"));
225 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
229 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
231 IPTR width
, height
, depth
;
236 InitSemaphore(&bm
->bmLock
);
240 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
241 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
242 OOP_GetAttr(o
, aHidd_BitMap_PixFmt
, (APTR
)&pf
);
243 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
244 D(bug("[NVBitmap] width=%d height=%d depth=%d\n", width
, height
, depth
));
246 if (width
== 0 || height
== 0 || depth
== 0)
248 bug("[NVBitMap] size mismatch!\n");
253 else if (depth
<= 16)
260 bm
->pitch
= (width
* bytesPerPixel
+ 63) & ~63;
263 bm
->bpp
= bytesPerPixel
;
265 bm
->framebuffer
= AllocBitmapArea(_sd
, bm
->width
, bm
->height
,
268 if (bm
->framebuffer
== -1)
270 bm
->framebuffer
= (IPTR
)AllocMem(bm
->pitch
* bm
->height
,
271 MEMF_PUBLIC
| MEMF_CLEAR
);
284 bm
->surface_format
= SURFACE_FORMAT_DEPTH24
;
285 bm
->pattern_format
= PATTERN_FORMAT_DEPTH24
;
286 bm
->rect_format
= RECT_FORMAT_DEPTH24
;
287 bm
->line_format
= LINE_FORMAT_DEPTH24
;
291 bm
->surface_format
= SURFACE_FORMAT_DEPTH16
;
292 bm
->pattern_format
= PATTERN_FORMAT_DEPTH16
;
293 bm
->rect_format
= RECT_FORMAT_DEPTH16
;
294 bm
->line_format
= LINE_FORMAT_DEPTH16
;
297 bm
->surface_format
= SURFACE_FORMAT_DEPTH8
;
298 bm
->pattern_format
= PATTERN_FORMAT_DEPTH8
;
299 bm
->rect_format
= RECT_FORMAT_DEPTH8
;
300 bm
->line_format
= LINE_FORMAT_DEPTH8
;
304 if ((bm
->framebuffer
!= 0xffffffff) && (bm
->framebuffer
!= 0))
310 OOP_MethodID disp_mid
= OOP_GetMethodID(IID_Root
, moRoot_Dispose
);
311 OOP_CoerceMethod(cl
, o
, (OOP_Msg
) &disp_mid
);
317 VOID
NVBM__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
319 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
323 NVDmaKickoff(&_sd
->Card
);
328 FreeBitmapArea(_sd
, bm
->framebuffer
, bm
->width
, bm
->height
, bm
->bpp
);
330 bm
->framebuffer
= -1;
334 FreeMem((APTR
)bm
->framebuffer
, bm
->pitch
* bm
->height
);
337 FreePooled(_sd
->memPool
, bm
->state
, sizeof(struct CardState
));
344 OOP_DoSuperMethod(cl
, o
, msg
);
347 void NVBM__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
349 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
352 if (IS_NVBM_ATTR(msg
->attrID
, idx
))
356 case aoHidd_nvBitMap_Drawable
:
358 *msg
->storage
= bm
->framebuffer
+ (IPTR
)_sd
->Card
.FrameBuffer
;
360 *msg
->storage
= bm
->framebuffer
;
364 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
369 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
373 VOID
NVBM__Hidd_BitMap__Clear(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_Clear
*msg
)
375 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
379 D(bug("[NVBitMap] Clear()\n"));
387 _sd
->Card
.DMAKickoffCallback
= NVDMAKickoffCallback
;
389 NVDmaStart(&_sd
->Card
, SURFACE_FORMAT
, 4);
390 NVDmaNext(&_sd
->Card
, bm
->surface_format
);
391 NVDmaNext(&_sd
->Card
, (bm
->pitch
<< 16) | _sd
->src_pitch
);
392 NVDmaNext(&_sd
->Card
, _sd
->src_offset
);
393 NVDmaNext(&_sd
->Card
, bm
->framebuffer
);
395 _sd
->surface_format
= bm
->surface_format
;
396 _sd
->dst_pitch
= bm
->pitch
;
397 _sd
->dst_offset
= bm
->framebuffer
;
399 NVDmaStart(&_sd
->Card
, RECT_FORMAT
, 1);
400 NVDmaNext(&_sd
->Card
, bm
->rect_format
);
401 _sd
->rect_format
= bm
->rect_format
;
403 NVSetRopSolid(_sd
, vHidd_GC_DrawMode_Copy
, ~0 << bm
->depth
);
404 NVDmaStart(&_sd
->Card
, RECT_SOLID_COLOR
, 1);
405 NVDmaNext(&_sd
->Card
, GC_BG(msg
->gc
));
407 NVDmaStart(&_sd
->Card
, RECT_SOLID_RECTS(0), 2);
408 NVDmaNext(&_sd
->Card
, 0);
409 NVDmaNext(&_sd
->Card
, (bm
->width
<< 16) | (bm
->height
));
411 NVDmaKickoff(&_sd
->Card
);
418 ULONG
*ptr
= (ULONG
*)bm
->framebuffer
;
420 int i
= bm
->width
* bm
->height
* bm
->bpp
/ 4;
432 val
= GC_BG(msg
->gc
) & 0xff;
437 val
= GC_BG(msg
->gc
) << 16 | (GC_BG(msg
->gc
) & 0xffff);
440 val
= GC_BG(msg
->gc
);
455 VOID
NVBM__Hidd_BitMap__PutPixel(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutPixel
*msg
)
457 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
461 UBYTE
*ptr
= (UBYTE
*)((IPTR
)bm
->framebuffer
+ bm
->bpp
* msg
->x
+ bm
->pitch
* msg
->y
);
465 ptr
+= (IPTR
)_sd
->Card
.FrameBuffer
;
480 *(UWORD
*)ptr
= msg
->pixel
;
483 *(ULONG
*)ptr
= msg
->pixel
;
490 HIDDT_Pixel
NVBM__Hidd_BitMap__GetPixel(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetPixel
*msg
)
493 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
497 UBYTE
*ptr
= (UBYTE
*)((IPTR
)bm
->framebuffer
+ bm
->bpp
* msg
->x
+ bm
->pitch
* msg
->y
);
501 ptr
+= (IPTR
)_sd
->Card
.FrameBuffer
;
516 pixel
= *(UWORD
*)ptr
;
519 pixel
= *(ULONG
*)ptr
;
525 /* Get pen number from colortab */
529 VOID
NVBM__Hidd_BitMap__FillRect(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_DrawRect
*msg
)
531 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
535 D(bug("[NVBitMap] FillRect(%p,%d,%d,%d,%d)\n",
536 bm
->framebuffer
, msg
->minX
, msg
->minY
, msg
->maxX
, msg
->maxY
));
544 _sd
->Card
.DMAKickoffCallback
= NVDMAKickoffCallback
;
545 _sd
->gpu_busy
= TRUE
;
547 NVDmaStart(&_sd
->Card
, SURFACE_FORMAT
, 4);
548 NVDmaNext(&_sd
->Card
, bm
->surface_format
);
549 NVDmaNext(&_sd
->Card
, (bm
->pitch
<< 16) | _sd
->src_pitch
);
550 NVDmaNext(&_sd
->Card
, _sd
->src_offset
);
551 NVDmaNext(&_sd
->Card
, bm
->framebuffer
);
553 _sd
->surface_format
= bm
->surface_format
;
554 _sd
->dst_pitch
= bm
->pitch
;
555 _sd
->dst_offset
= bm
->framebuffer
;
557 NVDmaStart(&_sd
->Card
, RECT_FORMAT
, 1);
558 NVDmaNext(&_sd
->Card
, bm
->rect_format
);
559 _sd
->rect_format
= bm
->rect_format
;
561 NVSetRopSolid(_sd
, GC_DRMD(msg
->gc
), ~0 << bm
->depth
);
562 NVDmaStart(&_sd
->Card
, RECT_SOLID_COLOR
, 1);
563 NVDmaNext(&_sd
->Card
, GC_FG(msg
->gc
));
565 NVDmaStart(&_sd
->Card
, RECT_SOLID_RECTS(0), 2);
566 NVDmaNext(&_sd
->Card
, (msg
->minX
<< 16) | (msg
->minY
& 0xffff));
567 NVDmaNext(&_sd
->Card
, ((msg
->maxX
- msg
->minX
+ 1) << 16)
568 | ((msg
->maxY
- msg
->minY
+ 1) & 0xffff));
570 NVDmaKickoff(&_sd
->Card
);
572 // if ((msg->maxX - msg->minX) * (msg->maxY - msg->minY) > 512)
579 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
585 ULONG
NVBM__Hidd_BitMap__BytesPerLine(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_BytesPerLine
*msg
)
587 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
589 return (bm
->bpp
* msg
->width
+ 63) & ~63;
592 VOID
NVBM__Hidd_BitMap__DrawLine(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_DrawLine
*msg
)
594 OOP_Object
*gc
= msg
->gc
;
595 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
599 D(bug("[NVBitmap] DrawLine(%p, %d, %d, %d, %d)\n",
600 bm
->framebuffer
, msg
->x1
, msg
->y1
, msg
->x2
, msg
->y2
));
602 if ((GC_LINEPAT(gc
) != (UWORD
)~0) || !bm
->fbgfx
)
604 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
613 _sd
->Card
.DMAKickoffCallback
= NVDMAKickoffCallback
;
614 _sd
->gpu_busy
= TRUE
;
616 NVDmaStart(&_sd
->Card
, SURFACE_OFFSET_DST
, 1);
617 NVDmaNext(&_sd
->Card
, bm
->framebuffer
);
618 _sd
->dst_offset
= bm
->framebuffer
;
620 NVDmaStart(&_sd
->Card
, SURFACE_PITCH
, 1);
621 NVDmaNext(&_sd
->Card
, (bm
->pitch
<< 16) | _sd
->src_pitch
);
622 _sd
->dst_pitch
= bm
->pitch
;
626 NVDmaStart(&_sd
->Card
, CLIP_POINT
, 2);
627 NVDmaNext(&_sd
->Card
, (GC_CLIPY1(gc
) << 16) | GC_CLIPX1(gc
));
628 NVDmaNext(&_sd
->Card
, ((GC_CLIPY2(gc
)-GC_CLIPY1(gc
)+1) << 16) |
629 (GC_CLIPX2(gc
)-GC_CLIPX1(gc
)+1));
632 NVSetRopSolid(_sd
, GC_DRMD(gc
), ~0 << bm
->depth
);
633 NVDmaStart(&_sd
->Card
, LINE_FORMAT
, 2);
634 NVDmaNext(&_sd
->Card
, bm
->line_format
);
635 NVDmaNext(&_sd
->Card
, GC_FG(gc
));
637 NVDmaStart(&_sd
->Card
, LINE_LINES(0), 4);
638 NVDmaNext(&_sd
->Card
, (msg
->y1
<< 16) | (msg
->x1
& 0xffff));
639 NVDmaNext(&_sd
->Card
, (msg
->y2
<< 16) | (msg
->x2
& 0xffff));
640 NVDmaNext(&_sd
->Card
, (msg
->y2
<< 16) | (msg
->x2
& 0xffff));
641 NVDmaNext(&_sd
->Card
, ((msg
->y2
+ 1) << 16) | ((msg
->x2
+ 1) & 0xffff));
645 NVDmaStart(&_sd
->Card
, CLIP_POINT
, 2);
646 NVDmaNext(&_sd
->Card
, 0x00000000);
647 NVDmaNext(&_sd
->Card
, 0xff00ff00);
650 NVDmaKickoff(&_sd
->Card
);
658 VOID
NVBM__Hidd_BitMap__PutImageLUT(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImageLUT
*msg
)
660 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
664 IPTR VideoData
= bm
->framebuffer
;
668 VideoData
+= (IPTR
)_sd
->Card
.FrameBuffer
;
682 struct pHidd_BitMap_CopyLUTMemBox16 __m
= {
683 _sd
->mid_CopyLUTMemBox16
,
697 OOP_DoMethod(o
, (OOP_Msg
)m
);
703 struct pHidd_BitMap_CopyLUTMemBox32 __m
= {
704 _sd
->mid_CopyLUTMemBox32
,
718 OOP_DoMethod(o
, (OOP_Msg
)m
);
723 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
726 } /* switch(data->bytesperpix) */
732 VOID
NVBM__Hidd_BitMap__BlitColorExpansion(OOP_Class
*cl
, OOP_Object
*o
,
733 struct pHidd_BitMap_BlitColorExpansion
*msg
)
735 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
739 if ((OOP_OCLASS(msg
->srcBitMap
) == _sd
->planarbmclass
) && bm
->fbgfx
)
741 struct planarbm_data
*planar
= OOP_INST_DATA(OOP_OCLASS(msg
->srcBitMap
), msg
->srcBitMap
);
745 ULONG skipleft
= msg
->srcX
- (msg
->srcX
& ~31);
746 ULONG mask
= ~0 << bm
->depth
;
748 cemd
= GC_COLEXP(msg
->gc
);
749 bg
= GC_BG(msg
->gc
) | mask
;
750 fg
= GC_FG(msg
->gc
) | mask
;
752 ULONG bw
= (msg
->width
+ 31 + skipleft
) & ~31;
753 ULONG x
= msg
->destX
, y
= msg
->destY
, w
= msg
->width
, h
= msg
->height
;
759 _sd
->gpu_busy
= TRUE
;
761 NVDmaStart(&_sd
->Card
, SURFACE_FORMAT
, 4);
762 NVDmaNext(&_sd
->Card
, bm
->surface_format
);
763 NVDmaNext(&_sd
->Card
, (bm
->pitch
<< 16) | (_sd
->src_pitch
));
764 NVDmaNext(&_sd
->Card
, _sd
->src_offset
);
765 NVDmaNext(&_sd
->Card
, bm
->framebuffer
);
767 NVDmaStart(&_sd
->Card
, RECT_FORMAT
, 1);
768 NVDmaNext(&_sd
->Card
, bm
->rect_format
);
770 _sd
->surface_format
= bm
->surface_format
;
771 _sd
->dst_pitch
= bm
->pitch
;
772 _sd
->dst_offset
= bm
->framebuffer
;
774 NVSetRopSolid(_sd
, GC_DRMD(msg
->gc
), ~0 << bm
->depth
);
776 if (cemd
& vHidd_GC_ColExp_Transparent
)
778 NVDmaStart(&_sd
->Card
, RECT_EXPAND_ONE_COLOR_CLIP
, 5);
779 NVDmaNext(&_sd
->Card
, (y
<< 16) | ((x
) & 0xffff));
780 NVDmaNext(&_sd
->Card
, ((y
+ h
) << 16) | ((x
+ w
) & 0xffff));
781 NVDmaNext(&_sd
->Card
, fg
);
782 NVDmaNext(&_sd
->Card
, (h
<< 16) | bw
);
783 NVDmaNext(&_sd
->Card
, (y
<< 16) | ((x
-skipleft
) & 0xffff));
784 expand
= RECT_EXPAND_ONE_COLOR_DATA(0);
788 NVDmaStart(&_sd
->Card
, RECT_EXPAND_TWO_COLOR_CLIP
, 7);
789 NVDmaNext(&_sd
->Card
, (y
<< 16) | ((x
) & 0xffff));
790 NVDmaNext(&_sd
->Card
, ((y
+ h
) << 16) | ((x
+ w
) & 0xffff));
791 NVDmaNext(&_sd
->Card
, bg
);
792 NVDmaNext(&_sd
->Card
, fg
);
793 NVDmaNext(&_sd
->Card
, (h
<< 16) | bw
);
794 NVDmaNext(&_sd
->Card
, (h
<< 16) | bw
);
795 NVDmaNext(&_sd
->Card
, (y
<< 16) | ((x
-skipleft
) & 0xffff));
796 expand
= RECT_EXPAND_TWO_COLOR_DATA(0);
800 ULONG
*ptr
= (ULONG
*)planar
->planes
[0];
802 ptr
+= (planar
->bytesperrow
* msg
->srcY
>> 2) +
805 if ((bw
>> 5) * h
< RECT_EXPAND_ONE_COLOR_DATA_MAX_DWORDS
)
807 NVDmaStart(&_sd
->Card
, expand
, (bw
>> 5) * h
);
808 for (i
= 0; i
< h
; i
++)
810 for (j
=0; j
< (bw
>> 5); j
++)
812 NVDmaNext(&_sd
->Card
, ptr
[j
]);
814 ptr
+= planar
->bytesperrow
>> 2;
819 for (i
= 0; i
< h
; i
++)
821 NVDmaStart(&_sd
->Card
, expand
, (bw
>> 5));
823 for (j
=0; j
< (bw
>> 5); j
++)
825 NVDmaNext(&_sd
->Card
, ptr
[j
]);
827 ptr
+= planar
->bytesperrow
>> 2;
831 NVDmaStart(&_sd
->Card
, BLIT_POINT_SRC
, 1);
832 NVDmaNext(&_sd
->Card
, 0);
833 NVDmaKickoff(&_sd
->Card
);
838 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
843 VOID
NVBM__Hidd_BitMap__DrawRect(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_DrawRect
*msg
)
845 OOP_Object
*gc
= msg
->gc
;
846 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
851 D(bug("[NVBitmap] DrawRect(%p, %d, %d, %d, %d)\n",
852 bm
->framebuffer
, msg
->minX
, msg
->minY
, msg
->maxX
, msg
->maxY
));
854 if (msg
->minX
== msg
->maxX
) addX
= 1; else addX
= 0;
855 if (msg
->minY
== msg
->maxY
) addY
= 1; else addY
= 0;
857 if ((GC_LINEPAT(gc
) != (UWORD
)~0) || !bm
->fbgfx
)
859 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
865 _sd
->gpu_busy
= TRUE
;
869 _sd
->Card
.DMAKickoffCallback
= NVDMAKickoffCallback
;
871 NVDmaStart(&_sd
->Card
, SURFACE_OFFSET_DST
, 1);
872 NVDmaNext(&_sd
->Card
, bm
->framebuffer
);
873 _sd
->dst_offset
= bm
->framebuffer
;
875 NVDmaStart(&_sd
->Card
, SURFACE_PITCH
, 1);
876 NVDmaNext(&_sd
->Card
, (bm
->pitch
<< 16) | _sd
->src_pitch
);
877 _sd
->dst_pitch
= bm
->pitch
;
881 NVDmaStart(&_sd
->Card
, CLIP_POINT
, 2);
882 NVDmaNext(&_sd
->Card
, (GC_CLIPY1(gc
) << 16) | GC_CLIPX1(gc
));
883 NVDmaNext(&_sd
->Card
, ((GC_CLIPY2(gc
)-GC_CLIPY1(gc
)+1) << 16) |
884 (GC_CLIPX2(gc
)-GC_CLIPX1(gc
)+1));
887 NVSetRopSolid(_sd
, GC_DRMD(gc
), ~0 << bm
->depth
);
888 NVDmaStart(&_sd
->Card
, LINE_FORMAT
, 2);
889 NVDmaNext(&_sd
->Card
, bm
->line_format
);
890 NVDmaNext(&_sd
->Card
, GC_FG(gc
));
892 NVDmaStart(&_sd
->Card
, LINE_LINES(0), 8);
894 NVDmaNext(&_sd
->Card
, (msg
->minY
<< 16) | (msg
->minX
& 0xffff));
895 NVDmaNext(&_sd
->Card
, (msg
->minY
<< 16) | (msg
->maxX
& 0xffff));
897 NVDmaNext(&_sd
->Card
, ((msg
->minY
+ addY
) << 16) | (msg
->maxX
& 0xffff));
898 NVDmaNext(&_sd
->Card
, ((msg
->maxY
<< 16)) | (msg
->maxX
& 0xffff));
900 NVDmaNext(&_sd
->Card
, ((msg
->maxY
<< 16)) | ((msg
->maxX
- addX
) & 0xffff));
901 NVDmaNext(&_sd
->Card
, ((msg
->maxY
<< 16)) | ((msg
->minX
) & 0xffff));
903 NVDmaNext(&_sd
->Card
, ((msg
->maxY
- addY
) << 16) | (msg
->minX
& 0xffff));
904 NVDmaNext(&_sd
->Card
, ((msg
->minY
+ addY
) << 16) | (msg
->minX
& 0xffff));
908 NVDmaStart(&_sd
->Card
, CLIP_POINT
, 2);
909 NVDmaNext(&_sd
->Card
, 0x00000000);
910 NVDmaNext(&_sd
->Card
, 0xff00ff00);
913 NVDmaKickoff(&_sd
->Card
);
921 VOID
NVBM__Hidd_BitMap__DrawPolygon(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_DrawPolygon
*msg
)
923 OOP_Object
*gc
= msg
->gc
;
924 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
929 if ((GC_LINEPAT(gc
) != (UWORD
)~0) || !bm
->fbgfx
)
931 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
940 _sd
->Card
.DMAKickoffCallback
= NVDMAKickoffCallback
;
941 _sd
->gpu_busy
= TRUE
;
943 NVDmaStart(&_sd
->Card
, SURFACE_OFFSET_DST
, 1);
944 NVDmaNext(&_sd
->Card
, bm
->framebuffer
);
945 _sd
->dst_offset
= bm
->framebuffer
;
947 NVDmaStart(&_sd
->Card
, SURFACE_PITCH
, 1);
948 NVDmaNext(&_sd
->Card
, (bm
->pitch
<< 16) | _sd
->src_pitch
);
949 _sd
->dst_pitch
= bm
->pitch
;
953 NVDmaStart(&_sd
->Card
, CLIP_POINT
, 2);
954 NVDmaNext(&_sd
->Card
, (GC_CLIPY1(gc
) << 16) | GC_CLIPX1(gc
));
955 NVDmaNext(&_sd
->Card
, ((GC_CLIPY2(gc
)-GC_CLIPY1(gc
)+1) << 16) |
956 (GC_CLIPX2(gc
)-GC_CLIPX1(gc
)+1));
959 NVSetRopSolid(_sd
, GC_DRMD(gc
), ~0 << bm
->depth
);
960 NVDmaStart(&_sd
->Card
, LINE_FORMAT
, 2);
961 NVDmaNext(&_sd
->Card
, bm
->line_format
);
962 NVDmaNext(&_sd
->Card
, GC_FG(gc
));
964 for(i
= 2; i
< (2 * msg
->n
); i
= i
+ 2)
966 NVDmaStart(&_sd
->Card
, LINE_LINES(0), 2);
967 NVDmaNext(&_sd
->Card
, (msg
->coords
[i
- 1] << 16) | msg
->coords
[i
- 2]);
968 NVDmaNext(&_sd
->Card
, (msg
->coords
[i
+ 1] << 16) | msg
->coords
[i
]);
973 NVDmaStart(&_sd
->Card
, CLIP_POINT
, 2);
974 NVDmaNext(&_sd
->Card
, 0x00000000);
975 NVDmaNext(&_sd
->Card
, 0x7f007f00);
978 NVDmaKickoff(&_sd
->Card
);
986 VOID
NVBM__Hidd_BitMap__PutImage(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImage
*msg
)
988 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
992 IPTR VideoData
= bm
->framebuffer
;
996 VideoData
+= (IPTR
)_sd
->Card
.FrameBuffer
;
1008 case vHidd_StdPixFmt_Native
:
1013 struct pHidd_BitMap_CopyMemBox8 __m
= {
1014 _sd
->mid_CopyMemBox8
,
1027 OOP_DoMethod(o
, (OOP_Msg
)m
);
1033 struct pHidd_BitMap_CopyMemBox16 __m
= {
1034 _sd
->mid_CopyMemBox16
,
1047 OOP_DoMethod(o
, (OOP_Msg
)m
);
1053 struct pHidd_BitMap_CopyMemBox32 __m
= {
1054 _sd
->mid_CopyMemBox32
,
1067 OOP_DoMethod(o
, (OOP_Msg
)m
);
1071 } /* switch(data->bytesperpix) */
1074 case vHidd_StdPixFmt_Native32
:
1079 struct pHidd_BitMap_PutMem32Image8 __m
= {
1080 _sd
->mid_PutMem32Image8
,
1090 OOP_DoMethod(o
, (OOP_Msg
)m
);
1096 struct pHidd_BitMap_PutMem32Image16 __m
= {
1097 _sd
->mid_PutMem32Image16
,
1107 OOP_DoMethod(o
, (OOP_Msg
)m
);
1113 struct pHidd_BitMap_CopyMemBox32 __m
= {
1114 _sd
->mid_CopyMemBox32
,
1127 OOP_DoMethod(o
, (OOP_Msg
)m
);
1131 } /* switch(data->bytesperpix) */
1135 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
1138 } /* switch(msg->pixFmt) */
1143 VOID
NVBM__Hidd_BitMap__GetImage(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImage
*msg
)
1145 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1149 IPTR VideoData
= bm
->framebuffer
;
1153 VideoData
+= (IPTR
)_sd
->Card
.FrameBuffer
;
1165 case vHidd_StdPixFmt_Native
:
1170 struct pHidd_BitMap_CopyMemBox8 __m
= {
1171 _sd
->mid_CopyMemBox8
,
1184 OOP_DoMethod(o
, (OOP_Msg
)m
);
1190 struct pHidd_BitMap_CopyMemBox16 __m
= {
1191 _sd
->mid_CopyMemBox16
,
1204 OOP_DoMethod(o
, (OOP_Msg
)m
);
1210 struct pHidd_BitMap_CopyMemBox32 __m
= {
1211 _sd
->mid_CopyMemBox32
,
1224 OOP_DoMethod(o
, (OOP_Msg
)m
);
1228 } /* switch(data->bytesperpix) */
1231 case vHidd_StdPixFmt_Native32
:
1236 struct pHidd_BitMap_GetMem32Image8 __m
= {
1237 _sd
->mid_GetMem32Image8
,
1248 OOP_DoMethod(o
, (OOP_Msg
)m
);
1254 struct pHidd_BitMap_GetMem32Image16 __m
= {
1255 _sd
->mid_GetMem32Image16
,
1266 OOP_DoMethod(o
, (OOP_Msg
)m
);
1272 struct pHidd_BitMap_CopyMemBox32 __m
= {
1273 _sd
->mid_CopyMemBox32
,
1286 OOP_DoMethod(o
, (OOP_Msg
)m
);
1290 } /* switch(data->bytesperpix) */
1294 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
1297 } /* switch(msg->pixFmt) */
1303 VOID
NVBM__Hidd_BitMap__PutTemplate(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutTemplate
*msg
)
1305 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1309 IPTR VideoData
= bm
->framebuffer
;
1313 VideoData
+= (IPTR
)_sd
->Card
.FrameBuffer
;
1327 struct pHidd_BitMap_PutMemTemplate8 __m
= {
1328 _sd
->mid_PutMemTemplate8
,
1342 OOP_DoMethod(o
, (OOP_Msg
)m
);
1348 struct pHidd_BitMap_PutMemTemplate16 __m
= {
1349 _sd
->mid_PutMemTemplate16
,
1363 OOP_DoMethod(o
, (OOP_Msg
)m
);
1369 struct pHidd_BitMap_PutMemTemplate32 __m
= {
1370 _sd
->mid_PutMemTemplate32
,
1384 OOP_DoMethod(o
, (OOP_Msg
)m
);
1388 } /* switch(bm->bpp) */
1393 VOID
NVBM__Hidd_BitMap__PutPattern(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutPattern
*msg
)
1395 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1399 IPTR VideoData
= bm
->framebuffer
;
1403 VideoData
+= (IPTR
)_sd
->Card
.FrameBuffer
;
1417 struct pHidd_BitMap_PutMemPattern8 __m
= {
1418 _sd
->mid_PutMemPattern8
,
1438 OOP_DoMethod(o
, (OOP_Msg
)m
);
1444 struct pHidd_BitMap_PutMemPattern16 __m
= {
1445 _sd
->mid_PutMemPattern16
,
1465 OOP_DoMethod(o
, (OOP_Msg
)m
);
1471 struct pHidd_BitMap_PutMemPattern32 __m
= {
1472 _sd
->mid_PutMemPattern32
,
1492 OOP_DoMethod(o
, (OOP_Msg
)m
);
1496 } /* switch(bm->bpp) */
1502 BOOL
NVBM__Hidd_BitMap__ObtainDirectAccess(OOP_Class
*cl
, OOP_Object
*o
,
1503 struct pHidd_BitMap_ObtainDirectAccess
*msg
)
1505 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1508 IPTR VideoData
= bm
->framebuffer
;
1512 VideoData
+= (IPTR
)_sd
->Card
.FrameBuffer
;
1521 *msg
->addressReturn
= (UBYTE
*)VideoData
;
1522 *msg
->widthReturn
= bm
->pitch
/ bm
->bpp
;
1523 *msg
->heightReturn
= bm
->height
;
1524 *msg
->bankSizeReturn
= *msg
->memSizeReturn
= bm
->pitch
* bm
->height
;
1529 VOID
NVBM__Hidd_BitMap__ReleaseDirectAccess(OOP_Class
*cl
, OOP_Object
*o
,
1530 struct pHidd_BitMap_ReleaseDirectAccess
*msg
)
1532 nvBitMap
*bm
= OOP_INST_DATA(cl
, o
);
1540 static int Init_BMMethodIDs(LIBBASETYPEPTR LIBBASE
)
1542 LIBBASE
->sd
.mid_CopyMemBox8
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_CopyMemBox8
);
1543 LIBBASE
->sd
.mid_CopyMemBox16
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_CopyMemBox16
);
1544 LIBBASE
->sd
.mid_CopyMemBox32
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_CopyMemBox32
);
1545 LIBBASE
->sd
.mid_PutMem32Image8
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_PutMem32Image8
);
1546 LIBBASE
->sd
.mid_PutMem32Image16
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_PutMem32Image16
);
1547 LIBBASE
->sd
.mid_GetMem32Image8
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_GetMem32Image8
);
1548 LIBBASE
->sd
.mid_GetMem32Image16
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_GetMem32Image16
);
1549 LIBBASE
->sd
.mid_Clear
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_Clear
);
1550 LIBBASE
->sd
.mid_PutMemTemplate8
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_PutMemTemplate8
);
1551 LIBBASE
->sd
.mid_PutMemTemplate16
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_PutMemTemplate16
);
1552 LIBBASE
->sd
.mid_PutMemTemplate32
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_PutMemTemplate32
);
1553 LIBBASE
->sd
.mid_PutMemPattern8
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_PutMemPattern8
);
1554 LIBBASE
->sd
.mid_PutMemPattern16
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_PutMemPattern16
);
1555 LIBBASE
->sd
.mid_PutMemPattern32
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_PutMemPattern32
);
1556 LIBBASE
->sd
.mid_CopyLUTMemBox16
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_CopyLUTMemBox16
);
1557 LIBBASE
->sd
.mid_CopyLUTMemBox32
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_CopyLUTMemBox32
);
1558 LIBBASE
->sd
.mid_GetImage
= OOP_GetMethodID(IID_Hidd_BitMap
, moHidd_BitMap_GetImage
);
1563 ADD2INITLIB(Init_BMMethodIDs
, 0)