mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-06 15:48:05 -04:00
psp bugfixes, refactoring, stuff
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@284 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
03e4f2a349
commit
9d917eea21
14 changed files with 109 additions and 48 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
16
Pico/Pico.c
16
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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
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()
|
||||
{
|
||||
drZ80.Z80_IRQ = 0; // lower irq when accepted
|
||||
}
|
||||
#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
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue