| 245 | |
| 246 | |
| 247 | ILboolean ParseChunks() |
| 248 | { |
| 249 | BLOCKHEAD Block; |
| 250 | ILuint Pos; |
| 251 | |
| 252 | do { |
| 253 | if (iread(&Block, 1, sizeof(Block)) != sizeof(Block)) { |
| 254 | ilGetError(); // Get rid of the erroneous IL_FILE_READ_ERROR. |
| 255 | return IL_TRUE; |
| 256 | } |
| 257 | if (Header.MajorVersion == 3) |
| 258 | Block.BlockLen = GetLittleUInt(); |
| 259 | else |
| 260 | UInt(&Block.BlockLen); |
| 261 | |
| 262 | if (Block.HeadID[0] != 0x7E || Block.HeadID[1] != 0x42 || |
| 263 | Block.HeadID[2] != 0x4B || Block.HeadID[3] != 0x00) { |
| 264 | return IL_TRUE; |
| 265 | } |
| 266 | UShort(&Block.BlockID); |
| 267 | UInt(&Block.BlockLen); |
| 268 | |
| 269 | Pos = itell(); |
| 270 | |
| 271 | switch (Block.BlockID) |
| 272 | { |
| 273 | case PSP_LAYER_START_BLOCK: |
| 274 | if (!ReadLayerBlock(Block.BlockLen)) |
| 275 | return IL_FALSE; |
| 276 | break; |
| 277 | |
| 278 | case PSP_ALPHA_BANK_BLOCK: |
| 279 | if (!ReadAlphaBlock(Block.BlockLen)) |
| 280 | return IL_FALSE; |
| 281 | break; |
| 282 | |
| 283 | case PSP_COLOR_BLOCK: |
| 284 | if (!ReadPalette(Block.BlockLen)) |
| 285 | return IL_FALSE; |
| 286 | break; |
| 287 | |
| 288 | // Gets done in the next iseek, so this is now commented out. |
| 289 | //default: |
| 290 | //iseek(Block.BlockLen, IL_SEEK_CUR); |
| 291 | } |
| 292 | |
| 293 | // Skip to next block just in case we didn't read the entire block. |
| 294 | iseek(Pos + Block.BlockLen, IL_SEEK_SET); |
| 295 | |
| 296 | // @TODO: Do stuff here. |
| 297 | |
| 298 | } while (1); |
| 299 | |
| 300 | return IL_TRUE; |
| 301 | } |
| 302 | |
| 303 | |
| 304 | ILboolean ReadLayerBlock(ILuint BlockLen) |
no test coverage detected