fixup
This commit is contained in:
@@ -192,16 +192,39 @@ void SplashPackLoader::LoadSplashpack(uint8_t *data, SplashpackSceneSetup &setup
|
||||
for (uint16_t i = 0; i < header->textureAtlasCount; i++) {
|
||||
psxsplash::SPLASHPACKTextureAtlas *atlas = reinterpret_cast<psxsplash::SPLASHPACKTextureAtlas *>(cursor);
|
||||
uint8_t *offsetData = data + atlas->polygonsOffset;
|
||||
uint16_t *castedData = reinterpret_cast<uint16_t *>(offsetData);
|
||||
psxsplash::Renderer::GetInstance().VramUpload(castedData, atlas->x, atlas->y, atlas->width, atlas->height);
|
||||
// Ensure 4-byte alignment for DMA transfer. If the exporter
|
||||
// produced an unaligned offset, copy to an aligned temporary.
|
||||
uint32_t pixelBytes = (uint32_t)atlas->width * atlas->height * 2;
|
||||
if (reinterpret_cast<uintptr_t>(offsetData) & 3) {
|
||||
uint8_t* aligned = new uint8_t[(pixelBytes + 3) & ~3];
|
||||
__builtin_memcpy(aligned, offsetData, pixelBytes);
|
||||
psxsplash::Renderer::GetInstance().VramUpload(
|
||||
reinterpret_cast<uint16_t*>(aligned), atlas->x, atlas->y, atlas->width, atlas->height);
|
||||
delete[] aligned;
|
||||
} else {
|
||||
psxsplash::Renderer::GetInstance().VramUpload(
|
||||
reinterpret_cast<uint16_t*>(offsetData), atlas->x, atlas->y, atlas->width, atlas->height);
|
||||
}
|
||||
cursor += sizeof(psxsplash::SPLASHPACKTextureAtlas);
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < header->clutCount; i++) {
|
||||
psxsplash::SPLASHPACKClut *clut = reinterpret_cast<psxsplash::SPLASHPACKClut *>(cursor);
|
||||
uint8_t *clutOffset = data + clut->clutOffset;
|
||||
psxsplash::Renderer::GetInstance().VramUpload((uint16_t *)clutOffset, clut->clutPackingX * 16,
|
||||
// Same alignment guard for CLUT data.
|
||||
uint32_t clutBytes = (uint32_t)clut->length * 2;
|
||||
if (reinterpret_cast<uintptr_t>(clutOffset) & 3) {
|
||||
uint8_t* aligned = new uint8_t[(clutBytes + 3) & ~3];
|
||||
__builtin_memcpy(aligned, clutOffset, clutBytes);
|
||||
psxsplash::Renderer::GetInstance().VramUpload(
|
||||
reinterpret_cast<uint16_t*>(aligned), clut->clutPackingX * 16,
|
||||
clut->clutPackingY, clut->length, 1);
|
||||
delete[] aligned;
|
||||
} else {
|
||||
psxsplash::Renderer::GetInstance().VramUpload(
|
||||
reinterpret_cast<uint16_t*>(clutOffset), clut->clutPackingX * 16,
|
||||
clut->clutPackingY, clut->length, 1);
|
||||
}
|
||||
cursor += sizeof(psxsplash::SPLASHPACKClut);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user