Convert many #ifdef SIMULATOR to #if (CONFIG_PLATFORM & PLATFORM_HOSTED) (and similar).
[kugel-rb.git] / apps / plugins / pacbox / pacbox_lcd.c
blobc4df2fa6cdafaf80a56e51c7052ec3c13b51df91
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Pacbox - a Pacman Emulator for Rockbox
12 * Based on PIE - Pacman Instructional Emulator
14 * Copyright (c) 1997-2003,2004 Alessandro Scotti
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.
21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22 * KIND, either express or implied.
24 ****************************************************************************/
26 #include "pacbox.h"
27 #include "pacbox_lcd.h"
28 #include "arcade.h"
29 #include "hardware.h"
31 #if (CONFIG_PLATFORM & PLATFORM_HOSTED) || !defined(IRIVER_H300_SERIES)
33 void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
35 fb_data* dst;
36 fb_data* next_dst;
37 int x,y;
39 #ifdef HAVE_LCD_COLOR
40 #if (LCD_WIDTH >= 224) && (LCD_HEIGHT >= 288)
41 /* Native resolution = 224x288 */
42 (void)next_dst;
43 dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS];
44 for (y=0;y<ScreenHeight;y++) {
45 for (x=0;x<ScreenWidth;x++) {
46 *(dst++) = palette[*(vbuf++)];
48 dst += XOFS*2;
50 #elif (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224)
51 /* Native resolution - rotated 90 degrees = 288x224 */
52 next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight-1];
53 for( y=ScreenHeight-1; y>=0; y-- ) {
54 dst = (next_dst--);
55 for( x=0; x<ScreenWidth; x++ ) {
56 *dst = palette[*(vbuf++)];
57 dst+=LCD_WIDTH;
60 #elif (LCD_WIDTH >= 216) && (LCD_HEIGHT >= 168)
61 /* 0.75 scaling - display 3 out of 4 pixels - rotated = 216x168
62 Skipping pixel #2 out of 4 seems to give the most legible display
64 next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+((ScreenHeight*3)/4)-1];
65 for (y=ScreenHeight-1;y >= 0; y--) {
66 if ((y & 3) != 1) {
67 dst = (next_dst--);
68 for (x=0;x<ScreenWidth;x++) {
69 if ((x & 3) == 1) { vbuf++; }
70 else {
71 *dst = palette[*(vbuf++)];
72 dst+=LCD_WIDTH;
75 } else {
76 vbuf+=ScreenWidth;
79 #elif (LCD_WIDTH >= 168) && (LCD_HEIGHT >= 216)
80 /* 0.75 scaling - display 3 out of 4 pixels - = 168x216
81 Skipping pixel #2 out of 4 seems to give the most legible display
83 (void)next_dst;
84 dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS];
85 for (y=0;y<ScreenHeight;y++) {
86 if ((y & 3) != 1) {
87 for (x=0;x<ScreenWidth;x++) {
88 if ((x & 3) == 1) { vbuf++; }
89 else {
90 *(dst++) = palette[*(vbuf++)];
93 dst += XOFS*2;
94 } else {
95 vbuf+=ScreenWidth;
98 #elif (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112)
99 /* 0.5 scaling - display every other pixel - rotated = 144x112 */
100 next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight/2-1];
101 for (y=(ScreenHeight/2)-1;y >= 0; y--) {
102 dst = (next_dst--);
103 for (x=0;x<ScreenWidth/2;x++) {
104 *dst = palette[*(vbuf)];
105 vbuf+=2;
106 dst+=LCD_WIDTH;
108 vbuf+=ScreenWidth;
110 #elif (LCD_WIDTH >= 128) && (LCD_HEIGHT >= 128)
111 /* 0.5 scaling - display every other pixel = 112x144, crop to 112x128 */
112 (void)next_dst;
113 dst=&lcd_framebuffer[XOFS];
115 /* Skip first 16 lines */
116 vbuf+=ScreenWidth*YCLIP;
118 /* Show regular screen */
119 for (y=0;y<(ScreenHeight/2-YCLIP);y++) {
120 for (x=0;x<ScreenWidth/2;x++) {
121 *(dst++) = palette[*(vbuf)];
122 vbuf+=2;
124 dst += XOFS*2;
125 vbuf+=ScreenWidth;
127 #endif
128 #else /* Greyscale LCDs */
129 #if (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112)
130 #if LCD_PIXELFORMAT == VERTICAL_PACKING
131 /* 0.5 scaling - display every other pixel = 144x112 */
132 next_dst=&lcd_framebuffer[YOFS/4*LCD_WIDTH+XOFS+ScreenHeight/2-1];
133 for (y=(ScreenHeight/2)-1;y >= 0; y--) {
134 dst = (next_dst--);
135 for (x=0;x<ScreenWidth/8;x++) {
136 *dst = (palette[*(vbuf+6)]<<6) | (palette[*(vbuf+4)] << 4) | (palette[*(vbuf+2)] << 2) | palette[*(vbuf)];
137 vbuf+=8;
138 dst+=LCD_WIDTH;
140 vbuf+=ScreenWidth;
142 #endif /* Vertical Packing */
143 #endif /* Size >= 144x112 */
144 #endif /* Not Colour */
147 #endif