1 #ifndef __YMDELTAT_H_
2 #define __YMDELTAT_H_
3 
4 #define YM_DELTAT_SHIFT    (16)
5 
6 
7 typedef void (*STATUS_CHANGE_HANDLER)(UINT8 which_chip, UINT8 status_bits);
8 
9 
10 /* DELTA-T (adpcm type B) struct */
11 typedef struct deltat_adpcm_state {     /* AT: rearranged and tigntened structure */
12 	UINT8	*memory;
13 	INT32	*output_pointer;/* pointer of output pointers	*/
14 	INT32	*pan;			/* pan : &output_pointer[pan]	*/
15 	double	freqbase;
16 	UINT32	memory_size;
17 	int	output_range;
18 	UINT32	now_addr;		/* current address		*/
19 	UINT32	now_step;		/* currect step			*/
20 	UINT32	step;			/* step					*/
21 	UINT32	start;			/* start address		*/
22 	UINT32	limit;			/* limit address		*/
23 	UINT32	end;			/* end address			*/
24 	UINT32	delta;			/* delta scale			*/
25 	INT32	volume;			/* current volume		*/
26 	INT32	acc;			/* shift Measurement value*/
27 	INT32	adpcmd;			/* next Forecast		*/
28 	INT32	adpcml;			/* current value		*/
29 	INT32	prev_acc;		/* leveling value		*/
30 	UINT8	now_data;		/* current rom data		*/
31 	UINT8	portstate;		/* port status			*/
32 	UINT8	control2;		/* control reg: SAMPLE, DA/AD, RAM TYPE (x8bit / x1bit), ROM/RAM */
33 	UINT8	portshift;		/* address bits shift-left:
34 							** 8 for YM2610,
35 							** 5 for ROM for Y8950 and YM2608,
36 							** 5 for x8bit DRAMs for Y8950 and YM2608,
37 							** 2 for x1bit DRAMs for Y8950 and YM2608 */
38 	UINT8	DRAMportshift;	/* address bits shift-right:
39 							** 0 for ROM and x8bit DRAMs,
40 							** 3 for x1 DRAMs */
41 
42 	UINT8	memread;		/* for dummy reading needed while reading external memory */
43 
44 	/* handlers and parameters for the status flags support */
45 	STATUS_CHANGE_HANDLER	status_set_handler;
46 	STATUS_CHANGE_HANDLER	status_reset_handler;
47 
48 	/*
49 	** note that different chips have these flags on different
50 	** bits of the status register
51 	*/
52 	UINT8	status_change_which_chip;	/* this chip id */
53 	UINT8	status_change_EOS_bit;		/* 1 on End Of Sample (record/playback/cycle time of AD/DA converting has passed)*/
54 	UINT8	status_change_BRDY_bit;		/* 1 after recording 2 datas (2x4bits) or after reading/writing 1 data */
55 	UINT8	status_change_ZERO_bit;		/* 1 if silence lasts for more than 290 miliseconds on ADPCM recording */
56 
57 /* neither Y8950 nor YM2608 can generate IRQ when PCMBSY bit changes, so instead of above method
58    the statusflag gets ORed with PCM_BSY (below) (on each read of statusflag of Y8950 and YM2608)
59 */
60 	UINT8	PCM_BSY;		/* 1 when ADPCM is playing; Y8950/YM2608 only */
61 
62 	UINT8	reg[16];		/* adpcm registers		*/
63 }YM_DELTAT;
64 
65 
66 UINT8 YM_DELTAT_ADPCM_Read(YM_DELTAT *DELTAT);
67 void YM_DELTAT_ADPCM_Write(YM_DELTAT *DELTAT,int r,int v);
68 void YM_DELTAT_ADPCM_Reset(YM_DELTAT *DELTAT,int pan);
69 
70 void YM_DELTAT_postload(YM_DELTAT *DELTAT,UINT8 *regs);
71 void YM_DELTAT_savestate(const char *statename,int num,YM_DELTAT *DELTAT);
72 
73 
74 #define YM_INLINE_BLOCK
75 #include "ymdeltat.c" /* include inline function section */
76 #undef  YM_INLINE_BLOCK
77 
78 #endif
79