add RLEVerticalExt (16 bit run length support)
This commit is contained in:
parent
90f648e0b0
commit
62ee8a6efa
8 changed files with 77689 additions and 106875 deletions
|
@ -1,6 +1,7 @@
|
|||
|
||||
build_thing:
|
||||
cmake -B bin -DPICO_SDK_PATH=../../pico-sdk
|
||||
# -DCMAKE_CXX_FLAGS=-Oz
|
||||
make -j8 -C bin
|
||||
# then manually copy bin/thing.uf2 to the pico
|
||||
|
||||
|
|
184253
pico_decoder/src/data.h
184253
pico_decoder/src/data.h
File diff suppressed because it is too large
Load diff
|
@ -75,21 +75,21 @@ void draw_num(u16 x, u16 y, u32 num) {
|
|||
int main() {
|
||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||
gpio_put(PICO_DEFAULT_LED_PIN, 1);
|
||||
tft_init_display(100 * 1000 * 1000); // max is 62.5MHz
|
||||
// tft_fill(0);
|
||||
|
||||
while (!error) {
|
||||
decode_next_frame();
|
||||
draw_num(30,2, reader);
|
||||
draw_num(15, 8, video[reader]);
|
||||
refresh_screen();
|
||||
sleep_ms(100);
|
||||
// sleep_ms(100);
|
||||
if (reader >= sizeof(video))
|
||||
reader = 0;
|
||||
error = true;
|
||||
// reader = 0;
|
||||
}
|
||||
gpio_put(PICO_DEFAULT_LED_PIN, 1);
|
||||
draw_num(30, 2, reader);
|
||||
draw_num(15, 8, video[reader]);
|
||||
draw_num(30, 2, reader-1);
|
||||
draw_num(15, 8, video[reader-1]);
|
||||
draw_num(30, 16, last_frame_start);
|
||||
draw_num(15, 22, last_frame_type);
|
||||
refresh_screen();
|
||||
|
@ -106,7 +106,7 @@ void refresh_screen() {
|
|||
DC_D;
|
||||
|
||||
u32 pixel_count = AREA;
|
||||
const u8 pixels[2] = {0, 176};
|
||||
const u8 pixels[2] = {0, 255};
|
||||
|
||||
while (pixel_count--) {
|
||||
u8 p = pixels[frame[pixel_count]];
|
||||
|
@ -135,14 +135,14 @@ void fill_frame(u8 color) {
|
|||
|
||||
void set_pixel(u16 x, u16 y, u8 color)
|
||||
{
|
||||
if (x >= WIDTH || y >= HEIGHT){
|
||||
while (1){
|
||||
gpio_put(PICO_DEFAULT_LED_PIN, 1);
|
||||
sleep_ms(50);
|
||||
gpio_put(PICO_DEFAULT_LED_PIN, 0);
|
||||
sleep_ms(50);
|
||||
}
|
||||
}
|
||||
// if (x >= WIDTH || y >= HEIGHT){
|
||||
// while (1){
|
||||
// gpio_put(PICO_DEFAULT_LED_PIN, 1);
|
||||
// sleep_ms(50);
|
||||
// gpio_put(PICO_DEFAULT_LED_PIN, 0);
|
||||
// sleep_ms(50);
|
||||
// }
|
||||
// }
|
||||
x = (WIDTH-1) - x;
|
||||
const u32 index = x * HEIGHT + y;
|
||||
frame[index] = color;
|
||||
|
@ -150,6 +150,7 @@ void set_pixel(u16 x, u16 y, u8 color)
|
|||
|
||||
void rle_horizontal();
|
||||
void rle_vertical();
|
||||
void rle_vertical_ext();
|
||||
void bg_strips_h();
|
||||
void cell_diff_4vv();
|
||||
|
||||
|
@ -179,13 +180,18 @@ void decode_next_frame()
|
|||
rle_vertical();
|
||||
break;
|
||||
#endif
|
||||
#ifdef USE_RLEVerticalExt
|
||||
case Encoding_RLEVerticalExt:
|
||||
rle_vertical_ext();
|
||||
break;
|
||||
#endif
|
||||
#ifdef USE_BGStripsH24
|
||||
case Encoding_BGStripsH24:
|
||||
bg_strips_h();
|
||||
break;
|
||||
#endif
|
||||
#ifdef USE_CellDiff4VV_small
|
||||
case Encoding_CellDiff4VV_small:
|
||||
#ifdef USE_CellDiff4VV
|
||||
case Encoding_CellDiff4VV:
|
||||
cell_diff_4vv();
|
||||
break;
|
||||
#endif
|
||||
|
@ -219,8 +225,7 @@ void rle_horizontal()
|
|||
#endif
|
||||
|
||||
#ifdef USE_RLEVertical
|
||||
void rle_vertical()
|
||||
{
|
||||
void rle_vertical() {
|
||||
u16 x = 0;
|
||||
u16 y = 0;
|
||||
u8 color = 0;
|
||||
|
@ -241,9 +246,39 @@ void rle_vertical()
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_RLEVerticalExt
|
||||
void rle_vertical_ext() {
|
||||
u16 x = 0;
|
||||
u16 y = 0;
|
||||
u8 color = 0;
|
||||
while (x < WIDTH) {
|
||||
u8 byte = next_byte();
|
||||
u16 run = byte;
|
||||
if (byte == 0 && video[reader] == 0) {
|
||||
// 16 bit run length
|
||||
u16 upper = video[reader + 1] << 8;
|
||||
if (upper) {
|
||||
u16 lower = video[reader + 2];
|
||||
run = upper | lower;
|
||||
reader += 3;
|
||||
}
|
||||
}
|
||||
for (u16 i = 0; i < run; i++) {
|
||||
set_pixel(x, y, color);
|
||||
y += 1;
|
||||
if (y == HEIGHT) {
|
||||
y = 0;
|
||||
x += 1;
|
||||
}
|
||||
}
|
||||
color = !color;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_BGStripsH24
|
||||
void bg_strips_h()
|
||||
{
|
||||
void bg_strips_h() {
|
||||
u8 head = next_byte();
|
||||
u8 bg = head >> 7;
|
||||
u8 fg = 1 - bg;
|
||||
|
@ -262,7 +297,7 @@ void bg_strips_h()
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_CellDiff4VV_small
|
||||
#ifdef USE_CellDiff4VV
|
||||
void cell_diff_4vv() {
|
||||
const u32 cells_x = WIDTH/4;
|
||||
const u32 cells_y = HEIGHT/4;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue