Skip to content

Commit

Permalink
WIP: pico: handle rgb555 blits for PicoVision
Browse files Browse the repository at this point in the history
Missing Surface::alpha handling and using the wrong format.
  • Loading branch information
Daft-Freak committed Jul 19, 2023
1 parent 000250a commit 3aa22ce
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions 32blit-pico/display_picovision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,34 @@ static void pen_rgba_rgb555_picovision(const blit::Pen* pen, const blit::Surface
}
}

template<int h_repeat = 1>
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<int h_repeat = 1>
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);
Expand All @@ -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<h_repeat>((uint16_t *)s, dest, doff, cnt, src_step);

do {
auto step = std::min(cnt, uint32_t(std::size(blend_buf)));

Expand Down

0 comments on commit 3aa22ce

Please sign in to comment.