Skip to content

Commit

Permalink
Pass through pen get for PicoVision
Browse files Browse the repository at this point in the history
Now there's at least some way to read from the screen surface
  • Loading branch information
Daft-Freak committed Jul 18, 2023
1 parent 6979e9b commit 06728db
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 32blit-pico/display_picovision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@ static void blit_rgba_rgb555_picovision(const blit::Surface* src, uint32_t soff,
} while(cnt);
}

template<int h_repeat = 1>
static blit::Pen get_pen_rgb555_picovision(const blit::Surface *surf, uint32_t offset) {
uint32_t tmp;
ram.read_blocking(base_address + offset * h_repeat * 2, &tmp, 1);

uint8_t r, g, b;
unpack_rgb555(tmp, r, g, b);
return {r, g, b};
}

static void write_frame_setup(uint16_t width, uint16_t height, blit::PixelFormat format, uint8_t h_repeat, uint8_t v_repeat) {
constexpr int buf_size = 32;
uint32_t buf[buf_size];
Expand Down Expand Up @@ -347,9 +357,11 @@ void display_mode_changed(blit::ScreenMode new_mode, blit::SurfaceTemplate &new_
if(new_surf_template.bounds.w <= 160) {
new_surf_template.pen_blend = pen_rgba_rgb555_picovision<2>;
new_surf_template.blit_blend = blit_rgba_rgb555_picovision<2>;
new_surf_template.pen_get = get_pen_rgb555_picovision<2>;
} else {
new_surf_template.pen_blend = pen_rgba_rgb555_picovision;
new_surf_template.blit_blend = blit_rgba_rgb555_picovision;
new_surf_template.pen_get = get_pen_rgb555_picovision;
}

need_mode_change = 2; // make sure to update both banks
Expand Down
1 change: 1 addition & 0 deletions 32blit/engine/api_private.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace blit {

PenBlendFunc pen_blend = nullptr;
BlitBlendFunc blit_blend = nullptr;
PenGetFunc pen_get = nullptr;
};

// subset of Surface for API compat
Expand Down
3 changes: 3 additions & 0 deletions 32blit/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ namespace blit {
if(new_screen.blit_blend)
screen.bbf = new_screen.blit_blend;

if(new_screen.pen_get)
screen.pgf = new_screen.pen_get;

return true;
}

Expand Down

0 comments on commit 06728db

Please sign in to comment.