mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
bugfixes, state load for new mode
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@468 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
538a6098d4
commit
453d2a6eda
9 changed files with 32 additions and 44 deletions
|
@ -159,7 +159,7 @@ static int PicoAreaScan(int PmovAction,unsigned int ver, void *PmovFile)
|
||||||
ScanVar(sn76496_regs,28*4,"SN76496state", PmovFile, PmovAction); // regs and other stuff
|
ScanVar(sn76496_regs,28*4,"SN76496state", PmovFile, PmovAction); // regs and other stuff
|
||||||
if(PicoOpt&1) {
|
if(PicoOpt&1) {
|
||||||
ScanVar(ym2612_regs, 0x200+4, "YM2612state", PmovFile, PmovAction); // regs + addr line
|
ScanVar(ym2612_regs, 0x200+4, "YM2612state", PmovFile, PmovAction); // regs + addr line
|
||||||
if((PmovAction&3)==2) YM2612PicoStateLoad(); // reload YM2612 state from it's regs
|
if((PmovAction&3)==2) ym2612_unpack_state(); // reload YM2612 state from it's regs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -712,7 +712,7 @@ static void PicoCartDetect(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unusual region 'code'
|
// Unusual region 'code'
|
||||||
if (rom_strcmp(0x1f0, "EUROPE") == 0)
|
if (rom_strcmp(0x1f0, "EUROPE") == 0 || rom_strcmp(0x1f0, "Europe") == 0)
|
||||||
*(int *) (Pico.rom+0x1f0) = 0x20204520;
|
*(int *) (Pico.rom+0x1f0) = 0x20204520;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -883,14 +883,13 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80)
|
||||||
return YM2612Write_(a, d);
|
return YM2612Write_(a, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: savestates
|
|
||||||
#define ym2612_read_local() \
|
#define ym2612_read_local() \
|
||||||
if (xcycles >= timer_a_next_oflow) \
|
if (xcycles >= timer_a_next_oflow) \
|
||||||
ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 1; \
|
ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 1; \
|
||||||
if (xcycles >= timer_b_next_oflow) \
|
if (xcycles >= timer_b_next_oflow) \
|
||||||
ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 2
|
ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 2
|
||||||
|
|
||||||
|
|
||||||
u32 ym2612_read_local_z80(void)
|
u32 ym2612_read_local_z80(void)
|
||||||
{
|
{
|
||||||
int xcycles = z80_cyclesDone() << 8;
|
int xcycles = z80_cyclesDone() << 8;
|
||||||
|
@ -913,6 +912,23 @@ u32 ym2612_read_local_68k(void)
|
||||||
return ym2612.OPN.ST.status;
|
return ym2612.OPN.ST.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: new ym2612 savestates
|
||||||
|
void ym2612_unpack_state(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
YM2612PicoStateLoad();
|
||||||
|
|
||||||
|
// feed all the registers and update internal state
|
||||||
|
for (i = 0x20; i < 0xC0; i++) {
|
||||||
|
ym2612_write_local(0, i, 0);
|
||||||
|
ym2612_write_local(1, ym2612.REGS[i], 0);
|
||||||
|
}
|
||||||
|
for (i = 0x30; i < 0xC0; i++) {
|
||||||
|
ym2612_write_local(2, i, 0);
|
||||||
|
ym2612_write_local(3, ym2612.REGS[i|0x100], 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
// z80 memhandlers
|
// z80 memhandlers
|
||||||
|
|
||||||
|
|
|
@ -479,6 +479,7 @@ extern int timer_a_next_oflow, timer_a_step, timer_a_offset; // in z80 cycles
|
||||||
extern int timer_b_next_oflow, timer_b_step, timer_b_offset;
|
extern int timer_b_next_oflow, timer_b_step, timer_b_offset;
|
||||||
|
|
||||||
void ym2612_sync_timers(int z80_cycles, int mode_old, int mode_new);
|
void ym2612_sync_timers(int z80_cycles, int mode_old, int mode_new);
|
||||||
|
void ym2612_unpack_state(void);
|
||||||
|
|
||||||
#define timers_cycle() \
|
#define timers_cycle() \
|
||||||
if (timer_a_next_oflow > 0 && timer_a_next_oflow < 0x70000000) \
|
if (timer_a_next_oflow > 0 && timer_a_next_oflow < 0x70000000) \
|
||||||
|
|
|
@ -230,7 +230,7 @@ PICO_INTERNAL int PicoCdLoadState(void *file)
|
||||||
case CHUNK_PSG: CHECKED_READ2(28*4, sn76496_regs); break;
|
case CHUNK_PSG: CHECKED_READ2(28*4, sn76496_regs); break;
|
||||||
case CHUNK_FM:
|
case CHUNK_FM:
|
||||||
CHECKED_READ2(0x200+4, ym2612_regs);
|
CHECKED_READ2(0x200+4, ym2612_regs);
|
||||||
YM2612PicoStateLoad();
|
ym2612_unpack_state();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// cd stuff
|
// cd stuff
|
||||||
|
|
|
@ -140,7 +140,7 @@ void PsndRerate(int preserve_state)
|
||||||
if (preserve_state) {
|
if (preserve_state) {
|
||||||
// feed it back it's own registers, just like after loading state
|
// feed it back it's own registers, just like after loading state
|
||||||
memcpy(YM2612GetRegs(), state, 0x200);
|
memcpy(YM2612GetRegs(), state, 0x200);
|
||||||
YM2612PicoStateLoad();
|
ym2612_unpack_state();
|
||||||
if ((PicoAHW & PAHW_MCD) && !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1))
|
if ((PicoAHW & PAHW_MCD) && !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1))
|
||||||
cdda_start_play();
|
cdda_start_play();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1863,26 +1863,7 @@ int YM2612PicoTick_(int n)
|
||||||
|
|
||||||
void YM2612PicoStateLoad_(void)
|
void YM2612PicoStateLoad_(void)
|
||||||
{
|
{
|
||||||
#ifndef EXTERNAL_YM2612
|
|
||||||
int i, real_A1 = ym2612.addr_A1;
|
|
||||||
|
|
||||||
reset_channels( &ym2612.CH[0] );
|
reset_channels( &ym2612.CH[0] );
|
||||||
|
|
||||||
// feed all the registers and update internal state
|
|
||||||
for(i = 0; i < 0x100; i++) {
|
|
||||||
YM2612Write_(0, i);
|
|
||||||
YM2612Write_(1, ym2612.REGS[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; i < 0x100; i++) {
|
|
||||||
YM2612Write_(2, i);
|
|
||||||
YM2612Write_(3, ym2612.REGS[i|0x100]);
|
|
||||||
}
|
|
||||||
|
|
||||||
ym2612.addr_A1 = real_A1;
|
|
||||||
#else
|
|
||||||
reset_channels( &ym2612.CH[0] );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef EXTERNAL_YM2612
|
#ifndef EXTERNAL_YM2612
|
||||||
|
|
|
@ -178,24 +178,11 @@ void YM2612PicoStateLoad_940(void)
|
||||||
{
|
{
|
||||||
UINT8 *REGS = YM2612GetRegs();
|
UINT8 *REGS = YM2612GetRegs();
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* make sure JOB940_PICOSTATELOAD gets done before next JOB940_YM2612UPDATEONE */
|
/* make sure JOB940_PICOSTATELOAD gets done before next JOB940_YM2612UPDATEONE */
|
||||||
add_job_940(JOB940_PICOSTATELOAD);
|
add_job_940(JOB940_PICOSTATELOAD);
|
||||||
if (CHECK_BUSY(JOB940_PICOSTATELOAD)) wait_busy_940(JOB940_PICOSTATELOAD);
|
if (CHECK_BUSY(JOB940_PICOSTATELOAD)) wait_busy_940(JOB940_PICOSTATELOAD);
|
||||||
|
|
||||||
writebuff_ptr = 0;
|
writebuff_ptr = 0;
|
||||||
|
|
||||||
// feed all the registers and update internal state
|
|
||||||
for(i = 0; i < 0x100; i++) {
|
|
||||||
YM2612Write_940(0, i, -1);
|
|
||||||
YM2612Write_940(1, REGS[i], -1);
|
|
||||||
}
|
|
||||||
for(i = 0; i < 0x100; i++) {
|
|
||||||
YM2612Write_940(2, i, -1);
|
|
||||||
YM2612Write_940(3, REGS[i|0x100], -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
addr_A1 = *(INT32 *) (REGS + 0x200);
|
addr_A1 = *(INT32 *) (REGS + 0x200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,18 +52,21 @@ static unsigned int inp_prev = 0;
|
||||||
static unsigned long wait_for_input(unsigned int interesting, int is_key_config)
|
static unsigned long wait_for_input(unsigned int interesting, int is_key_config)
|
||||||
{
|
{
|
||||||
unsigned int ret;
|
unsigned int ret;
|
||||||
static int repeats = 0, wait = 50;
|
static int repeats = 0, wait = 6;
|
||||||
int release = 0, count, i;
|
int release = 0, count, i;
|
||||||
|
|
||||||
if (!is_key_config)
|
if (!is_key_config)
|
||||||
interesting |= (interesting & 0xf0) << 24; // also use analog
|
interesting |= (interesting & 0xf0) << 24; // also use analog
|
||||||
|
|
||||||
if (repeats == 2 || repeats == 4) wait /= 2;
|
if (repeats == 2) wait = 3;
|
||||||
if (repeats == 6) wait = 15;
|
else if (repeats == 4) wait = 2;
|
||||||
|
else if (repeats == 6) wait = 1;
|
||||||
|
|
||||||
for (i = 0; i < 6 && inp_prev == psp_pad_read(1); i++) {
|
for (i = 0; i < wait && inp_prev == gp2x_joystick_read(1); i++) {
|
||||||
|
|
||||||
|
for (i = 0; i < wait && inp_prev == psp_pad_read(1); i++) {
|
||||||
if (i == 0) repeats++;
|
if (i == 0) repeats++;
|
||||||
psp_msleep(wait);
|
psp_msleep(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (count = 0; !((ret = psp_pad_read(1)) & interesting) && count < 100; count++) {
|
for (count = 0; !((ret = psp_pad_read(1)) & interesting) && count < 100; count++) {
|
||||||
|
@ -73,7 +76,7 @@ static unsigned long wait_for_input(unsigned int interesting, int is_key_config)
|
||||||
|
|
||||||
if (release || ret != inp_prev) {
|
if (release || ret != inp_prev) {
|
||||||
repeats = 0;
|
repeats = 0;
|
||||||
wait = 50;
|
wait = 6;
|
||||||
}
|
}
|
||||||
inp_prev = ret;
|
inp_prev = ret;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue