mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
32x, some reset related fixes
This commit is contained in:
parent
0290987ccb
commit
eec6905e0b
2 changed files with 29 additions and 24 deletions
|
@ -35,6 +35,9 @@ void p32x_update_irls(SH2 *active_sh2, unsigned int m68k_cycles)
|
||||||
int irqs, mlvl = 0, slvl = 0;
|
int irqs, mlvl = 0, slvl = 0;
|
||||||
int mrun, srun;
|
int mrun, srun;
|
||||||
|
|
||||||
|
if ((Pico32x.regs[0] & (P32XS_nRES|P32XS_ADEN)) != (P32XS_nRES|P32XS_ADEN))
|
||||||
|
return;
|
||||||
|
|
||||||
if (active_sh2 != NULL)
|
if (active_sh2 != NULL)
|
||||||
m68k_cycles = sh2_cycles_done_m68k(active_sh2);
|
m68k_cycles = sh2_cycles_done_m68k(active_sh2);
|
||||||
|
|
||||||
|
@ -100,13 +103,21 @@ void Pico32xStartup(void)
|
||||||
{
|
{
|
||||||
elprintf(EL_STATUS|EL_32X, "32X startup");
|
elprintf(EL_STATUS|EL_32X, "32X startup");
|
||||||
|
|
||||||
// TODO: OOM handling
|
|
||||||
PicoIn.AHW |= PAHW_32X;
|
PicoIn.AHW |= PAHW_32X;
|
||||||
sh2_init(&msh2, 0, &ssh2);
|
// TODO: OOM handling
|
||||||
msh2.irq_callback = sh2_irq_cb;
|
if (Pico32xMem == NULL) {
|
||||||
sh2_init(&ssh2, 1, &msh2);
|
Pico32xMem = plat_mmap(0x06000000, sizeof(*Pico32xMem), 0, 0);
|
||||||
ssh2.irq_callback = sh2_irq_cb;
|
if (Pico32xMem == NULL) {
|
||||||
|
elprintf(EL_STATUS, "OOM");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memset(Pico32xMem, 0, sizeof(struct Pico32xMem));
|
||||||
|
|
||||||
|
sh2_init(&msh2, 0, &ssh2);
|
||||||
|
msh2.irq_callback = sh2_irq_cb;
|
||||||
|
sh2_init(&ssh2, 1, &msh2);
|
||||||
|
ssh2.irq_callback = sh2_irq_cb;
|
||||||
|
}
|
||||||
PicoMemSetup32x();
|
PicoMemSetup32x();
|
||||||
p32x_pwm_ctl_changed();
|
p32x_pwm_ctl_changed();
|
||||||
p32x_timers_recalc();
|
p32x_timers_recalc();
|
||||||
|
@ -117,6 +128,8 @@ void Pico32xStartup(void)
|
||||||
|
|
||||||
if (!Pico.m.pal)
|
if (!Pico.m.pal)
|
||||||
Pico32x.vdp_regs[0] |= P32XV_nPAL;
|
Pico32x.vdp_regs[0] |= P32XV_nPAL;
|
||||||
|
else
|
||||||
|
Pico32x.vdp_regs[0] &= ~P32XV_nPAL;
|
||||||
|
|
||||||
rendstatus_old = -1;
|
rendstatus_old = -1;
|
||||||
|
|
||||||
|
@ -126,11 +139,8 @@ void Pico32xStartup(void)
|
||||||
|
|
||||||
void Pico32xShutdown(void)
|
void Pico32xShutdown(void)
|
||||||
{
|
{
|
||||||
sh2_finish(&msh2);
|
Pico32x.sh2_regs[0] &= ~P32XS2_ADEN;
|
||||||
sh2_finish(&ssh2);
|
Pico32x.regs[6] |= P32XS_RV;
|
||||||
|
|
||||||
Pico32x.vdp_regs[0] |= P32XS_nRES;
|
|
||||||
Pico32x.vdp_regs[6] |= P32XS_RV;
|
|
||||||
|
|
||||||
rendstatus_old = -1;
|
rendstatus_old = -1;
|
||||||
|
|
||||||
|
@ -212,6 +222,9 @@ void PicoUnload32x(void)
|
||||||
if (PicoIn.AHW & PAHW_32X)
|
if (PicoIn.AHW & PAHW_32X)
|
||||||
Pico32xShutdown();
|
Pico32xShutdown();
|
||||||
|
|
||||||
|
sh2_finish(&msh2);
|
||||||
|
sh2_finish(&ssh2);
|
||||||
|
|
||||||
if (Pico32xMem != NULL)
|
if (Pico32xMem != NULL)
|
||||||
plat_munmap(Pico32xMem, sizeof(*Pico32xMem));
|
plat_munmap(Pico32xMem, sizeof(*Pico32xMem));
|
||||||
Pico32xMem = NULL;
|
Pico32xMem = NULL;
|
||||||
|
@ -226,6 +239,7 @@ void PicoReset32x(void)
|
||||||
p32x_pwm_ctl_changed();
|
p32x_pwm_ctl_changed();
|
||||||
p32x_timers_recalc();
|
p32x_timers_recalc();
|
||||||
Pico32x.vdp_regs[0] &= ~P32XV_Mx; // 32X graphics disabled
|
Pico32x.vdp_regs[0] &= ~P32XV_Mx; // 32X graphics disabled
|
||||||
|
Pico32x.pending_fb = Pico32x.vdp_regs[0x0a/2] & P32XV_FS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,9 +278,8 @@ static void p32x_start_blank(void)
|
||||||
|
|
||||||
// FB swap waits until vblank
|
// FB swap waits until vblank
|
||||||
if ((Pico32x.vdp_regs[0x0a/2] ^ Pico32x.pending_fb) & P32XV_FS) {
|
if ((Pico32x.vdp_regs[0x0a/2] ^ Pico32x.pending_fb) & P32XV_FS) {
|
||||||
Pico32x.vdp_regs[0x0a/2] &= ~P32XV_FS;
|
Pico32x.vdp_regs[0x0a/2] ^= P32XV_FS;
|
||||||
Pico32x.vdp_regs[0x0a/2] |= Pico32x.pending_fb;
|
Pico32xSwapDRAM(Pico32x.pending_fb ^ P32XV_FS);
|
||||||
Pico32xSwapDRAM(Pico32x.pending_fb ^ 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p32x_trigger_irq(NULL, Pico.t.m68c_aim, P32XI_VINT);
|
p32x_trigger_irq(NULL, Pico.t.m68c_aim, P32XI_VINT);
|
||||||
|
|
|
@ -695,12 +695,12 @@ static void p32x_vdp_write8(u32 a, u32 d)
|
||||||
r[4 / 2] = d & 0xff;
|
r[4 / 2] = d & 0xff;
|
||||||
break;
|
break;
|
||||||
case 0x0b:
|
case 0x0b:
|
||||||
d &= 1;
|
d &= P32XV_FS;
|
||||||
Pico32x.pending_fb = d;
|
Pico32x.pending_fb = d;
|
||||||
// if we are blanking and FS bit is changing
|
// if we are blanking and FS bit is changing
|
||||||
if (((r[0x0a/2] & P32XV_VBLK) || (r[0] & P32XV_Mx) == 0) && ((r[0x0a/2] ^ d) & P32XV_FS)) {
|
if (((r[0x0a/2] & P32XV_VBLK) || (r[0] & P32XV_Mx) == 0) && ((r[0x0a/2] ^ d) & P32XV_FS)) {
|
||||||
r[0x0a/2] ^= P32XV_FS;
|
r[0x0a/2] ^= P32XV_FS;
|
||||||
Pico32xSwapDRAM(d ^ 1);
|
Pico32xSwapDRAM(d ^ P32XV_FS);
|
||||||
elprintf(EL_32X, "VDP FS: %d", r[0x0a/2] & P32XV_FS);
|
elprintf(EL_32X, "VDP FS: %d", r[0x0a/2] & P32XV_FS);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2303,14 +2303,6 @@ void PicoMemSetup32x(void)
|
||||||
unsigned int rs;
|
unsigned int rs;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (Pico32xMem == NULL)
|
|
||||||
Pico32xMem = plat_mmap(0x06000000, sizeof(*Pico32xMem), 0, 0);
|
|
||||||
if (Pico32xMem == NULL) {
|
|
||||||
elprintf(EL_STATUS, "OOM");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
memset(Pico32xMem, 0, sizeof(struct Pico32xMem));
|
|
||||||
|
|
||||||
get_bios();
|
get_bios();
|
||||||
|
|
||||||
// cartridge area becomes unmapped
|
// cartridge area becomes unmapped
|
||||||
|
@ -2446,7 +2438,7 @@ void PicoMemSetup32x(void)
|
||||||
ssh2_read32_map[0xc0/2].addr = MAP_MEMORY(ssh2.data_array);
|
ssh2_read32_map[0xc0/2].addr = MAP_MEMORY(ssh2.data_array);
|
||||||
|
|
||||||
// map DRAM area, both 68k and SH2
|
// map DRAM area, both 68k and SH2
|
||||||
Pico32xSwapDRAM(1);
|
Pico32xSwapDRAM((Pico32x.vdp_regs[0x0a / 2] & P32XV_FS) ^ P32XV_FS);
|
||||||
|
|
||||||
msh2.read8_map = msh2_read8_map; ssh2.read8_map = ssh2_read8_map;
|
msh2.read8_map = msh2_read8_map; ssh2.read8_map = ssh2_read8_map;
|
||||||
msh2.read16_map = msh2_read16_map; ssh2.read16_map = ssh2_read16_map;
|
msh2.read16_map = msh2_read16_map; ssh2.read16_map = ssh2_read16_map;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue