Disable paletted textures for now
This commit is contained in:
@@ -12,50 +12,50 @@
|
|||||||
#include "util/endian.h"
|
#include "util/endian.h"
|
||||||
|
|
||||||
errorret_t assetTextureLoad(assetentire_t entire) {
|
errorret_t assetTextureLoad(assetentire_t entire) {
|
||||||
assertNotNull(entire.data, "Data pointer cannot be NULL.");
|
// assertNotNull(entire.data, "Data pointer cannot be NULL.");
|
||||||
assertNotNull(entire.output, "Output pointer cannot be NULL.");
|
// assertNotNull(entire.output, "Output pointer cannot be NULL.");
|
||||||
|
|
||||||
assettexture_t *assetData = (assettexture_t *)entire.data;
|
// assettexture_t *assetData = (assettexture_t *)entire.data;
|
||||||
texture_t *texture = (texture_t *)entire.output;
|
// texture_t *texture = (texture_t *)entire.output;
|
||||||
|
|
||||||
// Read header and version (first 4 bytes)
|
// // Read header and version (first 4 bytes)
|
||||||
if(
|
// if(
|
||||||
assetData->header[0] != 'D' ||
|
// assetData->header[0] != 'D' ||
|
||||||
assetData->header[1] != 'P' ||
|
// assetData->header[1] != 'P' ||
|
||||||
assetData->header[2] != 'T'
|
// assetData->header[2] != 'T'
|
||||||
) {
|
// ) {
|
||||||
errorThrow("Invalid texture header");
|
// errorThrow("Invalid texture header");
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Version (can only be 1 atm)
|
// // Version (can only be 1 atm)
|
||||||
if(assetData->version != 0x01) {
|
// if(assetData->version != 0x01) {
|
||||||
errorThrow("Unsupported texture version");
|
// errorThrow("Unsupported texture version");
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Fix endian
|
// // Fix endian
|
||||||
assetData->width = endianLittleToHost32(assetData->width);
|
// assetData->width = endianLittleToHost32(assetData->width);
|
||||||
assetData->height = endianLittleToHost32(assetData->height);
|
// assetData->height = endianLittleToHost32(assetData->height);
|
||||||
|
|
||||||
// Check dimensions.
|
// // Check dimensions.
|
||||||
if(
|
// if(
|
||||||
assetData->width == 0 || assetData->width > ASSET_TEXTURE_WIDTH_MAX ||
|
// assetData->width == 0 || assetData->width > ASSET_TEXTURE_WIDTH_MAX ||
|
||||||
assetData->height == 0 || assetData->height > ASSET_TEXTURE_HEIGHT_MAX
|
// assetData->height == 0 || assetData->height > ASSET_TEXTURE_HEIGHT_MAX
|
||||||
) {
|
// ) {
|
||||||
errorThrow("Invalid texture dimensions");
|
// errorThrow("Invalid texture dimensions");
|
||||||
}
|
// }
|
||||||
|
|
||||||
textureInit(
|
// textureInit(
|
||||||
texture,
|
// texture,
|
||||||
assetData->width,
|
// assetData->width,
|
||||||
assetData->height,
|
// assetData->height,
|
||||||
TEXTURE_FORMAT_PALETTE,
|
// TEXTURE_FORMAT_PALETTE,
|
||||||
(texturedata_t){
|
// (texturedata_t){
|
||||||
.paletted = {
|
// .paletted = {
|
||||||
.indices = NULL,
|
// .indices = NULL,
|
||||||
.palette = NULL
|
// .palette = NULL
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
|
|
||||||
errorOk();
|
// errorOk();
|
||||||
}
|
}
|
||||||
@@ -40,26 +40,26 @@ errorret_t displayInit(void) {
|
|||||||
errorChain(textInit());
|
errorChain(textInit());
|
||||||
errorChain(screenInit());
|
errorChain(screenInit());
|
||||||
|
|
||||||
PALETTES[0].colors[0] = COLOR_RED;
|
// PALETTES[0].colors[0] = COLOR_RED;
|
||||||
PALETTES[0].colors[1] = COLOR_GREEN;
|
// PALETTES[0].colors[1] = COLOR_GREEN;
|
||||||
PALETTES[0].colors[2] = COLOR_BLUE;
|
// PALETTES[0].colors[2] = COLOR_BLUE;
|
||||||
PALETTES[0].colors[3] = COLOR_WHITE;
|
// PALETTES[0].colors[3] = COLOR_WHITE;
|
||||||
PALETTES[0].colors[4] = COLOR_MAGENTA;
|
// PALETTES[0].colors[4] = COLOR_MAGENTA;
|
||||||
PALETTES[0].colors[5] = COLOR_CYAN;
|
// PALETTES[0].colors[5] = COLOR_CYAN;
|
||||||
PALETTES[0].colors[6] = COLOR_YELLOW;
|
// PALETTES[0].colors[6] = COLOR_YELLOW;
|
||||||
PALETTES[0].colors[7] = COLOR_BLACK;
|
// PALETTES[0].colors[7] = COLOR_BLACK;
|
||||||
PALETTES[0].count = 8;
|
// PALETTES[0].count = 8;
|
||||||
|
|
||||||
uint8_t indices[64] = {
|
// uint8_t indices[64] = {
|
||||||
0,0,0,0,0,0,0,0,
|
// 0,0,0,0,0,0,0,0,
|
||||||
1,1,1,1,1,1,1,1,
|
// 1,1,1,1,1,1,1,1,
|
||||||
2,2,2,2,2,2,2,2,
|
// 2,2,2,2,2,2,2,2,
|
||||||
3,3,3,3,3,3,3,3,
|
// 3,3,3,3,3,3,3,3,
|
||||||
4,4,4,4,4,4,4,4,
|
// 4,4,4,4,4,4,4,4,
|
||||||
5,5,5,5,5,5,5,5,
|
// 5,5,5,5,5,5,5,5,
|
||||||
6,6,6,6,6,6,6,6,
|
// 6,6,6,6,6,6,6,6,
|
||||||
7,7,7,7,7,7,7,7
|
// 7,7,7,7,7,7,7,7
|
||||||
};
|
// };
|
||||||
|
|
||||||
// errorChain(textureInit(
|
// errorChain(textureInit(
|
||||||
// &PALETTE_TEXTURE,
|
// &PALETTE_TEXTURE,
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ typedef union texturedata_u {
|
|||||||
palette_t *palette;
|
palette_t *palette;
|
||||||
} paletted;
|
} paletted;
|
||||||
color_t *rgbaColors;
|
color_t *rgbaColors;
|
||||||
uint8_t *compressedData;
|
|
||||||
} texturedata_t;
|
} texturedata_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -69,83 +69,6 @@ errorret_t textureInitDolphin(
|
|||||||
break;
|
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: {
|
case TEXTURE_FORMAT_PALETTE: {
|
||||||
assertUnreachable("Paletted textures not yet implemented for Dolphin");
|
assertUnreachable("Paletted textures not yet implemented for Dolphin");
|
||||||
break;
|
break;
|
||||||
@@ -171,18 +94,18 @@ errorret_t textureDisposeDolphin(texturedolphin_t *texture) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TEXTURE_FORMAT_RGB4A3: {
|
// case TEXTURE_FORMAT_RGB4A3: {
|
||||||
assertUnreachable("RGB4A3 texture format not yet implemented");
|
// assertUnreachable("RGB4A3 texture format not yet implemented");
|
||||||
}
|
// }
|
||||||
|
|
||||||
case TEXTURE_FORMAT_RGB5: {
|
// case TEXTURE_FORMAT_RGB5: {
|
||||||
assertUnreachable("RGB5 texture format not yet implemented");
|
// assertUnreachable("RGB5 texture format not yet implemented");
|
||||||
}
|
// }
|
||||||
|
|
||||||
case TEXTURE_FORMAT_PALETTE: {
|
// case TEXTURE_FORMAT_PALETTE: {
|
||||||
assertUnreachable("Paletted textures not yet implemented for Dolphin");
|
// assertUnreachable("Paletted textures not yet implemented for Dolphin");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
assertUnreachable("Unsupported texture format for Dolphin");
|
assertUnreachable("Unsupported texture format for Dolphin");
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ typedef union texturedata_u texturedata_t;
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TEXTURE_FORMAT_RGBA = GX_TF_RGBA8,
|
TEXTURE_FORMAT_RGBA = GX_TF_RGBA8,
|
||||||
TEXTURE_FORMAT_PALETTE = GX_TF_CI8,
|
// TEXTURE_FORMAT_PALETTE = GX_TF_CI8,
|
||||||
TEXTURE_FORMAT_RGB4A3 = GX_TF_RGB5A3,
|
// TEXTURE_FORMAT_RGB4A3 = GX_TF_RGB5A3,
|
||||||
TEXTURE_FORMAT_RGB5 = GX_TF_RGB565,
|
// TEXTURE_FORMAT_RGB5 = GX_TF_RGB565,
|
||||||
} textureformatdolphin_t;
|
} textureformatdolphin_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user