summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2007-04-18 07:41:31 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2007-04-18 07:41:31 +0000
commitc3dcc87aa494934943769b70fd752af1271d196a (patch)
tree56cd61160f29c22ee3fa67ee9bc3e020013aa051
parent521d6a5e1f1dc3a08700b22db5b203920c9f3bda (diff)
downloadrockbox-c3dcc87aa494934943769b70fd752af1271d196a.tar.gz
rockbox-c3dcc87aa494934943769b70fd752af1271d196a.zip
Allow rockboy to run while music is playing with smaller roms. Works on players that do not use the IRAM macros. Only tested on the Gigabeat as I think that is the only player that will run rockboy well with music. Also simplified the sound and reduced the code size a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13199 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/rockboy/emu.c18
-rw-r--r--apps/plugins/rockboy/loader.c171
-rw-r--r--apps/plugins/rockboy/main.c3
-rw-r--r--apps/plugins/rockboy/mem.h21
-rw-r--r--apps/plugins/rockboy/rbsound.c103
-rw-r--r--apps/plugins/rockboy/rockboy.c24
-rw-r--r--apps/plugins/rockboy/rockmacros.h3
-rw-r--r--apps/plugins/rockboy/save.c5
-rw-r--r--apps/plugins/rockboy/sound.c4
9 files changed, 176 insertions, 176 deletions
diff --git a/apps/plugins/rockboy/emu.c b/apps/plugins/rockboy/emu.c
index 50fc442713..7f24bde01e 100644
--- a/apps/plugins/rockboy/emu.c
+++ b/apps/plugins/rockboy/emu.c
@@ -41,23 +41,21 @@ void emu_run(void)
41#ifdef HAVE_ADJUSTABLE_CPU_FREQ 41#ifdef HAVE_ADJUSTABLE_CPU_FREQ
42 rb->cpu_boost(true); 42 rb->cpu_boost(true);
43#endif 43#endif
44
44 while(!shut) 45 while(!shut)
45 { 46 {
46 cpu_emulate(2280); 47 cpu_emulate(2280);
47 while (R_LY > 0 && R_LY < 144) 48 while (R_LY > 0 && R_LY < 144)
48 emu_step(); 49 emu_step();
49 50
50 /* rtc_tick(); */ /* RTC support not implemented */ 51 rtc_tick(); /* RTC support not implemented */
51 52
52 if(options.sound) 53 if(options.sound || !plugbuf)
53 {
54 sound_mix(); 54 sound_mix();
55 pcm_submit(); 55
56 }
57
58 doevents(); 56 doevents();
59 vid_begin(); 57 vid_begin();
60 58
61 if (!(R_LCDC & 0x80)) 59 if (!(R_LCDC & 0x80))
62 cpu_emulate(32832); 60 cpu_emulate(32832);
63 61
@@ -70,11 +68,11 @@ void emu_run(void)
70 frames++; 68 frames++;
71 framesin++; 69 framesin++;
72 70
73 if(*rb->current_tick-timeten>=20) 71 if(*rb->current_tick-timeten>=10)
74 { 72 {
75 timeten=*rb->current_tick; 73 timeten=*rb->current_tick;
76 if(framesin<12) options.frameskip++; 74 if(framesin<6) options.frameskip++;
77 if(framesin>12) options.frameskip--; 75 if(framesin>6) options.frameskip--;
78 if(options.frameskip>options.maxskip) options.frameskip=options.maxskip; 76 if(options.frameskip>options.maxskip) options.frameskip=options.maxskip;
79 if(options.frameskip<0) options.frameskip=0; 77 if(options.frameskip<0) options.frameskip=0;
80 framesin=0; 78 framesin=0;
diff --git a/apps/plugins/rockboy/loader.c b/apps/plugins/rockboy/loader.c
index 1317362c2c..0dbd0b4591 100644
--- a/apps/plugins/rockboy/loader.c
+++ b/apps/plugins/rockboy/loader.c
@@ -1,8 +1,3 @@
1
2#include <stdio.h>
3#include <string.h>
4
5
6#include "rockmacros.h" 1#include "rockmacros.h"
7#include "defs.h" 2#include "defs.h"
8#include "regs.h" 3#include "regs.h"
@@ -13,11 +8,58 @@
13#include "save.h" 8#include "save.h"
14#include "sound.h" 9#include "sound.h"
15 10
11/* From http://www.semis.demon.co.uk/Gameboy/Gbspec.txt (4/17/2007)
12 * Cartridge type:
13 * 0 - ROM ONLY 12 - ROM+MBC3+RAM
14 * 1 - ROM+MBC1 13 - ROM+MBC3+RAM+BATT
15 * 2 - ROM+MBC1+RAM 19 - ROM+MBC5
16 * 3 - ROM+MBC1+RAM+BATT 1A - ROM+MBC5+RAM
17 * 5 - ROM+MBC2 1B - ROM+MBC5+RAM+BATT
18 * 6 - ROM+MBC2+BATTERY 1C - ROM+MBC5+RUMBLE
19 * 8 - ROM+RAM 1D - ROM+MBC5+RUMBLE+SRAM
20 * 9 - ROM+RAM+BATTERY 1E - ROM+MBC5+RUMBLE+SRAM+BATT
21 * B - ROM+MMM01 1F - Pocket Camera
22 * C - ROM+MMM01+SRAM FD - Bandai TAMA5
23 * D - ROM+MMM01+SRAM+BATT FE - Hudson HuC-3
24 * F - ROM+MBC3+TIMER+BATT FF - Hudson HuC-1
25 * 10 - ROM+MBC3+TIMER+RAM+BATT
26 * 11 - ROM+MBC3
27 */
16 28
17static int mbc_table[256] = 29static int mbc_table[256] =
18{ 30{
19 0, 1, 1, 1, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 3, 31 MBC_NONE,
20 3, 3, 3, 3, 0, 0, 0, 0, 0, 5, 5, 5, MBC_RUMBLE, MBC_RUMBLE, MBC_RUMBLE, 0, 32 MBC_MBC1,
33 MBC_MBC1,
34 MBC_MBC1 | MBC_BAT,
35 0,
36 MBC_MBC2,
37 MBC_MBC2 | MBC_BAT,
38 0,
39 0,
40 MBC_BAT,
41 0,
42 0,
43 0,
44 MBC_BAT,
45 0,
46 MBC_MBC3 | MBC_BAT | MBC_RTC,
47 MBC_MBC3 | MBC_BAT | MBC_RTC,
48 MBC_MBC3,
49 MBC_MBC3,
50 MBC_MBC3 | MBC_BAT,
51 0,
52 0,
53 0,
54 0,
55 0,
56 MBC_MBC5,
57 MBC_MBC5,
58 MBC_MBC5 | MBC_BAT,
59 MBC_RUMBLE,
60 MBC_RUMBLE,
61 MBC_RUMBLE | MBC_BAT,
62 0,
21 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
23 65
@@ -34,46 +76,29 @@ static int mbc_table[256] =
34 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
35 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 78 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
37 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MBC_HUC3, MBC_HUC1 79 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
38}; 80 MBC_HUC3,
39 81 MBC_HUC1
40static int rtc_table[256] =
41{
42 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
43 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44 0
45};
46
47static int batt_table[256] =
48{
49 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0,
50 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,
51 0
52}; 82};
53 83
54static int romsize_table[256] = 84static unsigned short romsize_table[56] =
55{ 85{
56 2, 4, 8, 16, 32, 64, 128, 256, 512, 86 2, 4, 8, 16, 32, 64, 128, 256,
57 0, 0, 0, 0, 0, 0, 0, 0, 87 512, 0, 0, 0, 0, 0, 0, 0,
58 0, 0, 0, 0, 0, 0, 0, 0, 88 0, 0, 0, 0, 0, 0, 0, 0,
59 0, 0, 0, 0, 0, 0, 0, 0, 89 0, 0, 0, 0, 0, 0, 0, 0,
60 0, 0, 0, 0, 0, 0, 0, 0, 90 0, 0, 0, 0, 0, 0, 0, 0,
61 0, 0, 0, 0, 0, 0, 0, 0, 91 0, 0, 0, 0, 0, 0, 0, 0,
62 0, 0, 0, 0, 0, 0, 0, 0, 92 0, 0, 0, 0, 128, 128, 128, 0
63 0, 0, 0, 0, 0, 0, 0, 0, 93 /* 0, 0, 0, 0, 72, 80, 96 -- actual values but bad to use these! */
64 0, 0, 0, 0, 0, 0, 0, 0,
65 0, 0, 0, 0, 0, 0, 0, 0,
66 0, 0, 128, 128, 128
67 /* 0, 0, 72, 80, 96 -- actual values but bad to use these! */
68}; 94};
69 95
70static int ramsize_table[256] = 96/* Ram size should be no larger then 16 banks 1Mbit */
97static unsigned char ramsize_table[5] =
71{ 98{
72 1, 1, 1, 4, 16, 99 0, 1, 1, 4, 16
73 4 /* FIXME - what value should this be?! */
74}; 100};
75 101
76
77static char *romfile; 102static char *romfile;
78static char sramfile[500]; 103static char sramfile[500];
79static char rtcfile[500]; 104static char rtcfile[500];
@@ -100,24 +125,23 @@ static void initmem(void *mem, int size)
100 125
101static byte *loadfile(int fd, int *len) 126static byte *loadfile(int fd, int *len)
102{ 127{
103 int c, l = 0, p = 0; 128 int c;
104 129 byte *d;
105 byte *d, buf[512]; 130
106 d=malloc(32768); 131 *len=lseek(fd,0,SEEK_END);
107 for(;;) 132 d=malloc((*len)*sizeof(char)+64);
133 if(d==0)
108 { 134 {
109 c = read(fd, buf, sizeof buf); 135 die("Not enough memory");
110 if (c <= 0) break; 136 return 0;
111 l += c;
112 memcpy(d+p, buf, c);
113 p += c;
114 } 137 }
115 setmallocpos(d+p+64); 138 lseek(fd,0,SEEK_SET);
116 *len = l; 139
140 c = read(fd, d, *len);
141
117 return d; 142 return d;
118} 143}
119 144
120
121int rom_load(void) 145int rom_load(void)
122{ 146{
123 int fd; 147 int fd;
@@ -126,13 +150,19 @@ int rom_load(void)
126 150
127 fd = open(romfile, O_RDONLY); 151 fd = open(romfile, O_RDONLY);
128 152
129 if (fd<0) { 153 if (fd<0)
130 die("cannot open rom file"); 154 {
131 die(romfile); 155 die("cannot open rom file %s", romfile);
132 return 1; 156 return 1;
133 } 157 }
134 158
135 data = loadfile(fd, &len); 159 data = loadfile(fd, &len);
160 close(fd);
161 if(data==0)
162 {
163 die("Not Enough Memory");
164 return 1;
165 }
136 header = data; /* no zip. = decompress(data, &len); */ 166 header = data; /* no zip. = decompress(data, &len); */
137 167
138 memcpy(rom.name, header+0x0134, 16); 168 memcpy(rom.name, header+0x0134, 16);
@@ -141,17 +171,22 @@ int rom_load(void)
141 rom.name[16] = 0; 171 rom.name[16] = 0;
142 172
143 c = header[0x0147]; 173 c = header[0x0147];
144 mbc.type = mbc_table[c]; 174 mbc.type = mbc_table[c]&(MBC_MBC1|MBC_MBC2|MBC_MBC3|MBC_MBC5|MBC_RUMBLE|MBC_HUC1|MBC_HUC3);
145 mbc.batt = (batt_table[c] && !nobatt) || forcebatt; 175 mbc.batt = ((mbc_table[c]&MBC_BAT) && !nobatt) || forcebatt;
146 rtc.batt = rtc_table[c]; 176 rtc.batt = mbc_table[c]&MBC_RTC;
147 mbc.romsize = romsize_table[header[0x0148]];
148 mbc.ramsize = ramsize_table[header[0x0149]];
149 177
150 if (!mbc.romsize) { 178 if(header[0x0148]<10 || (header[0x0148]>51 && header[0x0148]<55))
179 mbc.romsize = romsize_table[header[0x0148]];
180 else
181 {
151 die("unknown ROM size %02X\n", header[0x0148]); 182 die("unknown ROM size %02X\n", header[0x0148]);
152 return 1; 183 return 1;
153 } 184 }
154 if (!mbc.ramsize) { 185
186 if(header[0x0149]<5)
187 mbc.ramsize = ramsize_table[header[0x0149]];
188 else
189 {
155 die("unknown SRAM size %02X\n", header[0x0149]); 190 die("unknown SRAM size %02X\n", header[0x0149]);
156 return 1; 191 return 1;
157 } 192 }
@@ -160,7 +195,17 @@ int rom_load(void)
160 rom.bank = (void *) data; /* realloc(data, rlen); */ 195 rom.bank = (void *) data; /* realloc(data, rlen); */
161 if (rlen > len) memset(rom.bank[0]+len, 0xff, rlen - len); 196 if (rlen > len) memset(rom.bank[0]+len, 0xff, rlen - len);
162 197
198 /* This is the size of the ram on the cartridge
199 * See http://www.semis.demon.co.uk/Gameboy/Gbspec.txt
200 * for a full description. (8192*number of banks)
201 */
163 ram.sbank = malloc(8192 * mbc.ramsize); 202 ram.sbank = malloc(8192 * mbc.ramsize);
203 if(ram.sbank==0 && mbc.ramsize!=0)
204 {
205 die("Not enough Memory");
206 return 1;
207 }
208
164 /* ram.ibank = malloc(4096*8); */ 209 /* ram.ibank = malloc(4096*8); */
165 210
166 initmem(ram.sbank, 8192 * mbc.ramsize); 211 initmem(ram.sbank, 8192 * mbc.ramsize);
@@ -171,8 +216,6 @@ int rom_load(void)
171 216
172 c = header[0x0143]; 217 c = header[0x0143];
173 hw.cgb = ((c == 0x80) || (c == 0xc0)) && !forcedmg; 218 hw.cgb = ((c == 0x80) || (c == 0xc0)) && !forcedmg;
174
175 close(fd);
176 219
177 return 0; 220 return 0;
178} 221}
diff --git a/apps/plugins/rockboy/main.c b/apps/plugins/rockboy/main.c
index fc21ca0d58..bb6b6bd2d7 100644
--- a/apps/plugins/rockboy/main.c
+++ b/apps/plugins/rockboy/main.c
@@ -1,6 +1,3 @@
1#include <stdio.h>
2#include <string.h>
3
4#include "rockmacros.h" 1#include "rockmacros.h"
5#include "input.h" 2#include "input.h"
6#include "emu.h" 3#include "emu.h"
diff --git a/apps/plugins/rockboy/mem.h b/apps/plugins/rockboy/mem.h
index 66165d1970..005c495f31 100644
--- a/apps/plugins/rockboy/mem.h
+++ b/apps/plugins/rockboy/mem.h
@@ -1,19 +1,18 @@
1#ifndef __MEM_H__ 1#ifndef __MEM_H__
2#define __MEM_H__ 2#define __MEM_H__
3 3
4
5#include "defs.h" 4#include "defs.h"
6 5
7 6#define MBC_NONE 0
8 7#define MBC_MBC1 1
9#define MBC_NONE 0 8#define MBC_MBC2 2
10#define MBC_MBC1 1 9#define MBC_MBC3 4
11#define MBC_MBC2 2 10#define MBC_MBC5 8
12#define MBC_MBC3 3 11#define MBC_RUMBLE 16
13#define MBC_MBC5 5 12#define MBC_HUC1 32
14#define MBC_RUMBLE 15 13#define MBC_HUC3 64
15#define MBC_HUC1 0xC1 14#define MBC_RTC 128
16#define MBC_HUC3 0xC3 15#define MBC_BAT 256
17 16
18struct mbc 17struct mbc
19{ 18{
diff --git a/apps/plugins/rockboy/rbsound.c b/apps/plugins/rockboy/rbsound.c
index 41d00c1b73..4e61d5590c 100644
--- a/apps/plugins/rockboy/rbsound.c
+++ b/apps/plugins/rockboy/rbsound.c
@@ -2,30 +2,14 @@
2#include "defs.h" 2#include "defs.h"
3#include "pcm.h" 3#include "pcm.h"
4 4
5/*#define ONEBUF*/
6 /* Note: I think the single buffer implementation is more
7 * responsive with sound(less lag) but it creates more
8 * choppyness overall to the sound. 2 buffer's don't seem to
9 * make a difference, but 4 buffers is definately noticable
10 */
11
12struct pcm pcm IBSS_ATTR; 5struct pcm pcm IBSS_ATTR;
13 6
14bool sound = 1; 7#define N_BUFS 2
15#ifdef ONEBUF
16#define N_BUFS 1
17#else
18#define N_BUFS 4
19#endif
20#define BUF_SIZE 1024 8#define BUF_SIZE 1024
21 9
22#if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR) 10#if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR)
23 11
24#ifndef ONEBUF 12bool doneplay=1;
25static short curbuf,gmcurbuf;
26#else
27bool doneplay=0;
28#endif
29 13
30static unsigned char *buf=0; 14static unsigned char *buf=0;
31static unsigned short *gmbuf; 15static unsigned short *gmbuf;
@@ -34,33 +18,30 @@ static bool newly_started;
34 18
35void get_more(unsigned char** start, size_t* size) 19void get_more(unsigned char** start, size_t* size)
36{ 20{
37#ifdef ONEBUF 21 *start = (unsigned char*)(&gmbuf[pcm.len*doneplay]);
38 doneplay=1; 22 *size = BUF_SIZE*sizeof(short);
39 *start = (unsigned char*)(gmbuf);
40#else
41 *start = (unsigned char*)(&gmbuf[pcm.len*curbuf]);
42#endif
43 *size = BUF_SIZE*sizeof(short);
44} 23}
45 24
46void pcm_init(void) 25void pcm_init(void)
47{ 26{
27 if(plugbuf)
28 return;
29
48 newly_started = true; 30 newly_started = true;
49 31
50 pcm.hz = 11025; 32 pcm.hz = 11025;
51 pcm.stereo = 1; 33 pcm.stereo = 1;
52 34
53 pcm.len = BUF_SIZE; 35 pcm.len = BUF_SIZE;
54 if(!buf){ 36 if(!buf)
55 buf = my_malloc(pcm.len * N_BUFS); 37 {
56 gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short)); 38 buf = my_malloc(pcm.len * N_BUFS);
57 pcm.buf = buf; 39 gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short));
58 pcm.pos = 0; 40
59#ifndef ONEBUF 41 pcm.buf = buf;
60 curbuf = gmcurbuf= 0; 42 pcm.pos = 0;
61#endif 43 memset(gmbuf, 0, pcm.len * N_BUFS *sizeof(short));
62 memset(gmbuf, 0, pcm.len * N_BUFS *sizeof(short)); 44 memset(buf, 0, pcm.len * N_BUFS);
63 memset(buf, 0, pcm.len * N_BUFS);
64 } 45 }
65 46
66 rb->pcm_play_stop(); 47 rb->pcm_play_stop();
@@ -75,46 +56,32 @@ void pcm_close(void)
75 rb->pcm_play_stop(); 56 rb->pcm_play_stop();
76 rb->pcm_set_frequency(44100); 57 rb->pcm_set_frequency(44100);
77} 58}
78 59
79int pcm_submit(void) 60int pcm_submit(void)
80{ 61{
81 if (!options.sound) return 1;
82 register int i; 62 register int i;
83 63
84 if (!sound) { 64 if (pcm.pos < pcm.len) return 1;
85 pcm.pos = 0;
86 return 0;
87 }
88 65
89 if (pcm.pos < pcm.len) return 1; 66 doneplay=!doneplay;
90 67
91#ifndef ONEBUF 68 if(doneplay)
92 curbuf = (curbuf + 1) % N_BUFS; 69 pcm.buf = buf + pcm.len;
93 pcm.buf = buf + pcm.len * curbuf; 70 else
94#endif 71 pcm.buf = buf;
95 pcm.pos = 0; 72
73 pcm.pos = 0;
74
75 /* gotta convert the 8 bit buffer to 16 */
76 for(i=0; i<pcm.len;i++)
77 gmbuf[i+pcm.len*doneplay] = (pcm.buf[i]<<8)-0x8000;
78
79 if(newly_started)
80 {
81 rb->pcm_play_data(&get_more,NULL,0);
82 newly_started = false;
83 }
96 84
97 /* gotta convert the 8 bit buffer to 16 */
98 for(i=0; i<pcm.len;i++)
99#ifdef ONEBUF
100 gmbuf[i] = (pcm.buf[i]<<8)-0x8000;
101#else
102 gmbuf[i+pcm.len*curbuf] = (pcm.buf[i]<<8)-0x8000;
103#endif
104
105 if(newly_started)
106 {
107 rb->pcm_play_data(&get_more,NULL,0);
108 newly_started = false;
109 }
110
111 /* this while loop and done play are in place to make sure the sound timing
112 * is correct(although it's not)
113 */
114#ifdef ONEBUF
115 while(doneplay==0) rb->yield();
116 doneplay=0;
117#endif
118 return 1; 85 return 1;
119} 86}
120#else 87#else
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index 1534173114..3fbe1fd8e1 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -65,12 +65,6 @@ void* memcpy(void* dst, const void* src, size_t size)
65 return rb->memcpy(dst, src, size); 65 return rb->memcpy(dst, src, size);
66} 66}
67 67
68void setmallocpos(void *pointer)
69{
70 audio_bufferpointer = pointer;
71 audio_buffer_free = audio_bufferpointer - audio_bufferbase;
72}
73
74void setoptions (void) 68void setoptions (void)
75{ 69{
76 int fd; 70 int fd;
@@ -197,9 +191,18 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
197 rb->splash(HZ*3, "Play gameboy ROM file! (.gb/.gbc)"); 191 rb->splash(HZ*3, "Play gameboy ROM file! (.gb/.gbc)");
198 return PLUGIN_OK; 192 return PLUGIN_OK;
199 } 193 }
200 194 if(rb->audio_status())
201 audio_bufferbase = audio_bufferpointer 195 {
202 = rb->plugin_get_audio_buffer((int *)&audio_buffer_free); 196 audio_bufferbase = audio_bufferpointer
197 = rb->plugin_get_buffer((int *)&audio_buffer_free);
198 plugbuf=true;
199 }
200 else
201 {
202 audio_bufferbase = audio_bufferpointer
203 = rb->plugin_get_audio_buffer((int *)&audio_buffer_free);
204 plugbuf=false;
205 }
203#if MEM <= 8 && !defined(SIMULATOR) 206#if MEM <= 8 && !defined(SIMULATOR)
204 /* loaded as an overlay plugin, protect from overwriting ourselves */ 207 /* loaded as an overlay plugin, protect from overwriting ourselves */
205 if ((unsigned)(plugin_start_addr - (unsigned char *)audio_bufferbase) 208 if ((unsigned)(plugin_start_addr - (unsigned char *)audio_bufferbase)
@@ -226,7 +229,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
226 rb->splash(HZ/2, errormsg); 229 rb->splash(HZ/2, errormsg);
227 return PLUGIN_ERROR; 230 return PLUGIN_ERROR;
228 } 231 }
229 pcm_close(); 232 if(!rb->audio_status())
233 pcm_close();
230 rb->splash(HZ/2, "Shutting down"); 234 rb->splash(HZ/2, "Shutting down");
231 235
232 savesettings(); 236 savesettings();
diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h
index 06db25b433..d302fd04fe 100644
--- a/apps/plugins/rockboy/rockmacros.h
+++ b/apps/plugins/rockboy/rockmacros.h
@@ -31,7 +31,6 @@ 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 setmallocpos(void *pointer);
35void *sys_timer(void); 34void *sys_timer(void);
36int sys_elapsed(long *oldtick); 35int sys_elapsed(long *oldtick);
37int pcm_submit(void); 36int pcm_submit(void);
@@ -122,6 +121,8 @@ struct options {
122 int pal; 121 int pal;
123}; 122};
124 123
124bool plugbuf;
125
125extern struct options options; 126extern struct options options;
126#define savedir "/.rockbox/rockboy" 127#define savedir "/.rockbox/rockboy"
127 128
diff --git a/apps/plugins/rockboy/save.c b/apps/plugins/rockboy/save.c
index 2332811911..794579d8fa 100644
--- a/apps/plugins/rockboy/save.c
+++ b/apps/plugins/rockboy/save.c
@@ -1,7 +1,4 @@
1
2
3#include "rockmacros.h" 1#include "rockmacros.h"
4#include <stdio.h>
5 2
6#include "defs.h" 3#include "defs.h"
7#include "cpu-gb.h" 4#include "cpu-gb.h"
@@ -13,8 +10,6 @@
13#include "mem.h" 10#include "mem.h"
14#include "sound.h" 11#include "sound.h"
15 12
16
17
18#ifdef ROCKBOX_LITTLE_ENDIAN 13#ifdef ROCKBOX_LITTLE_ENDIAN
19#define LIL(x) (x) 14#define LIL(x) (x)
20#else 15#else
diff --git a/apps/plugins/rockboy/sound.c b/apps/plugins/rockboy/sound.c
index 707bb6b956..516b9c3f71 100644
--- a/apps/plugins/rockboy/sound.c
+++ b/apps/plugins/rockboy/sound.c
@@ -1,6 +1,3 @@
1
2
3
4#include "rockmacros.h" 1#include "rockmacros.h"
5#include "defs.h" 2#include "defs.h"
6#include "pcm.h" 3#include "pcm.h"
@@ -125,7 +122,6 @@ void sound_reset(void)
125 122
126void sound_mix(void) 123void sound_mix(void)
127{ 124{
128 if(!options.sound) return;
129 int s, l, r, f, n; 125 int s, l, r, f, n;
130 126
131 if (!RATE || cpu.snd < RATE) return; 127 if (!RATE || cpu.snd < RATE) return;