mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-05 14:57:46 -04:00
1.10 release
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@23 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
b30a8e675a
commit
598e7c06cd
8 changed files with 359 additions and 50 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "asmutils.h"
|
#include "asmutils.h"
|
||||||
|
#include "../../Pico/PicoInt.h"
|
||||||
|
|
||||||
/* we will need some gp2x internals here */
|
/* we will need some gp2x internals here */
|
||||||
extern volatile unsigned short *gp2x_memregs; /* from minimal library rlyeh */
|
extern volatile unsigned short *gp2x_memregs; /* from minimal library rlyeh */
|
||||||
|
@ -20,6 +21,9 @@ extern volatile unsigned long *gp2x_memregl;
|
||||||
static unsigned char *shared_mem = 0;
|
static unsigned char *shared_mem = 0;
|
||||||
static _940_data_t *shared_data = 0;
|
static _940_data_t *shared_data = 0;
|
||||||
static _940_ctl_t *shared_ctl = 0;
|
static _940_ctl_t *shared_ctl = 0;
|
||||||
|
static unsigned char *mp3_mem = 0;
|
||||||
|
|
||||||
|
#define MP3_SIZE_MAX (0x1000000 - 4*640*480)
|
||||||
|
|
||||||
int crashed_940 = 0;
|
int crashed_940 = 0;
|
||||||
|
|
||||||
|
@ -321,6 +325,12 @@ void YM2612Init_940(int baseclock, int rate)
|
||||||
shared_data = (_940_data_t *) (shared_mem+0x100000);
|
shared_data = (_940_data_t *) (shared_mem+0x100000);
|
||||||
/* this area must not get buffered on either side */
|
/* this area must not get buffered on either side */
|
||||||
shared_ctl = (_940_ctl_t *) (shared_mem+0x200000);
|
shared_ctl = (_940_ctl_t *) (shared_mem+0x200000);
|
||||||
|
mp3_mem = (unsigned char *) mmap(0, MP3_SIZE_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x3000000);
|
||||||
|
if (mp3_mem == MAP_FAILED)
|
||||||
|
{
|
||||||
|
printf("mmap(mp3_mem) failed with %i\n", errno);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
crashed_940 = 1;
|
crashed_940 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,9 +411,70 @@ void YM2612ResetChip_940(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void mix_samples(short *dest_buf, int *ym_buf, short *mp3_buf, int len, int stereo)
|
||||||
|
{
|
||||||
|
if (mp3_buf)
|
||||||
|
{
|
||||||
|
if (stereo)
|
||||||
|
{
|
||||||
|
for (; len > 0; len--)
|
||||||
|
{
|
||||||
|
int l, r, lm, rm;
|
||||||
|
l = r = *dest_buf;
|
||||||
|
l += *ym_buf++; r += *ym_buf++;
|
||||||
|
lm = *mp3_buf++; rm = *mp3_buf++;
|
||||||
|
l += lm - lm/2; r += rm - rm/2;
|
||||||
|
Limit( l, MAXOUT, MINOUT );
|
||||||
|
Limit( r, MAXOUT, MINOUT );
|
||||||
|
*dest_buf++ = l; *dest_buf++ = r;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (; len > 0; len--)
|
||||||
|
{
|
||||||
|
// TODO: normalize
|
||||||
|
int l = *ym_buf++;
|
||||||
|
l += *dest_buf;
|
||||||
|
l += *mp3_buf++;
|
||||||
|
Limit( l, MAXOUT, MINOUT );
|
||||||
|
*dest_buf++ = l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (stereo)
|
||||||
|
{
|
||||||
|
for (; len > 0; len--)
|
||||||
|
{
|
||||||
|
int l, r;
|
||||||
|
l = r = *dest_buf;
|
||||||
|
l += *ym_buf++, r += *ym_buf++;
|
||||||
|
Limit( l, MAXOUT, MINOUT );
|
||||||
|
Limit( r, MAXOUT, MINOUT );
|
||||||
|
*dest_buf++ = l; *dest_buf++ = r;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (; len > 0; len--)
|
||||||
|
{
|
||||||
|
int l = *ym_buf++;
|
||||||
|
l += *dest_buf;
|
||||||
|
Limit( l, MAXOUT, MINOUT );
|
||||||
|
*dest_buf++ = l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// here we assume that length is different between games, but constant in one game
|
||||||
|
|
||||||
|
static FILE *loaded_mp3 = 0;
|
||||||
|
|
||||||
void YM2612UpdateOne_940(short *buffer, int length, int stereo)
|
void YM2612UpdateOne_940(short *buffer, int length, int stereo)
|
||||||
{
|
{
|
||||||
int i, *mix_buffer = shared_data->mix_buffer;
|
int cdda_on, *ym_buffer = shared_data->mix_buffer, mp3_job = 0;
|
||||||
|
static int mp3_samples_ready = 0, mp3_buffer_offs = 0;
|
||||||
|
static int mp3_play_bufsel = 1;
|
||||||
|
|
||||||
//printf("YM2612UpdateOne_940()\n");
|
//printf("YM2612UpdateOne_940()\n");
|
||||||
if (shared_ctl->busy) wait_busy_940();
|
if (shared_ctl->busy) wait_busy_940();
|
||||||
|
@ -413,24 +484,29 @@ void YM2612UpdateOne_940(short *buffer, int length, int stereo)
|
||||||
// printf("%i ", shared_ctl->vstarts[i]);
|
// printf("%i ", shared_ctl->vstarts[i]);
|
||||||
//printf(")\n");
|
//printf(")\n");
|
||||||
|
|
||||||
|
// emulatind MCD, cdda enabled in config, not data track, CDC is reading, playback was started, track not ended
|
||||||
|
cdda_on = (PicoMCD & 1) && (currentConfig.EmuOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) &&
|
||||||
|
(Pico_mcd->scd.Status_CDC & 1) && loaded_mp3 && shared_ctl->mp3_offs < shared_ctl->mp3_len;
|
||||||
|
|
||||||
/* mix data from previous go */
|
/* mix data from previous go */
|
||||||
if (stereo) {
|
if (cdda_on && mp3_samples_ready >= length)
|
||||||
int *mb = mix_buffer;
|
{
|
||||||
for (i = length; i > 0; i--) {
|
if (1152 - mp3_buffer_offs >= length) {
|
||||||
int l, r;
|
mix_samples(buffer, ym_buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, length, stereo);
|
||||||
l = r = *buffer;
|
|
||||||
l += *mb++, r += *mb++;
|
mp3_buffer_offs += length;
|
||||||
Limit( l, MAXOUT, MINOUT );
|
|
||||||
Limit( r, MAXOUT, MINOUT );
|
|
||||||
*buffer++ = l; *buffer++ = r;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < length; i++) {
|
// collect from both buffers..
|
||||||
int l = mix_buffer[i];
|
int left = 1152 - mp3_buffer_offs;
|
||||||
l += buffer[i];
|
mix_samples(buffer, ym_buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, left, stereo);
|
||||||
Limit( l, MAXOUT, MINOUT );
|
mp3_play_bufsel ^= 1;
|
||||||
buffer[i] = l;
|
mp3_buffer_offs = length - left;
|
||||||
|
mix_samples(buffer + left * 2, ym_buffer + left * 2,
|
||||||
|
shared_data->mp3_buffer[mp3_play_bufsel], mp3_buffer_offs, stereo);
|
||||||
}
|
}
|
||||||
|
mp3_samples_ready -= length;
|
||||||
|
} else {
|
||||||
|
mix_samples(buffer, ym_buffer, 0, length, stereo);
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("new writes: %i\n", writebuff_ptr);
|
//printf("new writes: %i\n", writebuff_ptr);
|
||||||
|
@ -441,12 +517,56 @@ void YM2612UpdateOne_940(short *buffer, int length, int stereo)
|
||||||
}
|
}
|
||||||
writebuff_ptr = 0;
|
writebuff_ptr = 0;
|
||||||
|
|
||||||
/* give 940 another job */
|
/* give 940 ym job */
|
||||||
shared_ctl->writebuffsel ^= 1;
|
shared_ctl->writebuffsel ^= 1;
|
||||||
shared_ctl->length = length;
|
shared_ctl->length = length;
|
||||||
shared_ctl->stereo = stereo;
|
shared_ctl->stereo = stereo;
|
||||||
add_job_940(JOB940_YM2612UPDATEONE, 0);
|
|
||||||
|
// make sure we will have enough mp3 samples next frame
|
||||||
|
if (cdda_on && mp3_samples_ready < length)
|
||||||
|
{
|
||||||
|
shared_ctl->mp3_buffsel ^= 1;
|
||||||
|
mp3_job = JOB940_MP3DECODE;
|
||||||
|
mp3_samples_ready += 1152;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_job_940(JOB940_YM2612UPDATEONE, mp3_job);
|
||||||
//spend_cycles(512);
|
//spend_cycles(512);
|
||||||
//printf("SRCPND: %08lx, INTMODE: %08lx, INTMASK: %08lx, INTPEND: %08lx\n",
|
//printf("SRCPND: %08lx, INTMODE: %08lx, INTMASK: %08lx, INTPEND: %08lx\n",
|
||||||
// gp2x_memregl[0x4500>>2], gp2x_memregl[0x4504>>2], gp2x_memregl[0x4508>>2], gp2x_memregl[0x4510>>2]);
|
// gp2x_memregl[0x4500>>2], gp2x_memregl[0x4504>>2], gp2x_memregl[0x4508>>2], gp2x_memregl[0x4510>>2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************/
|
||||||
|
|
||||||
|
void mp3_start_play(FILE *f, int pos) // pos is 0-1023
|
||||||
|
{
|
||||||
|
int byte_offs = 0;
|
||||||
|
|
||||||
|
if (!(currentConfig.EmuOpt&0x800)) { // cdda disabled?
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loaded_mp3 != f)
|
||||||
|
{
|
||||||
|
printf("loading mp3... "); fflush(stdout);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
fread(mp3_mem, 1, MP3_SIZE_MAX, f);
|
||||||
|
if (feof(f)) printf("done.\n");
|
||||||
|
else printf("done. mp3 too large, not all data loaded.\n");
|
||||||
|
shared_ctl->mp3_len = ftell(f);
|
||||||
|
loaded_mp3 = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// seek..
|
||||||
|
if (pos) {
|
||||||
|
byte_offs = (shared_ctl->mp3_len << 6) >> 10;
|
||||||
|
byte_offs *= pos;
|
||||||
|
byte_offs >>= 6;
|
||||||
|
}
|
||||||
|
printf("mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len);
|
||||||
|
|
||||||
|
shared_ctl->mp3_offs = byte_offs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,8 @@ OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/i
|
||||||
../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o
|
../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o
|
||||||
# unzip
|
# unzip
|
||||||
OBJS += ../../unzip/unzip.o
|
OBJS += ../../unzip/unzip.o
|
||||||
|
# mp3
|
||||||
|
OBJS += mp3.o
|
||||||
# CPU cores
|
# CPU cores
|
||||||
ifeq "$(use_musashi)" "1"
|
ifeq "$(use_musashi)" "1"
|
||||||
DEFINC += -DEMU_M68K
|
DEFINC += -DEMU_M68K
|
||||||
|
@ -78,13 +80,14 @@ DEFINC += -D_USE_DRZ80
|
||||||
OBJS += ../../cpu/DrZ80/drz80.o
|
OBJS += ../../cpu/DrZ80/drz80.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
all: PicoDrive.gpe
|
all: PicoDrive.gpe
|
||||||
|
|
||||||
PicoDrive.gpe : $(OBJS)
|
PicoDrive.gpe : $(OBJS) helix/helix_mp3.a
|
||||||
@echo $@
|
@echo $@
|
||||||
@$(GCC) $(COPT) $(OBJS) $(PRELIBS) -lm -o $@
|
@$(GCC) -o $@ $(COPT) $^ -lm
|
||||||
@$(STRIP) $@
|
@$(STRIP) $@
|
||||||
# @$(GCC) $(COPT) $(OBJS) $(PRELIBS) -lm -o PicoDrive_.gpe
|
# @$(GCC) $(COPT) $(OBJS) -lm -o PicoDrive_.gpe
|
||||||
# @gpecomp PicoDrive_.gpe $@
|
# @gpecomp PicoDrive_.gpe $@
|
||||||
ifeq "$(up)" "1"
|
ifeq "$(up)" "1"
|
||||||
@cmd //C copy $@ \\\\10.0.1.2\\gp2x\\mnt\\sd\\games\\PicoDrive\\
|
@cmd //C copy $@ \\\\10.0.1.2\\gp2x\\mnt\\sd\\games\\PicoDrive\\
|
||||||
|
@ -98,7 +101,7 @@ up:
|
||||||
|
|
||||||
testrefr.gpe : test.o gp2x.o asmutils.o
|
testrefr.gpe : test.o gp2x.o asmutils.o
|
||||||
@echo $@
|
@echo $@
|
||||||
@$(GCC) $(COPT) $^ $(PRELIBS) -o $@
|
@$(GCC) $(COPT) $^ -o $@
|
||||||
@$(STRIP) $@
|
@$(STRIP) $@
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
|
@ -126,6 +129,10 @@ testrefr.gpe : test.o gp2x.o asmutils.o
|
||||||
@echo building Cyclone...
|
@echo building Cyclone...
|
||||||
@make -C ../../cpu/Cyclone/proj -f Makefile.linux
|
@make -C ../../cpu/Cyclone/proj -f Makefile.linux
|
||||||
|
|
||||||
|
# build helix libs
|
||||||
|
helix/helix_mp3.a:
|
||||||
|
make -C helix
|
||||||
|
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
clean: tidy
|
clean: tidy
|
||||||
|
@ -139,6 +146,20 @@ clean_prof:
|
||||||
find ../.. -name '*.gcno' -delete
|
find ../.. -name '*.gcno' -delete
|
||||||
find ../.. -name '*.gcda' -delete
|
find ../.. -name '*.gcda' -delete
|
||||||
|
|
||||||
|
# ----------- release -----------
|
||||||
|
ifneq ($(findstring rel,$(MAKECMDGOALS)),)
|
||||||
|
ifeq ($(VER),)
|
||||||
|
$(error need VER)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
rel: PicoDrive.gpe code940/code940.bin ../readme.txt config.txt
|
||||||
|
zip -9 -j ../../PicoDrive_$(VER).zip $^ mmuhack.o
|
||||||
|
|
||||||
|
code940/code940.bin:
|
||||||
|
make -C code940/
|
||||||
|
|
||||||
|
|
||||||
# test
|
# test
|
||||||
usbjoy.o : usbjoy.c
|
usbjoy.o : usbjoy.c
|
||||||
@echo $<
|
@echo $<
|
||||||
|
|
10
gp2x/emu.c
10
gp2x/emu.c
|
@ -187,11 +187,11 @@ static int cd_check(char *ext, char **bios_file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* it seems we have a CD image here. Try to detect region and load a suitable BIOS now.. */
|
/* it seems we have a CD image here. Try to detect region and load a suitable BIOS now.. */
|
||||||
fseek(cd_f, (type == 1) ? 0x100 : 0x110, SEEK_SET);
|
fseek(cd_f, (type == 1) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET);
|
||||||
fread(buf, 1, 1, cd_f);
|
fread(buf, 1, 1, cd_f);
|
||||||
fclose(cd_f);
|
fclose(cd_f);
|
||||||
|
|
||||||
if (buf[0] == 0x64) region = 4; // EU
|
if (buf[0] == 0x64) region = 8; // EU
|
||||||
if (buf[0] == 0xa1) region = 1; // JAP
|
if (buf[0] == 0xa1) region = 1; // JAP
|
||||||
|
|
||||||
printf("detected %s Sega/Mega CD image with %s region\n",
|
printf("detected %s Sega/Mega CD image with %s region\n",
|
||||||
|
@ -452,9 +452,9 @@ int emu_ReadConfig(int game)
|
||||||
// set default config
|
// set default config
|
||||||
memset(¤tConfig, 0, sizeof(currentConfig));
|
memset(¤tConfig, 0, sizeof(currentConfig));
|
||||||
currentConfig.lastRomFile[0] = 0;
|
currentConfig.lastRomFile[0] = 0;
|
||||||
currentConfig.EmuOpt = 0x1f;
|
currentConfig.EmuOpt = 0x1f | 0xc00; // | cd_leds | cd_cdda
|
||||||
currentConfig.PicoOpt = 0x0f;
|
currentConfig.PicoOpt = 0x0f | 0x200; // | use_940
|
||||||
currentConfig.PsndRate = 22050;
|
currentConfig.PsndRate = 44100;
|
||||||
currentConfig.PicoRegion = 0; // auto
|
currentConfig.PicoRegion = 0; // auto
|
||||||
currentConfig.Frameskip = -1; // auto
|
currentConfig.Frameskip = -1; // auto
|
||||||
currentConfig.CPUclock = 200;
|
currentConfig.CPUclock = 200;
|
||||||
|
|
|
@ -630,7 +630,8 @@ static void cd_menu_loop_options(void)
|
||||||
if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options
|
if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options
|
||||||
switch (menu_sel) {
|
switch (menu_sel) {
|
||||||
case 3: tmp_opts.EmuOpt ^=0x400; break;
|
case 3: tmp_opts.EmuOpt ^=0x400; break;
|
||||||
case 4: return;
|
case 4: tmp_opts.EmuOpt ^=0x800; break;
|
||||||
|
case 5: return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(inp & (GP2X_X|GP2X_A)) return;
|
if(inp & (GP2X_X|GP2X_A)) return;
|
||||||
|
|
BIN
gp2x/mmuhack.o
Normal file
BIN
gp2x/mmuhack.o
Normal file
Binary file not shown.
|
@ -12,6 +12,9 @@
|
||||||
#include "../gp2x/gp2x.h"
|
#include "../gp2x/gp2x.h"
|
||||||
#include "../gp2x/emu.h"
|
#include "../gp2x/emu.h"
|
||||||
#include "../gp2x/menu.h"
|
#include "../gp2x/menu.h"
|
||||||
|
#include "../gp2x/code940/940shared.h"
|
||||||
|
#include "../gp2x/helix/pub/mp3dec.h"
|
||||||
|
#include "../../Pico/PicoInt.h"
|
||||||
|
|
||||||
|
|
||||||
static YM2612 ym2612;
|
static YM2612 ym2612;
|
||||||
|
@ -20,6 +23,14 @@ YM2612 *ym2612_940 = &ym2612;
|
||||||
int mix_buffer_[44100/50*2]; /* this is where the YM2612 samples will be mixed to */
|
int mix_buffer_[44100/50*2]; /* this is where the YM2612 samples will be mixed to */
|
||||||
int *mix_buffer = mix_buffer_;
|
int *mix_buffer = mix_buffer_;
|
||||||
|
|
||||||
|
static _940_data_t shared_data_;
|
||||||
|
static _940_ctl_t shared_ctl_;
|
||||||
|
static _940_data_t *shared_data = &shared_data_;
|
||||||
|
static _940_ctl_t *shared_ctl = &shared_ctl_;
|
||||||
|
|
||||||
|
unsigned char *mp3_mem = 0;
|
||||||
|
|
||||||
|
#define MP3_SIZE_MAX (0x1000000 - 4*640*480)
|
||||||
|
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
|
|
||||||
|
@ -73,6 +84,8 @@ void YM2612PicoStateLoad_940(void)
|
||||||
|
|
||||||
void YM2612Init_940(int baseclock, int rate)
|
void YM2612Init_940(int baseclock, int rate)
|
||||||
{
|
{
|
||||||
|
mp3_mem = malloc(MP3_SIZE_MAX);
|
||||||
|
|
||||||
YM2612Init_(baseclock, rate);
|
YM2612Init_(baseclock, rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,30 +96,177 @@ void YM2612ResetChip_940(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void YM2612UpdateOne_940(short *buffer, int length, int stereo)
|
static void mix_samples(short *dest_buf, int *ym_buf, short *mp3_buf, int len, int stereo)
|
||||||
{
|
{
|
||||||
int i;
|
if (mp3_buf)
|
||||||
|
{
|
||||||
YM2612UpdateOne_(buffer, length, stereo);
|
if (stereo)
|
||||||
|
{
|
||||||
/* mix data */
|
for (; len > 0; len--)
|
||||||
if (stereo) {
|
{
|
||||||
int *mb = mix_buffer;
|
|
||||||
for (i = length; i > 0; i--) {
|
|
||||||
int l, r;
|
int l, r;
|
||||||
l = r = *buffer;
|
l = r = *dest_buf;
|
||||||
l += *mb++, r += *mb++;
|
l += *ym_buf++; r += *ym_buf++;
|
||||||
|
l += *mp3_buf++; r += *mp3_buf++;
|
||||||
Limit( l, MAXOUT, MINOUT );
|
Limit( l, MAXOUT, MINOUT );
|
||||||
Limit( r, MAXOUT, MINOUT );
|
Limit( r, MAXOUT, MINOUT );
|
||||||
*buffer++ = l; *buffer++ = r;
|
*dest_buf++ = l; *dest_buf++ = r;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < length; i++) {
|
for (; len > 0; len--)
|
||||||
int l = mix_buffer[i];
|
{
|
||||||
l += buffer[i];
|
int l = *ym_buf++;
|
||||||
|
l += *dest_buf;
|
||||||
|
l += *mp3_buf++;
|
||||||
Limit( l, MAXOUT, MINOUT );
|
Limit( l, MAXOUT, MINOUT );
|
||||||
buffer[i] = l;
|
*dest_buf++ = l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (stereo)
|
||||||
|
{
|
||||||
|
for (; len > 0; len--)
|
||||||
|
{
|
||||||
|
int l, r;
|
||||||
|
l = r = *dest_buf;
|
||||||
|
l += *ym_buf++, r += *ym_buf++;
|
||||||
|
Limit( l, MAXOUT, MINOUT );
|
||||||
|
Limit( r, MAXOUT, MINOUT );
|
||||||
|
*dest_buf++ = l; *dest_buf++ = r;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (; len > 0; len--)
|
||||||
|
{
|
||||||
|
int l = *ym_buf++;
|
||||||
|
l += *dest_buf;
|
||||||
|
Limit( l, MAXOUT, MINOUT );
|
||||||
|
*dest_buf++ = l;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static void local_decode(void)
|
||||||
|
{
|
||||||
|
int mp3_offs = shared_ctl->mp3_offs;
|
||||||
|
unsigned char *readPtr = mp3_mem + mp3_offs;
|
||||||
|
int bytesLeft = shared_ctl->mp3_len - mp3_offs;
|
||||||
|
int offset; // frame offset from readPtr
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
if (bytesLeft <= 0) return; // EOF, nothing to do
|
||||||
|
|
||||||
|
offset = MP3FindSyncWord(readPtr, bytesLeft);
|
||||||
|
if (offset < 0) {
|
||||||
|
shared_ctl->mp3_offs = shared_ctl->mp3_len;
|
||||||
|
return; // EOF
|
||||||
|
}
|
||||||
|
readPtr += offset;
|
||||||
|
bytesLeft -= offset;
|
||||||
|
|
||||||
|
err = MP3Decode(shared_data->mp3dec, &readPtr, &bytesLeft,
|
||||||
|
shared_data->mp3_buffer[shared_ctl->mp3_buffsel], 0);
|
||||||
|
if (err) {
|
||||||
|
if (err == ERR_MP3_INDATA_UNDERFLOW) {
|
||||||
|
shared_ctl->mp3_offs = shared_ctl->mp3_len; // EOF
|
||||||
|
return;
|
||||||
|
} else if (err <= -6 && err >= -12) {
|
||||||
|
// ERR_MP3_INVALID_FRAMEHEADER, ERR_MP3_INVALID_*
|
||||||
|
// just try to skip the offending frame..
|
||||||
|
readPtr++;
|
||||||
|
}
|
||||||
|
shared_ctl->mp3_errors++;
|
||||||
|
shared_ctl->mp3_lasterr = err;
|
||||||
|
}
|
||||||
|
shared_ctl->mp3_offs = readPtr - mp3_mem;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static FILE *loaded_mp3 = 0;
|
||||||
|
|
||||||
|
void YM2612UpdateOne_940(short *buffer, int length, int stereo)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
int cdda_on, *ym_buffer = mix_buffer;
|
||||||
|
static int mp3_samples_ready = 0, mp3_buffer_offs = 0;
|
||||||
|
static int mp3_play_bufsel = 1;
|
||||||
|
|
||||||
|
|
||||||
|
YM2612UpdateOne_(buffer, length, stereo); // really writes to mix_buffer
|
||||||
|
|
||||||
|
// emulatind MCD, not data track, CDC is reading, playback was started, track not ended
|
||||||
|
cdda_on = (PicoMCD & 1) && !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1)
|
||||||
|
&& loaded_mp3 && shared_ctl->mp3_offs < shared_ctl->mp3_len;
|
||||||
|
|
||||||
|
/* mix data from previous go */
|
||||||
|
if (cdda_on && mp3_samples_ready >= length)
|
||||||
|
{
|
||||||
|
if (1152 - mp3_buffer_offs >= length) {
|
||||||
|
mix_samples(buffer, ym_buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, length, stereo);
|
||||||
|
|
||||||
|
mp3_buffer_offs += length;
|
||||||
|
} else {
|
||||||
|
// collect from both buffers..
|
||||||
|
int left = 1152 - mp3_buffer_offs;
|
||||||
|
mix_samples(buffer, ym_buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, left, stereo);
|
||||||
|
mp3_play_bufsel ^= 1;
|
||||||
|
mp3_buffer_offs = length - left;
|
||||||
|
mix_samples(buffer + left * 2, ym_buffer + left * 2,
|
||||||
|
shared_data->mp3_buffer[mp3_play_bufsel], mp3_buffer_offs, stereo);
|
||||||
|
}
|
||||||
|
mp3_samples_ready -= length;
|
||||||
|
} else {
|
||||||
|
mix_samples(buffer, ym_buffer, 0, length, stereo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure we will have enough mp3 samples next frame
|
||||||
|
if (cdda_on && mp3_samples_ready < length)
|
||||||
|
{
|
||||||
|
shared_ctl->mp3_buffsel ^= 1;
|
||||||
|
local_decode();
|
||||||
|
mp3_samples_ready += 1152;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
YM2612UpdateOne_(buffer, length, stereo); // really writes to mix_buffer
|
||||||
|
|
||||||
|
mix_samples(buffer, mix_buffer, 0, length, stereo);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************/
|
||||||
|
|
||||||
|
void mp3_start_play(FILE *f, int pos) // pos is 0-1023
|
||||||
|
{
|
||||||
|
int byte_offs = 0;
|
||||||
|
|
||||||
|
if (loaded_mp3 != f)
|
||||||
|
{
|
||||||
|
printf("loading mp3... "); fflush(stdout);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
fread(mp3_mem, 1, MP3_SIZE_MAX, f);
|
||||||
|
if (feof(f)) printf("done.\n");
|
||||||
|
else printf("done. mp3 too large, not all data loaded.\n");
|
||||||
|
shared_ctl->mp3_len = ftell(f);
|
||||||
|
loaded_mp3 = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// seek..
|
||||||
|
if (pos) {
|
||||||
|
byte_offs = (shared_ctl->mp3_len << 6) >> 10;
|
||||||
|
byte_offs *= pos;
|
||||||
|
byte_offs >>= 6;
|
||||||
|
}
|
||||||
|
printf("mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len);
|
||||||
|
|
||||||
|
shared_ctl->mp3_offs = byte_offs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/i
|
||||||
../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o
|
../../zlib/deflate.o ../../zlib/crc32.o ../../zlib/adler32.o ../../zlib/zutil.o ../../zlib/compress.o
|
||||||
# unzip
|
# unzip
|
||||||
OBJS += ../../unzip/unzip.o
|
OBJS += ../../unzip/unzip.o
|
||||||
|
# mp3
|
||||||
|
OBJS += ../gp2x/mp3.o
|
||||||
# CPU cores
|
# CPU cores
|
||||||
DEFINC += -DEMU_M68K
|
DEFINC += -DEMU_M68K
|
||||||
OBJS += ../../cpu/musashi/m68kcpu.o ../../cpu/musashi/m68kopac.o ../../cpu/musashi/m68kopdm.o \
|
OBJS += ../../cpu/musashi/m68kcpu.o ../../cpu/musashi/m68kopac.o ../../cpu/musashi/m68kopdm.o \
|
||||||
|
@ -62,7 +64,7 @@ tidy:
|
||||||
|
|
||||||
PicoDrive : $(OBJS)
|
PicoDrive : $(OBJS)
|
||||||
@echo $@
|
@echo $@
|
||||||
@$(GCC) $(COPT) $(OBJS) $(LDFLAGS) -lm -o $@
|
@$(GCC) $(COPT) $(OBJS) ../gp2x/helix/helix_mp3_x86.a $(LDFLAGS) -lm -o $@
|
||||||
|
|
||||||
|
|
||||||
../../cpu/mz80/mz80.o : ../../cpu/mz80/mz80.asm
|
../../cpu/mz80/mz80.o : ../../cpu/mz80/mz80.asm
|
||||||
|
|
|
@ -298,6 +298,11 @@ void gp2x_sound_write(void *buff, int len)
|
||||||
write(sounddev, buff, len);
|
write(sounddev, buff, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gp2x_sound_sync(void)
|
||||||
|
{
|
||||||
|
ioctl(sounddev, SOUND_PCM_SYNC, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void gp2x_sound_volume(int l, int r)
|
void gp2x_sound_volume(int l, int r)
|
||||||
{
|
{
|
||||||
l=l<0?0:l; l=l>255?255:l; r=r<0?0:r; r=r>255?255:r;
|
l=l<0?0:l; l=l>255?255:l; r=r<0?0:r; r=r>255?255:r;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue