diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-04-10 19:23:12 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-04-10 19:23:12 (GMT) |
| commit | f734568ad20b47fdd121b13aae8cebda4ea57d5a (patch) | |
| tree | 4e41bfc6bf0c22189de98e8810e2e1e196d3e117 | |
| parent | 22ca8886c25115df575f8a3e67a5da9059fc3f28 (diff) | |
wasp: draw565: Optimize the bit expansion blitter slightly.
| -rw-r--r-- | wasp/draw565.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/wasp/draw565.py b/wasp/draw565.py index 028b920..93032ac 100644 --- a/wasp/draw565.py +++ b/wasp/draw565.py @@ -7,13 +7,12 @@ import micropython @micropython.viper def _bitblit(bitbuf, pixels, bgfg: int, count: int): - mv = ptr8(bitbuf) + mv = ptr16(bitbuf) px = ptr8(pixels) - bghi = (bgfg >> 24) & 0xff - bglo = (bgfg >> 16) & 0xff - fghi = (bgfg >> 8) & 0xff - fglo = (bgfg ) & 0xff + # Extract and byte-swap + bg = ((bgfg >> 24) & 0xff) + ((bgfg >> 8) & 0xff00) + fg = ((bgfg >> 8) & 0xff) + ((bgfg & 0xff) << 8) bitselect = 0x80 pxp = 0 @@ -22,9 +21,7 @@ def _bitblit(bitbuf, pixels, bgfg: int, count: int): for bit in range(count): # Draw the pixel active = px[pxp] & bitselect - mv[mvp] = fghi if active else bghi - mvp += 1 - mv[mvp] = fglo if active else bglo + mv[mvp] = fg if active else bg mvp += 1 # Advance to the next bit |
