| 2363 | } |
| 2364 | |
| 2365 | void 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 | |
| 2398 | void ReadCompressionShort(CFILE *fp, uint16_t *vals, int total) { |
| 2399 | int count = 0; |
no test coverage detected