From 03627e053938782cc6d13d2519a4bd9eb65694ef Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Sat, 18 Mar 2006 09:14:10 +0000 Subject: More patches from Fredrik Öhrn - joystick2.diff (add support using buttons on the iriver remotes) and speedup.diff (more optimisations for Coldfire targets). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9089 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/pacbox/SOURCES | 5 +- apps/plugins/pacbox/arcade.c | 4 + apps/plugins/pacbox/hardware.c | 2 +- apps/plugins/pacbox/pacbox.c | 18 +++- apps/plugins/pacbox/pacbox.h | 15 +++ apps/plugins/pacbox/pacbox_cf.S | 215 ++++++++++++++++++++++++++++----------- apps/plugins/pacbox/pacbox_lcd.c | 4 + 7 files changed, 198 insertions(+), 65 deletions(-) diff --git a/apps/plugins/pacbox/SOURCES b/apps/plugins/pacbox/SOURCES index c457f5b2ce..cedcda1363 100644 --- a/apps/plugins/pacbox/SOURCES +++ b/apps/plugins/pacbox/SOURCES @@ -4,8 +4,9 @@ hardware.c z80.c #if (CONFIG_CPU == PP5020) && (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224) pacbox_arm.S -#elif defined(IRIVER_H300_SERIES) && !defined(SIMULATOR) -pacbox_cf.S #else pacbox_lcd.c #endif +#if defined(CPU_COLDFIRE) +pacbox_cf.S +#endif diff --git a/apps/plugins/pacbox/arcade.c b/apps/plugins/pacbox/arcade.c index b4619d4c39..db7bf0bb89 100644 --- a/apps/plugins/pacbox/arcade.c +++ b/apps/plugins/pacbox/arcade.c @@ -408,6 +408,9 @@ unsigned getDipSwitches(void) { return result; } +#if defined (CPU_COLDFIRE) +extern void drawChar( unsigned char * buffer, int index, int ox, int oy, int color ); +#else static inline void drawChar( unsigned char * buffer, int index, int ox, int oy, int color ) { int x,y; @@ -446,6 +449,7 @@ static inline void drawChar( unsigned char * buffer, int index, int ox, int oy, } } } +#endif inline void drawSprite( unsigned char * buffer, int index ) { diff --git a/apps/plugins/pacbox/hardware.c b/apps/plugins/pacbox/hardware.c index 3cc4858e43..23658cf61e 100644 --- a/apps/plugins/pacbox/hardware.c +++ b/apps/plugins/pacbox/hardware.c @@ -35,7 +35,7 @@ unsigned char spriteset_rom_[4*1024] IBSS_ATTR; // Sprite set ROM (4K) unsigned char dirty_[1024] IBSS_ATTR; unsigned char video_mem_[1024] IBSS_ATTR; // Video memory (1K) unsigned char color_mem_[1024] IBSS_ATTR; // Color memory (1K) -unsigned char charmap_[256*8*8]; /* Character data for 256 8x8 characters */ +unsigned char charmap_[256*8*8] IBSS_ATTR; /* Character data for 256 8x8 characters */ unsigned char spritemap_[64*16*16]; /* Sprite data for 64 16x16 sprites */ unsigned char output_devices_ IBSS_ATTR; /* Output flip-flops set by the game program */ unsigned char interrupt_vector_ IBSS_ATTR; diff --git a/apps/plugins/pacbox/pacbox.c b/apps/plugins/pacbox/pacbox.c index e38dc0caf8..097e207ee6 100644 --- a/apps/plugins/pacbox/pacbox.c +++ b/apps/plugins/pacbox/pacbox.c @@ -115,7 +115,7 @@ static bool loadROMS( void ) } /* A buffer to render Pacman's 244x288 screen into */ -static unsigned char video_buffer[ScreenWidth*ScreenHeight] __attribute__ ((aligned (4))); +static unsigned char video_buffer[ScreenWidth*ScreenHeight] __attribute__ ((aligned (16))); static long start_time; static long video_frames = 0; @@ -283,7 +283,11 @@ static int gameProc( void ) /* Check the button status */ status = rb->button_status(); - if ((status & PACMAN_MENU) == PACMAN_MENU) { + if ((status & PACMAN_MENU) == PACMAN_MENU +#ifdef PACMAN_RC_MENU + || status == PACMAN_RC_MENU +#endif + ) { end_time = *rb->current_tick; x = pacbox_menu(); rb->lcd_clear_display(); @@ -295,6 +299,15 @@ static int gameProc( void ) start_time += *rb->current_tick-end_time; } +#ifdef PACMAN_HAS_REMOTE + setDeviceMode( Joy1_Left, (status & PACMAN_LEFT || status == PACMAN_RC_LEFT) ? DeviceOn : DeviceOff); + setDeviceMode( Joy1_Right, (status & PACMAN_RIGHT || status == PACMAN_RC_RIGHT) ? DeviceOn : DeviceOff); + setDeviceMode( Joy1_Up, (status & PACMAN_UP || status == PACMAN_RC_UP) ? DeviceOn : DeviceOff); + setDeviceMode( Joy1_Down, (status & PACMAN_DOWN || status == PACMAN_RC_DOWN) ? DeviceOn : DeviceOff); + setDeviceMode( CoinSlot_1, (status & PACMAN_COIN || status == PACMAN_RC_COIN) ? DeviceOn : DeviceOff); + setDeviceMode( Key_OnePlayer, (status & PACMAN_1UP || status == PACMAN_RC_1UP) ? DeviceOn : DeviceOff); + setDeviceMode( Key_TwoPlayers, (status & PACMAN_2UP || status == PACMAN_RC_2UP) ? DeviceOn : DeviceOff); +#else setDeviceMode( Joy1_Left, (status & PACMAN_LEFT) ? DeviceOn : DeviceOff); setDeviceMode( Joy1_Right, (status & PACMAN_RIGHT) ? DeviceOn : DeviceOff); setDeviceMode( Joy1_Up, (status & PACMAN_UP) ? DeviceOn : DeviceOff); @@ -303,6 +316,7 @@ static int gameProc( void ) setDeviceMode( Key_OnePlayer, (status & PACMAN_1UP) ? DeviceOn : DeviceOff); #ifdef PACMAN_2UP setDeviceMode( Key_TwoPlayers, (status & PACMAN_2UP) ? DeviceOn : DeviceOff); +#endif #endif /* We only update the screen every third frame - Pacman's native diff --git a/apps/plugins/pacbox/pacbox.h b/apps/plugins/pacbox/pacbox.h index 3e80754f76..c852608680 100644 --- a/apps/plugins/pacbox/pacbox.h +++ b/apps/plugins/pacbox/pacbox.h @@ -50,6 +50,21 @@ #define PACMAN_COIN BUTTON_REC #define PACMAN_MENU BUTTON_MODE +#ifdef HAVE_REMOTE_LCD + +#define PACMAN_HAS_REMOTE + +#define PACMAN_RC_UP BUTTON_RC_VOL_UP +#define PACMAN_RC_DOWN BUTTON_RC_VOL_DOWN +#define PACMAN_RC_LEFT BUTTON_RC_REW +#define PACMAN_RC_RIGHT BUTTON_RC_FF +#define PACMAN_RC_1UP BUTTON_RC_SOURCE +#define PACMAN_RC_2UP BUTTON_RC_BITRATE +#define PACMAN_RC_COIN BUTTON_RC_REC +#define PACMAN_RC_MENU BUTTON_RC_MODE + +#endif + #elif CONFIG_KEYPAD == GIGABEAT_PAD #define PACMAN_UP BUTTON_UP diff --git a/apps/plugins/pacbox/pacbox_cf.S b/apps/plugins/pacbox/pacbox_cf.S index 7dc6140b44..5d3185eca2 100644 --- a/apps/plugins/pacbox/pacbox_cf.S +++ b/apps/plugins/pacbox/pacbox_cf.S @@ -21,6 +21,10 @@ .section .text .align 2 + + +#if defined(IRIVER_H300_SERIES) && !defined(SIMULATOR) + .global blit_display /* @@ -57,99 +61,190 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf) #define SHRUNK_WIDTH ((ScreenWidth/4)*3) #define SHRUNK_HEIGHT ((ScreenHeight/4)*3) +#define BD_SAVE (9 * 4) + +process_4_pixels: + move.b %d4, %d2 + move.w (%a1, %d2.l * 2), %d3 + move.w %d3, (2 * LCD_WIDTH * 2)(%a0) + + lsr.l #8, %d4 + move.b %d4, %d2 + move.w (%a1, %d2.l * 2), %d3 + move.w %d3, (1 * LCD_WIDTH * 2)(%a0) + + swap.w %d4 + move.b %d4, %d2 + move.w (%a1, %d2.l * 2), (%a0) + + lea.l 3 * LCD_WIDTH * 2(%a0), %a0 + rts + +process_line: + move.l %a3, %d1 +bd_x_loop: + movem.l (%a2), %d4-%d7 // Read 16 pixels + + bsr.s process_4_pixels + move.l %d5, %d4 + bsr.s process_4_pixels + move.l %d6, %d4 + bsr.s process_4_pixels + move.l %d7, %d4 + bsr.s process_4_pixels + + lea 16(%a2), %a2 + subq.l #1, %d1; + bne.s bd_x_loop + + rts + blit_display: - lea -28(%sp), %sp - movem.l %d2-%d6/%a2, (%sp) + lea -BD_SAVE(%sp), %sp + movem.l %d2-%d7/%a2-%a4, (%sp) - move.l 32(%sp), %a0 // lcd_framebuffer - move.l 36(%sp), %a2 // vbuf + move.l BD_SAVE + 4(%sp), %a0 // lcd_framebuffer + move.l BD_SAVE + 8(%sp), %a2 // vbuf lea palette, %a1 lea.l ((YOFS * LCD_WIDTH + XOFS + SHRUNK_HEIGHT) * 2)(%a0), %a0 move.l #(ScreenHeight / 4), %d0 - move.l #(ScreenWidth / 4), %d1 + move.l #(ScreenWidth / 16), %a3 + move.l #(LCD_WIDTH * SHRUNK_WIDTH + 1) * 2, %a4 moveq.l #0, %d2 -y_loop: - move.l %d1, %d5 -x_loop1: - move.l (%a2)+, %d3 +bd_y_loop: + bsr.s process_line - move.b %d3, %d2 - move.w (%a1, %d2.l * 2), %d6 - move.w %d6, (2 * LCD_WIDTH * 2)(%a0) + suba.l %a4, %a0 + lea.l ScreenWidth(%a2), %a2 // Skip 1 line - lsr.l #8, %d3 - move.b %d3, %d2 - move.w (%a1, %d2.l * 2), %d6 - move.w %d6, (1 * LCD_WIDTH * 2)(%a0) + bsr.s process_line - swap.w %d3 - move.b %d3, %d2 - move.w (%a1, %d2.l * 2), (%a0) + suba.l %a4, %a0 - lea.l 3 * LCD_WIDTH * 2(%a0), %a0 + bsr.s process_line - subq.l #1, %d5 - bne.s x_loop1 + suba.l %a4, %a0 - suba.l #(LCD_WIDTH * SHRUNK_WIDTH + 1) * 2, %a0 - lea.l ScreenWidth(%a2), %a2 // Skip 1 line + subq.l #1, %d0 + bne bd_y_loop - move.l %d1, %d5 -x_loop2: - move.l (%a2)+, %d3 + movem.l (%sp), %d2-%d7/%a2-%a4 + lea.l BD_SAVE(%sp), %sp + rts - move.b %d3, %d2 - move.w (%a1, %d2.l * 2), %d6 - move.w %d6, 2 * LCD_WIDTH * 2(%a0) +#endif /* defined(IRIVER_H300_SERIES) && !defined(SIMULATOR) */ - lsr.l #8, %d3 - move.b %d3, %d2 - move.w (%a1, %d2.l * 2), %d6 - move.w %d6, 1 * LCD_WIDTH * 2(%a0) - swap.w %d3 - move.b %d3, %d2 - move.w (%a1, %d2.l * 2), (%a0) +/* See arcade.c for the C implementation of drawChar */ +/* Note! This version does not handle flipped screen mode. */ + + .global drawChar - lea.l 3 * LCD_WIDTH * 2(%a0), %a0 +#define DC_SAVE (4 * 4) - subq.l #1, %d5 - bne.s x_loop2 +drawChar: + lea -DC_SAVE(%sp), %sp + movem.l %d2-%d5, (%sp) - suba.l #(LCD_WIDTH * SHRUNK_WIDTH + 1) * 2, %a0 + movea.l DC_SAVE + 4(%sp), %a0 // buffer - move.l %d1, %d5 -x_loop3: - move.l (%a2)+, %d3 + move.l DC_SAVE + 16(%sp), %d0 // oy + move.l %d0, %d1 + lsl.l #8, %d0 + lsl.l #5, %d1 + sub.l %d1, %d0 + adda.l %d0, %a0 + adda.l DC_SAVE + 12(%sp), %a0 // ox - move.b %d3, %d2 - move.w (%a1, %d2.l * 2), %d6 - move.w %d6, 2 * LCD_WIDTH * 2(%a0) + move.l DC_SAVE + 20(%sp), %d0 // color + and.l #0x3F, %d0 + bne.s have_color + + moveq.l #8, %d1 + moveq.l #0, %d2 + moveq.l #0, %d3 + +clear_loop: + movem.l %d2-%d3, (%a0) + lea 224(%a0), %a0 + + subq.l #1, %d1 + bne.s clear_loop + + bra.s dc_exit + +have_color: + lsl.l #2, %d0 + + lea.l charmap_, %a1 + move.l DC_SAVE + 8(%sp), %d2 // index + lsl.l #6, %d2 + adda.l %d2, %a1 - lsr.l #8, %d3 + moveq.l #8, %d1 + moveq.l #0, %d3 + moveq.l #24, %d5 + +dc_y_loop: + move.l (%a1)+, %d3 + move.l %d3, %d4 + + move.l %d3, %d2 // Pixel 1 + lsr.l %d5, %d2 + add.l %d0, %d2 + lsl.l #8, %d2 + + swap.w %d4 // Pixel 2 + move.b %d4, %d2 + add.l %d0, %d2 + lsl.l #8, %d2 + + lsr.l #8, %d3 // Pixel 3 move.b %d3, %d2 - move.w (%a1, %d2.l * 2), %d6 - move.w %d6, 1 * LCD_WIDTH * 2(%a0) + add.l %d0, %d2 + lsl.l #8, %d2 + + swap.w %d4 // Pixel 4 + move.b %d4, %d2 + add.l %d0, %d2 + + move.l %d2, (%a0)+ - swap.w %d3 + move.l (%a1)+, %d3 + move.l %d3, %d4 + + move.l %d3, %d2 // Pixel 1 + lsr.l %d5, %d2 + add.l %d0, %d2 + lsl.l #8, %d2 + + swap.w %d4 // Pixel 2 + move.b %d4, %d2 + add.l %d0, %d2 + lsl.l #8, %d2 + + lsr.l #8, %d3 // Pixel 3 move.b %d3, %d2 - move.w (%a1, %d2.l * 2), (%a0) + add.l %d0, %d2 + lsl.l #8, %d2 - lea.l 3 * LCD_WIDTH * 2(%a0), %a0 + swap.w %d4 // Pixel 4 + move.b %d4, %d2 + add.l %d0, %d2 - subq.l #1, %d5 - bne.s x_loop3 + move.l %d2, (%a0)+ - suba.l #(LCD_WIDTH * SHRUNK_WIDTH + 1) * 2, %a0 + lea 216(%a0), %a0 - subq.l #1, %d0 - bne y_loop + subq.l #1, %d1 + bne.s dc_y_loop - movem.l (%sp), %d2-%d6/%a2 - lea.l 28(%sp), %sp +dc_exit: + movem.l (%sp), %d2-%d5 + lea.l DC_SAVE(%sp), %sp rts diff --git a/apps/plugins/pacbox/pacbox_lcd.c b/apps/plugins/pacbox/pacbox_lcd.c index 83931b1b68..5d126efcf1 100644 --- a/apps/plugins/pacbox/pacbox_lcd.c +++ b/apps/plugins/pacbox/pacbox_lcd.c @@ -26,6 +26,8 @@ #include "arcade.h" #include "hardware.h" +#if defined(SIMULATOR) || !defined(IRIVER_H300_SERIES) + void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf) { fb_data* dst; @@ -103,3 +105,5 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf) #endif /* Size >= 144x112 */ #endif /* Not Colour */ } + +#endif -- cgit v1.2.3