\r
// ym2413\r
#define YM2413_CLK 3579545\r
-OPLL old_opll;\r
static OPLL *opll = NULL;\r
-unsigned YM2413_reg;\r
+static OPLL old_opll;\r
+static struct {\r
+ uint32_t adr;\r
+ uint8_t reg[sizeof(opll->reg)];\r
+} opll_buf;\r
+\r
+PICO_INTERNAL void *YM2413GetRegs(void)\r
+{\r
+ memcpy(opll_buf.reg, opll->reg, sizeof(opll->reg));\r
+ opll_buf.adr = opll->adr;\r
+ return &opll_buf;\r
+}\r
+\r
+PICO_INTERNAL void YM2413UnpackState(void)\r
+{\r
+ int i;\r
+\r
+ for (i = sizeof(opll->reg)-1; i >= 0; i--) {\r
+ OPLL_writeIO(opll, 0, i);\r
+ OPLL_writeIO(opll, 1, opll_buf.reg[i]);\r
+ }\r
+ opll->adr = opll_buf.adr;\r
+}\r
\r
static resampler_t *fmresampler;\r
+static int (*PsndFMUpdate)(s32 *buffer, int length, int stereo, int is_buf_empty);\r
\r
PICO_INTERNAL void PsndInit(void)\r
{\r
timers_reset();\r
}\r
\r
-int (*PsndFMUpdate)(s32 *buffer, int length, int stereo, int is_buf_empty);\r
-\r
// FM polyphase FIR resampling\r
#define FMFIR_TAPS 9\r
\r
if (preserve_state) memcpy(&old_opll, opll, sizeof(OPLL)); // remember old state\r
OPLL_setRate(opll, PicoIn.sndRate);\r
OPLL_reset(opll);\r
+ if (preserve_state) memcpy(&opll->adr, &old_opll.adr, sizeof(OPLL)-20); // restore old state\r
+ OPLL_forceRefresh(opll);\r
}\r
\r
if (state)\r
\r
// sn76496 & ym2413\r
extern int *sn76496_regs;\r
-extern OPLL old_opll;\r
\r
static arearw *areaRead;\r
static arearw *areaWrite;\r
CHUNK_DRAM,\r
CHUNK_32XPAL,\r
CHUNK_32X_EVT,\r
- CHUNK_YM2413, //40\r
//rename\r
CHUNK_32X_FIRST = CHUNK_MSH2,\r
CHUNK_32X_LAST = CHUNK_32X_EVT,\r
CHUNK_CD_GFX,\r
CHUNK_CD_CDC,\r
CHUNK_CD_CDD,\r
+ CHUNK_YM2413,\r
//\r
CHUNK_DEFAULT_COUNT,\r
CHUNK_CARTHW_ = CHUNK_CARTHW, // 64 (defined in PicoInt)\r
{\r
char sbuff[32] = "Saving.. ";\r
unsigned char buff[0x60], buff_z80[Z80_STATE_SIZE];\r
- void *ym2612_regs = YM2612GetRegs();\r
+ void *ym_regs = YM2612GetRegs();\r
void *buf2 = NULL;\r
int ver = 0x0191; // not really used..\r
int retval = -1;\r
CHECKED_WRITE_BUFF(CHUNK_VSRAM, PicoMem.vsram);\r
CHECKED_WRITE_BUFF(CHUNK_IOPORTS, PicoMem.ioports);\r
ym2612_pack_state();\r
- CHECKED_WRITE(CHUNK_FM, 0x200+4, ym2612_regs);\r
+ ym_regs = YM2612GetRegs();\r
+ CHECKED_WRITE(CHUNK_FM, 0x200+4, ym_regs);\r
\r
if (!(PicoIn.opt & POPT_DIS_IDLE_DET))\r
SekInitIdleDet();\r
}\r
else {\r
CHECKED_WRITE_BUFF(CHUNK_SMS, Pico.ms);\r
- CHECKED_WRITE_BUFF(CHUNK_YM2413, old_opll);\r
+ ym_regs = YM2413GetRegs();\r
+ CHECKED_WRITE(CHUNK_YM2413, 0x40+4, ym_regs);\r
}\r
\r
CHECKED_WRITE_BUFF(CHUNK_VRAM, PicoMem.vram);\r
unsigned char buff_sh2[SH2_STATE_SIZE];\r
unsigned char *buf = NULL;\r
unsigned char chunk;\r
- void *ym2612_regs;\r
+ void *ym_regs;\r
int len_check;\r
int retval = -1;\r
char header[8];\r
\r
case CHUNK_IOPORTS: CHECKED_READ_BUFF(PicoMem.ioports); break;\r
case CHUNK_PSG: CHECKED_READ2(28*4, sn76496_regs); break;\r
- case CHUNK_YM2413: CHECKED_READ_BUFF(old_opll); break;\r
+ case CHUNK_YM2413:\r
+ ym_regs = YM2413GetRegs();\r
+ CHECKED_READ2(0x40+4, ym_regs);\r
+ YM2413UnpackState();\r
+ break;\r
case CHUNK_FM:\r
- ym2612_regs = YM2612GetRegs();\r
- CHECKED_READ2(0x200+4, ym2612_regs);\r
+ ym_regs = YM2612GetRegs();\r
+ CHECKED_READ2(0x200+4, ym_regs);\r
ym2612_unpack_state();\r
break;\r
\r