Skip to content

Commit

Permalink
fix #69
Browse files Browse the repository at this point in the history
  • Loading branch information
mateoconlechuga committed Dec 24, 2020
1 parent 51f1220 commit 615ac1c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ int convert_tileset(convert_t *convert, tileset_t *tileset)
}

tileset->compressed = convert->compress != COMPRESS_NONE;
tileset->rlet = convert->style == CONVERT_STYLE_RLET;

tileset_alloc_tiles(tileset);

Expand Down
27 changes: 10 additions & 17 deletions src/output-appvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int output_appvar_header(output_t *output, appvar_t *appvar)
}

appvar->size += appvar->dataOffset;

/* first entry is number of entries */
appvar_insert_entry(appvar, 0, numEntries - 1);

Expand Down Expand Up @@ -468,20 +468,11 @@ static void output_appvar_c_include_file_converts(output_t *output, FILE *fdh, i
image->name,
*index);

if (image->rlet)
{
fprintf(fdh, "#define %s ((gfx_rletsprite_t*)%s_appvar[%d])\n",
image->name,
output->appvar.name,
*index);
}
else
{
fprintf(fdh, "#define %s ((gfx_sprite_t*)%s_appvar[%d])\n",
image->name,
output->appvar.name,
*index);
}
fprintf(fdh, "#define %s ((%s*)%s_appvar[%d])\n",
image->name,
image->rlet ? "gfx_rletsprite_t" : "gfx_sprite_t",
output->appvar.name,
*index);
}

*index = *index + 1;
Expand Down Expand Up @@ -538,14 +529,16 @@ static void output_appvar_c_include_file_converts(output_t *output, FILE *fdh, i
fprintf(fdh, "extern unsigned char *%s_tiles_data[%d];\n",
tileset->image.name,
tileset->numTiles);
fprintf(fdh, "#define %s_tiles ((gfx_sprite_t**)%s_tiles_data)\n",
fprintf(fdh, "#define %s_tiles ((%s**)%s_tiles_data)\n",
tileset->image.name,
tileset->rlet ? "gfx_rletsprite_t" : "gfx_sprite_t",
tileset->image.name);
for (l = 0; l < tileset->numTiles; l++)
{
fprintf(fdh, "#define %s_tile_%d ((gfx_sprite_t*)%s_tiles_data[%d])\n",
fprintf(fdh, "#define %s_tile_%d ((%s*)%s_tiles_data[%d])\n",
tileset->image.name,
l,
tileset->rlet ? "gfx_rletsprite_t" : "gfx_sprite_t",
tileset->image.name,
l);
}
Expand Down
18 changes: 8 additions & 10 deletions src/output-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,10 @@ int output_c_image(image_t *image)
}
else
{
if (image->rlet)
{
fprintf(fdh, "#define %s ((gfx_rletsprite_t*)%s_data)\n", image->name, image->name);
}
else
{
fprintf(fdh, "#define %s ((gfx_sprite_t*)%s_data)\n", image->name, image->name);
}
fprintf(fdh, "#define %s ((%s*)%s_data)\n",
image->name,
image->rlet ? "gfx_rletsprite_t" : "gfx_sprite_t",
image->name);
fprintf(fdh, "extern unsigned char %s_data[%d];\n", image->name, image->size);
}

Expand Down Expand Up @@ -203,9 +199,10 @@ int output_c_tileset(tileset_t *tileset)
tileset->image.name,
i,
tile->size);
fprintf(fdh, "#define %s_tile_%d ((gfx_sprite_t*)%s_tile_%d_data)\n",
fprintf(fdh, "#define %s_tile_%d ((%s*)%s_tile_%d_data)\n",
tileset->image.name,
i,
tileset->rlet ? "gfx_rletsprite_t" : "gfx_sprite_t",
tileset->image.name,
i);
}
Expand All @@ -229,8 +226,9 @@ int output_c_tileset(tileset_t *tileset)
tileset->image.name,
tileset->numTiles);

fprintf(fdh, "#define %s_tiles ((gfx_sprite_t**)%s_tiles_data)\n",
fprintf(fdh, "#define %s_tiles ((%s**)%s_tiles_data)\n",
tileset->image.name,
tileset->rlet ? "gfx_rletsprite_t" : "gfx_sprite_t",
tileset->image.name);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/tileset.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ typedef struct

/* set by convert */
bool compressed;
bool rlet;

/* set by output */
int appvarIndex;
Expand Down

0 comments on commit 615ac1c

Please sign in to comment.