summaryrefslogtreecommitdiff
path: root/apps/plugins/rockboy/sys_rockbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/rockboy/sys_rockbox.c')
-rw-r--r--apps/plugins/rockboy/sys_rockbox.c271
1 files changed, 271 insertions, 0 deletions
diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c
new file mode 100644
index 0000000000..43cd8ad29e
--- /dev/null
+++ b/apps/plugins/rockboy/sys_rockbox.c
@@ -0,0 +1,271 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 Michiel van der Kolk, Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "rockmacros.h"
21#include "fb.h"
22#include "input.h"
23#include "rc.h"
24#include "lcd.h"
25#include "hw.h"
26#include "config.h"
27
28rcvar_t joy_exports[] =
29{
30 RCV_END
31};
32
33rcvar_t vid_exports[] =
34{
35 RCV_END
36};
37
38struct fb fb;
39byte *video_base_buf;
40
41extern int debug_trace;
42
43static byte frameb[145][160];
44
45void vid_settitle(char *title)
46{
47 rb->splash(HZ*2, true, title);
48}
49
50void joy_init(void)
51{
52}
53
54void joy_close(void)
55{
56}
57
58#if CONFIG_KEYPAD == IRIVER_H100_PAD
59#define ROCKBOY_PAD_A BUTTON_ON
60#define ROCKBOY_PAD_B BUTTON_OFF
61#define ROCKBOY_PAD_START BUTTON_REC
62#define ROCKBOY_PAD_SELECT BUTTON_MODE
63#define ROCKBOY_QUIT BUTTON_SELECT
64
65#elif CONFIG_KEYPAD == RECORDER_PAD
66#define ROCKBOY_PAD_A BUTTON_F1
67#define ROCKBOY_PAD_B BUTTON_F2
68#define ROCKBOY_PAD_START BUTTON_F3
69#define ROCKBOY_PAD_SELECT BUTTON_PLAY
70#define ROCKBOY_QUIT BUTTON_OFF
71
72#endif
73
74unsigned int oldbuttonstate = 0, newbuttonstate;
75
76void ev_poll(void)
77{
78 event_t ev;
79 int released, pressed;
80 newbuttonstate = rb->button_status();
81 released = ~newbuttonstate & oldbuttonstate;
82 pressed = newbuttonstate & ~oldbuttonstate;
83 oldbuttonstate = newbuttonstate;
84
85 if(released) {
86 ev.type = EV_RELEASE;
87 if(released & BUTTON_LEFT) { ev.code=PAD_LEFT; ev_postevent(&ev); }
88 if(released & BUTTON_RIGHT) {ev.code=PAD_RIGHT; ev_postevent(&ev);}
89 if(released & BUTTON_DOWN) { ev.code=PAD_DOWN; ev_postevent(&ev); }
90 if(released & BUTTON_UP) { ev.code=PAD_UP; ev_postevent(&ev); }
91 if(released & ROCKBOY_PAD_A) { ev.code=PAD_A; ev_postevent(&ev); }
92 if(released & ROCKBOY_PAD_B) { ev.code=PAD_B; ev_postevent(&ev); }
93 if(released & ROCKBOY_PAD_START) {
94 ev.code=PAD_START;
95 ev_postevent(&ev);
96 }
97 if(released & ROCKBOY_PAD_SELECT) {
98 ev.code=PAD_SELECT;
99 ev_postevent(&ev);
100 }
101 }
102 if(pressed) { /* button press */
103 ev.type = EV_PRESS;
104 if(pressed & BUTTON_LEFT) { ev.code=PAD_LEFT; ev_postevent(&ev); }
105 if(pressed & BUTTON_RIGHT) { ev.code=PAD_RIGHT; ev_postevent(&ev);}
106 if(pressed & BUTTON_DOWN) { ev.code=PAD_DOWN; ev_postevent(&ev); }
107 if(pressed & BUTTON_UP) { ev.code=PAD_UP; ev_postevent(&ev); }
108 if(pressed & ROCKBOY_PAD_A) { ev.code=PAD_A; ev_postevent(&ev); }
109 if(pressed & ROCKBOY_PAD_B) { ev.code=PAD_B; ev_postevent(&ev); }
110 if(pressed & ROCKBOY_PAD_START) {
111 ev.code=PAD_START;
112 ev_postevent(&ev);
113 }
114 if(pressed & ROCKBOY_PAD_SELECT) {
115 ev.code=PAD_SELECT;
116 ev_postevent(&ev);
117 }
118 if(pressed & ROCKBOY_QUIT) {
119 die("");
120 cleanshut=1;
121 }
122 }
123
124}
125
126void vid_setpal(int i, int r, int g, int b)
127{
128 (void)i;
129 (void)r;
130 (void)g;
131 (void)b;
132}
133
134void vid_init(void)
135{
136}
137
138void vid_begin(void)
139{
140 fb.pelsize=1; // 8 bit framebuffer.. (too much.. but lowest gnuboy will support.. so yea...
141 fb.h=144;
142 fb.w=160;
143 fb.pitch=160;
144 fb.enabled=1;
145 fb.dirty=0;
146 video_base_buf=fb.ptr=(byte *)frameb;
147}
148
149void vid_update(int scanline)
150{
151 int cnt=0,scanline_remapped;
152 byte *frameb;
153#if LCD_HEIGHT == 64 /* Archos */
154 int balance = 0;
155 if (scanline >= 128)
156 return;
157 scanline_remapped = scanline / 16;
158 frameb = rb->lcd_framebuffer + scanline_remapped * LCD_WIDTH;
159 while (cnt < 160) {
160 balance += LCD_WIDTH;
161 if (balance > 0)
162 {
163#ifdef SIMULATOR /* simulator uses C */
164 register unsigned scrbyte = 0;
165 if (scan.buf[0][cnt] & 0x02) scrbyte |= 0x01;
166 if (scan.buf[1][cnt] & 0x02) scrbyte |= 0x02;
167 if (scan.buf[2][cnt] & 0x02) scrbyte |= 0x04;
168 if (scan.buf[3][cnt] & 0x02) scrbyte |= 0x08;
169 if (scan.buf[4][cnt] & 0x02) scrbyte |= 0x10;
170 if (scan.buf[5][cnt] & 0x02) scrbyte |= 0x20;
171 if (scan.buf[6][cnt] & 0x02) scrbyte |= 0x40;
172 if (scan.buf[7][cnt] & 0x02) scrbyte |= 0x80;
173 *(frameb++) = scrbyte;
174#else
175 asm volatile (
176 "mov.b @%0,r0 \n"
177 "add %1,%0 \n"
178 "tst #0x02, r0 \n" /* ~bit 1 */
179 "rotcr r1 \n"
180 "mov.b @%0,r0 \n"
181 "add %1,%0 \n"
182 "tst #0x02, r0 \n" /* ~bit 1 */
183 "rotcr r1 \n"
184 "mov.b @%0,r0 \n"
185 "add %1,%0 \n"
186 "tst #0x02, r0 \n" /* ~bit 1 */
187 "rotcr r1 \n"
188 "mov.b @%0,r0 \n"
189 "add %1,%0 \n"
190 "tst #0x02, r0 \n" /* ~bit 1 */
191 "rotcr r1 \n"
192 "mov.b @%0,r0 \n"
193 "add %1,%0 \n"
194 "tst #0x02, r0 \n" /* ~bit 1 */
195 "rotcr r1 \n"
196 "mov.b @%0,r0 \n"
197 "add %1,%0 \n"
198 "tst #0x02, r0 \n" /* ~bit 1 */
199 "rotcr r1 \n"
200 "mov.b @%0,r0 \n"
201 "add %1,%0 \n"
202 "tst #0x02, r0 \n" /* ~bit 1 */
203 "rotcr r1 \n"
204 "mov.b @%0,r0 \n"
205 "add %1,%0 \n"
206 "tst #0x02, r0 \n" /* ~bit 1 */
207 "rotcr r1 \n"
208
209 "shlr16 r1 \n"
210 "shlr8 r1 \n"
211 "not r1,r1 \n" /* account for negated bits */
212 "mov.b r1,@%2 \n"
213 : /* outputs */
214 : /* inputs */
215 /* %0 */ "r"(scan.buf[0] + cnt),
216 /* %1 */ "r"(256), /* scan.buf line length */
217 /* %2 */ "r"(frameb++)
218 : /* clobbers */
219 "r0", "r1"
220 );
221#endif
222 balance -= 160;
223 }
224 cnt ++;
225 }
226 rb->lcd_update_rect(0, (scanline/2) & ~7, LCD_WIDTH, 8);
227#else /* LCD_HEIGHT != 64, iRiver */
228 if (scanline >= 128)
229 return;
230 scanline_remapped = scanline / 8;
231 frameb = rb->lcd_framebuffer + scanline_remapped * LCD_WIDTH;
232 while (cnt < 160) {
233 register unsigned scrbyte = 0;
234 if (scan.buf[0][cnt] & 0x02) scrbyte |= 0x01;
235 if (scan.buf[1][cnt] & 0x02) scrbyte |= 0x02;
236 if (scan.buf[2][cnt] & 0x02) scrbyte |= 0x04;
237 if (scan.buf[3][cnt] & 0x02) scrbyte |= 0x08;
238 if (scan.buf[4][cnt] & 0x02) scrbyte |= 0x10;
239 if (scan.buf[5][cnt] & 0x02) scrbyte |= 0x20;
240 if (scan.buf[6][cnt] & 0x02) scrbyte |= 0x40;
241 if (scan.buf[7][cnt] & 0x02) scrbyte |= 0x80;
242 *(frameb++) = scrbyte;
243 cnt++;
244 }
245 rb->lcd_update_rect(0, scanline & ~7, LCD_WIDTH, 8);
246#endif
247}
248
249void vid_end(void)
250{
251}
252
253long timerresult;
254
255void *sys_timer(void)
256{
257 timerresult=*rb->current_tick;
258 return &timerresult;
259}
260
261// returns microseconds passed since sys_timer
262int sys_elapsed(long *oldtick)
263{
264 return ((*rb->current_tick-(*oldtick))*1000000)/HZ;
265}
266
267void sys_sleep(int us)
268{
269 if (us <= 0) return;
270// rb->sleep(HZ*us/1000000);
271}