for (int i = 0; i < TILE_SZ; i+=4) {
for (int j = 0; j < 4; ++j) {
if (packed) { /* packed format */
+ //printf("%d %d ", ptr[0], ptr[1]);
if (ptr[0] >= 8 || ptr[1] >= 8)
fprintf(stdout, "warning: too many colors detected\n");
gfx->outpal[ptr[0]] = (gfx->palette[ptr[0]].r >> 4) << 8 |
buf[i+j] = ptr[0] << 4;
buf[i+j] |= ptr[1];
ptr += 2;
- } else { /* planar format */
+ } else { /* TODO: planar format */
for (int x = 0; x < 8; ++x) {
if (ptr[x] >= 8)
fprintf(stdout, "warning: too many colors detected\n");
}
if (!packed)
ptr += 8;
+ else {
+ ptr += (8 * (gfx->row_tiles-1));
+ }
}
}
goto close;
}
- unsigned nr_tiles = 1;
-
- for (int i = 0; i < nr_tiles; ++i) {
- generate_4bpp_tile(tile_buf, gfx, true);
- int ret = fwrite(tile_buf, sizeof(unsigned char), TILE_SZ, gfxstream);
- if (ret != TILE_SZ) {
- fprintf(stderr, "failed to convert, only write %d instead of %d\n", ret, TILE_SZ);
- goto cleanup;
+ for (int i = 0; i < gfx->row_tiles; ++i) {
+ for (int j = 0; j < gfx->col_tiles; ++j) {
+ //printf("row[%d]col[%d]\n",i,j);
+ generate_4bpp_tile(tile_buf, gfx, true);
+ int ret = fwrite(tile_buf, sizeof(unsigned char), TILE_SZ, gfxstream);
+ if (ret != TILE_SZ) {
+ fprintf(stderr, "failed to convert, only write %d instead of %d\n", ret, TILE_SZ);
+ goto cleanup;
+ }
+ gfx->data += 8; /* next column */
+ //printf("\n");
}
+ gfx->data += (gfx->col_tiles * 64) - 16;
}
palstream = fopen("out.pal", "w");