summaryrefslogtreecommitdiff
path: root/frontends/calculator/CEdev/examples/gfx_sprite_compress/src/main.c
blob: d74b073a084709f0bf1d81c6c4e14e719779602d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tice.h>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <compression.h>
#include <graphx.h>

/* Include the graphics file */
#include "gfx/all_gfx.h"

/* Put all your code here */
void main(void) {
    /* Define our sprite */
    gfx_sprite_t *apple;

    /* Allocate space for the decompressed sprite */
    apple = gfx_MallocSprite(apple_width, apple_height); /* Same as: gfx_AllocSprite(apple_width, apple_height, malloc) */

    /* Decompress the sprite */
    zx7_Decompress(apple, apple_compressed);

    /* Initialize the 8bpp graphics */
    gfx_Begin();

    /* Set up the palette */
    gfx_SetPalette(all_gfx_pal, sizeof_all_gfx_pal, 0);
    gfx_FillScreen(0);

    /* Draw the decompressed sprite */
    gfx_Sprite(apple, (LCD_WIDTH - 220) / 2, (LCD_HEIGHT - 240) / 2);

    /* Wait for a key */
    while (!os_GetCSC());

    /* Please, don't forget to free the apple image memory :) */
    free(apple);

    gfx_End();
}