comparison tools/lib64fmts.c @ 1577:632f1dbc83eb

Get rid of some code duplication by merging functionality of certain pixel decoding functions into the generic one.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 13 May 2018 09:50:13 +0300
parents 2a9d0431e7b4
children fb60abb09a65
comparison
equal deleted inserted replaced
1576:e5be5235e7e1 1577:632f1dbc83eb
247 static Uint8 fmtGetPixelTruePaint( 247 static Uint8 fmtGetPixelTruePaint(
248 const DMC64Image *img, const int bmoffs, const int scroffs, 248 const DMC64Image *img, const int bmoffs, const int scroffs,
249 const int vshift, const int vbitmap, const int raster) 249 const int vshift, const int vbitmap, const int raster)
250 { 250 {
251 (void) raster; 251 (void) raster;
252 return dmC64GetGenericMCPixel(img, bmoffs, scroffs, vshift, 0, vbitmap, 0); 252 return dmC64GetGenericMCPixel(img, bmoffs, scroffs, vshift, 0, vbitmap, 0, img->bgcolor);
253 } 253 }
254 254
255 255
256 #define XX2_MIN_SIZE 4000 256 #define XX2_MIN_SIZE 4000
257 257
402 { 402 {
403 vb = 0; 403 vb = 0;
404 vr = raster - 100; 404 vr = raster - 100;
405 } 405 }
406 406
407 switch ((img->bitmap[vbitmap][bmoffs] >> vshift) & 3) 407 return dmC64GetGenericMCPixel(
408 { 408 img, bmoffs, scroffs, vshift,
409 case 0: return img->extraData[vb][vr] & 15; break; 409 vbank, vbitmap, 0,
410 case 1: return img->screen[vbank][scroffs] >> 4; break; 410 img->extraData[vb][vr] & 15);
411 case 2: return img->screen[vbank][scroffs] & 15; break;
412 default: return img->color[0][scroffs] & 15; break;
413 }
414 } 411 }
415 412
416 413
417 static Uint8 fmtGetPixelGunPaint( 414 static Uint8 fmtGetPixelGunPaint(
418 const DMC64Image *img, const int bmoffs, const int scroffs, 415 const DMC64Image *img, const int bmoffs, const int scroffs,
429 { 426 {
430 vb = 0; 427 vb = 0;
431 vr = raster - 177; 428 vr = raster - 177;
432 } 429 }
433 430
434 switch ((img->bitmap[vbitmap][bmoffs] >> vshift) & 3) 431 return dmC64GetGenericMCPixel(
435 { 432 img, bmoffs, scroffs, vshift,
436 case 0: return img->extraData[vb][vr] & 15; break; 433 vbank, vbitmap, 0,
437 case 1: return img->screen[vbank][scroffs] >> 4; break; 434 img->extraData[vb][vr] & 15);
438 case 2: return img->screen[vbank][scroffs] & 15; break;
439 default: return img->color[0][scroffs] & 15; break;
440 }
441 } 435 }
442 436
443 437
444 static Uint8 fmtGetPixelBMFLI( 438 static Uint8 fmtGetPixelBMFLI(
445 const DMC64Image *img, const int bmoffs, const int scroffs, 439 const DMC64Image *img, const int bmoffs, const int scroffs,
446 const int vshift, const int vbitmap, const int raster) 440 const int vshift, const int vbitmap, const int raster)
447 { 441 {
448 const int vbank = raster & 7; 442 const int vbank = raster & 7;
449 switch ((img->bitmap[vbitmap][bmoffs] >> vshift) & 3) 443
450 { 444 return dmC64GetGenericMCPixel(
451 case 0: return img->extraData[0][raster]; break; 445 img, bmoffs, scroffs, vshift,
452 case 1: return img->screen[vbank][scroffs] >> 4; break; 446 vbank, vbitmap, 0,
453 case 2: return img->screen[vbank][scroffs] & 15; break; 447 img->extraData[0][raster] & 15);
454 default: return img->color[0][scroffs] & 15; break;
455 }
456 } 448 }
457 449
458 450
459 static Uint8 fmtGetPixelFLIDesigner( 451 static Uint8 fmtGetPixelFLIDesigner(
460 const DMC64Image *img, const int bmoffs, const int scroffs, 452 const DMC64Image *img, const int bmoffs, const int scroffs,
461 const int vshift, const int vbitmap, const int raster) 453 const int vshift, const int vbitmap, const int raster)
462 { 454 {
463 return dmC64GetGenericMCPixel(img, bmoffs, scroffs, vshift, raster & 7, vbitmap, 0); 455 return dmC64GetGenericMCPixel(img, bmoffs, scroffs, vshift, raster & 7, vbitmap, 0, img->bgcolor);
464 } 456 }
465 457
466 458
467 static Uint8 fmtGetPixelCHFLI( 459 static Uint8 fmtGetPixelCHFLI(
468 const DMC64Image *img, const int bmoffs, const int scroffs, 460 const DMC64Image *img, const int bmoffs, const int scroffs,