1 |
|
/* |
2 |
|
* gfxaccel.cpp - Generic Native QuickDraw acceleration |
3 |
|
* |
4 |
< |
* SheepShaver (C) 1997-2004 Marc Hellwig and Christian Bauer |
4 |
> |
* SheepShaver (C) 1997-2008 Marc Hellwig and Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
52 |
|
return bpp; |
53 |
|
} |
54 |
|
|
55 |
+ |
// Pass-through dirty areas to redraw functions |
56 |
+ |
static inline void NQD_set_dirty_area(uint32 p) |
57 |
+ |
{ |
58 |
+ |
if (ReadMacInt32(p + acclDestBaseAddr) == screen_base) { |
59 |
+ |
int16 x = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2); |
60 |
+ |
int16 y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0); |
61 |
+ |
int16 w = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2); |
62 |
+ |
int16 h = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0); |
63 |
+ |
video_set_dirty_area(x, y, w, h); |
64 |
+ |
} |
65 |
+ |
} |
66 |
+ |
|
67 |
|
|
68 |
|
/* |
69 |
|
* Rectangle inversion |
294 |
|
bool NQD_fillrect_hook(uint32 p) |
295 |
|
{ |
296 |
|
D(bug("accl_fillrect_hook %08x\n", p)); |
297 |
+ |
NQD_set_dirty_area(p); |
298 |
|
|
299 |
|
// Check if we can accelerate this fillrect |
300 |
|
if (ReadMacInt32(p + 0x284) != 0 && ReadMacInt32(p + acclDestPixelSize) >= 8) { |
301 |
|
const int transfer_mode = ReadMacInt32(p + acclTransferMode); |
302 |
|
if (transfer_mode == 8) { |
303 |
|
// Fill |
304 |
< |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_FILLRECT)); |
304 |
> |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_NQD_FILLRECT)); |
305 |
|
return true; |
306 |
|
} |
307 |
|
else if (transfer_mode == 10) { |
308 |
|
// Invert |
309 |
< |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_INVRECT)); |
309 |
> |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_NQD_INVRECT)); |
310 |
|
return true; |
311 |
|
} |
312 |
|
} |
318 |
|
* Isomorphic rectangle blitting |
319 |
|
*/ |
320 |
|
|
308 |
– |
// TODO: optimize for VOSF and target pixmap == screen |
321 |
|
void NQD_bitblt(uint32 p) |
322 |
|
{ |
323 |
|
D(bug("accl_bitblt %08x\n", p)); |
384 |
|
bool NQD_bitblt_hook(uint32 p) |
385 |
|
{ |
386 |
|
D(bug("accl_draw_hook %08x\n", p)); |
387 |
+ |
NQD_set_dirty_area(p); |
388 |
|
|
389 |
|
// Check if we can accelerate this bitblt |
390 |
|
if (ReadMacInt32(p + 0x018) + ReadMacInt32(p + 0x128) == 0 && |
391 |
|
ReadMacInt32(p + 0x130) == 0 && |
392 |
|
ReadMacInt32(p + acclSrcPixelSize) >= 8 && |
393 |
|
ReadMacInt32(p + acclSrcPixelSize) == ReadMacInt32(p + acclDestPixelSize) && |
394 |
< |
(ReadMacInt32(p + acclSrcRowBytes) ^ ReadMacInt32(p + acclDestRowBytes)) >= 0 && // same sign? |
395 |
< |
ReadMacInt32(p + acclTransferMode) == 0 && // srcCopy? |
396 |
< |
ReadMacInt32(p + 0x15c) > 0) { |
394 |
> |
(int32)(ReadMacInt32(p + acclSrcRowBytes) ^ ReadMacInt32(p + acclDestRowBytes)) >= 0 && // same sign? |
395 |
> |
ReadMacInt32(p + acclTransferMode) == 0 && // srcCopy? |
396 |
> |
(int32)ReadMacInt32(p + 0x15c) > 0) { |
397 |
|
|
398 |
|
// Yes, set function pointer |
399 |
< |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_BITBLT)); |
399 |
> |
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_NQD_BITBLT)); |
400 |
|
return true; |
401 |
|
} |
402 |
|
return false; |
403 |
|
} |
404 |
|
|
405 |
+ |
// Unknown hook |
406 |
+ |
bool NQD_unknown_hook(uint32 arg) |
407 |
+ |
{ |
408 |
+ |
D(bug("accl_unknown_hook %08x\n", arg)); |
409 |
+ |
NQD_set_dirty_area(arg); |
410 |
+ |
|
411 |
+ |
return false; |
412 |
+ |
} |
413 |
+ |
|
414 |
|
// Wait for graphics operation to finish |
415 |
|
bool NQD_sync_hook(uint32 arg) |
416 |
|
{ |
432 |
|
|
433 |
|
SheepVar bitblt_hook_info(sizeof(accl_hook_info)); |
434 |
|
base = bitblt_hook_info.addr(); |
435 |
< |
WriteMacInt32(base + 0, NativeTVECT(NATIVE_BITBLT_HOOK)); |
436 |
< |
WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK)); |
435 |
> |
WriteMacInt32(base + 0, NativeTVECT(NATIVE_NQD_BITBLT_HOOK)); |
436 |
> |
WriteMacInt32(base + 4, NativeTVECT(NATIVE_NQD_SYNC_HOOK)); |
437 |
|
WriteMacInt32(base + 8, ACCL_BITBLT); |
438 |
|
NQDMisc(6, bitblt_hook_info.addr()); |
439 |
|
|
440 |
|
SheepVar fillrect_hook_info(sizeof(accl_hook_info)); |
441 |
|
base = fillrect_hook_info.addr(); |
442 |
< |
WriteMacInt32(base + 0, NativeTVECT(NATIVE_FILLRECT_HOOK)); |
443 |
< |
WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK)); |
442 |
> |
WriteMacInt32(base + 0, NativeTVECT(NATIVE_NQD_FILLRECT_HOOK)); |
443 |
> |
WriteMacInt32(base + 4, NativeTVECT(NATIVE_NQD_SYNC_HOOK)); |
444 |
|
WriteMacInt32(base + 8, ACCL_FILLRECT); |
445 |
|
NQDMisc(6, fillrect_hook_info.addr()); |
446 |
+ |
|
447 |
+ |
for (int op = 0; op < 8; op++) { |
448 |
+ |
switch (op) { |
449 |
+ |
case ACCL_BITBLT: |
450 |
+ |
case ACCL_FILLRECT: |
451 |
+ |
continue; |
452 |
+ |
} |
453 |
+ |
SheepVar unknown_hook_info(sizeof(accl_hook_info)); |
454 |
+ |
base = unknown_hook_info.addr(); |
455 |
+ |
WriteMacInt32(base + 0, NativeTVECT(NATIVE_NQD_UNKNOWN_HOOK)); |
456 |
+ |
WriteMacInt32(base + 4, NativeTVECT(NATIVE_NQD_SYNC_HOOK)); |
457 |
+ |
WriteMacInt32(base + 8, op); |
458 |
+ |
NQDMisc(6, unknown_hook_info.addr()); |
459 |
+ |
} |
460 |
|
} |
461 |
|
} |