diff options
-rw-r--r-- | apps/plugins/pacbox/Makefile | 7 | ||||
-rw-r--r-- | apps/plugins/pacbox/SOURCES | 9 | ||||
-rw-r--r-- | apps/plugins/pacbox/arcade.c | 63 | ||||
-rw-r--r-- | apps/plugins/pacbox/pacbox.c | 179 | ||||
-rw-r--r-- | apps/plugins/pacbox/pacbox.h | 91 | ||||
-rw-r--r-- | apps/plugins/pacbox/pacbox_arm.S | 130 | ||||
-rw-r--r-- | apps/plugins/pacbox/pacbox_lcd.c | 105 | ||||
-rw-r--r-- | apps/plugins/pacbox/pacbox_lcd.h | 31 |
8 files changed, 423 insertions, 192 deletions
diff --git a/apps/plugins/pacbox/Makefile b/apps/plugins/pacbox/Makefile index 817c6d451a..0b7f4b9e15 100644 --- a/apps/plugins/pacbox/Makefile +++ b/apps/plugins/pacbox/Makefile | |||
@@ -19,10 +19,13 @@ endif | |||
19 | 19 | ||
20 | LINKFILE := $(OBJDIR)/link.lds | 20 | LINKFILE := $(OBJDIR)/link.lds |
21 | DEPFILE = $(OBJDIR)/dep-pacbox | 21 | DEPFILE = $(OBJDIR)/dep-pacbox |
22 | SRC = arcade.c pacbox.c hardware.c z80.c | 22 | |
23 | # This sets up 'SRC' based on the files mentioned in SOURCES | ||
24 | include $(TOOLSDIR)/makesrc.inc | ||
23 | 25 | ||
24 | SOURCES = $(SRC) | 26 | SOURCES = $(SRC) |
25 | OBJS := $(SRC:%.c=$(OBJDIR)/%.o) | 27 | OBJS2 := $(SRC:%.c=$(OBJDIR)/%.o) |
28 | OBJS = $(patsubst %.S, $(OBJDIR)/%.o, $(OBJS2)) | ||
26 | DIRS = . | 29 | DIRS = . |
27 | 30 | ||
28 | LDS := ../plugin.lds | 31 | LDS := ../plugin.lds |
diff --git a/apps/plugins/pacbox/SOURCES b/apps/plugins/pacbox/SOURCES new file mode 100644 index 0000000000..3d6145ddce --- /dev/null +++ b/apps/plugins/pacbox/SOURCES | |||
@@ -0,0 +1,9 @@ | |||
1 | arcade.c | ||
2 | pacbox.c | ||
3 | hardware.c | ||
4 | z80.c | ||
5 | #if (CONFIG_CPU == PP5020) && (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224) | ||
6 | pacbox_arm.S | ||
7 | #else | ||
8 | pacbox_lcd.c | ||
9 | #endif | ||
diff --git a/apps/plugins/pacbox/arcade.c b/apps/plugins/pacbox/arcade.c index e7bf124700..dc3ea0c9ba 100644 --- a/apps/plugins/pacbox/arcade.c +++ b/apps/plugins/pacbox/arcade.c | |||
@@ -252,19 +252,19 @@ static unsigned decodePaletteByte( unsigned char value ) | |||
252 | unsigned bit0, bit1, bit2; | 252 | unsigned bit0, bit1, bit2; |
253 | unsigned red, green, blue; | 253 | unsigned red, green, blue; |
254 | 254 | ||
255 | bit0 = (value >> 0) & 0x01; | 255 | bit0 = (value >> 0) & 0x01; |
256 | bit1 = (value >> 1) & 0x01; | 256 | bit1 = (value >> 1) & 0x01; |
257 | bit2 = (value >> 2) & 0x01; | 257 | bit2 = (value >> 2) & 0x01; |
258 | red = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; | 258 | red = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
259 | 259 | ||
260 | bit0 = (value >> 3) & 0x01; | 260 | bit0 = (value >> 3) & 0x01; |
261 | bit1 = (value >> 4) & 0x01; | 261 | bit1 = (value >> 4) & 0x01; |
262 | bit2 = (value >> 5) & 0x01; | 262 | bit2 = (value >> 5) & 0x01; |
263 | green = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; | 263 | green = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
264 | 264 | ||
265 | bit0 = 0; | 265 | bit0 = 0; |
266 | bit1 = (value >> 6) & 0x01; | 266 | bit1 = (value >> 6) & 0x01; |
267 | bit2 = (value >> 7) & 0x01; | 267 | bit2 = (value >> 7) & 0x01; |
268 | blue = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; | 268 | blue = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; |
269 | 269 | ||
270 | return (blue << 16 ) | (green << 8) | red; | 270 | return (blue << 16 ) | (green << 8) | red; |
@@ -428,6 +428,7 @@ inline void drawSprite( unsigned char * buffer, int index ) | |||
428 | { | 428 | { |
429 | struct PacmanSprite ps = sprites_[index]; | 429 | struct PacmanSprite ps = sprites_[index]; |
430 | int x,y; | 430 | int x,y; |
431 | char * s, * s2; | ||
431 | 432 | ||
432 | // Exit now if sprite not visible at all | 433 | // Exit now if sprite not visible at all |
433 | if( (ps.color == 0) || (ps.x >= ScreenWidth) || (ps.y < 16) || (ps.y >= (ScreenHeight-32)) ) { | 434 | if( (ps.color == 0) || (ps.x >= ScreenWidth) || (ps.y < 16) || (ps.y >= (ScreenHeight-32)) ) { |
@@ -436,59 +437,77 @@ inline void drawSprite( unsigned char * buffer, int index ) | |||
436 | 437 | ||
437 | // Clip the sprite coordinates to cut the parts that fall off the screen | 438 | // Clip the sprite coordinates to cut the parts that fall off the screen |
438 | int start_x = (ps.x < 0) ? 0 : ps.x; | 439 | int start_x = (ps.x < 0) ? 0 : ps.x; |
439 | int end_x = (ps.x < (ScreenWidth-16)) ? ps.x+16 : ScreenWidth; | 440 | int end_x = (ps.x < (ScreenWidth-16)) ? ps.x+15 : ScreenWidth-1; |
440 | 441 | ||
441 | // Prepare variables for drawing | 442 | // Prepare variables for drawing |
442 | int color = (ps.color & 0x3F)*4; | 443 | int color = (ps.color & 0x3F)*4; |
443 | unsigned char * spritemap_base = spritemap_ + ((ps.n & 0x3F)*256); | 444 | unsigned char * spritemap_base = spritemap_ + ((ps.n & 0x3F)*256); |
444 | 445 | ||
445 | buffer += ScreenWidth*ps.y; | 446 | buffer += ScreenWidth*ps.y; |
447 | s2 = &spritemap_base[start_x-ps.x]; | ||
448 | |||
449 | dirty_[(start_x >> 3) + (ps.y >> 3)*28] = 1; | ||
450 | dirty_[(start_x >> 3) + 1 + (ps.y >> 3)*28] = 1; | ||
451 | dirty_[(end_x >> 3) + (ps.y >> 3)*28] = 1; | ||
452 | dirty_[(start_x >> 3) + ((ps.y >> 3)+1)*28] = 1; | ||
453 | dirty_[(start_x >> 3) + 1 + ((ps.y >> 3)+1)*28] = 1; | ||
454 | dirty_[(end_x >> 3) + ((ps.y >> 3)+1)*28] = 1; | ||
455 | dirty_[(start_x >> 3) + ((ps.y+15) >> 3)*28] = 1; | ||
456 | dirty_[(start_x >> 3) + 1 + ((ps.y+15) >> 3)*28] = 1; | ||
457 | dirty_[(end_x >> 3) + ((ps.y+15) >> 3)*28] = 1; | ||
446 | 458 | ||
447 | // Draw the 16x16 sprite | 459 | // Draw the 16x16 sprite |
448 | if( ps.mode == 0 ) { // Normal | 460 | if( ps.mode == 0 ) { // Normal |
449 | // Draw the 16x16 sprite | 461 | // Draw the 16x16 sprite |
450 | for( y=0; y<16; y++ ) { | 462 | for( y=15; y>=0; y-- ) { |
451 | char* s = &spritemap_base[start_x-ps.x+y*16]; | 463 | s = s2; |
452 | for( x=start_x; x<end_x; x++ ) { | 464 | for( x=start_x; x<=end_x; x++ ) { |
453 | int c = *(s++); | 465 | int c = *(s++); |
454 | if( c ) { | 466 | if( c ) { |
455 | buffer[x] = c + color; | 467 | buffer[x] = c + color; |
456 | } | 468 | } |
457 | } | 469 | } |
458 | buffer += ScreenWidth; | 470 | buffer += ScreenWidth; |
471 | s2 += 16; | ||
459 | } | 472 | } |
460 | } else if( ps.mode == 1 ) { // Flip Y | 473 | } else if( ps.mode == 1 ) { // Flip Y |
461 | for( y=0; y<16; y++ ) { | 474 | s2 += 240; |
462 | char* s = &spritemap_base[start_x-ps.x+(15-y)*16]; | 475 | for( y=15; y>=0; y-- ) { |
463 | for( x=start_x; x<end_x; x++ ) { | 476 | s = s2; |
477 | for( x=start_x; x<=end_x; x++ ) { | ||
464 | int c = *(s++); | 478 | int c = *(s++); |
465 | if( c ) { | 479 | if( c ) { |
466 | buffer[x] = c + color; | 480 | buffer[x] = c + color; |
467 | } | 481 | } |
468 | } | 482 | } |
469 | buffer += ScreenWidth; | 483 | buffer += ScreenWidth; |
484 | s2 -= 16; | ||
470 | } | 485 | } |
471 | } else if( ps.mode == 2 ) { // Flip X | 486 | } else if( ps.mode == 2 ) { // Flip X |
472 | for( y=0; y<16; y++ ) { | 487 | s2 += 15; |
473 | char* s = &spritemap_base[15-start_x+ps.x+y*16]; | 488 | for( y=15; y>=-0; y-- ) { |
474 | for( x=start_x; x<end_x; x++ ) { | 489 | s = s2; |
490 | for( x=start_x; x<=end_x; x++ ) { | ||
475 | int c = *(s--); | 491 | int c = *(s--); |
476 | if( c ) { | 492 | if( c ) { |
477 | buffer[x] = c + color; | 493 | buffer[x] = c + color; |
478 | } | 494 | } |
479 | } | 495 | } |
480 | buffer += ScreenWidth; | 496 | buffer += ScreenWidth; |
497 | s2 += 16; | ||
481 | } | 498 | } |
482 | } else { // Flip X and Y | 499 | } else { // Flip X and Y |
483 | for( y=0; y<16; y++ ) { | 500 | s2 += 255; |
484 | char* s = &spritemap_base[15-start_x+ps.x+(15-y)*16]; | 501 | for( y=15; y>=0; y-- ) { |
485 | for( x=start_x; x<end_x; x++ ) { | 502 | s = s2; |
503 | for( x=start_x; x<=end_x; x++ ) { | ||
486 | int c = *(s--); | 504 | int c = *(s--); |
487 | if( c ) { | 505 | if( c ) { |
488 | buffer[x] = c + color; | 506 | buffer[x] = c + color; |
489 | } | 507 | } |
490 | } | 508 | } |
491 | buffer += ScreenWidth; | 509 | buffer += ScreenWidth; |
510 | s2 -= 16; | ||
492 | } | 511 | } |
493 | } | 512 | } |
494 | } | 513 | } |
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 | ||
28 | PLUGIN_HEADER | 30 | PLUGIN_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 | |||
99 | struct plugin_api* rb; | 43 | struct plugin_api* rb; |
100 | 44 | ||
101 | unsigned framesPerSecond = VideoFrequency; | 45 | unsigned framesPerSecond = VideoFrequency; |
@@ -180,31 +124,6 @@ int settings_to_dip(struct pacman_settings settings) | |||
180 | ); | 124 | ); |
181 | } | 125 | } |
182 | 126 | ||
183 | |||
184 | |||
185 | int 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 | |||
208 | bool pacbox_menu(void) | 127 | bool 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 | */ |
332 | int gameProc( void ) | 251 | int 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)); |
diff --git a/apps/plugins/pacbox/pacbox.h b/apps/plugins/pacbox/pacbox.h new file mode 100644 index 0000000000..84bd8a7be8 --- /dev/null +++ b/apps/plugins/pacbox/pacbox.h | |||
@@ -0,0 +1,91 @@ | |||
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 | * http://www.ascotti.org/ | ||
16 | * | ||
17 | * All files in this archive are subject to the GNU General Public License. | ||
18 | * See the file COPYING in the source tree root for full license agreement. | ||
19 | * | ||
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
21 | * KIND, either express or implied. | ||
22 | * | ||
23 | ****************************************************************************/ | ||
24 | |||
25 | /* Platform-specific defines - used in both C and ASM files */ | ||
26 | |||
27 | #ifndef _PACBOX_H | ||
28 | #define _PACBOX_H | ||
29 | |||
30 | #include "config.h" | ||
31 | |||
32 | #if CONFIG_KEYPAD == IPOD_4G_PAD | ||
33 | |||
34 | #define PACMAN_UP BUTTON_RIGHT | ||
35 | #define PACMAN_DOWN BUTTON_LEFT | ||
36 | #define PACMAN_LEFT BUTTON_MENU | ||
37 | #define PACMAN_RIGHT BUTTON_PLAY | ||
38 | #define PACMAN_1UP BUTTON_SELECT | ||
39 | #define PACMAN_COIN BUTTON_SELECT | ||
40 | #define PACMAN_MENU (BUTTON_MENU | BUTTON_SELECT) | ||
41 | |||
42 | #elif CONFIG_KEYPAD == IRIVER_H100_PAD || CONFIG_KEYPAD == IRIVER_H300_PAD | ||
43 | |||
44 | #define PACMAN_UP BUTTON_RIGHT | ||
45 | #define PACMAN_DOWN BUTTON_LEFT | ||
46 | #define PACMAN_LEFT BUTTON_UP | ||
47 | #define PACMAN_RIGHT BUTTON_DOWN | ||
48 | #define PACMAN_1UP BUTTON_SELECT | ||
49 | #define PACMAN_2UP BUTTON_ON | ||
50 | #define PACMAN_COIN BUTTON_REC | ||
51 | #define PACMAN_MENU BUTTON_MODE | ||
52 | |||
53 | #elif CONFIG_KEYPAD == GIGABEAT_PAD | ||
54 | |||
55 | #define PACMAN_UP BUTTON_UP | ||
56 | #define PACMAN_DOWN BUTTON_DOWN | ||
57 | #define PACMAN_LEFT BUTTON_LEFT | ||
58 | #define PACMAN_RIGHT BUTTON_RIGHT | ||
59 | #define PACMAN_1UP BUTTON_SELECT | ||
60 | #define PACMAN_2UP BUTTON_POWER | ||
61 | #define PACMAN_COIN BUTTON_A | ||
62 | #define PACMAN_MENU BUTTON_MENU | ||
63 | |||
64 | #elif CONFIG_KEYPAD == IAUDIO_X5_PAD | ||
65 | |||
66 | #define PACMAN_UP BUTTON_RIGHT | ||
67 | #define PACMAN_DOWN BUTTON_LEFT | ||
68 | #define PACMAN_LEFT BUTTON_UP | ||
69 | #define PACMAN_RIGHT BUTTON_DOWN | ||
70 | #define PACMAN_1UP BUTTON_SELECT | ||
71 | #define PACMAN_2UP BUTTON_POWER | ||
72 | #define PACMAN_COIN BUTTON_REC | ||
73 | #define PACMAN_MENU BUTTON_PLAY | ||
74 | |||
75 | #endif | ||
76 | |||
77 | #if (LCD_HEIGHT >= 288) | ||
78 | #define XOFS ((LCD_WIDTH-224)/2) | ||
79 | #define YOFS ((LCD_HEIGHT-288)/2) | ||
80 | #elif (LCD_WIDTH >= 288) | ||
81 | #define XOFS ((LCD_WIDTH-288)/2) | ||
82 | #define YOFS ((LCD_HEIGHT-224)/2) | ||
83 | #elif (LCD_WIDTH >= 220) | ||
84 | #define XOFS ((LCD_WIDTH-(288*3/4))/2) | ||
85 | #define YOFS ((LCD_HEIGHT-(224*3/4))/2) | ||
86 | #elif (LCD_WIDTH >= 144) | ||
87 | #define XOFS ((LCD_WIDTH-288/2)/2) | ||
88 | #define YOFS ((LCD_HEIGHT-224/2)/2) | ||
89 | #endif | ||
90 | |||
91 | #endif | ||
diff --git a/apps/plugins/pacbox/pacbox_arm.S b/apps/plugins/pacbox/pacbox_arm.S new file mode 100644 index 0000000000..ade3ad2de6 --- /dev/null +++ b/apps/plugins/pacbox/pacbox_arm.S | |||
@@ -0,0 +1,130 @@ | |||
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 | * All files in this archive are subject to the GNU General Public License. | ||
17 | * See the file COPYING in the source tree root for full license agreement. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | |||
24 | #include "pacbox.h" | ||
25 | |||
26 | .section .icode,"ax",%progbits | ||
27 | .global blit_display | ||
28 | |||
29 | /* void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf) | ||
30 | |||
31 | next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight-1]; | ||
32 | for( y=ScreenHeight; y>0; y-- ) { | ||
33 | dst = (next_dst--); | ||
34 | for( x=ScreenWidth; x>0; x-- ) { | ||
35 | *dst = palette[*(vbuf++)]; | ||
36 | dst+=LCD_WIDTH; | ||
37 | } | ||
38 | } | ||
39 | */ | ||
40 | |||
41 | #ifdef HAVE_LCD_COLOR | ||
42 | #if (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224) | ||
43 | |||
44 | blit_display: | ||
45 | stmdb sp!, {r4-r12, lr} | ||
46 | |||
47 | add r3, r0, #5696 | ||
48 | add r3, r3, #24 @ 5720 = (2*(YOFS*LCD_WIDTH+XOFS+ScreenHeight-4)) | ||
49 | ldr r0, =palette | ||
50 | mov lr, #288 @ y = 288 | ||
51 | |||
52 | mov r12, #224*3 | ||
53 | |||
54 | loop_y: mov r2, r3 @ r2 = next_dst | ||
55 | sub r3, r3, #8 @ next_dst-=4 | ||
56 | |||
57 | mov ip, #224 @ x = 224 | ||
58 | |||
59 | /* store 2 input bytes from the next four lines in r7-r10 */ | ||
60 | loop_x: | ||
61 | ldrh r8, [r1, #224] @ r8 = vbuf[224] | ||
62 | ldrh r7, [r1] @ r7 = vbuf[0] ; vbuf += 2; | ||
63 | add r1, r1, #448 | ||
64 | ldrh r10, [r1, #224] @ r8 = vbuf[224] | ||
65 | ldrh r9, [r1], #2 @ r7 = vbuf[0] ; vbuf += 2; | ||
66 | sub r1, r1, #448 | ||
67 | |||
68 | |||
69 | /* Convert high bytes of r7-r10 into palette entries in r5 and r6 */ | ||
70 | mov r6, r7, lsr #8 | ||
71 | mov r6, r6, lsl #1 | ||
72 | ldrh r6, [r6, r0] @ r6 = palette[hi(r7]] | ||
73 | |||
74 | mov r11, r8, lsr #8 | ||
75 | mov r11, r11, lsl #1 | ||
76 | ldrh r11, [r11, r0] @ r11 = palette[hi(r8]] | ||
77 | |||
78 | orr r6, r11, r6, lsl #16 @ r6 = palette[hi(r8]] | ||
79 | @ | (palette[hi(r7)] << 16) | ||
80 | |||
81 | mov r5, r9, lsr #8 | ||
82 | mov r5, r5, lsl #1 | ||
83 | ldrh r5, [r5, r0] @ r5 = palette[hi(r9]] | ||
84 | |||
85 | mov r11, r10, lsr #8 | ||
86 | mov r11, r11, lsl #1 | ||
87 | ldrh r11, [r11, r0] @ r11 = palette[hi(r10)]] | ||
88 | |||
89 | orr r5, r11, r5, lsl #16 @ r5 = palette[hi(r10]] | ||
90 | @ | (palette[hi(r9)] << 16) | ||
91 | |||
92 | /* Convert low bytes of r7-r10 into palette entries in r7 and r8 */ | ||
93 | and r7, r7, #0xff | ||
94 | mov r7, r7, lsl #1 | ||
95 | ldrh r7, [r7, r0] | ||
96 | |||
97 | and r8, r8, #0xff | ||
98 | mov r8, r8, lsl #1 | ||
99 | ldrh r8, [r8, r0] | ||
100 | |||
101 | orr r8, r8, r7, lsl #16 | ||
102 | |||
103 | and r9, r9, #0xff | ||
104 | mov r9, r9, lsl #1 | ||
105 | ldrh r9, [r9, r0] | ||
106 | |||
107 | and r10, r10, #0xff | ||
108 | mov r10, r10, lsl #1 | ||
109 | ldrh r10, [r10, r0] | ||
110 | |||
111 | orr r7, r10, r9, lsl #16 | ||
112 | |||
113 | /* Now write the 8 pixels to the screen */ | ||
114 | stmia r2!, {r7, r8} | ||
115 | add r2, r2, #(LCD_WIDTH*2)-8 @ dst += LCD_WIDTH | ||
116 | |||
117 | stmia r2!, {r5, r6} | ||
118 | add r2, r2, #(LCD_WIDTH*2)-8 @ dst += LCD_WIDTH | ||
119 | |||
120 | /* end of x loop */ | ||
121 | subs ip, ip, #2 @ x-=2 | ||
122 | bne loop_x | ||
123 | |||
124 | /* end of y loop */ | ||
125 | add r1, r1, #224*3 @ vbuf += 224*3 | ||
126 | subs lr, lr, #4 @ y-=4 | ||
127 | ldmeqia sp!, {r4-r12, pc} | ||
128 | b loop_y | ||
129 | #endif | ||
130 | #endif | ||
diff --git a/apps/plugins/pacbox/pacbox_lcd.c b/apps/plugins/pacbox/pacbox_lcd.c new file mode 100644 index 0000000000..83931b1b68 --- /dev/null +++ b/apps/plugins/pacbox/pacbox_lcd.c | |||
@@ -0,0 +1,105 @@ | |||
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 | * All files in this archive are subject to the GNU General Public License. | ||
17 | * See the file COPYING in the source tree root for full license agreement. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | |||
24 | #include "pacbox.h" | ||
25 | #include "pacbox_lcd.h" | ||
26 | #include "arcade.h" | ||
27 | #include "hardware.h" | ||
28 | |||
29 | void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf) | ||
30 | { | ||
31 | fb_data* dst; | ||
32 | fb_data* next_dst; | ||
33 | int x,y; | ||
34 | |||
35 | #ifdef HAVE_LCD_COLOR | ||
36 | #if (LCD_WIDTH >= 224) && (LCD_HEIGHT >= 288) | ||
37 | /* Native resolution = 224x288 */ | ||
38 | (void)next_dst; | ||
39 | dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS]; | ||
40 | for (y=0;y<ScreenHeight;y++) { | ||
41 | for (x=0;x<ScreenWidth;x++) { | ||
42 | *(dst++) = palette[*(vbuf++)]; | ||
43 | } | ||
44 | dst += XOFS*2; | ||
45 | } | ||
46 | #elif (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224) | ||
47 | /* Native resolution - rotated 90 degrees = 288x224 */ | ||
48 | next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight-1]; | ||
49 | for( y=ScreenHeight-1; y>=0; y-- ) { | ||
50 | dst = (next_dst--); | ||
51 | for( x=0; x<ScreenWidth; x++ ) { | ||
52 | *dst = palette[*(vbuf++)]; | ||
53 | dst+=LCD_WIDTH; | ||
54 | } | ||
55 | } | ||
56 | #elif (LCD_WIDTH >= 216) && (LCD_HEIGHT >= 168) | ||
57 | /* 0.75 scaling - display 3 out of 4 pixels = 216x168 | ||
58 | Skipping pixel #2 out of 4 seems to give the most legible display | ||
59 | */ | ||
60 | next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+((ScreenHeight*3)/4)-1]; | ||
61 | for (y=ScreenHeight-1;y >= 0; y--) { | ||
62 | if ((y & 3) != 1) { | ||
63 | dst = (next_dst--); | ||
64 | for (x=0;x<ScreenWidth;x++) { | ||
65 | if ((x & 3) == 1) { vbuf++; } | ||
66 | else { | ||
67 | *dst = palette[*(vbuf++)]; | ||
68 | dst+=LCD_WIDTH; | ||
69 | } | ||
70 | } | ||
71 | } else { | ||
72 | vbuf+=ScreenWidth; | ||
73 | } | ||
74 | } | ||
75 | #elif (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112) | ||
76 | /* 0.5 scaling - display every other pixel = 144x112 */ | ||
77 | next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight/2-1]; | ||
78 | for (y=(ScreenHeight/2)-1;y >= 0; y--) { | ||
79 | dst = (next_dst--); | ||
80 | for (x=0;x<ScreenWidth/2;x++) { | ||
81 | *dst = palette[*(vbuf)]; | ||
82 | vbuf+=2; | ||
83 | dst+=LCD_WIDTH; | ||
84 | } | ||
85 | vbuf+=ScreenWidth; | ||
86 | } | ||
87 | #endif | ||
88 | #else /* Greyscale LCDs */ | ||
89 | #if (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112) | ||
90 | #if LCD_PIXELFORMAT == VERTICAL_PACKING | ||
91 | /* 0.5 scaling - display every other pixel = 144x112 */ | ||
92 | next_dst=&lcd_framebuffer[YOFS/4*LCD_WIDTH+XOFS+ScreenHeight/2-1]; | ||
93 | for (y=(ScreenHeight/2)-1;y >= 0; y--) { | ||
94 | dst = (next_dst--); | ||
95 | for (x=0;x<ScreenWidth/8;x++) { | ||
96 | *dst = (palette[*(vbuf+6)]<<6) | (palette[*(vbuf+4)] << 4) | (palette[*(vbuf+2)] << 2) | palette[*(vbuf)]; | ||
97 | vbuf+=8; | ||
98 | dst+=LCD_WIDTH; | ||
99 | } | ||
100 | vbuf+=ScreenWidth; | ||
101 | } | ||
102 | #endif /* Vertical Packing */ | ||
103 | #endif /* Size >= 144x112 */ | ||
104 | #endif /* Not Colour */ | ||
105 | } | ||
diff --git a/apps/plugins/pacbox/pacbox_lcd.h b/apps/plugins/pacbox/pacbox_lcd.h new file mode 100644 index 0000000000..e1fbaa6a04 --- /dev/null +++ b/apps/plugins/pacbox/pacbox_lcd.h | |||
@@ -0,0 +1,31 @@ | |||
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 | * All files in this archive are subject to the GNU General Public License. | ||
17 | * See the file COPYING in the source tree root for full license agreement. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | |||
24 | #ifndef _PACBOX_LCD_H | ||
25 | #define _PACBOX_LCD_H | ||
26 | |||
27 | #include "plugin.h" | ||
28 | |||
29 | void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf); | ||
30 | |||
31 | #endif | ||