1
0
Fork 0
forked from len0rd/rockbox

Commit FS #7379 - This patch fixes most of the sound problems from the previous version. This is a complete rewrite of VisualBoyAdvance's sound code from C++ to C. This patch also eliminates the need for some large tables giving more room in IRAM and the plugin buffer.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13947 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Karl Kurbjun 2007-07-21 04:00:58 +00:00
parent e9c09d4d0e
commit fa3fc0c5c7
7 changed files with 696 additions and 354 deletions

View file

@ -562,10 +562,3 @@ void mbc_reset(void)
mbc.enableram = 0; mbc.enableram = 0;
mem_updatemap(); mem_updatemap();
} }

View file

@ -41,7 +41,6 @@ struct ram
int loaded; int loaded;
}; };
extern struct mbc mbc; extern struct mbc mbc;
extern struct rom rom; extern struct rom rom;
extern struct ram ram; extern struct ram ram;

View file

@ -12,13 +12,14 @@ struct pcm pcm IBSS_ATTR;
bool doneplay=1; bool doneplay=1;
bool bufnum=0; bool bufnum=0;
static unsigned short *buf=0; static unsigned short *buf=0, *hwbuf=0;
static bool newly_started; static bool newly_started;
void get_more(unsigned char** start, size_t* size) void get_more(unsigned char** start, size_t* size)
{ {
*start = (unsigned char*)(&buf[pcm.len*doneplay]); memcpy(hwbuf, &buf[pcm.len*doneplay], BUF_SIZE*sizeof(short));
*start = (unsigned char*)(hwbuf);
*size = BUF_SIZE*sizeof(short); *size = BUF_SIZE*sizeof(short);
doneplay=1; doneplay=1;
} }
@ -29,14 +30,20 @@ void pcm_init(void)
return; return;
newly_started = true; newly_started = true;
#if defined(HW_HAVE_11) && !defined(TOSHIBA_GIGABEAT_F)
pcm.hz = SAMPR_11;
#else
pcm.hz = SAMPR_44; pcm.hz = SAMPR_44;
#endif
pcm.stereo = 1; pcm.stereo = 1;
pcm.len = BUF_SIZE; pcm.len = BUF_SIZE;
if(!buf) if(!buf)
{ {
buf = my_malloc(pcm.len * N_BUFS *sizeof(short)); buf = my_malloc(pcm.len * N_BUFS *sizeof(short));
hwbuf = my_malloc(pcm.len *sizeof(short));
pcm.buf = buf; pcm.buf = buf;
pcm.pos = 0; pcm.pos = 0;

View file

@ -35,7 +35,6 @@ void *sys_timer(void);
int sys_elapsed(long *oldtick); int sys_elapsed(long *oldtick);
int pcm_submit(void); int pcm_submit(void);
void pcm_init(void); void pcm_init(void);
void sound_dirty(void);
void doevents(void) ICODE_ATTR; void doevents(void) ICODE_ATTR;
void ev_poll(void); void ev_poll(void);
int do_user_menu(void); int do_user_menu(void);

View file

@ -89,24 +89,24 @@ struct svar svars[] =
I4("S1on", &snd.ch[0].on), I4("S1on", &snd.ch[0].on),
I4("S1p ", &snd.ch[0].pos), I4("S1p ", &snd.ch[0].pos),
I4("S1c ", &snd.ch[0].cnt), I4("S1c ", &snd.ch[0].len),
I4("S1ec", &snd.ch[0].encnt), I4("S1ec", &snd.ch[0].enlen),
I4("S1sc", &snd.ch[0].swcnt), I4("S1sc", &snd.ch[0].swlen),
I4("S2on", &snd.ch[1].on), I4("S2on", &snd.ch[1].on),
I4("S2p ", &snd.ch[1].pos), I4("S2p ", &snd.ch[1].pos),
I4("S2c ", &snd.ch[1].cnt), I4("S2c ", &snd.ch[1].len),
I4("S2ec", &snd.ch[1].encnt), I4("S2ec", &snd.ch[1].enlen),
I4("S3on", &snd.ch[2].on), I4("S3on", &snd.ch[2].on),
I4("S3p ", &snd.ch[2].pos), I4("S3p ", &snd.ch[2].pos),
I4("S3c ", &snd.ch[2].cnt), I4("S3c ", &snd.ch[2].len),
I4("S4on", &snd.ch[3].on), I4("S4on", &snd.ch[3].on),
I4("S4p ", &snd.ch[3].pos), I4("S4p ", &snd.ch[3].pos),
I4("S4c ", &snd.ch[3].cnt), I4("S4c ", &snd.ch[3].len),
I4("S4ec", &snd.ch[3].encnt), I4("S4ec", &snd.ch[3].enlen),
I4("hdma", &hw.hdma), I4("hdma", &hw.hdma),
I4("sram", &sramblock), I4("sram", &sramblock),

File diff suppressed because it is too large Load diff

View file

@ -5,18 +5,34 @@
struct sndchan struct sndchan
{ {
int on; /* S1, S2, S3, S4 */
unsigned pos; int on, len, skip, cont;
int cnt, encnt, swcnt; unsigned int pos;
int len, enlen, swlen;
int swfreq; /* S1, S2, S4 */
int freq; int enlen, envol, endir, enlenreload;
int envol, endir;
/* S1, S2 */
const byte *wave;
/* S1 only */
int swlen, swlenreload, swsteps, swstep, swdir;
/* S3 only */
int outputlevel;
/* S4 only */
int shiftskip, shiftpos, shiftright, shiftleft;
int nsteps, clock;
}; };
struct snd struct snd
{ {
int level1, level2, balance;
bool gbDigitalSound;
int rate; int rate;
int quality;
struct sndchan ch[4]; struct sndchan ch[4];
}; };
@ -29,12 +45,8 @@ extern struct snd snd;
byte sound_read(byte r) ICODE_ATTR; byte sound_read(byte r) ICODE_ATTR;
void sound_write(byte r, byte b) ICODE_ATTR; void sound_write(byte r, byte b) ICODE_ATTR;
void sound_dirty(void) ICODE_ATTR; void sound_dirty(void);
void sound_reset(void); void sound_reset(void);
void sound_mix(void) ICODE_ATTR; void sound_mix(void) ICODE_ATTR;
void s1_init(void);
void s2_init(void);
void s3_init(void);
void s4_init(void);
#endif #endif