Mercurial > hg > dmlib
comparison tools/lib64gfx.c @ 2345:fe025c461760
Move pixel helper functions from being inline in lib64gfx.h to lib64gfx.c
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 08 Oct 2019 14:49:00 +0300 |
parents | 13e54305e5fc |
children | 82cb32297ed2 |
comparison
equal
deleted
inserted
replaced
2344:13e54305e5fc | 2345:fe025c461760 |
---|---|
1328 err: | 1328 err: |
1329 return res; | 1329 return res; |
1330 } | 1330 } |
1331 | 1331 |
1332 | 1332 |
1333 // | |
1334 // Helper functions for pixel format decoding | |
1335 // | |
1336 int dmC64GetGenericSCPixel(Uint8 *col, | |
1337 const DMC64Image *img, const int bmoffs, const int scroffs, | |
1338 const int vshift, const int vbank, const int bitmap) | |
1339 { | |
1340 if ((img->bitmap[bitmap].data[bmoffs] >> vshift) & 1) | |
1341 *col = img->screen[vbank].data[scroffs] >> 4; | |
1342 else | |
1343 *col = img->screen[vbank].data[scroffs] & 15; | |
1344 | |
1345 return DMERR_OK; | |
1346 } | |
1347 | |
1348 | |
1349 int dmC64GetGenericMCPixel(Uint8 *col, | |
1350 const DMC64Image *img, const int bmoffs, const int scroffs, | |
1351 const int vshift, const int vbank, const int bitmap, | |
1352 const int cbank, const int bgcolor) | |
1353 { | |
1354 switch ((img->bitmap[bitmap].data[bmoffs] >> vshift) & 3) | |
1355 { | |
1356 case 0: *col = bgcolor & 15; break; | |
1357 case 1: *col = img->screen[vbank].data[scroffs] >> 4; break; | |
1358 case 2: *col = img->screen[vbank].data[scroffs] & 15; break; | |
1359 default: *col = img->color[cbank].data[scroffs] & 15; break; | |
1360 } | |
1361 | |
1362 return DMERR_OK; | |
1363 } | |
1364 | |
1365 | |
1366 int dmC64GetGenericCharSCPixel(Uint8 *col, | |
1367 const DMC64Image *img, const int scroffs, const int rasterX, | |
1368 const int chrbank, const size_t chroffs, const int chr, | |
1369 const int cbank, const int bgcolor) | |
1370 { | |
1371 if (chroffs >= img->charData[chrbank].size) | |
1372 { | |
1373 return dmError(DMERR_INVALID_DATA, | |
1374 "Character map index #%d out of bounds for char ROM data.\n", | |
1375 chr); | |
1376 } | |
1377 | |
1378 const int vshift = 7 - (rasterX & 7); | |
1379 if ((img->charData[chrbank].data[chroffs] >> vshift) & 1) | |
1380 *col = img->color[cbank].data[scroffs] & 15; | |
1381 else | |
1382 *col = bgcolor & 15; | |
1383 | |
1384 return DMERR_OK; | |
1385 } | |
1386 | |
1387 | |
1388 int dmC64GetGenericCharMCPixel(Uint8 *col, | |
1389 const DMC64Image *img, const int scroffs, const int rasterX, | |
1390 const int chrbank, const size_t chroffs, const int chr, | |
1391 const int cbank, const int bgcolor, | |
1392 const int bgd022, const int bgd023) | |
1393 { | |
1394 if (chroffs >= img->charData[chrbank].size) | |
1395 { | |
1396 return dmError(DMERR_INVALID_DATA, | |
1397 "Character map index #%d out of bounds for char ROM data.\n", | |
1398 chr); | |
1399 } | |
1400 | |
1401 const int ccol = img->color[cbank].data[scroffs]; | |
1402 if (ccol & 8) | |
1403 { | |
1404 const int vshift = 6 - (rasterX & 6); | |
1405 switch ((img->charData[chrbank].data[chroffs] >> vshift) & 3) | |
1406 { | |
1407 case 0: *col = bgcolor & 15; break; | |
1408 case 1: *col = bgd022 & 15; break; | |
1409 case 2: *col = bgd023 & 15; break; | |
1410 case 3: *col = ccol & 7; | |
1411 } | |
1412 } | |
1413 else | |
1414 { | |
1415 const int vshift = 7 - (rasterX & 7); | |
1416 if ((img->charData[chrbank].data[chroffs] >> vshift) & 1) | |
1417 *col = ccol & 7; | |
1418 else | |
1419 *col = bgcolor & 15; | |
1420 } | |
1421 | |
1422 return DMERR_OK; | |
1423 } | |
1424 | |
1425 | |
1426 int dmC64GetGenericCharECMPixel(Uint8 *col, | |
1427 const DMC64Image *img, const int scroffs, const int rasterX, | |
1428 const int chrbank, const size_t chroffs, const int chr, | |
1429 const int cbank, const int bgcolor, | |
1430 const int bgd022, const int bgd023, const int bgd024) | |
1431 { | |
1432 if (chroffs >= img->charData[0].size) | |
1433 { | |
1434 return dmError(DMERR_INVALID_DATA, | |
1435 "Character map index #%d out of bounds for char ROM data.\n", | |
1436 chr); | |
1437 } | |
1438 | |
1439 const int vshift = 7 - (rasterX & 7); | |
1440 if ((img->charData[chrbank].data[chroffs] >> vshift) & 1) | |
1441 *col = img->color[cbank].data[scroffs] & 15; | |
1442 else | |
1443 switch ((chr >> 6) & 3) | |
1444 { | |
1445 case 0: *col = bgcolor & 15; break; | |
1446 case 1: *col = bgd022 & 15; break; | |
1447 case 2: *col = bgd023 & 15; break; | |
1448 case 3: *col = bgd024 & 15; break; | |
1449 } | |
1450 | |
1451 return DMERR_OK; | |
1452 } | |
1453 | |
1454 | |
1333 static int fmtGetGenericSCPixel(DMC64ScanLine *scan, | 1455 static int fmtGetGenericSCPixel(DMC64ScanLine *scan, |
1334 const DMC64Image *img, const int rasterX, const int rasterY) | 1456 const DMC64Image *img, const int rasterX, const int rasterY) |
1335 { | 1457 { |
1336 DM_C64_GENERIC_SC_PIXEL_DEFS(img) | 1458 DM_C64_GENERIC_SC_PIXEL_DEFS(img) |
1337 | 1459 |