summaryrefslogtreecommitdiff
path: root/apps/plugins/pacbox/pacbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pacbox/pacbox.c')
-rw-r--r--apps/plugins/pacbox/pacbox.c179
1 files changed, 11 insertions, 168 deletions
diff --git a/apps/plugins/pacbox/pacbox.c b/apps/plugins/pacbox/pacbox.c
index 7177245d9f..f989a25608 100644
--- a/apps/plugins/pacbox/pacbox.c
+++ b/apps/plugins/pacbox/pacbox.c
@@ -24,6 +24,8 @@
24 24
25#include "plugin.h" 25#include "plugin.h"
26#include "arcade.h" 26#include "arcade.h"
27#include "pacbox.h"
28#include "pacbox_lcd.h"
27 29
28PLUGIN_HEADER 30PLUGIN_HEADER
29 31
@@ -38,64 +40,6 @@ extern char iend[];
38/* How many video frames (out of a possible 60) we display each second */ 40/* How many video frames (out of a possible 60) we display each second */
39#define FPS 20 41#define FPS 20
40 42
41#if CONFIG_KEYPAD == IPOD_4G_PAD
42
43#define PACMAN_UP BUTTON_RIGHT
44#define PACMAN_DOWN BUTTON_LEFT
45#define PACMAN_LEFT BUTTON_MENU
46#define PACMAN_RIGHT BUTTON_PLAY
47#define PACMAN_1UP BUTTON_SELECT
48#define PACMAN_COIN BUTTON_SELECT
49
50#elif CONFIG_KEYPAD == IRIVER_H100_PAD || CONFIG_KEYPAD == IRIVER_H300_PAD
51
52#define PACMAN_UP BUTTON_RIGHT
53#define PACMAN_DOWN BUTTON_LEFT
54#define PACMAN_LEFT BUTTON_UP
55#define PACMAN_RIGHT BUTTON_DOWN
56#define PACMAN_1UP BUTTON_SELECT
57#define PACMAN_2UP BUTTON_ON
58#define PACMAN_COIN BUTTON_REC
59#define PACMAN_MENU BUTTON_MODE
60
61#elif CONFIG_KEYPAD == GIGABEAT_PAD
62
63#define PACMAN_UP BUTTON_UP
64#define PACMAN_DOWN BUTTON_DOWN
65#define PACMAN_LEFT BUTTON_LEFT
66#define PACMAN_RIGHT BUTTON_RIGHT
67#define PACMAN_1UP BUTTON_SELECT
68#define PACMAN_2UP BUTTON_POWER
69#define PACMAN_COIN BUTTON_A
70#define PACMAN_MENU BUTTON_MENU
71
72#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
73
74#define PACMAN_UP BUTTON_RIGHT
75#define PACMAN_DOWN BUTTON_LEFT
76#define PACMAN_LEFT BUTTON_UP
77#define PACMAN_RIGHT BUTTON_DOWN
78#define PACMAN_1UP BUTTON_SELECT
79#define PACMAN_2UP BUTTON_POWER
80#define PACMAN_COIN BUTTON_REC
81#define PACMAN_MENU BUTTON_PLAY
82
83#endif
84
85#if (LCD_HEIGHT >= 288)
86#define XOFS ((LCD_WIDTH-224)/2)
87#define YOFS ((LCD_HEIGHT-288)/2)
88#elif (LCD_WIDTH >= 288)
89#define XOFS ((LCD_WIDTH-288)/2)
90#define YOFS ((LCD_HEIGHT-224)/2)
91#elif (LCD_WIDTH >= 220)
92#define XOFS ((LCD_WIDTH-(288*3/4))/2)
93#define YOFS ((LCD_HEIGHT-(224*3/4))/2)
94#elif (LCD_WIDTH >= 144)
95#define XOFS ((LCD_WIDTH-288/2)/2)
96#define YOFS ((LCD_HEIGHT-224/2)/2)
97#endif
98
99struct plugin_api* rb; 43struct plugin_api* rb;
100 44
101unsigned framesPerSecond = VideoFrequency; 45unsigned framesPerSecond = VideoFrequency;
@@ -180,31 +124,6 @@ int settings_to_dip(struct pacman_settings settings)
180 ); 124 );
181} 125}
182 126
183
184
185int pacbox_menu_cb(int key, int m)
186{
187 (void)m;
188 switch(key)
189 {
190#ifdef MENU_ENTER2
191 case MENU_ENTER2:
192#endif
193 case MENU_ENTER:
194 key = BUTTON_NONE; /* eat the downpress, next menu reacts on release */
195 break;
196
197#ifdef MENU_ENTER2
198 case MENU_ENTER2 | BUTTON_REL:
199#endif
200 case MENU_ENTER | BUTTON_REL:
201 key = MENU_ENTER; /* fake downpress, next menu doesn't like release */
202 break;
203 }
204
205 return key;
206}
207
208bool pacbox_menu(void) 127bool pacbox_menu(void)
209{ 128{
210 int m; 129 int m;
@@ -253,7 +172,7 @@ bool pacbox_menu(void)
253 }; 172 };
254 173
255 m = rb->menu_init(items, sizeof(items) / sizeof(*items), 174 m = rb->menu_init(items, sizeof(items) / sizeof(*items),
256 pacbox_menu_cb, NULL, NULL, NULL); 175 NULL, NULL, NULL, NULL);
257 176
258 rb->button_clear_queue(); 177 rb->button_clear_queue();
259 178
@@ -331,14 +250,11 @@ bool pacbox_menu(void)
331*/ 250*/
332int gameProc( void ) 251int gameProc( void )
333{ 252{
334 int x,y; 253 int x;
335 int fps; 254 int fps;
336 char str[80]; 255 char str[80];
337 int status; 256 int status;
338 long end_time; 257 long end_time;
339 unsigned char* vbuf = video_buffer;
340 fb_data* dst;
341 fb_data* next_dst;
342 258
343 /* Run the machine for one frame (1/60th second) */ 259 /* Run the machine for one frame (1/60th second) */
344 run(); 260 run();
@@ -348,11 +264,7 @@ int gameProc( void )
348 /* Check the button status */ 264 /* Check the button status */
349 status = rb->button_status(); 265 status = rb->button_status();
350 266
351#ifdef PACMAN_MENU 267 if ((status & PACMAN_MENU) == PACMAN_MENU) {
352 if (status & PACMAN_MENU) {
353#else
354 if (rb->button_hold()) {
355#endif
356 end_time = *rb->current_tick; 268 end_time = *rb->current_tick;
357 x = pacbox_menu(); 269 x = pacbox_menu();
358 rb->lcd_clear_display(); 270 rb->lcd_clear_display();
@@ -389,80 +301,11 @@ int gameProc( void )
389 the sprites on top. Even with the memcpy, this is faster than redrawing 301 the sprites on top. Even with the memcpy, this is faster than redrawing
390 the whole background. 302 the whole background.
391 */ 303 */
392 renderBackground( background ); 304
393 rb->memcpy(video_buffer,background,sizeof(video_buffer)); 305 renderBackground( video_buffer );
394 renderSprites( video_buffer ); 306 renderSprites( video_buffer );
395 307
396#ifdef HAVE_LCD_COLOR 308 blit_display(rb->lcd_framebuffer,video_buffer);
397#if (LCD_WIDTH >= 224) && (LCD_HEIGHT >= 288)
398 /* Native resolution = 224x288 */
399 (void)next_dst;
400 dst=&rb->lcd_framebuffer[YOFS*LCD_WIDTH+XOFS];
401 for (y=0;y<ScreenHeight;y++) {
402 for (x=0;x<ScreenWidth;x++) {
403 *(dst++) = palette[*(vbuf++)];
404 }
405 dst += XOFS*2;
406 }
407#elif (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224)
408 /* Native resolution - rotated 90 degrees = 288x224 */
409 next_dst=&rb->lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight-1];
410 for( y=ScreenHeight-1; y>=0; y-- ) {
411 dst = (next_dst--);
412 for( x=0; x<ScreenWidth; x++ ) {
413 *dst = palette[*(vbuf++)];
414 dst+=LCD_WIDTH;
415 }
416 }
417#elif (LCD_WIDTH >= 216) && (LCD_HEIGHT >= 168)
418 /* 0.75 scaling - display 3 out of 4 pixels = 216x168
419 Skipping pixel #2 out of 4 seems to give the most legible display
420 */
421 next_dst=&rb->lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+((ScreenHeight*3)/4)-1];
422 for (y=ScreenHeight-1;y >= 0; y--) {
423 if ((y & 3) != 1) {
424 dst = (next_dst--);
425 for (x=0;x<ScreenWidth;x++) {
426 if ((x & 3) == 1) { vbuf++; }
427 else {
428 *dst = palette[*(vbuf++)];
429 dst+=LCD_WIDTH;
430 }
431 }
432 } else {
433 vbuf+=ScreenWidth;
434 }
435 }
436#elif (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112)
437 /* 0.5 scaling - display every other pixel = 144x112 */
438 next_dst=&rb->lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight/2-1];
439 for (y=(ScreenHeight/2)-1;y >= 0; y--) {
440 dst = (next_dst--);
441 for (x=0;x<ScreenWidth/2;x++) {
442 *dst = palette[*(vbuf)];
443 vbuf+=2;
444 dst+=LCD_WIDTH;
445 }
446 vbuf+=ScreenWidth;
447 }
448#endif
449#else /* Greyscale LCDs */
450#if (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112)
451#if LCD_PIXELFORMAT == VERTICAL_PACKING
452 /* 0.5 scaling - display every other pixel = 144x112 */
453 next_dst=&rb->lcd_framebuffer[YOFS/4*LCD_WIDTH+XOFS+ScreenHeight/2-1];
454 for (y=(ScreenHeight/2)-1;y >= 0; y--) {
455 dst = (next_dst--);
456 for (x=0;x<ScreenWidth/8;x++) {
457 *dst = (palette[*(vbuf+6)]<<6) | (palette[*(vbuf+4)] << 4) | (palette[*(vbuf+2)] << 2) | palette[*(vbuf)];
458 vbuf+=8;
459 dst+=LCD_WIDTH;
460 }
461 vbuf+=ScreenWidth;
462 }
463#endif /* Vertical Packing */
464#endif /* Size >= 144x112 */
465#endif /* Not Colour */
466 309
467 if (settings.showfps) { 310 if (settings.showfps) {
468 fps = (video_frames*HZ*100) / (*rb->current_tick-start_time); 311 fps = (video_frames*HZ*100) / (*rb->current_tick-start_time);
@@ -519,7 +362,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
519 settings.numlives = 2; /* 3 lives */ 362 settings.numlives = 2; /* 3 lives */
520 settings.bonus = 0; /* 10000 points */ 363 settings.bonus = 0; /* 10000 points */
521 settings.ghostnames = 0; /* Normal names */ 364 settings.ghostnames = 0; /* Normal names */
522 settings.showfps = 0; /* Do not show FPS */ 365 settings.showfps = 1; /* Do not show FPS */
523 366
524 /* Initialise the hardware */ 367 /* Initialise the hardware */
525 init_PacmanMachine(settings_to_dip(settings)); 368 init_PacmanMachine(settings_to_dip(settings));