From: notaz Date: Mon, 29 Oct 2007 18:16:46 +0000 (+0000) Subject: psp bugfixes, refactoring, stuff X-Git-Tag: v1.85~634 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d917eea21607c7c239d4b0cd850d660c0c8e4c5;p=picodrive.git psp bugfixes, refactoring, stuff git-svn-id: file:///home/notaz/opt/svn/PicoDrive@284 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/Pico/Debug.c b/Pico/Debug.c index 6962a6aa..1c221229 100644 --- a/Pico/Debug.c +++ b/Pico/Debug.c @@ -137,8 +137,8 @@ int CM_compareRun(int cyc) // compare PC m68ki_cpu.pc&=~1; - if ( SekPc != (m68ki_cpu.pc&0xffffff) ) { - dprintf("PC: %06x vs %06x", SekPc, m68ki_cpu.pc&0xffffff); + if (SekPc != m68ki_cpu.pc) { + dprintf("PC: %06x vs %06x", SekPc, m68ki_cpu.pc); err=1; } diff --git a/Pico/Pico.c b/Pico/Pico.c index 38c8233c..4d6f9400 100644 --- a/Pico/Pico.c +++ b/Pico/Pico.c @@ -137,7 +137,7 @@ int PicoReset(int hard) Pico.m.pal=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) { PicoResetMCD(hard); @@ -255,17 +255,17 @@ static __inline void getSamples(int y) if(y == 224) { if(emustatus & 2) - curr_pos += sound_render(curr_pos, PsndLen-PsndLen/2); - else curr_pos = sound_render(0, PsndLen); + curr_pos += PsndRender(curr_pos, PsndLen-PsndLen/2); + else curr_pos = PsndRender(0, PsndLen); if (emustatus&1) emustatus|=2; else emustatus&=~2; if (PicoWriteSound) PicoWriteSound(curr_pos); // clear sound buffer - sound_clear(); + PsndClear(); } else if(emustatus & 3) { emustatus|= 2; 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) { // 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++) { - sound_timers_and_dac(line); + Psnd_timers_and_dac(line); if ((line == 224 || line == line_sample) && PsndOut) getSamples(line); if (line == 32 && PsndOut) emustatus &= ~1; 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 if (!(PicoOpt&1) && PsndOut) { - int len = sound_render(0, PsndLen); + int len = PsndRender(0, PsndLen); if (PicoWriteSound) PicoWriteSound(len); // clear sound buffer - sound_clear(); + PsndClear(); } // a gap between flags set and vint diff --git a/Pico/Pico.h b/Pico/Pico.h index b337f8dc..3b7f62b2 100644 --- a/Pico/Pico.h +++ b/Pico/Pico.h @@ -130,7 +130,7 @@ extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to us // sound.c extern int PsndRate,PsndLen; extern short *PsndOut; -void sound_rerate(int preserve_state); +void PsndRerate(int preserve_state); // Utils.c extern int PicuAnd; diff --git a/Pico/PicoFrameHints.c b/Pico/PicoFrameHints.c index 91959d85..b5cef7d1 100644 --- a/Pico/PicoFrameHints.c +++ b/Pico/PicoFrameHints.c @@ -130,7 +130,7 @@ static int PicoFrameHints(void) PicoLine(y); if(PicoOpt&1) - sound_timers_and_dac(y); + Psnd_timers_and_dac(y); #ifndef PICO_CD // get samples from sound chips @@ -192,7 +192,7 @@ static int PicoFrameHints(void) z80_int(); if (PicoOpt&1) - sound_timers_and_dac(y); + Psnd_timers_and_dac(y); // get samples from sound chips #ifndef PICO_CD @@ -223,7 +223,7 @@ static int PicoFrameHints(void) #endif if(PicoOpt&1) - sound_timers_and_dac(y); + Psnd_timers_and_dac(y); // Run scanline: if (Pico.m.dma_xfers) SekCyclesBurn(CheckDMA()); diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index c086d7ad..9aead107 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -392,10 +392,10 @@ PICO_INTERNAL_ASM void wram_1M_to_2M(unsigned char *m); PICO_INTERNAL void PicoCDBufferRead(void *dest, int lba); // sound/sound.c -PICO_INTERNAL void sound_reset(void); -PICO_INTERNAL void sound_timers_and_dac(int raster); -PICO_INTERNAL int sound_render(int offset, int length); -PICO_INTERNAL void sound_clear(void); +PICO_INTERNAL void PsndReset(void); +PICO_INTERNAL void Psnd_timers_and_dac(int raster); +PICO_INTERNAL int PsndRender(int offset, int length); +PICO_INTERNAL void PsndClear(void); // z80 functionality wrappers PICO_INTERNAL void z80_init(void); PICO_INTERNAL void z80_resetCycles(void); diff --git a/Pico/cd/Pico.c b/Pico/cd/Pico.c index 1ffd44bd..def0a418 100644 --- a/Pico/cd/Pico.c +++ b/Pico/cd/Pico.c @@ -235,10 +235,10 @@ static __inline void update_chips(void) static __inline void getSamples(int y) { - int len = sound_render(0, PsndLen); + int len = PsndRender(0, PsndLen); if (PicoWriteSound) PicoWriteSound(len); // clear sound buffer - sound_clear(); + PsndClear(); } diff --git a/Pico/sound/sound.c b/Pico/sound/sound.c index 99500847..5f9836b8 100644 --- a/Pico/sound/sound.c +++ b/Pico/sound/sound.c @@ -101,7 +101,7 @@ static void dac_recalculate(void) } -PICO_INTERNAL void sound_reset(void) +PICO_INTERNAL void PsndReset(void) { void *ym2612_regs; @@ -110,12 +110,12 @@ PICO_INTERNAL void sound_reset(void) memset(ym2612_regs, 0, 0x200+4); z80startCycle = z80stopCycle = 0; - sound_rerate(0); + PsndRerate(0); } // to be called after changing sound rate or chips -void sound_rerate(int preserve_state) +void PsndRerate(int preserve_state) { void *state = NULL; int target_fps = Pico.m.pal ? 50 : 60; @@ -163,12 +163,12 @@ void sound_rerate(int preserve_state) // clear all buffers memset32(PsndBuffer, 0, sizeof(PsndBuffer)/4); if (PsndOut) - sound_clear(); + PsndClear(); } // 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 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; 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 = PsndBuffer+offset; @@ -316,23 +316,26 @@ static unsigned int DrZ80_rebaseSP(unsigned short a) return drZ80.Z80SP_BASE + a; } -static unsigned char DrZ80_in(unsigned short p) +static void DrZ80_irq_callback() { - elprintf(EL_ANOMALY, "Z80 port %04x read", p); - return 0xff; + drZ80.Z80_IRQ = 0; // lower irq when accepted } +#endif -static void DrZ80_out(unsigned short p,unsigned char d) +#if defined(_USE_DRZ80) || defined(_USE_CZ80) +static unsigned char z80_in(unsigned short p) { - elprintf(EL_ANOMALY, "Z80 port %04x write %02x", p, d); + elprintf(EL_ANOMALY, "Z80 port %04x read", p); + return 0xff; } -static void DrZ80_irq_callback() +static void z80_out(unsigned short p,unsigned char d) { - drZ80.Z80_IRQ = 0; // lower irq when accepted + elprintf(EL_ANOMALY, "Z80 port %04x write %02x", p, d); } #endif + // z80 functionality wrappers PICO_INTERNAL void z80_init(void) { @@ -361,8 +364,8 @@ PICO_INTERNAL void z80_init(void) drZ80.z80_read16 =z80_read16; drZ80.z80_write8 =z80_write; drZ80.z80_write16 =z80_write16; - drZ80.z80_in =DrZ80_in; - drZ80.z80_out =DrZ80_out; + drZ80.z80_in =z80_in; + drZ80.z80_out =z80_out; drZ80.z80_irq_callback=DrZ80_irq_callback; #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_ReadB(&CZ80, (UINT8 (*)(UINT32 address))z80_read); Cz80_Set_WriteB(&CZ80, z80_write); + Cz80_Set_INPort(&CZ80, z80_in); + Cz80_Set_OUTPort(&CZ80, z80_out); #endif } diff --git a/cpu/fame/famec.c b/cpu/fame/famec.c index 3dcb8b12..76965fad 100644 --- a/cpu/fame/famec.c +++ b/cpu/fame/famec.c @@ -26,6 +26,7 @@ #define FAMEC_ADR_BITS 24 // #define FAMEC_FETCHBITS 8 #define FAMEC_DATABITS 8 +#define FAMEC_32BIT_PC #define USE_CYCLONE_TIMING #define USE_CYCLONE_TIMING_DIV @@ -289,15 +290,22 @@ static u32 flag_I; #define GET_PC \ (u32)PC - BasePC; + +#ifndef FAMEC_32BIT_PC + #define SET_PC(A) \ BasePC = g_m68kcontext->Fetch[((A) >> M68K_FETCHSFT) & M68K_FETCHMASK]; \ /* BasePC -= (A) & 0xFF000000; */ \ PC = (u16*)(((A) & M68K_ADR_MASK) + BasePC); -#define SET_PC_BASE(P,B,A) \ - (B) = g_m68kcontext->Fetch[((A) >> M68K_FETCHSFT) & M68K_FETCHMASK]; \ - /* (B) -= (A) & 0xFF000000; */ \ - (P) = (u16*)(((A) & M68K_ADR_MASK) + (B)); +#else + +#define SET_PC(A) \ + BasePC = g_m68kcontext->Fetch[((A) >> M68K_FETCHSFT) & M68K_FETCHMASK]; \ + BasePC -= (A) & 0xFF000000; \ + PC = (u16*)((A) + BasePC); + +#endif #define PRE_IO \ @@ -717,7 +725,10 @@ static FAMEC_EXTRA_INLINE void execute_exception(s32 vect) /* adjust SR */ 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) diff --git a/cpu/fame/famec_opcodes.h b/cpu/fame/famec_opcodes.h index 759c00fa..eeb3c2bb 100644 --- a/cpu/fame/famec_opcodes.h +++ b/cpu/fame/famec_opcodes.h @@ -30046,7 +30046,11 @@ OPCODE(0x90D0) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(12) +#else RET(10) +#endif } // SUBA @@ -30063,7 +30067,11 @@ OPCODE(0x90D8) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(12) +#else RET(10) +#endif } // SUBA @@ -30080,7 +30088,11 @@ OPCODE(0x90E0) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(14) +#else RET(12) +#endif } // SUBA @@ -30097,7 +30109,11 @@ OPCODE(0x90E8) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(16) +#else RET(14) +#endif } // SUBA @@ -30114,7 +30130,11 @@ OPCODE(0x90F0) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(18) +#else RET(16) +#endif } // SUBA @@ -30130,7 +30150,11 @@ OPCODE(0x90F8) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(16) +#else RET(14) +#endif } // SUBA @@ -30146,7 +30170,11 @@ OPCODE(0x90F9) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(20) +#else RET(18) +#endif } // SUBA @@ -30163,7 +30191,11 @@ OPCODE(0x90FA) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(16) +#else RET(14) +#endif } // SUBA @@ -30180,7 +30212,11 @@ OPCODE(0x90FB) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(18) +#else RET(16) +#endif } // SUBA @@ -30210,7 +30246,11 @@ OPCODE(0x90DF) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(12) +#else RET(10) +#endif } // SUBA @@ -30227,7 +30267,11 @@ OPCODE(0x90E7) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(14) +#else RET(12) +#endif } // SUBA diff --git a/platform/gizmondo/emu.c b/platform/gizmondo/emu.c index cf9a13e0..73c01dcc 100644 --- a/platform/gizmondo/emu.c +++ b/platform/gizmondo/emu.c @@ -593,7 +593,7 @@ void emu_Loop(void) { int ret, snd_excess_add, stereo; 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; snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps; diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 954d26f5..41187c5d 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -682,7 +682,7 @@ void emu_Loop(void) Reset940(1, 2); 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; printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n", diff --git a/platform/psp/data/bg32.bin b/platform/psp/data/bg32.bin index e887b124..42f4473f 100644 Binary files a/platform/psp/data/bg32.bin and b/platform/psp/data/bg32.bin differ diff --git a/platform/psp/data/bg40.bin b/platform/psp/data/bg40.bin index 73fe6666..b54a5573 100644 Binary files a/platform/psp/data/bg40.bin and b/platform/psp/data/bg40.bin differ diff --git a/platform/psp/emu.c b/platform/psp/emu.c index 0ecbcc66..0db88ca1 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -142,6 +142,7 @@ void emu_setDefaultConfig(void) currentConfig.KeyBinds[13] = 1<<5; currentConfig.KeyBinds[15] = 1<<6; currentConfig.KeyBinds[ 3] = 1<<7; + currentConfig.KeyBinds[12] = 1<<26; // switch rnd currentConfig.KeyBinds[ 8] = 1<<27; // save state currentConfig.KeyBinds[ 9] = 1<<28; // load state currentConfig.PicoCDBuffers = 0; @@ -538,7 +539,7 @@ static void sound_prepare(void) samples_made = samples_done = 0; 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;