summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2006-01-10 21:55:56 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2006-01-10 21:55:56 +0000
commitcf218e33eca3abcc1067b9e78f1c82510bfe7c69 (patch)
tree5f60203774b1080ddfb62092681005d163d4cbb9 /apps/plugins
parent640eeabfe113695a22bf60ba327210a5526b187d (diff)
downloadrockbox-cf218e33eca3abcc1067b9e78f1c82510bfe7c69.tar.gz
rockbox-cf218e33eca3abcc1067b9e78f1c82510bfe7c69.zip
Patch #1401999 by Karl Kurbjun - Rockboy color, sound support, and speedups
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8324 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/rockboy/emu.c2
-rw-r--r--apps/plugins/rockboy/lcd-gb.h2
-rw-r--r--apps/plugins/rockboy/lcd.c34
-rw-r--r--apps/plugins/rockboy/loader.c4
-rw-r--r--apps/plugins/rockboy/menu.c74
-rw-r--r--apps/plugins/rockboy/pcm.h2
-rw-r--r--apps/plugins/rockboy/rbsound.c102
-rw-r--r--apps/plugins/rockboy/rockboy.c2
-rw-r--r--apps/plugins/rockboy/rockmacros.h3
-rw-r--r--apps/plugins/rockboy/sound.c11
-rw-r--r--apps/plugins/rockboy/sys_rockbox.c59
11 files changed, 194 insertions, 101 deletions
diff --git a/apps/plugins/rockboy/emu.c b/apps/plugins/rockboy/emu.c
index 57385f8e5f..cf37d9b2b8 100644
--- a/apps/plugins/rockboy/emu.c
+++ b/apps/plugins/rockboy/emu.c
@@ -73,7 +73,7 @@ void emu_run(void)
73#if !defined(SIMULATOR) && defined(HAVE_ADJUSTABLE_CPU_FREQ) 73#if !defined(SIMULATOR) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
74 rb->cpu_boost(true); 74 rb->cpu_boost(true);
75#endif 75#endif
76 while(shut==0) 76 while(!shut)
77 { 77 {
78 cpu_emulate(2280); 78 cpu_emulate(2280);
79 while (R_LY > 0 && R_LY < 144) 79 while (R_LY > 0 && R_LY < 144)
diff --git a/apps/plugins/rockboy/lcd-gb.h b/apps/plugins/rockboy/lcd-gb.h
index 14d7ee49e0..9f1b890c17 100644
--- a/apps/plugins/rockboy/lcd-gb.h
+++ b/apps/plugins/rockboy/lcd-gb.h
@@ -21,7 +21,7 @@ struct scan
21#elif LCD_DEPTH == 2 21#elif LCD_DEPTH == 2
22 byte buf[4][256]; 22 byte buf[4][256];
23#elif LCD_DEPTH > 4 23#elif LCD_DEPTH > 4
24 byte buf[1][256]; 24 byte buf[256];
25#endif 25#endif
26 byte pal1[128]; 26 byte pal1[128];
27 un16 pal2[64]; 27 un16 pal2[64];
diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c
index 883c4952fc..4cd4ddc04c 100644
--- a/apps/plugins/rockboy/lcd.c
+++ b/apps/plugins/rockboy/lcd.c
@@ -19,7 +19,13 @@ struct scan scan IBSS_ATTR;
19 19
20#define BG (scan.bg) 20#define BG (scan.bg)
21#define WND (scan.wnd) 21#define WND (scan.wnd)
22
23#if LCD_DEPTH ==16
24#define BUF (scan.buf)
25#else
22#define BUF (scan.buf[scanline_ind]) 26#define BUF (scan.buf[scanline_ind])
27#endif
28
23#define PRI (scan.pri) 29#define PRI (scan.pri)
24 30
25#define PAL1 (scan.pal1) 31#define PAL1 (scan.pal1)
@@ -55,7 +61,10 @@ static int rgb332;
55 61
56static int sprsort = 1; 62static int sprsort = 1;
57static int sprdebug; 63static int sprdebug;
58static int scanline_ind=0,insync=0; 64static int insync=0;
65#if LCD_DEPTH < 16
66static int scanline_ind=0;
67#endif
59 68
60#define DEF_PAL { 0x98d0e0, 0x68a0b0, 0x60707C, 0x2C3C3C } 69#define DEF_PAL { 0x98d0e0, 0x68a0b0, 0x60707C, 0x2C3C3C }
61 70
@@ -930,7 +939,7 @@ void lcd_refreshline(void)
930 939
931 940
932 941
933/* 942#if HAVE_LCD_COLOR
934static void updatepalette(int i) 943static void updatepalette(int i)
935{ 944{
936 int c, r, g, b, y, u, v, rr, gg; 945 int c, r, g, b, y, u, v, rr, gg;
@@ -964,7 +973,7 @@ static void updatepalette(int i)
964 | (u<<fb.cc[1].l) | (v<<fb.cc[2].l); 973 | (u<<fb.cc[1].l) | (v<<fb.cc[2].l);
965 return; 974 return;
966 } 975 }
967 976/*
968 if (fb.indexed) 977 if (fb.indexed)
969 { 978 {
970 pal_release(PAL1[i]); 979 pal_release(PAL1[i]);
@@ -973,7 +982,7 @@ static void updatepalette(int i)
973 PAL2[i] = (c<<8) | c; 982 PAL2[i] = (c<<8) | c;
974 PAL4[i] = (c<<24) | (c<<16) | (c<<8) | c; 983 PAL4[i] = (c<<24) | (c<<16) | (c<<8) | c;
975 return; 984 return;
976 } 985 }*/
977 986
978 r = (r >> fb.cc[0].r) << fb.cc[0].l; 987 r = (r >> fb.cc[0].r) << fb.cc[0].l;
979 g = (g >> fb.cc[1].r) << fb.cc[1].l; 988 g = (g >> fb.cc[1].r) << fb.cc[1].l;
@@ -996,13 +1005,16 @@ static void updatepalette(int i)
996 PAL4[i] = c; 1005 PAL4[i] = c;
997 break; 1006 break;
998 } 1007 }
999}*/ 1008}
1009#endif
1000 1010
1001void pal_write(int i, byte b) 1011void pal_write(int i, byte b)
1002{ 1012{
1003 if (lcd.pal[i] == b) return; 1013 if (lcd.pal[i] == b) return;
1004 lcd.pal[i] = b; 1014 lcd.pal[i] = b;
1005// updatepalette(i>>1); 1015#if LCD_DEPTH ==16
1016 updatepalette(i>>1);
1017#endif
1006} 1018}
1007 1019
1008void pal_write_dmg(int i, int mapnum, byte d) 1020void pal_write_dmg(int i, int mapnum, byte d)
@@ -1043,7 +1055,9 @@ void vram_dirty(void)
1043 1055
1044void pal_dirty(void) 1056void pal_dirty(void)
1045{ 1057{
1046// int i; 1058#if LCD_DEPTH ==16
1059 int i;
1060#endif
1047 if (!hw.cgb) 1061 if (!hw.cgb)
1048 { 1062 {
1049 1063
@@ -1052,8 +1066,10 @@ void pal_dirty(void)
1052 pal_write_dmg(64, 2, R_OBP0); 1066 pal_write_dmg(64, 2, R_OBP0);
1053 pal_write_dmg(72, 3, R_OBP1); 1067 pal_write_dmg(72, 3, R_OBP1);
1054 } 1068 }
1055// for (i = 0; i < 64; i++) 1069#if LCD_DEPTH ==16
1056// updatepalette(i); 1070 for (i = 0; i < 64; i++)
1071 updatepalette(i);
1072#endif
1057} 1073}
1058 1074
1059void lcd_reset(void) 1075void lcd_reset(void)
diff --git a/apps/plugins/rockboy/loader.c b/apps/plugins/rockboy/loader.c
index 53839d6150..0a8eaba13f 100644
--- a/apps/plugins/rockboy/loader.c
+++ b/apps/plugins/rockboy/loader.c
@@ -86,7 +86,7 @@ static char *savedir = "/.rockbox/rockboy";
86static int saveslot; 86static int saveslot;
87 87
88static int forcebatt, nobatt; 88static int forcebatt, nobatt;
89static int forcedmg; 89static int forcedmg, gbamode;
90 90
91static int memfill = -1, memrand = -1; 91static int memfill = -1, memrand = -1;
92 92
@@ -181,7 +181,7 @@ int rom_load(void)
181 181
182 c = header[0x0143]; 182 c = header[0x0143];
183 hw.cgb = ((c == 0x80) || (c == 0xc0)) && !forcedmg; 183 hw.cgb = ((c == 0x80) || (c == 0xc0)) && !forcedmg;
184 hw.gba = 0; //(hw.cgb && gbamode); 184 hw.gba = (hw.cgb && gbamode);
185 185
186 close(fd); 186 close(fd);
187 187
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c
index 50f86c3408..140e7a28b1 100644
--- a/apps/plugins/rockboy/menu.c
+++ b/apps/plugins/rockboy/menu.c
@@ -67,11 +67,33 @@ static const char *slot_menu[] = {
67 67
68#define OPT_MENU_TITLE "Options" 68#define OPT_MENU_TITLE "Options"
69typedef enum { 69typedef enum {
70 OM_ITEM_FS,
71 OM_ITEM_SOUND,
70 OM_ITEM_BACK, 72 OM_ITEM_BACK,
71 OM_MENU_LAST 73 OM_MENU_LAST
72} OptMenuItem; 74} OptMenuItem;
73 75
74static const char *opt_menu[] = { 76static const char *opt_menu[] = {
77 "Frameskip",
78 "Sound ON/OFF",
79 "Previous Menu..."
80};
81
82#define FS_MENU_TITLE "Frameskip"
83typedef enum {
84 FS_ITEM_FS0,
85 FS_ITEM_FS1,
86 FS_ITEM_FS2,
87 FS_ITEM_FS3,
88 FS_ITEM_BACK,
89 FS_MENU_LAST
90} FSMenuItem;
91
92static const char *fs_menu[] = {
93 "Skip 0 Frames",
94 "Skip 1 Frames",
95 "Skip 2 Frames",
96 "Skip 3 Frames",
75 "Previous Menu..." 97 "Previous Menu..."
76}; 98};
77 99
@@ -90,6 +112,8 @@ int do_user_menu(void) {
90 int mi, ret, num_items; 112 int mi, ret, num_items;
91 bool done = false; 113 bool done = false;
92 114
115 pcm_init();
116
93 /* set defaults */ 117 /* set defaults */
94 ret = 0; /* return value */ 118 ret = 0; /* return value */
95 mi = 0; /* initial menu selection */ 119 mi = 0; /* initial menu selection */
@@ -119,7 +143,7 @@ int do_user_menu(void) {
119 break; 143 break;
120 } 144 }
121 } 145 }
122 146 rb->lcd_clear_display();
123 /* return somethin' */ 147 /* return somethin' */
124 return ret; 148 return ret;
125} 149}
@@ -314,6 +338,42 @@ static void do_slot_menu(bool is_load) {
314 } 338 }
315} 339}
316 340
341static void do_fs_menu(void) {
342 int mi, ret, num_items;
343 bool done = false;
344
345 /* set defaults */
346 ret = 0; /* return value */
347 mi = 0; /* initial menu selection */
348 num_items = sizeof(fs_menu) / sizeof(char*);
349
350 /* loop until we should exit menu */
351 while (!done) {
352 /* get item selection */
353 mi = do_menu(FS_MENU_TITLE, (char**) fs_menu, num_items, mi);
354
355 /* handle selected menu item */
356 switch (mi) {
357 case MENU_CANCEL:
358 case FS_ITEM_BACK:
359 done = true;
360 break;
361 case FS_ITEM_FS0:
362 frameskip=0;
363 break;
364 case FS_ITEM_FS1:
365 frameskip=1;
366 break;
367 case FS_ITEM_FS2:
368 frameskip=2;
369 break;
370 case FS_ITEM_FS3:
371 frameskip=3;
372 break;
373 }
374 }
375}
376
317static void do_opt_menu(void) { 377static void do_opt_menu(void) {
318 int mi, num_items; 378 int mi, num_items;
319 bool done = false; 379 bool done = false;
@@ -324,8 +384,18 @@ static void do_opt_menu(void) {
324 384
325 while (!done) { 385 while (!done) {
326 mi = do_menu(OPT_MENU_TITLE, (char**) opt_menu, num_items, mi); 386 mi = do_menu(OPT_MENU_TITLE, (char**) opt_menu, num_items, mi);
327 if (mi == MENU_CANCEL || mi == OM_ITEM_BACK) 387 switch (mi) {
388 case OM_ITEM_FS:
389 do_fs_menu();
390 break;
391 case OM_ITEM_SOUND:
392 sound=!sound;
393 break;
394 case MENU_CANCEL:
395 case OM_ITEM_BACK:
328 done = true; 396 done = true;
397 break;
398 }
329 } 399 }
330} 400}
331 401
diff --git a/apps/plugins/rockboy/pcm.h b/apps/plugins/rockboy/pcm.h
index 742f0e5a95..3719933520 100644
--- a/apps/plugins/rockboy/pcm.h
+++ b/apps/plugins/rockboy/pcm.h
@@ -9,7 +9,7 @@ struct pcm
9{ 9{
10 int hz, len; 10 int hz, len;
11 int stereo; 11 int stereo;
12 short *buf; 12 byte *buf;
13 int pos; 13 int pos;
14}; 14};
15 15
diff --git a/apps/plugins/rockboy/rbsound.c b/apps/plugins/rockboy/rbsound.c
index 139c33d037..b68a053f77 100644
--- a/apps/plugins/rockboy/rbsound.c
+++ b/apps/plugins/rockboy/rbsound.c
@@ -5,117 +5,89 @@
5 5
6struct pcm pcm; 6struct pcm pcm;
7 7
8#define BUF_SIZE (8192) 8bool sound = 1;
9#define DMA_PORTION (1024) 9#define N_BUFS 4
10 10#define BUF_SIZE 1024
11static short buf1_unal[(BUF_SIZE / sizeof(short)) + 2]; // to make sure 4 byte aligned
12 11
13rcvar_t pcm_exports[] = 12rcvar_t pcm_exports[] =
14{ 13{
15 RCV_END 14 RCV_END
16}; 15};
17 16
18/*#if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR) 17#if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR)
19 * disabled cause it crashes with current audio implementation.. no sound.
20 */
21#if 0
22static short* buf1;
23 18
24static short front_buf[512]; 19static int curbuf,gmcurbuf;
25 20
26static short* last_back_pos; 21static byte *buf=0;
22static short *gmbuf;
27 23
28static bool newly_started; 24static bool newly_started;
29static int turns;
30 25
31void pcm_init(void) 26void pcm_init(void)
32{ 27{
33 buf1 = (signed short*)((((unsigned int)buf1_unal) >> 2) << 2); /* here i just make sure that buffer is aligned to 4 bytes*/ 28 if(!sound) return;
29
34 newly_started = true; 30 newly_started = true;
35 last_back_pos = buf1;
36 turns = 0;
37 31
38 pcm.hz = 11025; 32 pcm.hz = 11025;
39 pcm.stereo = 1; 33 pcm.stereo = 1;
40 pcm.buf = front_buf;
41 pcm.len = (sizeof(front_buf)) / sizeof(short); /* length in shorts, not bytes */
42 pcm.pos = 0;
43 34
35 pcm.len = BUF_SIZE;
36 if(!buf){
37 buf = my_malloc(pcm.len * N_BUFS);
38 gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short));
39 pcm.buf = buf;
40 pcm.pos = 0;
41 curbuf = gmcurbuf= 0;
42 }
44 43
45 rb->pcm_play_stop(); 44 rb->pcm_play_stop();
46 rb->pcm_set_frequency(11025); 45 rb->pcm_set_frequency(11025); // 44100 22050 11025
47 rb->pcm_set_volume(200);
48} 46}
49 47
50void pcm_close(void) 48void pcm_close(void)
51{ 49{
52 memset(&pcm, 0, sizeof pcm); 50 memset(&pcm, 0, sizeof pcm);
53 newly_started = true; 51 newly_started = true;
54 last_back_pos = buf1;
55 rb->pcm_play_stop(); 52 rb->pcm_play_stop();
53 rb->pcm_set_frequency(44100);
56} 54}
57 55
58void get_more(unsigned char** start, long* size) 56void get_more(unsigned char** start, long* size)
59{ 57{
60 int length; 58 *start = (unsigned char*)(&gmbuf[pcm.len*curbuf]);
61 unsigned int sar = (unsigned int)SAR0; 59 *size = BUF_SIZE*sizeof(short);
62 length = ((unsigned int)buf1) + BUF_SIZE - sar;
63
64 if(turns > 0)
65 {
66 newly_started = true;
67 last_back_pos = buf1;
68 turns = 0;
69 return;
70 } /* sound will stop if no one feeds data*/
71
72 if(length <= 0)
73 {
74 *start = (unsigned char*)buf1;
75 *size = DMA_PORTION;
76 turns++;
77 }
78 else
79 {
80 *start = (unsigned char*)sar;
81 if(length > DMA_PORTION)
82 *size = DMA_PORTION;
83 else
84 *size = length;
85 }
86
87} 60}
88 61
89int pcm_submit(void) 62int pcm_submit(void)
90{ 63{
91 while( (turns < 0) && ((((unsigned int)last_back_pos) + pcm.pos * sizeof(short)) > ((unsigned int)SAR0)) && !newly_started) rb->yield(); /* wait until data is passed through DAC or until exit*/ 64 register int i;
92 int shorts_left = ((((unsigned int)buf1) + BUF_SIZE) - ((unsigned int)last_back_pos)) / sizeof(short); 65
93 if( shorts_left >= pcm.pos ) 66 if (!sound) {
94 { 67 pcm.pos = 0;
95 memcpy(last_back_pos,pcm.buf,pcm.pos * sizeof(short)); 68 return 0;
96 last_back_pos = &last_back_pos[pcm.pos];
97 } 69 }
98 else 70
99 { 71 if (pcm.pos >= pcm.len) {
100 int last_pos = shorts_left; 72 curbuf = (curbuf + 1) % N_BUFS;
101 memcpy(last_back_pos,pcm.buf,shorts_left * sizeof(short)); 73 pcm.buf = buf + pcm.len * curbuf;
102 last_back_pos = buf1; 74 pcm.pos = 0;
103 shorts_left = pcm.pos - shorts_left; 75
104 memcpy(last_back_pos,&pcm.buf[last_pos],shorts_left * sizeof(short)); 76 // gotta convert the 8 bit buffer to 16
105 last_back_pos = &buf1[shorts_left]; 77 for(i=0; i<pcm.len;i++)
106 turns--; 78 gmbuf[i+pcm.len*curbuf] = (pcm.buf[i]<<8)-0x8000;
107 } 79 }
108 80
109 if(newly_started) 81 if(newly_started)
110 { 82 {
111 rb->pcm_play_data((unsigned char*)buf1,pcm.pos * sizeof(short),&get_more); 83 rb->pcm_play_data(&get_more);
112 newly_started = false; 84 newly_started = false;
113 } 85 }
114 86
115 pcm.pos = 0;
116 return 1; 87 return 1;
117} 88}
118#else 89#else
90static byte buf1_unal[(BUF_SIZE / sizeof(short)) + 2]; // to make sure 4 byte aligned
119void pcm_init(void) 91void pcm_init(void)
120{ 92{
121 pcm.hz = 11025; 93 pcm.hz = 11025;
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index 56773879fa..fc004e752d 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -102,6 +102,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
102 otherwise you will get lovely "I04: IllInstr" errors... :-) */ 102 otherwise you will get lovely "I04: IllInstr" errors... :-) */
103 rb = api; 103 rb = api;
104 104
105 rb->lcd_setfont(0);
106
105 if (!parameter) { 107 if (!parameter) {
106 rb->splash(HZ*3, true, "Play gameboy ROM file! (.gb/.gbc)"); 108 rb->splash(HZ*3, true, "Play gameboy ROM file! (.gb/.gbc)");
107 return PLUGIN_OK; 109 return PLUGIN_OK;
diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h
index 9e902e7dca..c68223d478 100644
--- a/apps/plugins/rockboy/rockmacros.h
+++ b/apps/plugins/rockboy/rockmacros.h
@@ -92,3 +92,6 @@ void savestate(int fd);
92 92
93/* Using #define isn't enough with GCC 4.0.1 */ 93/* Using #define isn't enough with GCC 4.0.1 */
94void* memcpy(void* dst, const void* src, size_t size); 94void* memcpy(void* dst, const void* src, size_t size);
95
96extern int frameskip;
97extern bool sound;
diff --git a/apps/plugins/rockboy/sound.c b/apps/plugins/rockboy/sound.c
index accfda2540..58cbe542f9 100644
--- a/apps/plugins/rockboy/sound.c
+++ b/apps/plugins/rockboy/sound.c
@@ -158,9 +158,10 @@ void sound_reset(void)
158 sound_off(); 158 sound_off();
159} 159}
160 160
161
162void sound_mix(void) 161void sound_mix(void)
163{ 162{
163
164 if (!sound) return;
164 int s, l, r, f, n; 165 int s, l, r, f, n;
165 166
166 if (!RATE || cpu.snd < RATE) return; 167 if (!RATE || cpu.snd < RATE) return;
@@ -275,10 +276,10 @@ void sound_mix(void)
275 pcm_submit(); 276 pcm_submit();
276 if (pcm.stereo) 277 if (pcm.stereo)
277 { 278 {
278 pcm.buf[pcm.pos++] = (signed short)(l * 256); 279 pcm.buf[pcm.pos++] = l+128;
279 pcm.buf[pcm.pos++] = (signed short)(r * 256); 280 pcm.buf[pcm.pos++] = r+128;
280 } 281 }
281 else pcm.buf[pcm.pos++] = (signed short)((r+l) * 128); 282 else pcm.buf[pcm.pos++] = ((l+r)>>1)+128;
282 } 283 }
283 } 284 }
284 R_NR52 = (R_NR52&0xf0) | S1.on | (S2.on<<1) | (S3.on<<2) | (S4.on<<3); 285 R_NR52 = (R_NR52&0xf0) | S1.on | (S2.on<<1) | (S3.on<<2) | (S4.on<<3);
@@ -288,6 +289,7 @@ void sound_mix(void)
288 289
289byte sound_read(byte r) 290byte sound_read(byte r)
290{ 291{
292 if(!sound) return 0;
291 sound_mix(); 293 sound_mix();
292 /* printf("read %02X: %02X\n", r, REG(r)); */ 294 /* printf("read %02X: %02X\n", r, REG(r)); */
293 return REG(r); 295 return REG(r);
@@ -344,6 +346,7 @@ void s4_init(void)
344 346
345void sound_write(byte r, byte b) 347void sound_write(byte r, byte b)
346{ 348{
349 if(!sound) return;
347#if 0 350#if 0
348 static void *timer; 351 static void *timer;
349 if (!timer) timer = sys_timer(); 352 if (!timer) timer = sys_timer();
diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c
index b6408d53dc..b8bb65e6fc 100644
--- a/apps/plugins/rockboy/sys_rockbox.c
+++ b/apps/plugins/rockboy/sys_rockbox.c
@@ -25,6 +25,8 @@
25#include "hw.h" 25#include "hw.h"
26#include "config.h" 26#include "config.h"
27 27
28int frameskip;
29
28rcvar_t joy_exports[] = 30rcvar_t joy_exports[] =
29{ 31{
30 RCV_END 32 RCV_END
@@ -52,14 +54,20 @@ void joy_close(void)
52{ 54{
53} 55}
54 56
55#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ 57#if (CONFIG_KEYPAD == IRIVER_H100_PAD)
56 (CONFIG_KEYPAD == IRIVER_H300_PAD)
57#define ROCKBOY_PAD_A BUTTON_ON 58#define ROCKBOY_PAD_A BUTTON_ON
58#define ROCKBOY_PAD_B BUTTON_OFF 59#define ROCKBOY_PAD_B BUTTON_OFF
59#define ROCKBOY_PAD_START BUTTON_REC 60#define ROCKBOY_PAD_START BUTTON_REC
60#define ROCKBOY_PAD_SELECT BUTTON_SELECT 61#define ROCKBOY_PAD_SELECT BUTTON_SELECT
61#define ROCKBOY_MENU BUTTON_MODE 62#define ROCKBOY_MENU BUTTON_MODE
62 63
64#elif (CONFIG_KEYPAD == IRIVER_H300_PAD)
65#define ROCKBOY_PAD_A BUTTON_REC
66#define ROCKBOY_PAD_B BUTTON_MODE
67#define ROCKBOY_PAD_START BUTTON_ON
68#define ROCKBOY_PAD_SELECT BUTTON_SELECT
69#define ROCKBOY_MENU BUTTON_OFF
70
63#elif CONFIG_KEYPAD == RECORDER_PAD 71#elif CONFIG_KEYPAD == RECORDER_PAD
64#define ROCKBOY_PAD_A BUTTON_F1 72#define ROCKBOY_PAD_A BUTTON_F1
65#define ROCKBOY_PAD_B BUTTON_F2 73#define ROCKBOY_PAD_B BUTTON_F2
@@ -71,10 +79,11 @@ void joy_close(void)
71 79
72unsigned int oldbuttonstate = 0, newbuttonstate,holdbutton; 80unsigned int oldbuttonstate = 0, newbuttonstate,holdbutton;
73 81
82int released, pressed;
83
74void ev_poll(void) 84void ev_poll(void)
75{ 85{
76 event_t ev; 86 event_t ev;
77 int released, pressed;
78 newbuttonstate = rb->button_status(); 87 newbuttonstate = rb->button_status();
79 released = ~newbuttonstate & oldbuttonstate; 88 released = ~newbuttonstate & oldbuttonstate;
80 pressed = newbuttonstate & ~oldbuttonstate; 89 pressed = newbuttonstate & ~oldbuttonstate;
@@ -141,31 +150,49 @@ void vid_setpal(int i, int r, int g, int b)
141 (void)b; 150 (void)b;
142} 151}
143 152
144void vid_begin(void) 153void vid_begin(void) // This frameskip code is borrowed from the GNUboyCE project
145{ 154{
155 static int skip = 0;
156 skip = (skip + 1) % (frameskip > 0 ? frameskip + 1 : 1);
157 fb.enabled = skip == 0;
146} 158}
147 159
148void vid_init(void) 160void vid_init(void)
149{ 161{
150 fb.pelsize=1; // 8 bit framebuffer.. (too much.. but lowest gnuboy will support.. so yea...
151 fb.h=144; 162 fb.h=144;
152 fb.w=160; 163 fb.w=160;
153 fb.pitch=160; 164 fb.pitch=160;
154 fb.enabled=1; 165 fb.enabled=1;
155 fb.dirty=0; 166 fb.dirty=0;
156 fb.mode=3; 167 fb.mode=3;
157}
158 168
159#ifdef HAVE_LCD_COLOR 169 frameskip=2;
160static const fb_data my_pal[4] = { 170
161 LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY, LCD_BLACK 171#if defined(HAVE_LCD_COLOR)
162}; 172 fb.pelsize=2; // 16 bit framebuffer
173
174 fb.indexed = 0; // no palette on lcd
175 fb.cc[0].r = 3; // 8-5 (wasted bits on red)
176 fb.cc[0].l = 11; //this is the offset to the R bits (16-5)
177 fb.cc[1].r = 2; // 8-6 (wasted bits on green)
178 fb.cc[1].l = 5; // This is the offset to the G bits (16-5-6)
179 fb.cc[2].r = 3; // 8-5 (wasted bits on red)
180 fb.cc[2].l = 0; // This is the offset to the B bits (16-5-6-5)
181 fb.cc[3].r = 0; // no alpha
182 fb.cc[3].l = 0;
183 fb.yuv = 0; // not in yuv format
184#else // ***** NEED TO LOOK INTO THIS MORE FOR THE H100 (Should be able to get rid of some IFDEF's elsewhere)
185 fb.pelsize=1; // 8 bit framebuffer.. (too much.. but lowest gnuboy will support.. so yea...
163#endif 186#endif
187}
164 188
189fb_data *frameb;
165void vid_update(int scanline) 190void vid_update(int scanline)
166{ 191{
167 int cnt=0,scanline_remapped; 192 register int cnt=0;
168 fb_data *frameb; 193#if LCD_HEIGHT < 144
194 int scanline_remapped;
195#endif
169#if (LCD_HEIGHT == 64) && (LCD_DEPTH == 1) /* Archos */ 196#if (LCD_HEIGHT == 64) && (LCD_DEPTH == 1) /* Archos */
170 int balance = 0; 197 int balance = 0;
171 if (fb.mode==1) 198 if (fb.mode==1)
@@ -258,11 +285,11 @@ void vid_update(int scanline)
258 } 285 }
259 rb->lcd_update_rect(0, scanline & ~3, LCD_WIDTH, 4); 286 rb->lcd_update_rect(0, scanline & ~3, LCD_WIDTH, 4);
260#elif (LCD_HEIGHT >= 144) && defined(HAVE_LCD_COLOR) /* iriver H3x0, colour iPod */ 287#elif (LCD_HEIGHT >= 144) && defined(HAVE_LCD_COLOR) /* iriver H3x0, colour iPod */
261 scanline_remapped = scanline + (LCD_HEIGHT-144)/2; 288 frameb = rb->lcd_framebuffer + (scanline + (LCD_HEIGHT-144)/2) * LCD_WIDTH + (LCD_WIDTH-160)/2;;
262 frameb = rb->lcd_framebuffer + scanline_remapped * LCD_WIDTH + (LCD_WIDTH-160)/2;
263 while (cnt < 160) 289 while (cnt < 160)
264 *frameb++ = my_pal[scan.buf[0][cnt++]&0x3]; 290 *frameb++ = scan.pal2[scan.buf[cnt++]];
265 rb->lcd_update_rect((LCD_WIDTH-160)/2, scanline_remapped, 160, 1); 291 if(scanline==143)
292 rb->lcd_update(); // this seems faster then doing individual scanlines
266#endif /* LCD_HEIGHT */ 293#endif /* LCD_HEIGHT */
267} 294}
268 295