From ba7bfc478e2e085d496b8110f7e42078ee4f803a Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Thu, 22 Apr 2004 22:54:47 +0000 Subject: [PATCH] Extend NativeOp count to 64 (6-bit value), aka fix NATIVE_FILLRECT opcpdes. Translate NQD_{bitblt,fillrect,invrect} to direct native calls. Use Mac2HostAddr() for converting Mac base address to native. --- SheepShaver/src/Unix/video_x.cpp | 12 ++++----- SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp | 27 +++++++++++++++----- SheepShaver/src/thunks.cpp | 12 ++++----- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/SheepShaver/src/Unix/video_x.cpp b/SheepShaver/src/Unix/video_x.cpp index da67d4cf..7681bde0 100644 --- a/SheepShaver/src/Unix/video_x.cpp +++ b/SheepShaver/src/Unix/video_x.cpp @@ -1696,7 +1696,7 @@ void NQD_invrect(uint32 p) // And perform the inversion const int bpp = bytes_per_pixel(ReadMacInt32(p + acclDestPixelSize)); const int dest_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); - uint8 *dest = (uint8 *)(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dest_row_bytes) + (dest_X * bpp)); + uint8 *dest = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dest_row_bytes) + (dest_X * bpp)); width *= bpp; switch (bpp) { case 1: @@ -1806,7 +1806,7 @@ void NQD_fillrect(uint32 p) // And perform the fill const int bpp = bytes_per_pixel(ReadMacInt32(p + acclDestPixelSize)); const int dest_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); - uint8 *dest = (uint8 *)(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dest_row_bytes) + (dest_X * bpp)); + uint8 *dest = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dest_row_bytes) + (dest_X * bpp)); width *= bpp; switch (bpp) { case 1: @@ -1874,8 +1874,8 @@ void NQD_bitblt(uint32 p) if ((int32)ReadMacInt32(p + acclSrcRowBytes) > 0) { const int src_row_bytes = (int32)ReadMacInt32(p + acclSrcRowBytes); const int dst_row_bytes = (int32)ReadMacInt32(p + acclDestRowBytes); - uint8 *src = (uint8 *)ReadMacInt32(p + acclSrcBaseAddr) + (src_Y * src_row_bytes) + (src_X * bpp); - uint8 *dst = (uint8 *)ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dst_row_bytes) + (dest_X * bpp); + uint8 *src = Mac2HostAddr(ReadMacInt32(p + acclSrcBaseAddr) + (src_Y * src_row_bytes) + (src_X * bpp)); + uint8 *dst = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + (dest_Y * dst_row_bytes) + (dest_X * bpp)); for (int i = 0; i < height; i++) { memcpy(dst, src, width); src += src_row_bytes; @@ -1885,8 +1885,8 @@ void NQD_bitblt(uint32 p) else { const int src_row_bytes = -(int32)ReadMacInt32(p + acclSrcRowBytes); const int dst_row_bytes = -(int32)ReadMacInt32(p + acclDestRowBytes); - uint8 *src = (uint8 *)ReadMacInt32(p + acclSrcBaseAddr) + ((src_Y + height - 1) * src_row_bytes) + (src_X * bpp); - uint8 *dst = (uint8 *)ReadMacInt32(p + acclDestBaseAddr) + ((dest_Y + height - 1) * dst_row_bytes) + (dest_X * bpp); + uint8 *src = Mac2HostAddr(ReadMacInt32(p + acclSrcBaseAddr) + ((src_Y + height - 1) * src_row_bytes) + (src_X * bpp)); + uint8 *dst = Mac2HostAddr(ReadMacInt32(p + acclDestBaseAddr) + ((dest_Y + height - 1) * dst_row_bytes) + (dest_X * bpp)); for (int i = height - 1; i >= 0; i--) { memcpy(dst, src, width); src -= src_row_bytes; diff --git a/SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp b/SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp index 4a96f222..ce84dd8e 100644 --- a/SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp +++ b/SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp @@ -225,14 +225,14 @@ void sheepshaver_cpu::init_decoder() static void NativeOp(int selector); /* NativeOp instruction format: - +------------+--------------------------+--+----------+------------+ - | 6 | |FN| OP | 2 | - +------------+--------------------------+--+----------+------------+ - 0 5 |6 19 20 21 25 26 31 + +------------+-------------------------+--+-----------+------------+ + | 6 | |FN| OP | 2 | + +------------+-------------------------+--+-----------+------------+ + 0 5 |6 18 19 20 25 26 31 */ -typedef bit_field< 20, 20 > FN_field; -typedef bit_field< 21, 25 > NATIVE_OP_field; +typedef bit_field< 19, 19 > FN_field; +typedef bit_field< 20, 25 > NATIVE_OP_field; typedef bit_field< 26, 31 > EMUL_OP_field; // Execute EMUL_OP routine @@ -362,6 +362,21 @@ bool sheepshaver_cpu::compile1(codegen_context_t & cg_context) dg.gen_invoke_T0_T1_T2((void (*)(uint32, uint32, uint32))check_load_invoc); compiled = true; break; + case NATIVE_BITBLT: + dg.gen_load_T0_GPR(3); + dg.gen_invoke_T0((void (*)(uint32))NQD_bitblt); + compiled = true; + break; + case NATIVE_INVRECT: + dg.gen_load_T0_GPR(3); + dg.gen_invoke_T0((void (*)(uint32))NQD_invrect); + compiled = true; + break; + case NATIVE_FILLRECT: + dg.gen_load_T0_GPR(3); + dg.gen_invoke_T0((void (*)(uint32))NQD_fillrect); + compiled = true; + break; } if (FN_field::test(opcode)) { if (compiled) { diff --git a/SheepShaver/src/thunks.cpp b/SheepShaver/src/thunks.cpp index 30aa2eab..af05e504 100644 --- a/SheepShaver/src/thunks.cpp +++ b/SheepShaver/src/thunks.cpp @@ -37,14 +37,14 @@ /* NativeOp instruction format: - +------------+--------------------------+--+----------+------------+ - | 6 | |FN| OP | 2 | - +------------+--------------------------+--+----------+------------+ - 0 5 |6 19 20 21 25 26 31 + +------------+-------------------------+--+-----------+------------+ + | 6 | |FN| OP | 2 | + +------------+-------------------------+--+-----------+------------+ + 0 5 |6 18 19 20 25 26 31 */ -#define POWERPC_NATIVE_OP(LR, OP) \ - (POWERPC_EMUL_OP | ((LR) << 11) | (((uint32)OP) << 6) | 2) +#define POWERPC_NATIVE_OP(FN, OP) \ + (POWERPC_EMUL_OP | ((FN) << 12) | (((uint32)OP) << 6) | 2) /* * Return the fake PowerPC opcode to handle specified native code