mirror of
https://github.com/holub/mame
synced 2025-06-30 16:00:01 +03:00
tms34020: implement CLIP opcode (#5716)
* tms34020: Fix out of bounds read, when extra logging is enabled * tms34020: Annotate unimplemented clip opcode * tms34020: Implement CLIP instruction
This commit is contained in:
parent
4bbabbde2d
commit
290dad6ea1
@ -2107,7 +2107,60 @@ void tms340x0_device::cexec_s(uint16_t op)
|
|||||||
void tms340x0_device::clip(uint16_t op)
|
void tms340x0_device::clip(uint16_t op)
|
||||||
{
|
{
|
||||||
if (!m_is_34020) { unimpl(op); return; }
|
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)
|
void tms340x0_device::cmovcg_a(uint16_t op)
|
||||||
|
@ -187,10 +187,13 @@ device_memory_interface::space_config_vector tms340x0_device::memory_space_confi
|
|||||||
#define OFFSET() BREG(4)
|
#define OFFSET() BREG(4)
|
||||||
#define WSTART_X() BREG_X(5)
|
#define WSTART_X() BREG_X(5)
|
||||||
#define WSTART_Y() BREG_Y(5)
|
#define WSTART_Y() BREG_Y(5)
|
||||||
|
#define WSTART_XY() BREG_XY(5)
|
||||||
#define WEND_X() BREG_X(6)
|
#define WEND_X() BREG_X(6)
|
||||||
#define WEND_Y() BREG_Y(6)
|
#define WEND_Y() BREG_Y(6)
|
||||||
|
#define WEND_XY() BREG_XY(6)
|
||||||
#define DYDX_X() BREG_X(7)
|
#define DYDX_X() BREG_X(7)
|
||||||
#define DYDX_Y() BREG_Y(7)
|
#define DYDX_Y() BREG_Y(7)
|
||||||
|
#define DYDX_XY() BREG_XY(7)
|
||||||
#define COLOR0() BREG(8)
|
#define COLOR0() BREG(8)
|
||||||
#define COLOR1() BREG(9)
|
#define COLOR1() BREG(9)
|
||||||
#define COUNT() BREG(10)
|
#define COUNT() BREG(10)
|
||||||
@ -1496,7 +1499,7 @@ u16 tms34020_device::io_register_r(offs_t offset)
|
|||||||
{
|
{
|
||||||
int result, total;
|
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)
|
switch (offset)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user