From ba5b241f672cce00d1fe9521da445aa8d7f918b0 Mon Sep 17 00:00:00 2001 From: zlago Date: Thu, 26 Sep 2024 10:51:02 +0200 Subject: asset pipeline --- src/loader.c | 2 +- src/main.c | 5 ++- src/res/autotiles.tsx | 40 ++++++++++++++++++++ src/res/padding.ase | Bin 0 -> 401 bytes src/res/padding.tsx | 4 ++ src/res/set/autotiles.ase | Bin 0 -> 628 bytes src/res/tileset.ase | Bin 0 -> 883 bytes src/res/tileset.tsx | 28 ++++++++++++++ src/res/untitled.tmx | 92 ++++++++++++++++++++++++++++++++++++++++++++++ src/tilemap.c | 6 +-- src/tilemap.h | 2 +- src/util.c | 1 + src/zip.c | 8 +++- 13 files changed, 179 insertions(+), 9 deletions(-) create mode 100644 src/res/autotiles.tsx create mode 100644 src/res/padding.ase create mode 100644 src/res/padding.tsx create mode 100644 src/res/set/autotiles.ase create mode 100644 src/res/tileset.ase create mode 100644 src/res/tileset.tsx create mode 100644 src/res/untitled.tmx (limited to 'src') diff --git a/src/loader.c b/src/loader.c index aa599bd..985f4b7 100644 --- a/src/loader.c +++ b/src/loader.c @@ -224,7 +224,7 @@ int loadResources(char *filename) { memcpy(chaos_file->name, zip_file->filename, j); chaos_file->name[j] = 0; - chaos_file->extension = get_extension_type(zip_file->filename + j + 1, zip_file->filename_length - j - 1); + chaos_file->extension = get_extension_type((char *) zip_file->filename + j + 1, zip_file->filename_length - j - 1); #if 0 fprintf(stderr, "%s: %i\n", chaos_file->name, chaos_file->extension); diff --git a/src/main.c b/src/main.c index bf23ee0..394f52c 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,7 @@ #define SDL_MAIN_HANDLED #include +#include #include #include "input.h" @@ -57,9 +58,9 @@ int main(int argc, char **argv) { return 1; } free(a); - struct blob map = res_get_map("out"); + struct blob map = res_get_map("untitled"); tilemap = load_tilemap(map.data, map.size); - printf("load_tilemap %p\n", tilemap); + printf("load_tilemap %p\n", (void *) tilemap); SDL_SetRenderTarget(renderer, NULL); } diff --git a/src/res/autotiles.tsx b/src/res/autotiles.tsx new file mode 100644 index 0000000..891246a --- /dev/null +++ b/src/res/autotiles.tsx @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/res/padding.ase b/src/res/padding.ase new file mode 100644 index 0000000..3bdd076 Binary files /dev/null and b/src/res/padding.ase differ diff --git a/src/res/padding.tsx b/src/res/padding.tsx new file mode 100644 index 0000000..304fb63 --- /dev/null +++ b/src/res/padding.tsx @@ -0,0 +1,4 @@ + + + + diff --git a/src/res/set/autotiles.ase b/src/res/set/autotiles.ase new file mode 100644 index 0000000..e263ed0 Binary files /dev/null and b/src/res/set/autotiles.ase differ diff --git a/src/res/tileset.ase b/src/res/tileset.ase new file mode 100644 index 0000000..19cca48 Binary files /dev/null and b/src/res/tileset.ase differ diff --git a/src/res/tileset.tsx b/src/res/tileset.tsx new file mode 100644 index 0000000..f9b772b --- /dev/null +++ b/src/res/tileset.tsx @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/res/untitled.tmx b/src/res/untitled.tmx new file mode 100644 index 0000000..51b506c --- /dev/null +++ b/src/res/untitled.tmx @@ -0,0 +1,92 @@ + + + + + + + + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,35,35,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,35,35,35,35,35,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,35,35,35,35,35,35,35,35,0,0,0,35,35,35,0,0,0,0,0,0,0,0,0,35,0,0,0, +0,0,0,35,35,35,35,35,35,35,35,35,0,35,35,35,35,35,0,0,0,0,0,0,0,35,35,35,0,0, +0,0,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,0,0,0,0,0,35,35,35,35,35,0, +0,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,0,0,0,35,35,35,35,35,35,35, +35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,0,35,35,35,35,35,35,35,35, +35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35, +35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35, +35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35, +35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35, +35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35, +35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35, +35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35, +35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35 + + + + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,9,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,11,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + + + + + + + + + + + diff --git a/src/tilemap.c b/src/tilemap.c index 3f19f0e..5660046 100644 --- a/src/tilemap.c +++ b/src/tilemap.c @@ -37,7 +37,7 @@ void free_tilemap(struct tilemap *tilemap) { free(tilemap); } -struct tilemap *load_tilemap(void const *data, size_t size) { +struct tilemap *load_tilemap(void *data, size_t size) { struct tilemap *tilemap = malloc(sizeof (struct tilemap)); if (tilemap == NULL) { return NULL; @@ -50,10 +50,10 @@ struct tilemap *load_tilemap(void const *data, size_t size) { tilemap->collision = NULL; tilemap->tilemaps = NULL; - struct sets const *const sets = data; + struct sets *const sets = data; data = sets + 1; size -= sizeof (struct sets); - char const *str = data; + char *str = data; int y = 0; SDL_SetRenderTarget(renderer, tilemap->tileset); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0); diff --git a/src/tilemap.h b/src/tilemap.h index dc0f938..e9b42aa 100644 --- a/src/tilemap.h +++ b/src/tilemap.h @@ -16,4 +16,4 @@ extern struct tilemap { void init_tilemap(void); void free_tilemap(struct tilemap *tilemap); -struct tilemap *load_tilemap(void const *data, size_t size); +struct tilemap *load_tilemap(void *data, size_t size); diff --git a/src/util.c b/src/util.c index fc20e94..f6b00a9 100644 --- a/src/util.c +++ b/src/util.c @@ -1,5 +1,6 @@ #include // FILE * #include // ESPIPE +#include #include #include #include // true/false diff --git a/src/zip.c b/src/zip.c index aca980d..76820b5 100644 --- a/src/zip.c +++ b/src/zip.c @@ -39,7 +39,9 @@ struct zip_file *zip_index(char *const restrict file, size_t const size, int *co // find and verify the footer struct zip_footer *footer = zip_find_footer(file, size, &err); if (footer == NULL) { - error && (*error = err); + if (error) { + *error = err; + } return NULL; } @@ -47,7 +49,9 @@ struct zip_file *zip_index(char *const restrict file, size_t const size, int *co struct zip_file *headers = malloc(sizeof (*headers) + footer->headers_no * sizeof (*headers->files)); err = index_zip(headers->files, file, footer); if (err) { - error && (*error = err); + if (error) { + *error = err; + } free(headers); return NULL; } -- cgit 1.4.1-2-gfad0