#ifndef NAGI_SOUND_SOUND_H
#define NAGI_SOUND_SOUND_H

struct sound_struct
{
	struct sound_struct *next;	// 0-1
	u16 num;		// 2-3
	u8 *data;		// 4-5
	u8 *channel[4];	// 6-7, 8-9, A-B, C-D
};
typedef struct sound_struct SOUND;

struct channel_struct
{
	u8 *data;
	u16 duration;
	u16 toggle;	// turned on (1)  but when the channel's data runs out, it's set to (0)
	u16 word1796;
	u8 attenuation;
	u8 attenuation_copy;
	u8 *dissolve;
	
	// for the sample mixer
	u16 freq_count;
	u16 freq_prev;
	u8 volume;	
	u16 sample_num;
	u8 *sample_cur;
	s32 count;
	s32 scale;
};
typedef struct channel_struct CHANNEL;

// must be mono 16bit 44100 for now
struct sample_struct
{
	u8 *data;
	int size;
	
	u16 freq_base;
	int *scale_table;
};
typedef struct sample_struct SAMPLE;

// --------- BASE



extern u16 sound_playing;
extern u16 sound_flag;

extern void sound_list_init(void);
extern void sound_list_new_room(void);
extern u8 *cmd_load_sound(u8 *c);
extern SOUND *sound_load(u16 snd_num);
extern u8 *cmd_sound(u8 *c);
extern u8 *cmd_stop_sound(u8 *c);
extern void sound_stop(void);

#endif /* NAGI_SOUND_SOUND_H */
