Skip to content

Commit 45a0387

Browse files
Clean up tilemap examples a bit
1 parent 2c12310 commit 45a0387

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

examples/gfx_tilemap/src/main.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,27 @@
3030
extern uint8_t tilemap_map[];
3131

3232
/* Put functions here */
33-
gfx_tilemap_t tilemap;
3433

3534
/* Put all your code here */
3635
void main(void) {
37-
uint8_t key;
38-
unsigned x_offset = 0, y_offset = 0;
36+
sk_key_t key;
37+
unsigned int x_offset = 0;
38+
unsigned int y_offset = 0;
39+
gfx_tilemap_t tilemap;
3940

4041
/* Initialize the tilemap structure */
41-
tilemap.map = tilemap_map;
42-
tilemap.tiles = tileset_tiles;
43-
tilemap.type_width = gfx_tile_16_pixel;
42+
tilemap.map = tilemap_map;
43+
tilemap.tiles = tileset_tiles;
44+
tilemap.type_width = gfx_tile_16_pixel;
4445
tilemap.type_height = gfx_tile_16_pixel;
4546
tilemap.tile_height = TILE_HEIGHT;
46-
tilemap.tile_width = TILE_WIDTH;
47+
tilemap.tile_width = TILE_WIDTH;
4748
tilemap.draw_height = TILEMAP_DRAW_HEIGHT;
48-
tilemap.draw_width = TILEMAP_DRAW_WIDTH;
49-
tilemap.height = TILEMAP_HEIGHT;
50-
tilemap.width = TILEMAP_WIDTH;
51-
tilemap.y_loc = Y_OFFSET;
52-
tilemap.x_loc = X_OFFSET;
49+
tilemap.draw_width = TILEMAP_DRAW_WIDTH;
50+
tilemap.height = TILEMAP_HEIGHT;
51+
tilemap.width = TILEMAP_WIDTH;
52+
tilemap.y_loc = Y_OFFSET;
53+
tilemap.x_loc = X_OFFSET;
5354

5455
/* Initialize the 8bpp graphics */
5556
gfx_Begin( gfx_8bpp );

examples/gfx_tilemap_compress/src/main.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,36 @@ gfx_image_t *tileset_tiles[128];
3939

4040
/* Put all your code here */
4141
void main(void) {
42-
uint8_t key, i;
42+
sk_key_t key;
43+
uint8_t i;
44+
unsigned int x_offset = 0;
45+
unsigned int y_offset = 0;
4346
gfx_image_t *tmp_ptr;
4447
gfx_tilemap_t tilemap;
45-
unsigned x_offset = 0, y_offset = 0;
46-
48+
49+
/* For linking purposes */
4750
malloc(0);
4851

4952
/* Decompress the tiles */
5053
for(i = 0; i < 128; i++) {
51-
tmp_ptr = gfx_AllocSprite( TILE_WIDTH, TILE_HEIGHT, malloc );
54+
tmp_ptr = gfx_MallocSprite( TILE_WIDTH, TILE_HEIGHT );
5255
dzx7_Turbo( tileset_tiles_compressed[i], tmp_ptr ); // or dzx7_Standard, but in this case we have a lot of tiles
5356
tileset_tiles[i] = tmp_ptr;
5457
}
5558

5659
/* Initialize the tilemap structure */
57-
tilemap.map = tilemap_map;
58-
tilemap.tiles = tileset_tiles;
59-
tilemap.type_width = gfx_tile_16_pixel;
60+
tilemap.map = tilemap_map;
61+
tilemap.tiles = tileset_tiles;
62+
tilemap.type_width = gfx_tile_16_pixel;
6063
tilemap.type_height = gfx_tile_16_pixel;
6164
tilemap.tile_height = TILE_HEIGHT;
62-
tilemap.tile_width = TILE_WIDTH;
65+
tilemap.tile_width = TILE_WIDTH;
6366
tilemap.draw_height = TILEMAP_DRAW_HEIGHT;
64-
tilemap.draw_width = TILEMAP_DRAW_WIDTH;
65-
tilemap.height = TILEMAP_HEIGHT;
66-
tilemap.width = TILEMAP_WIDTH;
67-
tilemap.y_loc = Y_OFFSET;
68-
tilemap.x_loc = X_OFFSET;
67+
tilemap.draw_width = TILEMAP_DRAW_WIDTH;
68+
tilemap.height = TILEMAP_HEIGHT;
69+
tilemap.width = TILEMAP_WIDTH;
70+
tilemap.y_loc = Y_OFFSET;
71+
tilemap.x_loc = X_OFFSET;
6972

7073
/* Initialize the 8bpp graphics */
7174
gfx_Begin( gfx_8bpp );

0 commit comments

Comments
 (0)