PCM sound, refactored code940

git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@27 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2007-02-04 17:15:31 +00:00
parent 98c9d8d9e7
commit 49fe50f04c
10 changed files with 150 additions and 168 deletions

View file

@ -14,6 +14,9 @@
#include "asmutils.h" #include "asmutils.h"
#include "../../Pico/PicoInt.h" #include "../../Pico/PicoInt.h"
// tmp
#include "../../Pico/sound/mix.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 */
extern volatile unsigned long *gp2x_memregl; extern volatile unsigned long *gp2x_memregl;
@ -223,6 +226,7 @@ int YM2612PicoTick_940(int n)
return 0; return 0;
} }
static int g_busy = 10;
static void wait_busy_940(void) static void wait_busy_940(void)
{ {
@ -239,8 +243,9 @@ static void wait_busy_940(void)
} }
printf("wait iterations: %i\n", i); printf("wait iterations: %i\n", i);
#else #else
for (i = 0; shared_ctl->busy && i < 0x10000; i++) for (i = 0; /*shared_ctl->busy*/gp2x_memregs[0x3B3E>>1] && i < 0x10000; i++)
spend_cycles(8*1024); // tested to be best for mp3 dec spend_cycles(8*1024); // tested to be best for mp3 dec
//printf("i = 0x%x\n", i);
if (i < 0x10000) return; if (i < 0x10000) return;
/* 940 crashed */ /* 940 crashed */
@ -248,6 +253,19 @@ static void wait_busy_940(void)
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
printf("%i ", shared_ctl->vstarts[i]); printf("%i ", shared_ctl->vstarts[i]);
printf(")\n"); printf(")\n");
printf("irq pending flags: DUALCPU %04x (see 15?), SRCPND %08lx (see 26), INTPND %08lx\n",
gp2x_memregs[0x3b46>>1], gp2x_memregl[0x4500>>2], gp2x_memregl[0x4510>>2]);
printf("last irq PC: %08x, lastjob: 0x%03x, busy: %x, lastbusy: %x, g_busy: %x\n", shared_ctl->last_irq_pc,
shared_ctl->lastjob, gp2x_memregs[0x3B3E>>1]/*shared_ctl->busy*/, shared_ctl->lastbusy, g_busy);
printf("trying to interrupt..\n");
gp2x_memregs[0x3B3E>>1] = 0xffff;
for (i = 0; /*shared_ctl->busy*/gp2x_memregs[0x3B3E>>1] && i < 0x10000; i++)
spend_cycles(8*1024);
printf("i = 0x%x\n", i);
printf("irq pending flags: DUALCPU %04x (see 15?), SRCPND %08lx (see 26), INTPND %08lx\n",
gp2x_memregs[0x3b46>>1], gp2x_memregl[0x4500>>2], gp2x_memregl[0x4510>>2]);
printf("last irq PC: %08x, lastjob: 0x%03x, busy: %x\n", shared_ctl->last_irq_pc, shared_ctl->lastjob, gp2x_memregs[0x3B3E>>1]/*shared_ctl->busy*/);
strcpy(menuErrorMsg, "940 crashed."); strcpy(menuErrorMsg, "940 crashed.");
engineState = PGS_Menu; engineState = PGS_Menu;
crashed_940 = 1; crashed_940 = 1;
@ -257,10 +275,17 @@ static void wait_busy_940(void)
static void add_job_940(int job0, int job1) static void add_job_940(int job0, int job1)
{ {
/* if (gp2x_memregs[0x3b46>>1] || shared_ctl->busy)
{
printf("!!add_job_940: irq pending flags: DUALCPU %04x (see 15?), SRCPND %08lx (see 26), INTPND %08lx, busy: %x\n",
gp2x_memregs[0x3b46>>1], gp2x_memregl[0x4500>>2], gp2x_memregl[0x4510>>2], shared_ctl->busy);
}
*/
shared_ctl->jobs[0] = job0; shared_ctl->jobs[0] = job0;
shared_ctl->jobs[1] = job1; shared_ctl->jobs[1] = job1;
shared_ctl->busy = 1; //shared_ctl->busy = ++g_busy; // 1;
gp2x_memregs[0x3B3E>>1] = 0xffff; // cause an IRQ for 940 gp2x_memregs[0x3B3E>>1] = ++g_busy; // set busy flag
// gp2x_memregs[0x3B3E>>1] = 0xffff; // cause interrupt
} }
@ -268,7 +293,7 @@ void YM2612PicoStateLoad_940(void)
{ {
int i, old_A1 = addr_A1; int i, old_A1 = addr_A1;
if (shared_ctl->busy) wait_busy_940(); if (/*shared_ctl->busy*/gp2x_memregs[0x3B3E>>1]) wait_busy_940();
// feed all the registers and update internal state // feed all the registers and update internal state
for(i = 0; i < 0x100; i++) { for(i = 0; i < 0x100; i++) {
@ -310,10 +335,8 @@ void YM2612Init_940(int baseclock, int rate)
Reset940(1, 2); Reset940(1, 2);
Pause940(1); Pause940(1);
gp2x_memregs[0x3B46>>1] = 0xffff; // clear pending DUALCPU interrupts for 940 gp2x_memregs[0x3B40>>1] = 0; // disable DUALCPU interrupts for 920
gp2x_memregs[0x3B42>>1] = 0xffff; // enable DUALCPU interrupts for 940 gp2x_memregs[0x3B42>>1] = 1; // enable DUALCPU interrupts for 940
gp2x_memregl[0x4508>>2] = ~(1<<26); // unmask DUALCPU ints in the undocumented 940's interrupt controller
if (shared_mem == NULL) if (shared_mem == NULL)
{ {
@ -388,7 +411,13 @@ void YM2612Init_940(int baseclock, int rate)
shared_ctl->rate = rate; shared_ctl->rate = rate;
shared_ctl->jobs[0] = JOB940_INITALL; shared_ctl->jobs[0] = JOB940_INITALL;
shared_ctl->jobs[1] = 0; shared_ctl->jobs[1] = 0;
shared_ctl->busy = 1; //shared_ctl->busy = 1;
gp2x_memregs[0x3B3E>>1] = 1; // set busy flag
gp2x_memregs[0x3B46>>1] = 0xffff; // clear pending DUALCPU interrupts for 940
gp2x_memregl[0x4500>>2] = 0; // clear pending IRQs in SRCPND
gp2x_memregl[0x4510>>2] = 0; // clear pending IRQs in INTPND
gp2x_memregl[0x4508>>2] = ~(1<<26); // unmask DUALCPU ints in the undocumented 940's interrupt controller
/* start the 940 */ /* start the 940 */
Reset940(0, 2); Reset940(0, 2);
@ -406,7 +435,7 @@ void YM2612ResetChip_940(void)
return; return;
} }
if (shared_ctl->busy) wait_busy_940(); if (/*shared_ctl->busy*/gp2x_memregs[0x3B3E>>1]) wait_busy_940();
internal_reset(); internal_reset();
@ -414,104 +443,93 @@ void YM2612ResetChip_940(void)
} }
static void mix_samples(short *dest_buf, int *ym_buf, short *mp3_buf, int len, int stereo) //extern int pcm_buffer[2*44100/50];
/*
static void mix_samples(int *dest_buf, short *mp3_buf, int len, int stereo)
{ {
if (mp3_buf) // int *pcm = pcm_buffer + offset * 2;
if (stereo)
{ {
if (stereo) for (; len > 0; len--)
{ {
for (; len > 0; len--) int lm, rm;
{ lm = *mp3_buf++; rm = *mp3_buf++;
int l, r, lm, rm; *dest_buf++ += lm - lm/2; *dest_buf++ += rm - rm/2;
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 {
else for (; len > 0; len--)
{
if (stereo)
{ {
for (; len > 0; len--) int l = *mp3_buf++;
{ *dest_buf++ = l - l/2;
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 // here we assume that length is different between games, but constant in one game
static int mp3_samples_ready = 0, mp3_buffer_offs = 0; static int mp3_samples_ready = 0, mp3_buffer_offs = 0;
static int mp3_play_bufsel = 0; static int mp3_play_bufsel = 0;
void YM2612UpdateOne_940(short *buffer, int length, int stereo) int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty)
{ {
int cdda_on, *ym_buffer = shared_data->mix_buffer, mp3_job = 0; int length_mp3 = Pico.m.pal ? 44100/50 : 44100/60; // mp3s are locked to 44100Hz stereo
int *ym_buf = shared_data->mix_buffer;
// int *dest_buf = buffer;
int cdda_on, mp3_job = 0;
// int len;
// emulating CD, enabled in opts, not data track, CDC is reading, playback was started, track not ended
cdda_on = (PicoMCD & 1) && (PicoOpt & 0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) &&
(Pico_mcd->scd.Status_CDC & 1) && loaded_mp3;
//printf("YM2612UpdateOne_940()\n"); //printf("YM2612UpdateOne_940()\n");
if (shared_ctl->busy) wait_busy_940(); if (/*shared_ctl->busy*/gp2x_memregs[0x3B3E>>1]) wait_busy_940();
//printf("940 (cnt: %i, wc: %i, ve: ", shared_ctl->loopc, shared_ctl->waitc); // track ended?
//for (i = 0; i < 8; i++) cdda_on = cdda_on && shared_ctl->mp3_offs < shared_ctl->mp3_len;
// printf("%i ", shared_ctl->vstarts[i]);
//printf(")\n");
// emulatind MCD, cdda enabled in config, not data track, CDC is reading, playback was started, track not ended // mix in ym buffer
cdda_on = (PicoMCD & 1) && (currentConfig.EmuOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) && if (is_buf_empty) memcpy32(buffer, ym_buf, length<<stereo);
(Pico_mcd->scd.Status_CDC & 1) && loaded_mp3 && shared_ctl->mp3_offs < shared_ctl->mp3_len; // else TODO
/* mix data from previous go */ // for (len = length << stereo; len > 0; len--)
if (cdda_on && mp3_samples_ready >= length) // {
// *dest_buf++ += *ym_buf++;
// }
/* mix mp3 data, only stereo */
if (cdda_on && mp3_samples_ready >= length_mp3)
{ {
if (1152 - mp3_buffer_offs >= length) { int shr = 0;
mix_samples(buffer, ym_buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, length, stereo); void (*mix_samples)(int *dest_buf, short *mp3_buf, int count) = mix_16h_to_32;
if (PsndRate == 22050) { mix_samples = mix_16h_to_32_s1; shr = 1; }
else if (PsndRate == 11025) { mix_samples = mix_16h_to_32_s2; shr = 2; }
mp3_buffer_offs += length; if (1152 - mp3_buffer_offs >= length_mp3) {
mix_samples(buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, (length_mp3>>shr)<<1);
mp3_buffer_offs += length_mp3;
} else { } else {
// collect from both buffers.. // collect from both buffers..
int left = 1152 - mp3_buffer_offs; int left = 1152 - mp3_buffer_offs;
mix_samples(buffer, ym_buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, left, stereo); if (mp3_play_bufsel == 0)
mp3_play_bufsel ^= 1; {
mp3_buffer_offs = length - left; mix_samples(buffer, shared_data->mp3_buffer[0] + mp3_buffer_offs*2, (length_mp3>>shr)<<1);
mix_samples(buffer + left * 2, ym_buffer + left * 2, mp3_buffer_offs = length_mp3 - left;
shared_data->mp3_buffer[mp3_play_bufsel], mp3_buffer_offs, stereo); mp3_play_bufsel = 1;
} else {
mix_samples(buffer, shared_data->mp3_buffer[1] + mp3_buffer_offs*2, (left>>shr)<<1);
mp3_buffer_offs = length_mp3 - left;
mix_samples(buffer + ((left>>shr)<<1),
shared_data->mp3_buffer[0], (mp3_buffer_offs>>shr)<<1);
mp3_play_bufsel = 0;
}
} }
mp3_samples_ready -= length; mp3_samples_ready -= length_mp3;
} else {
mix_samples(buffer, ym_buffer, 0, length, stereo);
} }
//printf("new writes: %i\n", writebuff_ptr);
if (shared_ctl->writebuffsel == 1) { if (shared_ctl->writebuffsel == 1) {
shared_ctl->writebuff0[writebuff_ptr] = 0xffff; shared_ctl->writebuff0[writebuff_ptr] = 0xffff;
} else { } else {
@ -525,7 +543,7 @@ void YM2612UpdateOne_940(short *buffer, int length, int stereo)
shared_ctl->stereo = stereo; shared_ctl->stereo = stereo;
// make sure we will have enough mp3 samples next frame // make sure we will have enough mp3 samples next frame
if (cdda_on && mp3_samples_ready < length) if (cdda_on && mp3_samples_ready < length_mp3)
{ {
shared_ctl->mp3_buffsel ^= 1; shared_ctl->mp3_buffsel ^= 1;
mp3_job = JOB940_MP3DECODE; mp3_job = JOB940_MP3DECODE;
@ -536,6 +554,8 @@ void YM2612UpdateOne_940(short *buffer, int length, int stereo)
//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]);
return 1;
} }
@ -551,11 +571,11 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
if (loaded_mp3 != f) if (loaded_mp3 != f)
{ {
printf("loading mp3... "); fflush(stdout); // printf("loading mp3... "); fflush(stdout);
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);
fread(mp3_mem, 1, MP3_SIZE_MAX, f); fread(mp3_mem, 1, MP3_SIZE_MAX, f);
if (feof(f)) printf("done.\n"); // if (feof(f)) printf("done.\n");
else printf("done. mp3 too large, not all data loaded.\n"); // else printf("done. mp3 too large, not all data loaded.\n");
shared_ctl->mp3_len = ftell(f); shared_ctl->mp3_len = ftell(f);
loaded_mp3 = f; loaded_mp3 = f;
} }
@ -566,7 +586,7 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
byte_offs *= pos; byte_offs *= pos;
byte_offs >>= 6; byte_offs >>= 6;
} }
printf("mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len); // printf("mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len);
shared_ctl->mp3_offs = byte_offs; shared_ctl->mp3_offs = byte_offs;

View file

@ -1,6 +1,6 @@
void YM2612Init_940(int baseclock, int rate); void YM2612Init_940(int baseclock, int rate);
void YM2612ResetChip_940(void); void YM2612ResetChip_940(void);
void YM2612UpdateOne_940(short *buffer, int length, int stereo); int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty);
int YM2612Write_940(unsigned int a, unsigned int v); int YM2612Write_940(unsigned int a, unsigned int v);
unsigned char YM2612Read_940(void); unsigned char YM2612Read_940(void);

View file

@ -41,7 +41,7 @@ OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory
# Pico - CD # Pico - CD
OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \ OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \
../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \ ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \
../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/pcm.o
# asm stuff # asm stuff
ifeq "$(asm_render)" "1" ifeq "$(asm_render)" "1"
DEFINC += -D_ASM_DRAW_C DEFINC += -D_ASM_DRAW_C
@ -56,6 +56,7 @@ DEFINC += -D_ASM_YM2612_C
OBJS += ../../Pico/sound/ym2612_asm.o OBJS += ../../Pico/sound/ym2612_asm.o
endif endif
# Pico - sound # Pico - sound
OBJS += ../../Pico/sound/mix_asm.o
OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o
# zlib # zlib
OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \ OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \
@ -94,7 +95,7 @@ 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\\
endif endif
up: up: PicoDrive.gpe
@cp -v PicoDrive.gpe /mnt/gp2x/mnt/sd/games/PicoDrive/ @cp -v PicoDrive.gpe /mnt/gp2x/mnt/sd/games/PicoDrive/
# @cmd //C copy PicoDrive.gpe \\\\10.0.1.2\\gp2x\\mnt\\sd\\games\\PicoDrive\\ # @cmd //C copy PicoDrive.gpe \\\\10.0.1.2\\gp2x\\mnt\\sd\\games\\PicoDrive\\
@ -124,6 +125,9 @@ testrefr.gpe : test.o gp2x.o asmutils.o
../../Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s ../../Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s
@echo $< @echo $<
@$(AS) $(ASOPT) $< -o $@ @$(AS) $(ASOPT) $< -o $@
../../Pico/sound/mix_asm.o : ../../Pico/sound/mix.s
@echo $<
@$(AS) $(ASOPT) $< -o $@
# build Cyclone # build Cyclone
../../cpu/Cyclone/proj/Cyclone.s : ../../cpu/Cyclone/proj/Cyclone.s :

View file

@ -10,3 +10,5 @@ void vidCpyM2_40col(void *dest, void *src);
void vidCpyM2_32col(void *dest, void *src); void vidCpyM2_32col(void *dest, void *src);
void vidCpyM2_32col_nobord(void *dest, void *src); void vidCpyM2_32col_nobord(void *dest, void *src);
void spend_cycles(int c); // utility void spend_cycles(int c); // utility
void flushcache(void);

View file

@ -3,6 +3,7 @@
@ (c) Copyright 2006, notaz @ (c) Copyright 2006, notaz
@ All Rights Reserved @ All Rights Reserved
@ vim:filetype=armasm
@ Convert 0000bbb0 ggg0rrr0 0000bbb0 ggg0rrr0 @ Convert 0000bbb0 ggg0rrr0 0000bbb0 ggg0rrr0
@ to 00000000 rrr00000 ggg00000 bbb00000 ... @ to 00000000 rrr00000 ggg00000 bbb00000 ...
@ -197,7 +198,6 @@ vidCpyM2_32col_nobord:
b vidCpyM2_32_loop_out b vidCpyM2_32_loop_out
@ test
.global spend_cycles @ c .global spend_cycles @ c
spend_cycles: spend_cycles:
@ -208,3 +208,12 @@ spend_cycles:
bpl .sc_loop bpl .sc_loop
bx lr bx lr
@ test
.global flushcache
flushcache:
swi #0x9f0002
mov pc, lr

View file

@ -276,6 +276,7 @@ int emu_ReloadRom(void)
// bios_help() ? // bios_help() ?
return 0; return 0;
} else { } else {
if (PicoMCD & 1) PicoExitMCD();
PicoMCD &= ~1; PicoMCD &= ~1;
} }
@ -374,7 +375,7 @@ int emu_ReloadRom(void)
} }
} }
gettimeofday(&noticeMsgTime, 0); gettimeofday(&noticeMsgTime, 0);
printf("PicoMCD: %x\n", PicoMCD);
// load SRAM for this ROM // load SRAM for this ROM
if(currentConfig.EmuOpt & 1) if(currentConfig.EmuOpt & 1)
emu_SaveLoadGame(1, 1); emu_SaveLoadGame(1, 1);
@ -452,8 +453,8 @@ int emu_ReadConfig(int game)
// set default config // set default config
memset(&currentConfig, 0, sizeof(currentConfig)); memset(&currentConfig, 0, sizeof(currentConfig));
currentConfig.lastRomFile[0] = 0; currentConfig.lastRomFile[0] = 0;
currentConfig.EmuOpt = 0x1f | 0xc00; // | cd_leds | cd_cdda currentConfig.EmuOpt = 0x1f | 0x400; // | cd_leds
currentConfig.PicoOpt = 0x0f | 0x200; // | use_940 currentConfig.PicoOpt = 0x0f | 0xe00; // | use_940 | cd_pcm | cd_cdda
currentConfig.PsndRate = 44100; currentConfig.PsndRate = 44100;
currentConfig.PicoRegion = 0; // auto currentConfig.PicoRegion = 0; // auto
currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP
@ -599,20 +600,20 @@ static void cd_leds(void)
// 8-bit modes // 8-bit modes
unsigned int col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0; unsigned int col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;
unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0; unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;
*(unsigned int *)((char *)gp2x_screen + 320*2+306) = *(unsigned int *)((char *)gp2x_screen + 320*2+ 4) =
*(unsigned int *)((char *)gp2x_screen + 320*3+306) = *(unsigned int *)((char *)gp2x_screen + 320*3+ 4) =
*(unsigned int *)((char *)gp2x_screen + 320*4+306) = col_g; *(unsigned int *)((char *)gp2x_screen + 320*4+ 4) = col_g;
*(unsigned int *)((char *)gp2x_screen + 320*2+312) = *(unsigned int *)((char *)gp2x_screen + 320*2+12) =
*(unsigned int *)((char *)gp2x_screen + 320*3+312) = *(unsigned int *)((char *)gp2x_screen + 320*3+12) =
*(unsigned int *)((char *)gp2x_screen + 320*4+312) = col_r; *(unsigned int *)((char *)gp2x_screen + 320*4+12) = col_r;
} else { } else {
// 16-bit modes // 16-bit modes
unsigned int *p = (unsigned int *)((short *)gp2x_screen + 320*2+306); unsigned int *p = (unsigned int *)((short *)gp2x_screen + 320*2+4);
unsigned int col_g = (old_reg & 2) ? 0x06000600 : 0; unsigned int col_g = (old_reg & 2) ? 0x06000600 : 0;
unsigned int col_r = (old_reg & 1) ? 0xc000c000 : 0; unsigned int col_r = (old_reg & 1) ? 0xc000c000 : 0;
*p++ = col_g; *p++ = col_g; p++; *p++ = col_r; *p++ = col_r; p += 320/2 - 10/2; *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += 320/2 - 12/2;
*p++ = col_g; *p++ = col_g; p++; *p++ = col_r; *p++ = col_r; p += 320/2 - 10/2; *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += 320/2 - 12/2;
*p++ = col_g; *p++ = col_g; p++; *p++ = col_r; *p++ = col_r; p += 320/2 - 10/2; *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += 320/2 - 12/2;
} }
} }

View file

@ -19,8 +19,8 @@ typedef struct {
char lastRomFile[512]; char lastRomFile[512];
int EmuOpt; // LSb->MSb: use_sram, show_fps, enable_sound, gzip_saves, int EmuOpt; // LSb->MSb: use_sram, show_fps, enable_sound, gzip_saves,
// squidgehack, save_cfg_on_exit, <unused>, 16_bit_mode // squidgehack, save_cfg_on_exit, <unused>, 16_bit_mode
// craigix_ram, confirm_save, show_cd_leds, enable_cdda // craigix_ram, confirm_save, show_cd_leds
// enable_pcm //
int PicoOpt; // used for config saving only, see Pico.h int PicoOpt; // used for config saving only, see Pico.h
int PsndRate; // ditto int PsndRate; // ditto
int PicoRegion; // ditto int PicoRegion; // ditto

View file

@ -574,7 +574,8 @@ static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_j
gp2x_text_out8(tl_x, (y+=10), "EUR BIOS: %s", b_eu); // 1 gp2x_text_out8(tl_x, (y+=10), "EUR BIOS: %s", b_eu); // 1
gp2x_text_out8(tl_x, (y+=10), "JAP BIOS: %s", b_jp); // 2 gp2x_text_out8(tl_x, (y+=10), "JAP BIOS: %s", b_jp); // 2
gp2x_text_out8(tl_x, (y+=10), "CD LEDs %s", (currentConfig.EmuOpt &0x400)?"ON":"OFF"); // 3 gp2x_text_out8(tl_x, (y+=10), "CD LEDs %s", (currentConfig.EmuOpt &0x400)?"ON":"OFF"); // 3
gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s) %s", (currentConfig.EmuOpt &0x800)?"ON":"OFF"); // 4 gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s) %s", (currentConfig.PicoOpt&0x800)?"ON":"OFF"); // 4
gp2x_text_out8(tl_x, (y+=10), "PCM audio %s", (currentConfig.PicoOpt&0x400)?"ON":"OFF"); // 5
gp2x_text_out8(tl_x, (y+=10), "Done"); gp2x_text_out8(tl_x, (y+=10), "Done");
// draw cursor // draw cursor
@ -590,7 +591,7 @@ static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_j
static void cd_menu_loop_options(void) static void cd_menu_loop_options(void)
{ {
int menu_sel = 0, menu_sel_max = 5; int menu_sel = 0, menu_sel_max = 6;
unsigned long inp = 0; unsigned long inp = 0;
char bios_us[32], bios_eu[32], bios_jp[32], *bios, *p; char bios_us[32], bios_eu[32], bios_jp[32], *bios, *p;
@ -618,8 +619,9 @@ 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: currentConfig.EmuOpt ^=0x400; break; case 3: currentConfig.EmuOpt ^=0x400; break;
case 4: currentConfig.EmuOpt ^=0x800; break; case 4: currentConfig.PicoOpt^=0x800; break;
case 5: return; case 5: currentConfig.PicoOpt^=0x400; break;
case 6: return;
} }
} }
if(inp & (GP2X_X|GP2X_A)) return; if(inp & (GP2X_X|GP2X_A)) return;

View file

@ -20,8 +20,6 @@
static YM2612 ym2612; static YM2612 ym2612;
YM2612 *ym2612_940 = &ym2612; YM2612 *ym2612_940 = &ym2612;
int mix_buffer_[44100/50*2]; /* this is where the YM2612 samples will be mixed to */
int *mix_buffer = mix_buffer_;
// static _940_data_t shared_data_; // static _940_data_t shared_data_;
static _940_ctl_t shared_ctl_; static _940_ctl_t shared_ctl_;
@ -96,58 +94,6 @@ 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;
l = r = *dest_buf;
l += *ym_buf++; r += *ym_buf++;
l += *mp3_buf++; r += *mp3_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;
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;
}
}
}
}
#if 0 #if 0
static void local_decode(void) static void local_decode(void)
{ {
@ -190,7 +136,7 @@ static void local_decode(void)
static FILE *loaded_mp3 = 0; static FILE *loaded_mp3 = 0;
void YM2612UpdateOne_940(short *buffer, int length, int stereo) int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty)
{ {
#if 0 #if 0
int cdda_on, *ym_buffer = mix_buffer; int cdda_on, *ym_buffer = mix_buffer;
@ -233,9 +179,7 @@ void YM2612UpdateOne_940(short *buffer, int length, int stereo)
mp3_samples_ready += 1152; mp3_samples_ready += 1152;
} }
#else #else
YM2612UpdateOne_(buffer, length, stereo); // really writes to mix_buffer return YM2612UpdateOne_(buffer, length, stereo, is_buf_empty);
mix_samples(buffer, mix_buffer, 0, length, stereo);
#endif #endif
} }

View file

@ -31,9 +31,9 @@ OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory
# Pico - CD # Pico - CD
OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \ OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \
../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \ ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \
../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/pcm.o
# Pico - sound # Pico - sound
OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o ../../Pico/sound/mix.o
# zlib # zlib
OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \ OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/inftrees.o ../../zlib/trees.o \
../../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