comparison tools/lib64gfx.c @ 1513:181163a6dd24

Remove insane troll logic from dmC64GetOpSize().
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 May 2018 22:26:17 +0300
parents ee691fbf8f27
children 24b8b452925e
comparison
equal deleted inserted replaced
1512:ee691fbf8f27 1513:181163a6dd24
484 } 484 }
485 485
486 486
487 static BOOL dmC64GetOpSize(const DMC64EncDecOp *op, const DMC64ImageFormat *fmt, size_t *size) 487 static BOOL dmC64GetOpSize(const DMC64EncDecOp *op, const DMC64ImageFormat *fmt, size_t *size)
488 { 488 {
489 BOOL check;
490 switch (op->type) 489 switch (op->type)
491 { 490 {
492 case DT_SCREEN_RAM: 491 case DT_SCREEN_RAM:
493 case DT_COLOR_RAM: 492 case DT_COLOR_RAM:
494 *size = fmt->chHeight * fmt->chWidth; 493 *size = fmt->chHeight * fmt->chWidth;
495 check = TRUE;
496 break; 494 break;
497 495
498 case DT_BITMAP: 496 case DT_BITMAP:
499 *size = fmt->chHeight * fmt->chWidth * 8; 497 *size = fmt->chHeight * fmt->chWidth * 8;
500 check = TRUE;
501 break; 498 break;
502 499
503 case DT_EXTRA_DATA: 500 case DT_EXTRA_DATA:
504 *size = op->size; 501 *size = op->size;
505 check = TRUE;
506 break; 502 break;
507 503
508 case DT_CHAR_DATA: 504 case DT_CHAR_DATA:
509 *size = C64_MAX_CHARS * C64_CHR_SIZE; 505 *size = C64_MAX_CHARS * C64_CHR_SIZE;
510 check = TRUE;
511 break; 506 break;
512 507
513 case DT_COLOR_REG: 508 case DT_COLOR_REG:
514 *size = 1; 509 *size = 0;
515 check = FALSE;
516 break; 510 break;
517 511
518 default: 512 default:
519 *size = 0; 513 *size = 0;
520 check = FALSE;
521 }
522
523 if (op->size != 0)
524 {
525 if (check && op->size > *size)
526 return FALSE;
527
528 *size = op->size;
529 } 514 }
530 515
531 return TRUE; 516 return TRUE;
532 } 517 }
533 518