MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / ReadCompressionByte

Function ReadCompressionByte

Descent3/LoadLevel.cpp:2365–2396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2363}
2364
2365void ReadCompressionByte(CFILE *fp, uint8_t *vals, int total) {
2366 int count = 0;
2367 uint8_t compressed = cf_ReadByte(fp);
2368
2369 if (compressed == 0) {
2370 for (int i = 0; i < total; i++)
2371 vals[i] = cf_ReadByte(fp);
2372
2373 return;
2374 }
2375
2376 while (count != total) {
2377 ASSERT(count < total);
2378 uint8_t command = cf_ReadByte(fp);
2379
2380 if (command == 0) // next byte is raw
2381 {
2382 uint8_t height = cf_ReadByte(fp);
2383
2384 vals[count] = height;
2385 count++;
2386 } else if (command >= 2 && command <= 250) // next pixel is run of pixels
2387 {
2388 uint8_t height = cf_ReadByte(fp);
2389 for (int k = 0; k < command; k++) {
2390 vals[count] = height;
2391 count++;
2392 }
2393 } else
2394 Int3(); // bad compression run
2395 }
2396}
2397
2398void ReadCompressionShort(CFILE *fp, uint16_t *vals, int total) {
2399 int count = 0;

Callers 4

ReadRoomFunction · 0.85
ReadTerrainHeightChunkFunction · 0.85
ReadTerrainTmapFlagChunkFunction · 0.85

Calls 1

cf_ReadByteFunction · 0.85

Tested by

no test coverage detected