ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
mg_reader.h
Go to the documentation of this file.
1
30
31#pragma once
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#include <stddef.h>
38#include <stdint.h>
39
40#include "jof.h"
41#include "ra8_err.h"
42#include "ra8_tile_cache.h"
43
63
70typedef enum : uint8_t {
73} mg_zoom_t;
74
89
101typedef struct {
104 void* pread_ctx;
105 uint8_t* scratch;
106 uint32_t scratch_cap;
108
115typedef struct {
116 uint16_t* fb;
117 int32_t fb_w;
118 int32_t fb_h;
121 uint32_t image_id;
123
133typedef struct {
134 uint16_t* fb;
135 int32_t fb_w;
136 int32_t fb_h;
138 uint32_t image_id;
139 uint16_t page_w;
140 uint16_t page_h;
141 uint16_t tile_w;
142 uint16_t tile_h;
143 uint16_t tile_cols;
144 uint16_t tile_rows;
145 int32_t view_x;
146 int32_t view_y;
147 uint8_t zoom;
148 uint8_t fit_factor;
151
175[[nodiscard]] ra8_err_t mg_reader_init(mg_reader_t* r, const mg_reader_cfg_t* cfg);
176
202[[nodiscard]] mg_zone_t mg_zone_hit(const mg_reader_t* r, int32_t x, int32_t y);
203
228[[nodiscard]] bool mg_reader_tap(mg_reader_t* r, int32_t x, int32_t y);
229
247[[nodiscard]] bool mg_reader_toggle_zoom(mg_reader_t* r);
248
274[[nodiscard]] ra8_err_t mg_reader_render(mg_reader_t* r);
275
309
330[[nodiscard]] ra8_err_t mg_reader_status(const mg_reader_t* r, char* buf, uint32_t cap);
331
349[[nodiscard]] uint32_t mg_fnv1a(const void* buf, uint32_t len);
350
379[[nodiscard]] ra8_err_t mg_tile_decode(void* ctx,
380 const ra8_tile_key_t* key,
381 uint8_t* cell,
382 uint32_t cell_bytes,
383 uint16_t* out_w,
384 uint16_t* out_h);
385
386#ifdef __cplusplus
387}
388#endif
JOF band-tile atlas: the display-native normalized image format (#231, shared with the longstrip scro...
ra8_err_t(* jof_pread_fn)(void *ctx, uint64_t offset, uint8_t *buf, size_t len, size_t *got)
Positioned-read seam over an atlas backing store (DIP).
Definition jof.h:241
bool mg_reader_tap(mg_reader_t *r, int32_t x, int32_t y)
Apply a tap: pan or toggle zoom, and report whether state changed.
Definition mg_reader.c:461
ra8_err_t mg_tile_decode(void *ctx, const ra8_tile_key_t *key, uint8_t *cell, uint32_t cell_bytes, uint16_t *out_w, uint16_t *out_h)
Tile-cache decode-on-miss callback: page one atlas tile into a cell.
Definition mg_reader.c:633
ra8_err_t mg_reader_status(const mg_reader_t *r, char *buf, uint32_t cap)
Format the status-bar string ("MANGA 1:1 x=.. y=..").
Definition mg_reader.c:522
mg_zone_t mg_zone_hit(const mg_reader_t *r, int32_t x, int32_t y)
Classify a panel coordinate into its tap-zone.
Definition mg_reader.c:417
uint32_t mg_fnv1a(const void *buf, uint32_t len)
FNV-1a-32 over a byte buffer (framebuffer render hash for the banner).
Definition mg_reader.c:540
mg_zone_t
The tap-zone a panel coordinate falls in (mg_zone_hit result).
Definition mg_reader.h:81
@ k_mg_zone_pan_up
Top edge band: slide viewport up.
Definition mg_reader.h:83
@ k_mg_zone_zoom
Centre: toggle 1:1 <-> fit-page.
Definition mg_reader.h:87
@ k_mg_zone_pan_left
Left edge band: slide left.
Definition mg_reader.h:85
@ k_mg_zone_pan_right
Right edge band: slide right.
Definition mg_reader.h:86
@ k_mg_zone_none
Outside every actionable zone.
Definition mg_reader.h:82
@ k_mg_zone_pan_down
Bottom edge band: slide down.
Definition mg_reader.h:84
ra8_err_t mg_reader_prefetch(mg_reader_t *r)
Warm the tiles one step ahead of the last pan (predictive prefetch).
Definition mg_reader.c:349
ra8_err_t mg_reader_render(mg_reader_t *r)
Render the current viewport + chrome into the framebuffer.
Definition mg_reader.c:332
mg_layout_t
Fixed chrome + navigation geometry, in panel/page pixels.
Definition mg_reader.h:54
@ k_mg_minimap_h
Minimap overlay height, panel px.
Definition mg_reader.h:59
@ k_mg_edge_band
Edge pan tap-zone thickness, panel px.
Definition mg_reader.h:57
@ k_mg_minimap_w
Minimap overlay width, panel px.
Definition mg_reader.h:58
@ k_mg_pan_step
Viewport slide per edge tap, page px.
Definition mg_reader.h:56
@ k_mg_statusbar_h
Top status-bar band height, panel px.
Definition mg_reader.h:55
@ k_mg_minimap_in
Minimap interior inset, px.
Definition mg_reader.h:61
@ k_mg_minimap_pad
Minimap inset from the panel edge, px.
Definition mg_reader.h:60
mg_zoom_t
The two zoom states cycled by a centre tap.
Definition mg_reader.h:70
@ k_mg_zoom_fit
Fit-page – whole page decimated to the panel.
Definition mg_reader.h:72
@ k_mg_zoom_full
1:1 – one page pixel per panel pixel; panned.
Definition mg_reader.h:71
ra8_err_t mg_reader_init(mg_reader_t *r, const mg_reader_cfg_t *cfg)
Bind a viewer to a produced atlas and reset it to 1:1 top-left.
Definition mg_reader.c:619
bool mg_reader_toggle_zoom(mg_reader_t *r)
Toggle the zoom between 1:1 and fit-page (SW-button entry point).
Definition mg_reader.c:450
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Fixed-RAM-budget image-tile cache with LRU eviction (Layer 3b, #147).
ra8_tile_pan_dir_t
Direction of viewport travel, for predictive pan prefetch.
Parsed + validated geometry of one JOF atlas.
Definition jof.h:208
Everything mg_reader_init needs to bind a viewer to a page.
Definition mg_reader.h:115
uint16_t * fb
RGB565 framebuffer (panel).
Definition mg_reader.h:116
const jof_info_t * info
Parsed atlas geometry.
Definition mg_reader.h:120
ra8_tile_cache_t * cache
Tile cache over the atlas.
Definition mg_reader.h:119
int32_t fb_h
Framebuffer height, pixels.
Definition mg_reader.h:118
uint32_t image_id
Tile-cache key image id.
Definition mg_reader.h:121
int32_t fb_w
Framebuffer width, pixels.
Definition mg_reader.h:117
Viewer state: the page geometry plus the current viewport + zoom.
Definition mg_reader.h:133
int32_t view_x
Viewport left in page px (1:1 anchor).
Definition mg_reader.h:145
int32_t view_y
Viewport top in page px (1:1 anchor).
Definition mg_reader.h:146
uint32_t image_id
Tile-cache key image id.
Definition mg_reader.h:138
int32_t fb_w
Framebuffer width, pixels.
Definition mg_reader.h:135
uint16_t tile_h
Atlas tile height, pixels.
Definition mg_reader.h:142
uint8_t fit_factor
Decimation factor for fit-page (>= 1).
Definition mg_reader.h:148
uint16_t tile_w
Atlas tile width, pixels.
Definition mg_reader.h:141
uint16_t page_h
Full page height, pixels.
Definition mg_reader.h:140
uint16_t * fb
RGB565 panel framebuffer.
Definition mg_reader.h:134
int32_t fb_h
Framebuffer height, pixels.
Definition mg_reader.h:136
uint16_t page_w
Full page width, pixels.
Definition mg_reader.h:139
ra8_tile_cache_t * cache
Tile cache paging the atlas.
Definition mg_reader.h:137
uint8_t zoom
Current mg_zoom_t.
Definition mg_reader.h:147
uint16_t tile_cols
Atlas tile columns.
Definition mg_reader.h:143
uint16_t tile_rows
Atlas tile rows.
Definition mg_reader.h:144
ra8_tile_pan_dir_t last_pan
Last pan direction (mg_reader_prefetch seed).
Definition mg_reader.h:149
Decode-on-miss context bound into the tile cache (DIP seam).
Definition mg_reader.h:101
const jof_info_t * info
Parsed atlas geometry.
Definition mg_reader.h:102
jof_pread_fn pread
Atlas positioned-read seam.
Definition mg_reader.h:103
uint8_t * scratch
Deflate stored-stream staging.
Definition mg_reader.h:105
void * pread_ctx
Context for pread.
Definition mg_reader.h:104
uint32_t scratch_cap
Capacity of scratch.
Definition mg_reader.h:106
Tile-cache state (caller-owned; treat as private).
Identifies one decoded image tile.