/***************************************************************************

  ym2610.h

  Header file for software emulation for YAMAHA YM-2610 sound generator

***************************************************************************/

#ifndef _YM2610_H_
#define _YM2610_H_

/* for busy flag emulation , function FM_GET_TIME_NOW() should be */
/* return the present time in second unit with (double) value     */
/* in timer.c */
#define FM_GET_TIME_NOW() timer_get_time()

typedef s16 FMSAMPLE;
typedef s32 FMSAMPLE_MIX;

typedef void (*FM_TIMERHANDLER)(int channel, int count, double stepTime);
typedef void (*FM_IRQHANDLER)(int irq);

int YM2610Init(int baseclock, int rate, void *pcmroma, int pcmsizea,
				FM_TIMERHANDLER TimerHandler,
				FM_IRQHANDLER IRQHandler);

void YM2610Reset(void);
void YM2610Update(s16 *buffer, int length);
void SSGUpdate(s16 *buffer, int length);
int  YM2610Write(int addr, u8 value);
u8   YM2610Read(int addr);
int  YM2610TimerOver(int channel);
void YM2610_ssg_reset(void);

#ifdef SAVE_STATE
void state_save_ym2610(u8 *state_buf);
void state_load_ym2610(u8 *state_buf);
#endif

#endif /* _YM2610_H_ */
