2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
9 #include <exec/libraries.h>
10 #include <exec/rawfmt.h>
11 #include <exec/types.h>
12 #include <exec/resident.h>
13 #include <exec/memory.h>
14 #include <graphics/displayinfo.h>
15 #include <aros/libcall.h>
16 #include <proto/alib.h>
17 #include <proto/exec.h>
18 #include <proto/graphics.h>
19 #include <proto/kernel.h>
20 #include <proto/oop.h>
21 #include <proto/utility.h>
24 #include <hidd/hidd.h>
25 #include <hidd/graphics.h>
27 #include <aros/symbolsets.h>
29 #include "amigavideogfx.h"
30 #include "amigavideobitmap.h"
35 #include LC_LIBDEFS_FILE
39 #include <aros/debug.h>
41 #define SPECIALMODES 3
42 #define NATIVEMODES (3 * 4 * SPECIALMODES)
43 static const UWORD widthtable
[] = { 320, 640, 1280, 0 };
44 static const UWORD heighttable
[] = { 200, 256, 400, 512, 0 };
45 static const ULONG specialmask_aga
[] = { 0, EXTRAHALFBRITE_KEY
, HAM_KEY
, 0xffffffff };
47 #define SPECIAL_MODE_MASK (EXTRAHALFBRITE_KEY | HAM_KEY)
49 VOID
AmigaVideoCl__Hidd_Gfx__NominalDimensions(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_NominalDimensions
*msg
)
51 struct amigavideo_staticdata
*csd
= CSD(cl
);
52 struct GfxBase
*GfxBase
= (struct GfxBase
*)csd
->cs_GfxBase
;
54 DB2(bug("NominalDimensions()\n"));
57 *(msg
->width
) = GfxBase
->NormalDisplayColumns
;
59 *(msg
->height
) = GfxBase
->NormalDisplayRows
;
64 ULONG
AmigaVideoCl__Hidd_Gfx__ModeProperties(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_ModeProperties
*msg
)
67 ULONG modeid
= msg
->modeID
;
69 flags
= DIPF_IS_SPRITES
| DIPF_IS_DRAGGABLE
|
70 DIPF_IS_SPRITES_ATT
| DIPF_IS_SPRITES_CHNG_BASE
| DIPF_IS_SPRITES_CHNG_PRI
|
71 DIPF_IS_DBUFFER
| DIPF_IS_BEAMSYNC
| DIPF_IS_GENLOCK
;
72 msg
->props
->NumHWSprites
= 8;
73 if ((modeid
& MONITOR_ID_MASK
) == PAL_MONITOR_ID
)
75 if (modeid
& LORESLACE_KEY
)
76 flags
|= DIPF_IS_LACE
;
77 if (modeid
& HAM_KEY
) {
79 if (modeid
& SUPER_KEY
)
82 if (modeid
& EXTRAHALFBRITE_KEY
) {
83 flags
|= DIPF_IS_EXTRAHALFBRITE
;
84 if (modeid
& SUPER_KEY
)
87 if ((modeid
& SUPER_KEY
) == SUPER_KEY
&& !(flags
& DIPF_IS_AA
))
89 if (!(modeid
& SPECIAL_MODE_MASK
))
91 msg
->props
->DisplayInfoFlags
= flags
;
92 msg
->props
->CompositionFlags
= COMPF_ABOVE
| COMPF_BELOW
; // | COMPF_LEFT | COMPF_RIGHT;
93 DB2(bug("ModeProp %08x = %08x\n", modeid
, flags
));
94 return sizeof(struct HIDD_ModeProperties
);
97 HIDDT_ModeID
*AmigaVideoCl__Hidd_Gfx__QueryModeIDs(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_QueryModeIDs
*msg
)
99 struct amigavideo_staticdata
*csd
= CSD(cl
);
100 struct NativeChipsetMode
*node
;
101 struct TagItem
*tag
, *tstate
;
102 ULONG minwidth
= 0, maxwidth
= 0xFFFFFFFF;
103 ULONG minheight
= 0, maxheight
= 0xFFFFFFFF;
104 HIDDT_ModeID
*modeids
;
105 struct Library
*UtilityBase
= csd
->cs_UtilityBase
;
108 if (csd
->superforward
)
109 return (HIDDT_ModeID
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
111 for (tstate
= msg
->queryTags
; (tag
= NextTagItem(&tstate
)); )
115 case tHidd_GfxMode_MinWidth
:
116 minwidth
= (ULONG
)tag
->ti_Tag
;
119 case tHidd_GfxMode_MaxWidth
:
120 maxwidth
= (ULONG
)tag
->ti_Tag
;
123 case tHidd_GfxMode_MinHeight
:
124 minheight
= (ULONG
)tag
->ti_Tag
;
127 case tHidd_GfxMode_MaxHeight
:
128 maxheight
= (ULONG
)tag
->ti_Tag
;
131 case tHidd_GfxMode_PixFmts
:
132 /* all chipset modes have same pixelformat */
137 DB2(bug("QueryModeIDs (%dx%d)-(%dx%d)\n", minwidth
, minheight
, maxwidth
, maxheight
));
139 ForeachNode(&csd
->nativemodelist
, node
) {
140 if (node
->width
>= minwidth
&& node
->width
<= maxwidth
&& node
->height
>= minheight
&& node
->height
<= maxheight
) {
144 modeids
= AllocVec((cnt
+ 1) * sizeof(HIDDT_ModeID
), MEMF_PUBLIC
);
148 ForeachNode(&csd
->nativemodelist
, node
) {
149 if (node
->width
>= minwidth
&& node
->width
<= maxwidth
&& node
->height
>= minheight
&& node
->height
<= maxheight
) {
150 DB2(bug("%d: %08x\n", cnt
, node
->modeid
));
151 modeids
[cnt
++] = node
->modeid
;
154 modeids
[cnt
] = vHidd_ModeID_Invalid
;
158 VOID
AmigaVideoCl__Hidd_Gfx__ReleaseModeIDs(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_ReleaseModeIDs
*msg
)
160 struct amigavideo_staticdata
*csd
= CSD(cl
);
161 if (csd
->superforward
)
162 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
164 FreeVec(msg
->modeIDs
);
167 HIDDT_ModeID
AmigaVideoCl__Hidd_Gfx__NextModeID(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_NextModeID
*msg
)
169 struct amigavideo_staticdata
*csd
= CSD(cl
);
170 struct NativeChipsetMode
*node
= NULL
;
171 HIDDT_ModeID mid
= vHidd_ModeID_Invalid
;
173 DB2(bug("NextModeID %08x\n", msg
->modeID
));
174 if (msg
->modeID
!= vHidd_ModeID_Invalid
) {
175 ForeachNode(&csd
->nativemodelist
, node
) {
176 if (node
->modeid
== msg
->modeID
) {
177 node
= (struct NativeChipsetMode
*)node
->node
.ln_Succ
;
183 node
= (struct NativeChipsetMode
*)csd
->nativemodelist
.lh_Head
;
184 if (node
->node
.ln_Succ
) {
186 *msg
->syncPtr
= node
->sync
;
187 *msg
->pixFmtPtr
= node
->pf
;
189 DB2(bug("=%08x %p %p\n", mid
, *msg
->syncPtr
, *msg
->pixFmtPtr
));
193 BOOL
AmigaVideoCl__Hidd_Gfx__GetMode(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_GetMode
*msg
)
195 struct amigavideo_staticdata
*csd
= CSD(cl
);
196 struct NativeChipsetMode
*node
;
198 if (csd
->superforward
)
199 return (BOOL
)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
201 DB2(bug("GetMode %08x\n", msg
->modeID
));
202 ForeachNode(&csd
->nativemodelist
, node
) {
203 if (node
->modeid
== msg
->modeID
) {
204 *msg
->syncPtr
= node
->sync
;
205 *msg
->pixFmtPtr
= node
->pf
;
206 DB2(bug("= %p %p %dx%dx%d %d\n", node
->sync
, node
->pf
, node
->width
, node
->height
, node
->depth
, node
->special
));
210 DB2(bug("= FAIL\n"));
214 #define ADDTAG(tag,data) { *tagptr++ = tag; *tagptr++ = data; }
217 static void makemodename(ULONG modeid
, UBYTE
*bufptr
)
219 BOOL special
= FALSE
;
221 special
= (modeid
& SPECIAL_MODE_MASK
) != 0;
223 if ((modeid
& MONITOR_ID_MASK
) == PAL_MONITOR_ID
)
224 strcat(bufptr
, "PAL");
225 else if ((modeid
& MONITOR_ID_MASK
) == NTSC_MONITOR_ID
)
226 strcat (bufptr
, "NTSC");
228 if ((modeid
& (HIRES_KEY
| SUPER_KEY
)) == LORES_KEY
)
229 strcat(bufptr
, special
? "LowRes" : "Low Res");
230 else if ((modeid
& (HIRES_KEY
| SUPER_KEY
)) == HIRES_KEY
)
231 strcat(bufptr
, special
? "HighRes" : "High Res");
233 strcat(bufptr
, special
? "SuperHighRes" : "Super-High Res");
234 if (modeid
& HAM_KEY
)
235 strcat(bufptr
, " HAM");
236 if (modeid
& EXTRAHALFBRITE_KEY
)
237 strcat(bufptr
, " EHB");
238 if ((modeid
& LORESDPF2_KEY
) == LORESDPF_KEY
)
239 strcat(bufptr
, " DualPF");
240 if ((modeid
& LORESDPF2_KEY
) == LORESDPF2_KEY
)
241 strcat(bufptr
, " DualPF2");
242 if (modeid
& LORESLACE_KEY
)
243 strcat(bufptr
, special
? " Interlace" : " Laced");
244 DB2(bug("%08x '%s'\n", modeid
, bufptr
));
247 static struct NativeChipsetMode
*addmodeid(struct amigavideo_staticdata
*csd
, ULONG modeid
, WORD w
, WORD h
, WORD d
, UBYTE special
)
249 struct NativeChipsetMode
*m
;
251 m
= AllocMem(sizeof(struct NativeChipsetMode
), MEMF_CLEAR
| MEMF_PUBLIC
);
252 DB2(bug("%p %08x %dx%dx%d %d\n", m
, modeid
, w
, h
, d
, special
));
256 m
->special
= special
;
258 AddTail(&csd
->nativemodelist
, &m
->node
);
262 /* this is SOOO HORRIBLE, do not even attempt to understand it.. */
264 OOP_Object
*AmigaVideoCl__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
266 struct amigavideo_staticdata
*csd
= CSD(cl
);
267 struct Library
*OOPBase
= csd
->cs_OOPBase
;
268 struct TagItem mytags
[2];
269 struct pRoot_New mymsg
;
270 ULONG allocsize
= 3000, allocsizebuf
= 1000;
271 WORD x
, y
, cnt
, i
, j
;
274 ULONG
*tags
, *tagptr
;
275 ULONG
*modetags
[NATIVEMODES
], modeids
[NATIVEMODES
];
276 ULONG
*pftags_aga
[SPECIALMODES
];
277 ULONG
*pftags_ecs_shres
= NULL
, *pftags_ecs_hires
, *pftags_ecs_lores
, *pftags_ecs_6
;
278 ULONG
*mode_tags_aga
;
279 ULONG
*mode_tags_ecs
;
281 if (csd
->initialized
)
284 NewList(&csd
->nativemodelist
);
285 tags
= tagptr
= AllocVec(allocsize
, MEMF_PUBLIC
| MEMF_REVERSE
);
286 buf
= bufptr
= AllocVec(allocsizebuf
, MEMF_PUBLIC
| MEMF_REVERSE
);
289 for (y
= 0; heighttable
[y
]; y
++) {
290 WORD h
= heighttable
[y
];
291 for (x
= 0; widthtable
[x
]; x
++) {
292 WORD w
= widthtable
[x
];
300 if (!csd
->aga
&& !csd
->ecs_denise
)
302 d
= csd
->aga
? 8 : 2;
307 d
= csd
->aga
? 8 : 4;
310 d
= csd
->aga
? 8 : 5;
313 modeid
|= LORESLACE_KEY
;
314 if (h
== 200 || h
== 400)
315 modeid
|= NTSC_MONITOR_ID
;
317 modeid
|= PAL_MONITOR_ID
;
319 for (i
= 0; i
< SPECIALMODES
; i
++) {
323 if (!csd
->aga
&& (modeid
& SUPER_KEY
))
325 mid
|= EXTRAHALFBRITE_KEY
;
328 if (!csd
->aga
&& (modeid
& SUPER_KEY
))
331 d2
= csd
->aga
? 8 : 6;
334 addmodeid(csd
, mid
, w
, h
, d2
, csd
->aga
? i
: (i
== 0 ? res
: i
- 1 + 3));
335 modetags
[cnt
] = tagptr
;
336 modeids
[cnt
++] = mid
;
338 ADDTAG(aHidd_Sync_HDisp
, w
);
339 ADDTAG(aHidd_Sync_VDisp
, h
);
340 ADDTAG(aHidd_Sync_Flags
, h
>= 400 ? vHidd_Sync_Interlaced
: 0);
341 ADDTAG(aHidd_Sync_PixelClock
, 1000000000 / (280 >> res
));
350 pftags_aga
[0] = tagptr
;
351 ADDTAG(aHidd_PixFmt_RedShift
, 8);
352 ADDTAG(aHidd_PixFmt_GreenShift
, 16);
353 ADDTAG(aHidd_PixFmt_BlueShift
, 24);
354 ADDTAG(aHidd_PixFmt_AlphaShift
, 0);
355 ADDTAG(aHidd_PixFmt_RedMask
, 0x00FF0000);
356 ADDTAG(aHidd_PixFmt_GreenMask
, 0x0000FF00);
357 ADDTAG(aHidd_PixFmt_BlueMask
, 0x000000FF);
358 ADDTAG(aHidd_PixFmt_AlphaMask
, 0x00000000);
359 ADDTAG(aHidd_PixFmt_CLUTMask
, 0x000000FF);
360 ADDTAG(aHidd_PixFmt_CLUTShift
, 0);
361 ADDTAG(aHidd_PixFmt_ColorModel
, vHidd_ColorModel_Palette
);
362 ADDTAG(aHidd_PixFmt_Depth
, 8);
363 ADDTAG(aHidd_PixFmt_BytesPerPixel
, 1);
364 ADDTAG(aHidd_PixFmt_BitsPerPixel
, 8);
365 ADDTAG(aHidd_PixFmt_StdPixFmt
, vHidd_StdPixFmt_Plane
);
366 ADDTAG(aHidd_PixFmt_BitMapType
, vHidd_BitMapType_Planar
);
369 pftags_aga
[1] = tagptr
;
370 ADDTAG(aHidd_PixFmt_RedShift
, 8);
371 ADDTAG(aHidd_PixFmt_GreenShift
, 16);
372 ADDTAG(aHidd_PixFmt_BlueShift
, 24);
373 ADDTAG(aHidd_PixFmt_AlphaShift
, 0);
374 ADDTAG(aHidd_PixFmt_RedMask
, 0x00FF0000);
375 ADDTAG(aHidd_PixFmt_GreenMask
, 0x0000FF00);
376 ADDTAG(aHidd_PixFmt_BlueMask
, 0x000000FF);
377 ADDTAG(aHidd_PixFmt_AlphaMask
, 0x00000000);
378 ADDTAG(aHidd_PixFmt_CLUTMask
, 0x000000FF);
379 ADDTAG(aHidd_PixFmt_CLUTShift
, 0);
380 ADDTAG(aHidd_PixFmt_ColorModel
, vHidd_ColorModel_Palette
);
381 ADDTAG(aHidd_PixFmt_Depth
, 6);
382 ADDTAG(aHidd_PixFmt_BytesPerPixel
, 1);
383 ADDTAG(aHidd_PixFmt_BitsPerPixel
, 6);
384 ADDTAG(aHidd_PixFmt_StdPixFmt
, vHidd_StdPixFmt_Plane
);
385 ADDTAG(aHidd_PixFmt_BitMapType
, vHidd_BitMapType_Planar
);
388 pftags_aga
[2] = NULL
;
390 mode_tags_aga
= tagptr
;
391 ADDTAG(aHidd_Sync_HMin
, 112);
392 ADDTAG(aHidd_Sync_VMin
, 112);
393 ADDTAG(aHidd_Sync_HMax
, 16384);
394 ADDTAG(aHidd_Sync_VMax
, 16384);
396 for (j
= 0; specialmask_aga
[j
] != 0xffffffff; j
++) {
398 ADDTAG(aHidd_Gfx_PixFmtTags
, (IPTR
)pftags_aga
[j
]);
399 for (i
= 0; i
< cnt
; i
++) {
400 ULONG modeid
= modeids
[i
];
401 if ((j
== 0 && !(modeid
& SPECIAL_MODE_MASK
)) || (j
> 0 && ((modeid
& SPECIAL_MODE_MASK
) == specialmask_aga
[j
]))) {
402 makemodename(modeid
, bufptr
);
403 ADDTAG(aHidd_Sync_Description
, (IPTR
)bufptr
);
404 bufptr
+= strlen(bufptr
) + 1;
405 ADDTAG(aHidd_Gfx_SyncTags
, (IPTR
)modetags
[i
]);
412 mytags
[0].ti_Tag
= aHidd_Gfx_ModeTags
;
413 mytags
[0].ti_Data
= (IPTR
)mode_tags_aga
;
414 mytags
[1].ti_Tag
= TAG_MORE
;
415 mytags
[1].ti_Data
= (IPTR
)msg
->attrList
;
419 pftags_ecs_lores
= tagptr
;
420 ADDTAG(aHidd_PixFmt_RedShift
, 20);
421 ADDTAG(aHidd_PixFmt_GreenShift
, 24);
422 ADDTAG(aHidd_PixFmt_BlueShift
, 28);
423 ADDTAG(aHidd_PixFmt_AlphaShift
, 0);
424 ADDTAG(aHidd_PixFmt_RedMask
, 0x00000F00);
425 ADDTAG(aHidd_PixFmt_GreenMask
, 0x000000F0);
426 ADDTAG(aHidd_PixFmt_BlueMask
, 0x0000000F);
427 ADDTAG(aHidd_PixFmt_AlphaMask
, 0x00000000);
428 ADDTAG(aHidd_PixFmt_CLUTMask
, 0x0000001F);
429 ADDTAG(aHidd_PixFmt_CLUTShift
, 0);
430 ADDTAG(aHidd_PixFmt_ColorModel
, vHidd_ColorModel_Palette
);
431 ADDTAG(aHidd_PixFmt_Depth
, 5);
432 ADDTAG(aHidd_PixFmt_BytesPerPixel
, 1);
433 ADDTAG(aHidd_PixFmt_BitsPerPixel
, 5);
434 ADDTAG(aHidd_PixFmt_StdPixFmt
, vHidd_StdPixFmt_Plane
);
435 ADDTAG(aHidd_PixFmt_BitMapType
, vHidd_BitMapType_Planar
);
438 pftags_ecs_hires
= tagptr
;
439 ADDTAG(aHidd_PixFmt_RedShift
, 20);
440 ADDTAG(aHidd_PixFmt_GreenShift
, 24);
441 ADDTAG(aHidd_PixFmt_BlueShift
, 28);
442 ADDTAG(aHidd_PixFmt_AlphaShift
, 0);
443 ADDTAG(aHidd_PixFmt_RedMask
, 0x00000F00);
444 ADDTAG(aHidd_PixFmt_GreenMask
, 0x000000F0);
445 ADDTAG(aHidd_PixFmt_BlueMask
, 0x0000000F);
446 ADDTAG(aHidd_PixFmt_AlphaMask
, 0x00000000);
447 ADDTAG(aHidd_PixFmt_CLUTMask
, 0x0000001F);
448 ADDTAG(aHidd_PixFmt_CLUTShift
, 0);
449 ADDTAG(aHidd_PixFmt_ColorModel
, vHidd_ColorModel_Palette
);
450 ADDTAG(aHidd_PixFmt_Depth
, 4);
451 ADDTAG(aHidd_PixFmt_BytesPerPixel
, 1);
452 ADDTAG(aHidd_PixFmt_BitsPerPixel
, 4);
453 ADDTAG(aHidd_PixFmt_StdPixFmt
, vHidd_StdPixFmt_Plane
);
454 ADDTAG(aHidd_PixFmt_BitMapType
, vHidd_BitMapType_Planar
);
457 pftags_ecs_shres
= tagptr
;
458 ADDTAG(aHidd_PixFmt_RedShift
, 20);
459 ADDTAG(aHidd_PixFmt_GreenShift
, 24);
460 ADDTAG(aHidd_PixFmt_BlueShift
, 28);
461 ADDTAG(aHidd_PixFmt_AlphaShift
, 0);
462 ADDTAG(aHidd_PixFmt_RedMask
, 0x00000F00);
463 ADDTAG(aHidd_PixFmt_GreenMask
, 0x000000F0);
464 ADDTAG(aHidd_PixFmt_BlueMask
, 0x0000000F);
465 ADDTAG(aHidd_PixFmt_AlphaMask
, 0x00000000);
466 ADDTAG(aHidd_PixFmt_CLUTMask
, 0x0000001F);
467 ADDTAG(aHidd_PixFmt_CLUTShift
, 0);
468 ADDTAG(aHidd_PixFmt_ColorModel
, vHidd_ColorModel_Palette
);
469 ADDTAG(aHidd_PixFmt_Depth
, 2);
470 ADDTAG(aHidd_PixFmt_BytesPerPixel
, 1);
471 ADDTAG(aHidd_PixFmt_BitsPerPixel
, 2);
472 ADDTAG(aHidd_PixFmt_StdPixFmt
, vHidd_StdPixFmt_Plane
);
473 ADDTAG(aHidd_PixFmt_BitMapType
, vHidd_BitMapType_Planar
);
476 pftags_ecs_6
= tagptr
;
477 ADDTAG(aHidd_PixFmt_RedShift
, 20);
478 ADDTAG(aHidd_PixFmt_GreenShift
, 24);
479 ADDTAG(aHidd_PixFmt_BlueShift
, 28);
480 ADDTAG(aHidd_PixFmt_AlphaShift
, 0);
481 ADDTAG(aHidd_PixFmt_RedMask
, 0x00000F00);
482 ADDTAG(aHidd_PixFmt_GreenMask
, 0x000000F0);
483 ADDTAG(aHidd_PixFmt_BlueMask
, 0x0000000F);
484 ADDTAG(aHidd_PixFmt_AlphaMask
, 0x00000000);
485 ADDTAG(aHidd_PixFmt_CLUTMask
, 0x0000001F);
486 ADDTAG(aHidd_PixFmt_CLUTShift
, 0);
487 ADDTAG(aHidd_PixFmt_ColorModel
, vHidd_ColorModel_Palette
);
488 ADDTAG(aHidd_PixFmt_Depth
, 6);
489 ADDTAG(aHidd_PixFmt_BytesPerPixel
, 1);
490 ADDTAG(aHidd_PixFmt_BitsPerPixel
, 6);
491 ADDTAG(aHidd_PixFmt_StdPixFmt
, vHidd_StdPixFmt_Plane
);
492 ADDTAG(aHidd_PixFmt_BitMapType
, vHidd_BitMapType_Planar
);
495 mode_tags_ecs
= tagptr
;
496 ADDTAG(aHidd_Sync_HMin
, 112);
497 ADDTAG(aHidd_Sync_VMin
, 112);
498 ADDTAG(aHidd_Sync_HMax
, csd
->ecs_agnus
? 16384 : 1008);
499 ADDTAG(aHidd_Sync_VMax
, csd
->ecs_agnus
? 16384 : 1008);
501 ADDTAG(aHidd_Gfx_PixFmtTags
, (IPTR
)pftags_ecs_lores
);
502 for (i
= 0; i
< cnt
; i
++) {
503 if ((modeids
[i
] & SPECIAL_MODE_MASK
) || (modeids
[i
] & SUPER_KEY
) != LORES_KEY
)
505 makemodename(modeids
[i
], bufptr
);
506 ADDTAG(aHidd_Sync_Description
, (IPTR
)bufptr
);
507 bufptr
+= strlen(bufptr
) + 1;
508 ADDTAG(aHidd_Gfx_SyncTags
, (IPTR
)modetags
[i
]);
511 ADDTAG(aHidd_Gfx_PixFmtTags
, (IPTR
)pftags_ecs_hires
);
512 for (i
= 0; i
< cnt
; i
++) {
513 if ((modeids
[i
] & SPECIAL_MODE_MASK
) || (modeids
[i
] & SUPER_KEY
) != HIRES_KEY
)
515 makemodename(modeids
[i
], bufptr
);
516 ADDTAG(aHidd_Sync_Description
, (IPTR
)bufptr
);
517 bufptr
+= strlen(bufptr
) + 1;
518 ADDTAG(aHidd_Gfx_SyncTags
, (IPTR
)modetags
[i
]);
521 ADDTAG(aHidd_Gfx_PixFmtTags
, (IPTR
)pftags_ecs_shres
);
522 if (csd
->ecs_denise
) {
523 for (i
= 0; i
< cnt
; i
++) {
524 if ((modeids
[i
] & SPECIAL_MODE_MASK
) || (modeids
[i
] & SUPER_KEY
) != SUPER_KEY
)
526 makemodename(modeids
[i
], bufptr
);
527 ADDTAG(aHidd_Sync_Description
, (IPTR
)bufptr
);
528 bufptr
+= strlen(bufptr
) + 1;
529 ADDTAG(aHidd_Gfx_SyncTags
, (IPTR
)modetags
[i
]);
533 ADDTAG(aHidd_Gfx_PixFmtTags
, (IPTR
)pftags_ecs_6
);
534 for (i
= 0; i
< cnt
; i
++) {
535 if (!(modeids
[i
] & SPECIAL_MODE_MASK
))
537 makemodename(modeids
[i
], bufptr
);
538 ADDTAG(aHidd_Sync_Description
, (IPTR
)bufptr
);
539 bufptr
+= strlen(bufptr
) + 1;
540 ADDTAG(aHidd_Gfx_SyncTags
, (IPTR
)modetags
[i
]);
545 mytags
[0].ti_Tag
= aHidd_Gfx_ModeTags
;
546 mytags
[0].ti_Data
= (IPTR
)mode_tags_ecs
;
547 mytags
[1].ti_Tag
= TAG_MORE
;
548 mytags
[1].ti_Data
= (IPTR
)msg
->attrList
;
552 D(bug("alloc=%d alloced=%d\n", allocsize
, (ULONG
)tagptr
- (ULONG
)tags
));
553 D(bug("allocbuf=%d allocedbuf=%d\n", allocsizebuf
, bufptr
- buf
));
555 EnterFunc(bug("AGFX::New()\n"));
557 mymsg
.mID
= msg
->mID
;
558 mymsg
.attrList
= mytags
;
561 /* Register gfxmodes */
562 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
565 struct amigagfx_data
*data
= OOP_INST_DATA(cl
, o
);
566 struct NativeChipsetMode
*node
;
569 OOP_MethodID HiddGfxBase
= csd
->cs_HiddGfxBase
;
570 OOP_Object
*pixelformats
[8] = { 0 };
572 D(bug("AGFX::New(): Got object from super\n"));
573 NewList((struct List
*)&data
->bitmaps
);
574 csd
->initialized
= 1;
576 /* this can't be the right way to match modes.. */
577 csd
->superforward
= TRUE
;
578 midp
= HIDD_Gfx_QueryModeIDs(o
, NULL
);
579 for (pfcnt
= 0, i
= 0; midp
[i
] != vHidd_ModeID_Invalid
; i
++) {
580 OOP_Object
*sync
, *pf
;
581 HIDDT_ModeID mid
= midp
[i
];
582 if (!HIDD_Gfx_GetMode(o
, mid
, &sync
, &pf
))
584 for (j
= 0; j
< pfcnt
; j
++) {
585 if (pf
== pixelformats
[j
])
590 pixelformats
[pfcnt
++] = pf
;
594 pixelformats
[pfcnt
] = pixelformats
[0];
596 pixelformats
[pfcnt
] = pixelformats
[pfcnt
- 1];
599 for (i
= 0; i
< pfcnt
; i
++) {
600 DB2(bug("pf %d: %p\n", i
, pixelformats
[i
]));
603 ForeachNode(&csd
->nativemodelist
, node
) {
605 OOP_Object
*sync
= NULL
;
606 for (i
= 0; midp
[i
] != vHidd_ModeID_Invalid
; i
++) {
607 HIDDT_ModeID mid
= midp
[i
];
608 IPTR dwidth
, dheight
;
610 struct NativeChipsetMode
*node2
;
612 if (!HIDD_Gfx_GetMode(o
, mid
, &sync
, &pf
))
614 OOP_GetAttr(sync
, aHidd_Sync_HDisp
, &dwidth
);
615 OOP_GetAttr(sync
, aHidd_Sync_VDisp
, &dheight
);
616 if (node
->width
!= dwidth
|| node
->height
!= dheight
)
618 ForeachNode(&csd
->nativemodelist
, node2
) {
619 if (node
->width
== dwidth
&& node
->height
== dheight
) {
620 if (node2
->sync
== sync
) {
629 if (midp
[i
] == vHidd_ModeID_Invalid
) {
631 D(bug("sync not found!?\n"));
634 node
->pf
= pixelformats
[node
->special
];
635 DB2(bug("%08x %dx%dx%d sync = %p pf = %p\n",
636 node
->modeid
, node
->width
, node
->height
, node
->depth
, node
->sync
, node
->pf
));
639 HIDD_Gfx_ReleaseModeIDs(o
, midp
);
640 csd
->superforward
= FALSE
;
642 ForeachNode(&csd
->nativemodelist
, node
) {
643 DB2(bug("%08x %dx%dx%d sync = %p pf = %p\n", node
->modeid
, node
->width
, node
->height
, node
->depth
, node
->sync
, node
->pf
));
650 ReturnPtr("AGFX::New", OOP_Object
*, o
);
653 /********** GfxHidd::Dispose() ******************************/
654 VOID
AmigaVideoCl__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
656 EnterFunc(bug("AGFX::Dispose(o=%p)\n", o
));
658 D(bug("AGFX::Dispose: calling super\n"));
659 OOP_DoSuperMethod(cl
, o
, msg
);
661 ReturnVoid("AGFX::Dispose");
665 OOP_Object
*AmigaVideoCl__Hidd_Gfx__CreateObject(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_CreateObject
*msg
)
667 OOP_Object
*object
= NULL
;
669 EnterFunc(bug("AGFX::CreateObject()\n"));
671 if (msg
->cl
== CSD(cl
)->cs_basebm
)
673 struct amigavideo_staticdata
*csd
= CSD(cl
);
674 struct Library
*UtilityBase
= csd
->cs_UtilityBase
;
676 struct pHidd_Gfx_CreateObject p
;
677 struct TagItem tags
[] =
679 { TAG_IGNORE
, TAG_IGNORE
}, /* Placeholder for aHidd_BitMap_ClassPtr */
680 { TAG_MORE
, (IPTR
)msg
->attrList
}
683 modeid
= (HIDDT_ModeID
)GetTagData(aHidd_BitMap_ModeID
, vHidd_ModeID_Invalid
, msg
->attrList
);
684 D(bug("modeid=%08x\n", modeid
));
685 if (modeid
!= vHidd_ModeID_Invalid
) {
686 tags
[0].ti_Tag
= aHidd_BitMap_ClassPtr
;
687 tags
[0].ti_Data
= (IPTR
)CSD(cl
)->amigabmclass
;
694 object
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)&p
);
697 object
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
699 ReturnPtr("AGFX::CreateObject", OOP_Object
*, object
);
702 VOID
AmigaVideoCl__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
704 struct amigavideo_staticdata
*csd
= CSD(cl
);
707 //bug("AmigaVideoCl__Root__Get %x\n", msg->attrID);
709 if (IS_GFX_ATTR(msg
->attrID
, idx
))
714 case aoHidd_Gfx_HWSpriteTypes
:
715 *msg
->storage
= vHidd_SpriteType_3Plus1
;
717 case aoHidd_Gfx_SupportsHWCursor
:
718 case aoHidd_Gfx_NoFrameBuffer
:
719 *msg
->storage
= TRUE
;
721 case aoHidd_Gfx_IsWindowed
:
722 *msg
->storage
= FALSE
;
724 case aoHidd_Gfx_DriverName
:
725 *msg
->storage
= (IPTR
)"AmigaVideo";
729 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
732 VOID
AmigaVideoCl__Root__Set(OOP_Class
*cl
, OOP_Object
*obj
, struct pRoot_Set
*msg
)
734 struct amigavideo_staticdata
*csd
= CSD(cl
);
735 struct Library
*UtilityBase
= csd
->cs_UtilityBase
;
736 struct TagItem
*tag
, *tstate
;
738 tstate
= msg
->attrList
;
739 while((tag
= NextTagItem(&tstate
)))
742 D(bug("AmigaVideoCl__Root__Set %x\n", tag
->ti_Tag
));
743 if (IS_GFX_ATTR(tag
->ti_Tag
, idx
)) {
744 D(bug("->%d\n", idx
));
747 case aoHidd_Gfx_ActiveCallBack
:
748 csd
->acb
= (void *)tag
->ti_Data
;
751 case aoHidd_Gfx_ActiveCallBackData
:
752 csd
->acbdata
= (APTR
)tag
->ti_Data
;
757 OOP_DoSuperMethod(cl
, obj
, (OOP_Msg
)msg
);
760 ULONG
AmigaVideoCl__Hidd_Gfx__ShowViewPorts(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_ShowViewPorts
*msg
)
762 struct amigavideo_staticdata
*csd
= CSD(cl
);
763 struct Library
*OOPBase
= csd
->cs_OOPBase
;
764 struct HIDD_ViewPortData
*vpd
= msg
->Data
;
765 OOP_Object
*bm
= NULL
;
770 D(bug("AmigaShowViewPorts %p %p\n", vpd
, bm
));
773 struct amigabm_data
*data
= OOP_INST_DATA(OOP_OCLASS(bm
), bm
);
774 IPTR tags
[] = {aHidd_BitMap_Visible
, TRUE
, TAG_DONE
};
775 IPTR modeid
= vHidd_ModeID_Invalid
;
777 OOP_GetAttr(bm
, aHidd_BitMap_ModeID
, &modeid
);
778 csd
->modeid
= modeid
;
780 OOP_SetAttrs(bm
, (struct TagItem
*)tags
);
783 csd
->acb(csd
->acbdata
, NULL
);
792 VOID
AmigaVideoCl__Hidd_Gfx__CopyBox(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_CopyBox
*msg
)
794 struct amigavideo_staticdata
*csd
= CSD(cl
);
795 struct Library
*OOPBase
= csd
->cs_OOPBase
;
796 HIDDT_DrawMode mode
= GC_DRMD(msg
->gc
);
800 OOP_GetAttr(msg
->src
, aHidd_AmigaVideoBitMap_Drawable
, &src
);
801 OOP_GetAttr(msg
->dest
, aHidd_AmigaVideoBitMap_Drawable
, &dst
);
803 struct amigabm_data
*sdata
= OOP_INST_DATA(OOP_OCLASS(msg
->src
), msg
->src
);
804 struct amigabm_data
*ddata
= OOP_INST_DATA(OOP_OCLASS(msg
->dest
), msg
->dest
);
805 ok
= blit_copybox(csd
, sdata
->pbm
, ddata
->pbm
, msg
->srcX
, msg
->srcY
, msg
->width
, msg
->height
, msg
->destX
, msg
->destY
, mode
);
808 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
811 BOOL
AmigaVideoCl__Hidd_Gfx__CopyBoxMasked(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_CopyBoxMasked
*msg
)
813 struct amigavideo_staticdata
*csd
= CSD(cl
);
814 struct Library
*OOPBase
= csd
->cs_OOPBase
;
815 HIDDT_DrawMode mode
= GC_DRMD(msg
->gc
);
819 OOP_GetAttr(msg
->src
, aHidd_AmigaVideoBitMap_Drawable
, &src
);
820 OOP_GetAttr(msg
->dest
, aHidd_AmigaVideoBitMap_Drawable
, &dst
);
822 struct amigabm_data
*sdata
= OOP_INST_DATA(OOP_OCLASS(msg
->src
), msg
->src
);
823 struct amigabm_data
*ddata
= OOP_INST_DATA(OOP_OCLASS(msg
->dest
), msg
->dest
);
824 ok
= blit_copybox_mask(csd
, sdata
->pbm
, ddata
->pbm
, msg
->srcX
, msg
->srcY
, msg
->width
, msg
->height
, msg
->destX
, msg
->destY
, mode
, msg
->mask
);
827 return OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
832 BOOL
AmigaVideoCl__Hidd_Gfx__SetCursorShape(OOP_Class
*cl
, OOP_Object
*shape
, struct pHidd_Gfx_SetCursorShape
*msg
)
834 struct amigavideo_staticdata
*csd
= CSD(cl
);
835 struct Library
*OOPBase
= csd
->cs_OOPBase
;
839 OOP_GetAttr(msg
->shape
, aHidd_BitMap_Width
, &width
);
840 OOP_GetAttr(msg
->shape
, aHidd_BitMap_Height
, &height
);
842 maxw
= (csd
->aga
? 64 : 16);
845 if (width
> maxw
|| height
> maxh
)
848 return setsprite(csd
, width
, height
, msg
);
851 BOOL
AmigaVideoCl__Hidd_Gfx__GetMaxSpriteSize(OOP_Class
*cl
, ULONG Type
, ULONG
*Width
, ULONG
*Height
)
853 struct amigavideo_staticdata
*csd
= CSD(cl
);
854 *Width
= csd
->aga
? 64 : 16;
855 *Height
= *Width
* 2;
858 BOOL
AmigaVideoCl__Hidd_Gfx__SetCursorPos(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_SetCursorPos
*msg
)
860 struct amigavideo_staticdata
*csd
= CSD(cl
);
861 setspritepos(csd
, msg
->x
, msg
->y
);
864 VOID
AmigaVideoCl__Hidd_Gfx__SetCursorVisible(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_SetCursorVisible
*msg
)
866 struct amigavideo_staticdata
*csd
= CSD(cl
);
867 setspritevisible(csd
, msg
->visible
);
870 ULONG
AmigaVideoCl__Hidd_Gfx__MakeViewPort(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_MakeViewPort
*msg
)
872 D(struct HIDD_ViewPortData
*vpd
= msg
->Data
);
874 D(bug("AmigaVideoCl__Hidd_Gfx__MakeViewPort vp=%p bm=%p vpe=%p\n", vpd
->vpe
->ViewPort
, vpd
->Bitmap
, vpd
->vpe
));
875 /* TODO: implement this correctly */
879 void AmigaVideoCl__Hidd_Gfx__CleanViewPort(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Gfx_CleanViewPort
*msg
)
881 struct amigavideo_staticdata
*csd
= CSD(cl
);
882 struct Library
*GfxBase
= csd
->cs_GfxBase
;
883 struct HIDD_ViewPortData
*vpd
= msg
->Data
;
884 struct ViewPort
*vp
= vpd
->vpe
->ViewPort
;
886 D(bug("AmigaVideoCl__Hidd_Gfx__CleanViewPort vp=%p bm=%p vpe=%p\n", vpd
->vpe
->ViewPort
, vpd
->Bitmap
, vpd
->vpe
));
887 /* It's safe to call these functions on NULL pointers */
888 FreeCopList(vp
->ClrIns
);
889 FreeCopList(vp
->DspIns
);
890 FreeCopList(vp
->SprIns
);
894 FreeCopList(vp
->UCopIns
->FirstCopList
);
895 FreeMem(vp
->UCopIns
, sizeof(struct UCopList
));
898 /* Everything has been freed */
905 static void freeattrbases(struct amigavideo_staticdata
*csd
)
907 struct Library
*OOPBase
= csd
->cs_OOPBase
;
909 OOP_ReleaseAttrBase(IID_Hidd_BitMap
);
910 OOP_ReleaseAttrBase(IID_Hidd_PlanarBM
);
911 OOP_ReleaseAttrBase(IID_Hidd_AmigaVideoBitMap
);
912 OOP_ReleaseAttrBase(IID_Hidd_GC
);
913 OOP_ReleaseAttrBase(IID_Hidd_Sync
);
914 OOP_ReleaseAttrBase(IID_Hidd_Gfx
);
915 OOP_ReleaseAttrBase(IID_Hidd_PixFmt
);
916 OOP_ReleaseAttrBase(IID_Hidd_ColorMap
);
919 int Init_AmigaVideoClass(LIBBASETYPEPTR LIBBASE
)
921 struct amigavideo_staticdata
*csd
= &LIBBASE
->csd
;
922 struct Library
*OOPBase
= csd
->cs_OOPBase
;
924 D(bug("Init_AmigaVideoClass\n"));
925 __IHidd_BitMap
= OOP_ObtainAttrBase(IID_Hidd_BitMap
);
926 __IHidd_PlanarBM
= OOP_ObtainAttrBase(IID_Hidd_PlanarBM
);
927 __IHidd_AmigaVideoBitmap
= OOP_ObtainAttrBase(IID_Hidd_AmigaVideoBitMap
);
928 __IHidd_GC
= OOP_ObtainAttrBase(IID_Hidd_GC
);
929 __IHidd_Sync
= OOP_ObtainAttrBase(IID_Hidd_Sync
);
930 __IHidd_Gfx
= OOP_ObtainAttrBase(IID_Hidd_Gfx
);
931 __IHidd_PixFmt
= OOP_ObtainAttrBase(IID_Hidd_PixFmt
);
932 __IHidd_ColorMap
= OOP_ObtainAttrBase(IID_Hidd_ColorMap
);
934 if (!__IHidd_BitMap
|| !__IHidd_PlanarBM
|| !__IHidd_AmigaVideoBitmap
|| !__IHidd_GC
||
935 !__IHidd_Sync
|| !__IHidd_Gfx
|| !__IHidd_PixFmt
|| !__IHidd_ColorMap
)
937 D(bug("Init_AmigaVideoClass fail\n"));
945 static int Expunge_AmigaVideoClass(LIBBASETYPEPTR LIBBASE
)
947 struct amigavideo_staticdata
*csd
= &LIBBASE
->csd
;
948 D(bug("Expunge_AmigaVideoClass\n"));
953 ADD2EXPUNGELIB(Expunge_AmigaVideoClass
, 1)