Compare commits

..

2 Commits

Author SHA1 Message Date
Síle Ekaterin Liszka 10ac5c088f example: add example materials 2023-11-27 22:41:15 -08:00
Síle Ekaterin Liszka 1f3d6d1f5d src: more code fixes 2023-11-27 22:40:36 -08:00
8 changed files with 134 additions and 4 deletions

18
example/example.toml Normal file
View File

@ -0,0 +1,18 @@
name="Example"
[font]
"Melissa 8"="melissa8.toml"
[[script]]
name="example"
filename="example.txt"
font="Melissa 8"
min_tiles_per_line=0
max_tiles_per_line=0
tilemap_format="thingy"
leading_zeroes=false
tile_offset=0
raw_filename="example_raw.png"
dedupe_filename="example_ded.png"
tilemap_filename="example.tbl"
little_endian=false

6
example/example.txt Normal file
View File

@ -0,0 +1,6 @@
Potion
Hi Potion
Phoenix Tail
X-Potion
Huh?!
Oh my god, are you serious?!

BIN
example/melissa8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

93
example/melissa8.toml Normal file
View File

@ -0,0 +1,93 @@
name="Melissa 8"
filename="melissa8.png"
bits_per_pixel=2
width=8
height=8
palette=[
'008080',
'282828',
'f8f8f8',
'a8a8a8'
]
[map]
"a"=[1, 5]
"b"=[2, 5]
"c"=[3, 5]
"d"=[4, 5]
"e"=[5, 5]
"f"=[6, 5]
"g"=[7, 5]
"h"=[8, 5]
"i"=[9, 4]
"j"=[10, 3]
"k"=[11, 5]
"l"=[12, 4]
"m"=[13, 8]
"n"=[14, 5]
"o"=[15, 5]
"p"=[16, 5]
"q"=[17, 5]
"r"=[18, 5]
"s"=[19, 5]
"t"=[20, 5]
"u"=[21, 5]
"v"=[22, 6]
"w"=[23, 7]
"x"=[24, 6]
"y"=[25, 6]
"z"=[26, 5]
"A"=[33, 6]
"B"=[34, 6]
"C"=[35, 6]
"D"=[36, 6]
"E"=[37, 5]
"F"=[38, 5]
"G"=[39, 6]
"H"=[40, 6]
"I"=[41, 4]
"J"=[42, 4]
"K"=[43, 6]
"L"=[44, 6]
"M"=[45, 6]
"N"=[46, 6]
"O"=[47, 6]
"P"=[48, 6]
"Q"=[49, 6]
"R"=[50, 6]
"S"=[51, 5]
"T"=[52, 6]
"U"=[53, 6]
"V"=[54, 6]
"W"=[55, 7]
"X"=[56, 6]
"Y"=[57, 6]
"Z"=[58, 6]
"0"=[81, 5]
"1"=[82, 4]
"2"=[83, 5]
"3"=[84, 5]
"4"=[85, 5]
"5"=[86, 5]
"6"=[87, 5]
"7"=[88, 5]
"8"=[89, 5]
"9"=[90, 5]
":"=[97, 2]
","=[98, 3]
";"=[99, 3]
"-"=[100, 5]
"/"=[101, 4]
"("=[102, 4]
")"=[103, 4]
"."=[104, 2]
"'"=[105, 3]
'"'=[106, 5]
"%"=[107, 4]
"!"=[108, 3]
"?"=[109, 6]
"~"=[110, 7]
"*"=[111, 4]
"+"=[112, 6]
"="=[113, 5]
"#"=[114, 6]
" "=[115, 4]

View File

@ -10,7 +10,7 @@ font_t font_create(char *font_name, char *filename) {
char errbuf[200];
map_t *map;
printf("Processing %s...\n", font_name);
printf(" Processing %s...\n", font_name);
fp = fopen(filename, "r");

View File

@ -7,6 +7,7 @@
#include <toml.h>
#include "util.h"
#include "script.h"
#define ERRBUFSZ 200
@ -37,5 +38,11 @@ int main(int argc, char **argv) {
error("missing key: name", "");
}
printf("Preparing to process %s...\n", name.u.s);
printf("Processing game %s...\n", name.u.s);
toml_array_t *scripts = toml_array_in(conf, "script");
for (int i = 0; ; i++) {
toml_table_t *toml_script = toml_table_at(scripts, i);
script_t script = script_create(toml_script);
}
}

View File

@ -11,9 +11,11 @@ script_t script_create(toml_table_t *table) {
#define TOML_GET_KEY(var, key, func) toml_datum_t (var) = func(table, (key));\
if (!(var).ok) {\
char str[200];\
snprintf(str, 200, "key '%s' missing from", (key)); \
error(str, filename.u.s); \
snprintf(str, 200, "key '%s' missing", (key)); \
error(str, ""); \
}
TOML_GET_KEY(name, "name", toml_string_in)
printf(" Processing script %s...\n", name.u.s);
TOML_GET_KEY(filename, "filename", toml_string_in)
TOML_GET_KEY(font_name, "font", toml_string_in)
TOML_GET_KEY(min_tiles, "min_tiles_per_line", toml_int_in)

View File

@ -7,6 +7,7 @@
#include "font.h"
typedef struct {
char *name;
char *filename;
font_t font;
char *format;
@ -20,4 +21,7 @@ typedef struct {
bool little_endian;
} script_t;
script_t script_create(toml_table_t *table);
void script_destroy(script_t script);
#endif