summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Leonhardt <sebastian.leonhardt@web.de>2016-04-11 23:13:35 +0200
committerSebastian Leonhardt <sebastian.leonhardt@web.de>2018-04-02 20:29:01 +0200
commit96335a7eb2e9cf1e452feac0c8ae0c489197500f (patch)
tree4b324ed3c75d91aebf4b6caf6e68879445a2cff1
parentd5847e8cb2cf6eb5bc6929a13c95a1c563df8bc6 (diff)
downloadrockbox-96335a7eb2e9cf1e452feac0c8ae0c489197500f.tar.gz
rockbox-96335a7eb2e9cf1e452feac0c8ae0c489197500f.zip
pacbox: clean-up screen size code
removes the code duplication for lcd scaling in pacbox.h/pacbox_lcd.h Change-Id: Ib0aeacc9934351c5e32cd4b7576cdc840e6ff7da
-rw-r--r--apps/plugins/pacbox/pacbox.h37
-rw-r--r--apps/plugins/pacbox/pacbox_lcd.c16
2 files changed, 38 insertions, 15 deletions
diff --git a/apps/plugins/pacbox/pacbox.h b/apps/plugins/pacbox/pacbox.h
index bb132f7c4c..77a107bec4 100644
--- a/apps/plugins/pacbox/pacbox.h
+++ b/apps/plugins/pacbox/pacbox.h
@@ -373,22 +373,42 @@
373#endif 373#endif
374#endif 374#endif
375 375
376#if (LCD_HEIGHT >= 288) 376/* Calculate scaling and screen offset/clipping.
377 Put native portrait mode before landscape, if a screen resulution allows both.
378 */
379#if (LCD_WIDTH >= 224) && (LCD_HEIGHT >= 288)
380#define LCD_SCALE 100
381#define LCD_ROTATE 0
377#define XOFS ((LCD_WIDTH-224)/2) 382#define XOFS ((LCD_WIDTH-224)/2)
378#define YOFS ((LCD_HEIGHT-288)/2) 383#define YOFS ((LCD_HEIGHT-288)/2)
379#elif (LCD_WIDTH >= 288) 384
385#elif (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224)
386#define LCD_SCALE 100
387#define LCD_ROTATE 1
380#define XOFS ((LCD_WIDTH-288)/2) 388#define XOFS ((LCD_WIDTH-288)/2)
381#define YOFS ((LCD_HEIGHT-224)/2) 389#define YOFS ((LCD_HEIGHT-224)/2)
382#elif (LCD_WIDTH >= 220) 390
383#define XOFS ((LCD_WIDTH-(288*3/4))/2)
384#define YOFS ((LCD_HEIGHT-(224*3/4))/2)
385#elif (LCD_WIDTH >= 168) && (LCD_HEIGHT >= 216) 391#elif (LCD_WIDTH >= 168) && (LCD_HEIGHT >= 216)
392#define LCD_SCALE 75
393#define LCD_ROTATE 0
386#define XOFS ((LCD_WIDTH-(224*3/4))/2) 394#define XOFS ((LCD_WIDTH-(224*3/4))/2)
387#define YOFS ((LCD_HEIGHT-(288*3/4))/2) 395#define YOFS ((LCD_HEIGHT-(288*3/4))/2)
388#elif (LCD_WIDTH >= 144) 396
397#elif (LCD_WIDTH >= 216) && (LCD_HEIGHT >= 168)
398#define LCD_SCALE 75
399#define LCD_ROTATE 1
400#define XOFS ((LCD_WIDTH-(288*3/4))/2)
401#define YOFS ((LCD_HEIGHT-(224*3/4))/2)
402
403#elif (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112)
404#define LCD_SCALE 50
405#define LCD_ROTATE 1
389#define XOFS ((LCD_WIDTH-288/2)/2) 406#define XOFS ((LCD_WIDTH-288/2)/2)
390#define YOFS ((LCD_HEIGHT-224/2)/2) 407#define YOFS ((LCD_HEIGHT-224/2)/2)
391#elif (LCD_WIDTH >= 128) 408
409#elif (LCD_WIDTH >= 112) && (LCD_HEIGHT >= 128)
410#define LCD_SCALE 50
411#define LCD_ROTATE 0
392#define XOFS ((LCD_WIDTH-224/2)/2) 412#define XOFS ((LCD_WIDTH-224/2)/2)
393#if LCD_HEIGHT < 144 413#if LCD_HEIGHT < 144
394#define YCLIP ((288-2*LCD_HEIGHT)/2) 414#define YCLIP ((288-2*LCD_HEIGHT)/2)
@@ -397,6 +417,9 @@
397#define YCLIP 0 417#define YCLIP 0
398#define YOFS ((LCD_HEIGHT-288/2)/2) 418#define YOFS ((LCD_HEIGHT-288/2)/2)
399#endif 419#endif
420
421#else
422#error "unsupported screen resolution"
400#endif 423#endif
401 424
402/* How many video frames (out of a possible 60) we display each second. 425/* How many video frames (out of a possible 60) we display each second.
diff --git a/apps/plugins/pacbox/pacbox_lcd.c b/apps/plugins/pacbox/pacbox_lcd.c
index bc2de20858..6bb51a038d 100644
--- a/apps/plugins/pacbox/pacbox_lcd.c
+++ b/apps/plugins/pacbox/pacbox_lcd.c
@@ -35,7 +35,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
35 int x,y; 35 int x,y;
36 36
37#ifdef HAVE_LCD_COLOR 37#ifdef HAVE_LCD_COLOR
38#if (LCD_WIDTH >= 224) && (LCD_HEIGHT >= 288) 38#if LCD_SCALE==100 && LCD_ROTATE==0
39 /* Native resolution = 224x288 */ 39 /* Native resolution = 224x288 */
40 (void)next_dst; 40 (void)next_dst;
41 dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS]; 41 dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS];
@@ -45,7 +45,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
45 } 45 }
46 dst += XOFS*2; 46 dst += XOFS*2;
47 } 47 }
48#elif (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224) 48#elif LCD_SCALE==100 && LCD_ROTATE==1
49 /* Native resolution - rotated 90 degrees = 288x224 */ 49 /* Native resolution - rotated 90 degrees = 288x224 */
50 next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight-1]; 50 next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight-1];
51 for( y=ScreenHeight-1; y>=0; y-- ) { 51 for( y=ScreenHeight-1; y>=0; y-- ) {
@@ -55,7 +55,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
55 dst+=LCD_WIDTH; 55 dst+=LCD_WIDTH;
56 } 56 }
57 } 57 }
58#elif (LCD_WIDTH >= 216) && (LCD_HEIGHT >= 168) 58#elif LCD_SCALE==75 && LCD_ROTATE==1
59 /* 0.75 scaling - display 3 out of 4 pixels - rotated = 216x168 59 /* 0.75 scaling - display 3 out of 4 pixels - rotated = 216x168
60 Skipping pixel #2 out of 4 seems to give the most legible display 60 Skipping pixel #2 out of 4 seems to give the most legible display
61 */ 61 */
@@ -74,7 +74,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
74 vbuf+=ScreenWidth; 74 vbuf+=ScreenWidth;
75 } 75 }
76 } 76 }
77#elif (LCD_WIDTH >= 168) && (LCD_HEIGHT >= 216) 77#elif LCD_SCALE==75 && LCD_ROTATE==0
78 /* 0.75 scaling - display 3 out of 4 pixels - = 168x216 78 /* 0.75 scaling - display 3 out of 4 pixels - = 168x216
79 Skipping pixel #2 out of 4 seems to give the most legible display 79 Skipping pixel #2 out of 4 seems to give the most legible display
80 */ 80 */
@@ -93,7 +93,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
93 vbuf+=ScreenWidth; 93 vbuf+=ScreenWidth;
94 } 94 }
95 } 95 }
96#elif (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112) 96#elif LCD_SCALE==50 && LCD_ROTATE==1
97 /* 0.5 scaling - display every other pixel - rotated = 144x112 */ 97 /* 0.5 scaling - display every other pixel - rotated = 144x112 */
98 next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight/2-1]; 98 next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight/2-1];
99 for (y=(ScreenHeight/2)-1;y >= 0; y--) { 99 for (y=(ScreenHeight/2)-1;y >= 0; y--) {
@@ -105,7 +105,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
105 } 105 }
106 vbuf+=ScreenWidth; 106 vbuf+=ScreenWidth;
107 } 107 }
108#elif (LCD_WIDTH >= 128) && (LCD_HEIGHT >= 128) 108#elif LCD_SCALE==50 && LCD_ROTATE==0
109 /* 0.5 scaling - display every other pixel 109 /* 0.5 scaling - display every other pixel
110 * LCD_HEIGHT < 144: 112x144, crop to 112x128 110 * LCD_HEIGHT < 144: 112x144, crop to 112x128
111 * else center vertically without clipping */ 111 * else center vertically without clipping */
@@ -126,7 +126,7 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
126 } 126 }
127#endif 127#endif
128#else /* Greyscale LCDs */ 128#else /* Greyscale LCDs */
129#if (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112) 129#if LCD_SCALE==50 && LCD_ROTATE==1
130#if LCD_PIXELFORMAT == VERTICAL_PACKING 130#if LCD_PIXELFORMAT == VERTICAL_PACKING
131 /* 0.5 scaling - display every other pixel = 144x112 */ 131 /* 0.5 scaling - display every other pixel = 144x112 */
132 next_dst=&lcd_framebuffer[YOFS/4*LCD_WIDTH+XOFS+ScreenHeight/2-1]; 132 next_dst=&lcd_framebuffer[YOFS/4*LCD_WIDTH+XOFS+ScreenHeight/2-1];
@@ -140,6 +140,6 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
140 vbuf+=ScreenWidth; 140 vbuf+=ScreenWidth;
141 } 141 }
142#endif /* Vertical Packing */ 142#endif /* Vertical Packing */
143#endif /* Size >= 144x112 */ 143#endif /* scale 50% rotated */
144#endif /* Not Colour */ 144#endif /* Not Colour */
145} 145}