summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorTom Ross <midgey@rockbox.org>2007-10-16 18:16:22 +0000
committerTom Ross <midgey@rockbox.org>2007-10-16 18:16:22 +0000
commit437c3e40ca7579acc20b648319447045649b0873 (patch)
tree5504a232c510dff3f3872d8c7dee388fcbfafeb5 /apps/plugins
parent0b911fefea7615105244098da1baf4655fa1e721 (diff)
downloadrockbox-437c3e40ca7579acc20b648319447045649b0873.tar.gz
rockbox-437c3e40ca7579acc20b648319447045649b0873.zip
Code police and clean up for rockboy.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15144 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/rockboy/Makefile2
-rw-r--r--apps/plugins/rockboy/cpu-gb.h12
-rw-r--r--apps/plugins/rockboy/cpu.c62
-rw-r--r--apps/plugins/rockboy/emu.c3
-rw-r--r--apps/plugins/rockboy/fb.h6
-rw-r--r--apps/plugins/rockboy/hw.c18
-rw-r--r--apps/plugins/rockboy/hw.h2
-rw-r--r--apps/plugins/rockboy/lcd-gb.h11
-rw-r--r--apps/plugins/rockboy/lcd.c95
-rw-r--r--apps/plugins/rockboy/lcdc.c3
-rw-r--r--apps/plugins/rockboy/loader.c71
-rw-r--r--apps/plugins/rockboy/loader.h17
-rw-r--r--apps/plugins/rockboy/main.c41
-rw-r--r--apps/plugins/rockboy/mem.c10
-rw-r--r--apps/plugins/rockboy/mem.h2
-rw-r--r--apps/plugins/rockboy/menu.c15
-rw-r--r--apps/plugins/rockboy/palette-presets.h2
-rw-r--r--apps/plugins/rockboy/pcm.h3
-rw-r--r--apps/plugins/rockboy/rbsound.c2
-rw-r--r--apps/plugins/rockboy/rockboy.c54
-rw-r--r--apps/plugins/rockboy/rockmacros.h11
-rw-r--r--apps/plugins/rockboy/rtc.c2
-rw-r--r--apps/plugins/rockboy/save.c19
-rw-r--r--apps/plugins/rockboy/save.h2
-rw-r--r--apps/plugins/rockboy/sound.c6
-rw-r--r--apps/plugins/rockboy/sys_rockbox.c5
26 files changed, 167 insertions, 309 deletions
diff --git a/apps/plugins/rockboy/Makefile b/apps/plugins/rockboy/Makefile
index 65170bb6fd..2a372ef0c0 100644
--- a/apps/plugins/rockboy/Makefile
+++ b/apps/plugins/rockboy/Makefile
@@ -18,7 +18,7 @@ endif
18 18
19LINKFILE := $(OBJDIR)/link.lds 19LINKFILE := $(OBJDIR)/link.lds
20DEPFILE = $(OBJDIR)/dep-rockboy 20DEPFILE = $(OBJDIR)/dep-rockboy
21SRC = cpu.c emu.c events.c fastmem.c hw.c lcd.c lcdc.c loader.c main.c \ 21SRC = cpu.c emu.c events.c fastmem.c hw.c lcd.c lcdc.c loader.c \
22 mem.c menu.c rbsound.c rockboy.c rtc.c save.c sound.c sys_rockbox.c \ 22 mem.c menu.c rbsound.c rockboy.c rtc.c save.c sound.c sys_rockbox.c \
23 ../../../firmware/common/sscanf.c 23 ../../../firmware/common/sscanf.c
24 24
diff --git a/apps/plugins/rockboy/cpu-gb.h b/apps/plugins/rockboy/cpu-gb.h
index bbd6c84e59..d82185e479 100644
--- a/apps/plugins/rockboy/cpu-gb.h
+++ b/apps/plugins/rockboy/cpu-gb.h
@@ -23,9 +23,10 @@ struct cpu
23 union reg pc, sp, bc, de, hl, af; 23 union reg pc, sp, bc, de, hl, af;
24#endif 24#endif
25 int ime, ima; 25 int ime, ima;
26 int speed; 26 unsigned int speed;
27 int halt; 27 unsigned int halt;
28 int div, tim; 28 unsigned int div;
29 int tim;
29 int lcdc; 30 int lcdc;
30 int snd; 31 int snd;
31}; 32};
@@ -48,12 +49,7 @@ extern int blockclen;
48#endif 49#endif
49 50
50void cpu_reset(void); 51void cpu_reset(void);
51void div_advance(int cnt) ICODE_ATTR;
52void timer_advance(int cnt) ICODE_ATTR;
53void lcdc_advance(int cnt) ICODE_ATTR;
54void sound_advance(int cnt) ICODE_ATTR;
55void cpu_timers(int cnt) ICODE_ATTR; 52void cpu_timers(int cnt) ICODE_ATTR;
56int cpu_emulate(int cycles) ICODE_ATTR; 53int cpu_emulate(int cycles) ICODE_ATTR;
57inline int cpu_step(int max) ICODE_ATTR;
58 54
59#endif 55#endif
diff --git a/apps/plugins/rockboy/cpu.c b/apps/plugins/rockboy/cpu.c
index 2bf9e90d2b..1aca06f337 100644
--- a/apps/plugins/rockboy/cpu.c
+++ b/apps/plugins/rockboy/cpu.c
@@ -37,14 +37,14 @@ F = (F & (FL|FC)) | decflag_table[(r)]; }
37#define DECW(r) ( (r)-- ) 37#define DECW(r) ( (r)-- )
38 38
39#define ADD(n) { \ 39#define ADD(n) { \
40W(acc) = (un16)A + (un16)(n); \ 40W(acc) = (un32)A + (un32)(n); \
41F = (ZFLAG(LB(acc))) \ 41F = (ZFLAG(LB(acc))) \
42| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \ 42| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \
43| (HB(acc) << 4); \ 43| (HB(acc) << 4); \
44A = LB(acc); } 44A = LB(acc); }
45 45
46#define ADC(n) { \ 46#define ADC(n) { \
47W(acc) = (un16)A + (un16)(n) + (un16)((F&FC)>>4); \ 47W(acc) = (un32)A + (un32)(n) + (un32)((F&FC)>>4); \
48F = (ZFLAG(LB(acc))) \ 48F = (ZFLAG(LB(acc))) \
49| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \ 49| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \
50| (HB(acc) << 4); \ 50| (HB(acc) << 4); \
@@ -70,7 +70,7 @@ F = (FH & (((SP>>8) ^ ((n)>>8) ^ HB(acc)) << 1)) \
70HL = W(acc); } 70HL = W(acc); }
71 71
72#define CP(n) { \ 72#define CP(n) { \
73W(acc) = (un16)A - (un16)(n); \ 73W(acc) = (un32)A - (un32)(n); \
74F = FN \ 74F = FN \
75| (ZFLAG(LB(acc))) \ 75| (ZFLAG(LB(acc))) \
76| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \ 76| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \
@@ -79,7 +79,7 @@ F = FN \
79#define SUB(n) { CP((n)); A = LB(acc); } 79#define SUB(n) { CP((n)); A = LB(acc); }
80 80
81#define SBC(n) { \ 81#define SBC(n) { \
82W(acc) = (un16)A - (un16)(n) - (un16)((F&FC)>>4); \ 82W(acc) = (un32)A - (un32)(n) - (un32)((F&FC)>>4); \
83F = FN \ 83F = FN \
84| (ZFLAG((n8)LB(acc))) \ 84| (ZFLAG((n8)LB(acc))) \
85| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \ 85| (FH & ((A ^ (n) ^ LB(acc)) << 1)) \
@@ -273,18 +273,19 @@ void cpu_reset(void)
273#endif 273#endif
274} 274}
275 275
276 276static void div_advance(int cnt) ICODE_ATTR;
277void div_advance(int cnt) 277static void div_advance(int cnt)
278{ 278{
279 cpu.div += (cnt<<1); 279 cpu.div += (cnt<<1);
280 if (cpu.div >= 256) 280 if (cpu.div >> 8)
281 { 281 {
282 R_DIV += (cpu.div >> 8); 282 R_DIV += (cpu.div >> 8);
283 cpu.div &= 0xff; 283 cpu.div &= 0xff;
284 } 284 }
285} 285}
286 286
287void timer_advance(int cnt) 287static void timer_advance(int cnt) ICODE_ATTR;
288static void timer_advance(int cnt)
288{ 289{
289 int unit, tima; 290 int unit, tima;
290 291
@@ -293,28 +294,30 @@ void timer_advance(int cnt)
293 unit = ((-R_TAC) & 3) << 1; 294 unit = ((-R_TAC) & 3) << 1;
294 cpu.tim += (cnt<<unit); 295 cpu.tim += (cnt<<unit);
295 296
296 if (cpu.tim >= 512) 297 if (cpu.tim >> 9)
297 { 298 {
298 tima = R_TIMA + (cpu.tim >> 9); 299 tima = R_TIMA + (cpu.tim >> 9);
299 cpu.tim &= 0x1ff; 300 cpu.tim &= 0x1ff;
300 if (tima >= 256) 301 if (tima >> 8)
301 { 302 {
302 hw_interrupt(IF_TIMER, IF_TIMER); 303 hw_interrupt(IF_TIMER, IF_TIMER);
303 hw_interrupt(0, IF_TIMER); 304 hw_interrupt(0, IF_TIMER);
304 } 305 }
305 while (tima >= 256) 306 while (tima >> 8)
306 tima = tima - 256 + R_TMA; 307 tima = tima - 256 + R_TMA;
307 R_TIMA = tima; 308 R_TIMA = tima;
308 } 309 }
309} 310}
310 311
311void lcdc_advance(int cnt) 312static void lcdc_advance(int cnt) ICODE_ATTR;
313static void lcdc_advance(int cnt)
312{ 314{
313 cpu.lcdc -= cnt; 315 cpu.lcdc -= cnt;
314 if (cpu.lcdc <= 0) lcdc_trans(); 316 if (cpu.lcdc <= 0) lcdc_trans();
315} 317}
316 318
317void sound_advance(int cnt) 319static void sound_advance(int cnt) ICODE_ATTR;
320static void sound_advance(int cnt)
318{ 321{
319 cpu.snd += cnt; 322 cpu.snd += cnt;
320} 323}
@@ -328,11 +331,16 @@ void cpu_timers(int cnt)
328 sound_advance(cnt); 331 sound_advance(cnt);
329} 332}
330 333
331int cpu_idle(int max) 334static int cpu_idle(int max)
332{ 335{
333 int cnt, unit; 336 int cnt, unit;
334 337
335 if (!(cpu.halt && IME)) return 0; 338 if (!(cpu.halt && IME)) return 0;
339 if (R_IF & R_IE)
340 {
341 cpu.halt = 0;
342 return 0;
343 }
336 344
337 /* Make sure we don't miss lcdc status events! */ 345 /* Make sure we don't miss lcdc status events! */
338 if ((R_IE & (IF_VBLANK | IF_STAT)) && (max > cpu.lcdc)) 346 if ((R_IE & (IF_VBLANK | IF_STAT)) && (max > cpu.lcdc))
@@ -878,7 +886,7 @@ next:
878 PC++; 886 PC++;
879 if (R_KEY1 & 1) 887 if (R_KEY1 & 1)
880 { 888 {
881 cpu.speed = cpu.speed ^ 1; 889 cpu.speed ^= 1;
882 R_KEY1 = (R_KEY1 & 0x7E) | (cpu.speed << 7); 890 R_KEY1 = (R_KEY1 & 0x7E) | (cpu.speed << 7);
883 break; 891 break;
884 } 892 }
@@ -996,27 +1004,3 @@ next:
996} 1004}
997 1005
998#endif /* ASM_CPU_EMULATE */ 1006#endif /* ASM_CPU_EMULATE */
999
1000
1001#ifndef ASM_CPU_STEP
1002
1003inline int cpu_step(int max)
1004{
1005 register int cnt;
1006 if ((cnt = cpu_idle(max))) return cnt;
1007 return cpu_emulate(1);
1008}
1009
1010#endif /* ASM_CPU_STEP */
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
diff --git a/apps/plugins/rockboy/emu.c b/apps/plugins/rockboy/emu.c
index d04fa9a0fb..8b75211ab0 100644
--- a/apps/plugins/rockboy/emu.c
+++ b/apps/plugins/rockboy/emu.c
@@ -7,6 +7,7 @@
7#include "lcd-gb.h" 7#include "lcd-gb.h"
8#include "sound.h" 8#include "sound.h"
9#include "rtc-gb.h" 9#include "rtc-gb.h"
10#include "pcm.h"
10 11
11/* 12/*
12 * emu_reset is called to initialize the state of the emulated 13 * emu_reset is called to initialize the state of the emulated
@@ -23,7 +24,7 @@ void emu_reset(void)
23 sound_reset(); 24 sound_reset();
24} 25}
25 26
26void emu_step(void) 27static void emu_step(void)
27{ 28{
28 cpu_emulate(cpu.lcdc); 29 cpu_emulate(cpu.lcdc);
29} 30}
diff --git a/apps/plugins/rockboy/fb.h b/apps/plugins/rockboy/fb.h
index 97aeb425a0..96de665d14 100644
--- a/apps/plugins/rockboy/fb.h
+++ b/apps/plugins/rockboy/fb.h
@@ -10,15 +10,15 @@
10 10
11struct fb 11struct fb
12{ 12{
13 fb_data *ptr; 13#ifdef HAVE_LCD_COLOR
14 struct 14 struct
15 { 15 {
16 int l, r; 16 int l, r;
17 } cc[3]; 17 } cc[3];
18 int enabled; 18#else
19#if !defined(HAVE_LCD_COLOR)
20 int mode; 19 int mode;
21#endif 20#endif
21 int enabled;
22}; 22};
23 23
24 24
diff --git a/apps/plugins/rockboy/hw.c b/apps/plugins/rockboy/hw.c
index 05cdfbc156..10193c0d1d 100644
--- a/apps/plugins/rockboy/hw.c
+++ b/apps/plugins/rockboy/hw.c
@@ -63,8 +63,7 @@ void hw_hdma(void)
63 63
64 sa = ((addr)R_HDMA1 << 8) | (R_HDMA2&0xf0); 64 sa = ((addr)R_HDMA1 << 8) | (R_HDMA2&0xf0);
65 da = 0x8000 | ((int)(R_HDMA3&0x1f) << 8) | (R_HDMA4&0xf0); 65 da = 0x8000 | ((int)(R_HDMA3&0x1f) << 8) | (R_HDMA4&0xf0);
66 cnt = 16; 66 for (cnt=16; cnt>0; cnt--)
67 while (cnt--)
68 writeb(da++, readb(sa++)); 67 writeb(da++, readb(sa++));
69 cpu_timers(16); 68 cpu_timers(16);
70 R_HDMA1 = sa >> 8; 69 R_HDMA1 = sa >> 8;
@@ -93,12 +92,11 @@ void hw_hdma_cmd(byte c)
93 /* Perform GDMA */ 92 /* Perform GDMA */
94 sa = ((addr)R_HDMA1 << 8) | (R_HDMA2&0xf0); 93 sa = ((addr)R_HDMA1 << 8) | (R_HDMA2&0xf0);
95 da = 0x8000 | ((int)(R_HDMA3&0x1f) << 8) | (R_HDMA4&0xf0); 94 da = 0x8000 | ((int)(R_HDMA3&0x1f) << 8) | (R_HDMA4&0xf0);
96 cnt = ((int)c)+1; 95 cnt = (((int)c)+1) << 4;
97 /* FIXME - this should use cpu time! */ 96 /* FIXME - this should use cpu time! */
98 /*cpu_timers(102 * cnt);*/ 97 /*cpu_timers(102 * cnt);*/
99 cpu_timers((460>>cpu.speed)+cnt*16); /*dalias*/ 98 cpu_timers((460>>cpu.speed)+cnt); /*dalias*/
100 /*cpu_timers(228 + (16*cnt));*/ /* this should be right according to no$ */ 99 /*cpu_timers(228 + (16*cnt));*/ /* this should be right according to no$ */
101 cnt <<= 4;
102 while (cnt--) 100 while (cnt--)
103 writeb(da++, readb(sa++)); 101 writeb(da++, readb(sa++));
104 R_HDMA1 = sa >> 8; 102 R_HDMA1 = sa >> 8;
@@ -115,7 +113,7 @@ void hw_hdma_cmd(byte c)
115 * interrupt line) if a transition has been made. 113 * interrupt line) if a transition has been made.
116 */ 114 */
117 115
118void pad_refresh() 116void pad_refresh(void)
119{ 117{
120 byte oldp1; 118 byte oldp1;
121 oldp1 = R_P1; 119 oldp1 = R_P1;
@@ -139,7 +137,8 @@ void pad_refresh()
139 * pad. 137 * pad.
140 */ 138 */
141 139
142void pad_press(byte k) 140static void pad_press(byte k) ICODE_ATTR;
141static void pad_press(byte k)
143{ 142{
144 if (hw.pad & k) 143 if (hw.pad & k)
145 return; 144 return;
@@ -147,7 +146,8 @@ void pad_press(byte k)
147 pad_refresh(); 146 pad_refresh();
148} 147}
149 148
150void pad_release(byte k) 149static void pad_release(byte k) ICODE_ATTR;
150static void pad_release(byte k)
151{ 151{
152 if (!(hw.pad & k)) 152 if (!(hw.pad & k))
153 return; 153 return;
@@ -160,7 +160,7 @@ void pad_set(byte k, int st)
160 st ? pad_press(k) : pad_release(k); 160 st ? pad_press(k) : pad_release(k);
161} 161}
162 162
163void hw_reset() 163void hw_reset(void)
164{ 164{
165 hw.ilines = hw.pad = 0; 165 hw.ilines = hw.pad = 0;
166 166
diff --git a/apps/plugins/rockboy/hw.h b/apps/plugins/rockboy/hw.h
index 297eba30fe..67ffd9cf18 100644
--- a/apps/plugins/rockboy/hw.h
+++ b/apps/plugins/rockboy/hw.h
@@ -39,8 +39,6 @@ void hw_dma(byte b) ICODE_ATTR;
39void hw_hdma_cmd(byte c) ICODE_ATTR; 39void hw_hdma_cmd(byte c) ICODE_ATTR;
40void hw_hdma(void) ICODE_ATTR; 40void hw_hdma(void) ICODE_ATTR;
41void pad_refresh(void) ICODE_ATTR; 41void pad_refresh(void) ICODE_ATTR;
42void pad_press(byte k) ICODE_ATTR;
43void pad_release(byte k) ICODE_ATTR;
44void pad_set(byte k, int st) ICODE_ATTR; 42void pad_set(byte k, int st) ICODE_ATTR;
45void hw_reset(void); 43void hw_reset(void);
46 44
diff --git a/apps/plugins/rockboy/lcd-gb.h b/apps/plugins/rockboy/lcd-gb.h
index 91f2487462..36b971a88b 100644
--- a/apps/plugins/rockboy/lcd-gb.h
+++ b/apps/plugins/rockboy/lcd-gb.h
@@ -9,7 +9,7 @@ struct vissprite
9{ 9{
10 byte *buf; 10 byte *buf;
11 int x; 11 int x;
12 byte pal, pri, pad[6]; 12 byte pal, pri;
13}; 13};
14 14
15struct scan 15struct scan
@@ -51,15 +51,6 @@ struct lcd
51extern struct lcd lcd; 51extern struct lcd lcd;
52extern struct scan scan; 52extern struct scan scan;
53 53
54
55void updatepatpix(void) ICODE_ATTR;
56void tilebuf(void) ICODE_ATTR;
57void bg_scan(void) ICODE_ATTR;
58void wnd_scan(void) ICODE_ATTR;
59void bg_scan_pri(void) ICODE_ATTR;
60void wnd_scan_pri(void) ICODE_ATTR;
61void spr_enum(void) ICODE_ATTR;
62void spr_scan(void) ICODE_ATTR;
63void lcd_begin(void) ICODE_ATTR; 54void lcd_begin(void) ICODE_ATTR;
64void lcd_refreshline(void) ICODE_ATTR; 55void lcd_refreshline(void) ICODE_ATTR;
65void pal_write(int i, byte b) ICODE_ATTR; 56void pal_write(int i, byte b) ICODE_ATTR;
diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c
index 494160dc85..da3b138e51 100644
--- a/apps/plugins/rockboy/lcd.c
+++ b/apps/plugins/rockboy/lcd.c
@@ -5,7 +5,9 @@
5#include "mem.h" 5#include "mem.h"
6#include "lcd-gb.h" 6#include "lcd-gb.h"
7#include "fb.h" 7#include "fb.h"
8#ifdef HAVE_LCD_COLOR
8#include "palette-presets.h" 9#include "palette-presets.h"
10#endif
9#ifdef USE_ASM 11#ifdef USE_ASM
10#include "asm.h" 12#include "asm.h"
11#endif 13#endif
@@ -59,7 +61,8 @@ static int dmg_pal[4][4];
59fb_data *vdest; 61fb_data *vdest;
60 62
61#ifndef ASM_UPDATEPATPIX 63#ifndef ASM_UPDATEPATPIX
62void updatepatpix(void) 64static void updatepatpix(void) ICODE_ATTR;
65static void updatepatpix(void)
63{ 66{
64 int i, j; 67 int i, j;
65#if ((CONFIG_CPU != SH7034) && !defined(CPU_COLDFIRE)) 68#if ((CONFIG_CPU != SH7034) && !defined(CPU_COLDFIRE))
@@ -366,7 +369,8 @@ void updatepatpix(void)
366 369
367 370
368 371
369void tilebuf(void) 372static void tilebuf(void) ICODE_ATTR;
373static void tilebuf(void)
370{ 374{
371 int i, cnt; 375 int i, cnt;
372 int base; 376 int base;
@@ -468,7 +472,8 @@ void tilebuf(void)
468 * WX = WND start (if 0, no need to do anything) -> WY 472 * WX = WND start (if 0, no need to do anything) -> WY
469 * U = start...something...thingy... 7 at most 473 * U = start...something...thingy... 7 at most
470 */ 474 */
471void bg_scan(void) 475static void bg_scan(void) ICODE_ATTR;
476static void bg_scan(void)
472{ 477{
473 int cnt; 478 int cnt;
474 byte *src, *dest; 479 byte *src, *dest;
@@ -508,7 +513,8 @@ void bg_scan(void)
508 *(dest++) = *(src++); 513 *(dest++) = *(src++);
509} 514}
510 515
511void wnd_scan(void) 516static void wnd_scan(void) ICODE_ATTR;
517static void wnd_scan(void)
512{ 518{
513 int cnt; 519 int cnt;
514 byte *src, *dest; 520 byte *src, *dest;
@@ -554,7 +560,8 @@ static int priused(void *attr)
554 return (int)((a[0]|a[1]|a[2]|a[3]|a[4]|a[5]|a[6]|a[7])&0x80808080); 560 return (int)((a[0]|a[1]|a[2]|a[3]|a[4]|a[5]|a[6]|a[7])&0x80808080);
555} 561}
556 562
557void bg_scan_pri(void) 563static void bg_scan_pri(void) ICODE_ATTR;
564static void bg_scan_pri(void)
558{ 565{
559 int cnt, i; 566 int cnt, i;
560 byte *src, *dest; 567 byte *src, *dest;
@@ -584,7 +591,8 @@ void bg_scan_pri(void)
584 memset(dest, src[i&31]&128, cnt); 591 memset(dest, src[i&31]&128, cnt);
585} 592}
586 593
587void wnd_scan_pri(void) 594static void wnd_scan_pri(void) ICODE_ATTR;
595static void wnd_scan_pri(void)
588{ 596{
589 int cnt, i; 597 int cnt, i;
590 byte *src, *dest; 598 byte *src, *dest;
@@ -610,7 +618,7 @@ void wnd_scan_pri(void)
610 memset(dest, src[i]&128, cnt); 618 memset(dest, src[i]&128, cnt);
611} 619}
612 620
613void bg_scan_color(void) 621static void bg_scan_color(void)
614{ 622{
615 int cnt; 623 int cnt;
616 byte *src, *dest; 624 byte *src, *dest;
@@ -684,7 +692,7 @@ void bg_scan_color(void)
684 blendcpy(dest, src, *(tile++), cnt); 692 blendcpy(dest, src, *(tile++), cnt);
685} 693}
686 694
687void wnd_scan_color(void) 695static void wnd_scan_color(void)
688{ 696{
689 int cnt; 697 int cnt;
690 byte *src, *dest; 698 byte *src, *dest;
@@ -706,12 +714,8 @@ void wnd_scan_color(void)
706 blendcpy(dest, src, *(tile++), cnt); 714 blendcpy(dest, src, *(tile++), cnt);
707} 715}
708 716
709static void recolor(byte *buf, byte fill, int cnt) 717static void spr_enum(void) ICODE_ATTR;
710{ 718static void spr_enum(void)
711 while (cnt--) *(buf++) |= fill;
712}
713
714void spr_enum(void)
715{ 719{
716 int i, j; 720 int i, j;
717 struct obj *o; 721 struct obj *o;
@@ -764,14 +768,15 @@ void spr_enum(void)
764 if (VS[i].x > VS[j].x) 768 if (VS[i].x > VS[j].x)
765 { 769 {
766 ts = VS[i]; 770 ts = VS[i];
767 VS[i] = VS[j]; 771 VS[i] = VS[j];
768 VS[j] = ts; 772 VS[j] = ts;
769 } 773 }
770 } 774 }
771 } 775 }
772} 776}
773 777
774void spr_scan(void) 778static void spr_scan(void) ICODE_ATTR;
779static void spr_scan(void)
775{ 780{
776 int i, x; 781 int i, x;
777 byte pal, b, ns = NS; 782 byte pal, b, ns = NS;
@@ -874,26 +879,27 @@ void lcd_begin(void)
874#define S3R ((LCD_HEIGHT-((160*DXR)>>16))/2)*LCD_WIDTH+LCD_WIDTH-1 879#define S3R ((LCD_HEIGHT-((160*DXR)>>16))/2)*LCD_WIDTH+LCD_WIDTH-1
875#endif 880#endif
876 881
877 set_pal(); 882 vdest=rb->lcd_framebuffer;
878
879#ifdef HAVE_LCD_COLOR 883#ifdef HAVE_LCD_COLOR
884 set_pal();
885
880 if(options.rotate) 886 if(options.rotate)
881 { 887 {
882 if(options.fullscreen == 0) 888 if(options.scaling == 0)
883 vdest=fb.ptr+S2R; 889 vdest+=+S2R;
884 else if (options.fullscreen == 1) 890 else if (options.scaling == 1)
885 vdest=fb.ptr+S3R; 891 vdest+=S3R;
886 else 892 else
887 vdest=fb.ptr+S1R; 893 vdest+=S1R;
888 } 894 }
889 else 895 else
890 { 896 {
891 if(options.fullscreen == 0) 897 if(options.scaling == 0)
892 vdest=fb.ptr+S2; 898 vdest+=S2;
893 else if (options.fullscreen == 1) 899 else if (options.scaling == 1)
894 vdest=fb.ptr+S3; 900 vdest+=S3;
895 else 901 else
896 vdest=fb.ptr+S1; 902 vdest+=S1;
897 } 903 }
898#endif 904#endif
899 WY = R_WY; 905 WY = R_WY;
@@ -911,7 +917,7 @@ int sremain IDATA_ATTR=LCD_WIDTH-160;
911void setvidmode(void) 917void setvidmode(void)
912{ 918{
913#ifdef HAVE_LCD_COLOR 919#ifdef HAVE_LCD_COLOR
914 switch(options.fullscreen) 920 switch(options.scaling)
915 { 921 {
916 case 0: 922 case 0:
917 if(options.rotate) 923 if(options.rotate)
@@ -1036,7 +1042,6 @@ void lcd_refreshline(void)
1036 1042
1037 bg_scan(); 1043 bg_scan();
1038 wnd_scan(); 1044 wnd_scan();
1039 recolor(BUF+WX, 0x04, 160-WX);
1040 } 1045 }
1041 spr_scan(); 1046 spr_scan();
1042 1047
@@ -1097,13 +1102,13 @@ void lcd_refreshline(void)
1097#endif 1102#endif
1098} 1103}
1099 1104
1105#ifdef HAVE_LCD_COLOR
1100void set_pal(void) 1106void set_pal(void)
1101{ 1107{
1102 memcpy(dmg_pal,palettes[options.pal], sizeof dmg_pal); 1108 memcpy(dmg_pal,palettes[options.pal], sizeof(dmg_pal));
1103 pal_dirty(); 1109 pal_dirty();
1104} 1110}
1105 1111
1106#ifdef HAVE_LCD_COLOR
1107static void updatepalette(int i) 1112static void updatepalette(int i)
1108{ 1113{
1109 int c, r, g, b; 1114 int c, r, g, b;
@@ -1127,13 +1132,13 @@ static void updatepalette(int i)
1127#endif 1132#endif
1128 PAL[i] = c; 1133 PAL[i] = c;
1129} 1134}
1130#endif 1135#endif /* HAVE_LCD_COLOR */
1131 1136
1132void pal_write(int i, byte b) 1137void pal_write(int i, byte b)
1133{ 1138{
1134 if (lcd.pal[i] == b) return; 1139 if (lcd.pal[i] == b) return;
1135 lcd.pal[i] = b; 1140 lcd.pal[i] = b;
1136#if LCD_DEPTH ==16 1141#ifdef HAVE_LCD_COLOR
1137 updatepalette(i>>1); 1142 updatepalette(i>>1);
1138#endif 1143#endif
1139} 1144}
@@ -1175,7 +1180,7 @@ void vram_dirty(void)
1175 1180
1176void pal_dirty(void) 1181void pal_dirty(void)
1177{ 1182{
1178#if LCD_DEPTH ==16 1183#ifdef HAVE_LCD_COLOR
1179 int i; 1184 int i;
1180#endif 1185#endif
1181 if (!hw.cgb) 1186 if (!hw.cgb)
@@ -1186,7 +1191,7 @@ void pal_dirty(void)
1186 pal_write_dmg(64, 2, R_OBP0); 1191 pal_write_dmg(64, 2, R_OBP0);
1187 pal_write_dmg(72, 3, R_OBP1); 1192 pal_write_dmg(72, 3, R_OBP1);
1188 } 1193 }
1189#if LCD_DEPTH ==16 1194#ifdef HAVE_LCD_COLOR
1190 for (i = 0; i < 64; i++) 1195 for (i = 0; i < 64; i++)
1191 updatepalette(i); 1196 updatepalette(i);
1192#endif 1197#endif
@@ -1198,19 +1203,3 @@ void lcd_reset(void)
1198 lcd_begin(); 1203 lcd_begin();
1199 vram_dirty(); 1204 vram_dirty();
1200} 1205}
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
diff --git a/apps/plugins/rockboy/lcdc.c b/apps/plugins/rockboy/lcdc.c
index 90575bbef8..2a1b094929 100644
--- a/apps/plugins/rockboy/lcdc.c
+++ b/apps/plugins/rockboy/lcdc.c
@@ -47,9 +47,8 @@ void stat_trigger(void)
47 * update the STAT interrupt line. 47 * update the STAT interrupt line.
48 */ 48 */
49 49
50static void stat_change(int stat) 50static void stat_change(unsigned int stat)
51{ 51{
52 stat &= 3;
53 R_STAT = (R_STAT & 0x7C) | stat; 52 R_STAT = (R_STAT & 0x7C) | stat;
54 53
55 if (stat != 1) hw_interrupt(0, IF_VBLANK); 54 if (stat != 1) hw_interrupt(0, IF_VBLANK);
diff --git a/apps/plugins/rockboy/loader.c b/apps/plugins/rockboy/loader.c
index bdccb2e7e1..d48a06957e 100644
--- a/apps/plugins/rockboy/loader.c
+++ b/apps/plugins/rockboy/loader.c
@@ -26,7 +26,7 @@
26 * 11 - ROM+MBC3 26 * 11 - ROM+MBC3
27 */ 27 */
28 28
29static int mbc_table[256] = 29static const int mbc_table[256] =
30{ 30{
31 MBC_NONE, 31 MBC_NONE,
32 MBC_MBC1, 32 MBC_MBC1,
@@ -81,7 +81,7 @@ static int mbc_table[256] =
81 MBC_HUC1 81 MBC_HUC1
82}; 82};
83 83
84static unsigned short romsize_table[56] = 84static const unsigned short romsize_table[56] =
85{ 85{
86 2, 4, 8, 16, 32, 64, 128, 256, 86 2, 4, 8, 16, 32, 64, 128, 256,
87 512, 0, 0, 0, 0, 0, 0, 0, 87 512, 0, 0, 0, 0, 0, 0, 0,
@@ -94,7 +94,7 @@ static unsigned short romsize_table[56] =
94}; 94};
95 95
96/* Ram size should be no larger then 16 banks 1Mbit */ 96/* Ram size should be no larger then 16 banks 1Mbit */
97static unsigned char ramsize_table[5] = 97static const unsigned char ramsize_table[5] =
98{ 98{
99 0, 1, 1, 4, 16 99 0, 1, 1, 4, 16
100}; 100};
@@ -104,8 +104,6 @@ static char sramfile[500];
104static char rtcfile[500]; 104static char rtcfile[500];
105static char saveprefix[500]; 105static char saveprefix[500];
106 106
107static int saveslot;
108
109static int forcebatt, nobatt; 107static int forcebatt, nobatt;
110static int forcedmg; 108static int forcedmg;
111 109
@@ -142,7 +140,7 @@ static byte *loadfile(int fd, int *len)
142 return d; 140 return d;
143} 141}
144 142
145int rom_load(void) 143static int rom_load(void)
146{ 144{
147 int fd; 145 int fd;
148 byte c, *data, *header; 146 byte c, *data, *header;
@@ -220,7 +218,7 @@ int rom_load(void)
220 return 0; 218 return 0;
221} 219}
222 220
223int sram_load(void) 221static int sram_load(void)
224{ 222{
225 int fd; 223 int fd;
226 char meow[500]; 224 char meow[500];
@@ -243,7 +241,7 @@ int sram_load(void)
243} 241}
244 242
245 243
246int sram_save(void) 244static int sram_save(void)
247{ 245{
248 int fd; 246 int fd;
249 char meow[500]; 247 char meow[500];
@@ -261,45 +259,7 @@ int sram_save(void)
261 return 0; 259 return 0;
262} 260}
263 261
264 262static void rtc_save(void)
265void state_save(int n)
266{
267 int fd;
268 char name[500];
269
270 if (n < 0) n = saveslot;
271 if (n < 0) n = 0;
272 snprintf(name, 499,"%s.%03d", saveprefix, n);
273
274 if ((fd = open(name, O_WRONLY|O_CREAT|O_TRUNC)>=0))
275 {
276 savestate(fd);
277 close(fd);
278 }
279}
280
281
282void state_load(int n)
283{
284 int fd;
285 char name[500];
286
287 if (n < 0) n = saveslot;
288 if (n < 0) n = 0;
289 snprintf(name, 499, "%s.%03d", saveprefix, n);
290
291 if ((fd = open(name, O_RDONLY)>=0))
292 {
293 loadstate(fd);
294 close(fd);
295 vram_dirty();
296 pal_dirty();
297 sound_dirty();
298 mem_updatemap();
299 }
300}
301
302void rtc_save(void)
303{ 263{
304 int fd; 264 int fd;
305 if (!rtc.batt) return; 265 if (!rtc.batt) return;
@@ -308,7 +268,7 @@ void rtc_save(void)
308 close(fd); 268 close(fd);
309} 269}
310 270
311void rtc_load(void) 271static void rtc_load(void)
312{ 272{
313 int fd; 273 int fd;
314 if (!rtc.batt) return; 274 if (!rtc.batt) return;
@@ -317,21 +277,6 @@ void rtc_load(void)
317 close(fd); 277 close(fd);
318} 278}
319 279
320
321void loader_unload(void)
322{
323 sram_save();
324 /* if (romfile) free(romfile);
325 if (sramfile) free(sramfile);
326 if (saveprefix) free(saveprefix);
327 if (rom.bank) free(rom.bank);
328 if (ram.sbank) free(ram.sbank); */
329 romfile = 0;
330 rom.bank = 0;
331 ram.sbank = 0;
332 mbc.type = mbc.romsize = mbc.ramsize = mbc.batt = 0;
333}
334
335void cleanup(void) 280void cleanup(void)
336{ 281{
337 sram_save(); 282 sram_save();
diff --git a/apps/plugins/rockboy/loader.h b/apps/plugins/rockboy/loader.h
index 2eeb469403..33217d55f3 100644
--- a/apps/plugins/rockboy/loader.h
+++ b/apps/plugins/rockboy/loader.h
@@ -3,23 +3,6 @@
3#ifndef __LOADER_H__ 3#ifndef __LOADER_H__
4#define __LOADER_H__ 4#define __LOADER_H__
5 5
6
7typedef struct loader_s
8{
9 char *rom;
10 char *base;
11 char *sram;
12 char *state;
13 int ramloaded;
14} loader_t;
15
16
17extern loader_t loader;
18
19
20int rom_load(void);
21int sram_load(void);
22int sram_save(void);
23void loader_init(char *s); 6void loader_init(char *s);
24void cleanup(void); 7void cleanup(void);
25 8
diff --git a/apps/plugins/rockboy/main.c b/apps/plugins/rockboy/main.c
deleted file mode 100644
index bb6b6bd2d7..0000000000
--- a/apps/plugins/rockboy/main.c
+++ /dev/null
@@ -1,41 +0,0 @@
1#include "rockmacros.h"
2#include "input.h"
3#include "emu.h"
4#include "loader.h"
5#include "hw.h"
6
7void doevents()
8{
9 event_t ev;
10 int st;
11
12 ev_poll();
13 while (ev_getevent(&ev))
14 {
15 if (ev.type != EV_PRESS && ev.type != EV_RELEASE)
16 continue;
17 st = (ev.type != EV_RELEASE);
18 pad_set(ev.code, st);
19 }
20}
21
22int gnuboy_main(char *rom)
23{
24 rb->lcd_puts(0,0,"Init video");
25 vid_init();
26 rb->lcd_puts(0,1,"Init sound");
27 pcm_init();
28 rb->lcd_puts(0,2,"Loading rom");
29 loader_init(rom);
30 if(shut)
31 return PLUGIN_ERROR;
32 rb->lcd_puts(0,3,"Emu reset");
33 emu_reset();
34 rb->lcd_puts(0,4,"Emu run");
35 rb->lcd_clear_display();
36 rb->lcd_update();
37 emu_run();
38
39 /* never reached */
40 return PLUGIN_OK;
41}
diff --git a/apps/plugins/rockboy/mem.c b/apps/plugins/rockboy/mem.c
index 6811fd5f81..93072f5d51 100644
--- a/apps/plugins/rockboy/mem.c
+++ b/apps/plugins/rockboy/mem.c
@@ -28,7 +28,7 @@ struct ram ram;
28 * make the old maps potentially invalid. 28 * make the old maps potentially invalid.
29 */ 29 */
30 30
31void mem_updatemap() 31void mem_updatemap(void)
32{ 32{
33 int n; 33 int n;
34 static byte **map; 34 static byte **map;
@@ -93,7 +93,8 @@ void mem_updatemap()
93 * byte value to be written. 93 * byte value to be written.
94 */ 94 */
95 95
96void ioreg_write(byte r, byte b) 96static void ioreg_write(byte r, byte b) ICODE_ATTR;
97static void ioreg_write(byte r, byte b)
97{ 98{
98 if (!hw.cgb) 99 if (!hw.cgb)
99 { 100 {
@@ -225,7 +226,7 @@ void ioreg_write(byte r, byte b)
225} 226}
226 227
227 228
228byte ioreg_read(byte r) 229static byte ioreg_read(byte r)
229{ 230{
230 switch(r) 231 switch(r)
231 { 232 {
@@ -282,7 +283,8 @@ byte ioreg_read(byte r)
282 * and a byte value written to the address. 283 * and a byte value written to the address.
283 */ 284 */
284 285
285void mbc_write(int a, byte b) 286static void mbc_write(int a, byte b) ICODE_ATTR;
287static void mbc_write(int a, byte b)
286{ 288{
287 byte ha = (a>>12); 289 byte ha = (a>>12);
288 290
diff --git a/apps/plugins/rockboy/mem.h b/apps/plugins/rockboy/mem.h
index 338fd98bf0..d4097eff6d 100644
--- a/apps/plugins/rockboy/mem.h
+++ b/apps/plugins/rockboy/mem.h
@@ -46,8 +46,6 @@ extern struct rom rom;
46extern struct ram ram; 46extern struct ram ram;
47 47
48void mem_updatemap(void) ICODE_ATTR; 48void mem_updatemap(void) ICODE_ATTR;
49void ioreg_write(byte r, byte b) ICODE_ATTR;
50void mbc_write(int a, byte b) ICODE_ATTR;
51void mem_write(int a, byte b) ICODE_ATTR; 49void mem_write(int a, byte b) ICODE_ATTR;
52byte mem_read(int a) ICODE_ATTR; 50byte mem_read(int a) ICODE_ATTR;
53void mbc_reset(void); 51void mbc_reset(void);
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c
index e896e26c20..eead812b61 100644
--- a/apps/plugins/rockboy/menu.c
+++ b/apps/plugins/rockboy/menu.c
@@ -7,16 +7,17 @@
7#include "button.h" 7#include "button.h"
8#include "rockmacros.h" 8#include "rockmacros.h"
9#include "mem.h" 9#include "mem.h"
10#include "save.h"
10#include "lib/oldmenuapi.h" 11#include "lib/oldmenuapi.h"
11#include "rtc-gb.h" 12#include "rtc-gb.h"
12 13
13#if (CONFIG_KEYPAD == IPOD_4G_PAD) 14#if CONFIG_KEYPAD == IPOD_4G_PAD
14#define MENU_BUTTON_UP BUTTON_SCROLL_BACK 15#define MENU_BUTTON_UP BUTTON_SCROLL_BACK
15#define MENU_BUTTON_DOWN BUTTON_SCROLL_FWD 16#define MENU_BUTTON_DOWN BUTTON_SCROLL_FWD
16#define MENU_BUTTON_LEFT BUTTON_LEFT 17#define MENU_BUTTON_LEFT BUTTON_LEFT
17#define MENU_BUTTON_RIGHT BUTTON_RIGHT 18#define MENU_BUTTON_RIGHT BUTTON_RIGHT
18 19
19#elif (CONFIG_KEYPAD == IRIVER_H10_PAD) 20#elif CONFIG_KEYPAD == IRIVER_H10_PAD
20#define MENU_BUTTON_UP BUTTON_SCROLL_UP 21#define MENU_BUTTON_UP BUTTON_SCROLL_UP
21#define MENU_BUTTON_DOWN BUTTON_SCROLL_DOWN 22#define MENU_BUTTON_DOWN BUTTON_SCROLL_DOWN
22#define MENU_BUTTON_LEFT BUTTON_LEFT 23#define MENU_BUTTON_LEFT BUTTON_LEFT
@@ -37,7 +38,7 @@ static void munge_name(char *buf, size_t bufsiz);
37/* directory ROM save slots belong in */ 38/* directory ROM save slots belong in */
38#define STATE_DIR ROCKBOX_DIR "/rockboy" 39#define STATE_DIR ROCKBOX_DIR "/rockboy"
39 40
40int getbutton(char *text) 41static int getbutton(char *text)
41{ 42{
42 int fw, fh; 43 int fw, fh;
43 rb->lcd_clear_display(); 44 rb->lcd_clear_display();
@@ -59,7 +60,7 @@ int getbutton(char *text)
59 } 60 }
60} 61}
61 62
62void setupkeys(void) 63static void setupkeys(void)
63{ 64{
64 options.UP=getbutton ("Press Up"); 65 options.UP=getbutton ("Press Up");
65 options.DOWN=getbutton ("Press Down"); 66 options.DOWN=getbutton ("Press Down");
@@ -348,7 +349,7 @@ static void do_opt_menu(void)
348 }; 349 };
349 350
350#ifdef HAVE_LCD_COLOR 351#ifdef HAVE_LCD_COLOR
351 static const struct opt_items fullscreen[]= { 352 static const struct opt_items scaling[]= {
352 { "Scaled", -1 }, 353 { "Scaled", -1 },
353 { "Scaled - Maintain Ratio", -1 }, 354 { "Scaled - Maintain Ratio", -1 },
354#if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144) 355#if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144)
@@ -417,8 +418,8 @@ static void do_opt_menu(void)
417 break; 418 break;
418#ifdef HAVE_LCD_COLOR 419#ifdef HAVE_LCD_COLOR
419 case 4: /* Screen Size */ 420 case 4: /* Screen Size */
420 rb->set_option(items[4].desc, &options.fullscreen, INT, fullscreen, 421 rb->set_option(items[4].desc, &options.scaling, INT, scaling,
421 sizeof(fullscreen)/sizeof(*fullscreen), NULL ); 422 sizeof(scaling)/sizeof(*scaling), NULL );
422 setvidmode(); 423 setvidmode();
423 break; 424 break;
424 case 5: /* Screen rotate */ 425 case 5: /* Screen rotate */
diff --git a/apps/plugins/rockboy/palette-presets.h b/apps/plugins/rockboy/palette-presets.h
index 86c3898e06..9be79f6901 100644
--- a/apps/plugins/rockboy/palette-presets.h
+++ b/apps/plugins/rockboy/palette-presets.h
@@ -5,7 +5,7 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id: palette-presets.h $ 8 * $Id$
9 * 9 *
10 * All files in this archive are subject to the GNU General Public License. 10 * All files in this archive are subject to the GNU General Public License.
11 * See the file COPYING in the source tree root for full license agreement. 11 * See the file COPYING in the source tree root for full license agreement.
diff --git a/apps/plugins/rockboy/pcm.h b/apps/plugins/rockboy/pcm.h
index f009f5708c..b90bba087f 100644
--- a/apps/plugins/rockboy/pcm.h
+++ b/apps/plugins/rockboy/pcm.h
@@ -15,6 +15,9 @@ struct pcm
15 15
16extern struct pcm pcm; 16extern struct pcm pcm;
17 17
18void pcm_init(void);
19int pcm_submit(void);
20void pcm_close(void);
18 21
19#endif 22#endif
20 23
diff --git a/apps/plugins/rockboy/rbsound.c b/apps/plugins/rockboy/rbsound.c
index b5cfc96fa4..ac5a29c517 100644
--- a/apps/plugins/rockboy/rbsound.c
+++ b/apps/plugins/rockboy/rbsound.c
@@ -16,7 +16,7 @@ static unsigned short *buf=0, *hwbuf=0;
16 16
17static bool newly_started; 17static bool newly_started;
18 18
19void get_more(unsigned char** start, size_t* size) 19static void get_more(unsigned char** start, size_t* size)
20{ 20{
21 memcpy(hwbuf, &buf[pcm.len*doneplay], BUF_SIZE*sizeof(short)); 21 memcpy(hwbuf, &buf[pcm.len*doneplay], BUF_SIZE*sizeof(short));
22 *start = (unsigned char*)(hwbuf); 22 *start = (unsigned char*)(hwbuf);
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index a72a3a9e32..1cf4b7134b 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -19,6 +19,10 @@
19#include "plugin.h" 19#include "plugin.h"
20#include "loader.h" 20#include "loader.h"
21#include "rockmacros.h" 21#include "rockmacros.h"
22#include "input.h"
23#include "emu.h"
24#include "hw.h"
25#include "pcm.h"
22 26
23PLUGIN_HEADER 27PLUGIN_HEADER
24PLUGIN_IRAM_DECLARE 28PLUGIN_IRAM_DECLARE
@@ -29,8 +33,6 @@ PLUGIN_IRAM_DECLARE
29struct plugin_api* rb; 33struct plugin_api* rb;
30int shut,cleanshut; 34int shut,cleanshut;
31char *errormsg; 35char *errormsg;
32int gnuboy_main(char *rom);
33void pcm_close(void);
34 36
35#define optionname "options" 37#define optionname "options"
36 38
@@ -65,7 +67,7 @@ void* memcpy(void* dst, const void* src, size_t size)
65 return rb->memcpy(dst, src, size); 67 return rb->memcpy(dst, src, size);
66} 68}
67 69
68void setoptions (void) 70static void setoptions (void)
69{ 71{
70 int fd; 72 int fd;
71 DIR* dir; 73 DIR* dir;
@@ -85,7 +87,7 @@ void setoptions (void)
85 options.LEFT=BUTTON_LEFT; 87 options.LEFT=BUTTON_LEFT;
86 options.RIGHT=BUTTON_RIGHT; 88 options.RIGHT=BUTTON_RIGHT;
87 89
88#if (CONFIG_KEYPAD == IRIVER_H100_PAD) 90#if CONFIG_KEYPAD == IRIVER_H100_PAD
89 options.UP=BUTTON_UP; 91 options.UP=BUTTON_UP;
90 options.DOWN=BUTTON_DOWN; 92 options.DOWN=BUTTON_DOWN;
91 93
@@ -95,7 +97,7 @@ void setoptions (void)
95 options.SELECT=BUTTON_SELECT; 97 options.SELECT=BUTTON_SELECT;
96 options.MENU=BUTTON_MODE; 98 options.MENU=BUTTON_MODE;
97 99
98#elif (CONFIG_KEYPAD == IRIVER_H300_PAD) 100#elif CONFIG_KEYPAD == IRIVER_H300_PAD
99 options.UP=BUTTON_UP; 101 options.UP=BUTTON_UP;
100 options.DOWN=BUTTON_DOWN; 102 options.DOWN=BUTTON_DOWN;
101 103
@@ -190,9 +192,9 @@ void setoptions (void)
190 options.fps=0; 192 options.fps=0;
191 options.showstats=0; 193 options.showstats=0;
192#if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144) 194#if (LCD_WIDTH>=160) && (LCD_HEIGHT>=144)
193 options.fullscreen=0; 195 options.scaling=0;
194#else 196#else
195 options.fullscreen=1; 197 options.scaling=1;
196#endif 198#endif
197 options.sound=1; 199 options.sound=1;
198 options.pal=0; 200 options.pal=0;
@@ -203,7 +205,7 @@ void setoptions (void)
203 close(fd); 205 close(fd);
204} 206}
205 207
206void savesettings(void) 208static void savesettings(void)
207{ 209{
208 int fd; 210 int fd;
209 char optionsave[sizeof(savedir)+sizeof(optionname)]; 211 char optionsave[sizeof(savedir)+sizeof(optionname)];
@@ -218,6 +220,42 @@ void savesettings(void)
218 } 220 }
219} 221}
220 222
223void doevents(void)
224{
225 event_t ev;
226 int st;
227
228 ev_poll();
229 while (ev_getevent(&ev))
230 {
231 if (ev.type != EV_PRESS && ev.type != EV_RELEASE)
232 continue;
233 st = (ev.type != EV_RELEASE);
234 pad_set(ev.code, st);
235 }
236}
237
238static int gnuboy_main(char *rom)
239{
240 rb->lcd_puts(0,0,"Init video");
241 vid_init();
242 rb->lcd_puts(0,1,"Init sound");
243 pcm_init();
244 rb->lcd_puts(0,2,"Loading rom");
245 loader_init(rom);
246 if(shut)
247 return PLUGIN_ERROR;
248 rb->lcd_puts(0,3,"Emu reset");
249 emu_reset();
250 rb->lcd_puts(0,4,"Emu run");
251 rb->lcd_clear_display();
252 rb->lcd_update();
253 emu_run();
254
255 /* never reached */
256 return PLUGIN_OK;
257}
258
221/* this is the plugin entry point */ 259/* this is the plugin entry point */
222enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 260enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
223{ 261{
diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h
index a138fae2dd..89cb845ec2 100644
--- a/apps/plugins/rockboy/rockmacros.h
+++ b/apps/plugins/rockboy/rockmacros.h
@@ -31,18 +31,13 @@ extern int shut,cleanshut;
31void vid_init(void); 31void vid_init(void);
32inline void vid_begin(void); 32inline void vid_begin(void);
33void die(char *message, ...); 33void die(char *message, ...);
34void *sys_timer(void);
35int sys_elapsed(long *oldtick);
36int pcm_submit(void);
37void pcm_init(void);
38void doevents(void) ICODE_ATTR; 34void doevents(void) ICODE_ATTR;
39void ev_poll(void); 35void ev_poll(void);
40int do_user_menu(void); 36int do_user_menu(void);
41void loadstate(int fd);
42void savestate(int fd);
43void setvidmode(void); 37void setvidmode(void);
38#if defined(HAVE_LCD_COLOR)
44void set_pal(void); 39void set_pal(void);
45#if !defined(HAVE_LCD_COLOR) 40#else
46void vid_update(int scanline); 41void vid_update(int scanline);
47#endif 42#endif
48#ifdef DYNAREC 43#ifdef DYNAREC
@@ -106,7 +101,7 @@ struct options {
106 int A, B, START, SELECT, MENU; 101 int A, B, START, SELECT, MENU;
107 int UP, DOWN, LEFT, RIGHT; 102 int UP, DOWN, LEFT, RIGHT;
108 int frameskip, fps, maxskip; 103 int frameskip, fps, maxskip;
109 int sound, fullscreen, showstats; 104 int sound, scaling, showstats;
110 int rotate; 105 int rotate;
111 int pal; 106 int pal;
112 int dirty; 107 int dirty;
diff --git a/apps/plugins/rockboy/rtc.c b/apps/plugins/rockboy/rtc.c
index 17b2853fce..6f33bc4f9d 100644
--- a/apps/plugins/rockboy/rtc.c
+++ b/apps/plugins/rockboy/rtc.c
@@ -58,7 +58,7 @@ void rtc_write(byte b)
58 } 58 }
59} 59}
60 60
61void rtc_tick() 61void rtc_tick(void)
62{ 62{
63 if (rtc.stop) return; 63 if (rtc.stop) return;
64 if (++rtc.t == 60) 64 if (++rtc.t == 60)
diff --git a/apps/plugins/rockboy/save.c b/apps/plugins/rockboy/save.c
index 3f6c179beb..4211ceb77f 100644
--- a/apps/plugins/rockboy/save.c
+++ b/apps/plugins/rockboy/save.c
@@ -274,22 +274,3 @@ void savestate(int fd)
274 lseek(fd, base_offset + (sramblock << 12), SEEK_SET); 274 lseek(fd, base_offset + (sramblock << 12), SEEK_SET);
275 write(fd,ram.sbank, 4096*srl); 275 write(fd,ram.sbank, 4096*srl);
276} 276}
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
diff --git a/apps/plugins/rockboy/save.h b/apps/plugins/rockboy/save.h
index 01b3b14f05..8c1041038b 100644
--- a/apps/plugins/rockboy/save.h
+++ b/apps/plugins/rockboy/save.h
@@ -1,4 +1,2 @@
1void loadstate(int fd); 1void loadstate(int fd);
2void savestate(int fd); 2void savestate(int fd);
3void state_save(int n);
4void state_load(int n);
diff --git a/apps/plugins/rockboy/sound.c b/apps/plugins/rockboy/sound.c
index c5621d343a..175260b590 100644
--- a/apps/plugins/rockboy/sound.c
+++ b/apps/plugins/rockboy/sound.c
@@ -302,7 +302,7 @@ static void gbSoundChannel3(int *r, int *l)
302 } 302 }
303} 303}
304 304
305void gbSoundChannel4(int *r, int *l) 305static void gbSoundChannel4(int *r, int *l)
306{ 306{
307 int vol = S4.envol; 307 int vol = S4.envol;
308 308
@@ -669,7 +669,7 @@ void sound_write(byte r, byte b)
669 snd.gbDigitalSound = false; 669 snd.gbDigitalSound = false;
670} 670}
671 671
672void sound_reset() 672void sound_reset(void)
673{ 673{
674 snd.level1 = 7; 674 snd.level1 = 7;
675 snd.level2 = 7; 675 snd.level2 = 7;
@@ -737,7 +737,7 @@ void sound_reset()
737 else snd.rate = 0; 737 else snd.rate = 0;
738} 738}
739 739
740void sound_dirty() 740void sound_dirty(void)
741{ 741{
742 sound_write(RI_NR10, R_NR10); 742 sound_write(RI_NR10, R_NR10);
743 sound_write(RI_NR11, R_NR11); 743 sound_write(RI_NR11, R_NR11);
diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c
index fe3326737d..313e8ae46b 100644
--- a/apps/plugins/rockboy/sys_rockbox.c
+++ b/apps/plugins/rockboy/sys_rockbox.c
@@ -24,12 +24,10 @@
24#include "hw.h" 24#include "hw.h"
25#include "config.h" 25#include "config.h"
26 26
27#if (CONFIG_KEYPAD == SANSA_E200_PAD) 27#if CONFIG_KEYPAD == SANSA_E200_PAD
28
29#define ROCKBOY_SCROLLWHEEL 28#define ROCKBOY_SCROLLWHEEL
30#define ROCKBOY_SCROLLWHEEL_CC BUTTON_SCROLL_UP 29#define ROCKBOY_SCROLLWHEEL_CC BUTTON_SCROLL_UP
31#define ROCKBOY_SCROLLWHEEL_CW BUTTON_SCROLL_DOWN 30#define ROCKBOY_SCROLLWHEEL_CW BUTTON_SCROLL_DOWN
32
33#endif 31#endif
34 32
35struct fb fb IBSS_ATTR; 33struct fb fb IBSS_ATTR;
@@ -210,7 +208,6 @@ inline void vid_begin(void)
210void vid_init(void) 208void vid_init(void)
211{ 209{
212 fb.enabled=1; 210 fb.enabled=1;
213 fb.ptr=rb->lcd_framebuffer;
214 211
215#if defined(HAVE_LCD_COLOR) 212#if defined(HAVE_LCD_COLOR)
216 fb.cc[0].r = 3; /* 8-5 (wasted bits on red) */ 213 fb.cc[0].r = 3; /* 8-5 (wasted bits on red) */