psp bugfixes, refactoring, stuff

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@284 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2007-10-29 18:16:46 +00:00
parent 03e4f2a349
commit 9d917eea21
14 changed files with 109 additions and 48 deletions

View file

@ -137,8 +137,8 @@ int CM_compareRun(int cyc)
// compare PC // compare PC
m68ki_cpu.pc&=~1; m68ki_cpu.pc&=~1;
if ( SekPc != (m68ki_cpu.pc&0xffffff) ) { if (SekPc != m68ki_cpu.pc) {
dprintf("PC: %06x vs %06x", SekPc, m68ki_cpu.pc&0xffffff); dprintf("PC: %06x vs %06x", SekPc, m68ki_cpu.pc);
err=1; err=1;
} }

View file

@ -137,7 +137,7 @@ int PicoReset(int hard)
Pico.m.pal=pal; Pico.m.pal=pal;
Pico.video.status = 0x3408 | pal; // always set bits | vblank | pal Pico.video.status = 0x3408 | pal; // always set bits | vblank | pal
sound_reset(); // pal must be known here PsndReset(); // pal must be known here
if (PicoMCD & 1) { if (PicoMCD & 1) {
PicoResetMCD(hard); PicoResetMCD(hard);
@ -255,17 +255,17 @@ static __inline void getSamples(int y)
if(y == 224) { if(y == 224) {
if(emustatus & 2) if(emustatus & 2)
curr_pos += sound_render(curr_pos, PsndLen-PsndLen/2); curr_pos += PsndRender(curr_pos, PsndLen-PsndLen/2);
else curr_pos = sound_render(0, PsndLen); else curr_pos = PsndRender(0, PsndLen);
if (emustatus&1) emustatus|=2; else emustatus&=~2; if (emustatus&1) emustatus|=2; else emustatus&=~2;
if (PicoWriteSound) PicoWriteSound(curr_pos); if (PicoWriteSound) PicoWriteSound(curr_pos);
// clear sound buffer // clear sound buffer
sound_clear(); PsndClear();
} }
else if(emustatus & 3) { else if(emustatus & 3) {
emustatus|= 2; emustatus|= 2;
emustatus&=~1; emustatus&=~1;
curr_pos = sound_render(0, PsndLen/2); curr_pos = PsndRender(0, PsndLen/2);
} }
} }
@ -293,7 +293,7 @@ static void PicoRunZ80Simple(int line_from, int line_to)
if (PicoOpt&1) { if (PicoOpt&1) {
// we have ym2612 enabled, so we have to run Z80 in lines, so we could update DAC and timers // we have ym2612 enabled, so we have to run Z80 in lines, so we could update DAC and timers
for (line = line_from; line < line_to; line++) { for (line = line_from; line < line_to; line++) {
sound_timers_and_dac(line); Psnd_timers_and_dac(line);
if ((line == 224 || line == line_sample) && PsndOut) getSamples(line); if ((line == 224 || line == line_sample) && PsndOut) getSamples(line);
if (line == 32 && PsndOut) emustatus &= ~1; if (line == 32 && PsndOut) emustatus &= ~1;
if (line >= line_from_r && line < line_to_r) if (line >= line_from_r && line < line_to_r)
@ -397,10 +397,10 @@ static int PicoFrameSimple(void)
// here we render sound if ym2612 is disabled // here we render sound if ym2612 is disabled
if (!(PicoOpt&1) && PsndOut) { if (!(PicoOpt&1) && PsndOut) {
int len = sound_render(0, PsndLen); int len = PsndRender(0, PsndLen);
if (PicoWriteSound) PicoWriteSound(len); if (PicoWriteSound) PicoWriteSound(len);
// clear sound buffer // clear sound buffer
sound_clear(); PsndClear();
} }
// a gap between flags set and vint // a gap between flags set and vint

View file

@ -130,7 +130,7 @@ extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to us
// sound.c // sound.c
extern int PsndRate,PsndLen; extern int PsndRate,PsndLen;
extern short *PsndOut; extern short *PsndOut;
void sound_rerate(int preserve_state); void PsndRerate(int preserve_state);
// Utils.c // Utils.c
extern int PicuAnd; extern int PicuAnd;

View file

@ -130,7 +130,7 @@ static int PicoFrameHints(void)
PicoLine(y); PicoLine(y);
if(PicoOpt&1) if(PicoOpt&1)
sound_timers_and_dac(y); Psnd_timers_and_dac(y);
#ifndef PICO_CD #ifndef PICO_CD
// get samples from sound chips // get samples from sound chips
@ -192,7 +192,7 @@ static int PicoFrameHints(void)
z80_int(); z80_int();
if (PicoOpt&1) if (PicoOpt&1)
sound_timers_and_dac(y); Psnd_timers_and_dac(y);
// get samples from sound chips // get samples from sound chips
#ifndef PICO_CD #ifndef PICO_CD
@ -223,7 +223,7 @@ static int PicoFrameHints(void)
#endif #endif
if(PicoOpt&1) if(PicoOpt&1)
sound_timers_and_dac(y); Psnd_timers_and_dac(y);
// Run scanline: // Run scanline:
if (Pico.m.dma_xfers) SekCyclesBurn(CheckDMA()); if (Pico.m.dma_xfers) SekCyclesBurn(CheckDMA());

View file

@ -392,10 +392,10 @@ PICO_INTERNAL_ASM void wram_1M_to_2M(unsigned char *m);
PICO_INTERNAL void PicoCDBufferRead(void *dest, int lba); PICO_INTERNAL void PicoCDBufferRead(void *dest, int lba);
// sound/sound.c // sound/sound.c
PICO_INTERNAL void sound_reset(void); PICO_INTERNAL void PsndReset(void);
PICO_INTERNAL void sound_timers_and_dac(int raster); PICO_INTERNAL void Psnd_timers_and_dac(int raster);
PICO_INTERNAL int sound_render(int offset, int length); PICO_INTERNAL int PsndRender(int offset, int length);
PICO_INTERNAL void sound_clear(void); PICO_INTERNAL void PsndClear(void);
// z80 functionality wrappers // z80 functionality wrappers
PICO_INTERNAL void z80_init(void); PICO_INTERNAL void z80_init(void);
PICO_INTERNAL void z80_resetCycles(void); PICO_INTERNAL void z80_resetCycles(void);

View file

@ -235,10 +235,10 @@ static __inline void update_chips(void)
static __inline void getSamples(int y) static __inline void getSamples(int y)
{ {
int len = sound_render(0, PsndLen); int len = PsndRender(0, PsndLen);
if (PicoWriteSound) PicoWriteSound(len); if (PicoWriteSound) PicoWriteSound(len);
// clear sound buffer // clear sound buffer
sound_clear(); PsndClear();
} }

View file

@ -101,7 +101,7 @@ static void dac_recalculate(void)
} }
PICO_INTERNAL void sound_reset(void) PICO_INTERNAL void PsndReset(void)
{ {
void *ym2612_regs; void *ym2612_regs;
@ -110,12 +110,12 @@ PICO_INTERNAL void sound_reset(void)
memset(ym2612_regs, 0, 0x200+4); memset(ym2612_regs, 0, 0x200+4);
z80startCycle = z80stopCycle = 0; z80startCycle = z80stopCycle = 0;
sound_rerate(0); PsndRerate(0);
} }
// to be called after changing sound rate or chips // to be called after changing sound rate or chips
void sound_rerate(int preserve_state) void PsndRerate(int preserve_state)
{ {
void *state = NULL; void *state = NULL;
int target_fps = Pico.m.pal ? 50 : 60; int target_fps = Pico.m.pal ? 50 : 60;
@ -163,12 +163,12 @@ void sound_rerate(int preserve_state)
// clear all buffers // clear all buffers
memset32(PsndBuffer, 0, sizeof(PsndBuffer)/4); memset32(PsndBuffer, 0, sizeof(PsndBuffer)/4);
if (PsndOut) if (PsndOut)
sound_clear(); PsndClear();
} }
// This is called once per raster (aka line), but not necessarily for every line // This is called once per raster (aka line), but not necessarily for every line
PICO_INTERNAL void sound_timers_and_dac(int raster) PICO_INTERNAL void Psnd_timers_and_dac(int raster)
{ {
int pos, len; int pos, len;
int do_dac = PsndOut && (PicoOpt&1) && *ym2612_dacen; int do_dac = PsndOut && (PicoOpt&1) && *ym2612_dacen;
@ -216,7 +216,7 @@ PICO_INTERNAL void sound_timers_and_dac(int raster)
} }
PICO_INTERNAL void sound_clear(void) PICO_INTERNAL void PsndClear(void)
{ {
int len = PsndLen; int len = PsndLen;
if (PsndLen_exc_add) len++; if (PsndLen_exc_add) len++;
@ -225,7 +225,7 @@ PICO_INTERNAL void sound_clear(void)
} }
PICO_INTERNAL int sound_render(int offset, int length) PICO_INTERNAL int PsndRender(int offset, int length)
{ {
int buf32_updated = 0; int buf32_updated = 0;
int *buf32 = PsndBuffer+offset; int *buf32 = PsndBuffer+offset;
@ -316,23 +316,26 @@ static unsigned int DrZ80_rebaseSP(unsigned short a)
return drZ80.Z80SP_BASE + a; return drZ80.Z80SP_BASE + a;
} }
static unsigned char DrZ80_in(unsigned short p)
{
elprintf(EL_ANOMALY, "Z80 port %04x read", p);
return 0xff;
}
static void DrZ80_out(unsigned short p,unsigned char d)
{
elprintf(EL_ANOMALY, "Z80 port %04x write %02x", p, d);
}
static void DrZ80_irq_callback() static void DrZ80_irq_callback()
{ {
drZ80.Z80_IRQ = 0; // lower irq when accepted drZ80.Z80_IRQ = 0; // lower irq when accepted
} }
#endif #endif
#if defined(_USE_DRZ80) || defined(_USE_CZ80)
static unsigned char z80_in(unsigned short p)
{
elprintf(EL_ANOMALY, "Z80 port %04x read", p);
return 0xff;
}
static void z80_out(unsigned short p,unsigned char d)
{
elprintf(EL_ANOMALY, "Z80 port %04x write %02x", p, d);
}
#endif
// z80 functionality wrappers // z80 functionality wrappers
PICO_INTERNAL void z80_init(void) PICO_INTERNAL void z80_init(void)
{ {
@ -361,8 +364,8 @@ PICO_INTERNAL void z80_init(void)
drZ80.z80_read16 =z80_read16; drZ80.z80_read16 =z80_read16;
drZ80.z80_write8 =z80_write; drZ80.z80_write8 =z80_write;
drZ80.z80_write16 =z80_write16; drZ80.z80_write16 =z80_write16;
drZ80.z80_in =DrZ80_in; drZ80.z80_in =z80_in;
drZ80.z80_out =DrZ80_out; drZ80.z80_out =z80_out;
drZ80.z80_irq_callback=DrZ80_irq_callback; drZ80.z80_irq_callback=DrZ80_irq_callback;
#elif defined(_USE_CZ80) #elif defined(_USE_CZ80)
@ -372,6 +375,8 @@ PICO_INTERNAL void z80_init(void)
Cz80_Set_Fetch(&CZ80, 0x2000, 0x3fff, (UINT32)Pico.zram - 0x2000); // mirror Cz80_Set_Fetch(&CZ80, 0x2000, 0x3fff, (UINT32)Pico.zram - 0x2000); // mirror
Cz80_Set_ReadB(&CZ80, (UINT8 (*)(UINT32 address))z80_read); Cz80_Set_ReadB(&CZ80, (UINT8 (*)(UINT32 address))z80_read);
Cz80_Set_WriteB(&CZ80, z80_write); Cz80_Set_WriteB(&CZ80, z80_write);
Cz80_Set_INPort(&CZ80, z80_in);
Cz80_Set_OUTPort(&CZ80, z80_out);
#endif #endif
} }

View file

@ -26,6 +26,7 @@
#define FAMEC_ADR_BITS 24 #define FAMEC_ADR_BITS 24
// #define FAMEC_FETCHBITS 8 // #define FAMEC_FETCHBITS 8
#define FAMEC_DATABITS 8 #define FAMEC_DATABITS 8
#define FAMEC_32BIT_PC
#define USE_CYCLONE_TIMING #define USE_CYCLONE_TIMING
#define USE_CYCLONE_TIMING_DIV #define USE_CYCLONE_TIMING_DIV
@ -289,15 +290,22 @@ static u32 flag_I;
#define GET_PC \ #define GET_PC \
(u32)PC - BasePC; (u32)PC - BasePC;
#ifndef FAMEC_32BIT_PC
#define SET_PC(A) \ #define SET_PC(A) \
BasePC = g_m68kcontext->Fetch[((A) >> M68K_FETCHSFT) & M68K_FETCHMASK]; \ BasePC = g_m68kcontext->Fetch[((A) >> M68K_FETCHSFT) & M68K_FETCHMASK]; \
/* BasePC -= (A) & 0xFF000000; */ \ /* BasePC -= (A) & 0xFF000000; */ \
PC = (u16*)(((A) & M68K_ADR_MASK) + BasePC); PC = (u16*)(((A) & M68K_ADR_MASK) + BasePC);
#define SET_PC_BASE(P,B,A) \ #else
(B) = g_m68kcontext->Fetch[((A) >> M68K_FETCHSFT) & M68K_FETCHMASK]; \
/* (B) -= (A) & 0xFF000000; */ \ #define SET_PC(A) \
(P) = (u16*)(((A) & M68K_ADR_MASK) + (B)); BasePC = g_m68kcontext->Fetch[((A) >> M68K_FETCHSFT) & M68K_FETCHMASK]; \
BasePC -= (A) & 0xFF000000; \
PC = (u16*)((A) + BasePC);
#endif
#define PRE_IO \ #define PRE_IO \
@ -717,7 +725,10 @@ static FAMEC_EXTRA_INLINE void execute_exception(s32 vect)
/* adjust SR */ /* adjust SR */
flag_S = M68K_SR_S; flag_S = M68K_SR_S;
newPC&=M68K_ADR_MASK&~1; // don't crash on games with bad vector tables #ifndef FAMEC_32BIT_PC
newPC&=M68K_ADR_MASK
#endif
newPC&=~1; // don't crash on games with bad vector tables
SET_PC(newPC) SET_PC(newPC)

View file

@ -30046,7 +30046,11 @@ OPCODE(0x90D0)
res = dst - src; res = dst - src;
AREG((Opcode >> 9) & 7) = res; AREG((Opcode >> 9) & 7) = res;
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(12)
#else
RET(10) RET(10)
#endif
} }
// SUBA // SUBA
@ -30063,7 +30067,11 @@ OPCODE(0x90D8)
res = dst - src; res = dst - src;
AREG((Opcode >> 9) & 7) = res; AREG((Opcode >> 9) & 7) = res;
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(12)
#else
RET(10) RET(10)
#endif
} }
// SUBA // SUBA
@ -30080,7 +30088,11 @@ OPCODE(0x90E0)
res = dst - src; res = dst - src;
AREG((Opcode >> 9) & 7) = res; AREG((Opcode >> 9) & 7) = res;
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(14)
#else
RET(12) RET(12)
#endif
} }
// SUBA // SUBA
@ -30097,7 +30109,11 @@ OPCODE(0x90E8)
res = dst - src; res = dst - src;
AREG((Opcode >> 9) & 7) = res; AREG((Opcode >> 9) & 7) = res;
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(16)
#else
RET(14) RET(14)
#endif
} }
// SUBA // SUBA
@ -30114,7 +30130,11 @@ OPCODE(0x90F0)
res = dst - src; res = dst - src;
AREG((Opcode >> 9) & 7) = res; AREG((Opcode >> 9) & 7) = res;
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(18)
#else
RET(16) RET(16)
#endif
} }
// SUBA // SUBA
@ -30130,7 +30150,11 @@ OPCODE(0x90F8)
res = dst - src; res = dst - src;
AREG((Opcode >> 9) & 7) = res; AREG((Opcode >> 9) & 7) = res;
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(16)
#else
RET(14) RET(14)
#endif
} }
// SUBA // SUBA
@ -30146,7 +30170,11 @@ OPCODE(0x90F9)
res = dst - src; res = dst - src;
AREG((Opcode >> 9) & 7) = res; AREG((Opcode >> 9) & 7) = res;
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(20)
#else
RET(18) RET(18)
#endif
} }
// SUBA // SUBA
@ -30163,7 +30191,11 @@ OPCODE(0x90FA)
res = dst - src; res = dst - src;
AREG((Opcode >> 9) & 7) = res; AREG((Opcode >> 9) & 7) = res;
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(16)
#else
RET(14) RET(14)
#endif
} }
// SUBA // SUBA
@ -30180,7 +30212,11 @@ OPCODE(0x90FB)
res = dst - src; res = dst - src;
AREG((Opcode >> 9) & 7) = res; AREG((Opcode >> 9) & 7) = res;
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(18)
#else
RET(16) RET(16)
#endif
} }
// SUBA // SUBA
@ -30210,7 +30246,11 @@ OPCODE(0x90DF)
res = dst - src; res = dst - src;
AREG((Opcode >> 9) & 7) = res; AREG((Opcode >> 9) & 7) = res;
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(12)
#else
RET(10) RET(10)
#endif
} }
// SUBA // SUBA
@ -30227,7 +30267,11 @@ OPCODE(0x90E7)
res = dst - src; res = dst - src;
AREG((Opcode >> 9) & 7) = res; AREG((Opcode >> 9) & 7) = res;
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(14)
#else
RET(12) RET(12)
#endif
} }
// SUBA // SUBA

View file

@ -593,7 +593,7 @@ void emu_Loop(void)
{ {
int ret, snd_excess_add, stereo; int ret, snd_excess_add, stereo;
if (PsndRate != PsndRate_old || (PicoOpt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) { if (PsndRate != PsndRate_old || (PicoOpt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) {
sound_rerate(Pico.m.frame_count ? 1 : 0); PsndRerate(Pico.m.frame_count ? 1 : 0);
} }
stereo=(PicoOpt&8)>>3; stereo=(PicoOpt&8)>>3;
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps; snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;

View file

@ -682,7 +682,7 @@ void emu_Loop(void)
Reset940(1, 2); Reset940(1, 2);
Pause940(1); Pause940(1);
} }
sound_rerate(Pico.m.frame_count ? 1 : 0); PsndRerate(Pico.m.frame_count ? 1 : 0);
} }
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps; snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n", printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",

Binary file not shown.

Binary file not shown.

View file

@ -142,6 +142,7 @@ void emu_setDefaultConfig(void)
currentConfig.KeyBinds[13] = 1<<5; currentConfig.KeyBinds[13] = 1<<5;
currentConfig.KeyBinds[15] = 1<<6; currentConfig.KeyBinds[15] = 1<<6;
currentConfig.KeyBinds[ 3] = 1<<7; currentConfig.KeyBinds[ 3] = 1<<7;
currentConfig.KeyBinds[12] = 1<<26; // switch rnd
currentConfig.KeyBinds[ 8] = 1<<27; // save state currentConfig.KeyBinds[ 8] = 1<<27; // save state
currentConfig.KeyBinds[ 9] = 1<<28; // load state currentConfig.KeyBinds[ 9] = 1<<28; // load state
currentConfig.PicoCDBuffers = 0; currentConfig.PicoCDBuffers = 0;
@ -538,7 +539,7 @@ static void sound_prepare(void)
samples_made = samples_done = 0; samples_made = samples_done = 0;
if (PsndRate != PsndRate_old || (PicoOpt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) { if (PsndRate != PsndRate_old || (PicoOpt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) {
sound_rerate(Pico.m.frame_count ? 1 : 0); PsndRerate(Pico.m.frame_count ? 1 : 0);
} }
stereo=(PicoOpt&8)>>3; stereo=(PicoOpt&8)>>3;