Im running this on a Teensy 4.1 which has a builtin SD card, bang for buck these have massive perfomance and great support, only downside is no hardware debugging.
I have come up with a reasonable compromise which uses EVE_memWrite_sram_buffer, and a small 2KB buffer for streaming.
I simply read all raw data files (from EAB) into RAM_G from the SD card at startup. As the raw data does not include the data structure (width, height, format etc) I encode this into the file name and decode and store in a small asset manager data structure on startup.
I've not explored the inflate options, but I suspect that you would still need to reserve the same size uncompressed / raw image size in RAM_G? So apart from smaller image files, no real gain to be had, but I might (hopefully) be wrong!
I have come up with a reasonable compromise which uses EVE_memWrite_sram_buffer, and a small 2KB buffer for streaming.
I simply read all raw data files (from EAB) into RAM_G from the SD card at startup. As the raw data does not include the data structure (width, height, format etc) I encode this into the file name and decode and store in a small asset manager data structure on startup.
I've not explored the inflate options, but I suspect that you would still need to reserve the same size uncompressed / raw image size in RAM_G? So apart from smaller image files, no real gain to be had, but I might (hopefully) be wrong!
Code Select
struct AssetData
{
char name[32];
int width;
int height;
// when decoding filename, we expect the format and compression to be in the filename, e.g., "my_image_1024x600_ASTC_8X8.raw"
char format[16]; // e.g., "ASTC"
char compression[16]; // e.g., "8X8"
bool isValid;
uint32_t eveFormat; // EVE format for this asset, e.g., EVE_COMPRESSED_RGBA_ASTC_8x8_KHR
uint32_t eveAddress; // Start address in RAM_G (4-byte aligned)
uint32_t eveSize; // Total size of the asset in bytes
}; // AssetData
uint32_t GetEveFormat(const char *formatStr, const char *compressionStr)
{
if (strcmp(formatStr, "ASTC") == 0)
{
if (strcmp(compressionStr, "4x4") == 0)
return EVE_COMPRESSED_RGBA_ASTC_4x4_KHR;
if (strcmp(compressionStr, "5x4") == 0)
return EVE_COMPRESSED_RGBA_ASTC_5x4_KHR;
if (strcmp(compressionStr, "5x5") == 0)
return EVE_COMPRESSED_RGBA_ASTC_5x5_KHR;
if (strcmp(compressionStr, "6x5") == 0)
return EVE_COMPRESSED_RGBA_ASTC_6x5_KHR;
if (strcmp(compressionStr, "6x6") == 0)
return EVE_COMPRESSED_RGBA_ASTC_6x6_KHR;
if (strcmp(compressionStr, "8x5") == 0)
return EVE_COMPRESSED_RGBA_ASTC_8x5_KHR;
if (strcmp(compressionStr, "8x6") == 0)
return EVE_COMPRESSED_RGBA_ASTC_8x6_KHR;
if (strcmp(compressionStr, "8x8") == 0)
return EVE_COMPRESSED_RGBA_ASTC_8x8_KHR;
if (strcmp(compressionStr, "10x5") == 0)
return EVE_COMPRESSED_RGBA_ASTC_10x5_KHR;
if (strcmp(compressionStr, "10x6") == 0)
return EVE_COMPRESSED_RGBA_ASTC_10x6_KHR;
if (strcmp(compressionStr, "10x8") == 0)
return EVE_COMPRESSED_RGBA_ASTC_10x8_KHR;
if (strcmp(compressionStr, "10x10") == 0)
return EVE_COMPRESSED_RGBA_ASTC_10x10_KHR;
if (strcmp(compressionStr, "12x10") == 0)
return EVE_COMPRESSED_RGBA_ASTC_12x10_KHR;
if (strcmp(compressionStr, "12x12") == 0)
return EVE_COMPRESSED_RGBA_ASTC_12x12_KHR;
return EVE_COMPRESSED_RGBA_ASTC_8x8_KHR;
}
if (strcmp(formatStr, "RGB332") == 0)
return EVE_RGB332;
if (strcmp(formatStr, "RGB565") == 0)
return EVE_RGB565;
if (strcmp(formatStr, "L1") == 0)
return EVE_L1;
if (strcmp(formatStr, "L2") == 0)
return EVE_L2;
if (strcmp(formatStr, "L4") == 0)
return EVE_L4;
if (strcmp(formatStr, "L8") == 0)
return EVE_L8;
// Default fallback
return EVE_RGB565;
} // GetEveFormat
AssetData ParseAssetFilename(const char *inputFilename)
{
AssetData meta = {"", 0, 0, "", "", false};
char buffer[128];
strncpy(buffer, inputFilename, sizeof(buffer) - 1);
buffer[sizeof(buffer) - 1] = '\0';
// 1. Get the Name
char *namePart = strtok(buffer, "_");
if (namePart)
strncpy(meta.name, namePart, 31);
// 2. Get the Resolution string (e.g., "448x456")
char *resPart = strtok(NULL, "_");
// 3. Get the Format (e.g., "ASTC")
char *formatPart = strtok(NULL, "_");
if (formatPart)
strncpy(meta.format, formatPart, 15);
// 4. Get the Compression (e.g., "8X8.raw" -> "8X8")
char *compPart = strtok(NULL, ".");
if (compPart)
strncpy(meta.compression, compPart, 15);
meta.eveFormat = GetEveFormat(meta.format, meta.compression);
// Now, safely parse the resolution string separately
if (resPart)
{
char *wStr = strtok(resPart, "x");
char *hStr = strtok(NULL, "x");
if (wStr && hStr)
{
meta.width = atoi(wStr);
meta.height = atoi(hStr);
}
}
meta.isValid = true;
return meta;
} // ParseAssetFilename
void StreamRawFileToEVE(SdFile &file, uint32_t dest_ramg_address)
{
uint8_t buffer[2048]; // 2KB buffer for streaming
int bytesRead;
while ((bytesRead = file.read(buffer, sizeof(buffer))) > 0)
{
EVE_memWrite_sram_buffer(dest_ramg_address, buffer, bytesRead);
dest_ramg_address += bytesRead;
}
} // StreamRawFileToEVE