static ILboolean ParseChunks(PSP_CTX *ctx) { BLOCKHEAD Block; ILuint Pos; do { if (SIOread(ctx->io, &Block, 1, sizeof(Block)) != sizeof(Block)) { iPopError(); // Get rid of the erroneous IL_FILE_READ_ERROR. break; } if (ctx->Header.MajorVersion == 3) { Block.BlockLen = GetLittleUInt(ctx->io); } else { UInt(&Block.BlockLen); } if ( Block.HeadID[0] != 0x7E || Block.HeadID[1] != 0x42 || Block.HeadID[2] != 0x4B || Block.HeadID[3] != 0x00 ) { break; } UShort(&Block.BlockID); UInt(&Block.BlockLen); Pos = SIOtell(ctx->io); switch (Block.BlockID) { case PSP_LAYER_START_BLOCK: if (!ReadLayerBlock(ctx)) return IL_FALSE; break; case PSP_ALPHA_BANK_BLOCK: if (!ReadAlphaBlock(ctx)) return IL_FALSE; break; case PSP_COLOR_BLOCK: if (!ReadPalette(ctx)) return IL_FALSE; break; // Gets done in the next iseek, so this is now commented out. //default: //SIOseek(ctx->io, Block.BlockLen, IL_SEEK_CUR); } // Skip to next block just in case we didn't read the entire block. SIOseek(ctx->io, Pos + Block.BlockLen, IL_SEEK_SET); // @TODO: Do stuff here. } while (1); return IL_TRUE; }
ILboolean ParseChunks(PspLoadState* state, ILimage* image) { BLOCKHEAD Block; do { if (image->io.read(&image->io, &Block, 1, sizeof(Block)) != sizeof(Block)) { il2GetError(); // Get rid of the erroneous IL_FILE_READ_ERROR. return IL_TRUE; } if (state->Header.MajorVersion == 3) Block.BlockLen = GetLittleUInt(&image->io); else UInt(&Block.BlockLen); if (Block.HeadID[0] != 0x7E || Block.HeadID[1] != 0x42 || Block.HeadID[2] != 0x4B || Block.HeadID[3] != 0x00) { return IL_TRUE; } UShort(&Block.BlockID); UInt(&Block.BlockLen); auto Pos = image->io.tell(&image->io); switch (Block.BlockID) { case PSP_LAYER_START_BLOCK: if (!ReadLayerBlock(state, Block.BlockLen, image)) return IL_FALSE; break; case PSP_ALPHA_BANK_BLOCK: if (!ReadAlphaBlock(state, Block.BlockLen, image)) return IL_FALSE; break; case PSP_COLOR_BLOCK: if (!ReadPalette(state, Block.BlockLen, image)) return IL_FALSE; break; // Gets done in the next iseek, so this is now commented out. //default: //image->io.seek(&image->io, Block.BlockLen, IL_SEEK_CUR); } // Skip to next block just in case we didn't read the entire block. image->io.seek(&image->io, Pos + Block.BlockLen, IL_SEEK_SET); // @TODO: Do stuff here. } while (1); return IL_TRUE; }