mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
mcd, improve polling detection
This commit is contained in:
parent
ca1b77e601
commit
fbebab6934
2 changed files with 18 additions and 11 deletions
|
@ -281,7 +281,8 @@ void pcd_irq_s68k(int irq, int state)
|
||||||
{
|
{
|
||||||
if (state) {
|
if (state) {
|
||||||
SekInterruptS68k(irq);
|
SekInterruptS68k(irq);
|
||||||
SekSetStopS68k(0);
|
if (SekIsStoppedS68k())
|
||||||
|
SekSetStopS68k(0);
|
||||||
Pico_mcd->m.s68k_poll_a = 0;
|
Pico_mcd->m.s68k_poll_a = 0;
|
||||||
} else
|
} else
|
||||||
SekInterruptClearS68k(irq);
|
SekInterruptClearS68k(irq);
|
||||||
|
@ -342,21 +343,24 @@ void pcd_run_cpus_normal(int m68k_cycles)
|
||||||
|
|
||||||
#ifdef USE_POLL_DETECT
|
#ifdef USE_POLL_DETECT
|
||||||
if (Pico_mcd->m.m68k_poll_cnt >= 16) {
|
if (Pico_mcd->m.m68k_poll_cnt >= 16) {
|
||||||
|
int s68k_left;
|
||||||
// main CPU is polling, (wake and) run sub only
|
// main CPU is polling, (wake and) run sub only
|
||||||
SekSetStopS68k(0);
|
if (SekIsStoppedS68k())
|
||||||
pcd_sync_s68k(Pico.t.m68c_aim, 1);
|
SekSetStopS68k(0);
|
||||||
|
s68k_left = pcd_sync_s68k(Pico.t.m68c_aim, 1);
|
||||||
|
|
||||||
Pico.t.m68c_cnt = Pico.t.m68c_aim;
|
Pico.t.m68c_cnt = Pico.t.m68c_aim;
|
||||||
|
if (s68k_left > 0)
|
||||||
|
Pico.t.m68c_cnt -= ((long long)s68k_left * mcd_s68k_cycle_mult >> 16);
|
||||||
if (SekIsStoppedS68k()) {
|
if (SekIsStoppedS68k()) {
|
||||||
// slave has stopped, wake master to avoid lockups
|
// slave has stopped, wake master to avoid lockups
|
||||||
Pico_mcd->m.m68k_poll_cnt = 0;
|
Pico_mcd->m.m68k_poll_cnt = 0;
|
||||||
}
|
}
|
||||||
elprintf(EL_CDPOLL, "m68k poll [%02x] x%d @%06x",
|
elprintf(EL_CDPOLL, "m68k poll [%02x] x%d @%06x",
|
||||||
Pico_mcd->m.m68k_poll_a, Pico_mcd->m.m68k_poll_cnt, SekPc);
|
Pico_mcd->m.m68k_poll_a, Pico_mcd->m.m68k_poll_cnt, SekPc);
|
||||||
}
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
SekRunM68kOnce();
|
||||||
SekRunM68kOnce();
|
|
||||||
if (Pico_mcd->m.need_sync) {
|
if (Pico_mcd->m.need_sync) {
|
||||||
Pico_mcd->m.need_sync = 0;
|
Pico_mcd->m.need_sync = 0;
|
||||||
pcd_sync_s68k(Pico.t.m68c_cnt, 0);
|
pcd_sync_s68k(Pico.t.m68c_cnt, 0);
|
||||||
|
|
|
@ -144,6 +144,8 @@ void m68k_reg_write8(u32 a, u32 d)
|
||||||
u32 dold;
|
u32 dold;
|
||||||
a &= 0x3f;
|
a &= 0x3f;
|
||||||
|
|
||||||
|
Pico_mcd->m.m68k_poll_cnt = 0;
|
||||||
|
|
||||||
switch (a) {
|
switch (a) {
|
||||||
case 0:
|
case 0:
|
||||||
d &= 1;
|
d &= 1;
|
||||||
|
@ -180,8 +182,7 @@ void m68k_reg_write8(u32 a, u32 d)
|
||||||
return;
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
elprintf(EL_CDREGS, "m68k: prg wp=%02x", d);
|
elprintf(EL_CDREGS, "m68k: prg wp=%02x", d);
|
||||||
Pico_mcd->s68k_regs[2] = d; // really use s68k side register
|
goto write_comm;
|
||||||
return;
|
|
||||||
case 3:
|
case 3:
|
||||||
dold = Pico_mcd->s68k_regs[3];
|
dold = Pico_mcd->s68k_regs[3];
|
||||||
elprintf(EL_CDREG3, "m68k_regs w3: %02x @%06x", (u8)d, SekPc);
|
elprintf(EL_CDREG3, "m68k_regs w3: %02x @%06x", (u8)d, SekPc);
|
||||||
|
@ -331,7 +332,7 @@ u32 s68k_reg_read16(u32 a)
|
||||||
|
|
||||||
d = (Pico_mcd->s68k_regs[a]<<8) | Pico_mcd->s68k_regs[a+1];
|
d = (Pico_mcd->s68k_regs[a]<<8) | Pico_mcd->s68k_regs[a+1];
|
||||||
|
|
||||||
if (a >= 0x0e && a < 0x20)
|
if (a >= 0x0e && a < 0x30)
|
||||||
return s68k_poll_detect(a, d);
|
return s68k_poll_detect(a, d);
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
|
@ -494,6 +495,8 @@ void s68k_reg_write16(u32 a, u32 d)
|
||||||
{
|
{
|
||||||
u8 *r = Pico_mcd->s68k_regs;
|
u8 *r = Pico_mcd->s68k_regs;
|
||||||
|
|
||||||
|
Pico_mcd->m.s68k_poll_cnt = 0;
|
||||||
|
|
||||||
if ((a & 0x1f0) == 0x20)
|
if ((a & 0x1f0) == 0x20)
|
||||||
goto write_comm;
|
goto write_comm;
|
||||||
|
|
||||||
|
@ -501,8 +504,8 @@ void s68k_reg_write16(u32 a, u32 d)
|
||||||
case 0x0e:
|
case 0x0e:
|
||||||
// special case, 2 byte writes would be handled differently
|
// special case, 2 byte writes would be handled differently
|
||||||
// TODO: verify
|
// TODO: verify
|
||||||
r[0xf] = d;
|
d = (u8)d | (r[0xe] << 8);
|
||||||
return;
|
goto write_comm;
|
||||||
case 0x58: // stamp data size
|
case 0x58: // stamp data size
|
||||||
r[0x59] = d & 7;
|
r[0x59] = d & 7;
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue