haveyourcake but it works

This commit is contained in:
Cheezepin
2021-07-15 11:33:37 -07:00
parent 191835c43b
commit 18b562cd85
9 changed files with 2373 additions and 584 deletions

View File

@@ -49,8 +49,8 @@ static const ImageProps IMAGE_PROPERTIES[ImageType_MAX][2] = {
{256, 256, 32, 32, 8, 8, true, true},
},
[Cake] = {
{316, 228, 79, 19, 4, 12, false, false},
{320, 240, 80, 20, 4, 12, false, false},
{316, 228, 63, 29, 5, 8, false, false},
{320, 240, 64, 30, 5, 8, false, false},
},
[CakeEU] = {
{320, 224, 64, 32, 5, 7, false, false},
@@ -64,7 +64,7 @@ typedef struct {
static const TableDimension TABLE_DIMENSIONS[ImageType_MAX] = {
[Skybox] = {8, 10},
[Cake] = {4, 12},
[Cake] = {5, 8},
[CakeEU] = {5, 7},
};
@@ -106,15 +106,29 @@ static void split_tile(int col, int row, rgba *image, bool expanded) {
int tileWidth = props.tileWidth;
int tileHeight = props.tileHeight;
int imageWidth = props.imageWidth;
int imageHeight = props.imageHeight;
int numCols = props.numCols;
int expandedWidth = IMAGE_PROPERTIES[type][true].tileWidth;
rgba black = {0, 0, 0, 0};
for (int y = 0; y < tileHeight; y++) {
for (int x = 0; x < tileWidth; x++) {
int ny = row * tileHeight + y;
int nx = col * tileWidth + x;
tiles[row * numCols + col].px[y * expandedWidth + x] = image[(ny * imageWidth + nx)];
if(type == CakeEU) {
tiles[row * numCols + col].px[y * expandedWidth + x] = image[(ny * imageWidth + nx)];
} else {
if (nx < imageWidth && ny < imageHeight)
{
tiles[row * numCols + col].px[y * expandedWidth + x] = image[(ny * imageWidth + nx)];
}
else
{
tiles[row * numCols + col].px[y * expandedWidth + x] = black;
}
}
}
}
}
@@ -333,17 +347,24 @@ static void write_cake_c() {
FILE *cFile = fopen(buffer, "w");
const char *euSuffx = "";
if (type == CakeEU) {
euSuffx = "eu_";
}
int numTiles = TABLE_DIMENSIONS[type].cols * TABLE_DIMENSIONS[type].rows;
for (int i = 0; i < numTiles; ++i) {
fprintf(cFile, "ALIGNED8 static const Texture cake_end_texture_%s%d[] = {\n", euSuffx, i);
print_raw_data(cFile, &tiles[i]);
if (type == CakeEU) {
for (int i = 0; i < numTiles; ++i) {
fprintf(cFile, "ALIGNED8 static const Texture cake_end_texture_eu_%d[] = {\n", i);
print_raw_data(cFile, &tiles[i]);
fputs("};\n\n", cFile);
}
} else {
fprintf(cFile, "ALIGNED8 static const u8 cake_end_texture_data[] = {\n");
for (int i = 0; i < numTiles; ++i) {
print_raw_data(cFile, &tiles[i]);
fputc(',', cFile);
fputc('\n', cFile);
}
fputs("};\n\n", cFile);
}
fclose(cFile);
}
@@ -654,4 +675,4 @@ int main(int argc, char *argv[]) {
return EXIT_SUCCESS;
}
}

657
tools/skyconv.c.orig Normal file

File diff suppressed because it is too large Load Diff