comparison Discovery/Src/gfx_engine.c @ 110:cc8e24374b83 FlipDisplay

Added option to handled mirrored display to existing functions
author Ideenmodellierer
date Tue, 01 Jan 2019 21:02:17 +0100
parents e97deb6e2705
children 79b19d56ab08
comparison
equal deleted inserted replaced
109:65a6e352ce08 110:cc8e24374b83
902 } 902 }
903 903
904 904
905 static inline void gfx_brush(uint8_t thickness, GFX_DrawCfgScreen *hgfx, uint16_t x0, uint16_t y0, uint8_t color) 905 static inline void gfx_brush(uint8_t thickness, GFX_DrawCfgScreen *hgfx, uint16_t x0, uint16_t y0, uint8_t color)
906 { 906 {
907 uint32_t pDestination; 907 uint16_t* pDestination;
908 uint8_t offset = thickness/2; 908 uint8_t offset = thickness/2;
909 909 int16_t stepdir;
910 pDestination = hgfx->FBStartAdress + 2*(x0 - offset)*hgfx->ImageHeight + 2*(y0-offset); 910
911 SSettings* pSettings;
912 pSettings = settingsGetPointer();
913
914 if(pSettings->FlipDisplay)
915 {
916 pDestination = hgfx->FBStartAdress + (2*hgfx->ImageHeight * (hgfx->ImageWidth - x0 + offset)) + 2*(480 - y0+offset);
917 stepdir = -1;
918 }
919 else
920 {
921 pDestination = hgfx->FBStartAdress + 2*(x0 - offset)*hgfx->ImageHeight + 2*(y0-offset);
922 stepdir = 1;
923 }
911 for(int x=thickness;x>0;x--) 924 for(int x=thickness;x>0;x--)
912 { 925 {
913 for(int y=thickness;y>0;y--) 926 for(int y=thickness;y>0;y--)
914 { 927 {
915 *(__IO uint16_t*)pDestination = 0xFF00 + color; 928 *(__IO uint16_t*)pDestination = 0xFF00 + color;
916 pDestination +=2; 929 pDestination += stepdir;
917 } 930 }
918 pDestination += 2*(hgfx->ImageHeight - thickness); 931 pDestination += stepdir * (hgfx->ImageHeight - thickness);
919 } 932 }
920 } 933 }
921 934
922 935
923 void GFX_draw_thick_line(uint8_t thickness, GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color) 936 void GFX_draw_thick_line(uint8_t thickness, GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color)
966 } 979 }
967 980
968 981
969 void GFX_draw_line(GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color) 982 void GFX_draw_line(GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color)
970 { 983 {
971 uint32_t pDestination; 984 uint16_t* pDestination;
972 uint32_t j; 985 uint32_t j;
973 986 int16_t stepdir;
987 SSettings* pSettings;
988 pSettings = settingsGetPointer();
989
990
991 /* horizontal line */
974 if(start.x == stop.x) 992 if(start.x == stop.x)
975 { 993 {
976 if(start.y > stop.y) gfx_flip(&start,&stop); 994 if(start.y > stop.y) gfx_flip(&start,&stop);
995
977 pDestination = (uint32_t)hgfx->FBStartAdress; 996 pDestination = (uint32_t)hgfx->FBStartAdress;
978 pDestination += start.x * hgfx->ImageHeight * 2; 997 if(pSettings->FlipDisplay)
979 pDestination += start.y * 2; 998 {
999 pDestination += (800 - start.x) * hgfx->ImageHeight;
1000 pDestination += (480 - start.y);
1001 stepdir = -1;
1002 }
1003 else
1004 {
1005 pDestination += start.x * hgfx->ImageHeight;
1006 pDestination += start.y;
1007 stepdir = 1;
1008 }
980 for (j = stop.y - start.y; j > 0; j--) 1009 for (j = stop.y - start.y; j > 0; j--)
981 { 1010 {
982 *(__IO uint16_t*)pDestination = 0xFF00 + color; 1011 *(__IO uint16_t*)pDestination = 0xFF00 + color;
983 pDestination += 2; 1012 pDestination += stepdir;
984 } 1013 }
985 } 1014 }
986 else 1015 else /* vertical line ? */
987 if(start.y == stop.y) 1016 if(start.y == stop.y)
988 { 1017 {
989 if(start.x > stop.x) gfx_flip(&start,&stop); 1018 if(start.x > stop.x) gfx_flip(&start,&stop);
990 pDestination = (uint32_t)hgfx->FBStartAdress; 1019 pDestination = (uint32_t)hgfx->FBStartAdress;
991 pDestination += start.x * hgfx->ImageHeight * 2; 1020
992 pDestination += start.y * 2; 1021 if(pSettings->FlipDisplay)
1022 {
1023 pDestination += (800 - start.x) * hgfx->ImageHeight;
1024 pDestination += (480 - start.y);
1025 stepdir = -1;
1026 }
1027 else
1028 {
1029 pDestination += start.x * hgfx->ImageHeight;
1030 pDestination += start.y;
1031 stepdir = 1;
1032 }
1033
993 for (j = stop.x - start.x; j > 0; j--) 1034 for (j = stop.x - start.x; j > 0; j--)
994 { 1035 {
995 *(__IO uint16_t*)pDestination = 0xFF00 + color; 1036 *(__IO uint16_t*)pDestination = 0xFF00 + color;
996 pDestination += hgfx->ImageHeight * 2; 1037 pDestination += stepdir * hgfx->ImageHeight;
997 } 1038 }
998 } 1039 }
999 else // diagonal 1040 else /* diagonal */
1000 { 1041 {
1001 int x0 = start.x; 1042 int x0 = start.x;
1002 int y0 = start.y; 1043 int y0 = start.y;
1003 int x1 = stop.x; 1044 int x1 = stop.x;
1004 int y1 = stop.y; 1045 int y1 = stop.y;
1006 int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1; 1047 int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1;
1007 int err = (dx>dy ? dx : -dy)/2, e2; 1048 int err = (dx>dy ? dx : -dy)/2, e2;
1008 1049
1009 for(;;) 1050 for(;;)
1010 { 1051 {
1011 pDestination = (uint32_t)hgfx->FBStartAdress; 1052 pDestination = (uint16_t*)hgfx->FBStartAdress;
1012 pDestination += ((x0 * hgfx->ImageHeight) + y0) * 2; 1053
1054 if(pSettings->FlipDisplay)
1055 {
1056 pDestination += (((800 - x0) * hgfx->ImageHeight) + (480 - y0));
1057 }
1058 else
1059 {
1060 pDestination += ((x0 * hgfx->ImageHeight) + y0);
1061 }
1062
1013 *(__IO uint16_t*)pDestination = 0xFF00 + color; 1063 *(__IO uint16_t*)pDestination = 0xFF00 + color;
1014 if (x0==x1 && y0==y1) break; 1064 if (x0==x1 && y0==y1) break;
1015 e2 = err; 1065 e2 = err;
1016 if (e2 >-dx) { err -= dy; x0 += sx; } 1066 if (e2 >-dx) { err -= dy; x0 += sx; }
1017 if (e2 < dy) { err += dx; y0 += sy; } 1067 if (e2 < dy) { err += dx; y0 += sy; }
1020 } 1070 }
1021 1071
1022 1072
1023 void GFX_draw_image_monochrome(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, const tImage *image, uint8_t color) 1073 void GFX_draw_image_monochrome(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, const tImage *image, uint8_t color)
1024 { 1074 {
1025 uint32_t pDestination; 1075 uint16_t* pDestination;
1026 uint32_t j; 1076 uint32_t j;
1027 point_t start, stop; 1077 point_t start, stop;
1078
1079 SSettings* pSettings;
1080 pSettings = settingsGetPointer();
1028 1081
1029 start.x = window.left; 1082 start.x = window.left;
1030 start.y = (hgfx->ImageHeight - image->height - window.top); 1083 start.y = (hgfx->ImageHeight - image->height - window.top);
1031 stop.y = start.y + image->height; 1084 stop.y = start.y + image->height;
1032 stop.x = start.x + image->width; 1085 stop.x = start.x + image->width;
1033 j = 0; 1086 j = 0;
1034 1087
1035 for(int xx = start.x; xx < stop.x; xx++) 1088 if(pSettings->FlipDisplay)
1036 { 1089 {
1037 pDestination = (uint32_t)hgfx->FBStartAdress; 1090 for(int xx = start.x; xx < stop.x; xx++)
1038 pDestination += xx * hgfx->ImageHeight * 2; 1091 {
1039 pDestination += start.y * 2; 1092 pDestination = hgfx->FBStartAdress;
1040 for(int yy = start.y; yy < stop.y; yy++) 1093 pDestination += (hgfx->ImageHeight - start.y) + (stop.x * hgfx->ImageHeight) ;
1041 { 1094 pDestination -= (xx - start.x) * hgfx->ImageHeight;
1042 *(__IO uint8_t*)pDestination = color; 1095
1043 pDestination += 1; 1096 for(int yy = start.y; yy < stop.y; yy++)
1044 *(__IO uint8_t*)pDestination = image->data[j++]; 1097 {
1045 pDestination += 1; 1098 *(__IO uint16_t*)pDestination-- = image->data[j++] << 8 + color;
1046 } 1099 }
1047 } 1100 }
1101 }
1102 else
1103 {
1104 for(int xx = start.x; xx < stop.x; xx++)
1105 {
1106 pDestination = (uint32_t)hgfx->FBStartAdress;
1107 pDestination += xx * hgfx->ImageHeight;
1108 pDestination += start.y;
1109 for(int yy = start.y; yy < stop.y; yy++)
1110 {
1111 *(__IO uint16_t*)pDestination++ = image->data[j++] << 8 + color;
1112 }
1113 }
1114 }
1048 } 1115 }
1049 1116
1050 1117
1051 void GFX_draw_image_color(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, const tImage *image) 1118 void GFX_draw_image_color(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, const tImage *image)
1052 { 1119 {
1053 uint32_t pDestination; 1120 uint16_t* pDestination;
1121
1054 uint32_t j; 1122 uint32_t j;
1055 point_t start, stop; 1123 point_t start, stop;
1056 1124
1057 start.x = window.left; 1125 start.x = window.left;
1058 start.y = (hgfx->ImageHeight - image->height - window.top); 1126 start.y = (hgfx->ImageHeight - image->height - window.top);
1059 stop.y = start.y + image->height; 1127 stop.y = start.y + image->height;
1060 stop.x = start.x + image->width; 1128 stop.x = start.x + image->width;
1061 j = 0; 1129 j = 0;
1062 1130
1063 for(int xx = start.x; xx < stop.x; xx++) 1131 SSettings* pSettings;
1064 { 1132 pSettings = settingsGetPointer();
1065 pDestination = (uint32_t)hgfx->FBStartAdress; 1133
1066 pDestination += xx * hgfx->ImageHeight * 2; 1134 if(pSettings->FlipDisplay)
1067 pDestination += start.y * 2; 1135 {
1068 for(int yy = start.y; yy < stop.y; yy++) 1136 for(int xx = start.x; xx < stop.x; xx++)
1069 { 1137 {
1070 *(__IO uint8_t*)pDestination = image->data[j++]; 1138 pDestination = (uint16_t*)hgfx->FBStartAdress;
1071 pDestination += 1; 1139 pDestination += (hgfx->ImageHeight - start.y) + (stop.x * hgfx->ImageHeight);
1072 *(__IO uint8_t*)pDestination = 0xFF; 1140 pDestination -= (xx - start.x) * hgfx->ImageHeight;
1073 pDestination += 1; 1141
1074 } 1142 for(int yy = start.y; yy < stop.y; yy++)
1075 } 1143 {
1144 // *(__IO uint16_t*)pDestination-- = image->data[j++] << 8 | 0xFF;
1145 *(__IO uint16_t*)pDestination-- = 0xFF << 8 | image->data[j++];
1146 }
1147 }
1148 }
1149 else
1150 {
1151 for(int xx = start.x; xx < stop.x; xx++)
1152 {
1153 pDestination = (uint32_t)hgfx->FBStartAdress;
1154 pDestination += xx * hgfx->ImageHeight;
1155 pDestination += start.y;
1156 for(int yy = start.y; yy < stop.y; yy++)
1157 {
1158 *(__IO uint16_t*)pDestination++ = 0xFF << 8 | image->data[j++];
1159 }
1160 }
1161 }
1076 } 1162 }
1077 1163
1078 1164
1079 int16_Point_t switchToOctantZeroFrom(uint8_t octant, int16_t x, int16_t y) 1165 int16_Point_t switchToOctantZeroFrom(uint8_t octant, int16_t x, int16_t y)
1080 { 1166 {
1118 } 1204 }
1119 1205
1120 /* this is NOT fast nor optimized */ 1206 /* this is NOT fast nor optimized */
1121 void GFX_draw_pixel(GFX_DrawCfgScreen *hgfx, int16_t x, int16_t y, uint8_t color) 1207 void GFX_draw_pixel(GFX_DrawCfgScreen *hgfx, int16_t x, int16_t y, uint8_t color)
1122 { 1208 {
1123 uint32_t pDestination; 1209 uint16_t* pDestination;
1124 1210
1125 pDestination = (uint32_t)hgfx->FBStartAdress; 1211 SSettings* pSettings;
1126 pDestination += x * hgfx->ImageHeight * 2; 1212 pSettings = settingsGetPointer();
1127 pDestination += y * 2; 1213
1128 1214 pDestination = (uint16_t*)hgfx->FBStartAdress;
1129 *(__IO uint8_t*)pDestination = color; 1215 if(pSettings->FlipDisplay)
1130 pDestination += 1; 1216 {
1131 *(__IO uint8_t*)pDestination = 0xFF; 1217 pDestination += (800 - x) * hgfx->ImageHeight;
1218 pDestination += (480 - y);
1219 }
1220 else
1221 {
1222 pDestination += x * hgfx->ImageHeight;
1223 pDestination += y;
1224 }
1225 *(__IO uint16_t*)pDestination = 0xFF << 8 | color;
1132 } 1226 }
1133 1227
1134 1228
1135 /* store the quarter circle for given radius */ 1229 /* store the quarter circle for given radius */
1136 void GFX_draw_circle_with_MEMORY(uint8_t use_memory, GFX_DrawCfgScreen *hgfx, point_t center, uint8_t radius, int8_t color) 1230 void GFX_draw_circle_with_MEMORY(uint8_t use_memory, GFX_DrawCfgScreen *hgfx, point_t center, uint8_t radius, int8_t color)
1269 p2.y = 479 - window.bottom; 1363 p2.y = 479 - window.bottom;
1270 for(int i = 0; i <= vlines; i++) 1364 for(int i = 0; i <= vlines; i++)
1271 { 1365 {
1272 p1.x = window.left + (int)(i * deltaline + 0.5f); 1366 p1.x = window.left + (int)(i * deltaline + 0.5f);
1273 p2.x = p1.x ; 1367 p2.x = p1.x ;
1274 GFX_draw_colorline(hgfx, p1,p2, color ); 1368 //GFX_draw_colorline(hgfx, p1,p2, color );
1369 GFX_draw_line(hgfx, p1,p2, color );
1275 } 1370 }
1276 } 1371 }
1277 if(vdeltaline > 0) 1372 if(vdeltaline > 0)
1278 { 1373 {
1279 p1.y = 479 - window.top; 1374 p1.y = 479 - window.top;
1280 p2.y = 479 - window.bottom; 1375 p2.y = 479 - window.bottom;
1281 for(int i = 0; i < winwidth/vdeltaline; i++) 1376 for(int i = 0; i < winwidth/vdeltaline; i++)
1282 { 1377 {
1283 p1.x = window.left + (int)(i * vdeltaline + 0.5f); 1378 p1.x = window.left + (int)(i * vdeltaline + 0.5f);
1284 p2.x = p1.x ; 1379 p2.x = p1.x ;
1285 GFX_draw_colorline(hgfx, p1,p2, color ); 1380 // GFX_draw_colorline(hgfx, p1,p2, color );
1381 GFX_draw_line(hgfx, p1,p2, color );
1286 } 1382 }
1287 } 1383 }
1288 if(hlines > 0) 1384 if(hlines > 0)
1289 { 1385 {
1290 deltaline = ((float)winthight)/hlines; 1386 deltaline = ((float)winthight)/hlines;
1292 p2.x = window.right; 1388 p2.x = window.right;
1293 for(int i = 0; i <= hlines; i++) 1389 for(int i = 0; i <= hlines; i++)
1294 { 1390 {
1295 p1.y = 479 - window.top - (int)(i * deltaline + 0.5f); 1391 p1.y = 479 - window.top - (int)(i * deltaline + 0.5f);
1296 p2.y = p1.y; 1392 p2.y = p1.y;
1297 GFX_draw_colorline(hgfx, p1,p2, color ); 1393 // GFX_draw_colorline(hgfx, p1,p2, color );
1394 GFX_draw_line(hgfx, p1,p2, color );
1298 } 1395 }
1299 } 1396 }
1300 } 1397 }
1301 1398
1302 /* drawVeilUntil ist auff�llen des Bereichs unter der Kurve mit etwas hellerer Farbe 1399 /* drawVeilUntil ist auff�llen des Bereichs unter der Kurve mit etwas hellerer Farbe
1404 /// @param drawVeilUntil: ist auff�llen des Bereichs unter der Kurve mit etwas hellerer Farbe 1501 /// @param drawVeilUntil: ist auff�llen des Bereichs unter der Kurve mit etwas hellerer Farbe
1405 /// @param Xdivide: wird bisher nichr benutzt. 1502 /// @param Xdivide: wird bisher nichr benutzt.
1406 // =============================================================================== 1503 // ===============================================================================
1407 1504
1408 1505
1409 void GFX_graph_print(GFX_DrawCfgScreen *hgfx, const SWindowGimpStyle *window, int16_t drawVeilUntil, uint8_t Xdivide, uint16_t dataMin, uint16_t dataMax, uint16_t *data, uint16_t datalength, uint8_t color, uint8_t *colour_data) 1506 void GFX_graph_print(GFX_DrawCfgScreen *hgfx, const SWindowGimpStyle *window, const int16_t drawVeilUntil, uint8_t Xdivide, uint16_t dataMin, uint16_t dataMax, uint16_t *data, uint16_t datalength, uint8_t color, uint8_t *colour_data)
1410 { 1507 {
1411 //uint32_t pDestination,pDestination_old, 1508 uint16_t* pDestination_tmp;
1412 uint32_t pDestination_tmp,pDestination_end, pDestination_start, pDestination_zero_veil; 1509 uint16_t* pDestination_start;
1510 uint16_t* pDestination_end;
1511 uint16_t* pDestination_zero_veil;
1512
1513 SSettings* pSettings;
1413 1514
1414 uint32_t max = 0; 1515 uint32_t max = 0;
1415 int windowheight = -1; 1516 int windowheight = -1;
1416 int windowwidth = -1; 1517 int windowwidth = -1;
1417 int i = -1; 1518 int i = -1;
1427 uint16_t dataTemp = 0; 1528 uint16_t dataTemp = 0;
1428 1529
1429 uint8_t colorDataTemp; 1530 uint8_t colorDataTemp;
1430 uint8_t colormask = 0; 1531 uint8_t colormask = 0;
1431 1532
1533 pSettings = settingsGetPointer();
1534 pDestination_zero_veil = 0;
1535
1432 if(dataMin > dataMax) 1536 if(dataMin > dataMax)
1433 { 1537 {
1434 uint16_t dataFlip; 1538 uint16_t dataFlip;
1435 dataFlip = dataMin; 1539 dataFlip = dataMin;
1436 dataMin = dataMax; 1540 dataMin = dataMax;
1439 } 1543 }
1440 else 1544 else
1441 invert = 0; 1545 invert = 0;
1442 1546
1443 colormask = color; 1547 colormask = color;
1444 1548
1549 pSettings = settingsGetPointer();
1445 1550
1446 if(window->bottom > 479) 1551 if(window->bottom > 479)
1447 return; 1552 return;
1448 if(window->top > 479) 1553 if(window->top > 479)
1449 return; 1554 return;
1520 h_ulong /= dataDelta; 1625 h_ulong /= dataDelta;
1521 1626
1522 if(h_ulong > (window->bottom - window->top)) 1627 if(h_ulong > (window->bottom - window->top))
1523 h_ulong = (window->bottom - window->top); 1628 h_ulong = (window->bottom - window->top);
1524 1629
1525 if(drawVeilUntil > 0) 1630 if(!pSettings->FlipDisplay)
1526 { 1631 {
1527 pDestination_zero_veil = hgfx->FBStartAdress + 2 * ( (479 - (drawVeilUntil - 2) ) + ( (w1 + window->left) * hgfx->ImageHeight) ); 1632 if(drawVeilUntil > 0)
1528 } 1633 {
1529 else if(drawVeilUntil < 0 ) 1634 pDestination_zero_veil = (uint16_t*)hgfx->FBStartAdress;
1530 { 1635 pDestination_zero_veil += ((479 - (drawVeilUntil - 2) ) + ((w1 + window->left) * hgfx->ImageHeight) );
1531 pDestination_zero_veil = hgfx->FBStartAdress + 2 * ( (479 + (drawVeilUntil) ) + ( (w1 + window->left) * hgfx->ImageHeight) ); 1636 }
1532 } 1637 else if(drawVeilUntil < 0 )
1533 1638 {
1639 pDestination_zero_veil = hgfx->FBStartAdress;
1640 pDestination_zero_veil += ((479 + (drawVeilUntil)) + ((w1 + window->left) * hgfx->ImageHeight) );
1641 }
1642 }
1643 else
1644 {
1645 if(drawVeilUntil > 0)
1646 {
1647 pDestination_zero_veil = hgfx->FBStartAdress;
1648 pDestination_zero_veil += (((drawVeilUntil) ) + ( (window->right - w1) * hgfx->ImageHeight) );
1649 }
1650 else if(drawVeilUntil < 0 )
1651 {
1652 pDestination_zero_veil = hgfx->FBStartAdress;
1653 pDestination_zero_veil += 479 - drawVeilUntil + ( (window->right - w1 -1) * hgfx->ImageHeight);
1654 }
1655 }
1534 if(h_ulong + window->top > max) 1656 if(h_ulong + window->top > max)
1535 { 1657 {
1536 max = h_ulong + window->top; 1658 max = h_ulong + window->top;
1537 } 1659 }
1538 1660
1541 // { 1663 // {
1542 //output_content[pointer] = colormask; 1664 //output_content[pointer] = colormask;
1543 //output_mask[pointer] = true; 1665 //output_mask[pointer] = true;
1544 if(w1 > 0) 1666 if(w1 > 0)
1545 { 1667 {
1546 pDestination_start = hgfx->FBStartAdress + (2 * ((479 - (window->top)) + ((w1 + window->left) * hgfx->ImageHeight))); 1668 pDestination_start = hgfx->FBStartAdress;
1547 pDestination_end = pDestination_start; 1669 if(!pSettings->FlipDisplay)
1548 if(h_ulong >= h_ulong_old)
1549 { 1670 {
1550 pDestination_start -= 2 * h_ulong_old; 1671 pDestination_start += (((479 - (window->top)) + ((w1 + window->left) * hgfx->ImageHeight)));
1551 pDestination_end -= 2 * h_ulong;
1552 } 1672 }
1553 else 1673 else
1554 { 1674 {
1555 pDestination_start -= 2 * h_ulong; 1675 pDestination_start += (((window->top) + ((window->right - w1) * hgfx->ImageHeight)));
1556 pDestination_end -= 2 * h_ulong_old;
1557 } 1676 }
1677 pDestination_end = pDestination_start;
1678
1679 if(!pSettings->FlipDisplay)
1680 {
1681 if(h_ulong >= h_ulong_old)
1682 {
1683 pDestination_start -= h_ulong_old;
1684 pDestination_end -= h_ulong;
1685 }
1686 else
1687 {
1688 pDestination_start -= h_ulong;
1689 pDestination_end -= h_ulong_old;
1690 }
1691 }
1692 else
1693 {
1694 if(h_ulong < h_ulong_old)
1695 {
1696 pDestination_start += h_ulong_old;
1697 pDestination_end += h_ulong;
1698 }
1699 else
1700 {
1701 pDestination_start += h_ulong;
1702 pDestination_end += h_ulong_old;
1703 }
1704 }
1705
1558 1706
1559 // deco stops 1707 // deco stops
1560 if(drawVeilUntil < 0) 1708 if(drawVeilUntil < 0)
1561 { 1709 {
1562 pDestination_tmp = pDestination_end; 1710 if(!pSettings->FlipDisplay)
1563 while(pDestination_tmp <= pDestination_zero_veil)
1564 { 1711 {
1565 *(__IO uint8_t*)pDestination_tmp = colormask; 1712 pDestination_tmp = pDestination_end;
1566 pDestination_tmp -= 1; 1713 while(pDestination_tmp <= pDestination_zero_veil)
1567 *(__IO uint8_t*)pDestination_tmp = 0x80; 1714 {
1568 pDestination_tmp += 3; 1715 *(__IO uint16_t*)pDestination_tmp = (0x80 << 8) | colormask;
1716 pDestination_tmp++;
1717 }
1718 }
1719 else
1720 {
1721 pDestination_tmp = pDestination_zero_veil;
1722 while(pDestination_tmp <= pDestination_end)
1723 {
1724 *(__IO uint16_t*)pDestination_tmp = (0x80 << 8) | colormask;
1725 pDestination_tmp++;
1726 }
1569 } 1727 }
1570 } 1728 }
1571 else 1729 else
1572 { 1730 {
1573 // regular graph with veil underneath if requested 1731 // regular graph with veil underneath if requested
1574 // von oben nach unten 1732 // von oben nach unten
1575 // von grossen pDestination Werten zu kleinen pDestination Werten 1733 // von grossen pDestination Werten zu kleinen pDestination Werten
1576 pDestination_tmp = pDestination_start;
1577 while(pDestination_tmp >= pDestination_end)
1578 { 1734 {
1579 *(__IO uint8_t*)pDestination_tmp = colormask; 1735 pDestination_tmp = pDestination_start;
1580 pDestination_tmp += 1; 1736 while(pDestination_tmp >= pDestination_end)
1581 *(__IO uint8_t*)pDestination_tmp = 0xFF; 1737 {
1582 pDestination_tmp -= 3; 1738 *(__IO uint16_t*)pDestination_tmp = (0xFF << 8) | colormask ;
1739 pDestination_tmp--;
1740 }
1583 } 1741 }
1584 while((drawVeilUntil > 0) && (pDestination_tmp >= pDestination_zero_veil)) 1742
1743 if(!pSettings->FlipDisplay)
1585 { 1744 {
1586 *(__IO uint8_t*)pDestination_tmp = colormask; 1745 while((drawVeilUntil > 0) && (pDestination_tmp >= pDestination_zero_veil))
1587 pDestination_tmp += 1; 1746 {
1588 *(__IO uint8_t*)pDestination_tmp = 0x20; 1747 *(__IO uint16_t*)pDestination_tmp = (0x20 << 8) | colormask ;
1589 pDestination_tmp -= 3; 1748 pDestination_tmp--;
1749 }
1750 }
1751 else
1752 {
1753 pDestination_tmp = pDestination_start;
1754 while((drawVeilUntil > 0) && (pDestination_tmp <= pDestination_zero_veil))
1755 {
1756 *(__IO uint16_t*)pDestination_tmp = (0x20 << 8) | colormask ;
1757 pDestination_tmp++;
1758 }
1590 } 1759 }
1591 } 1760 }
1592 } 1761 }
1593 h_ulong_old = h_ulong; 1762 h_ulong_old = h_ulong;
1594 // } 1763 // }
1669 } 1838 }
1670 } 1839 }
1671 1840
1672 void GFX_draw_box(GFX_DrawCfgScreen *hgfx, point_t LeftLow, point_t WidthHeight, uint8_t Style, uint8_t color) 1841 void GFX_draw_box(GFX_DrawCfgScreen *hgfx, point_t LeftLow, point_t WidthHeight, uint8_t Style, uint8_t color)
1673 { 1842 {
1674 uint32_t pDestination, pStart; 1843 uint16_t* pDestination;
1844 uint16_t* pStart;
1675 uint32_t j; 1845 uint32_t j;
1676 uint32_t lineWidth, lineHeight; 1846 uint32_t lineWidth, lineHeight;
1677 int x, y; 1847 int x, y;
1678 uint8_t intensity; 1848 uint8_t intensity;
1849 int stepdir;
1679 1850
1680 typedef struct { 1851 typedef struct {
1681 int x; 1852 int x;
1682 int y; 1853 int y;
1683 uint8_t intensity; 1854 uint8_t intensity;
1699 {4,2,255}, 1870 {4,2,255},
1700 {3,2,84}, 1871 {3,2,84},
1701 {4,3,110} 1872 {4,3,110}
1702 }; 1873 };
1703 1874
1875 SSettings* pSettings;
1876 pSettings = settingsGetPointer();
1877
1704 lineWidth = WidthHeight.x; 1878 lineWidth = WidthHeight.x;
1705 lineHeight = WidthHeight.y; 1879 lineHeight = WidthHeight.y;
1706
1707 pStart = (uint32_t)hgfx->FBStartAdress; 1880 pStart = (uint32_t)hgfx->FBStartAdress;
1708 pStart += LeftLow.x * hgfx->ImageHeight * 2; 1881
1709 pStart += LeftLow.y * 2; 1882 if(!pSettings->FlipDisplay)
1883 {
1884 pStart += LeftLow.x * hgfx->ImageHeight;
1885 pStart += LeftLow.y;
1886 stepdir = 1;
1887 }
1888 else
1889 {
1890 pStart += (800 - LeftLow.x - 1) * hgfx->ImageHeight;
1891 pStart += (480 - LeftLow.y);
1892 stepdir = -1;
1893 }
1894 pStart = pStart;
1710 1895
1711 // Untere Linie 1896 // Untere Linie
1712 pDestination = pStart; 1897 pDestination = pStart;
1713 if(Style) 1898 if(Style)
1714 { 1899 {
1715 pDestination += 2 * 10 * hgfx->ImageHeight; 1900 pDestination += stepdir * 10 * hgfx->ImageHeight;
1716 lineWidth -= 18; 1901 lineWidth -= 18;
1717 } 1902 }
1718 for (j = lineWidth; j > 0; j--) 1903 for (j = lineWidth; j > 0; j--)
1719 { 1904 {
1905
1720 *(__IO uint16_t*)pDestination = 0xFF00 + color; 1906 *(__IO uint16_t*)pDestination = 0xFF00 + color;
1721 pDestination += hgfx->ImageHeight * 2; 1907 pDestination += stepdir * hgfx->ImageHeight;
1722 } 1908 }
1723 1909
1724 // Obere Linie 1910 // Obere Linie
1725 pDestination = pStart + 2 * WidthHeight.y; 1911
1912 pDestination = pStart + stepdir * WidthHeight.y;
1726 if(Style) 1913 if(Style)
1727 { 1914 {
1728 pDestination += 2 * 10 * hgfx->ImageHeight; 1915 pDestination += stepdir * 10 * hgfx->ImageHeight;
1729 } 1916 }
1730 1917
1731 for (j = lineWidth; j > 0; j--) 1918 for (j = lineWidth; j > 0; j--)
1732 { 1919 {
1733 *(__IO uint16_t*)pDestination = 0xFF00 + color; 1920 *(__IO uint16_t*)pDestination = 0xFF00 + color;
1734 pDestination += hgfx->ImageHeight * 2; 1921 pDestination += stepdir * hgfx->ImageHeight;
1735 } 1922 }
1736 1923
1737 // Linke Linie 1924 // Linke Linie
1738 pDestination = pStart; 1925 pDestination = pStart;
1926
1739 if(Style) 1927 if(Style)
1740 { 1928 {
1741 pDestination += 2 * 10; 1929 pDestination += stepdir * 10;
1742 lineHeight -= 18; 1930 lineHeight -= 18;
1743 } 1931 }
1744 1932
1745 for (j = lineHeight; j > 0; j--) 1933 for (j = lineHeight; j > 0; j--)
1746 { 1934 {
1747 *(__IO uint16_t*)pDestination = 0xFF00 + color; 1935 *(__IO uint16_t*)pDestination = 0xFF00 + color;
1748 pDestination += 2; 1936 pDestination += stepdir;
1749 } 1937 }
1938
1750 1939
1751 // Rechte Linie 1940 // Rechte Linie
1752 pDestination = pStart + 2 * WidthHeight.x * hgfx->ImageHeight; 1941
1942 pDestination = pStart + stepdir * WidthHeight.x * hgfx->ImageHeight;
1753 if(Style) 1943 if(Style)
1754 { 1944 {
1755 pDestination += 2 * 10; 1945 pDestination += stepdir * 10;
1756 } 1946 }
1757 1947
1758 for (j = lineHeight; j > 0; j--) 1948 for (j = lineHeight; j > 0; j--)
1759 { 1949 {
1760 *(__IO uint16_t*)pDestination = 0xFF00 + color; 1950 *(__IO uint16_t*)pDestination = 0xFF00 + color;
1761 pDestination += 2; 1951 pDestination += stepdir;
1762 } 1952 }
1953
1763 1954
1764 // Ecken wenn notwendig == Style 1955 // Ecken wenn notwendig == Style
1765 if(Style) 1956 if(Style)
1766 { 1957 {
1767 // links unten 1958 // links unten
1768 pDestination = pStart; 1959 pDestination = pStart;
1769 x = corner[0].x; 1960 x = corner[0].x;
1770 y = corner[0].y; 1961 y = corner[0].y;
1771 intensity = corner[0].intensity; 1962 intensity = corner[0].intensity;
1772 *(__IO uint16_t*)(pDestination + 2 * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; 1963
1964 *(__IO uint16_t*)(pDestination + stepdir * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color;
1773 1965
1774 for(j = 15; j > 0; j--) 1966 for(j = 15; j > 0; j--)
1775 { 1967 {
1776 x = corner[j].x; 1968 x = corner[j].x;
1777 y = corner[j].y; 1969 y = corner[j].y;
1778 intensity = corner[j].intensity; 1970 intensity = corner[j].intensity;
1779 *(__IO uint16_t*)(pDestination + 2 * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; 1971 *(__IO uint16_t*)(pDestination + stepdir * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color;
1780 *(__IO uint16_t*)(pDestination + 2 * (x + (y * hgfx->ImageHeight))) = (intensity << 8) + color; 1972 *(__IO uint16_t*)(pDestination + stepdir * (x + (y * hgfx->ImageHeight))) = (intensity << 8) + color;
1781 } 1973 }
1782 // links oben 1974 // links oben
1783 pDestination = pStart + 2 * WidthHeight.y; 1975 pDestination = pStart + stepdir * WidthHeight.y;
1784 x = corner[0].x; 1976 x = corner[0].x;
1785 y = corner[0].y; 1977 y = corner[0].y;
1786 intensity = corner[0].intensity; 1978 intensity = corner[0].intensity;
1787 *(__IO uint16_t*)(pDestination + 2 * (-y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; 1979 *(__IO uint16_t*)(pDestination + stepdir * (-y + (x * hgfx->ImageHeight))) = (intensity << 8) + color;
1788 1980
1789 for(j = 15; j > 0; j--) 1981 for(j = 15; j > 0; j--)
1790 { 1982 {
1791 x = corner[j].x; 1983 x = corner[j].x;
1792 y = corner[j].y; 1984 y = corner[j].y;
1793 intensity = corner[j].intensity; 1985 intensity = corner[j].intensity;
1794 *(__IO uint16_t*)(pDestination + 2 * (-y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; 1986 *(__IO uint16_t*)(pDestination + stepdir * (-y + (x * hgfx->ImageHeight))) = (intensity << 8) + color;
1795 *(__IO uint16_t*)(pDestination + 2 * (-x + (y * hgfx->ImageHeight))) = (intensity << 8) + color; 1987 *(__IO uint16_t*)(pDestination + stepdir * (-x + (y * hgfx->ImageHeight))) = (intensity << 8) + color;
1796 } 1988 }
1797 // rechts unten 1989 // rechts unten
1798 pDestination = pStart + 2 * WidthHeight.x * hgfx->ImageHeight; 1990 pDestination = pStart + stepdir * WidthHeight.x * hgfx->ImageHeight;
1799 x = corner[0].x; 1991 x = corner[0].x;
1800 y = corner[0].y; 1992 y = corner[0].y;
1801 intensity = corner[0].intensity; 1993 intensity = corner[0].intensity;
1802 *(__IO uint16_t*)(pDestination + 2 * (y - (x * hgfx->ImageHeight))) = (intensity << 8) + color; 1994 *(__IO uint16_t*)(pDestination + stepdir * (y - (x * hgfx->ImageHeight))) = (intensity << 8) + color;
1803 1995
1804 for(j = 15; j > 0; j--) 1996 for(j = 15; j > 0; j--)
1805 { 1997 {
1806 x = corner[j].x; 1998 x = corner[j].x;
1807 y = corner[j].y; 1999 y = corner[j].y;
1808 intensity = corner[j].intensity; 2000 intensity = corner[j].intensity;
1809 *(__IO uint16_t*)(pDestination + 2 * (y - (x * hgfx->ImageHeight))) = (intensity << 8) + color; 2001 *(__IO uint16_t*)(pDestination + stepdir * (y - (x * hgfx->ImageHeight))) = (intensity << 8) + color;
1810 *(__IO uint16_t*)(pDestination + 2 * (x - (y * hgfx->ImageHeight))) = (intensity << 8) + color; 2002 *(__IO uint16_t*)(pDestination + stepdir * (x - (y * hgfx->ImageHeight))) = (intensity << 8) + color;
1811 } 2003 }
1812 // rechts oben 2004 // rechts oben
1813 pDestination = pStart + 2 * WidthHeight.y + 2 * WidthHeight.x * hgfx->ImageHeight; 2005 pDestination = pStart + stepdir * WidthHeight.y + stepdir * WidthHeight.x * hgfx->ImageHeight;
1814 x = corner[0].x; 2006 x = corner[0].x;
1815 y = corner[0].y; 2007 y = corner[0].y;
1816 intensity = corner[0].intensity; 2008 intensity = corner[0].intensity;
1817 *(__IO uint16_t*)(pDestination - 2 * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; 2009 *(__IO uint16_t*)(pDestination + stepdir * -1 * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color;
1818 2010
1819 for(j = 15; j > 0; j--) 2011 for(j = 15; j > 0; j--)
1820 { 2012 {
1821 x = corner[j].x; 2013 x = corner[j].x;
1822 y = corner[j].y; 2014 y = corner[j].y;
1823 intensity = corner[j].intensity; 2015 intensity = corner[j].intensity;
1824 *(__IO uint16_t*)(pDestination - 2 * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; 2016 *(__IO uint16_t*)(pDestination + stepdir * -1 * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color;
1825 *(__IO uint16_t*)(pDestination - 2 * (x + (y * hgfx->ImageHeight))) = (intensity << 8) + color; 2017 *(__IO uint16_t*)(pDestination + stepdir * -1 * (x + (y * hgfx->ImageHeight))) = (intensity << 8) + color;
1826 } 2018 }
1827 } 2019 }
1828 } 2020 }
1829 2021
1830 2022
1869 void Gfx_write_label_var(GFX_DrawCfgScreen *screenInput, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const uint8_t color, const char *text) 2061 void Gfx_write_label_var(GFX_DrawCfgScreen *screenInput, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const uint8_t color, const char *text)
1870 { 2062 {
1871 2063
1872 GFX_DrawCfgWindow hgfx; 2064 GFX_DrawCfgWindow hgfx;
1873 2065
2066
2067 SSettings* pSettings;
2068 pSettings = settingsGetPointer();
2069
2070
1874 if(XrightGimpStyle > 799) 2071 if(XrightGimpStyle > 799)
1875 XrightGimpStyle = 799; 2072 XrightGimpStyle = 799;
1876 if(XleftGimpStyle >= XrightGimpStyle) 2073 if(XleftGimpStyle >= XrightGimpStyle)
1877 XleftGimpStyle = 0; 2074 XleftGimpStyle = 0;
1878 if(YtopGimpStyle > 479) 2075 if(YtopGimpStyle > 479)
1879 YtopGimpStyle = 479; 2076 YtopGimpStyle = 479;
1880 hgfx.Image = screenInput; 2077 hgfx.Image = screenInput;
1881 hgfx.WindowNumberOfTextLines = 1; 2078 hgfx.WindowNumberOfTextLines = 1;
1882 hgfx.WindowLineSpacing = 0; 2079 hgfx.WindowLineSpacing = 0;
1883 hgfx.WindowTab = 0; 2080 hgfx.WindowTab = 0;
1884 hgfx.WindowX0 = XleftGimpStyle; 2081
1885 hgfx.WindowX1 = XrightGimpStyle; 2082 if(!pSettings->FlipDisplay)
1886 hgfx.WindowY1 = 479 - YtopGimpStyle; 2083 {
1887 if(hgfx.WindowY1 < Font->height) 2084 hgfx.WindowX0 = XleftGimpStyle;
1888 hgfx.WindowY0 = 0; 2085 hgfx.WindowX1 = XrightGimpStyle;
2086 hgfx.WindowY1 = 479 - YtopGimpStyle;
2087 if(hgfx.WindowY1 < Font->height)
2088 hgfx.WindowY0 = 0;
2089 else
2090 hgfx.WindowY0 = hgfx.WindowY1 - Font->height;
2091 }
1889 else 2092 else
1890 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; 2093 {
1891 2094 hgfx.WindowX0 = 800 - XrightGimpStyle;
2095 hgfx.WindowX1 = 800 - XleftGimpStyle;
2096 hgfx.WindowY0 = YtopGimpStyle;
2097 if(hgfx.WindowY0 + Font->height > 480)
2098 hgfx.WindowY1 = 480;
2099 else
2100 hgfx.WindowY1 = hgfx.WindowY0 + Font->height;
2101 }
1892 GFX_write_label(Font, &hgfx, text, color); 2102 GFX_write_label(Font, &hgfx, text, color);
1893 } 2103 }
1894 2104
1895 /** 2105 /**
1896 ****************************************************************************** 2106 ******************************************************************************
2372 static uint32_t GFX_write_char_doubleSize(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font) 2582 static uint32_t GFX_write_char_doubleSize(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font)
2373 { 2583 {
2374 uint32_t i, j; 2584 uint32_t i, j;
2375 uint32_t width, height; 2585 uint32_t width, height;
2376 uint32_t found; 2586 uint32_t found;
2377 uint32_t pDestination; 2587 uint16_t* pDestination;
2378 uint32_t pDestinationColor; 2588 uint32_t pDestinationColor;
2379 uint32_t pSource; 2589 uint32_t pSource;
2380 uint32_t OffsetDestination; 2590 uint32_t OffsetDestination;
2381 uint32_t width_left; 2591 uint32_t width_left;
2382 uint32_t height_left; 2592 uint32_t height_left;
2383 uint32_t char_truncated_WidthFlag; 2593 uint32_t char_truncated_WidthFlag;
2384 uint32_t char_truncated_Height; 2594 uint32_t char_truncated_Height;
2385 uint8_t fill; 2595 uint8_t fill;
2386 uint32_t widthFont, heightFont; 2596 uint32_t widthFont, heightFont;
2387 uint32_t nextLine; 2597 uint32_t nextLine;
2388 2598 int32_t stepdir;
2599
2600 SSettings* pSettings;
2601 pSettings = settingsGetPointer();
2602
2603 if(pSettings->FlipDisplay)
2604 {
2605 stepdir = -1; /* decrement address while putting pixels */
2606 }
2607 else
2608 {
2609 stepdir = 1;
2610 }
2611
2389 2612
2390 if(hgfx->Image->ImageWidth <= (hgfx->WindowX0 + cfg->Xdelta)) 2613 if(hgfx->Image->ImageWidth <= (hgfx->WindowX0 + cfg->Xdelta))
2391 return 0x0000FFFF; 2614 return 0x0000FFFF;
2392 2615
2393 // ----------------------------- 2616 // -----------------------------
2409 heightFont = Font->chars[i].image->height; 2632 heightFont = Font->chars[i].image->height;
2410 widthFont = Font->chars[i].image->width; 2633 widthFont = Font->chars[i].image->width;
2411 2634
2412 height = heightFont*2; 2635 height = heightFont*2;
2413 width = widthFont*2; 2636 width = widthFont*2;
2414 2637
2415 OffsetDestination = 2 * (hgfx->Image->ImageHeight - height); 2638
2416 2639 if(pSettings->FlipDisplay)
2417 pDestination += (hgfx->WindowX0 + cfg->Xdelta) * hgfx->Image->ImageHeight * 2; 2640 {
2418 pDestination += (hgfx->WindowY0 + cfg->Ydelta) * 2; 2641 pDestination += (uint32_t)(hgfx->WindowX1 - cfg->Xdelta) * hgfx->Image->ImageHeight; /* set pointer to delta row */
2419 nextLine = hgfx->Image->ImageHeight * 2; 2642 pDestination += (hgfx->WindowY1 - cfg->Ydelta); /* set pointer to delta colum */
2643 }
2644 else
2645 {
2646 pDestination += (uint32_t)(hgfx->WindowX0 + cfg->Xdelta) * hgfx->Image->ImageHeight; /* set pointer to delta row */
2647 pDestination += (hgfx->WindowY0 + cfg->Ydelta); /* set pointer to delta colum */
2648 }
2649 OffsetDestination = (hgfx->Image->ImageHeight - height);
2650 nextLine = hgfx->Image->ImageHeight;
2420 2651
2421 // ----------------------------- 2652 // -----------------------------
2422 char_truncated_WidthFlag = 0; 2653 char_truncated_WidthFlag = 0;
2423 width_left = hgfx->Image->ImageWidth - (hgfx->WindowX0 + cfg->Xdelta); 2654 width_left = hgfx->Image->ImageWidth - (hgfx->WindowX0 + cfg->Xdelta);
2655
2424 if(width_left < width) 2656 if(width_left < width)
2425 { 2657 {
2426 char_truncated_WidthFlag = 1; 2658 char_truncated_WidthFlag = 1;
2427 width = width_left; 2659 width = width_left;
2428 widthFont = width/2; 2660 widthFont = width/2;
2429 } 2661 }
2430 // ----------------------------- 2662 // -----------------------------
2663
2431 char_truncated_Height = 0; 2664 char_truncated_Height = 0;
2432 height_left = hgfx->Image->ImageHeight - (hgfx->WindowY0 + cfg->Ydelta); 2665 height_left = hgfx->Image->ImageHeight - (hgfx->WindowY0 + cfg->Ydelta);
2433 if(height_left < height) 2666 if(height_left < height)
2434 { 2667 {
2435 char_truncated_Height = height - height_left; 2668 char_truncated_Height = height - height_left;
2439 char_truncated_Height += 1; 2672 char_truncated_Height += 1;
2440 } 2673 }
2441 height = height_left; 2674 height = height_left;
2442 heightFont = height/2; 2675 heightFont = height/2;
2443 } 2676 }
2444 OffsetDestination += 2 * char_truncated_Height; 2677
2678 OffsetDestination += char_truncated_Height;
2445 // ----------------------------- 2679 // -----------------------------
2446 if(height == 0) 2680 if(height == 0)
2447 return 0x0000FFFF; 2681 return 0x0000FFFF;
2448 // ----------------------------- 2682 // -----------------------------
2449
2450 if((cfg->color > 0) )
2451 {
2452 pDestinationColor = pDestination - 1;
2453
2454 for(i = width; i > 0; i--)
2455 {
2456 for (j = height; j > 0; j--)
2457 {
2458 *(__IO uint32_t*)pDestinationColor = cfg->color;
2459 pDestinationColor += 2;
2460 }
2461 pDestinationColor += OffsetDestination;
2462 }
2463 }
2464 2683
2465 if(cfg->singleSpaceWithSizeOfNextChar) 2684 if(cfg->singleSpaceWithSizeOfNextChar)
2466 { 2685 {
2467 cfg->singleSpaceWithSizeOfNextChar = 0; 2686 cfg->singleSpaceWithSizeOfNextChar = 0;
2468 2687
2474 height /= 2; 2693 height /= 2;
2475 for(i = width; i > 0; i--) 2694 for(i = width; i > 0; i--)
2476 { 2695 {
2477 for (j = height; j > 0; j--) 2696 for (j = height; j > 0; j--)
2478 { 2697 {
2479 *(__IO uint8_t*)pDestination = fill; 2698 *(__IO uint16_t*)pDestination = cfg->color << 8 | fill;
2480 pDestination += 2; 2699 pDestination += stepdir;
2481 *(__IO uint8_t*)pDestination = fill; 2700 *(__IO uint16_t*)pDestination = cfg->color << 8 | fill;
2482 pDestination += 2; 2701 pDestination += stepdir;
2483 } 2702 }
2484 pDestination += OffsetDestination; 2703 pDestination += stepdir * OffsetDestination;
2485 } 2704 }
2486 } 2705 }
2487 else 2706 else
2488 if(cfg->invert) 2707 if(cfg->invert)
2489 { 2708 {
2494 { 2713 {
2495 if(*(uint8_t*)pSource != 0x01) 2714 if(*(uint8_t*)pSource != 0x01)
2496 { 2715 {
2497 for (j = heightFont; j > 0; j--) 2716 for (j = heightFont; j > 0; j--)
2498 { 2717 {
2499 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 2718 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2500 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF - *(uint8_t*)pSource; 2719 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2501 pDestination += 2; 2720 pDestination += stepdir;
2502 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 2721 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2503 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF - *(uint8_t*)pSource; 2722 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2723 pDestination += stepdir;
2504 pSource++; 2724 pSource++;
2505 pDestination += 2; 2725
2506 2726 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2507 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 2727 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2508 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF - *(uint8_t*)pSource; 2728 pDestination += stepdir;
2509 pDestination += 2; 2729 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2510 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 2730 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2511 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF - *(uint8_t*)pSource; 2731 pDestination += stepdir;
2512 pSource++; 2732 pSource++;
2513 pDestination += 2; 2733
2514 2734 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2515 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 2735 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2516 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF - *(uint8_t*)pSource; 2736 pDestination += stepdir;
2517 pDestination += 2; 2737 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2518 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 2738 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2519 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF - *(uint8_t*)pSource; 2739 pDestination += stepdir;
2520 pSource++; 2740 pSource++;
2521 pDestination += 2; 2741
2522 2742 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2523 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 2743 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2524 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF - *(uint8_t*)pSource; 2744 pDestination += stepdir;
2525 pDestination += 2; 2745 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2526 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 2746 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2527 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF - *(uint8_t*)pSource; 2747 pDestination += stepdir;
2528 pSource++; 2748 pSource++;
2529 pDestination += 2;
2530 } 2749 }
2531 pSource += char_truncated_Height; 2750 pSource += char_truncated_Height;
2532 } 2751 }
2533 else 2752 else
2534 { 2753 {
2535 pSource++; 2754 pSource++;
2536 for (j = height; j > 0; j--) 2755 for (j = height; j > 0; j--)
2537 { 2756 {
2538 *(__IO uint8_t*)pDestination = 0xFF; 2757 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2539 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF; 2758 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 |0xFF;
2540 pDestination += 2; 2759 pDestination += stepdir;
2541 *(__IO uint8_t*)pDestination = 0xFF; 2760 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2542 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF; 2761 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | 0xFF;
2543 pDestination += 2; 2762 pDestination += stepdir;
2544 *(__IO uint8_t*)pDestination = 0xFF; 2763 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2545 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF; 2764 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | 0xFF;
2546 pDestination += 2; 2765 pDestination += stepdir;
2547 *(__IO uint8_t*)pDestination = 0xFF; 2766 *(__IO uint16_t*)pDestination = cfg->color << 8 |0xFF;
2548 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF; 2767 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | 0xFF;
2549 pDestination += 2; 2768 pDestination += stepdir;
2550 *(__IO uint8_t*)pDestination = 0xFF; 2769 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2551 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF; 2770 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | 0xFF;
2552 pDestination += 2; 2771 pDestination += stepdir;
2553 *(__IO uint8_t*)pDestination = 0xFF; 2772 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2554 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF; 2773 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | 0xFF;
2555 pDestination += 2; 2774 pDestination += stepdir;
2556 *(__IO uint8_t*)pDestination = 0xFF; 2775 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2557 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF; 2776 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | 0xFF;
2558 pDestination += 2; 2777 pDestination += stepdir;
2559 *(__IO uint8_t*)pDestination = 0xFF; 2778 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2560 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF; 2779 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | 0xFF;
2561 pDestination += 2; 2780 pDestination += stepdir;
2562 } 2781 }
2563 } 2782 }
2564 pDestination += OffsetDestination + nextLine; 2783 pDestination += (OffsetDestination + nextLine) * stepdir;
2565 } 2784 }
2566 } 2785 }
2567 else 2786 else
2568 { 2787 {
2569 heightFont /= 2; 2788 heightFont /= 2;
2571 { 2790 {
2572 if(*(uint8_t*)pSource != 0x01) 2791 if(*(uint8_t*)pSource != 0x01)
2573 { 2792 {
2574 for (j = heightFont; j > 0; j--) 2793 for (j = heightFont; j > 0; j--)
2575 { 2794 {
2576 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 2795 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2577 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF - *(uint8_t*)pSource; 2796 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2578 pDestination += 2; 2797 pDestination += stepdir;
2579 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 2798 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2580 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF - *(uint8_t*)pSource; 2799 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2800 pDestination += stepdir;
2581 pSource++; 2801 pSource++;
2582 pDestination += 2; 2802
2583 2803 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2584 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 2804 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2585 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF - *(uint8_t*)pSource; 2805 pDestination += stepdir;
2586 pDestination += 2; 2806 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2587 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 2807 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | (0xFF - *(uint8_t*)pSource);
2588 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF - *(uint8_t*)pSource; 2808 pDestination += stepdir;
2589 pSource++; 2809 pSource++;
2590 pDestination += 2;
2591 } 2810 }
2592 pSource += char_truncated_Height; 2811 pSource += char_truncated_Height;
2593 } 2812 }
2594 else 2813 else
2595 { 2814 {
2596 pSource++; 2815 pSource++;
2597 for (j = heightFont; j > 0; j--) 2816 for (j = heightFont; j > 0; j--)
2598 { 2817 {
2599 *(__IO uint8_t*)pDestination = 0xFF; 2818 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2600 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF; 2819 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | 0xFF;
2601 pDestination += 2; 2820 pDestination += stepdir;
2602 *(__IO uint8_t*)pDestination = 0xFF; 2821 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2603 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF; 2822 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | 0xFF;
2604 pDestination += 2; 2823 pDestination += stepdir;
2605 *(__IO uint8_t*)pDestination = 0xFF; 2824 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2606 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF; 2825 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | 0xFF;
2607 pDestination += 2; 2826 pDestination += stepdir;
2608 *(__IO uint8_t*)pDestination = 0xFF; 2827 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2609 *(__IO uint8_t*)(pDestination + nextLine) = 0xFF; 2828 *(__IO uint16_t*)(pDestination + nextLine) = cfg->color << 8 | 0xFF;
2610 pDestination += 2; 2829 pDestination += stepdir;
2611 } 2830 }
2612 } 2831 }
2613 pDestination += OffsetDestination + nextLine; 2832 pDestination += (OffsetDestination + nextLine) * stepdir;
2614 } 2833 }
2615 } 2834 }
2616 } 2835 } /* inverted */
2617 else 2836 else
2618 { 2837 {
2619 if((heightFont & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */ 2838 if((heightFont & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */
2620 { 2839 {
2621 heightFont /= 4; 2840 heightFont /= 4;
2623 { 2842 {
2624 if(*(uint8_t*)pSource != 0x01) 2843 if(*(uint8_t*)pSource != 0x01)
2625 { 2844 {
2626 for (j = heightFont; j > 0; j--) 2845 for (j = heightFont; j > 0; j--)
2627 { 2846 {
2628 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 2847 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource;
2629 *(__IO uint8_t*)(pDestination + nextLine) = *(uint8_t*)pSource; 2848 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = cfg->color << 8 | *(uint8_t*)pSource;
2630 pDestination += 2; 2849 pDestination += stepdir;
2631 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 2850 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource;
2632 *(__IO uint8_t*)(pDestination + nextLine) = *(uint8_t*)pSource; 2851 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = cfg->color << 8 | *(uint8_t*)pSource;
2852 pDestination += stepdir;
2633 pSource++; 2853 pSource++;
2634 pDestination += 2; 2854
2635 2855 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource;
2636 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 2856 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = cfg->color << 8 | *(uint8_t*)pSource;
2637 *(__IO uint8_t*)(pDestination + nextLine) = *(uint8_t*)pSource; 2857 pDestination += stepdir;
2638 pDestination += 2; 2858 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource;
2639 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 2859 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = cfg->color << 8 | *(uint8_t*)pSource;
2640 *(__IO uint8_t*)(pDestination + nextLine) = *(uint8_t*)pSource; 2860 pDestination += stepdir;
2641 pSource++; 2861 pSource++;
2642 pDestination += 2; 2862
2643 2863 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource;
2644 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 2864 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = cfg->color << 8 | *(uint8_t*)pSource;
2645 *(__IO uint8_t*)(pDestination + nextLine) = *(uint8_t*)pSource; 2865 pDestination += stepdir;
2646 pDestination += 2; 2866 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource;
2647 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 2867 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = cfg->color << 8 | *(uint8_t*)pSource;
2648 *(__IO uint8_t*)(pDestination + nextLine) = *(uint8_t*)pSource; 2868 pDestination += stepdir;
2649 pSource++; 2869 pSource++;
2650 pDestination += 2; 2870
2651 2871 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource;
2652 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 2872 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = cfg->color << 8 | *(uint8_t*)pSource;
2653 *(__IO uint8_t*)(pDestination + nextLine) = *(uint8_t*)pSource; 2873 pDestination += stepdir;
2654 pDestination += 2; 2874 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource;
2655 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 2875 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = cfg->color << 8 | *(uint8_t*)pSource;
2656 *(__IO uint8_t*)(pDestination + nextLine) = *(uint8_t*)pSource; 2876 pDestination += stepdir;
2657 pSource++; 2877 pSource++;
2658 pDestination += 2;
2659 } 2878 }
2660 pSource += char_truncated_Height; 2879 pSource += char_truncated_Height;
2661 } 2880 }
2662 else 2881 else
2663 { 2882 {
2664 pSource++; 2883 pSource++;
2665 pDestination += 2 * height; 2884 pDestination += stepdir * height;
2666 } 2885 }
2667 pDestination += OffsetDestination + nextLine; 2886 pDestination += stepdir * (OffsetDestination + nextLine);
2668 } 2887 }
2669 } 2888 }
2670 else 2889 else
2671 { 2890 {
2672 heightFont /= 2; 2891 heightFont /= 2;
2674 { 2893 {
2675 if(*(uint8_t*)pSource != 0x01) 2894 if(*(uint8_t*)pSource != 0x01)
2676 { 2895 {
2677 for (j = heightFont; j > 0; j--) 2896 for (j = heightFont; j > 0; j--)
2678 { 2897 {
2679 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 2898 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource;
2680 *(__IO uint8_t*)(pDestination + nextLine) = *(uint8_t*)pSource; 2899 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = cfg->color << 8 | *(uint8_t*)pSource;
2681 pDestination += 2; 2900 pDestination += stepdir;
2682 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 2901 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource;
2683 *(__IO uint8_t*)(pDestination + nextLine) = *(uint8_t*)pSource; 2902 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = cfg->color << 8 | *(uint8_t*)pSource;
2903 pDestination += stepdir;
2684 pSource++; 2904 pSource++;
2685 pDestination += 2; 2905
2686 2906 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource;
2687 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 2907 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = cfg->color << 8 | *(uint8_t*)pSource;
2688 *(__IO uint8_t*)(pDestination + nextLine) = *(uint8_t*)pSource; 2908 pDestination += stepdir;
2689 pDestination += 2; 2909 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource;
2690 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 2910 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = cfg->color << 8 | *(uint8_t*)pSource;
2691 *(__IO uint8_t*)(pDestination + nextLine) = *(uint8_t*)pSource; 2911 pDestination += stepdir;
2692 pSource++; 2912 pSource++;
2693 pDestination += 2;
2694 } 2913 }
2695 pSource += char_truncated_Height; 2914 pSource += char_truncated_Height;
2696 } 2915 }
2697 else 2916 else
2698 { 2917 {
2699 pSource++; 2918 pSource++;
2700 pDestination += 2 * height; 2919 pDestination += stepdir * height;
2701 } 2920 }
2702 pDestination += OffsetDestination + nextLine; 2921 pDestination += stepdir * (OffsetDestination + nextLine);
2703 } 2922 }
2704 } 2923 }
2705 } 2924 }
2706 2925
2707 // ----------------------------- 2926 // -----------------------------
2745 } 2964 }
2746 2965
2747 uint32_t i, j; 2966 uint32_t i, j;
2748 uint32_t width, height; 2967 uint32_t width, height;
2749 uint32_t found; 2968 uint32_t found;
2750 uint32_t pDestination; 2969 uint16_t* pDestination;
2751 uint32_t pDestinationColor; 2970 uint32_t pDestinationColor;
2752 uint32_t pSource; 2971 uint32_t pSource;
2753 uint32_t OffsetDestination; 2972 uint32_t OffsetDestination;
2754 uint32_t width_left; 2973 uint32_t width_left;
2755 uint32_t height_left; 2974 uint32_t height_left;
2756 uint32_t char_truncated_WidthFlag; 2975 uint32_t char_truncated_WidthFlag;
2757 uint32_t char_truncated_Height; 2976 uint32_t char_truncated_Height;
2758 uint8_t fill; 2977 uint8_t fill;
2978 int16_t stepdir;
2979
2980 SSettings* pSettings;
2981 pSettings = settingsGetPointer();
2982
2983 if(pSettings->FlipDisplay)
2984 {
2985 stepdir = -1; /* decrement address while putting pixels */
2986 }
2987 else
2988 {
2989 stepdir = 1;
2990 }
2759 2991
2760 if(hgfx->Image->ImageWidth <= (hgfx->WindowX0 + cfg->Xdelta)) 2992 if(hgfx->Image->ImageWidth <= (hgfx->WindowX0 + cfg->Xdelta))
2761 return 0x0000FFFF; 2993 return 0x0000FFFF;
2762 2994
2763 // ----------------------------- 2995 // -----------------------------
2782 */ 3014 */
2783 // ----------------------------- 3015 // -----------------------------
2784 3016
2785 3017
2786 pSource = ((uint32_t)Font->chars[i].image->data); 3018 pSource = ((uint32_t)Font->chars[i].image->data);
2787 pDestination = 1 + (uint32_t)hgfx->Image->FBStartAdress; 3019 pDestination = (uint32_t)hgfx->Image->FBStartAdress + 1;
2788 3020
2789 height = Font->chars[i].image->height; 3021 height = Font->chars[i].image->height;
2790 width = Font->chars[i].image->width; 3022 width = Font->chars[i].image->width;
2791 3023
2792 OffsetDestination = 2 * (hgfx->Image->ImageHeight - height); 3024 OffsetDestination = hgfx->Image->ImageHeight - height;
2793 3025
2794 pDestination += (hgfx->WindowX0 + cfg->Xdelta) * hgfx->Image->ImageHeight * 2; 3026
2795 pDestination += (hgfx->WindowY0 + cfg->Ydelta) * 2; 3027 /* Xyyyyy y= height */
2796 3028 /* Xyyyyy x= width */
3029 /* Xyyyyy */
3030
3031 if(pSettings->FlipDisplay)
3032 {
3033 pDestination += (hgfx->WindowX1 - cfg->Xdelta) * hgfx->Image->ImageHeight; /* set pointer to delta row */
3034 pDestination += (hgfx->WindowY1 - cfg->Ydelta); /* set pointer to delta colum */
3035 }
3036 else
3037 {
3038 pDestination += (hgfx->WindowX0 + cfg->Xdelta) * hgfx->Image->ImageHeight; /* set pointer to delta row */
3039 pDestination += (hgfx->WindowY0 + cfg->Ydelta); /* set pointer to delta colum */
3040 }
2797 3041
2798 3042
2799 // ----------------------------- 3043 // -----------------------------
2800 char_truncated_WidthFlag = 0; 3044 char_truncated_WidthFlag = 0;
2801 width_left = hgfx->Image->ImageWidth - (hgfx->WindowX0 + cfg->Xdelta); 3045 width_left = hgfx->Image->ImageWidth - (hgfx->WindowX0 + cfg->Xdelta);
2815 height_left -= 1; 3059 height_left -= 1;
2816 char_truncated_Height += 1; 3060 char_truncated_Height += 1;
2817 } 3061 }
2818 height = height_left; 3062 height = height_left;
2819 } 3063 }
2820 OffsetDestination += 2 * char_truncated_Height; 3064 OffsetDestination += char_truncated_Height;
2821 // ----------------------------- 3065 // -----------------------------
2822 if(height == 0) 3066 if(height == 0)
2823 return 0x0000FFFF; 3067 return 0x0000FFFF;
2824 // ----------------------------- 3068 // -----------------------------
2825 3069
2826 if((cfg->color > 0) )//&& (cfg->color < 6))
2827 {
2828 pDestinationColor = pDestination - 1;
2829
2830 for(i = width; i > 0; i--)
2831 {
2832 for (j = height; j > 0; j--)
2833 {
2834 *(__IO uint32_t*)pDestinationColor = cfg->color;//ColorLUT[cfg->color - 1];
2835 pDestinationColor += 2;
2836 }
2837 pDestinationColor += OffsetDestination;
2838 }
2839 }
2840
2841 if(cfg->singleSpaceWithSizeOfNextChar) 3070 if(cfg->singleSpaceWithSizeOfNextChar)
2842 { 3071 {
2843 cfg->singleSpaceWithSizeOfNextChar = 0; 3072 cfg->singleSpaceWithSizeOfNextChar = 0;
2844 3073
2845 if(cfg->invert) 3074 if(cfg->invert)
2850 height /= 2; 3079 height /= 2;
2851 for(i = width; i > 0; i--) 3080 for(i = width; i > 0; i--)
2852 { 3081 {
2853 for (j = height; j > 0; j--) 3082 for (j = height; j > 0; j--)
2854 { 3083 {
2855 *(__IO uint8_t*)pDestination = fill; 3084 *(__IO uint16_t*)pDestination = cfg->color << 8 | fill;
2856 pDestination += 2; 3085 pDestination += stepdir;
2857 *(__IO uint8_t*)pDestination = fill; 3086 *(__IO uint16_t*)pDestination = cfg->color << 8 | fill;
2858 pDestination += 2; 3087 pDestination += stepdir;
2859 } 3088 }
2860 pDestination += OffsetDestination; 3089 pDestination += stepdir * OffsetDestination;
2861 } 3090 }
2862 } 3091 }
2863 else 3092 else
2864 if(cfg->invert) 3093 if(cfg->invert)
2865 { 3094 {
2866 if((height & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */ 3095 if((height & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */
2867 { 3096 {
2868 height /= 4; 3097 height /= 4;
3098 for(i = width; i > 0; i--)
3099 {
3100 if(*(uint8_t*)pSource != 0x01)
3101 {
3102
3103 for (j = height; j > 0; j--)
3104 {
3105 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource++);
3106 pDestination += stepdir;
3107 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource++);
3108 pDestination += stepdir;
3109 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource++);
3110 pDestination += stepdir;
3111 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource++);
3112 pDestination += stepdir;
3113 }
3114 pSource += char_truncated_Height;
3115 }
3116 else /* empty line => fast fill */
3117 {
3118 pSource++;
3119 for (j = height; j > 0; j--)
3120 {
3121 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
3122 pDestination += stepdir;
3123 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
3124 pDestination += stepdir;
3125 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
3126 pDestination += stepdir;
3127 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
3128 pDestination += stepdir;
3129 }
3130 }
3131 pDestination += stepdir * OffsetDestination;
3132 }
3133 }
3134 else
3135 {
3136 height /= 2;
2869 for(i = width; i > 0; i--) 3137 for(i = width; i > 0; i--)
2870 { 3138 {
2871 if(*(uint8_t*)pSource != 0x01) 3139 if(*(uint8_t*)pSource != 0x01)
2872 { 3140 {
2873 for (j = height; j > 0; j--) 3141 for (j = height; j > 0; j--)
2874 { 3142 {
2875 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 3143 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource++);
2876 pSource++; 3144 pDestination += stepdir;
2877 pDestination += 2; 3145 *(__IO uint16_t*)pDestination = cfg->color << 8 | (0xFF - *(uint8_t*)pSource++);
2878 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 3146 pDestination += stepdir;
2879 pSource++;
2880 pDestination += 2;
2881 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource;
2882 pSource++;
2883 pDestination += 2;
2884 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource;
2885 pSource++;
2886 pDestination += 2;
2887 } 3147 }
2888 pSource += char_truncated_Height; 3148 pSource += char_truncated_Height;
2889 } 3149 }
2890 else 3150 else
2891 { 3151 {
2892 pSource++; 3152 pSource++;
2893 for (j = height; j > 0; j--) 3153 for (j = height; j > 0; j--)
2894 { 3154 {
2895 *(__IO uint8_t*)pDestination = 0xFF; 3155 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2896 pDestination += 2; 3156 pDestination += stepdir;
2897 *(__IO uint8_t*)pDestination = 0xFF; 3157 *(__IO uint16_t*)pDestination = cfg->color << 8 | 0xFF;
2898 pDestination += 2; 3158 pDestination += stepdir;
2899 *(__IO uint8_t*)pDestination = 0xFF;
2900 pDestination += 2;
2901 *(__IO uint8_t*)pDestination = 0xFF;
2902 pDestination += 2;
2903 } 3159 }
2904 } 3160 }
2905 pDestination += OffsetDestination; 3161 pDestination += stepdir * OffsetDestination;
2906 } 3162 }
2907 } 3163 }
2908 else 3164 }
2909 { 3165 else /* not inverted */
2910 height /= 2; 3166 {
3167 if((height & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */
3168 {
3169
3170 height /= 4;
3171
2911 for(i = width; i > 0; i--) 3172 for(i = width; i > 0; i--)
2912 { 3173 {
2913 if(*(uint8_t*)pSource != 0x01) 3174 if(*(uint8_t*)pSource != 0x01)
2914 { 3175 {
2915 for (j = height; j > 0; j--) 3176 for (j = height; j > 0; j--)
2916 { 3177 {
2917 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 3178 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource++;
2918 pSource++; 3179 pDestination += stepdir;
2919 pDestination += 2; 3180 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource++;
2920 *(__IO uint8_t*)pDestination = 0xFF - *(uint8_t*)pSource; 3181 pDestination += stepdir;
2921 pSource++; 3182 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource++;
2922 pDestination += 2; 3183 pDestination += stepdir;
3184 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource++;
3185 pDestination += stepdir;
2923 } 3186 }
2924 pSource += char_truncated_Height; 3187 pSource += char_truncated_Height;
2925 } 3188 }
2926 else 3189 else
2927 { 3190 {
2928 pSource++; 3191 pSource++;
2929 for (j = height; j > 0; j--) 3192 pDestination += stepdir * height * 4;
2930 {
2931 *(__IO uint8_t*)pDestination = 0xFF;
2932 pDestination += 2;
2933 *(__IO uint8_t*)pDestination = 0xFF;
2934 pDestination += 2;
2935 }
2936 } 3193 }
2937 pDestination += OffsetDestination; 3194 pDestination += stepdir * OffsetDestination;
2938 } 3195 }
2939 } 3196 }
2940 } 3197
2941 else 3198 else
2942 { 3199 {
2943 if((height & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */ 3200 height /= 2;
2944 {
2945 height /= 4;
2946 for(i = width; i > 0; i--) 3201 for(i = width; i > 0; i--)
2947 { 3202 {
2948 if(*(uint8_t*)pSource != 0x01) 3203 if(*(uint8_t*)pSource != 0x01)
2949 { 3204 {
2950 for (j = height; j > 0; j--) 3205 for (j = height; j > 0; j--)
2951 { 3206 {
2952 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 3207 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource++;
2953 pSource++; 3208 pDestination += stepdir;
2954 pDestination += 2; 3209 *(__IO uint16_t*)pDestination = cfg->color << 8 | *(uint8_t*)pSource++;
2955 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource; 3210 pDestination += stepdir;
2956 pSource++;
2957 pDestination += 2;
2958 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource;
2959 pSource++;
2960 pDestination += 2;
2961 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource;
2962 pSource++;
2963 pDestination += 2;
2964 } 3211 }
2965 pSource += char_truncated_Height; 3212 pSource += char_truncated_Height;
2966 } 3213 }
2967 else 3214 else
2968 { 3215 {
2969 pSource++; 3216 pSource++;
2970 pDestination += 2 * height * 4; 3217 pDestination += stepdir * height * 2;
2971 } 3218 }
2972 pDestination += OffsetDestination; 3219 pDestination += stepdir * OffsetDestination;
2973 }
2974 }
2975 else
2976 {
2977 height /= 2;
2978 for(i = width; i > 0; i--)
2979 {
2980 if(*(uint8_t*)pSource != 0x01)
2981 {
2982 for (j = height; j > 0; j--)
2983 {
2984 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource;
2985 pSource++;
2986 pDestination += 2;
2987 *(__IO uint8_t*)pDestination = *(uint8_t*)pSource;
2988 pSource++;
2989 pDestination += 2;
2990 }
2991 pSource += char_truncated_Height;
2992 }
2993 else
2994 {
2995 pSource++;
2996 pDestination += 2 * height * 2;
2997 }
2998 pDestination += OffsetDestination;
2999 } 3220 }
3000 } 3221 }
3001 } 3222 }
3002 3223
3003 // ----------------------------- 3224 // -----------------------------
3829 4050
3830 void write_content_simple(GFX_DrawCfgScreen *tMscreen, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) 4051 void write_content_simple(GFX_DrawCfgScreen *tMscreen, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color)
3831 { 4052 {
3832 GFX_DrawCfgWindow hgfx; 4053 GFX_DrawCfgWindow hgfx;
3833 4054
3834 if(XrightGimpStyle > 799) 4055 SSettings* pSettings;
3835 XrightGimpStyle = 799; 4056 pSettings = settingsGetPointer();
3836 if(XleftGimpStyle >= XrightGimpStyle) 4057
3837 XleftGimpStyle = 0; 4058 if(!pSettings->FlipDisplay)
3838 if(YtopGimpStyle > 479) 4059 {
3839 YtopGimpStyle = 479; 4060 if(XrightGimpStyle > 799)
4061 XrightGimpStyle = 799;
4062 if(XleftGimpStyle >= XrightGimpStyle)
4063 XleftGimpStyle = 0;
4064 if(YtopGimpStyle > 479)
4065 YtopGimpStyle = 479;
4066 }
3840 hgfx.Image = tMscreen; 4067 hgfx.Image = tMscreen;
3841 hgfx.WindowNumberOfTextLines = 1; 4068 hgfx.WindowNumberOfTextLines = 1;
3842 hgfx.WindowLineSpacing = 0; 4069 hgfx.WindowLineSpacing = 0;
3843 hgfx.WindowTab = 0; 4070 hgfx.WindowTab = 0;
3844 hgfx.WindowX0 = XleftGimpStyle; 4071
3845 hgfx.WindowX1 = XrightGimpStyle; 4072 if(!pSettings->FlipDisplay)
3846 hgfx.WindowY1 = 479 - YtopGimpStyle; 4073 {
3847 if(hgfx.WindowY1 < Font->height) 4074 hgfx.WindowX0 = XleftGimpStyle;
3848 hgfx.WindowY0 = 0; 4075 hgfx.WindowX1 = XrightGimpStyle;
4076 hgfx.WindowY1 = 479 - YtopGimpStyle;
4077 if(hgfx.WindowY1 < Font->height)
4078 hgfx.WindowY0 = 0;
4079 else
4080 hgfx.WindowY0 = hgfx.WindowY1 - Font->height;
4081 }
3849 else 4082 else
3850 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; 4083 {
3851 4084 hgfx.WindowX0 = 800 - XrightGimpStyle;
4085 hgfx.WindowX1 = 800 - XleftGimpStyle;
4086 hgfx.WindowY0 = YtopGimpStyle;
4087 if(hgfx.WindowY0 + Font->height >= 479)
4088 hgfx.WindowY1 = 479;
4089 else
4090 hgfx.WindowY1 = hgfx.WindowY0 + Font->height;
4091 }
3852 GFX_write_string_color(Font, &hgfx, text, 0, color); 4092 GFX_write_string_color(Font, &hgfx, text, 0, color);
3853 } 4093 }
3854 4094
3855 4095
3856 void gfx_write_topline_simple(GFX_DrawCfgScreen *tMscreen, const char *text, uint8_t color) 4096 void gfx_write_topline_simple(GFX_DrawCfgScreen *tMscreen, const char *text, uint8_t color)
3857 { 4097 {
3858 GFX_DrawCfgWindow hgfx; 4098 GFX_DrawCfgWindow hgfx;
3859 const tFont *Font = &FontT48; 4099 const tFont *Font = &FontT48;
3860 4100
4101 hgfx.Image = tMscreen;
4102 hgfx.WindowNumberOfTextLines = 1;
4103 hgfx.WindowLineSpacing = 0;
4104
4105 SSettings* pSettings;
4106 pSettings = settingsGetPointer();
4107
4108 hgfx.WindowTab = 0;
4109 hgfx.WindowX0 = 20;
4110 hgfx.WindowX1 = 779;
4111
4112 if(!pSettings->FlipDisplay)
4113 {
4114 hgfx.WindowY1 = 479;
4115 hgfx.WindowY0 = hgfx.WindowY1 - Font->height;
4116 }
4117 else
4118 {
4119 hgfx.WindowY0 = 0;
4120 hgfx.WindowY1 = Font->height;
4121 }
4122 GFX_write_label(Font, &hgfx, text, color);
4123 }
4124
4125
4126 void gfx_write_page_number(GFX_DrawCfgScreen *tMscreen, uint8_t page, uint8_t total, uint8_t color)
4127 {
4128 GFX_DrawCfgWindow hgfx;
4129 const tFont *Font = &FontT48;
4130 char text[7];
4131 uint8_t i, secondDigitPage, secondDigitTotal;
4132
4133 SSettings* pSettings;
4134 pSettings = settingsGetPointer();
4135
3861 hgfx.Image = tMscreen; 4136 hgfx.Image = tMscreen;
3862 hgfx.WindowNumberOfTextLines = 1; 4137 hgfx.WindowNumberOfTextLines = 1;
3863 hgfx.WindowLineSpacing = 0; 4138 hgfx.WindowLineSpacing = 0;
3864 hgfx.WindowTab = 0; 4139 hgfx.WindowTab = 0;
3865 hgfx.WindowX0 = 20; 4140
3866 hgfx.WindowX1 = 779; 4141 if(!pSettings->FlipDisplay)
3867 hgfx.WindowY1 = 479; 4142 {
3868 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; 4143 hgfx.WindowX1 = 779;
3869 4144 hgfx.WindowX0 = hgfx.WindowX1 - (25*5);
3870 GFX_write_label(Font, &hgfx, text, color); 4145 hgfx.WindowY1 = 479;
3871 4146 hgfx.WindowY0 = hgfx.WindowY1 - Font->height;
3872 } 4147 }
3873 4148 else
3874 4149 {
3875 void gfx_write_page_number(GFX_DrawCfgScreen *tMscreen, uint8_t page, uint8_t total, uint8_t color) 4150 hgfx.WindowX1 = 25*5;
3876 { 4151 hgfx.WindowX0 = 0;
3877 GFX_DrawCfgWindow hgfx; 4152 hgfx.WindowY1 = Font->height;;
3878 const tFont *Font = &FontT48; 4153 hgfx.WindowY0 = 0;
3879 char text[7]; 4154 }
3880 uint8_t i, secondDigitPage, secondDigitTotal;
3881
3882 hgfx.Image = tMscreen;
3883 hgfx.WindowNumberOfTextLines = 1;
3884 hgfx.WindowLineSpacing = 0;
3885 hgfx.WindowTab = 0;
3886 hgfx.WindowX1 = 779;
3887 hgfx.WindowX0 = hgfx.WindowX1 - (25*5);
3888 hgfx.WindowY1 = 479;
3889 hgfx.WindowY0 = hgfx.WindowY1 - Font->height;
3890
3891 if(page > 99) 4155 if(page > 99)
3892 page = 99; 4156 page = 99;
3893 if(total > 99) 4157 if(total > 99)
3894 total = 99; 4158 total = 99;
3895 4159