summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/topcat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/video/topcat.cpp')
-rw-r--r--src/devices/video/topcat.cpp112
1 files changed, 72 insertions, 40 deletions
diff --git a/src/devices/video/topcat.cpp b/src/devices/video/topcat.cpp
index d4f4188623e..f1e9f6c5399 100644
--- a/src/devices/video/topcat.cpp
+++ b/src/devices/video/topcat.cpp
@@ -35,7 +35,7 @@ void topcat_device::device_start()
save_item(NAME(m_fb_write_enable));
save_item(NAME(m_enable_blink_planes));
save_item(NAME(m_enable_alt_frame));
- save_item(NAME(m_cursor_ctrl));
+ save_item(NAME(m_cursor_plane_enable));
save_item(NAME(m_move_replacement_rule));
save_item(NAME(m_pixel_replacement_rule));
save_item(NAME(m_source_x_pixel));
@@ -83,30 +83,33 @@ WRITE16_MEMBER(topcat_device::vram_w)
modify_vram_offset(offset * 2, (data & m_plane_mask << 8));
}
+void topcat_device::get_cursor_pos(int *startx, int *starty, int *endx, int *endy)
+{
+ if (m_cursor_state && ((m_cursor_plane_enable >> 8) & m_plane_mask)) {
+ *startx = m_cursor_x_pos;
+ *starty = m_cursor_y_pos;
+ *endx = m_cursor_x_pos + m_cursor_width;
+ *endy = m_cursor_y_pos;
+
+ } else {
+ *startx = 0;
+ *starty = 0;
+ *endx = 0;
+ *endy = 0;
+ }
+}
+
TIMER_CALLBACK_MEMBER(topcat_device::cursor_callback)
{
m_cursor_timer->adjust(attotime::from_hz(5));
m_cursor_state ^= true;
-
- if (m_cursor_ctrl & m_plane_mask) {
- for(int i = 0; i < m_cursor_width; i++) {
- modify_vram(m_cursor_x_pos+i, m_cursor_y_pos, m_cursor_state);
- modify_vram(m_cursor_x_pos+i, m_cursor_y_pos-1, m_cursor_state);
- modify_vram(m_cursor_x_pos+i, m_cursor_y_pos-2, m_cursor_state);
- }
- }
}
-void topcat_device::update_cursor(int x, int y, uint8_t ctrl, uint8_t width)
+void topcat_device::update_cursor(int x, int y, uint16_t ctrl, uint8_t width)
{
- for(int i = 0; i < m_cursor_width; i++) {
- modify_vram(m_cursor_x_pos+i, m_cursor_y_pos, false);
- modify_vram(m_cursor_x_pos+i, m_cursor_y_pos-1, false);
- modify_vram(m_cursor_x_pos+i, m_cursor_y_pos-2, false);
- }
m_cursor_x_pos = (std::min)(x, m_fb_width - m_cursor_width);
m_cursor_y_pos = (std::max)((std::min)(y, m_fb_height), 2);
- m_cursor_ctrl = ctrl;
+ m_cursor_plane_enable = ctrl;
m_cursor_width = width;
}
@@ -166,16 +169,52 @@ void topcat_device::execute_rule(bool src, replacement_rule_t rule, bool &dst)
void topcat_device::window_move(void)
{
- if (!m_fb_write_enable)
+ int line, endline, lineincr;
+ int startcolumn, endcolumn, columnincr;
+
+ if (!((m_fb_write_enable >> 8) & m_plane_mask))
return;
- for(int line = 0; line < m_block_mover_pixel_height; line++) {
- for(int column = 0; column < m_block_mover_pixel_width; column++) {
+ LOG("WINDOWMOVE: %3ux%3u -> %3ux%3u / %3ux%3u rule %x\n",
+ m_source_x_pixel,
+ m_source_y_pixel,
+ m_dst_x_pixel,
+ m_dst_y_pixel,
+ m_block_mover_pixel_width,
+ m_block_mover_pixel_height,
+ m_move_replacement_rule);
+
+ if (m_dst_y_pixel > m_source_y_pixel) {
+ /* move down */
+ line = m_block_mover_pixel_height-1;
+ endline = -1;
+ lineincr = -1;
+ } else {
+ /* move up */
+ line = 0;
+ endline = m_block_mover_pixel_height;
+ lineincr = 1;
+ }
+
+ if (m_dst_x_pixel > m_source_x_pixel) {
+ /* move right */
+ startcolumn = m_block_mover_pixel_width-1;
+ endcolumn = -1;
+ columnincr = -1;
+ } else {
+ /* move left */
+ startcolumn = 0;
+ endcolumn = m_block_mover_pixel_width;
+ columnincr = 1;
+
+ }
+
+ for(;line != endline; line += lineincr) {
+ for(int column = startcolumn; column != endcolumn; column += columnincr) {
bool src = get_vram_pixel(m_source_x_pixel + column,
m_source_y_pixel + line);
bool dst = get_vram_pixel(m_dst_x_pixel + column,
m_dst_y_pixel + line);
-// execute_rule(src, (replacement_rule_t)((m_move_replacement_rule >> 4) & 0x0f), &dst);
execute_rule(src, (replacement_rule_t)(m_move_replacement_rule & 0x0f), dst);
modify_vram(m_dst_x_pixel + column, m_dst_y_pixel + line, dst);
}
@@ -184,7 +223,6 @@ void topcat_device::window_move(void)
READ16_MEMBER(topcat_device::ctrl_r)
{
-
uint16_t ret = 0xffff;
if (!m_read_enable)
@@ -224,8 +262,8 @@ READ16_MEMBER(topcat_device::ctrl_r)
case TOPCAT_REG_ENABLE_ALT_FRAME:
ret = m_enable_alt_frame;
break;
- case TOPCAT_REG_CURSOR_CNTL:
- ret = m_cursor_ctrl;
+ case TOPCAT_REG_CURSOR_PLANE_ENABLE:
+ ret = m_cursor_plane_enable;
break;
case TOPCAT_REG_PIXEL_REPLACE_RULE:
ret = m_pixel_replacement_rule;
@@ -260,27 +298,21 @@ READ16_MEMBER(topcat_device::ctrl_r)
WRITE16_MEMBER(topcat_device::ctrl_w)
{
- if (mem_mask == 0xff00)
- data >>= 8;
- if (mem_mask == 0x00ff) {
- logerror("%s: write ignored: %d\n", __FUNCTION__, offset);
- return;
- }
+ data &= mem_mask;
- if (offset == TOPCAT_REG_WRITE_ENABLE_PLANE && ((mem_mask & 0xff) == 0xff)) {
- m_write_enable = !(data & m_plane_mask);
+ if (offset == TOPCAT_REG_WRITE_ENABLE_PLANE) {
+ m_write_enable = (data >> 8) & m_plane_mask;
return;
}
if (offset == TOPCAT_REG_READ_ENABLE_PLANE) {
- m_read_enable = !(data & m_plane_mask);
+ m_read_enable = (data >> 8) & m_plane_mask;
return;
}
- if (!m_write_enable) {
+ if (!m_write_enable)
return;
- }
switch(offset) {
case TOPCAT_REG_VBLANK:
@@ -298,8 +330,9 @@ WRITE16_MEMBER(topcat_device::ctrl_w)
m_display_enable_planes = data;
break;
case TOPCAT_REG_FB_WRITE_ENABLE:
- m_fb_write_enable = data & m_plane_mask;
+ m_fb_write_enable = data;
break;
+
case TOPCAT_REG_START_WMOVE:
window_move();
break;
@@ -313,7 +346,6 @@ WRITE16_MEMBER(topcat_device::ctrl_w)
m_pixel_replacement_rule = data;
break;
case TOPCAT_REG_MOVE_REPLACE_RULE:
-
m_move_replacement_rule = data;
break;
case TOPCAT_REG_SOURCE_X_PIXEL:
@@ -334,17 +366,17 @@ WRITE16_MEMBER(topcat_device::ctrl_w)
case TOPCAT_REG_BLOCK_MOVER_PIXEL_HEIGHT:
m_block_mover_pixel_height = data;
break;
- case TOPCAT_REG_CURSOR_CNTL:
+ case TOPCAT_REG_CURSOR_PLANE_ENABLE:
update_cursor(m_cursor_x_pos, m_cursor_y_pos, data, m_cursor_width);
break;
case TOPCAT_REG_CURSOR_X_POS:
- update_cursor(data, m_cursor_y_pos, m_cursor_ctrl, m_cursor_width);
+ update_cursor(data, m_cursor_y_pos, m_cursor_plane_enable, m_cursor_width);
break;
case TOPCAT_REG_CURSOR_Y_POS:
- update_cursor(m_cursor_x_pos, data, m_cursor_ctrl, m_cursor_width);
+ update_cursor(m_cursor_x_pos, data, m_cursor_plane_enable, m_cursor_width);
break;
case TOPCAT_REG_CURSOR_WIDTH:
- update_cursor(m_cursor_x_pos, m_cursor_y_pos, m_cursor_ctrl, data);
+ update_cursor(m_cursor_x_pos, m_cursor_y_pos, m_cursor_plane_enable, data);
break;
default:
logerror("unknown register: %02X = %04x\n", offset, data, mem_mask);