forked from len0rd/rockbox
Karl Kurbjun's patch #1407719:
Here's another patch for rockboy that adds automatic frameskip (it's pretty rough as I haven't figured out an accurate timer), fullscreen support on the H300, and a bit of assembly and some IRAM stuff. I'm not sure if I'm doing the IRAM stuff correct though as it doesn't seem to make much of a difference if any. I've also added a statistics option that will show how many frames per second the gameboy is seeing (not what the player is getting) and what the frameskip is at. When you enable stats sometimes you have to go back into the menu and then come out to clear erronous values. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8397 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c05cd1676f
commit
137fb6cb9f
27 changed files with 490 additions and 213 deletions
|
|
@ -3,10 +3,18 @@
|
|||
#include "pcm.h"
|
||||
#include "rc.h"
|
||||
|
||||
struct pcm pcm;
|
||||
//#define ONEBUF // Note: I think the single buffer implementation is more responsive with sound(less lag)
|
||||
// but it creates more choppyness overall to the sound. 2 buffer's don't seem to make
|
||||
// a difference, but 4 buffers is definately noticable
|
||||
|
||||
struct pcm pcm IBSS_ATTR;
|
||||
|
||||
bool sound = 1;
|
||||
#ifdef ONEBUF
|
||||
#define N_BUFS 1
|
||||
#else
|
||||
#define N_BUFS 4
|
||||
#endif
|
||||
#define BUF_SIZE 1024
|
||||
|
||||
rcvar_t pcm_exports[] =
|
||||
|
|
@ -16,48 +24,62 @@ rcvar_t pcm_exports[] =
|
|||
|
||||
#if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR)
|
||||
|
||||
static int curbuf,gmcurbuf;
|
||||
#ifndef ONEBUF
|
||||
static short curbuf,gmcurbuf;
|
||||
#else
|
||||
bool doneplay=0;
|
||||
#endif
|
||||
|
||||
static byte *buf=0;
|
||||
static short *gmbuf;
|
||||
static unsigned char *buf=0;
|
||||
static unsigned short *gmbuf;
|
||||
|
||||
static bool newly_started;
|
||||
|
||||
void get_more(unsigned char** start, long* size)
|
||||
{
|
||||
#ifdef ONEBUF
|
||||
doneplay=1;
|
||||
*start = (unsigned char*)(gmbuf);
|
||||
#else
|
||||
*start = (unsigned char*)(&gmbuf[pcm.len*curbuf]);
|
||||
#endif
|
||||
*size = BUF_SIZE*sizeof(short);
|
||||
}
|
||||
|
||||
void pcm_init(void)
|
||||
{
|
||||
if(!sound) return;
|
||||
|
||||
newly_started = true;
|
||||
newly_started = true;
|
||||
|
||||
pcm.hz = 11025;
|
||||
pcm.stereo = 1;
|
||||
pcm.hz = 11025;
|
||||
pcm.stereo = 1;
|
||||
|
||||
pcm.len = BUF_SIZE;
|
||||
if(!buf){
|
||||
buf = my_malloc(pcm.len * N_BUFS);
|
||||
gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short));
|
||||
pcm.buf = buf;
|
||||
pcm.pos = 0;
|
||||
curbuf = gmcurbuf= 0;
|
||||
buf = my_malloc(pcm.len * N_BUFS);
|
||||
gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short));
|
||||
pcm.buf = buf;
|
||||
pcm.pos = 0;
|
||||
#ifndef ONEBUF
|
||||
curbuf = gmcurbuf= 0;
|
||||
#endif
|
||||
memset(gmbuf, 0, pcm.len * N_BUFS *sizeof(short));
|
||||
memset(buf, 0, pcm.len * N_BUFS);
|
||||
}
|
||||
|
||||
rb->pcm_play_stop();
|
||||
rb->pcm_set_frequency(11025); // 44100 22050 11025
|
||||
|
||||
rb->pcm_play_stop();
|
||||
|
||||
rb->pcm_set_frequency(11025); // 44100 22050 11025
|
||||
}
|
||||
|
||||
void pcm_close(void)
|
||||
{
|
||||
memset(&pcm, 0, sizeof pcm);
|
||||
newly_started = true;
|
||||
rb->pcm_play_stop();
|
||||
memset(&pcm, 0, sizeof pcm);
|
||||
newly_started = true;
|
||||
rb->pcm_play_stop();
|
||||
rb->pcm_set_frequency(44100);
|
||||
}
|
||||
|
||||
void get_more(unsigned char** start, long* size)
|
||||
{
|
||||
*start = (unsigned char*)(&gmbuf[pcm.len*curbuf]);
|
||||
*size = BUF_SIZE*sizeof(short);
|
||||
}
|
||||
|
||||
int pcm_submit(void)
|
||||
{
|
||||
|
|
@ -66,25 +88,36 @@ int pcm_submit(void)
|
|||
if (!sound) {
|
||||
pcm.pos = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (pcm.pos >= pcm.len) {
|
||||
curbuf = (curbuf + 1) % N_BUFS;
|
||||
pcm.buf = buf + pcm.len * curbuf;
|
||||
pcm.pos = 0;
|
||||
if (pcm.pos < pcm.len) return 1;
|
||||
|
||||
// gotta convert the 8 bit buffer to 16
|
||||
for(i=0; i<pcm.len;i++)
|
||||
gmbuf[i+pcm.len*curbuf] = (pcm.buf[i]<<8)-0x8000;
|
||||
}
|
||||
#ifndef ONEBUF
|
||||
curbuf = (curbuf + 1) % N_BUFS;
|
||||
pcm.buf = buf + pcm.len * curbuf;
|
||||
#endif
|
||||
pcm.pos = 0;
|
||||
|
||||
// gotta convert the 8 bit buffer to 16
|
||||
for(i=0; i<pcm.len;i++)
|
||||
#ifdef ONEBUF
|
||||
gmbuf[i] = (pcm.buf[i]<<8)-0x8000;
|
||||
#else
|
||||
gmbuf[i+pcm.len*curbuf] = (pcm.buf[i]<<8)-0x8000;
|
||||
#endif
|
||||
|
||||
if(newly_started)
|
||||
{
|
||||
rb->pcm_play_data(&get_more);
|
||||
newly_started = false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
if(newly_started)
|
||||
{
|
||||
rb->pcm_play_data(&get_more);
|
||||
newly_started = false;
|
||||
}
|
||||
|
||||
// this while loop and done play are in place to make sure the sound timing is correct(although it's not)
|
||||
#ifdef ONEBUF
|
||||
while(doneplay==0) rb->yield();
|
||||
doneplay=0;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
static byte buf1_unal[(BUF_SIZE / sizeof(short)) + 2]; // to make sure 4 byte aligned
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue