diff options
Diffstat (limited to 'apps/plugins')
-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 LINKFILE := $(OBJDIR)/link.lds DEPFILE = $(OBJDIR)/dep-pacbox -SRC = arcade.c pacbox.c hardware.c z80.c + +# This sets up 'SRC' based on the files mentioned in SOURCES +include $(TOOLSDIR)/makesrc.inc SOURCES = $(SRC) -OBJS := $(SRC:%.c=$(OBJDIR)/%.o) +OBJS2 := $(SRC:%.c=$(OBJDIR)/%.o) +OBJS = $(patsubst %.S, $(OBJDIR)/%.o, $(OBJS2)) DIRS = . 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 @@ +arcade.c +pacbox.c +hardware.c +z80.c +#if (CONFIG_CPU == PP5020) && (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224) +pacbox_arm.S +#else +pacbox_lcd.c +#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 ) unsigned bit0, bit1, bit2; unsigned red, green, blue; - bit0 = (value >> 0) & 0x01; - bit1 = (value >> 1) & 0x01; - bit2 = (value >> 2) & 0x01; - red = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + bit0 = (value >> 0) & 0x01; + bit1 = (value >> 1) & 0x01; + bit2 = (value >> 2) & 0x01; + red = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; bit0 = (value >> 3) & 0x01; - bit1 = (value >> 4) & 0x01; - bit2 = (value >> 5) & 0x01; - green = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + bit1 = (value >> 4) & 0x01; + bit2 = (value >> 5) & 0x01; + green = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; bit0 = 0; - bit1 = (value >> 6) & 0x01; - bit2 = (value >> 7) & 0x01; + bit1 = (value >> 6) & 0x01; + bit2 = (value >> 7) & 0x01; blue = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; return (blue << 16 ) | (green << 8) | red; @@ -428,6 +428,7 @@ inline void drawSprite( unsigned char * buffer, int index ) { struct PacmanSprite ps = sprites_[index]; int x,y; + char * s, * s2; // Exit now if sprite not visible at all 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 ) // Clip the sprite coordinates to cut the parts that fall off the screen int start_x = (ps.x < 0) ? 0 : ps.x; - int end_x = (ps.x < (ScreenWidth-16)) ? ps.x+16 : ScreenWidth; + int end_x = (ps.x < (ScreenWidth-16)) ? ps.x+15 : ScreenWidth-1; // Prepare variables for drawing int color = (ps.color & 0x3F)*4; unsigned char * spritemap_base = spritemap_ + ((ps.n & 0x3F)*256); buffer += ScreenWidth*ps.y; + s2 = &spritemap_base[start_x-ps.x]; + + dirty_[(start_x >> 3) + (ps.y >> 3)*28] = 1; + dirty_[(start_x >> 3) + 1 + (ps.y >> 3)*28] = 1; + dirty_[(end_x >> 3) + (ps.y >> 3)*28] = 1; + dirty_[(start_x >> 3) + ((ps.y >> 3)+1)*28] = 1; + dirty_[(start_x >> 3) + 1 + ((ps.y >> 3)+1)*28] = 1; + dirty_[(end_x >> 3) + ((ps.y >> 3)+1)*28] = 1; + dirty_[(start_x >> 3) + ((ps.y+15) >> 3)*28] = 1; + dirty_[(start_x >> 3) + 1 + ((ps.y+15) >> 3)*28] = 1; + dirty_[(end_x >> 3) + ((ps.y+15) >> 3)*28] = 1; // Draw the 16x16 sprite if( ps.mode == 0 ) { // Normal // Draw the 16x16 sprite - for( y=0; y<16; y++ ) { - char* s = &spritemap_base[start_x-ps.x+y*16]; - for( x=start_x; x<end_x; x++ ) { + for( y=15; y>=0; y-- ) { + s = s2; + for( x=start_x; x<=end_x; x++ ) { int c = *(s++); if( c ) { buffer[x] = c + color; } } buffer += ScreenWidth; + s2 += 16; } } else if( ps.mode == 1 ) { // Flip Y - for( y=0; y<16; y++ ) { - char* s = &spritemap_base[start_x-ps.x+(15-y)*16]; - for( x=start_x; x<end_x; x++ ) { + s2 += 240; + for( y=15; y>=0; y-- ) { + s = s2; + for( x=start_x; x<=end_x; x++ ) { int c = *(s++); if( c ) { buffer[x] = c + color; } } buffer += ScreenWidth; + s2 -= 16; } } else if( ps.mode == 2 ) { // Flip X - for( y=0; y<16; y++ ) { - char* s = &spritemap_base[15-start_x+ps.x+y*16]; - for( x=start_x; x<end_x; x++ ) { + s2 += 15; + for( y=15; y>=-0; y-- ) { + s = s2; + for( x=start_x; x<=end_x; x++ ) { int c = *(s--); if( c ) { buffer[x] = c + color; } } buffer += ScreenWidth; + s2 += 16; } } else { // Flip X and Y - for( y=0; y<16; y++ ) { - char* s = &spritemap_base[15-start_x+ps.x+(15-y)*16]; - for( x=start_x; x<end_x; x++ ) { + s2 += 255; + for( y=15; y>=0; y-- ) { + s = s2; + for( x=start_x; x<=end_x; x++ ) { int c = *(s--); if( c ) { buffer[x] = c + color; } } buffer += ScreenWidth; + s2 -= 16; } } } 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 @@ #include "plugin.h" #include "arcade.h" +#include "pacbox.h" +#include "pacbox_lcd.h" PLUGIN_HEADER @@ -38,64 +40,6 @@ extern char iend[]; /* How many video frames (out of a possible 60) we display each second */ #define FPS 20 -#if CONFIG_KEYPAD == IPOD_4G_PAD - -#define PACMAN_UP BUTTON_RIGHT -#define PACMAN_DOWN BUTTON_LEFT -#define PACMAN_LEFT BUTTON_MENU -#define PACMAN_RIGHT BUTTON_PLAY -#define PACMAN_1UP BUTTON_SELECT -#define PACMAN_COIN BUTTON_SELECT - -#elif CONFIG_KEYPAD == IRIVER_H100_PAD || CONFIG_KEYPAD == IRIVER_H300_PAD - -#define PACMAN_UP BUTTON_RIGHT -#define PACMAN_DOWN BUTTON_LEFT -#define PACMAN_LEFT BUTTON_UP -#define PACMAN_RIGHT BUTTON_DOWN -#define PACMAN_1UP BUTTON_SELECT -#define PACMAN_2UP BUTTON_ON -#define PACMAN_COIN BUTTON_REC -#define PACMAN_MENU BUTTON_MODE - -#elif CONFIG_KEYPAD == GIGABEAT_PAD - -#define PACMAN_UP BUTTON_UP -#define PACMAN_DOWN BUTTON_DOWN -#define PACMAN_LEFT BUTTON_LEFT -#define PACMAN_RIGHT BUTTON_RIGHT -#define PACMAN_1UP BUTTON_SELECT -#define PACMAN_2UP BUTTON_POWER -#define PACMAN_COIN BUTTON_A -#define PACMAN_MENU BUTTON_MENU - -#elif CONFIG_KEYPAD == IAUDIO_X5_PAD - -#define PACMAN_UP BUTTON_RIGHT -#define PACMAN_DOWN BUTTON_LEFT -#define PACMAN_LEFT BUTTON_UP -#define PACMAN_RIGHT BUTTON_DOWN -#define PACMAN_1UP BUTTON_SELECT -#define PACMAN_2UP BUTTON_POWER -#define PACMAN_COIN BUTTON_REC -#define PACMAN_MENU BUTTON_PLAY - -#endif - -#if (LCD_HEIGHT >= 288) -#define XOFS ((LCD_WIDTH-224)/2) -#define YOFS ((LCD_HEIGHT-288)/2) -#elif (LCD_WIDTH >= 288) -#define XOFS ((LCD_WIDTH-288)/2) -#define YOFS ((LCD_HEIGHT-224)/2) -#elif (LCD_WIDTH >= 220) -#define XOFS ((LCD_WIDTH-(288*3/4))/2) -#define YOFS ((LCD_HEIGHT-(224*3/4))/2) -#elif (LCD_WIDTH >= 144) -#define XOFS ((LCD_WIDTH-288/2)/2) -#define YOFS ((LCD_HEIGHT-224/2)/2) -#endif - struct plugin_api* rb; unsigned framesPerSecond = VideoFrequency; @@ -180,31 +124,6 @@ int settings_to_dip(struct pacman_settings settings) ); } - - -int pacbox_menu_cb(int key, int m) -{ - (void)m; - switch(key) - { -#ifdef MENU_ENTER2 - case MENU_ENTER2: -#endif - case MENU_ENTER: - key = BUTTON_NONE; /* eat the downpress, next menu reacts on release */ - break; - -#ifdef MENU_ENTER2 - case MENU_ENTER2 | BUTTON_REL: -#endif - case MENU_ENTER | BUTTON_REL: - key = MENU_ENTER; /* fake downpress, next menu doesn't like release */ - break; - } - - return key; -} - bool pacbox_menu(void) { int m; @@ -253,7 +172,7 @@ bool pacbox_menu(void) }; m = rb->menu_init(items, sizeof(items) / sizeof(*items), - pacbox_menu_cb, NULL, NULL, NULL); + NULL, NULL, NULL, NULL); rb->button_clear_queue(); @@ -331,14 +250,11 @@ bool pacbox_menu(void) */ int gameProc( void ) { - int x,y; + int x; int fps; char str[80]; int status; long end_time; - unsigned char* vbuf = video_buffer; - fb_data* dst; - fb_data* next_dst; /* Run the machine for one frame (1/60th second) */ run(); @@ -348,11 +264,7 @@ int gameProc( void ) /* Check the button status */ status = rb->button_status(); -#ifdef PACMAN_MENU - if (status & PACMAN_MENU) { -#else - if (rb->button_hold()) { -#endif + if ((status & PACMAN_MENU) == PACMAN_MENU) { end_time = *rb->current_tick; x = pacbox_menu(); rb->lcd_clear_display(); @@ -389,80 +301,11 @@ int gameProc( void ) the sprites on top. Even with the memcpy, this is faster than redrawing the whole background. */ - renderBackground( background ); - rb->memcpy(video_buffer,background,sizeof(video_buffer)); - renderSprites( video_buffer ); - -#ifdef HAVE_LCD_COLOR -#if (LCD_WIDTH >= 224) && (LCD_HEIGHT >= 288) - /* Native resolution = 224x288 */ - (void)next_dst; - dst=&rb->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_WIDTH >= 288) && (LCD_HEIGHT >= 224) - /* Native resolution - rotated 90 degrees = 288x224 */ - next_dst=&rb->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_WIDTH >= 216) && (LCD_HEIGHT >= 168) - /* 0.75 scaling - display 3 out of 4 pixels = 216x168 - Skipping pixel #2 out of 4 seems to give the most legible display - */ - next_dst=&rb->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_WIDTH >= 144) && (LCD_HEIGHT >= 112) - /* 0.5 scaling - display every other pixel = 144x112 */ - next_dst=&rb->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; - } -#endif -#else /* Greyscale LCDs */ -#if (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112) -#if LCD_PIXELFORMAT == VERTICAL_PACKING - /* 0.5 scaling - display every other pixel = 144x112 */ - next_dst=&rb->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 /* Size >= 144x112 */ -#endif /* Not Colour */ + + renderBackground( video_buffer ); + renderSprites( video_buffer ); + + blit_display(rb->lcd_framebuffer,video_buffer); if (settings.showfps) { 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) settings.numlives = 2; /* 3 lives */ settings.bonus = 0; /* 10000 points */ settings.ghostnames = 0; /* Normal names */ - settings.showfps = 0; /* Do not show FPS */ + settings.showfps = 1; /* Do not show FPS */ /* Initialise the hardware */ 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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Pacbox - a Pacman Emulator for Rockbox + * + * Based on PIE - Pacman Instructional Emulator + * + * Copyright (c) 1997-2003,2004 Alessandro Scotti + * http://www.ascotti.org/ + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* Platform-specific defines - used in both C and ASM files */ + +#ifndef _PACBOX_H +#define _PACBOX_H + +#include "config.h" + +#if CONFIG_KEYPAD == IPOD_4G_PAD + +#define PACMAN_UP BUTTON_RIGHT +#define PACMAN_DOWN BUTTON_LEFT +#define PACMAN_LEFT BUTTON_MENU +#define PACMAN_RIGHT BUTTON_PLAY +#define PACMAN_1UP BUTTON_SELECT +#define PACMAN_COIN BUTTON_SELECT +#define PACMAN_MENU (BUTTON_MENU | BUTTON_SELECT) + +#elif CONFIG_KEYPAD == IRIVER_H100_PAD || CONFIG_KEYPAD == IRIVER_H300_PAD + +#define PACMAN_UP BUTTON_RIGHT +#define PACMAN_DOWN BUTTON_LEFT +#define PACMAN_LEFT BUTTON_UP +#define PACMAN_RIGHT BUTTON_DOWN +#define PACMAN_1UP BUTTON_SELECT +#define PACMAN_2UP BUTTON_ON +#define PACMAN_COIN BUTTON_REC +#define PACMAN_MENU BUTTON_MODE + +#elif CONFIG_KEYPAD == GIGABEAT_PAD + +#define PACMAN_UP BUTTON_UP +#define PACMAN_DOWN BUTTON_DOWN +#define PACMAN_LEFT BUTTON_LEFT +#define PACMAN_RIGHT BUTTON_RIGHT +#define PACMAN_1UP BUTTON_SELECT +#define PACMAN_2UP BUTTON_POWER +#define PACMAN_COIN BUTTON_A +#define PACMAN_MENU BUTTON_MENU + +#elif CONFIG_KEYPAD == IAUDIO_X5_PAD + +#define PACMAN_UP BUTTON_RIGHT +#define PACMAN_DOWN BUTTON_LEFT +#define PACMAN_LEFT BUTTON_UP +#define PACMAN_RIGHT BUTTON_DOWN +#define PACMAN_1UP BUTTON_SELECT +#define PACMAN_2UP BUTTON_POWER +#define PACMAN_COIN BUTTON_REC +#define PACMAN_MENU BUTTON_PLAY + +#endif + +#if (LCD_HEIGHT >= 288) +#define XOFS ((LCD_WIDTH-224)/2) +#define YOFS ((LCD_HEIGHT-288)/2) +#elif (LCD_WIDTH >= 288) +#define XOFS ((LCD_WIDTH-288)/2) +#define YOFS ((LCD_HEIGHT-224)/2) +#elif (LCD_WIDTH >= 220) +#define XOFS ((LCD_WIDTH-(288*3/4))/2) +#define YOFS ((LCD_HEIGHT-(224*3/4))/2) +#elif (LCD_WIDTH >= 144) +#define XOFS ((LCD_WIDTH-288/2)/2) +#define YOFS ((LCD_HEIGHT-224/2)/2) +#endif + +#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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Pacbox - a Pacman Emulator for Rockbox + * + * Based on PIE - Pacman Instructional Emulator + * + * Copyright (c) 1997-2003,2004 Alessandro Scotti + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "pacbox.h" + + .section .icode,"ax",%progbits + .global blit_display + +/* void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf) + + next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight-1]; + for( y=ScreenHeight; y>0; y-- ) { + dst = (next_dst--); + for( x=ScreenWidth; x>0; x-- ) { + *dst = palette[*(vbuf++)]; + dst+=LCD_WIDTH; + } + } + */ + +#ifdef HAVE_LCD_COLOR +#if (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224) + +blit_display: + stmdb sp!, {r4-r12, lr} + + add r3, r0, #5696 + add r3, r3, #24 @ 5720 = (2*(YOFS*LCD_WIDTH+XOFS+ScreenHeight-4)) + ldr r0, =palette + mov lr, #288 @ y = 288 + + mov r12, #224*3 + +loop_y: mov r2, r3 @ r2 = next_dst + sub r3, r3, #8 @ next_dst-=4 + + mov ip, #224 @ x = 224 + +/* store 2 input bytes from the next four lines in r7-r10 */ +loop_x: + ldrh r8, [r1, #224] @ r8 = vbuf[224] + ldrh r7, [r1] @ r7 = vbuf[0] ; vbuf += 2; + add r1, r1, #448 + ldrh r10, [r1, #224] @ r8 = vbuf[224] + ldrh r9, [r1], #2 @ r7 = vbuf[0] ; vbuf += 2; + sub r1, r1, #448 + + +/* Convert high bytes of r7-r10 into palette entries in r5 and r6 */ + mov r6, r7, lsr #8 + mov r6, r6, lsl #1 + ldrh r6, [r6, r0] @ r6 = palette[hi(r7]] + + mov r11, r8, lsr #8 + mov r11, r11, lsl #1 + ldrh r11, [r11, r0] @ r11 = palette[hi(r8]] + + orr r6, r11, r6, lsl #16 @ r6 = palette[hi(r8]] + @ | (palette[hi(r7)] << 16) + + mov r5, r9, lsr #8 + mov r5, r5, lsl #1 + ldrh r5, [r5, r0] @ r5 = palette[hi(r9]] + + mov r11, r10, lsr #8 + mov r11, r11, lsl #1 + ldrh r11, [r11, r0] @ r11 = palette[hi(r10)]] + + orr r5, r11, r5, lsl #16 @ r5 = palette[hi(r10]] + @ | (palette[hi(r9)] << 16) + +/* Convert low bytes of r7-r10 into palette entries in r7 and r8 */ + and r7, r7, #0xff + mov r7, r7, lsl #1 + ldrh r7, [r7, r0] + + and r8, r8, #0xff + mov r8, r8, lsl #1 + ldrh r8, [r8, r0] + + orr r8, r8, r7, lsl #16 + + and r9, r9, #0xff + mov r9, r9, lsl #1 + ldrh r9, [r9, r0] + + and r10, r10, #0xff + mov r10, r10, lsl #1 + ldrh r10, [r10, r0] + + orr r7, r10, r9, lsl #16 + +/* Now write the 8 pixels to the screen */ + stmia r2!, {r7, r8} + add r2, r2, #(LCD_WIDTH*2)-8 @ dst += LCD_WIDTH + + stmia r2!, {r5, r6} + add r2, r2, #(LCD_WIDTH*2)-8 @ dst += LCD_WIDTH + +/* end of x loop */ + subs ip, ip, #2 @ x-=2 + bne loop_x + +/* end of y loop */ + add r1, r1, #224*3 @ vbuf += 224*3 + subs lr, lr, #4 @ y-=4 + ldmeqia sp!, {r4-r12, pc} + b loop_y +#endif +#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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Pacbox - a Pacman Emulator for Rockbox + * + * Based on PIE - Pacman Instructional Emulator + * + * Copyright (c) 1997-2003,2004 Alessandro Scotti + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * 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_WIDTH >= 224) && (LCD_HEIGHT >= 288) + /* 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_WIDTH >= 288) && (LCD_HEIGHT >= 224) + /* 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_WIDTH >= 216) && (LCD_HEIGHT >= 168) + /* 0.75 scaling - display 3 out of 4 pixels = 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_WIDTH >= 144) && (LCD_HEIGHT >= 112) + /* 0.5 scaling - display every other pixel = 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; + } +#endif +#else /* Greyscale LCDs */ +#if (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112) +#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 /* Size >= 144x112 */ +#endif /* Not Colour */ +} 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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Pacbox - a Pacman Emulator for Rockbox + * + * Based on PIE - Pacman Instructional Emulator + * + * Copyright (c) 1997-2003,2004 Alessandro Scotti + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _PACBOX_LCD_H +#define _PACBOX_LCD_H + +#include "plugin.h" + +void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf); + +#endif |