mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
z80/ym2612 reset handling improved
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@540 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
f8a6410104
commit
be297089d0
3 changed files with 42 additions and 40 deletions
|
@ -60,27 +60,46 @@ u32 z80ReadBusReq(void)
|
||||||
return d|0x80;
|
return d|0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _ASM_MEMORY_C
|
static void z80WriteBusReq(u32 d)
|
||||||
static
|
|
||||||
#endif
|
|
||||||
void z80WriteBusReq(u32 d)
|
|
||||||
{
|
{
|
||||||
d&=1; d^=1;
|
d&=1; d^=1;
|
||||||
|
elprintf(EL_BUSREQ, "set_zrun: %i->%i [%i] @%06x", Pico.m.z80Run, d, SekCyclesDone(), SekPc);
|
||||||
|
if (d ^ Pico.m.z80Run)
|
||||||
{
|
{
|
||||||
if (!d)
|
if (d)
|
||||||
|
{
|
||||||
|
z80_cycle_cnt = cycles_68k_to_z80(SekCyclesDone());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
z80stopCycle = SekCyclesDone();
|
||||||
|
if ((PicoOpt&POPT_EN_Z80) && !Pico.m.z80_reset)
|
||||||
|
PicoSyncZ80(z80stopCycle);
|
||||||
|
}
|
||||||
|
Pico.m.z80Run=d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void z80WriteReset(u32 d)
|
||||||
|
{
|
||||||
|
d&=1; d^=1;
|
||||||
|
elprintf(EL_BUSREQ, "set_zreset: %i->%i [%i] @%06x", Pico.m.z80_reset, d, SekCyclesDone(), SekPc);
|
||||||
|
if (d ^ Pico.m.z80_reset)
|
||||||
|
{
|
||||||
|
if (d)
|
||||||
{
|
{
|
||||||
if ((PicoOpt&POPT_EN_Z80) && Pico.m.z80Run)
|
if ((PicoOpt&POPT_EN_Z80) && Pico.m.z80Run)
|
||||||
{
|
PicoSyncZ80(SekCyclesDone());
|
||||||
z80stopCycle = SekCyclesDone();
|
|
||||||
PicoSyncZ80(z80stopCycle);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!Pico.m.z80Run)
|
|
||||||
z80_cycle_cnt = cycles_68k_to_z80(SekCyclesDone());
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
z80_cycle_cnt = cycles_68k_to_z80(SekCyclesDone());
|
||||||
|
z80_reset();
|
||||||
|
}
|
||||||
|
YM2612ResetChip();
|
||||||
|
timers_reset();
|
||||||
|
Pico.m.z80_reset=d;
|
||||||
}
|
}
|
||||||
elprintf(EL_BUSREQ, "set_zrun: %i->%i [%i] @%06x", Pico.m.z80Run, d, SekCyclesDone(), SekPc);
|
|
||||||
Pico.m.z80Run=(u8)d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _ASM_MEMORY_C
|
#ifndef _ASM_MEMORY_C
|
||||||
|
@ -161,17 +180,8 @@ void OtherWrite8(u32 a,u32 d)
|
||||||
if ((a&0xffffe0)==0xa10000) { IoWrite8(a, d); return; } // I/O ports
|
if ((a&0xffffe0)==0xa10000) { IoWrite8(a, d); return; } // I/O ports
|
||||||
#endif
|
#endif
|
||||||
if (a==0xa11100) { z80WriteBusReq(d); return; }
|
if (a==0xa11100) { z80WriteBusReq(d); return; }
|
||||||
if (a==0xa11200) {
|
if (a==0xa11200) { z80WriteReset(d); return; }
|
||||||
elprintf(EL_BUSREQ, "write z80Reset: %02x", d);
|
|
||||||
if (!(d&0x1)) { Pico.m.z80_reset = 1; Pico.m.z80Run = 0; YM2612ResetChip(); }
|
|
||||||
else if (Pico.m.z80_reset) {
|
|
||||||
Pico.m.z80_reset = 0;
|
|
||||||
YM2612ResetChip();
|
|
||||||
z80_reset();
|
|
||||||
timers_reset();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if !defined(_ASM_MEMORY_C) || defined(_ASM_MEMORY_C_AMIPS)
|
#if !defined(_ASM_MEMORY_C) || defined(_ASM_MEMORY_C_AMIPS)
|
||||||
if ((a&0xff7f00)==0xa06000) // Z80 BANK register
|
if ((a&0xff7f00)==0xa06000) // Z80 BANK register
|
||||||
{
|
{
|
||||||
|
@ -206,17 +216,8 @@ void OtherWrite16(u32 a,u32 d)
|
||||||
else elprintf(EL_ANOMALY, "68k z80 write with no bus or reset! [%06x] %04x @ %06x", a, d&0xffff, SekPc);
|
else elprintf(EL_ANOMALY, "68k z80 write with no bus or reset! [%06x] %04x @ %06x", a, d&0xffff, SekPc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (a==0xa11200) {
|
if (a==0xa11200) { z80WriteReset(d>>8); return; }
|
||||||
elprintf(EL_BUSREQ, "write z80reset: %04x", d);
|
|
||||||
if (!(d&0x100)) { Pico.m.z80_reset = 1; Pico.m.z80Run = 0; YM2612ResetChip(); }
|
|
||||||
else if (Pico.m.z80_reset) {
|
|
||||||
Pico.m.z80_reset = 0;
|
|
||||||
YM2612ResetChip();
|
|
||||||
z80_reset();
|
|
||||||
timers_reset();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((a&0xff7f00)==0xa06000) // Z80 BANK register
|
if ((a&0xff7f00)==0xa06000) // Z80 BANK register
|
||||||
{
|
{
|
||||||
Pico.m.z80_bank68k>>=1;
|
Pico.m.z80_bank68k>>=1;
|
||||||
|
|
|
@ -124,7 +124,7 @@ static int PicoFrameHints(void)
|
||||||
emustatus &= ~1;
|
emustatus &= ~1;
|
||||||
else if ((y == 224 || y == line_sample) && PsndOut)
|
else if ((y == 224 || y == line_sample) && PsndOut)
|
||||||
{
|
{
|
||||||
if (Pico.m.z80Run && (PicoOpt&POPT_EN_Z80))
|
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
|
||||||
PicoSyncZ80(SekCycleCnt);
|
PicoSyncZ80(SekCycleCnt);
|
||||||
if (ym2612.dacen && PsndDacLine <= y)
|
if (ym2612.dacen && PsndDacLine <= y)
|
||||||
PsndDoDAC(y);
|
PsndDoDAC(y);
|
||||||
|
@ -188,7 +188,7 @@ static int PicoFrameHints(void)
|
||||||
elprintf(EL_INTS, "vint: @ %06x [%i]", SekPc, SekCycleCnt);
|
elprintf(EL_INTS, "vint: @ %06x [%i]", SekPc, SekCycleCnt);
|
||||||
SekInterrupt(6);
|
SekInterrupt(6);
|
||||||
}
|
}
|
||||||
if (Pico.m.z80Run && (PicoOpt&POPT_EN_Z80)) {
|
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80)) {
|
||||||
PicoSyncZ80(SekCycleCnt);
|
PicoSyncZ80(SekCycleCnt);
|
||||||
elprintf(EL_INTS, "zint");
|
elprintf(EL_INTS, "zint");
|
||||||
z80_int();
|
z80_int();
|
||||||
|
@ -246,7 +246,7 @@ static int PicoFrameHints(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// sync z80
|
// sync z80
|
||||||
if (Pico.m.z80Run && (PicoOpt&POPT_EN_Z80))
|
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
|
||||||
PicoSyncZ80(Pico.m.pal ? 151809 : 127671); // cycles adjusted for converter
|
PicoSyncZ80(Pico.m.pal ? 151809 : 127671); // cycles adjusted for converter
|
||||||
if (PsndOut && ym2612.dacen && PsndDacLine <= lines-1)
|
if (PsndOut && ym2612.dacen && PsndDacLine <= lines-1)
|
||||||
PsndDoDAC(lines-1);
|
PsndDoDAC(lines-1);
|
||||||
|
|
|
@ -1668,6 +1668,8 @@ void YM2612Init_(int clock, int rate)
|
||||||
ym2612.OPN.ST.clock = clock;
|
ym2612.OPN.ST.clock = clock;
|
||||||
ym2612.OPN.ST.rate = rate;
|
ym2612.OPN.ST.rate = rate;
|
||||||
|
|
||||||
|
OPNSetPres( 6*24 );
|
||||||
|
|
||||||
/* Extend handler */
|
/* Extend handler */
|
||||||
YM2612ResetChip_();
|
YM2612ResetChip_();
|
||||||
}
|
}
|
||||||
|
@ -1680,7 +1682,6 @@ void YM2612ResetChip_(void)
|
||||||
|
|
||||||
memset(ym2612.REGS, 0, sizeof(ym2612.REGS));
|
memset(ym2612.REGS, 0, sizeof(ym2612.REGS));
|
||||||
|
|
||||||
OPNSetPres( 6*24 );
|
|
||||||
set_timers( 0x30 ); /* mode 0 , timer reset */
|
set_timers( 0x30 ); /* mode 0 , timer reset */
|
||||||
ym2612.REGS[0x27] = 0x30;
|
ym2612.REGS[0x27] = 0x30;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue