@@ -256,6 +256,9 @@ class SPR2ChunkData(
256256 buffer.writeShortLe(sprite.imageData.width)
257257 buffer.writeShortLe(sprite.imageData.height)
258258 buffer.writeShortLe(sprite.flags)
259+ if (sprite.flags != 1 .toShort() && sprite.flags != 3 .toShort() && sprite.flags != 7 .toShort())
260+ error(" Unsupported SPR2 flag! ${sprite.flags} " )
261+
259262 buffer.writeShortLe(sprite.unknown)
260263 buffer.writeShortLe(sprite.overridenPaletteId)
261264 buffer.writeShortLe(sprite.transparentPixelPaletteIndexId)
@@ -286,11 +289,25 @@ class SPR2ChunkData(
286289 if (pixelData.alphaBlending == 0u .toUByte()) {
287290 pixelCommandBuffer.writeUShortLe(SPR2Utils .packSectionHeader(0x03 , 1 ))
288291 } else {
289- pixelCommandBuffer.writeUShortLe(SPR2Utils .packSectionHeader(0x06 , 1 ))
290- pixelCommandBuffer.writeUByte(pixelData.paletteIndex)
291-
292- // It is always odd
293- pixelCommandBuffer.writeUByte(176u ) // Padding if odd
292+ if (sprite.flags == 1 .toShort()) {
293+ pixelCommandBuffer.writeUShortLe(SPR2Utils .packSectionHeader(0x06 , 1 ))
294+ pixelCommandBuffer.writeUByte(pixelData.paletteIndex)
295+
296+ // It is always odd
297+ pixelCommandBuffer.writeUByte(176u ) // Padding if odd
298+ } else if (sprite.flags == 3 .toShort()) {
299+ pixelCommandBuffer.writeUShortLe(SPR2Utils .packSectionHeader(0x01 , 1 ))
300+ pixelCommandBuffer.writeUByte(pixelData.depthBuffer)
301+ pixelCommandBuffer.writeUByte(pixelData.paletteIndex)
302+ } else if (sprite.flags == 7 .toShort()) {
303+ pixelCommandBuffer.writeUShortLe(SPR2Utils .packSectionHeader(0x02 , 1 ))
304+ pixelCommandBuffer.writeUByte(pixelData.depthBuffer)
305+ pixelCommandBuffer.writeUByte(pixelData.paletteIndex)
306+ pixelCommandBuffer.writeUByte(pixelData.alphaBlending)
307+
308+ // It is always odd
309+ pixelCommandBuffer.writeUByte(176u ) // Padding if odd
310+ }
294311 }
295312 }
296313
0 commit comments