diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/devices/cpu/tms34010/34010ops.hxx | 55 | ||||
-rw-r--r-- | src/devices/cpu/tms34010/tms34010.cpp | 5 |
2 files changed, 58 insertions, 2 deletions
diff --git a/src/devices/cpu/tms34010/34010ops.hxx b/src/devices/cpu/tms34010/34010ops.hxx index 3466b03d0d9..e315b81d51e 100644 --- a/src/devices/cpu/tms34010/34010ops.hxx +++ b/src/devices/cpu/tms34010/34010ops.hxx @@ -2107,7 +2107,60 @@ void tms340x0_device::cexec_s(uint16_t op) void tms340x0_device::clip(uint16_t op) { if (!m_is_34020) { unimpl(op); return; } - logerror("020:clip\n"); + XY daddr = DADDR_XY(); + XY wstart = WSTART_XY(); + XY wend = WEND_XY(); + XY dydx = DYDX_XY(); + // logerror("020:clip PC=0x%08x: WSTART=(%dx%d) WEND=(%dx%d) DADDR=(%dx%d) DYDX=(%dx%d)\n", + // m_pc, wstart.x, wstart.y, wend.x, wend.y, daddr.x, daddr.y, dydx.x, dydx.y); + + // Check whether array intersects with window... + bool is_l = wstart.x < (daddr.x + dydx.x); + bool is_r = wend.x > daddr.x; + bool is_t = wstart.y < (daddr.y + dydx.y); + bool is_b = wend.y > daddr.y; + if (!(is_l || is_r || is_t || is_b)) + { + // ...no itersection, set flags and return + m_st |= STBIT_Z | STBIT_V; + // TODO: manual does not specify cycles, only states that this is complex instruction + COUNT_CYCLES(3); + return; + } + + CLR_V(); + CLR_Z(); + + // Handle clipping if needed + bool array_clipped = false; + + if (wstart.x > daddr.x) + { + DADDR_X() = wstart.x; + array_clipped = true; + } + if (wend.x < (daddr.x + dydx.x - 1)) + { + DYDX_X() = wend.x - daddr.x; + array_clipped = true; + } + + if (wstart.y > daddr.y) + { + DADDR_Y() = wstart.y; + array_clipped = true; + } + if (wend.y < (daddr.y + dydx.y - 1)) + { + DYDX_Y() = wend.y - daddr.y; + array_clipped = true; + } + + if (array_clipped) + m_st |= STBIT_V; + + // TODO: manual does not specify cycles, only states that this is complex instruction + COUNT_CYCLES(3); } void tms340x0_device::cmovcg_a(uint16_t op) diff --git a/src/devices/cpu/tms34010/tms34010.cpp b/src/devices/cpu/tms34010/tms34010.cpp index 79e9cf42fb6..7b2bc7d30ba 100644 --- a/src/devices/cpu/tms34010/tms34010.cpp +++ b/src/devices/cpu/tms34010/tms34010.cpp @@ -187,10 +187,13 @@ device_memory_interface::space_config_vector tms340x0_device::memory_space_confi #define OFFSET() BREG(4) #define WSTART_X() BREG_X(5) #define WSTART_Y() BREG_Y(5) +#define WSTART_XY() BREG_XY(5) #define WEND_X() BREG_X(6) #define WEND_Y() BREG_Y(6) +#define WEND_XY() BREG_XY(6) #define DYDX_X() BREG_X(7) #define DYDX_Y() BREG_Y(7) +#define DYDX_XY() BREG_XY(7) #define COLOR0() BREG(8) #define COLOR1() BREG(9) #define COUNT() BREG(10) @@ -1496,7 +1499,7 @@ u16 tms34020_device::io_register_r(offs_t offset) { int result, total; - LOGCONTROLREGS("%s: read %s\n", machine().describe_context(), ioreg_name[offset]); + LOGCONTROLREGS("%s: read %s\n", machine().describe_context(), ioreg020_name[offset]); switch (offset) { |