ym2612 full saves wip

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@479 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2008-06-01 22:35:08 +00:00
parent e5fa981777
commit d2721b08bb
6 changed files with 199 additions and 55 deletions

View file

@ -145,8 +145,7 @@ static int PicoAreaScan(int PmovAction,unsigned int ver, void *PmovFile)
SCAN_VAR(Pico.m ,"misc") SCAN_VAR(Pico.m ,"misc")
SCAN_VAR(Pico.video,"video") SCAN_VAR(Pico.video,"video")
// notaz: save/load z80, YM2612, sn76496 states instead of Pico.s (which is unused anyway) if (PicoOpt&7) {
if(PicoOpt&7) {
if((PmovAction&3)==1) z80_pack(cpu_z80); if((PmovAction&3)==1) z80_pack(cpu_z80);
ret = SCAN_VAR(cpu_z80,"cpu_z80") ret = SCAN_VAR(cpu_z80,"cpu_z80")
// do not unpack if we fail to load z80 state // do not unpack if we fail to load z80 state
@ -155,9 +154,10 @@ static int PicoAreaScan(int PmovAction,unsigned int ver, void *PmovFile)
else z80_unpack(cpu_z80); else z80_unpack(cpu_z80);
} }
} }
if(PicoOpt&3) if (PicoOpt&3)
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) {
if((PmovAction&3)==1) ym2612_pack_state();
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) ym2612_unpack_state(); // reload YM2612 state from it's regs if((PmovAction&3)==2) ym2612_unpack_state(); // reload YM2612 state from it's regs
} }

View file

@ -796,7 +796,7 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80)
{ {
//elprintf(EL_STATUS, "timer a set %i", TAnew); //elprintf(EL_STATUS, "timer a set %i", TAnew);
ym2612.OPN.ST.TA = TAnew; ym2612.OPN.ST.TA = TAnew;
//ym2612.OPN.ST.TAC = (1024-TAnew)*18; ym2612.OPN.ST.TAC = (1024-TAnew)*18;
//ym2612.OPN.ST.TAT = 0; //ym2612.OPN.ST.TAT = 0;
// //
timer_a_step = timer_a_offset = 16466 * (1024 - TAnew); timer_a_step = timer_a_offset = 16466 * (1024 - TAnew);
@ -812,8 +812,7 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80)
if (ym2612.OPN.ST.TB != d) { if (ym2612.OPN.ST.TB != d) {
//elprintf(EL_STATUS, "timer b set %i", d); //elprintf(EL_STATUS, "timer b set %i", d);
ym2612.OPN.ST.TB = d; ym2612.OPN.ST.TB = d;
//ym2612.OPN.ST.TBC = (256-d)<<4; ym2612.OPN.ST.TBC = (256-d) * 288;
//ym2612.OPN.ST.TBC *= 18;
//ym2612.OPN.ST.TBT = 0; //ym2612.OPN.ST.TBT = 0;
timer_b_step = timer_b_offset = 262800 * (256 - d); // 262881 timer_b_step = timer_b_offset = 262800 * (256 - d); // 262881
if (ym2612.OPN.ST.mode & 2) { if (ym2612.OPN.ST.mode & 2) {
@ -912,21 +911,38 @@ u32 ym2612_read_local_68k(void)
return ym2612.OPN.ST.status; return ym2612.OPN.ST.status;
} }
// TODO: new ym2612 savestates, also save timers void ym2612_pack_state(void)
{
// TODO timers
#ifdef __GP2X__
if (PicoOpt & POPT_EXT_FM)
/*YM2612PicoStateSave2_940(0, 0)*/;
else
#endif
YM2612PicoStateSave2(0, 0);
}
void ym2612_unpack_state(void) void ym2612_unpack_state(void)
{ {
int i; int i, ret, tat, tbt;
YM2612PicoStateLoad(); YM2612PicoStateLoad();
// feed all the registers and update internal state // feed all the registers and update internal state
for (i = 0x20; i < 0xC0; i++) { for (i = 0x20; i < 0xB8; i++) {
ym2612_write_local(0, i, 0); ym2612_write_local(0, i, 0);
ym2612_write_local(1, ym2612.REGS[i], 0); ym2612_write_local(1, ym2612.REGS[i], 0);
} }
for (i = 0x30; i < 0xC0; i++) { for (i = 0x30; i < 0xB8; i++) {
ym2612_write_local(2, i, 0); ym2612_write_local(2, i, 0);
ym2612_write_local(3, ym2612.REGS[i|0x100], 0); ym2612_write_local(3, ym2612.REGS[i|0x100], 0);
} }
#ifdef __GP2X__
if (PicoOpt & POPT_EXT_FM)
/*ret = YM2612PicoStateLoad2_940(&tat, &tbt)*/;
else
#endif
ret = YM2612PicoStateLoad2(&tat, &tbt);
} }
// ----------------------------------------------------------------- // -----------------------------------------------------------------

View file

@ -476,6 +476,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_pack_state(void);
void ym2612_unpack_state(void); void ym2612_unpack_state(void);
#define timers_cycle() \ #define timers_cycle() \

View file

@ -121,8 +121,10 @@ PICO_INTERNAL int PicoCdSaveState(void *file)
} }
if (PicoOpt&3) if (PicoOpt&3)
CHECKED_WRITE(CHUNK_PSG, 28*4, sn76496_regs); CHECKED_WRITE(CHUNK_PSG, 28*4, sn76496_regs);
if (PicoOpt&1) if (PicoOpt&1) {
ym2612_pack_state();
CHECKED_WRITE(CHUNK_FM, 0x200+4, ym2612_regs); CHECKED_WRITE(CHUNK_FM, 0x200+4, ym2612_regs);
}
if (PicoAHW & PAHW_MCD) if (PicoAHW & PAHW_MCD)
{ {

View file

@ -1087,12 +1087,25 @@ void chan_render_loop(chan_rend_context *ct, int *buffer, unsigned short length)
static chan_rend_context crct; static chan_rend_context crct;
static void chan_render_prep(void)
{
crct.eg_timer_add = ym2612.OPN.eg_timer_add;
crct.lfo_inc = ym2612.OPN.lfo_inc;
}
static void chan_render_finish(void)
{
ym2612.OPN.eg_cnt = crct.eg_cnt;
ym2612.OPN.eg_timer = crct.eg_timer;
g_lfo_ampm = crct.pack >> 16; // need_save
ym2612.OPN.lfo_cnt = crct.lfo_cnt;
}
static int chan_render(int *buffer, int length, int c, UINT32 flags) // flags: stereo, ?, disabled, ?, pan_r, pan_l static int chan_render(int *buffer, int length, int c, UINT32 flags) // flags: stereo, ?, disabled, ?, pan_r, pan_l
{ {
crct.CH = &ym2612.CH[c]; crct.CH = &ym2612.CH[c];
crct.mem = crct.CH->mem_value; /* one sample delay memory */ crct.mem = crct.CH->mem_value; /* one sample delay memory */
crct.lfo_cnt = ym2612.OPN.lfo_cnt; crct.lfo_cnt = ym2612.OPN.lfo_cnt;
crct.lfo_inc = ym2612.OPN.lfo_inc;
flags &= 0x35; flags &= 0x35;
@ -1109,7 +1122,6 @@ static int chan_render(int *buffer, int length, int c, UINT32 flags) // flags: s
crct.eg_cnt = ym2612.OPN.eg_cnt; /* envelope generator counter */ crct.eg_cnt = ym2612.OPN.eg_cnt; /* envelope generator counter */
crct.eg_timer = ym2612.OPN.eg_timer; crct.eg_timer = ym2612.OPN.eg_timer;
crct.eg_timer_add = ym2612.OPN.eg_timer_add;
/* precalculate phase modulation incr */ /* precalculate phase modulation incr */
crct.phase1 = crct.CH->SLOT[SLOT1].phase; crct.phase1 = crct.CH->SLOT[SLOT1].phase;
@ -1185,15 +1197,6 @@ static int chan_render(int *buffer, int length, int c, UINT32 flags) // flags: s
else else
ym2612.slot_mask &= ~(0xf << (c*4)); ym2612.slot_mask &= ~(0xf << (c*4));
// if this the last call, write back persistent stuff:
if ((ym2612.slot_mask >> ((c+1)*4)) == 0)
{
ym2612.OPN.eg_cnt = crct.eg_cnt;
ym2612.OPN.eg_timer = crct.eg_timer;
g_lfo_ampm = crct.pack >> 16;
ym2612.OPN.lfo_cnt = crct.lfo_cnt;
}
return (crct.algo & 8) >> 3; // had output return (crct.algo & 8) >> 3; // had output
} }
@ -1212,10 +1215,10 @@ INLINE void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc)
SLOT->ksr = ksr; SLOT->ksr = ksr;
/* calculate envelope generator rates */ /* calculate envelope generator rates */
if ((SLOT->ar + SLOT->ksr) < 32+62) if ((SLOT->ar + ksr) < 32+62)
{ {
eg_sh = eg_rate_shift [SLOT->ar + SLOT->ksr ]; eg_sh = eg_rate_shift [SLOT->ar + ksr ];
eg_sel = eg_rate_select[SLOT->ar + SLOT->ksr ]; eg_sel = eg_rate_select[SLOT->ar + ksr ];
} }
else else
{ {
@ -1225,18 +1228,18 @@ INLINE void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc)
SLOT->eg_pack_ar = eg_inc_pack[eg_sel] | (eg_sh<<24); SLOT->eg_pack_ar = eg_inc_pack[eg_sel] | (eg_sh<<24);
eg_sh = eg_rate_shift [SLOT->d1r + SLOT->ksr]; eg_sh = eg_rate_shift [SLOT->d1r + ksr];
eg_sel = eg_rate_select[SLOT->d1r + SLOT->ksr]; eg_sel = eg_rate_select[SLOT->d1r + ksr];
SLOT->eg_pack_d1r = eg_inc_pack[eg_sel] | (eg_sh<<24); SLOT->eg_pack_d1r = eg_inc_pack[eg_sel] | (eg_sh<<24);
eg_sh = eg_rate_shift [SLOT->d2r + SLOT->ksr]; eg_sh = eg_rate_shift [SLOT->d2r + ksr];
eg_sel = eg_rate_select[SLOT->d2r + SLOT->ksr]; eg_sel = eg_rate_select[SLOT->d2r + ksr];
SLOT->eg_pack_d2r = eg_inc_pack[eg_sel] | (eg_sh<<24); SLOT->eg_pack_d2r = eg_inc_pack[eg_sel] | (eg_sh<<24);
eg_sh = eg_rate_shift [SLOT->rr + SLOT->ksr]; eg_sh = eg_rate_shift [SLOT->rr + ksr];
eg_sel = eg_rate_select[SLOT->rr + SLOT->ksr]; eg_sel = eg_rate_select[SLOT->rr + ksr];
SLOT->eg_pack_rr = eg_inc_pack[eg_sel] | (eg_sh<<24); SLOT->eg_pack_rr = eg_inc_pack[eg_sel] | (eg_sh<<24);
} }
@ -1634,12 +1637,14 @@ int YM2612UpdateOne_(int *buffer, int length, int stereo, int is_buf_empty)
/* mix to 32bit dest */ /* mix to 32bit dest */
// flags: stereo, ?, disabled, ?, pan_r, pan_l // flags: stereo, ?, disabled, ?, pan_r, pan_l
chan_render_prep();
if (ym2612.slot_mask & 0x00000f) active_chs |= chan_render(buffer, length, 0, stereo|((pan&0x003)<<4)) << 0; if (ym2612.slot_mask & 0x00000f) active_chs |= chan_render(buffer, length, 0, stereo|((pan&0x003)<<4)) << 0;
if (ym2612.slot_mask & 0x0000f0) active_chs |= chan_render(buffer, length, 1, stereo|((pan&0x00c)<<2)) << 1; if (ym2612.slot_mask & 0x0000f0) active_chs |= chan_render(buffer, length, 1, stereo|((pan&0x00c)<<2)) << 1;
if (ym2612.slot_mask & 0x000f00) active_chs |= chan_render(buffer, length, 2, stereo|((pan&0x030) )) << 2; if (ym2612.slot_mask & 0x000f00) active_chs |= chan_render(buffer, length, 2, stereo|((pan&0x030) )) << 2;
if (ym2612.slot_mask & 0x00f000) active_chs |= chan_render(buffer, length, 3, stereo|((pan&0x0c0)>>2)) << 3; if (ym2612.slot_mask & 0x00f000) active_chs |= chan_render(buffer, length, 3, stereo|((pan&0x0c0)>>2)) << 3;
if (ym2612.slot_mask & 0x0f0000) active_chs |= chan_render(buffer, length, 4, stereo|((pan&0x300)>>4)) << 4; if (ym2612.slot_mask & 0x0f0000) active_chs |= chan_render(buffer, length, 4, stereo|((pan&0x300)>>4)) << 4;
if (ym2612.slot_mask & 0xf00000) active_chs |= chan_render(buffer, length, 5, stereo|((pan&0xc00)>>6)|(ym2612.dacen<<2)) << 5; if (ym2612.slot_mask & 0xf00000) active_chs |= chan_render(buffer, length, 5, stereo|((pan&0xc00)>>6)|(ym2612.dacen<<2)) << 5;
chan_render_finish();
return active_chs; // 1 if buffer updated return active_chs; // 1 if buffer updated
} }
@ -1864,6 +1869,124 @@ int YM2612PicoTick_(int n)
void YM2612PicoStateLoad_(void) void YM2612PicoStateLoad_(void)
{ {
reset_channels( &ym2612.CH[0] ); reset_channels( &ym2612.CH[0] );
ym2612.slot_mask = 0xffffff;
}
typedef struct
{
UINT32 state_phase;
INT16 volume;
} ym_save_addon_slot;
typedef struct
{
UINT32 magic;
UINT8 address;
UINT8 status;
UINT8 addr_A1;
UINT8 unused;
int TAT;
int TBT;
UINT32 eg_cnt;
UINT32 eg_timer;
UINT32 lfo_cnt;
UINT16 lfo_ampm;
UINT16 unused2;
} ym_save_addon;
void YM2612PicoStateSave2(int tat, int tbt)
{
ym_save_addon_slot ss;
ym_save_addon sa;
unsigned char *ptr;
int c, s;
// chans 1,2,3
ptr = &ym2612.REGS[0x0b8];
for (c = 0; c < 3; c++)
{
for (s = 0; s < 4; s++) {
ss.state_phase = (ym2612.CH[c].SLOT[s].state << 29) | (ym2612.CH[c].SLOT[s].phase >> 3);
ss.volume = ym2612.CH[c].SLOT[s].volume;
memcpy(ptr, &ss, 6);
ptr += 6;
}
}
// chans 4,5,6
ptr = &ym2612.REGS[0x1b8];
for (; c < 6; c++)
{
for (s = 0; s < 4; s++) {
ss.state_phase = (ym2612.CH[c].SLOT[s].state << 29) | (ym2612.CH[c].SLOT[s].phase >> 3);
ss.volume = ym2612.CH[c].SLOT[s].volume;
memcpy(ptr, &ss, 6);
ptr += 6;
}
}
// other things
ptr = &ym2612.REGS[0x100];
sa.magic = 0x41534d59; // 'YMSA'
sa.address = ym2612.OPN.ST.address;
sa.status = ym2612.OPN.ST.status;
sa.addr_A1 = ym2612.addr_A1;
sa.unused = 0;
sa.TAT = tat;
sa.TBT = tbt;
sa.eg_cnt = ym2612.OPN.eg_cnt;
sa.eg_timer = ym2612.OPN.eg_timer;
sa.lfo_cnt = ym2612.OPN.lfo_cnt;
sa.lfo_ampm = g_lfo_ampm;
sa.unused2 = 0;
memcpy(ptr, &sa, sizeof(sa)); // 0x30 max
}
int YM2612PicoStateLoad2(int *tat, int *tbt)
{
ym_save_addon_slot ss;
ym_save_addon sa;
unsigned char *ptr;
int c, s;
ptr = &ym2612.REGS[0x100];
memcpy(&sa, ptr, sizeof(sa)); // 0x30 max
if (sa.magic != 0x41534d59) return -1;
ym2612.OPN.ST.address = sa.address;
ym2612.OPN.ST.status = sa.status;
ym2612.addr_A1 = sa.addr_A1;
ym2612.OPN.eg_cnt = sa.eg_cnt;
ym2612.OPN.eg_timer = sa.eg_timer;
ym2612.OPN.lfo_cnt = sa.lfo_cnt;
g_lfo_ampm = sa.lfo_ampm;
if (tat != NULL) *tat = sa.TAT;
if (tbt != NULL) *tbt = sa.TBT;
// chans 1,2,3
ptr = &ym2612.REGS[0x0b8];
for (c = 0; c < 3; c++)
{
for (s = 0; s < 4; s++) {
memcpy(&ss, ptr, 6);
ym2612.CH[c].SLOT[s].state = ss.state_phase >> 29;
ym2612.CH[c].SLOT[s].phase = ss.state_phase << 3;
ym2612.CH[c].SLOT[s].volume = ss.volume;
ptr += 6;
}
}
// chans 4,5,6
ptr = &ym2612.REGS[0x1b8];
for (; c < 6; c++)
{
for (s = 0; s < 4; s++) {
memcpy(&ss, ptr, 6);
ym2612.CH[c].SLOT[s].state = ss.state_phase >> 29;
ym2612.CH[c].SLOT[s].phase = ss.state_phase << 3;
ym2612.CH[c].SLOT[s].volume = ss.volume;
ptr += 6;
}
}
return 0;
} }
#ifndef EXTERNAL_YM2612 #ifndef EXTERNAL_YM2612

View file

@ -22,15 +22,15 @@ typedef signed int INT32; /* signed 32bit */
typedef struct typedef struct
{ {
INT32 *DT; /* #0x00 detune :dt_tab[DT] */ INT32 *DT; /* #0x00 detune :dt_tab[DT] */
UINT8 ar; /* #0x04 attack rate */ UINT8 ar; /* #0x04 attack rate */
UINT8 d1r; /* #0x05 decay rate */ UINT8 d1r; /* #0x05 decay rate */
UINT8 d2r; /* #0x06 sustain rate */ UINT8 d2r; /* #0x06 sustain rate */
UINT8 rr; /* #0x07 release rate */ UINT8 rr; /* #0x07 release rate */
UINT32 mul; /* #0x08 multiple :ML_TABLE[ML] */ UINT32 mul; /* #0x08 multiple :ML_TABLE[ML] */
/* Phase Generator */ /* Phase Generator */
UINT32 phase; /* #0x0c phase counter */ UINT32 phase; /* #0x0c phase counter | need_save */
UINT32 Incr; /* #0x10 phase step */ UINT32 Incr; /* #0x10 phase step | need_save */
UINT8 KSR; /* #0x14 key scale rate :3-KSR */ UINT8 KSR; /* #0x14 key scale rate :3-KSR */
UINT8 ksr; /* #0x15 key scale rate :kcode>>(3-KSR) */ UINT8 ksr; /* #0x15 key scale rate :kcode>>(3-KSR) */
@ -38,15 +38,15 @@ typedef struct
UINT8 key; /* #0x16 0=last key was KEY OFF, 1=KEY ON */ UINT8 key; /* #0x16 0=last key was KEY OFF, 1=KEY ON */
/* Envelope Generator */ /* Envelope Generator */
UINT8 state; /* #0x17 phase type: EG_OFF=0, EG_REL, EG_SUS, EG_DEC, EG_ATT */ UINT8 state; /* #0x17 phase type: EG_OFF=0, EG_REL, EG_SUS, EG_DEC, EG_ATT | need_save */
UINT16 tl; /* #0x18 total level: TL << 3 */ UINT16 tl; /* #0x18 total level: TL << 3 */
INT16 volume; /* #0x1a envelope counter */ INT16 volume; /* #0x1a envelope counter | need_save */
UINT32 sl; /* #0x1c sustain level:sl_table[SL] */ UINT32 sl; /* #0x1c sustain level:sl_table[SL] */
UINT32 eg_pack_ar; /* #0x20 (attack state) */ UINT32 eg_pack_ar; /* #0x20 (attack state) */
UINT32 eg_pack_d1r; /* #0x24 (decay state) */ UINT32 eg_pack_d1r; /* #0x24 (decay state) */
UINT32 eg_pack_d2r; /* #0x28 (sustain state) */ UINT32 eg_pack_d2r; /* #0x28 (sustain state) */
UINT32 eg_pack_rr; /* #0x2c (release state) */ UINT32 eg_pack_rr; /* #0x2c (release state) */
} FM_SLOT; } FM_SLOT;
@ -55,7 +55,7 @@ typedef struct
FM_SLOT SLOT[4]; /* four SLOTs (operators) */ FM_SLOT SLOT[4]; /* four SLOTs (operators) */
UINT8 ALGO; /* algorithm */ UINT8 ALGO; /* algorithm */
UINT8 FB; /* feedback shift */ UINT8 FB; /* feedback shift */
INT32 op1_out; /* op1 output for feedback */ INT32 op1_out; /* op1 output for feedback */
INT32 mem_value; /* delayed sample (MEM) value */ INT32 mem_value; /* delayed sample (MEM) value */
@ -64,7 +64,7 @@ typedef struct
UINT8 ams; /* channel AMS */ UINT8 ams; /* channel AMS */
UINT8 kcode; /* key code: */ UINT8 kcode; /* key code: */
UINT32 fc; /* fnum,blk:adjusted to sample rate */ UINT32 fc; /* fnum,blk:adjusted to sample rate */
UINT32 block_fnum; /* current blk/fnum value for this slot (can be different betweeen slots of one channel in 3slot mode) */ UINT32 block_fnum; /* current blk/fnum value for this slot (can be different betweeen slots of one channel in 3slot mode) */
/* LFO */ /* LFO */
@ -77,17 +77,17 @@ typedef struct
int clock; /* master clock (Hz) */ int clock; /* master clock (Hz) */
int rate; /* sampling rate (Hz) */ int rate; /* sampling rate (Hz) */
double freqbase; /* 08 frequency base */ double freqbase; /* 08 frequency base */
UINT8 address; /* 10 address register */ UINT8 address; /* 10 address register | need_save */
UINT8 status; /* 11 status flag */ UINT8 status; /* 11 status flag | need_save */
UINT8 mode; /* mode CSM / 3SLOT */ UINT8 mode; /* mode CSM / 3SLOT */
UINT8 fn_h; /* freq latch */ UINT8 fn_h; /* freq latch */
int TA; /* timer a */ int TA; /* timer a */
int TAC; /* timer a maxval */ int TAC; /* timer a maxval */
int TAT; /* timer a ticker */ int TAT; /* timer a ticker | need_save */
UINT8 TB; /* timer b */ UINT8 TB; /* timer b */
UINT8 pad[3]; UINT8 pad[3];
int TBC; /* timer b maxval */ int TBC; /* timer b maxval */
int TBT; /* timer b ticker */ int TBT; /* timer b ticker | need_save */
/* local time tables */ /* local time tables */
INT32 dt_tab[8][32];/* DeTune table */ INT32 dt_tab[8][32];/* DeTune table */
} FM_ST; } FM_ST;
@ -112,12 +112,12 @@ typedef struct
FM_3SLOT SL3; /* 3 slot mode state */ FM_3SLOT SL3; /* 3 slot mode state */
UINT32 pan; /* fm channels output mask (bit 1 = enable) */ UINT32 pan; /* fm channels output mask (bit 1 = enable) */
UINT32 eg_cnt; /* #0xb38 global envelope generator counter */ UINT32 eg_cnt; /* #0xb38 global envelope generator counter | need_save */
UINT32 eg_timer; /* #0xb3c global envelope generator counter works at frequency = chipclock/64/3 */ UINT32 eg_timer; /* #0xb3c global envelope generator counter works at frequency = chipclock/64/3 | need_save */
UINT32 eg_timer_add; /* #0xb40 step of eg_timer */ UINT32 eg_timer_add; /* #0xb40 step of eg_timer */
/* LFO */ /* LFO */
UINT32 lfo_cnt; UINT32 lfo_cnt; /* need_save */
UINT32 lfo_inc; UINT32 lfo_inc;
UINT32 lfo_freq[8]; /* LFO FREQ table */ UINT32 lfo_freq[8]; /* LFO FREQ table */
@ -126,13 +126,13 @@ typedef struct
/* here's the virtual YM2612 */ /* here's the virtual YM2612 */
typedef struct typedef struct
{ {
UINT8 REGS[0x200]; /* registers (for save states) */ UINT8 REGS[0x200]; /* registers (for save states) */
INT32 addr_A1; /* address line A1 */ INT32 addr_A1; /* address line A1 | need_save */
FM_CH CH[6]; /* channel state (0x168 bytes each)? */ FM_CH CH[6]; /* channel state (0x168 bytes each)? */
/* dac output (YM2612) */ /* dac output (YM2612) */
int dacen; int dacen;
INT32 dacout; INT32 dacout;
FM_OPN OPN; /* OPN state */ FM_OPN OPN; /* OPN state */
@ -156,6 +156,8 @@ int YM2612PicoTick_(int n);
void YM2612PicoStateLoad_(void); void YM2612PicoStateLoad_(void);
void *YM2612GetRegs(void); void *YM2612GetRegs(void);
void YM2612PicoStateSave2(int tat, int tbt);
int YM2612PicoStateLoad2(int *tat, int *tbt);
#ifndef __GP2X__ #ifndef __GP2X__
#define YM2612Init YM2612Init_ #define YM2612Init YM2612Init_