Mercurial > hg > dmlib
comparison lib64gfx.c @ 508:1ed5025c2538
Return DMLIB error values instead of arbitrary 0/negatives.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 19 Nov 2012 13:50:10 +0200 |
parents | 272e64259fde |
children | 43ea59887c69 |
comparison
equal
deleted
inserted
replaced
507:272e64259fde | 508:1ed5025c2538 |
---|---|
439 | 439 |
440 if (op->bank < 0 || op->bank >= C64_SCR_MAX_BANK) | 440 if (op->bank < 0 || op->bank >= C64_SCR_MAX_BANK) |
441 { | 441 { |
442 dmError("Invalid bank %d definition in generic decode operator %d @ #%d.\n", | 442 dmError("Invalid bank %d definition in generic decode operator %d @ #%d.\n", |
443 op->bank, op->type, i); | 443 op->bank, op->type, i); |
444 return -1; | 444 return DMERR_INTERNAL; |
445 } | 445 } |
446 | 446 |
447 if (op->type < 0 || op->type >= DT_LAST) | 447 if (op->type < 0 || op->type >= DT_LAST) |
448 { | 448 { |
449 dmError("Invalid decode operator type %d @ #%d.\n", | 449 dmError("Invalid decode operator type %d @ #%d.\n", |
450 op->type, i); | 450 op->type, i); |
451 return -1; | 451 return DMERR_INTERNAL; |
452 } | 452 } |
453 | 453 |
454 size = (op->size == 0) ? dmC64DefaultSizes[op->type] : op->size; | 454 size = (op->size == 0) ? dmC64DefaultSizes[op->type] : op->size; |
455 | 455 |
456 if (op->offs + size > len) | 456 if (op->offs + size > len) |
457 { | 457 { |
458 dmError("Decode out of bounds, op #%d type=%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x\n", | 458 dmError("Decode out of bounds, op #%d type=%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x\n", |
459 i, op->type, op->offs, op->offs, op->bank, size, size, len, len); | 459 i, op->type, op->offs, op->offs, op->bank, size, size, len, len); |
460 return -2; | 460 return DMERR_INVALID_DATA; |
461 } | 461 } |
462 | 462 |
463 src = buf + op->offs; | 463 src = buf + op->offs; |
464 | 464 |
465 switch (op->type) | 465 switch (op->type) |
472 case DT_FUNCTION: | 472 case DT_FUNCTION: |
473 if (op->function == NULL) | 473 if (op->function == NULL) |
474 { | 474 { |
475 dmError("Decode op is a function, but function ptr is NULL: op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x\n", | 475 dmError("Decode op is a function, but function ptr is NULL: op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x\n", |
476 i, op->offs, op->offs, op->bank, size, size, len, len); | 476 i, op->offs, op->offs, op->bank, size, size, len, len); |
477 return -6; | 477 return DMERR_INTERNAL; |
478 } | 478 } |
479 if (!op->function(img, op, buf, len)) | 479 if (!op->function(img, op, buf, len)) |
480 { | 480 { |
481 dmError("Decode op custom function failed: op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x\n", | 481 dmError("Decode op custom function failed: op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x\n", |
482 i, op->offs, op->offs, op->bank, size, size, len, len); | 482 i, op->offs, op->offs, op->bank, size, size, len, len); |
483 return -5; | 483 return DMERR_INTERNAL; |
484 } | 484 } |
485 break; | 485 break; |
486 } | 486 } |
487 } | 487 } |
488 | 488 |
489 return 0; | 489 return DMERR_OK; |
490 } | 490 } |
491 | 491 |
492 | 492 |
493 static int dmC64ConvertHiResBMP(DMImage *screen, const DMC64Image *img) | 493 static int dmC64ConvertHiResBMP(DMImage *screen, const DMC64Image *img) |
494 { | 494 { |
520 } | 520 } |
521 | 521 |
522 dp += screen->pitch; | 522 dp += screen->pitch; |
523 } | 523 } |
524 | 524 |
525 return 0; | 525 return DMERR_OK; |
526 } | 526 } |
527 | 527 |
528 | 528 |
529 static int dmC64ConvertMultiColorBMP(DMImage *screen, const DMC64Image *img) | 529 static int dmC64ConvertMultiColorBMP(DMImage *screen, const DMC64Image *img) |
530 { | 530 { |
560 } | 560 } |
561 | 561 |
562 dp += screen->pitch; | 562 dp += screen->pitch; |
563 } | 563 } |
564 | 564 |
565 return 0; | 565 return DMERR_OK; |
566 } | 566 } |
567 | 567 |
568 | 568 |
569 static int dmC64ConvertLaceMultiColorBMP(DMImage *screen, const DMC64Image *img) | 569 static int dmC64ConvertLaceMultiColorBMP(DMImage *screen, const DMC64Image *img) |
570 { | 570 { |
610 } | 610 } |
611 | 611 |
612 dp += screen->pitch; | 612 dp += screen->pitch; |
613 } | 613 } |
614 | 614 |
615 return 0; | 615 return DMERR_OK; |
616 } | 616 } |
617 | 617 |
618 | 618 |
619 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src) | 619 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src) |
620 { | 620 { |