Sonic CD runs on GP2X

git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@21 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2007-01-19 22:08:50 +00:00
parent 15f385743a
commit 8dfb9fd5df
13 changed files with 113 additions and 106 deletions

View file

@ -1,9 +1,5 @@
#include "940shared.h" #include "940shared.h"
/* this code assumes that we live @ 0x3000000 bank */
//static volatile unsigned short *gp2x_memregs = (void *) 0x0xbd000000;
//static volatile unsigned long *gp2x_memregl = (void *) 0x0xbd000000;
static _940_data_t *shared_data = (_940_data_t *) 0x100000; static _940_data_t *shared_data = (_940_data_t *) 0x100000;
static _940_ctl_t *shared_ctl = (_940_ctl_t *) 0x200000; static _940_ctl_t *shared_ctl = (_940_ctl_t *) 0x200000;
YM2612 *ym2612_940; YM2612 *ym2612_940;
@ -28,10 +24,10 @@ void Main940(int startvector)
shared_ctl->vstarts[startvector]++; shared_ctl->vstarts[startvector]++;
asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0"); asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0");
/* unmask IRQs */
for (;; shared_ctl->loopc++) for (;; shared_ctl->loopc++)
{ {
int job_num;
/* /*
while (!shared_ctl->busy) while (!shared_ctl->busy)
{ {
@ -44,7 +40,9 @@ void Main940(int startvector)
wait_irq(); wait_irq();
} }
switch (shared_ctl->job) for (job_num = 0; job_num < MAX_940JOBS; job_num++)
{
switch (shared_ctl->jobs[job_num])
{ {
case JOB940_YM2612INIT: case JOB940_YM2612INIT:
shared_ctl->writebuff0[0] = shared_ctl->writebuff1[0] = 0xffff; shared_ctl->writebuff0[0] = shared_ctl->writebuff1[0] = 0xffff;
@ -80,14 +78,16 @@ void Main940(int startvector)
} }
YM2612UpdateOne_(0, shared_ctl->length, shared_ctl->stereo); YM2612UpdateOne_(0, shared_ctl->length, shared_ctl->stereo);
// cache_clean_flush();
cache_clean();
// asm volatile ("mov r0, #0" ::: "r0");
// asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0"); /* drain write buffer, should be done on nonbuffered write */
break; break;
} }
} }
}
shared_ctl->busy = 0; shared_ctl->busy = 0;
// cache_clean_flush();
cache_clean();
// asm volatile ("mov r0, #0" ::: "r0");
// asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0"); /* drain write buffer, should be done on nonbuffered write */
} }
} }

View file

@ -250,9 +250,10 @@ static void wait_busy_940(void)
} }
static void add_job_940(int job) static void add_job_940(int job0, int job1)
{ {
shared_ctl->job = job; shared_ctl->jobs[0] = job0;
shared_ctl->jobs[1] = job1;
shared_ctl->busy = 1; shared_ctl->busy = 1;
gp2x_memregs[0x3B3E>>1] = 0xffff; // cause an IRQ for 940 gp2x_memregs[0x3B3E>>1] = 0xffff; // cause an IRQ for 940
} }
@ -276,7 +277,7 @@ void YM2612PicoStateLoad_940(void)
addr_A1 = old_A1; addr_A1 = old_A1;
add_job_940(JOB940_PICOSTATELOAD); add_job_940(JOB940_PICOSTATELOAD, 0);
} }
@ -299,10 +300,9 @@ extern char **g_argv;
void YM2612Init_940(int baseclock, int rate) void YM2612Init_940(int baseclock, int rate)
{ {
printf("YM2612Init_940()\n"); printf("YM2612Init_940()\n");
//printf("sizeof(*shared_data): %i (%x)\n", sizeof(*shared_data), sizeof(*shared_data)); printf("Mem usage: shared_data: %i, shared_ctl: %i\n", sizeof(*shared_data), sizeof(*shared_ctl));
//printf("sizeof(*shared_ctl): %i (%x)\n", sizeof(*shared_ctl), sizeof(*shared_ctl));
Reset940(1); Reset940(1, 2);
Pause940(1); Pause940(1);
gp2x_memregs[0x3B46>>1] = 0xffff; // clear pending DUALCPU interrupts for 940 gp2x_memregs[0x3B46>>1] = 0xffff; // clear pending DUALCPU interrupts for 940
@ -312,7 +312,7 @@ void YM2612Init_940(int baseclock, int rate)
if (shared_mem == NULL) if (shared_mem == NULL)
{ {
shared_mem = (unsigned char *) mmap(0, 0x210000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x3000000); shared_mem = (unsigned char *) mmap(0, 0x210000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x2000000);
if(shared_mem == MAP_FAILED) if(shared_mem == MAP_FAILED)
{ {
printf("mmap(shared_data) failed with %i\n", errno); printf("mmap(shared_data) failed with %i\n", errno);
@ -373,11 +373,12 @@ void YM2612Init_940(int baseclock, int rate)
/* now cause 940 to init it's ym2612 stuff */ /* now cause 940 to init it's ym2612 stuff */
shared_ctl->baseclock = baseclock; shared_ctl->baseclock = baseclock;
shared_ctl->rate = rate; shared_ctl->rate = rate;
shared_ctl->job = JOB940_YM2612INIT; shared_ctl->jobs[0] = JOB940_YM2612INIT;
shared_ctl->jobs[1] = 0;
shared_ctl->busy = 1; shared_ctl->busy = 1;
/* start the 940 */ /* start the 940 */
Reset940(0); Reset940(0, 2);
Pause940(0); Pause940(0);
// YM2612ResetChip_940(); // will be done on JOB940_YM2612INIT // YM2612ResetChip_940(); // will be done on JOB940_YM2612INIT
@ -396,7 +397,7 @@ void YM2612ResetChip_940(void)
internal_reset(); internal_reset();
add_job_940(JOB940_YM2612RESETCHIP); add_job_940(JOB940_YM2612RESETCHIP, 0);
} }
@ -444,7 +445,7 @@ void YM2612UpdateOne_940(short *buffer, int length, int stereo)
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); add_job_940(JOB940_YM2612UPDATEONE, 0);
//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]);

View file

@ -33,7 +33,7 @@ code940: @ interrupt table:
mov r12, #6 mov r12, #6
mov sp, #0x100000 @ reset stack mov sp, #0x100000 @ reset stack
sub sp, sp, #4 sub sp, sp, #4
mov r1, #0xbd000000 @ assume we live @ 0x3000000 bank mov r1, #0xbe000000 @ assume we live @ 0x2000000 bank
orr r2, r1, #0x3B00 orr r2, r1, #0x3B00
orr r2, r2, #0x0046 orr r2, r2, #0x0046
mvn r3, #0 mvn r3, #0
@ -67,9 +67,9 @@ code940: @ interrupt table:
mcr p15, 0, r0, c6, c2, 0 mcr p15, 0, r0, c6, c2, 0
mcr p15, 0, r0, c6, c2, 1 mcr p15, 0, r0, c6, c2, 1
@ set up region 3: 64k 0xbd000000-0xbd010000 (hw control registers) @ set up region 3: 64k 0xbe000000-0xbe010000 (hw control registers)
mov r0, #(0x0f<<1)|1 mov r0, #(0x0f<<1)|1
orr r0, r0, #0xbd000000 orr r0, r0, #0xbe000000
mcr p15, 0, r0, c6, c3, 0 mcr p15, 0, r0, c6, c3, 0
mcr p15, 0, r0, c6, c3, 1 mcr p15, 0, r0, c6, c3, 1
@ -172,3 +172,5 @@ wait_irq:
b .b_reserved b .b_reserved
.pool .pool
@ vim:filetype=ignored:

View file

@ -8,24 +8,26 @@ enum _940_job_t {
JOB940_NUMJOBS JOB940_NUMJOBS
}; };
#define MAX_940JOBS 2
typedef struct typedef struct
{ {
YM2612 ym2612; /* current state of the emulated YM2612 */ YM2612 ym2612; /* current state of the emulated 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 */
short mp3_buffer[2][1152*2]; /* buffer for mp3 decoder's output */
} _940_data_t; } _940_data_t;
typedef struct typedef struct
{ {
int job; /* a job for second core */ int jobs[MAX_940JOBS]; /* jobs for second core */
int busy; /* busy status of the 940 core */ int busy; /* busy status of the 940 core */
int length; /* number of samples to mix (882 max) */ int length; /* number of samples to mix (882 max) */
int stereo; /* mix samples as stereo, doubles sample count automatically */ int stereo; /* mix samples as stereo, doubles sample count automatically */
int baseclock; /* ym2612 settings */ int baseclock; /* ym2612 settings */
int rate; int rate;
int writebuffsel; /* which write buffer to use (from 940 side) */ int writebuffsel; /* which write buffer to use (from 940 side) */
UINT16 writebuff0[2048]; /* 1024 for savestates, 1024 extra */ UINT16 writebuff0[2048]; /* list of writes to ym2612, 1024 for savestates, 1024 extra */
UINT16 writebuff1[2048]; UINT16 writebuff1[2048];
int vstarts[8]; /* debug: number of starts from each of 8 vectors */ int vstarts[8]; /* debug: number of starts from each of 8 vectors */
int loopc; /* debug: main loop counter */ int loopc; /* debug: main loop counter */

View file

@ -10,7 +10,7 @@ CROSS = arm-linux-
dprint = 1 dprint = 1
#mz80 = 1 #mz80 = 1
#debug_cyclone = 1 #debug_cyclone = 1
asm_memory = 1 asm_memory = 0 # TODO
asm_render = 1 asm_render = 1
asm_ym2612 = 1 asm_ym2612 = 1
#profile = 1 #profile = 1
@ -42,7 +42,7 @@ OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory
../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o
# 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_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o
# asm stuff # asm stuff
ifeq "$(asm_render)" "1" ifeq "$(asm_render)" "1"
DEFINC += -D_ASM_DRAW_C DEFINC += -D_ASM_DRAW_C

View file

@ -374,7 +374,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);
@ -586,8 +586,10 @@ void osd_text(int x, int y, char *text)
static void cd_leds(void) static void cd_leds(void)
{ {
static int old_reg = 0; // mmu problems?
if (!((Pico_mcd->s68k_regs[0] ^ old_reg) & 3)) return; // no change // static
int old_reg;
// if (!((Pico_mcd->s68k_regs[0] ^ old_reg) & 3)) return; // no change
old_reg = Pico_mcd->s68k_regs[0]; old_reg = Pico_mcd->s68k_regs[0];
if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) { if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {
@ -1021,7 +1023,7 @@ void emu_Loop(void)
if(PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old || crashed_940) { if(PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old || crashed_940) {
/* if 940 is turned off, we need it to be put back to sleep */ /* if 940 is turned off, we need it to be put back to sleep */
if (!(PicoOpt&0x200) && ((PicoOpt^PicoOpt_old)&0x200)) { if (!(PicoOpt&0x200) && ((PicoOpt^PicoOpt_old)&0x200)) {
Reset940(1); Reset940(1, 2);
Pause940(1); Pause940(1);
} }
sound_rerate(); sound_rerate();

View file

@ -223,9 +223,9 @@ void Pause940(int yes)
} }
void Reset940(int yes) void Reset940(int yes, int bank)
{ {
gp2x_memregs[0x3B48>>1] = ((yes&1) << 7) | (0x03); /* bank=3 */ gp2x_memregs[0x3B48>>1] = ((yes&1) << 7) | (bank & 0x03); /* bank=3 */
} }
@ -280,7 +280,7 @@ char *ext_menu = 0, *ext_state = 0;
void gp2x_deinit(void) void gp2x_deinit(void)
{ {
Reset940(1); Reset940(1, 3);
Pause940(1); Pause940(1);
gp2x_video_changemode(15); gp2x_video_changemode(15);

View file

@ -25,7 +25,7 @@ unsigned long gp2x_joystick_read(int allow_usb_joy);
/* 940 core */ /* 940 core */
void Pause940(int yes); void Pause940(int yes);
void Reset940(int yes); void Reset940(int yes, int bank);
extern void *gp2x_screen; extern void *gp2x_screen;

View file

@ -86,8 +86,8 @@ int main(int argc, char *argv[])
mmuhack_status = ret; mmuhack_status = ret;
} }
cpuctrl_init(); cpuctrl_init();
Reset940(1); // Reset940(1);
Pause940(1); // Pause940(1);
if (currentConfig.EmuOpt&0x100) { if (currentConfig.EmuOpt&0x100) {
printf("setting RAM timings.. "); fflush(stdout); printf("setting RAM timings.. "); fflush(stdout);
// craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2 // craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2

View file

@ -959,7 +959,7 @@ static void draw_menu_root(int menu_sel)
} else { } else {
y += 30; y += 30;
} }
gp2x_text_out8(tl_x, (y+=10), "Load new ROM"); gp2x_text_out8(tl_x, (y+=10), "Load new ROM/ISO");
gp2x_text_out8(tl_x, (y+=10), "Change options"); gp2x_text_out8(tl_x, (y+=10), "Change options");
gp2x_text_out8(tl_x, (y+=10), "Configure controls"); gp2x_text_out8(tl_x, (y+=10), "Configure controls");
gp2x_text_out8(tl_x, (y+=10), "Credits"); gp2x_text_out8(tl_x, (y+=10), "Credits");

View file

@ -12,7 +12,7 @@
// pico.c // pico.c
#define CAN_HANDLE_240_LINES 1 #define CAN_HANDLE_240_LINES 1
//#define dprintf(f,...) printf(f"\n",##__VA_ARGS__) //#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)
#define dprintf(x...) #define dprintf(x...)
#endif //PORT_CONFIG_H #endif //PORT_CONFIG_H

View file

@ -1,2 +1,2 @@
#define VERSION "0.965" #define VERSION "1.10"

View file

@ -327,7 +327,7 @@ void Pause940(int yes)
{ {
} }
void Reset940(int yes) void Reset940(int yes, int bank)
{ {
} }