Mercurial > repos > blastem
diff vdp.c @ 1653:858d52140375
Small optimization to render_map
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 27 Dec 2018 10:40:24 -0800 |
parents | d0a69348add8 |
children | 3128d4e0bc68 |
line wrap: on
line diff
--- a/vdp.c Thu Dec 27 09:23:51 2018 -0800 +++ b/vdp.c Thu Dec 27 10:40:24 2018 -0800 @@ -1208,23 +1208,27 @@ } else { address += 4 * context->v_offset; } - uint16_t pal_priority = (col >> 9) & 0x70; - int32_t dir; + uint8_t pal_priority = (col >> 9) & 0x70; + uint32_t bits = *((uint32_t *)(&context->vdpmem[address])); if (col & MAP_BIT_H_FLIP) { - offset += 7; - offset &= SCROLL_BUFFER_MASK; - dir = -1; + uint32_t shift = 28; + for (int i = 0; i < 8; i++) + { + tmp_buf[offset++] = pal_priority | ((bits >> shift) & 0xF); + shift -= 4; + offset &= SCROLL_BUFFER_MASK; + } } else { - dir = 1; - } - for (uint32_t i=0; i < 4; i++, address++) - { - tmp_buf[offset] = pal_priority | (context->vdpmem[address] >> 4); - offset += dir; - offset &= SCROLL_BUFFER_MASK; - tmp_buf[offset] = pal_priority | (context->vdpmem[address] & 0xF); - offset += dir; - offset &= SCROLL_BUFFER_MASK; + for (int i = 0; i < 4; i++) + { + uint8_t right = pal_priority | (bits & 0xF); + bits >>= 4; + tmp_buf[offset++] = pal_priority | (bits & 0xF); + offset &= SCROLL_BUFFER_MASK; + bits >>= 4; + tmp_buf[offset++] = right; + offset &= SCROLL_BUFFER_MASK; + } } }