From: notaz Date: Tue, 27 May 2008 21:38:46 +0000 (+0000) Subject: bugfixes, state load for new mode X-Git-Tag: v1.85~482 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=453d2a6edadbd6a0977b76eba14961006c907f01;p=picodrive.git bugfixes, state load for new mode git-svn-id: file:///home/notaz/opt/svn/PicoDrive@468 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/Pico/Area.c b/Pico/Area.c index d8833a43..4f4fa568 100644 --- a/Pico/Area.c +++ b/Pico/Area.c @@ -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 if(PicoOpt&1) { 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 } } diff --git a/Pico/Cart.c b/Pico/Cart.c index dacd793a..4dac3df9 100644 --- a/Pico/Cart.c +++ b/Pico/Cart.c @@ -712,7 +712,7 @@ static void PicoCartDetect(void) } // 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; } diff --git a/Pico/Memory.c b/Pico/Memory.c index fb6b99c4..a9f09274 100644 --- a/Pico/Memory.c +++ b/Pico/Memory.c @@ -883,14 +883,13 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80) return YM2612Write_(a, d); } -// TODO: savestates + #define ym2612_read_local() \ if (xcycles >= timer_a_next_oflow) \ ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 1; \ if (xcycles >= timer_b_next_oflow) \ ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 2 - u32 ym2612_read_local_z80(void) { int xcycles = z80_cyclesDone() << 8; @@ -913,6 +912,23 @@ u32 ym2612_read_local_68k(void) 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 diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index bf5c46d9..cd5ba5b6 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -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; void ym2612_sync_timers(int z80_cycles, int mode_old, int mode_new); +void ym2612_unpack_state(void); #define timers_cycle() \ if (timer_a_next_oflow > 0 && timer_a_next_oflow < 0x70000000) \ diff --git a/Pico/cd/Area.c b/Pico/cd/Area.c index 8561257f..1a4d271a 100644 --- a/Pico/cd/Area.c +++ b/Pico/cd/Area.c @@ -230,7 +230,7 @@ PICO_INTERNAL int PicoCdLoadState(void *file) case CHUNK_PSG: CHECKED_READ2(28*4, sn76496_regs); break; case CHUNK_FM: CHECKED_READ2(0x200+4, ym2612_regs); - YM2612PicoStateLoad(); + ym2612_unpack_state(); break; // cd stuff diff --git a/Pico/sound/sound.c b/Pico/sound/sound.c index d49ea68a..ab6b7e1c 100644 --- a/Pico/sound/sound.c +++ b/Pico/sound/sound.c @@ -140,7 +140,7 @@ void PsndRerate(int preserve_state) if (preserve_state) { // feed it back it's own registers, just like after loading state memcpy(YM2612GetRegs(), state, 0x200); - YM2612PicoStateLoad(); + ym2612_unpack_state(); if ((PicoAHW & PAHW_MCD) && !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1)) cdda_start_play(); } diff --git a/Pico/sound/ym2612.c b/Pico/sound/ym2612.c index 34dabecd..4b74826c 100644 --- a/Pico/sound/ym2612.c +++ b/Pico/sound/ym2612.c @@ -1863,26 +1863,7 @@ int YM2612PicoTick_(int n) void YM2612PicoStateLoad_(void) { -#ifndef EXTERNAL_YM2612 - int i, real_A1 = ym2612.addr_A1; - - 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 diff --git a/platform/gp2x/940ctl.c b/platform/gp2x/940ctl.c index 8c8b18b1..4a571ffd 100644 --- a/platform/gp2x/940ctl.c +++ b/platform/gp2x/940ctl.c @@ -178,24 +178,11 @@ void YM2612PicoStateLoad_940(void) { UINT8 *REGS = YM2612GetRegs(); - int i; - /* make sure JOB940_PICOSTATELOAD gets done before next JOB940_YM2612UPDATEONE */ add_job_940(JOB940_PICOSTATELOAD); if (CHECK_BUSY(JOB940_PICOSTATELOAD)) wait_busy_940(JOB940_PICOSTATELOAD); 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); } diff --git a/platform/psp/menu.c b/platform/psp/menu.c index 48de81ed..4cb0b4ba 100644 --- a/platform/psp/menu.c +++ b/platform/psp/menu.c @@ -52,18 +52,21 @@ static unsigned int inp_prev = 0; static unsigned long wait_for_input(unsigned int interesting, int is_key_config) { unsigned int ret; - static int repeats = 0, wait = 50; + static int repeats = 0, wait = 6; int release = 0, count, i; if (!is_key_config) interesting |= (interesting & 0xf0) << 24; // also use analog - if (repeats == 2 || repeats == 4) wait /= 2; - if (repeats == 6) wait = 15; + if (repeats == 2) wait = 3; + 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++; - psp_msleep(wait); + psp_msleep(30); } 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) { repeats = 0; - wait = 50; + wait = 6; } inp_prev = ret;