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