From e8810a10b8d88318d64c7c7b76841eab48d41727 Mon Sep 17 00:00:00 2001 From: GetAway Date: Sun, 2 Jul 2017 15:03:42 +0200 Subject: [PATCH] fix segfault for larger resolutions on Nevis fix icon positioning bump version 4.02 --- fb_display.c | 2 +- gfx.c | 10 ++++++++++ tuxwetter.c | 24 ++++++++++++------------ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/fb_display.c b/fb_display.c index 81e7296..1d0128c 100644 --- a/fb_display.c +++ b/fb_display.c @@ -290,7 +290,7 @@ void blit2FB(void *fbbuff, void setBG() { - RenderBox(0, 0, var_screeninfo.xres, var_screeninfo.yres, 0, 0/*black*/); + RenderBox(0, 0, var_screeninfo.xres-sx, var_screeninfo.yres-sy, 0, 0/*black*/); } void clearBB() diff --git a/gfx.c b/gfx.c index ed0ad7b..942f770 100644 --- a/gfx.c +++ b/gfx.c @@ -32,6 +32,13 @@ void RenderBox(int rsx, int rsy, int rex, int rey, int rad, int col) dxx=0; } + int dyy_max = var_screeninfo.yres; + if (ssy + dyy > dyy_max) + { + printf("[tuxwetter] %s called with max. width = %d (max. %d)\n", __func__, ssy + dyy, var_screeninfo.yres); + dyy = dyy_max - ssy; + } + if(R) { if(--dyy<=0) @@ -123,6 +130,9 @@ int paintIcon(const char *const fname, int xstart, int ystart, int xsize, int ys int imx,imy,dxo,dyo,dxp,dyp; unsigned char *buffer=NULL; + xstart += sx; + ystart += sy; + if((tfh=fopen(fname,"r"))!=NULL) { if(png_getsize(fname, &x1, &y1)) diff --git a/tuxwetter.c b/tuxwetter.c index 3c8dc8b..349aa9a 100644 --- a/tuxwetter.c +++ b/tuxwetter.c @@ -44,7 +44,7 @@ #include "gifdecomp.h" #include "icons.h" -#define P_VERSION "4.0" +#define P_VERSION "4.02" #define S_VERSION "" @@ -73,7 +73,7 @@ static char TCF_FILE[128]=""; #define LCD_RDIST 10 void blit(void) { - memcpy(lfb, lbb, fix_screeninfo.line_length*var_screeninfo.yres*sizeof(uint32_t)); + memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); } // Forward defines @@ -1179,7 +1179,7 @@ void ShowInfo(MENU *m) icon_h = ysize = 32; } multiple_pics=1; - paintIcon(TUX_ICON, isx+44-icon_w/2, (isy+dy-soffs+11)-icon_h/2, xsize, ysize, &iw, &ih); + paintIcon(TUX_ICON, isx+20-icon_w/2, (isy+dy-soffs-4)-icon_h/2, xsize, ysize, &iw, &ih); // Title text RenderString(m->headertxt[m->act_header], isx+47, isy+dy-soffs+11, ixw-sbw-45, LEFT, FSIZE_BIG, CMHT); @@ -1209,10 +1209,10 @@ void ShowInfo(MENU *m) //multiple_pics=1; switch(loop % 10) { - case 0: paintIcon(ICON_BUTTON_RED, isx+42-icon_w/2, isy+my-9+(icon_h)/2, 0, 0, &iw, &ih); break; - case 1: paintIcon(ICON_BUTTON_GREEN, isx+42-icon_w/2, isy+my-9+(icon_h)/2, 0, 0, &iw, &ih); break; - case 2: paintIcon(ICON_BUTTON_YELLOW,isx+42-icon_w/2, isy+my-9+(icon_h)/2, 0, 0, &iw, &ih); break; - case 3: paintIcon(ICON_BUTTON_BLUE, isx+42-icon_w/2, isy+my-9+(icon_h)/2, 0, 0, &iw, &ih); break; + case 0: paintIcon(ICON_BUTTON_RED, isx+18-icon_w/2, isy+my-8-(icon_h)/2, 0, 0, &iw, &ih); break; + case 1: paintIcon(ICON_BUTTON_GREEN, isx+18-icon_w/2, isy+my-8-(icon_h)/2, 0, 0, &iw, &ih); break; + case 2: paintIcon(ICON_BUTTON_YELLOW,isx+18-icon_w/2, isy+my-8-(icon_h)/2, 0, 0, &iw, &ih); break; + case 3: paintIcon(ICON_BUTTON_BLUE, isx+18-icon_w/2, isy+my-8-(icon_h)/2, 0, 0, &iw, &ih); break; default: sprintf(tstr,"%1d",(loop % 10)-3); RenderString(tstr, isx+10, isy+my+4, 15, CENTER, FSIZE_SMALL, ((loop%10) == (tind%10))?CMCST:CMCT); @@ -2256,7 +2256,7 @@ void close_jpg_gif_png(void) ioctl(fb, FBIOPUTCMAP, oldcmap); // for(; sy <= ey; sy++) memset(lbb + sx + var_screeninfo.xres*(sy),TRANSP, ex-sx + 1); memset(lbb, TRANSP, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); - memcpy(lfb, lbb, fix_screeninfo.line_length*var_screeninfo.yres*sizeof(uint32_t)); + memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); #endif gmodeon=0; } @@ -2526,7 +2526,7 @@ unsigned char *buffer=NULL/*,*gbuf*/; #if 0 // don't know what this is about #ifndef HAVE_DREAMBOX_HARDWARE - i=fix_screeninfo.line_length*var_screeninfo.yres*sizeof(uint32_t); + i=var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t); gbuf=lfb; while(i--) if(*gbuf >=127) @@ -3170,7 +3170,7 @@ PLISTENTRY pl=&epl; //init backbuffer - if(!(lbb = malloc(fix_screeninfo.line_length*var_screeninfo.yres*sizeof(uint32_t)))) + if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)))) { perror("tuxwetter \n"); FTC_Manager_Done(manager); @@ -3181,7 +3181,7 @@ PLISTENTRY pl=&epl; stride = fix_screeninfo.line_length/sizeof(uint32_t); - memset(lbb, TRANSP, fix_screeninfo.line_length*var_screeninfo.yres*sizeof(uint32_t)); + memset(lbb, TRANSP, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); startx = sx; starty = sy; @@ -3758,7 +3758,7 @@ PLISTENTRY pl=&epl; free(line_buffer); // clear Display - memset(lbb, TRANSP, fix_screeninfo.line_length*var_screeninfo.yres*sizeof(uint32_t)); + memset(lbb, TRANSP, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); blit(); munmap(lfb, fix_screeninfo.smem_len); close(fb); -- 2.39.5