From: Toni Wilen Date: Mon, 10 Jul 2023 09:26:57 +0000 (+0300) Subject: TMS34010 plane masking update X-Git-Tag: 5.1.0~153 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=f2cc4ab29742e19cdb4e2e8fa6e548d1fce7d4d4;p=francis%2Fwinuae.git TMS34010 plane masking update --- diff --git a/mame/tm34010/34010gfx.c b/mame/tm34010/34010gfx.c index d650cfaf..a350be0e 100644 --- a/mame/tm34010/34010gfx.c +++ b/mame/tm34010/34010gfx.c @@ -1046,6 +1046,7 @@ void FUNCTION_NAME(tms340x0_device::pixblt)(int src_is_linear, int dst_is_linear /* fetch the initial source word */ srcword = (this->*word_read)(*m_program, srcwordaddr++ << 1); + srcword &= m_plane_mask_inv; readwrites++; /* fetch the initial dest word */ @@ -1065,6 +1066,7 @@ void FUNCTION_NAME(tms340x0_device::pixblt)(int src_is_linear, int dst_is_linear if (srcbit + BITS_PER_PIXEL > 16) { srcword |= (this->*word_read)(*m_program, srcwordaddr++ << 1) << 16; + srcword &= m_plane_mask_inv; readwrites++; } @@ -1096,7 +1098,7 @@ void FUNCTION_NAME(tms340x0_device::pixblt)(int src_is_linear, int dst_is_linear dstbit += BITS_PER_PIXEL; if (dstbit > 16) { - if (m_plane_masking) dstword = do_plane_masking((this->*word_read)(*m_program, dstwordaddr << 1), dstword); + if (m_plane_mask) dstword = do_plane_masking((this->*word_read)(*m_program, dstwordaddr << 1), dstword); (this->*word_write)(*m_program, dstwordaddr++ << 1, dstword); readwrites++; dstbit -= 16; @@ -1116,7 +1118,7 @@ void FUNCTION_NAME(tms340x0_device::pixblt)(int src_is_linear, int dst_is_linear readwrites++; } - if (m_plane_masking) dstword = do_plane_masking((this->*word_read)(*m_program, dstwordaddr << 1), dstword); + if (m_plane_mask) dstword = do_plane_masking((this->*word_read)(*m_program, dstwordaddr << 1), dstword); (this->*word_write)(*m_program, dstwordaddr++ << 1, dstword); readwrites++; } @@ -1419,6 +1421,7 @@ if ((daddr & (BITS_PER_PIXEL - 1)) != 0) osd_printf_debug("PIXBLT_R%d with odd d /* fetch the initial source word */ srcword = (this->*word_read)(*m_program, --swordaddr << 1); + srcword &= m_plane_mask_inv; srcmask = PIXEL_MASK << ((saddr - BITS_PER_PIXEL) & 15); /* handle the right partial word */ @@ -1435,6 +1438,7 @@ if ((daddr & (BITS_PER_PIXEL - 1)) != 0) osd_printf_debug("PIXBLT_R%d with odd d if (srcmask == 0) { srcword = (this->*word_read)(*m_program, --swordaddr << 1); + srcword &= m_plane_mask_inv; srcmask = PIXEL_MASK << (16 - BITS_PER_PIXEL); } @@ -1461,7 +1465,7 @@ if ((daddr & (BITS_PER_PIXEL - 1)) != 0) osd_printf_debug("PIXBLT_R%d with odd d } /* write the result */ - if (m_plane_masking) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); + if (m_plane_mask) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); (this->*word_write)(*m_program, dwordaddr << 1, dstword); } @@ -1483,6 +1487,7 @@ if ((daddr & (BITS_PER_PIXEL - 1)) != 0) osd_printf_debug("PIXBLT_R%d with odd d if (srcmask == 0) { srcword = (this->*word_read)(*m_program, --swordaddr << 1); + srcword &= m_plane_mask_inv; srcmask = PIXEL_MASK << (16 - BITS_PER_PIXEL); } @@ -1509,7 +1514,7 @@ if ((daddr & (BITS_PER_PIXEL - 1)) != 0) osd_printf_debug("PIXBLT_R%d with odd d } /* write the result */ - if (m_plane_masking) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); + if (m_plane_mask) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); (this->*word_write)(*m_program, dwordaddr << 1, dstword); } @@ -1527,6 +1532,7 @@ if ((daddr & (BITS_PER_PIXEL - 1)) != 0) osd_printf_debug("PIXBLT_R%d with odd d if (srcmask == 0) { srcword = (this->*word_read)(*m_program, --swordaddr << 1); + srcword &= m_plane_mask_inv; srcmask = PIXEL_MASK << (16 - BITS_PER_PIXEL); } @@ -1553,7 +1559,7 @@ if ((daddr & (BITS_PER_PIXEL - 1)) != 0) osd_printf_debug("PIXBLT_R%d with odd d } /* write the result */ - if (m_plane_masking) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); + if (m_plane_mask) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); (this->*word_write)(*m_program, dwordaddr << 1, dstword); } @@ -1680,6 +1686,7 @@ void FUNCTION_NAME(tms340x0_device::pixblt_b)(int dst_is_linear) /* fetch the initial source word */ srcword = (this->*word_read)(*m_program, swordaddr++ << 1); + srcword &= m_plane_mask_inv; srcmask = 1 << (saddr & 15); /* handle the left partial word */ @@ -1704,6 +1711,7 @@ void FUNCTION_NAME(tms340x0_device::pixblt_b)(int dst_is_linear) if (srcmask == 0) { srcword = (this->*word_read)(*m_program, swordaddr++ << 1); + srcword &= m_plane_mask_inv; srcmask = 0x0001; } @@ -1712,7 +1720,7 @@ void FUNCTION_NAME(tms340x0_device::pixblt_b)(int dst_is_linear) } /* write the result */ - if (m_plane_masking) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); + if (m_plane_mask) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); (this->*word_write)(*m_program, dwordaddr++ << 1, dstword); } @@ -1741,6 +1749,7 @@ void FUNCTION_NAME(tms340x0_device::pixblt_b)(int dst_is_linear) if (srcmask == 0) { srcword = (this->*word_read)(*m_program, swordaddr++ << 1); + srcword &= m_plane_mask_inv; srcmask = 0x0001; } @@ -1749,7 +1758,7 @@ void FUNCTION_NAME(tms340x0_device::pixblt_b)(int dst_is_linear) } /* write the result */ - if (m_plane_masking) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); + if (m_plane_mask) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); (this->*word_write)(*m_program, dwordaddr++ << 1, dstword); } @@ -1775,6 +1784,7 @@ void FUNCTION_NAME(tms340x0_device::pixblt_b)(int dst_is_linear) if (srcmask == 0) { srcword = (this->*word_read)(*m_program, swordaddr++ << 1); + srcword &= m_plane_mask_inv; srcmask = 0x0001; } @@ -1783,7 +1793,7 @@ void FUNCTION_NAME(tms340x0_device::pixblt_b)(int dst_is_linear) } /* write the result */ - if (m_plane_masking) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); + if (m_plane_mask) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); (this->*word_write)(*m_program, dwordaddr++ << 1, dstword); } @@ -1915,7 +1925,7 @@ void FUNCTION_NAME(tms340x0_device::fill)(int dst_is_linear) } /* write the result */ - if (m_plane_masking) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); + if (m_plane_mask) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); (this->*word_write)(*m_program, dwordaddr++ << 1, dstword); } @@ -1943,7 +1953,7 @@ void FUNCTION_NAME(tms340x0_device::fill)(int dst_is_linear) } /* write the result */ - if (m_plane_masking) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); + if (m_plane_mask) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); (this->*word_write)(*m_program, dwordaddr++ << 1, dstword); } @@ -1968,7 +1978,7 @@ void FUNCTION_NAME(tms340x0_device::fill)(int dst_is_linear) } /* write the result */ - if (m_plane_masking) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); + if (m_plane_mask) dstword = do_plane_masking((this->*word_read)(*m_program, dwordaddr << 1), dstword); (this->*word_write)(*m_program, dwordaddr++ << 1, dstword); } diff --git a/mame/tm34010/34010ops.h b/mame/tm34010/34010ops.h index c8df512c..902e66c0 100644 --- a/mame/tm34010/34010ops.h +++ b/mame/tm34010/34010ops.h @@ -29,6 +29,21 @@ inline UINT32 tms340x0_device::TMS34010_RDMEM_DWORD(offs_t A) return result | (m_program->read_word(A+2)<<16); } +inline UINT32 tms340x0_device::TMS34010_RDMEM_WORD_MASK(offs_t A) +{ + UINT32 result = m_program->read_word(A); + result &= m_plane_mask_inv; + return result; +} +inline UINT32 tms340x0_device::TMS34010_RDMEM_DWORD_MASK(offs_t A) +{ + UINT32 result = m_program->read_word(A); + result |= (m_program->read_word(A + 2) << 16); + result &= m_plane_mask_inv; + return result; +} + + #define TMS34010_WRMEM(A,V) (m_program->write_byte(A,V)) #define TMS34010_WRMEM_WORD(A,V) (m_program->write_word(A,V)) inline void tms340x0_device::TMS34010_WRMEM_DWORD(offs_t A, UINT32 V) @@ -39,14 +54,14 @@ inline void tms340x0_device::TMS34010_WRMEM_DWORD(offs_t A, UINT32 V) inline void tms340x0_device::TMS34010_WRMEM_WORD_MASK(offs_t A, UINT32 V) { - if (m_plane_masking) V = do_plane_masking(TMS34010_RDMEM_WORD(A), V); + if (m_plane_mask) V = do_plane_masking(TMS34010_RDMEM_WORD(A), V); m_program->write_word(A, V); } inline void tms340x0_device::TMS34010_WRMEM_DWORD_MASK(offs_t A, UINT32 V) { - if (m_plane_masking) V = do_plane_masking(TMS34010_RDMEM_DWORD(A), V); + if (m_plane_mask) V = do_plane_masking(TMS34010_RDMEM_DWORD(A), V); m_program->write_word(A, V); m_program->write_word(A + 2, V >> 16); diff --git a/mame/tm34010/tms34010.cpp b/mame/tm34010/tms34010.cpp index e0e7462c..ef40e056 100644 --- a/mame/tm34010/tms34010.cpp +++ b/mame/tm34010/tms34010.cpp @@ -246,11 +246,9 @@ inline INT32 tms340x0_device::POP() } -UINT32 tms340x0_device::do_plane_masking(UINT32 r, UINT32 w) +inline UINT32 tms340x0_device::do_plane_masking(UINT32 r, UINT32 w) { - UINT32 pmask = IOREG(REG_PMASK); - pmask |= pmask << 16; - UINT32 o = (r & pmask) | (w & ~pmask); + UINT32 o = (r & m_plane_mask) | (w & m_plane_mask_inv); return o; } @@ -297,7 +295,7 @@ UINT32 tms340x0_device::read_pixel_shiftreg(offs_t offset) /* No Raster Op + No Transparency */ #define WP(m1,m2) \ UINT32 a = TOBYTE(offset & 0xfffffff0); \ - UINT32 pix = TMS34010_RDMEM_WORD(a); \ + UINT32 pix = TMS34010_RDMEM_WORD_MASK(a); \ UINT32 shiftcount = offset & m1; \ \ data &= m2; \ @@ -310,7 +308,7 @@ UINT32 tms340x0_device::read_pixel_shiftreg(offs_t offset) if (data) \ { \ UINT32 a = TOBYTE(offset & 0xfffffff0); \ - UINT32 pix = TMS34010_RDMEM_WORD(a); \ + UINT32 pix = TMS34010_RDMEM_WORD_MASK(a); \ UINT32 shiftcount = offset & m1; \ \ pix = (pix & ~(m2 << shiftcount)) | (data << shiftcount); \ @@ -319,7 +317,7 @@ UINT32 tms340x0_device::read_pixel_shiftreg(offs_t offset) /* Raster Op + No Transparency */ #define WP_R(m1,m2) \ UINT32 a = TOBYTE(offset & 0xfffffff0); \ - UINT32 pix = TMS34010_RDMEM_WORD(a); \ + UINT32 pix = TMS34010_RDMEM_WORD_MASK(a); \ UINT32 shiftcount = offset & m1; \ \ data = (this->*m_raster_op)(data & m2, (pix >> shiftcount) & m2) & m2; \ @@ -329,7 +327,7 @@ UINT32 tms340x0_device::read_pixel_shiftreg(offs_t offset) /* Raster Op + Transparency */ #define WP_R_T(m1,m2) \ UINT32 a = TOBYTE(offset & 0xfffffff0); \ - UINT32 pix = TMS34010_RDMEM_WORD(a); \ + UINT32 pix = TMS34010_RDMEM_WORD_MASK(a); \ UINT32 shiftcount = offset & m1; \ \ data = (this->*m_raster_op)(data & m2, (pix >> shiftcount) & m2) & m2; \ @@ -377,12 +375,12 @@ void tms340x0_device::write_pixel_r_8(offs_t offset, UINT32 data) { WP_R(0x08, 0 void tms340x0_device::write_pixel_r_16(offs_t offset, UINT32 data) { UINT32 a = TOBYTE(offset & 0xfffffff0); - TMS34010_WRMEM_WORD_MASK(a, (this->*m_raster_op)(data, TMS34010_RDMEM_WORD(a))); + TMS34010_WRMEM_WORD_MASK(a, (this->*m_raster_op)(data, TMS34010_RDMEM_WORD_MASK(a))); } void tms340x0_device::write_pixel_r_32(offs_t offset, UINT32 data) { UINT32 a = TOBYTE(offset & 0xffffffe0); - TMS34010_WRMEM_DWORD_MASK(a, (this->*m_raster_op)(data, TMS34010_RDMEM_DWORD(a))); + TMS34010_WRMEM_DWORD_MASK(a, (this->*m_raster_op)(data, TMS34010_RDMEM_DWORD_MASK(a))); } /* Raster Op + Transparency */ @@ -393,7 +391,7 @@ void tms340x0_device::write_pixel_r_t_8(offs_t offset, UINT32 data) { WP_R_T(0x0 void tms340x0_device::write_pixel_r_t_16(offs_t offset, UINT32 data) { UINT32 a = TOBYTE(offset & 0xfffffff0); - data = (this->*m_raster_op)(data, TMS34010_RDMEM_WORD(a)); + data = (this->*m_raster_op)(data, TMS34010_RDMEM_WORD_MASK(a)); if (data) TMS34010_WRMEM_WORD_MASK(a, data); @@ -401,7 +399,7 @@ void tms340x0_device::write_pixel_r_t_16(offs_t offset, UINT32 data) void tms340x0_device::write_pixel_r_t_32(offs_t offset, UINT32 data) { UINT32 a = TOBYTE(offset & 0xffffffe0); - data = (this->*m_raster_op)(data, TMS34010_RDMEM_DWORD(a)); + data = (this->*m_raster_op)(data, TMS34010_RDMEM_DWORD_MASK(a)); if (data) TMS34010_WRMEM_DWORD_MASK(a, data); @@ -1153,7 +1151,8 @@ WRITE16_MEMBER( tms340x0_device::io_register_w ) break; case REG_PMASK: - m_plane_masking = data != 0; + m_plane_mask = (data << 16) | data; + m_plane_mask_inv = m_plane_mask ^ 0xffffffff; break; case REG_DPYCTL: diff --git a/mame/tm34010/tms34010.h b/mame/tm34010/tms34010.h index 91c2afd7..f6af70d8 100644 --- a/mame/tm34010/tms34010.h +++ b/mame/tm34010/tms34010.h @@ -347,7 +347,8 @@ protected: direct_read_data *m_direct; UINT32 m_pixclock; /* the pixel clock (0 means don't adjust screen size) */ int m_pixperclock; /* pixels per clock */ - bool m_plane_masking; + UINT32 m_plane_mask; + UINT32 m_plane_mask_inv; UINT16 m_prefetch_data; // emu_timer *m_scantimer; @@ -379,9 +380,11 @@ protected: } m_regs[31]; UINT16 m_IOregs[64]; - UINT16 m_shiftreg[(8 * 512 * sizeof(UINT16))/2]; + UINT16 m_shiftreg[(8 * 512 * sizeof(UINT16))/2]; UINT32 TMS34010_RDMEM_DWORD(offs_t A); + UINT32 TMS34010_RDMEM_DWORD_MASK(offs_t A); + UINT32 TMS34010_RDMEM_WORD_MASK(offs_t A); void TMS34010_WRMEM_DWORD(offs_t A, UINT32 V); void TMS34010_WRMEM_DWORD_MASK(offs_t A, UINT32 V); void TMS34010_WRMEM_WORD_MASK(offs_t A, UINT32 V);