PCM sound, refactored code940

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@27 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2007-02-04 17:15:31 +00:00
parent 7573607016
commit 4f265db776
28 changed files with 914 additions and 312 deletions

View file

@ -14,6 +14,9 @@
#include "asmutils.h"
#include "../../Pico/PicoInt.h"
// tmp
#include "../../Pico/sound/mix.h"
/* we will need some gp2x internals here */
extern volatile unsigned short *gp2x_memregs; /* from minimal library rlyeh */
extern volatile unsigned long *gp2x_memregl;
@ -223,6 +226,7 @@ int YM2612PicoTick_940(int n)
return 0;
}
static int g_busy = 10;
static void wait_busy_940(void)
{
@ -239,8 +243,9 @@ static void wait_busy_940(void)
}
printf("wait iterations: %i\n", i);
#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
//printf("i = 0x%x\n", i);
if (i < 0x10000) return;
/* 940 crashed */
@ -248,6 +253,19 @@ static void wait_busy_940(void)
for (i = 0; i < 8; i++)
printf("%i ", shared_ctl->vstarts[i]);
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.");
engineState = PGS_Menu;
crashed_940 = 1;
@ -257,10 +275,17 @@ static void wait_busy_940(void)
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[1] = job1;
shared_ctl->busy = 1;
gp2x_memregs[0x3B3E>>1] = 0xffff; // cause an IRQ for 940
//shared_ctl->busy = ++g_busy; // 1;
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;
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
for(i = 0; i < 0x100; i++) {
@ -310,10 +335,8 @@ void YM2612Init_940(int baseclock, int rate)
Reset940(1, 2);
Pause940(1);
gp2x_memregs[0x3B46>>1] = 0xffff; // clear pending DUALCPU interrupts for 940
gp2x_memregs[0x3B42>>1] = 0xffff; // enable DUALCPU interrupts for 940
gp2x_memregl[0x4508>>2] = ~(1<<26); // unmask DUALCPU ints in the undocumented 940's interrupt controller
gp2x_memregs[0x3B40>>1] = 0; // disable DUALCPU interrupts for 920
gp2x_memregs[0x3B42>>1] = 1; // enable DUALCPU interrupts for 940
if (shared_mem == NULL)
{
@ -388,7 +411,13 @@ void YM2612Init_940(int baseclock, int rate)
shared_ctl->rate = rate;
shared_ctl->jobs[0] = JOB940_INITALL;
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 */
Reset940(0, 2);
@ -406,7 +435,7 @@ void YM2612ResetChip_940(void)
return;
}
if (shared_ctl->busy) wait_busy_940();
if (/*shared_ctl->busy*/gp2x_memregs[0x3B3E>>1]) wait_busy_940();
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 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;
}
int lm, rm;
lm = *mp3_buf++; rm = *mp3_buf++;
*dest_buf++ += lm - lm/2; *dest_buf++ += rm - rm/2;
}
}
else
{
if (stereo)
} else {
for (; len > 0; len--)
{
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;
}
int l = *mp3_buf++;
*dest_buf++ = l - l/2;
}
}
}
*/
// 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_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");
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);
//for (i = 0; i < 8; i++)
// printf("%i ", shared_ctl->vstarts[i]);
//printf(")\n");
// track ended?
cdda_on = cdda_on && shared_ctl->mp3_offs < shared_ctl->mp3_len;
// 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 in ym buffer
if (is_buf_empty) memcpy32(buffer, ym_buf, length<<stereo);
// else TODO
/* mix data from previous go */
if (cdda_on && mp3_samples_ready >= length)
// for (len = length << stereo; len > 0; len--)
// {
// *dest_buf++ += *ym_buf++;
// }
/* mix mp3 data, only stereo */
if (cdda_on && mp3_samples_ready >= length_mp3)
{
if (1152 - mp3_buffer_offs >= length) {
mix_samples(buffer, ym_buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, length, stereo);
int shr = 0;
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 {
// 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);
if (mp3_play_bufsel == 0)
{
mix_samples(buffer, shared_data->mp3_buffer[0] + mp3_buffer_offs*2, (length_mp3>>shr)<<1);
mp3_buffer_offs = length_mp3 - left;
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;
} else {
mix_samples(buffer, ym_buffer, 0, length, stereo);
mp3_samples_ready -= length_mp3;
}
//printf("new writes: %i\n", writebuff_ptr);
if (shared_ctl->writebuffsel == 1) {
shared_ctl->writebuff0[writebuff_ptr] = 0xffff;
} else {
@ -525,7 +543,7 @@ void YM2612UpdateOne_940(short *buffer, int length, int stereo)
shared_ctl->stereo = stereo;
// 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;
mp3_job = JOB940_MP3DECODE;
@ -536,6 +554,8 @@ void YM2612UpdateOne_940(short *buffer, int length, int stereo)
//spend_cycles(512);
//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]);
return 1;
}
@ -551,11 +571,11 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
if (loaded_mp3 != f)
{
printf("loading mp3... "); fflush(stdout);
// 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");
// 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;
}
@ -566,7 +586,7 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
byte_offs *= pos;
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;

View file

@ -1,6 +1,6 @@
void YM2612Init_940(int baseclock, int rate);
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);
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
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/Area.o ../../Pico/cd/Misc.o
../../Pico/cd/Area.o ../../Pico/cd/Misc.o ../../Pico/cd/pcm.o
# asm stuff
ifeq "$(asm_render)" "1"
DEFINC += -D_ASM_DRAW_C
@ -56,6 +56,7 @@ DEFINC += -D_ASM_YM2612_C
OBJS += ../../Pico/sound/ym2612_asm.o
endif
# Pico - sound
OBJS += ../../Pico/sound/mix_asm.o
OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o
# zlib
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\\
endif
up:
up: PicoDrive.gpe
@cp -v PicoDrive.gpe /mnt/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
@echo $<
@$(AS) $(ASOPT) $< -o $@
../../Pico/sound/mix_asm.o : ../../Pico/sound/mix.s
@echo $<
@$(AS) $(ASOPT) $< -o $@
# build Cyclone
../../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_nobord(void *dest, void *src);
void spend_cycles(int c); // utility
void flushcache(void);

View file

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

View file

@ -57,17 +57,18 @@ static void mp3_decode(void)
}
void Main940(int startvector)
void Main940(int startvector, int pc_at_irq)
{
ym2612_940 = &shared_data->ym2612;
mix_buffer = shared_data->mix_buffer;
// debug
shared_ctl->vstarts[startvector]++;
shared_ctl->last_irq_pc = pc_at_irq;
// asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0");
for (;;)
// for (;;)
{
int job_num = 0;
/*
@ -77,13 +78,18 @@ void Main940(int startvector)
spend_cycles(8*1024);
}
*/
/*
if (!shared_ctl->busy)
{
wait_irq();
}
shared_ctl->lastbusy = shared_ctl->busy;
*/
for (job_num = 0; job_num < MAX_940JOBS; job_num++)
{
shared_ctl->lastjob = (job_num << 8) | shared_ctl->jobs[job_num];
switch (shared_ctl->jobs[job_num])
{
case JOB940_INITALL:
@ -122,7 +128,7 @@ void Main940(int startvector)
YM2612Write_(d >> 8, d);
}
YM2612UpdateOne_(0, shared_ctl->length, shared_ctl->stereo);
YM2612UpdateOne_(mix_buffer, shared_ctl->length, shared_ctl->stereo, 1);
break;
}
@ -138,7 +144,10 @@ void Main940(int startvector)
// cache_clean_flush();
shared_ctl->loopc++;
shared_ctl->busy = 0;
// // shared_ctl->busy = 0; // shared mem is not reliable?
wait_irq();
}
}

View file

@ -1,5 +1,7 @@
.global code940
.equ mmsp2_regs, (0xc0000000-0x02000000) @ assume we live @ 0x2000000 bank
code940: @ interrupt table:
b .b_reset @ reset
b .b_undef @ undefined instructions
@ -33,7 +35,7 @@ code940: @ interrupt table:
mov r12, #6
mov sp, #0x100000 @ reset stack
sub sp, sp, #4
mov r1, #0xbe000000 @ assume we live @ 0x2000000 bank
mov r1, #mmsp2_regs
orr r2, r1, #0x3B00
orr r2, r2, #0x0046
mvn r3, #0
@ -69,7 +71,7 @@ code940: @ interrupt table:
@ set up region 3: 64k 0xbe000000-0xbe010000 (hw control registers)
mov r0, #(0x0f<<1)|1
orr r0, r0, #0xbe000000
orr r0, r0, #mmsp2_regs
mcr p15, 0, r0, c6, c3, 0
mcr p15, 0, r0, c6, c3, 1
@ -88,7 +90,7 @@ code940: @ interrupt table:
mov r0, #(1<<1)
mcr p15, 0, r0, c3, c0, 0
@ set protection, allow accsess only to regions 1 and 2
@ set protection, allow access only to regions 1 and 2
mov r0, #(3<<8)|(3<<6)|(3<<4)|(3<<2)|(0) @ data: [full, full, full, full, no access] for regions [4 3 2 1 0]
mcr p15, 0, r0, c5, c0, 0
mov r0, #(0<<8)|(0<<6)|(0<<4)|(3<<2)|(0) @ instructions: [no access, no, no, full, no]
@ -98,9 +100,9 @@ code940: @ interrupt table:
orr r0, r0, #1 @ 0x00000001: enable protection unit
orr r0, r0, #4 @ 0x00000004: enable D cache
orr r0, r0, #0x1000 @ 0x00001000: enable I cache
bic r0, r0, #0xC0000000
orr r0, r0, #0x40000000 @ 0x40000000: synchronous, faster?
@ orr r0, r0, #0xC0000000 @ 0xC0000000: async
@ bic r0, r0, #0xC0000000
@ orr r0, r0, #0x40000000 @ 0x40000000: synchronous, faster?
orr r0, r0, #0xC0000000 @ 0xC0000000: async
mcr p15, 0, r0, c1, c0, 0 @ set control reg
@ flush (invalidate) the cache (just in case)
@ -109,11 +111,13 @@ code940: @ interrupt table:
.Enter:
mov r0, r12
mov r1, lr
bl Main940
@ we should never get here
.b_deadloop:
b .b_deadloop
@.b_deadloop:
@ b .b_deadloop
b .b_reserved
@ -171,13 +175,25 @@ cf_inner_loop:
.global wait_irq
wait_irq:
mov r0, #mmsp2_regs
orr r0, r0, #0x3B00
orr r1, r0, #0x0042
mov r3, #0
strh r3, [r1] @ disable interrupts
orr r2, r0, #0x003E
strh r3, [r2] @ remove busy flag
mov r3, #1
strh r3, [r1] @ enable interrupts
mrs r0, cpsr
bic r0, r0, #0x80
msr cpsr_c, r0 @ enable interrupts
msr cpsr_c, r0 @ enable interrupts
mov r0, #0
mcr p15, 0, r0, c7, c0, 4 @ wait for IRQ
@ mcr p15, 0, r0, c15, c8, 2
nop
nop
b .b_reserved
.pool

View file

@ -24,7 +24,7 @@ typedef struct
typedef struct
{
int jobs[MAX_940JOBS]; /* jobs for second core */
int busy; /* busy status of the 940 core */
int busy_; /* unused */
int length; /* number of samples to mix (882 max) */
int stereo; /* mix samples as stereo, doubles sample count automatically */
int baseclock; /* ym2612 settings */
@ -39,4 +39,7 @@ typedef struct
int loopc; /* debug: main loop counter */
int mp3_errors; /* debug: mp3 decoder's error counter */
int mp3_lasterr; /* debug: mp3 decoder's last error */
int last_irq_pc; /* debug: PC value when IRQ happened */
int lastjob; /* debug: last job id */
int lastbusy; /* debug: */
} _940_ctl_t;

View file

@ -11,7 +11,7 @@ CROSS = arm-linux-
DEFINC = -I../.. -I. -D__GP2X__ -DARM # -DBENCHMARK
COPT_COMMON = -static -s -O3 -ftracer -fstrength-reduce -Wall -funroll-loops -fomit-frame-pointer -fstrict-aliasing -ffast-math
COPT = $(COPT_COMMON) -mtune=arm920t
COPT = $(COPT_COMMON) -mtune=arm940t
GCC = $(CROSS)gcc
STRIP = $(CROSS)strip
AS = $(CROSS)as
@ -20,10 +20,6 @@ OBJCOPY = $(CROSS)objcopy
all: code940.bin
up940:
@cp -v code940.bin /mnt/gp2x/mnt/sd/games/PicoDrive/
# @cmd //C copy code940.bin \\\\10.0.1.2\\gp2x\\mnt\\sd\\games\\PicoDrive\\
.c.o:
@echo $<
@ -36,7 +32,7 @@ up940:
# stuff for 940 core
# init, emu_control, emu
OBJS940 += 940init.o 940.o 940ym2612.o memcpy.o
OBJS940 += 940init.o 940.o 940ym2612.o memcpy.o mix.o
# the asm code seems to be faster when run on 920, but not on 940 for some reason
# OBJS940 += ../../Pico/sound/ym2612_asm.o
@ -51,17 +47,21 @@ code940.bin : code940.gpe
code940.gpe : $(OBJS940) ../helix/helix_mp3.a
@echo $@
@$(LD) -static -e code940 -Ttext 0x0 $^ -L$(lgcc_path) -lgcc -o $@
@$(LD) -static -e code940 -Ttext 0x0 $^ -L$(lgcc_path) -lgcc -o $@ -Map code940.map
940ym2612.o : ../../../Pico/sound/ym2612.c
@echo $@
@$(GCC) $(COPT_COMMON) -mtune=arm940t $(DEFINC) -DEXTERNAL_YM2612 -c $< -o $@
@$(GCC) $(COPT) $(DEFINC) -DEXTERNAL_YM2612 -c $< -o $@
mix.o : ../../../Pico/sound/mix.s
@echo $@
@$(GCC) $(COPT) $(DEFINC) -DEXTERNAL_YM2612 -c $< -o $@
../helix/helix_mp3.a:
@make -C ../helix/
up:
up: code940.bin
@cp -v code940.bin /mnt/gp2x/mnt/sd/games/PicoDrive/
@ -69,7 +69,7 @@ up:
clean: tidy
@$(RM) code940.bin
tidy:
@$(RM) code940.gpe $(OBJS940)
@$(RM) code940.gpe $(OBJS940) code940.map
OBJSMP3T = mp3test.o ../gp2x.o ../asmutils.o ../usbjoy.o

View file

@ -276,6 +276,7 @@ int emu_ReloadRom(void)
// bios_help() ?
return 0;
} else {
if (PicoMCD & 1) PicoExitMCD();
PicoMCD &= ~1;
}
@ -374,7 +375,7 @@ int emu_ReloadRom(void)
}
}
gettimeofday(&noticeMsgTime, 0);
printf("PicoMCD: %x\n", PicoMCD);
// load SRAM for this ROM
if(currentConfig.EmuOpt & 1)
emu_SaveLoadGame(1, 1);
@ -452,8 +453,8 @@ int emu_ReadConfig(int game)
// set default config
memset(&currentConfig, 0, sizeof(currentConfig));
currentConfig.lastRomFile[0] = 0;
currentConfig.EmuOpt = 0x1f | 0xc00; // | cd_leds | cd_cdda
currentConfig.PicoOpt = 0x0f | 0x200; // | use_940
currentConfig.EmuOpt = 0x1f | 0x400; // | cd_leds
currentConfig.PicoOpt = 0x0f | 0xe00; // | use_940 | cd_pcm | cd_cdda
currentConfig.PsndRate = 44100;
currentConfig.PicoRegion = 0; // auto
currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP
@ -599,20 +600,20 @@ static void cd_leds(void)
// 8-bit modes
unsigned int col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;
unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;
*(unsigned int *)((char *)gp2x_screen + 320*2+306) =
*(unsigned int *)((char *)gp2x_screen + 320*3+306) =
*(unsigned int *)((char *)gp2x_screen + 320*4+306) = col_g;
*(unsigned int *)((char *)gp2x_screen + 320*2+312) =
*(unsigned int *)((char *)gp2x_screen + 320*3+312) =
*(unsigned int *)((char *)gp2x_screen + 320*4+312) = col_r;
*(unsigned int *)((char *)gp2x_screen + 320*2+ 4) =
*(unsigned int *)((char *)gp2x_screen + 320*3+ 4) =
*(unsigned int *)((char *)gp2x_screen + 320*4+ 4) = col_g;
*(unsigned int *)((char *)gp2x_screen + 320*2+12) =
*(unsigned int *)((char *)gp2x_screen + 320*3+12) =
*(unsigned int *)((char *)gp2x_screen + 320*4+12) = col_r;
} else {
// 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_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++; *p++ = col_r; *p++ = col_r; p += 320/2 - 10/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+=2; *p++ = col_r; *p++ = col_r; p += 320/2 - 12/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];
int EmuOpt; // LSb->MSb: use_sram, show_fps, enable_sound, gzip_saves,
// squidgehack, save_cfg_on_exit, <unused>, 16_bit_mode
// craigix_ram, confirm_save, show_cd_leds, enable_cdda
// enable_pcm
// craigix_ram, confirm_save, show_cd_leds
//
int PicoOpt; // used for config saving only, see Pico.h
int PsndRate; // 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), "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), "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");
// 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)
{
int menu_sel = 0, menu_sel_max = 5;
int menu_sel = 0, menu_sel_max = 6;
unsigned long inp = 0;
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
switch (menu_sel) {
case 3: currentConfig.EmuOpt ^=0x400; break;
case 4: currentConfig.EmuOpt ^=0x800; break;
case 5: return;
case 4: currentConfig.PicoOpt^=0x800; break;
case 5: currentConfig.PicoOpt^=0x400; break;
case 6: return;
}
}
if(inp & (GP2X_X|GP2X_A)) return;