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

@ -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