comparison tools/lib64gfx.c @ 2343:94a653883a32

Change Uint8 pointer in getPixel functions to DMC64ScanLine pointer in preparation for future changes related to sprites on scanlines.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 25 Sep 2019 12:11:35 +0300
parents a56f3bcb5476
children 13e54305e5fc
comparison
equal deleted inserted replaced
2342:a5c68b0d6e10 2343:94a653883a32
1328 err: 1328 err:
1329 return res; 1329 return res;
1330 } 1330 }
1331 1331
1332 1332
1333 static int fmtGetGenericSCPixel(Uint8 *col, 1333 static int fmtGetGenericSCPixel(DMC64ScanLine *scan,
1334 const DMC64Image *img, const int rasterX, const int rasterY) 1334 const DMC64Image *img, const int rasterX, const int rasterY)
1335 { 1335 {
1336 DM_C64_GENERIC_SC_PIXEL_DEFS(img) 1336 DM_C64_GENERIC_SC_PIXEL_DEFS(img)
1337 1337
1338 return dmC64GetGenericSCPixel( 1338 return dmC64GetGenericSCPixel(
1339 col, img, 1339 scan->col, img,
1340 bmoffs, scroffs, 1340 bmoffs, scroffs,
1341 vshift, 0, 0); 1341 vshift, 0, 0);
1342 } 1342 }
1343 1343
1344 1344
1345 static int fmtGetGenericMCPixel(Uint8 *col, 1345 static int fmtGetGenericMCPixel(DMC64ScanLine *scan,
1346 const DMC64Image *img, const int rasterX, const int rasterY) 1346 const DMC64Image *img, const int rasterX, const int rasterY)
1347 { 1347 {
1348 DM_C64_GENERIC_MC_PIXEL_DEFS(img) 1348 DM_C64_GENERIC_MC_PIXEL_DEFS(img)
1349 1349
1350 return dmC64GetGenericMCPixel( 1350 return dmC64GetGenericMCPixel(
1351 col, img, 1351 scan->col, img,
1352 bmoffs, scroffs, 1352 bmoffs, scroffs,
1353 vshift, 0, 1353 vshift, 0,
1354 0, 0, img->bgcolor); 1354 0, 0, img->bgcolor);
1355 } 1355 }
1356 1356
1357 1357
1358 static int fmtGetGenericCharPixel(Uint8 *col, 1358 static int fmtGetGenericCharPixel(DMC64ScanLine *scan,
1359 const DMC64Image *img, const int rasterX, const int rasterY) 1359 const DMC64Image *img, const int rasterX, const int rasterY)
1360 { 1360 {
1361 DM_C64_GENERIC_CHAR_PIXEL(img) 1361 DM_C64_GENERIC_CHAR_PIXEL(img)
1362 int chr = img->screen[0].data[scroffs]; 1362 int chr = img->screen[0].data[scroffs];
1363 1363
1367 1367
1368 switch (img->extraInfo[D64_EI_MODE] & D64_FMT_MODE_MASK) 1368 switch (img->extraInfo[D64_EI_MODE] & D64_FMT_MODE_MASK)
1369 { 1369 {
1370 case D64_FMT_HIRES: 1370 case D64_FMT_HIRES:
1371 return dmC64GetGenericCharSCPixel( 1371 return dmC64GetGenericCharSCPixel(
1372 col, img, 1372 scan->col, img,
1373 scroffs, rasterX, 1373 scroffs, rasterX,
1374 0, (chr * D64_CHR_SIZE) + (rasterY & 7), chr, 1374 0, (chr * D64_CHR_SIZE) + (rasterY & 7), chr,
1375 0, img->bgcolor); 1375 0, img->bgcolor);
1376 1376
1377 case D64_FMT_MC: 1377 case D64_FMT_MC:
1378 return dmC64GetGenericCharMCPixel( 1378 return dmC64GetGenericCharMCPixel(
1379 col, img, 1379 scan->col, img,
1380 scroffs, rasterX, 1380 scroffs, rasterX,
1381 0, (chr * D64_CHR_SIZE) + (rasterY & 7), chr, 1381 0, (chr * D64_CHR_SIZE) + (rasterY & 7), chr,
1382 0, img->bgcolor, img->d022, img->d023); 1382 0, img->bgcolor, img->d022, img->d023);
1383 1383
1384 case D64_FMT_ECM: 1384 case D64_FMT_ECM:
1385 return dmC64GetGenericCharECMPixel( 1385 return dmC64GetGenericCharECMPixel(
1386 col, img, 1386 scan->col, img,
1387 scroffs, rasterX, 1387 scroffs, rasterX,
1388 0, ((chr & 0x3f) * D64_CHR_SIZE) + (rasterY & 7), chr, 1388 0, ((chr & 0x3f) * D64_CHR_SIZE) + (rasterY & 7), chr,
1389 0, img->bgcolor, img->d022, img->d023, img->d024); 1389 0, img->bgcolor, img->d022, img->d023, img->d024);
1390 1390
1391 default: 1391 default:
1399 // Convert a C64 format bitmap in DMC64Image struct to 1399 // Convert a C64 format bitmap in DMC64Image struct to
1400 // a indexed/paletted bitmap image. 1400 // a indexed/paletted bitmap image.
1401 static int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageConvSpec *spec) 1401 static int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageConvSpec *spec)
1402 { 1402 {
1403 DMC64GetPixelFunc getPixel; 1403 DMC64GetPixelFunc getPixel;
1404 1404 DMC64ScanLine scan;
1405
1406 (void) spec;
1405 dmMemset(dst->data, 0, dst->size); 1407 dmMemset(dst->data, 0, dst->size);
1408 dmMemset(&scan, 0, sizeof(scan));
1406 1409
1407 // Check pixel getter function 1410 // Check pixel getter function
1408 if (src->fmt->getPixel != NULL) 1411 if (src->fmt->getPixel != NULL)
1409 getPixel = src->fmt->getPixel; 1412 getPixel = src->fmt->getPixel;
1410 else 1413 else
1422 } 1425 }
1423 1426
1424 // Perform conversion 1427 // Perform conversion
1425 for (int yc = 0; yc < dst->height; yc++) 1428 for (int yc = 0; yc < dst->height; yc++)
1426 { 1429 {
1427 Uint8 *dp = dst->data + (yc * dst->pitch); 1430 scan.col = dst->data + (yc * dst->pitch);
1428 for (int xc = 0; xc < dst->width; xc++, dp++) 1431 for (int xc = 0; xc < dst->width; xc++, scan.col++)
1429 { 1432 {
1430 int res; 1433 int res;
1431 if ((res = getPixel(dp, src, xc, yc)) != DMERR_OK) 1434 if ((res = getPixel(&scan, src, xc, yc)) != DMERR_OK)
1432 return res; 1435 return res;
1433 } 1436 }
1434 } 1437 }
1435 1438
1436 return DMERR_OK; 1439 return DMERR_OK;