NQD dirty boxes, generic code

+ while we are at it, also rename a few NQD related NativeOps.
This commit is contained in:
gbeauche 2006-05-13 17:12:18 +00:00
parent 1470a8af13
commit 74a5024be4
6 changed files with 86 additions and 35 deletions

View File

@ -2549,3 +2549,13 @@ static void *redraw_func(void *arg)
}
return NULL;
}
/*
* Record dirty area from NQD
*/
void video_set_dirty_area(int x, int y, int w, int h)
{
// TBD
}

View File

@ -52,6 +52,18 @@ static inline int bytes_per_pixel(int depth)
return bpp;
}
// Pass-through dirty areas to redraw functions
static inline void NQD_set_dirty_area(uint32 p)
{
if (ReadMacInt32(p + acclDestBaseAddr) == screen_base) {
int16 x = (int16)ReadMacInt16(p + acclDestRect + 2) - (int16)ReadMacInt16(p + acclDestBoundsRect + 2);
int16 y = (int16)ReadMacInt16(p + acclDestRect + 0) - (int16)ReadMacInt16(p + acclDestBoundsRect + 0);
int16 w = (int16)ReadMacInt16(p + acclDestRect + 6) - (int16)ReadMacInt16(p + acclDestRect + 2);
int16 h = (int16)ReadMacInt16(p + acclDestRect + 4) - (int16)ReadMacInt16(p + acclDestRect + 0);
video_set_dirty_area(x, y, w, h);
}
}
/*
* Rectangle inversion
@ -282,18 +294,19 @@ void NQD_fillrect(uint32 p)
bool NQD_fillrect_hook(uint32 p)
{
D(bug("accl_fillrect_hook %08x\n", p));
NQD_set_dirty_area(p);
// Check if we can accelerate this fillrect
if (ReadMacInt32(p + 0x284) != 0 && ReadMacInt32(p + acclDestPixelSize) >= 8) {
const int transfer_mode = ReadMacInt32(p + acclTransferMode);
if (transfer_mode == 8) {
// Fill
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_FILLRECT));
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_NQD_FILLRECT));
return true;
}
else if (transfer_mode == 10) {
// Invert
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_INVRECT));
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_NQD_INVRECT));
return true;
}
}
@ -305,7 +318,6 @@ bool NQD_fillrect_hook(uint32 p)
* Isomorphic rectangle blitting
*/
// TODO: optimize for VOSF and target pixmap == screen
void NQD_bitblt(uint32 p)
{
D(bug("accl_bitblt %08x\n", p));
@ -372,6 +384,7 @@ void NQD_bitblt(uint32 p)
bool NQD_bitblt_hook(uint32 p)
{
D(bug("accl_draw_hook %08x\n", p));
NQD_set_dirty_area(p);
// Check if we can accelerate this bitblt
if (ReadMacInt32(p + 0x018) + ReadMacInt32(p + 0x128) == 0 &&
@ -383,12 +396,21 @@ bool NQD_bitblt_hook(uint32 p)
(int32)ReadMacInt32(p + 0x15c) > 0) {
// Yes, set function pointer
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_BITBLT));
WriteMacInt32(p + acclDrawProc, NativeTVECT(NATIVE_NQD_BITBLT));
return true;
}
return false;
}
// Unknown hook
bool NQD_unknown_hook(uint32 arg)
{
D(bug("accl_unknown_hook %08x\n", arg));
NQD_set_dirty_area(arg);
return false;
}
// Wait for graphics operation to finish
bool NQD_sync_hook(uint32 arg)
{
@ -410,16 +432,30 @@ void VideoInstallAccel(void)
SheepVar bitblt_hook_info(sizeof(accl_hook_info));
base = bitblt_hook_info.addr();
WriteMacInt32(base + 0, NativeTVECT(NATIVE_BITBLT_HOOK));
WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK));
WriteMacInt32(base + 0, NativeTVECT(NATIVE_NQD_BITBLT_HOOK));
WriteMacInt32(base + 4, NativeTVECT(NATIVE_NQD_SYNC_HOOK));
WriteMacInt32(base + 8, ACCL_BITBLT);
NQDMisc(6, bitblt_hook_info.addr());
SheepVar fillrect_hook_info(sizeof(accl_hook_info));
base = fillrect_hook_info.addr();
WriteMacInt32(base + 0, NativeTVECT(NATIVE_FILLRECT_HOOK));
WriteMacInt32(base + 4, NativeTVECT(NATIVE_SYNC_HOOK));
WriteMacInt32(base + 0, NativeTVECT(NATIVE_NQD_FILLRECT_HOOK));
WriteMacInt32(base + 4, NativeTVECT(NATIVE_NQD_SYNC_HOOK));
WriteMacInt32(base + 8, ACCL_FILLRECT);
NQDMisc(6, fillrect_hook_info.addr());
for (int op = 0; op < 8; op++) {
switch (op) {
case ACCL_BITBLT:
case ACCL_FILLRECT:
continue;
}
SheepVar unknown_hook_info(sizeof(accl_hook_info));
base = unknown_hook_info.addr();
WriteMacInt32(base + 0, NativeTVECT(NATIVE_NQD_UNKNOWN_HOOK));
WriteMacInt32(base + 4, NativeTVECT(NATIVE_NQD_SYNC_HOOK));
WriteMacInt32(base + 8, op);
NQDMisc(6, unknown_hook_info.addr());
}
}
}

View File

@ -57,12 +57,13 @@ enum {
NATIVE_R_GET_RESOURCE,
NATIVE_MAKE_EXECUTABLE,
NATIVE_CHECK_LOAD_INVOC,
NATIVE_SYNC_HOOK,
NATIVE_BITBLT_HOOK,
NATIVE_FILLRECT_HOOK,
NATIVE_BITBLT,
NATIVE_INVRECT,
NATIVE_FILLRECT,
NATIVE_NQD_SYNC_HOOK,
NATIVE_NQD_BITBLT_HOOK,
NATIVE_NQD_FILLRECT_HOOK,
NATIVE_NQD_UNKNOWN_HOOK,
NATIVE_NQD_BITBLT,
NATIVE_NQD_INVRECT,
NATIVE_NQD_FILLRECT,
NATIVE_NAMED_CHECK_LOAD_INVOC,
NATIVE_GET_NAMED_RESOURCE,
NATIVE_GET_1_NAMED_RESOURCE,

View File

@ -139,6 +139,7 @@ extern void video_set_palette(void);
extern void video_set_cursor(void);
extern bool video_can_change_cursor(void);
extern int16 video_mode_change(VidLocals *csSave, uint32 ParamPtr);
extern void video_set_dirty_area(int x, int y, int w, int h);
extern int16 VSLDoInterruptService(uint32 arg1);
extern void NQDMisc(uint32 arg1, uintptr arg2);
@ -147,6 +148,7 @@ extern void NQDMisc(uint32 arg1, uintptr arg2);
extern bool NQD_sync_hook(uint32);
extern bool NQD_bitblt_hook(uint32);
extern bool NQD_fillrect_hook(uint32);
extern bool NQD_unknown_hook(uint32);
extern void NQD_bitblt(uint32);
extern void NQD_invrect(uint32);
extern void NQD_fillrect(uint32);

View File

@ -352,17 +352,17 @@ int sheepshaver_cpu::compile1(codegen_context_t & cg_context)
status = COMPILE_CODE_OK;
break;
#endif
case NATIVE_BITBLT:
case NATIVE_NQD_BITBLT:
dg.gen_load_T0_GPR(3);
dg.gen_invoke_T0((void (*)(uint32))NQD_bitblt);
status = COMPILE_CODE_OK;
break;
case NATIVE_INVRECT:
case NATIVE_NQD_INVRECT:
dg.gen_load_T0_GPR(3);
dg.gen_invoke_T0((void (*)(uint32))NQD_invrect);
status = COMPILE_CODE_OK;
break;
case NATIVE_FILLRECT:
case NATIVE_NQD_FILLRECT:
dg.gen_load_T0_GPR(3);
dg.gen_invoke_T0((void (*)(uint32))NQD_fillrect);
status = COMPILE_CODE_OK;
@ -1033,22 +1033,22 @@ void sheepshaver_cpu::execute_native_op(uint32 selector)
case NATIVE_ETHER_RSRV:
gpr(3) = ether_rsrv((queue_t *)gpr(3));
break;
case NATIVE_SYNC_HOOK:
case NATIVE_NQD_SYNC_HOOK:
gpr(3) = NQD_sync_hook(gpr(3));
break;
case NATIVE_BITBLT_HOOK:
case NATIVE_NQD_BITBLT_HOOK:
gpr(3) = NQD_bitblt_hook(gpr(3));
break;
case NATIVE_BITBLT:
case NATIVE_NQD_BITBLT:
NQD_bitblt(gpr(3));
break;
case NATIVE_FILLRECT_HOOK:
case NATIVE_NQD_FILLRECT_HOOK:
gpr(3) = NQD_fillrect_hook(gpr(3));
break;
case NATIVE_INVRECT:
case NATIVE_NQD_INVRECT:
NQD_invrect(gpr(3));
break;
case NATIVE_FILLRECT:
case NATIVE_NQD_FILLRECT:
NQD_fillrect(gpr(3));
break;
case NATIVE_SERIAL_NOTHING:

View File

@ -89,12 +89,13 @@ uint32 NativeOpcode(int selector)
case NATIVE_GET_NAMED_RESOURCE:
case NATIVE_GET_1_NAMED_RESOURCE:
case NATIVE_MAKE_EXECUTABLE:
case NATIVE_SYNC_HOOK:
case NATIVE_BITBLT_HOOK:
case NATIVE_FILLRECT_HOOK:
case NATIVE_BITBLT:
case NATIVE_INVRECT:
case NATIVE_FILLRECT:
case NATIVE_NQD_SYNC_HOOK:
case NATIVE_NQD_BITBLT_HOOK:
case NATIVE_NQD_FILLRECT_HOOK:
case NATIVE_NQD_UNKNOWN_HOOK:
case NATIVE_NQD_BITBLT:
case NATIVE_NQD_INVRECT:
case NATIVE_NQD_FILLRECT:
opcode = POWERPC_NATIVE_OP(1, selector);
break;
default:
@ -319,12 +320,13 @@ bool ThunksInit(void)
DEFINE_NATIVE_OP(NATIVE_SERIAL_STATUS, SerialStatus);
DEFINE_NATIVE_OP(NATIVE_SERIAL_CLOSE, SerialClose);
DEFINE_NATIVE_OP(NATIVE_MAKE_EXECUTABLE, MakeExecutable);
DEFINE_NATIVE_OP(NATIVE_SYNC_HOOK, NQD_sync_hook);
DEFINE_NATIVE_OP(NATIVE_BITBLT_HOOK, NQD_bitblt_hook);
DEFINE_NATIVE_OP(NATIVE_FILLRECT_HOOK, NQD_fillrect_hook);
DEFINE_NATIVE_OP(NATIVE_BITBLT, NQD_bitblt);
DEFINE_NATIVE_OP(NATIVE_INVRECT, NQD_invrect);
DEFINE_NATIVE_OP(NATIVE_FILLRECT, NQD_fillrect);
DEFINE_NATIVE_OP(NATIVE_NQD_SYNC_HOOK, NQD_sync_hook);
DEFINE_NATIVE_OP(NATIVE_NQD_BITBLT_HOOK, NQD_bitblt_hook);
DEFINE_NATIVE_OP(NATIVE_NQD_FILLRECT_HOOK, NQD_fillrect_hook);
DEFINE_NATIVE_OP(NATIVE_NQD_UNKNOWN_HOOK, NQD_unknown_hook);
DEFINE_NATIVE_OP(NATIVE_NQD_BITBLT, NQD_bitblt);
DEFINE_NATIVE_OP(NATIVE_NQD_INVRECT, NQD_invrect);
DEFINE_NATIVE_OP(NATIVE_NQD_FILLRECT, NQD_fillrect);
#undef DEFINE_NATIVE_OP
#endif