| 378 | |
| 379 | |
| 380 | ILboolean ReadAlphaBlock(ILuint BlockLen) |
| 381 | { |
| 382 | BLOCKHEAD Block; |
| 383 | ALPHAINFO_CHUNK AlphaInfo; |
| 384 | ALPHA_CHUNK AlphaChunk; |
| 385 | ILushort NumAlpha, StringSize; |
| 386 | ILuint ChunkSize, Padding; |
| 387 | |
| 388 | if (Header.MajorVersion == 3) { |
| 389 | NumAlpha = GetLittleUShort(); |
| 390 | } |
| 391 | else { |
| 392 | ChunkSize = GetLittleUInt(); |
| 393 | NumAlpha = GetLittleUShort(); |
| 394 | Padding = (ChunkSize - 4 - 2); |
| 395 | if (Padding > 0) |
| 396 | iseek(Padding, IL_SEEK_CUR); |
| 397 | } |
| 398 | |
| 399 | // Alpha channel header |
| 400 | if (iread(&Block, 1, sizeof(Block)) != sizeof(Block)) |
| 401 | return IL_FALSE; |
| 402 | if (Header.MajorVersion == 3) |
| 403 | Block.BlockLen = GetLittleUInt(); |
| 404 | else |
| 405 | UInt(&Block.BlockLen); |
| 406 | |
| 407 | if (Block.HeadID[0] != 0x7E || Block.HeadID[1] != 0x42 || |
| 408 | Block.HeadID[2] != 0x4B || Block.HeadID[3] != 0x00) { |
| 409 | return IL_FALSE; |
| 410 | } |
| 411 | if (Block.BlockID != PSP_ALPHA_CHANNEL_BLOCK) |
| 412 | return IL_FALSE; |
| 413 | |
| 414 | |
| 415 | if (Header.MajorVersion >= 4) { |
| 416 | ChunkSize = GetLittleUInt(); |
| 417 | StringSize = GetLittleUShort(); |
| 418 | iseek(StringSize, IL_SEEK_CUR); |
| 419 | if (iread(&AlphaInfo, sizeof(AlphaInfo), 1) != 1) |
| 420 | return IL_FALSE; |
| 421 | Padding = (ChunkSize - 4 - 2 - StringSize - sizeof(AlphaInfo)); |
| 422 | if (Padding > 0) |
| 423 | iseek(Padding, IL_SEEK_CUR); |
| 424 | |
| 425 | ChunkSize = GetLittleUInt(); |
| 426 | if (iread(&AlphaChunk, sizeof(AlphaChunk), 1) != 1) |
| 427 | return IL_FALSE; |
| 428 | Padding = (ChunkSize - 4 - sizeof(AlphaChunk)); |
| 429 | if (Padding > 0) |
| 430 | iseek(Padding, IL_SEEK_CUR); |
| 431 | } |
| 432 | else { |
| 433 | iseek(256, IL_SEEK_CUR); |
| 434 | iread(&AlphaInfo, sizeof(AlphaInfo), 1); |
| 435 | if (iread(&AlphaChunk, sizeof(AlphaChunk), 1) != 1) |
| 436 | return IL_FALSE; |
| 437 | } |
no test coverage detected