mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
add write_callback to sinf_inflate function
This commit is contained in:
parent
9558ac1830
commit
047578c4c0
@ -36,10 +36,6 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifndef SINF_WRITE
|
|
||||||
#error Must define SINF_WRITE(byte) macro
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// maximum possible window size (in bits) used during compression/deflate
|
// maximum possible window size (in bits) used during compression/deflate
|
||||||
#define SINF_WBITS 10
|
#define SINF_WBITS 10
|
||||||
|
|
||||||
@ -59,6 +55,7 @@ typedef struct {
|
|||||||
int cbufi;
|
int cbufi;
|
||||||
SINF_TREE ltree; /* dynamic length/symbol tree */
|
SINF_TREE ltree; /* dynamic length/symbol tree */
|
||||||
SINF_TREE dtree; /* dynamic distance tree */
|
SINF_TREE dtree; /* dynamic distance tree */
|
||||||
|
void (* write)(uint8_t byte);
|
||||||
} SINF_DATA;
|
} SINF_DATA;
|
||||||
|
|
||||||
/* --------------------------------------------------- *
|
/* --------------------------------------------------- *
|
||||||
@ -106,7 +103,7 @@ static void sinf_write(SINF_DATA *d, uint8_t byte)
|
|||||||
{
|
{
|
||||||
d->cbuf[d->cbufi] = byte;
|
d->cbuf[d->cbufi] = byte;
|
||||||
d->cbufi = (d->cbufi + 1) % (1 << SINF_WBITS);
|
d->cbufi = (d->cbufi + 1) % (1 << SINF_WBITS);
|
||||||
SINF_WRITE(byte);
|
d->write(byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* build the fixed huffman trees */
|
/* build the fixed huffman trees */
|
||||||
@ -394,7 +391,7 @@ static int sinf_inflate_dynamic_block(SINF_DATA *d)
|
|||||||
* ---------------------- */
|
* ---------------------- */
|
||||||
|
|
||||||
/* inflate stream from source */
|
/* inflate stream from source */
|
||||||
static int sinf_inflate(uint8_t *data)
|
static int sinf_inflate(uint8_t *data, void (*write_callback)(uint8_t byte))
|
||||||
{
|
{
|
||||||
SINF_DATA d;
|
SINF_DATA d;
|
||||||
int bfinal;
|
int bfinal;
|
||||||
@ -403,6 +400,7 @@ static int sinf_inflate(uint8_t *data)
|
|||||||
d.bitcount = 0;
|
d.bitcount = 0;
|
||||||
d.cbufi = 0;
|
d.cbufi = 0;
|
||||||
d.source = data;
|
d.source = data;
|
||||||
|
d.write = write_callback;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
#define CMD(X) (*((__IO uint8_t *)((uint32_t)(0x60000000))) = (X))
|
#define CMD(X) (*((__IO uint8_t *)((uint32_t)(0x60000000))) = (X))
|
||||||
#define DATA(X) (*((__IO uint8_t *)((uint32_t)(0x60000000 | 0x10000))) = (X))
|
#define DATA(X) (*((__IO uint8_t *)((uint32_t)(0x60000000 | 0x10000))) = (X))
|
||||||
|
|
||||||
|
static void DATAfunc(uint8_t x) {
|
||||||
|
DATA(x);
|
||||||
|
}
|
||||||
|
|
||||||
static void DATAS(void *bytes, int len);
|
static void DATAS(void *bytes, int len);
|
||||||
|
|
||||||
void sram_init(void) {
|
void sram_init(void) {
|
||||||
|
@ -14,7 +14,9 @@ static SDL_Texture *TEXTURE = 0;
|
|||||||
static int DATAODD = 0;
|
static int DATAODD = 0;
|
||||||
static int POSX, POSY, SX, SY, EX, EY = 0;
|
static int POSX, POSY, SX, SY, EX, EY = 0;
|
||||||
|
|
||||||
static void DATA(uint8_t x) {
|
#define DATA(X) DATAfunc((X))
|
||||||
|
|
||||||
|
static void DATAfunc(uint8_t x) {
|
||||||
if (!SDL_inited) return;
|
if (!SDL_inited) return;
|
||||||
if (POSX <= EX && POSY <= EY) {
|
if (POSX <= EX && POSY <= EY) {
|
||||||
((uint8_t *)SCREEN->pixels)[POSX * 2 + POSY * SCREEN->pitch + (DATAODD ^ 1)] = x;
|
((uint8_t *)SCREEN->pixels)[POSX * 2 + POSY * SCREEN->pitch + (DATAODD ^ 1)] = x;
|
||||||
|
@ -60,7 +60,7 @@ static void display_blit(uint8_t x, uint8_t y, uint8_t w, uint8_t h, void *data,
|
|||||||
|
|
||||||
static void display_image(uint8_t x, uint8_t y, uint8_t w, uint8_t h, void *data, int datalen) {
|
static void display_image(uint8_t x, uint8_t y, uint8_t w, uint8_t h, void *data, int datalen) {
|
||||||
display_set_window(x, y, w, h);
|
display_set_window(x, y, w, h);
|
||||||
sinf_inflate(data);
|
sinf_inflate(data, DATAfunc);
|
||||||
display_update();
|
display_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user