comparison tools/lib64gfx.c @ 1362:7bc67ba68904

Better handling of resolution interlaced pictures.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 22 Sep 2017 16:25:25 +0300
parents 00f47a678482
children 0d61895e1763
comparison
equal deleted inserted replaced
1361:00f47a678482 1362:7bc67ba68904
1035 if (dst->width < src->width || dst->height < src->height) 1035 if (dst->width < src->width || dst->height < src->height)
1036 return DMERR_INVALID_DATA; 1036 return DMERR_INVALID_DATA;
1037 1037
1038 dmMemset(dst->data, 0, dst->size); 1038 dmMemset(dst->data, 0, dst->size);
1039 1039
1040 // Resolution interlaced pics need to halve the source width
1041 int rwidth = src->width;
1042 if ((src->type & D64_FMT_ILACE) && src->laceType == D64_ILACE_RES)
1043 rwidth /= 2;
1044
1040 // Perform conversion 1045 // Perform conversion
1041 for (yc = 0; yc < src->height; yc++) 1046 for (yc = 0; yc < src->height; yc++)
1042 { 1047 {
1043 Uint8 *d = dp; 1048 Uint8 *d = dp;
1044 const int y = yc / 8, yb = yc & 7; 1049 const int y = yc / 8, yb = yc & 7;
1048 if (src->type & D64_FMT_CHAR) 1053 if (src->type & D64_FMT_CHAR)
1049 { 1054 {
1050 // Charmode conversion 1055 // Charmode conversion
1051 if ((src->type & D64_FMT_MC) == D64_FMT_HIRES) 1056 if ((src->type & D64_FMT_MC) == D64_FMT_HIRES)
1052 // Hi-res charmap 1057 // Hi-res charmap
1053 for (xc = 0; xc < src->width; xc++) 1058 for (xc = 0; xc < rwidth; xc++)
1054 { 1059 {
1055 const int x = xc / 8; 1060 const int x = xc / 8;
1056 const int scroffs = scroffsy + x; 1061 const int scroffs = scroffsy + x;
1057 const int chr = src->screen[0][scroffs]; 1062 const int chr = src->screen[0][scroffs];
1058 const int v = 7 - (xc & 7); 1063 const int v = 7 - (xc & 7);
1062 else 1067 else
1063 *d++ = src->bgcolor; 1068 *d++ = src->bgcolor;
1064 } 1069 }
1065 else 1070 else
1066 // Multicolor variants 1071 // Multicolor variants
1067 for (xc = 0; xc < src->width; xc++) 1072 for (xc = 0; xc < rwidth; xc++)
1068 { 1073 {
1069 const int x = xc / 4; 1074 const int x = xc / 4;
1070 const int scroffs = scroffsy + x; 1075 const int scroffs = scroffsy + x;
1071 const int chr = src->screen[0][scroffs]; 1076 const int chr = src->screen[0][scroffs];
1072 const int col = src->color[0][scroffs] & 15; 1077 const int col = src->color[0][scroffs] & 15;
1097 // Perform generic BITMAP conversion 1102 // Perform generic BITMAP conversion
1098 const int bmoffsy = y * src->ch_width * 8 + yb; 1103 const int bmoffsy = y * src->ch_width * 8 + yb;
1099 1104
1100 if ((src->type & D64_FMT_MC) == D64_FMT_HIRES) 1105 if ((src->type & D64_FMT_MC) == D64_FMT_HIRES)
1101 // Hi-res bitmap 1106 // Hi-res bitmap
1102 for (xc = 0; xc < src->width; xc++) 1107 for (xc = 0; xc < rwidth; xc++)
1103 { 1108 {
1104 const int x = xc / 8; 1109 const int x = xc / 8;
1105 const int scroffs = scroffsy + x; 1110 const int scroffs = scroffsy + x;
1106 const int bmoffs = bmoffsy + (x * 8); 1111 const int bmoffs = bmoffsy + (x * 8);
1107 const int v = 7 - (xc & 7); 1112 const int v = 7 - (xc & 7);
1111 else 1116 else
1112 *d++ = src->screen[0][scroffs] & 15; 1117 *d++ = src->screen[0][scroffs] & 15;
1113 } 1118 }
1114 else 1119 else
1115 // Multicolor bitmap and variants 1120 // Multicolor bitmap and variants
1116 for (xc = 0; xc < src->width; xc++) 1121 for (xc = 0; xc < rwidth; xc++)
1117 { 1122 {
1118 const int x = xc / 4; 1123 const int x = xc / 4;
1119 const int scroffs = scroffsy + x; 1124 const int scroffs = scroffsy + x;
1120 const int bmoffs = bmoffsy + (x * 8); 1125 const int bmoffs = bmoffsy + (x * 8);
1121 const int v = 6 - ((xc * 2) & 6); 1126 const int v = 6 - ((xc * 2) & 6);
1140 *d++ = c; 1145 *d++ = c;
1141 } 1146 }
1142 else 1147 else
1143 if (src->type & D64_FMT_ILACE) 1148 if (src->type & D64_FMT_ILACE)
1144 { 1149 {
1145 *d++ = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, src->laceBank1, scroffs); 1150 switch (src->laceType)
1146 *d++ = dmC64GetMCColor(src, (src->bitmap[1][bmoffs] >> v) & 3, 0, src->laceBank2, scroffs); 1151 {
1152 case D64_ILACE_RES:
1153 *d++ = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, src->laceBank1, scroffs);
1154 *d++ = dmC64GetMCColor(src, (src->bitmap[1][bmoffs] >> v) & 3, 0, src->laceBank2, scroffs);
1155 break;
1156 }
1147 } 1157 }
1148 else 1158 else
1149 { 1159 {
1150 c = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, 0, scroffs); 1160 c = dmC64GetMCColor(src, (src->bitmap[0][bmoffs] >> v) & 3, 0, 0, scroffs);
1151 *d++ = c; 1161 *d++ = c;