A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Pacbox - a Pacman Emulator for Rockbox
11 *
12 * Based on PIE - Pacman Instructional Emulator
13 *
14 * Copyright (c) 1997-2003,2004 Alessandro Scotti
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
20 *
21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22 * KIND, either express or implied.
23 *
24 ****************************************************************************/
25
26#include "pacbox.h"
27#include "pacbox_lcd.h"
28#include "arcade.h"
29#include "hardware.h"
30
31void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
32{
33 fb_data* dst;
34 fb_data* next_dst;
35 int x,y;
36
37#ifdef HAVE_LCD_COLOR
38#if LCD_SCALE==100 && LCD_ROTATE==0
39 /* Native resolution = 224x288 */
40 (void)next_dst;
41 dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS];
42 for (y=0;y<ScreenHeight;y++) {
43 for (x=0;x<ScreenWidth;x++) {
44 *(dst++) = palette[*(vbuf++)];
45 }
46 dst += XOFS*2;
47 }
48#elif LCD_SCALE==100 && LCD_ROTATE==1
49 /* Native resolution - rotated 90 degrees = 288x224 */
50 next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight-1];
51 for( y=ScreenHeight-1; y>=0; y-- ) {
52 dst = (next_dst--);
53 for( x=0; x<ScreenWidth; x++ ) {
54 *dst = palette[*(vbuf++)];
55 dst+=LCD_WIDTH;
56 }
57 }
58#elif LCD_SCALE==100 && LCD_ROTATE==2
59 /* Native resolution - rotated 270 degrees = 288x224 */
60 next_dst=&lcd_framebuffer[(LCD_HEIGHT-YOFS)*LCD_WIDTH+XOFS];
61 for( y=0; y<ScreenHeight; y++ ) {
62 dst = (next_dst++);
63 for( x=ScreenWidth-1; x>=0; x-- ) {
64 *dst = palette[*(vbuf++)];
65 dst-=LCD_WIDTH;
66 }
67 }
68#elif LCD_SCALE==75 && LCD_ROTATE==1
69 /* 0.75 scaling - display 3 out of 4 pixels - rotated = 216x168
70 Skipping pixel #2 out of 4 seems to give the most legible display
71 */
72 next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+((ScreenHeight*3)/4)-1];
73 for (y=ScreenHeight-1;y >= 0; y--) {
74 if ((y & 3) != 1) {
75 dst = (next_dst--);
76 for (x=0;x<ScreenWidth;x++) {
77 if ((x & 3) == 1) { vbuf++; }
78 else {
79 *dst = palette[*(vbuf++)];
80 dst+=LCD_WIDTH;
81 }
82 }
83 } else {
84 vbuf+=ScreenWidth;
85 }
86 }
87#elif LCD_SCALE==75 && LCD_ROTATE==0
88 /* 0.75 scaling - display 3 out of 4 pixels - = 168x216
89 Skipping pixel #2 out of 4 seems to give the most legible display
90 */
91 (void)next_dst;
92 dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS];
93 for (y=0;y<ScreenHeight;y++) {
94 if ((y & 3) != 1) {
95 for (x=0;x<ScreenWidth;x++) {
96 if ((x & 3) == 1) { vbuf++; }
97 else {
98 *(dst++) = palette[*(vbuf++)];
99 }
100 }
101 dst += XOFS*2;
102 } else {
103 vbuf+=ScreenWidth;
104 }
105 }
106#elif LCD_SCALE==50 && LCD_ROTATE==1
107 /* 0.5 scaling - display every other pixel - rotated = 144x112 */
108 next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight/2-1];
109 for (y=(ScreenHeight/2)-1;y >= 0; y--) {
110 dst = (next_dst--);
111 for (x=0;x<ScreenWidth/2;x++) {
112 *dst = palette[*(vbuf)];
113 vbuf+=2;
114 dst+=LCD_WIDTH;
115 }
116 vbuf+=ScreenWidth;
117 }
118#elif LCD_SCALE==50 && LCD_ROTATE==0
119 /* 0.5 scaling - display every other pixel
120 * LCD_HEIGHT < 144: 112x144, crop to 112x128
121 * else center vertically without clipping */
122 (void)next_dst;
123 dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS];
124
125 /* Skip first YCLIP lines */
126 vbuf+=ScreenWidth*YCLIP;
127
128 /* Show regular screen */
129 for (y=0;y<(ScreenHeight/2-YCLIP);y++) {
130 for (x=0;x<ScreenWidth/2;x++) {
131 *(dst++) = palette[*(vbuf)];
132 vbuf+=2;
133 }
134 dst += XOFS*2;
135 vbuf+=ScreenWidth;
136 }
137#elif LCD_SCALE==40 && LCD_ROTATE==1
138 /* 0.4 scaling - rotated = 116x90 */
139 /* show 2 out of 5 pixels: 1st and 3rd anf 4th merged together */
140 next_dst=&lcd_framebuffer[XOFS*LCD_WIDTH+YOFS+ScreenHeight*2/5-1];
141 for (y=(ScreenHeight*2/5)-1;y >= 0; y--) {
142 dst = (next_dst--);
143 for (x=0;x<ScreenWidth*2/5;x++) {
144 *dst = palette[*(vbuf)] | palette[*(vbuf+ScreenWidth+1)];
145 /* every odd row number merge 2 source lines as one */
146 if (y & 1) *dst |= palette[*(vbuf+ScreenWidth*2)];
147 vbuf+=2;
148 dst+=LCD_WIDTH;
149
150 x++;
151 /* every odd column merge 2 colums together */
152 *dst = palette[*(vbuf)] | palette[*(vbuf+1)] |palette[*(vbuf+ScreenWidth+2)];
153 if (y & 1) *dst |= palette[*(vbuf+ScreenWidth*2+1)];
154 vbuf+=3;
155 dst+=LCD_WIDTH;
156 }
157 vbuf+=ScreenWidth-1;
158 if (y & 1) vbuf+=ScreenWidth;
159 }
160#elif LCD_SCALE==33 && LCD_ROTATE==0
161 /* 1/3 scaling - display every third pixel - 75x96 */
162 (void)next_dst;
163 dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS];
164
165 for (y=0;y<ScreenHeight/3;y++) {
166 for (x=0;x<ScreenWidth/3;x++) {
167 *(dst++) = palette[*(vbuf)]
168 | palette[*(vbuf+ScreenWidth+1)]
169 | palette[*(vbuf+ScreenWidth*2+2)];
170 vbuf+=3;
171 }
172 dst += XOFS*2;
173 vbuf+=ScreenWidth*2+2;
174 }
175#endif
176
177#else /* Greyscale LCDs */
178#if LCD_SCALE==50 && LCD_ROTATE==1
179#if LCD_PIXELFORMAT == VERTICAL_PACKING
180 /* 0.5 scaling - display every other pixel = 144x112 */
181 next_dst=&lcd_framebuffer[YOFS/4*LCD_WIDTH+XOFS+ScreenHeight/2-1];
182 for (y=(ScreenHeight/2)-1;y >= 0; y--) {
183 dst = (next_dst--);
184 for (x=0;x<ScreenWidth/8;x++) {
185 *dst = (palette[*(vbuf+6)]<<6) | (palette[*(vbuf+4)] << 4) | (palette[*(vbuf+2)] << 2) | palette[*(vbuf)];
186 vbuf+=8;
187 dst+=LCD_WIDTH;
188 }
189 vbuf+=ScreenWidth;
190 }
191#endif /* Vertical Packing */
192#endif /* scale 50% rotated */
193#endif /* Not Colour */
194}