comparison Discovery/Src/gfx_engine.c @ 160:e3ca52b8e7fa

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