From d3e16169bb1db6448d21929af9b0727a03114bbe Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Tue, 18 Jul 2023 22:37:59 +0100 Subject: [PATCH] WIP: pico: handle rgb555 blits for PicoVision Missing Surface::alpha handling and using the wrong format. --- 32blit-pico/display_picovision.cpp | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/32blit-pico/display_picovision.cpp b/32blit-pico/display_picovision.cpp index 71f1e4acb..47af42072 100644 --- a/32blit-pico/display_picovision.cpp +++ b/32blit-pico/display_picovision.cpp @@ -166,6 +166,34 @@ static void pen_rgba_rgb555_picovision(const blit::Pen* pen, const blit::Surface } } +template +static void blit_rgb555(uint16_t *s, const blit::Surface* dest, uint32_t doff, uint32_t cnt, int32_t src_step) { + if(h_repeat == 1 && src_step == 1 && !dest->mask && dest->alpha == 255) { + // copy + ram.write(base_address + doff * 2, (uint32_t *)s, cnt * 2); + return; + } + + do { + auto step = std::min(cnt, uint32_t(std::size(blend_buf))); + + auto *ptr = blend_buf; + for(unsigned i = 0; i < step; i += h_repeat) { + // TODO if dest->alpha, blend + + auto col = *s; + for(int j = 0; j < h_repeat; j++) + *ptr++ = col; + + s += src_step; + } + + ram.write(base_address + doff * 2, (uint32_t *)blend_buf, step * 2); + doff += step; + cnt -= step; + } while(cnt); +} + template static void blit_rgba_rgb555_picovision(const blit::Surface* src, uint32_t soff, const blit::Surface* dest, uint32_t doff, uint32_t cnt, int32_t src_step) { uint8_t* s = src->palette ? src->data + soff : src->data + (soff * src->pixel_stride); @@ -176,6 +204,9 @@ static void blit_rgba_rgb555_picovision(const blit::Surface* src, uint32_t soff, flush_batch(); + if(src->format == blit::PixelFormat::RGB565) // still a lie + return blit_rgb555((uint16_t *)s, dest, doff, cnt, src_step); + do { auto step = std::min(cnt, uint32_t(std::size(blend_buf)));