Disable paletted textures for now
This commit is contained in:
@@ -12,50 +12,50 @@
|
||||
#include "util/endian.h"
|
||||
|
||||
errorret_t assetTextureLoad(assetentire_t entire) {
|
||||
assertNotNull(entire.data, "Data pointer cannot be NULL.");
|
||||
assertNotNull(entire.output, "Output pointer cannot be NULL.");
|
||||
// assertNotNull(entire.data, "Data pointer cannot be NULL.");
|
||||
// assertNotNull(entire.output, "Output pointer cannot be NULL.");
|
||||
|
||||
assettexture_t *assetData = (assettexture_t *)entire.data;
|
||||
texture_t *texture = (texture_t *)entire.output;
|
||||
// assettexture_t *assetData = (assettexture_t *)entire.data;
|
||||
// texture_t *texture = (texture_t *)entire.output;
|
||||
|
||||
// Read header and version (first 4 bytes)
|
||||
if(
|
||||
assetData->header[0] != 'D' ||
|
||||
assetData->header[1] != 'P' ||
|
||||
assetData->header[2] != 'T'
|
||||
) {
|
||||
errorThrow("Invalid texture header");
|
||||
}
|
||||
// // Read header and version (first 4 bytes)
|
||||
// if(
|
||||
// assetData->header[0] != 'D' ||
|
||||
// assetData->header[1] != 'P' ||
|
||||
// assetData->header[2] != 'T'
|
||||
// ) {
|
||||
// errorThrow("Invalid texture header");
|
||||
// }
|
||||
|
||||
// Version (can only be 1 atm)
|
||||
if(assetData->version != 0x01) {
|
||||
errorThrow("Unsupported texture version");
|
||||
}
|
||||
// // Version (can only be 1 atm)
|
||||
// if(assetData->version != 0x01) {
|
||||
// errorThrow("Unsupported texture version");
|
||||
// }
|
||||
|
||||
// Fix endian
|
||||
assetData->width = endianLittleToHost32(assetData->width);
|
||||
assetData->height = endianLittleToHost32(assetData->height);
|
||||
// // Fix endian
|
||||
// assetData->width = endianLittleToHost32(assetData->width);
|
||||
// assetData->height = endianLittleToHost32(assetData->height);
|
||||
|
||||
// Check dimensions.
|
||||
if(
|
||||
assetData->width == 0 || assetData->width > ASSET_TEXTURE_WIDTH_MAX ||
|
||||
assetData->height == 0 || assetData->height > ASSET_TEXTURE_HEIGHT_MAX
|
||||
) {
|
||||
errorThrow("Invalid texture dimensions");
|
||||
}
|
||||
// // Check dimensions.
|
||||
// if(
|
||||
// assetData->width == 0 || assetData->width > ASSET_TEXTURE_WIDTH_MAX ||
|
||||
// assetData->height == 0 || assetData->height > ASSET_TEXTURE_HEIGHT_MAX
|
||||
// ) {
|
||||
// errorThrow("Invalid texture dimensions");
|
||||
// }
|
||||
|
||||
textureInit(
|
||||
texture,
|
||||
assetData->width,
|
||||
assetData->height,
|
||||
TEXTURE_FORMAT_PALETTE,
|
||||
(texturedata_t){
|
||||
.paletted = {
|
||||
.indices = NULL,
|
||||
.palette = NULL
|
||||
}
|
||||
}
|
||||
);
|
||||
// textureInit(
|
||||
// texture,
|
||||
// assetData->width,
|
||||
// assetData->height,
|
||||
// TEXTURE_FORMAT_PALETTE,
|
||||
// (texturedata_t){
|
||||
// .paletted = {
|
||||
// .indices = NULL,
|
||||
// .palette = NULL
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
|
||||
errorOk();
|
||||
// errorOk();
|
||||
}
|
||||
@@ -40,26 +40,26 @@ errorret_t displayInit(void) {
|
||||
errorChain(textInit());
|
||||
errorChain(screenInit());
|
||||
|
||||
PALETTES[0].colors[0] = COLOR_RED;
|
||||
PALETTES[0].colors[1] = COLOR_GREEN;
|
||||
PALETTES[0].colors[2] = COLOR_BLUE;
|
||||
PALETTES[0].colors[3] = COLOR_WHITE;
|
||||
PALETTES[0].colors[4] = COLOR_MAGENTA;
|
||||
PALETTES[0].colors[5] = COLOR_CYAN;
|
||||
PALETTES[0].colors[6] = COLOR_YELLOW;
|
||||
PALETTES[0].colors[7] = COLOR_BLACK;
|
||||
PALETTES[0].count = 8;
|
||||
// PALETTES[0].colors[0] = COLOR_RED;
|
||||
// PALETTES[0].colors[1] = COLOR_GREEN;
|
||||
// PALETTES[0].colors[2] = COLOR_BLUE;
|
||||
// PALETTES[0].colors[3] = COLOR_WHITE;
|
||||
// PALETTES[0].colors[4] = COLOR_MAGENTA;
|
||||
// PALETTES[0].colors[5] = COLOR_CYAN;
|
||||
// PALETTES[0].colors[6] = COLOR_YELLOW;
|
||||
// PALETTES[0].colors[7] = COLOR_BLACK;
|
||||
// PALETTES[0].count = 8;
|
||||
|
||||
uint8_t indices[64] = {
|
||||
0,0,0,0,0,0,0,0,
|
||||
1,1,1,1,1,1,1,1,
|
||||
2,2,2,2,2,2,2,2,
|
||||
3,3,3,3,3,3,3,3,
|
||||
4,4,4,4,4,4,4,4,
|
||||
5,5,5,5,5,5,5,5,
|
||||
6,6,6,6,6,6,6,6,
|
||||
7,7,7,7,7,7,7,7
|
||||
};
|
||||
// uint8_t indices[64] = {
|
||||
// 0,0,0,0,0,0,0,0,
|
||||
// 1,1,1,1,1,1,1,1,
|
||||
// 2,2,2,2,2,2,2,2,
|
||||
// 3,3,3,3,3,3,3,3,
|
||||
// 4,4,4,4,4,4,4,4,
|
||||
// 5,5,5,5,5,5,5,5,
|
||||
// 6,6,6,6,6,6,6,6,
|
||||
// 7,7,7,7,7,7,7,7
|
||||
// };
|
||||
|
||||
// errorChain(textureInit(
|
||||
// &PALETTE_TEXTURE,
|
||||
|
||||
@@ -26,7 +26,6 @@ typedef union texturedata_u {
|
||||
palette_t *palette;
|
||||
} paletted;
|
||||
color_t *rgbaColors;
|
||||
uint8_t *compressedData;
|
||||
} texturedata_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,83 +69,6 @@ errorret_t textureInitDolphin(
|
||||
break;
|
||||
}
|
||||
|
||||
case TEXTURE_FORMAT_RGB4A3: {
|
||||
assertUnreachable("RGB4A3 texture format not yet implemented");
|
||||
}
|
||||
|
||||
case TEXTURE_FORMAT_RGB5: {
|
||||
assertUnreachable("RGB5 texture format not yet implemented");
|
||||
}
|
||||
|
||||
// assertTrue(
|
||||
// (width % 4) == 0 && (height % 4) == 0,
|
||||
// "RGB4A3 requires w/h multiple of 4 (or pad)"
|
||||
// );
|
||||
|
||||
// // Convert to RGB4A3 format
|
||||
// size_t rgbaSize = width * height * sizeof(u16);
|
||||
// texture->rgba = (u16*)memalign(32, rgbaSize);
|
||||
// assertNotNull(texture->rgba, "Failed to allocate texture RGBA data");
|
||||
|
||||
// for(uint32_t y = 0; y < height; ++y) {
|
||||
// for(uint32_t x = 0; x < width; ++x) {
|
||||
// const int src = y * width + x;
|
||||
|
||||
// const int tileX = x >> 2;
|
||||
// const int tileY = y >> 2;
|
||||
// const int tilesPerRow = width >> 2;
|
||||
// const int tileIndex = tileY * tilesPerRow + tileX;
|
||||
// const int tileBaseWords = tileIndex * 16;
|
||||
// const int inTile = ((y & 3) << 2) + (x & 3);
|
||||
// const int dest = tileBaseWords + inTile;
|
||||
|
||||
// color4b_t col = data.rgbaColors[src];
|
||||
|
||||
// u16 outCol;
|
||||
// if(col.a < 255) {
|
||||
// // 0AAA RRRR GGGG BBBB
|
||||
// outCol = (
|
||||
// (0u << 15) |
|
||||
// ((u16)(col.a >> 5) << 12) |
|
||||
// ((u16)(col.r >> 4) << 8) |
|
||||
// ((u16)(col.g >> 4) << 4) |
|
||||
// ((u16)(col.b >> 4) << 0)
|
||||
// );
|
||||
// } else {
|
||||
// // 1RRRR RRGG GGGB BBBB
|
||||
// outCol = (
|
||||
// (1u << 15) |
|
||||
// ((u16)(col.r >> 3) << 10) |
|
||||
// ((u16)(col.g >> 3) << 5) |
|
||||
// ((u16)(col.b >> 3) << 0)
|
||||
// );
|
||||
// }
|
||||
// texture->rgba[dest] = outCol;
|
||||
// }
|
||||
// }
|
||||
|
||||
// DCFlushRange(texture->rgba, rgbaSize);
|
||||
// GX_InitTexObj(
|
||||
// &texture->texObj,
|
||||
// texture->rgba,
|
||||
// width, height,
|
||||
// GX_TF_RGB5A3,
|
||||
// GX_REPEAT, GX_REPEAT,
|
||||
// GX_FALSE
|
||||
// );
|
||||
|
||||
// DCFlushRange(texture->rgba, rgbaSize);
|
||||
// GX_InvalidateTexAll();
|
||||
|
||||
// GX_InitTexObjLOD(
|
||||
// &texture->texObj,
|
||||
// GX_NEAR, GX_NEAR,
|
||||
// 0.0f, 0.0f, 0.0f,
|
||||
// GX_FALSE,
|
||||
// GX_FALSE,
|
||||
// GX_ANISO_1
|
||||
// );
|
||||
|
||||
case TEXTURE_FORMAT_PALETTE: {
|
||||
assertUnreachable("Paletted textures not yet implemented for Dolphin");
|
||||
break;
|
||||
@@ -171,18 +94,18 @@ errorret_t textureDisposeDolphin(texturedolphin_t *texture) {
|
||||
break;
|
||||
}
|
||||
|
||||
case TEXTURE_FORMAT_RGB4A3: {
|
||||
assertUnreachable("RGB4A3 texture format not yet implemented");
|
||||
}
|
||||
// case TEXTURE_FORMAT_RGB4A3: {
|
||||
// assertUnreachable("RGB4A3 texture format not yet implemented");
|
||||
// }
|
||||
|
||||
case TEXTURE_FORMAT_RGB5: {
|
||||
assertUnreachable("RGB5 texture format not yet implemented");
|
||||
}
|
||||
// case TEXTURE_FORMAT_RGB5: {
|
||||
// assertUnreachable("RGB5 texture format not yet implemented");
|
||||
// }
|
||||
|
||||
case TEXTURE_FORMAT_PALETTE: {
|
||||
assertUnreachable("Paletted textures not yet implemented for Dolphin");
|
||||
break;
|
||||
}
|
||||
// case TEXTURE_FORMAT_PALETTE: {
|
||||
// assertUnreachable("Paletted textures not yet implemented for Dolphin");
|
||||
// break;
|
||||
// }
|
||||
|
||||
default: {
|
||||
assertUnreachable("Unsupported texture format for Dolphin");
|
||||
|
||||
@@ -12,9 +12,9 @@ typedef union texturedata_u texturedata_t;
|
||||
|
||||
typedef enum {
|
||||
TEXTURE_FORMAT_RGBA = GX_TF_RGBA8,
|
||||
TEXTURE_FORMAT_PALETTE = GX_TF_CI8,
|
||||
TEXTURE_FORMAT_RGB4A3 = GX_TF_RGB5A3,
|
||||
TEXTURE_FORMAT_RGB5 = GX_TF_RGB565,
|
||||
// TEXTURE_FORMAT_PALETTE = GX_TF_CI8,
|
||||
// TEXTURE_FORMAT_RGB4A3 = GX_TF_RGB5A3,
|
||||
// TEXTURE_FORMAT_RGB5 = GX_TF_RGB565,
|
||||
} textureformatdolphin_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
Reference in New Issue
Block a user