summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-03-18 09:14:10 +0000
committerDave Chapman <dave@dchapman.com>2006-03-18 09:14:10 +0000
commit03627e053938782cc6d13d2519a4bd9eb65694ef (patch)
tree1d35c337d9e0500047838ee703c147d60b5ac43d
parentd00d58896b37479923f8f6256d110e0a850bd820 (diff)
downloadrockbox-03627e053938782cc6d13d2519a4bd9eb65694ef.tar.gz
rockbox-03627e053938782cc6d13d2519a4bd9eb65694ef.zip
More patches from Fredrik Öhrn - joystick2.diff (add support using buttons on the iriver remotes) and speedup.diff (more optimisations for Coldfire targets).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9089 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/pacbox/SOURCES5
-rw-r--r--apps/plugins/pacbox/arcade.c4
-rw-r--r--apps/plugins/pacbox/hardware.c2
-rw-r--r--apps/plugins/pacbox/pacbox.c18
-rw-r--r--apps/plugins/pacbox/pacbox.h15
-rw-r--r--apps/plugins/pacbox/pacbox_cf.S215
-rw-r--r--apps/plugins/pacbox/pacbox_lcd.c4
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
4z80.c 4z80.c
5#if (CONFIG_CPU == PP5020) && (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224) 5#if (CONFIG_CPU == PP5020) && (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224)
6pacbox_arm.S 6pacbox_arm.S
7#elif defined(IRIVER_H300_SERIES) && !defined(SIMULATOR)
8pacbox_cf.S
9#else 7#else
10pacbox_lcd.c 8pacbox_lcd.c
11#endif 9#endif
10#if defined(CPU_COLDFIRE)
11pacbox_cf.S
12#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) {
408 return result; 408 return result;
409} 409}
410 410
411#if defined (CPU_COLDFIRE)
412extern void drawChar( unsigned char * buffer, int index, int ox, int oy, int color );
413#else
411static inline void drawChar( unsigned char * buffer, int index, int ox, int oy, int color ) 414static inline void drawChar( unsigned char * buffer, int index, int ox, int oy, int color )
412{ 415{
413 int x,y; 416 int x,y;
@@ -446,6 +449,7 @@ static inline void drawChar( unsigned char * buffer, int index, int ox, int oy,
446 } 449 }
447 } 450 }
448} 451}
452#endif
449 453
450inline void drawSprite( unsigned char * buffer, int index ) 454inline void drawSprite( unsigned char * buffer, int index )
451{ 455{
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)
35unsigned char dirty_[1024] IBSS_ATTR; 35unsigned char dirty_[1024] IBSS_ATTR;
36unsigned char video_mem_[1024] IBSS_ATTR; // Video memory (1K) 36unsigned char video_mem_[1024] IBSS_ATTR; // Video memory (1K)
37unsigned char color_mem_[1024] IBSS_ATTR; // Color memory (1K) 37unsigned char color_mem_[1024] IBSS_ATTR; // Color memory (1K)
38unsigned char charmap_[256*8*8]; /* Character data for 256 8x8 characters */ 38unsigned char charmap_[256*8*8] IBSS_ATTR; /* Character data for 256 8x8 characters */
39unsigned char spritemap_[64*16*16]; /* Sprite data for 64 16x16 sprites */ 39unsigned char spritemap_[64*16*16]; /* Sprite data for 64 16x16 sprites */
40unsigned char output_devices_ IBSS_ATTR; /* Output flip-flops set by the game program */ 40unsigned char output_devices_ IBSS_ATTR; /* Output flip-flops set by the game program */
41unsigned char interrupt_vector_ IBSS_ATTR; 41unsigned 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 )
115} 115}
116 116
117/* A buffer to render Pacman's 244x288 screen into */ 117/* A buffer to render Pacman's 244x288 screen into */
118static unsigned char video_buffer[ScreenWidth*ScreenHeight] __attribute__ ((aligned (4))); 118static unsigned char video_buffer[ScreenWidth*ScreenHeight] __attribute__ ((aligned (16)));
119 119
120static long start_time; 120static long start_time;
121static long video_frames = 0; 121static long video_frames = 0;
@@ -283,7 +283,11 @@ static int gameProc( void )
283 /* Check the button status */ 283 /* Check the button status */
284 status = rb->button_status(); 284 status = rb->button_status();
285 285
286 if ((status & PACMAN_MENU) == PACMAN_MENU) { 286 if ((status & PACMAN_MENU) == PACMAN_MENU
287#ifdef PACMAN_RC_MENU
288 || status == PACMAN_RC_MENU
289#endif
290 ) {
287 end_time = *rb->current_tick; 291 end_time = *rb->current_tick;
288 x = pacbox_menu(); 292 x = pacbox_menu();
289 rb->lcd_clear_display(); 293 rb->lcd_clear_display();
@@ -295,6 +299,15 @@ static int gameProc( void )
295 start_time += *rb->current_tick-end_time; 299 start_time += *rb->current_tick-end_time;
296 } 300 }
297 301
302#ifdef PACMAN_HAS_REMOTE
303 setDeviceMode( Joy1_Left, (status & PACMAN_LEFT || status == PACMAN_RC_LEFT) ? DeviceOn : DeviceOff);
304 setDeviceMode( Joy1_Right, (status & PACMAN_RIGHT || status == PACMAN_RC_RIGHT) ? DeviceOn : DeviceOff);
305 setDeviceMode( Joy1_Up, (status & PACMAN_UP || status == PACMAN_RC_UP) ? DeviceOn : DeviceOff);
306 setDeviceMode( Joy1_Down, (status & PACMAN_DOWN || status == PACMAN_RC_DOWN) ? DeviceOn : DeviceOff);
307 setDeviceMode( CoinSlot_1, (status & PACMAN_COIN || status == PACMAN_RC_COIN) ? DeviceOn : DeviceOff);
308 setDeviceMode( Key_OnePlayer, (status & PACMAN_1UP || status == PACMAN_RC_1UP) ? DeviceOn : DeviceOff);
309 setDeviceMode( Key_TwoPlayers, (status & PACMAN_2UP || status == PACMAN_RC_2UP) ? DeviceOn : DeviceOff);
310#else
298 setDeviceMode( Joy1_Left, (status & PACMAN_LEFT) ? DeviceOn : DeviceOff); 311 setDeviceMode( Joy1_Left, (status & PACMAN_LEFT) ? DeviceOn : DeviceOff);
299 setDeviceMode( Joy1_Right, (status & PACMAN_RIGHT) ? DeviceOn : DeviceOff); 312 setDeviceMode( Joy1_Right, (status & PACMAN_RIGHT) ? DeviceOn : DeviceOff);
300 setDeviceMode( Joy1_Up, (status & PACMAN_UP) ? DeviceOn : DeviceOff); 313 setDeviceMode( Joy1_Up, (status & PACMAN_UP) ? DeviceOn : DeviceOff);
@@ -304,6 +317,7 @@ static int gameProc( void )
304#ifdef PACMAN_2UP 317#ifdef PACMAN_2UP
305 setDeviceMode( Key_TwoPlayers, (status & PACMAN_2UP) ? DeviceOn : DeviceOff); 318 setDeviceMode( Key_TwoPlayers, (status & PACMAN_2UP) ? DeviceOn : DeviceOff);
306#endif 319#endif
320#endif
307 321
308 /* We only update the screen every third frame - Pacman's native 322 /* We only update the screen every third frame - Pacman's native
309 framerate is 60fps, so we are attempting to display 20fps */ 323 framerate is 60fps, so we are attempting to display 20fps */
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 @@
50#define PACMAN_COIN BUTTON_REC 50#define PACMAN_COIN BUTTON_REC
51#define PACMAN_MENU BUTTON_MODE 51#define PACMAN_MENU BUTTON_MODE
52 52
53#ifdef HAVE_REMOTE_LCD
54
55#define PACMAN_HAS_REMOTE
56
57#define PACMAN_RC_UP BUTTON_RC_VOL_UP
58#define PACMAN_RC_DOWN BUTTON_RC_VOL_DOWN
59#define PACMAN_RC_LEFT BUTTON_RC_REW
60#define PACMAN_RC_RIGHT BUTTON_RC_FF
61#define PACMAN_RC_1UP BUTTON_RC_SOURCE
62#define PACMAN_RC_2UP BUTTON_RC_BITRATE
63#define PACMAN_RC_COIN BUTTON_RC_REC
64#define PACMAN_RC_MENU BUTTON_RC_MODE
65
66#endif
67
53#elif CONFIG_KEYPAD == GIGABEAT_PAD 68#elif CONFIG_KEYPAD == GIGABEAT_PAD
54 69
55#define PACMAN_UP BUTTON_UP 70#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 @@
21 21
22 .section .text 22 .section .text
23 .align 2 23 .align 2
24
25
26#if defined(IRIVER_H300_SERIES) && !defined(SIMULATOR)
27
24 .global blit_display 28 .global blit_display
25 29
26/* 30/*
@@ -57,99 +61,190 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
57#define SHRUNK_WIDTH ((ScreenWidth/4)*3) 61#define SHRUNK_WIDTH ((ScreenWidth/4)*3)
58#define SHRUNK_HEIGHT ((ScreenHeight/4)*3) 62#define SHRUNK_HEIGHT ((ScreenHeight/4)*3)
59 63
64#define BD_SAVE (9 * 4)
65
66process_4_pixels:
67 move.b %d4, %d2
68 move.w (%a1, %d2.l * 2), %d3
69 move.w %d3, (2 * LCD_WIDTH * 2)(%a0)
70
71 lsr.l #8, %d4
72 move.b %d4, %d2
73 move.w (%a1, %d2.l * 2), %d3
74 move.w %d3, (1 * LCD_WIDTH * 2)(%a0)
75
76 swap.w %d4
77 move.b %d4, %d2
78 move.w (%a1, %d2.l * 2), (%a0)
79
80 lea.l 3 * LCD_WIDTH * 2(%a0), %a0
81 rts
82
83process_line:
84 move.l %a3, %d1
85bd_x_loop:
86 movem.l (%a2), %d4-%d7 // Read 16 pixels
87
88 bsr.s process_4_pixels
89 move.l %d5, %d4
90 bsr.s process_4_pixels
91 move.l %d6, %d4
92 bsr.s process_4_pixels
93 move.l %d7, %d4
94 bsr.s process_4_pixels
95
96 lea 16(%a2), %a2
97 subq.l #1, %d1;
98 bne.s bd_x_loop
99
100 rts
101
60blit_display: 102blit_display:
61 lea -28(%sp), %sp 103 lea -BD_SAVE(%sp), %sp
62 movem.l %d2-%d6/%a2, (%sp) 104 movem.l %d2-%d7/%a2-%a4, (%sp)
63 105
64 move.l 32(%sp), %a0 // lcd_framebuffer 106 move.l BD_SAVE + 4(%sp), %a0 // lcd_framebuffer
65 move.l 36(%sp), %a2 // vbuf 107 move.l BD_SAVE + 8(%sp), %a2 // vbuf
66 108
67 lea palette, %a1 109 lea palette, %a1
68 110
69 lea.l ((YOFS * LCD_WIDTH + XOFS + SHRUNK_HEIGHT) * 2)(%a0), %a0 111 lea.l ((YOFS * LCD_WIDTH + XOFS + SHRUNK_HEIGHT) * 2)(%a0), %a0
70 112
71 move.l #(ScreenHeight / 4), %d0 113 move.l #(ScreenHeight / 4), %d0
72 move.l #(ScreenWidth / 4), %d1 114 move.l #(ScreenWidth / 16), %a3
115 move.l #(LCD_WIDTH * SHRUNK_WIDTH + 1) * 2, %a4
73 moveq.l #0, %d2 116 moveq.l #0, %d2
74 117
75y_loop: 118bd_y_loop:
76 move.l %d1, %d5 119 bsr.s process_line
77x_loop1:
78 move.l (%a2)+, %d3
79 120
80 move.b %d3, %d2 121 suba.l %a4, %a0
81 move.w (%a1, %d2.l * 2), %d6 122 lea.l ScreenWidth(%a2), %a2 // Skip 1 line
82 move.w %d6, (2 * LCD_WIDTH * 2)(%a0)
83 123
84 lsr.l #8, %d3 124 bsr.s process_line
85 move.b %d3, %d2
86 move.w (%a1, %d2.l * 2), %d6
87 move.w %d6, (1 * LCD_WIDTH * 2)(%a0)
88 125
89 swap.w %d3 126 suba.l %a4, %a0
90 move.b %d3, %d2
91 move.w (%a1, %d2.l * 2), (%a0)
92 127
93 lea.l 3 * LCD_WIDTH * 2(%a0), %a0 128 bsr.s process_line
94 129
95 subq.l #1, %d5 130 suba.l %a4, %a0
96 bne.s x_loop1
97 131
98 suba.l #(LCD_WIDTH * SHRUNK_WIDTH + 1) * 2, %a0 132 subq.l #1, %d0
99 lea.l ScreenWidth(%a2), %a2 // Skip 1 line 133 bne bd_y_loop
100 134
101 move.l %d1, %d5 135 movem.l (%sp), %d2-%d7/%a2-%a4
102x_loop2: 136 lea.l BD_SAVE(%sp), %sp
103 move.l (%a2)+, %d3 137 rts
104 138
105 move.b %d3, %d2 139#endif /* defined(IRIVER_H300_SERIES) && !defined(SIMULATOR) */
106 move.w (%a1, %d2.l * 2), %d6
107 move.w %d6, 2 * LCD_WIDTH * 2(%a0)
108 140
109 lsr.l #8, %d3
110 move.b %d3, %d2
111 move.w (%a1, %d2.l * 2), %d6
112 move.w %d6, 1 * LCD_WIDTH * 2(%a0)
113 141
114 swap.w %d3 142/* See arcade.c for the C implementation of drawChar */
115 move.b %d3, %d2 143/* Note! This version does not handle flipped screen mode. */
116 move.w (%a1, %d2.l * 2), (%a0) 144
145 .global drawChar
117 146
118 lea.l 3 * LCD_WIDTH * 2(%a0), %a0 147#define DC_SAVE (4 * 4)
119 148
120 subq.l #1, %d5 149drawChar:
121 bne.s x_loop2 150 lea -DC_SAVE(%sp), %sp
151 movem.l %d2-%d5, (%sp)
122 152
123 suba.l #(LCD_WIDTH * SHRUNK_WIDTH + 1) * 2, %a0 153 movea.l DC_SAVE + 4(%sp), %a0 // buffer
124 154
125 move.l %d1, %d5 155 move.l DC_SAVE + 16(%sp), %d0 // oy
126x_loop3: 156 move.l %d0, %d1
127 move.l (%a2)+, %d3 157 lsl.l #8, %d0
158 lsl.l #5, %d1
159 sub.l %d1, %d0
160 adda.l %d0, %a0
161 adda.l DC_SAVE + 12(%sp), %a0 // ox
128 162
129 move.b %d3, %d2 163 move.l DC_SAVE + 20(%sp), %d0 // color
130 move.w (%a1, %d2.l * 2), %d6 164 and.l #0x3F, %d0
131 move.w %d6, 2 * LCD_WIDTH * 2(%a0) 165 bne.s have_color
166
167 moveq.l #8, %d1
168 moveq.l #0, %d2
169 moveq.l #0, %d3
170
171clear_loop:
172 movem.l %d2-%d3, (%a0)
173 lea 224(%a0), %a0
174
175 subq.l #1, %d1
176 bne.s clear_loop
177
178 bra.s dc_exit
179
180have_color:
181 lsl.l #2, %d0
182
183 lea.l charmap_, %a1
184 move.l DC_SAVE + 8(%sp), %d2 // index
185 lsl.l #6, %d2
186 adda.l %d2, %a1
132 187
133 lsr.l #8, %d3 188 moveq.l #8, %d1
189 moveq.l #0, %d3
190 moveq.l #24, %d5
191
192dc_y_loop:
193 move.l (%a1)+, %d3
194 move.l %d3, %d4
195
196 move.l %d3, %d2 // Pixel 1
197 lsr.l %d5, %d2
198 add.l %d0, %d2
199 lsl.l #8, %d2
200
201 swap.w %d4 // Pixel 2
202 move.b %d4, %d2
203 add.l %d0, %d2
204 lsl.l #8, %d2
205
206 lsr.l #8, %d3 // Pixel 3
134 move.b %d3, %d2 207 move.b %d3, %d2
135 move.w (%a1, %d2.l * 2), %d6 208 add.l %d0, %d2
136 move.w %d6, 1 * LCD_WIDTH * 2(%a0) 209 lsl.l #8, %d2
210
211 swap.w %d4 // Pixel 4
212 move.b %d4, %d2
213 add.l %d0, %d2
214
215 move.l %d2, (%a0)+
137 216
138 swap.w %d3 217 move.l (%a1)+, %d3
218 move.l %d3, %d4
219
220 move.l %d3, %d2 // Pixel 1
221 lsr.l %d5, %d2
222 add.l %d0, %d2
223 lsl.l #8, %d2
224
225 swap.w %d4 // Pixel 2
226 move.b %d4, %d2
227 add.l %d0, %d2
228 lsl.l #8, %d2
229
230 lsr.l #8, %d3 // Pixel 3
139 move.b %d3, %d2 231 move.b %d3, %d2
140 move.w (%a1, %d2.l * 2), (%a0) 232 add.l %d0, %d2
233 lsl.l #8, %d2
141 234
142 lea.l 3 * LCD_WIDTH * 2(%a0), %a0 235 swap.w %d4 // Pixel 4
236 move.b %d4, %d2
237 add.l %d0, %d2
143 238
144 subq.l #1, %d5 239 move.l %d2, (%a0)+
145 bne.s x_loop3
146 240
147 suba.l #(LCD_WIDTH * SHRUNK_WIDTH + 1) * 2, %a0 241 lea 216(%a0), %a0
148 242
149 subq.l #1, %d0 243 subq.l #1, %d1
150 bne y_loop 244 bne.s dc_y_loop
151 245
152 movem.l (%sp), %d2-%d6/%a2 246dc_exit:
153 lea.l 28(%sp), %sp 247 movem.l (%sp), %d2-%d5
248 lea.l DC_SAVE(%sp), %sp
154 rts 249 rts
155 250
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 @@
26#include "arcade.h" 26#include "arcade.h"
27#include "hardware.h" 27#include "hardware.h"
28 28
29#if defined(SIMULATOR) || !defined(IRIVER_H300_SERIES)
30
29void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf) 31void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
30{ 32{
31 fb_data* dst; 33 fb_data* dst;
@@ -103,3 +105,5 @@ void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
103#endif /* Size >= 144x112 */ 105#endif /* Size >= 144x112 */
104#endif /* Not Colour */ 106#endif /* Not Colour */
105} 107}
108
109#endif