+int YM2612PicoStateLoad2(int *tat, int *tbt)\r
+{\r
+ ym_save_addon_slot ss;\r
+ ym_save_addon2 sa2;\r
+ ym_save_addon sa;\r
+ unsigned char *ptr;\r
+ UINT32 fn;\r
+ UINT8 blk;\r
+ int c, s;\r
+\r
+ ptr = &ym2612.REGS[0x100];\r
+ memcpy(&sa, ptr, sizeof(sa)); // 0x30 max\r
+ if (sa.magic != 0x41534d59) return -1;\r
+\r
+ ptr = &ym2612.REGS[0];\r
+ memcpy(&sa2, ptr, sizeof(sa2));\r
+\r
+ ym2612.OPN.ST.address = sa.address;\r
+ ym2612.OPN.ST.status = sa.status;\r
+ ym2612.addr_A1 = sa.addr_A1;\r
+ ym2612.OPN.eg_cnt = sa.eg_cnt;\r
+ ym2612.OPN.eg_timer = sa.eg_timer;\r
+ ym2612.OPN.lfo_cnt = sa.lfo_cnt;\r
+ g_lfo_ampm = sa.lfo_ampm;\r
+ if (tat != NULL) *tat = sa.TAT;\r
+ if (tbt != NULL) *tbt = sa.TBT;\r
+\r
+ // chans 1,2,3\r
+ ptr = &ym2612.REGS[0x0b8];\r
+ for (c = 0; c < 3; c++)\r
+ {\r
+ for (s = 0; s < 4; s++) {\r
+ memcpy(&ss, ptr, 6);\r
+ ym2612.CH[c].SLOT[s].state = ss.state_phase >> 29;\r
+ ym2612.CH[c].SLOT[s].phase = ss.state_phase << 3;\r
+ ym2612.CH[c].SLOT[s].volume = ss.volume;\r
+ ym2612.CH[c].SLOT[s].key = (sa.keyon_field & (1 << (c*4 + s))) ? 1 : 0;\r
+ ym2612.CH[c].SLOT[s].ksr = (UINT8)-1;\r
+//ym2612.CH[c].SLOT[s].Incr = check_ym.CH[c].SLOT[s].Incr;\r
+ ptr += 6;\r
+ }\r
+ ym2612.CH[c].SLOT[SLOT1].Incr=-1;\r
+ ym2612.CH[c].block_fnum = sa2.block_fnum[c];\r
+ fn = ym2612.CH[c].block_fnum & 0x7ff;\r
+ blk = ym2612.CH[c].block_fnum >> 11;\r
+ ym2612.CH[c].kcode= (blk<<2) | opn_fktable[fn >> 7];\r
+ ym2612.CH[c].fc = fn_table[fn*2]>>(7-blk);\r
+ }\r
+ // chans 4,5,6\r
+ ptr = &ym2612.REGS[0x1b8];\r
+ for (; c < 6; c++)\r
+ {\r
+ for (s = 0; s < 4; s++) {\r
+ memcpy(&ss, ptr, 6);\r
+ ym2612.CH[c].SLOT[s].state = ss.state_phase >> 29;\r
+ ym2612.CH[c].SLOT[s].phase = ss.state_phase << 3;\r
+ ym2612.CH[c].SLOT[s].volume = ss.volume;\r
+ ym2612.CH[c].SLOT[s].key = (sa.keyon_field & (1 << (c*4 + s))) ? 1 : 0;\r
+ ym2612.CH[c].SLOT[s].ksr = (UINT8)-1;\r
+//ym2612.CH[c].SLOT[s].Incr = check_ym.CH[c].SLOT[s].Incr;\r
+ ptr += 6;\r
+ }\r
+ ym2612.CH[c].SLOT[SLOT1].Incr=-1;\r
+ ym2612.CH[c].block_fnum = sa2.block_fnum[c];\r
+ fn = ym2612.CH[c].block_fnum & 0x7ff;\r
+ blk = ym2612.CH[c].block_fnum >> 11;\r
+ ym2612.CH[c].kcode= (blk<<2) | opn_fktable[fn >> 7];\r
+ ym2612.CH[c].fc = fn_table[fn*2]>>(7-blk);\r
+ }\r
+ for (c = 0; c < 3; c++)\r
+ {\r
+ ym2612.OPN.SL3.block_fnum[c] = sa2.block_fnum_sl3[c];\r
+ fn = ym2612.OPN.SL3.block_fnum[c] & 0x7ff;\r
+ blk = ym2612.OPN.SL3.block_fnum[c] >> 11;\r
+ ym2612.OPN.SL3.kcode[c]= (blk<<2) | opn_fktable[fn >> 7];\r
+ ym2612.OPN.SL3.fc[c] = fn_table[fn*2]>>(7-blk);\r