]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
TMS34010 plane masking update
authorToni Wilen <twilen@winuae.net>
Mon, 10 Jul 2023 09:26:57 +0000 (12:26 +0300)
committerToni Wilen <twilen@winuae.net>
Mon, 10 Jul 2023 09:26:57 +0000 (12:26 +0300)
mame/tm34010/34010gfx.c
mame/tm34010/34010ops.h
mame/tm34010/tms34010.cpp
mame/tm34010/tms34010.h

index d650cfaf21e1afd072ab0c4a08b2fba80aeb62d7..a350be0e692e3e2f9a578dd05249ae20db2467f5 100644 (file)
@@ -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);
                        }
 
index c8df512c3e37ac08a6961213a457d6eb394266c5..902e66c0a2765cf99a9a64ef68e60210d2184844 100644 (file)
@@ -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);
index e0e7462c7744893d21da3f94b8818272dca7ba6f..ef40e0565caa565653198a3abbd55be9e3519c51 100644 (file)
@@ -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:
index 91c2afd7f356a42d57b07554b5a82ec748eed19f..f6af70d8742ff90348cbeb02f27cf9fec1ff0284 100644 (file)
@@ -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);