#ifndef SN76489_H
#define SN76489_H

#ifdef __ASSEMBLER__

#define r_sreg_save r14

#else  /* !ASSEMBLER */

register uint8_t r_sreg_save asm("r14");

struct sn76489_channel_t {
	uint16_t period;
	uint8_t amplitude;
	uint16_t counter;
	uint8_t state;
};

// Stores the SN76489 channel states.
extern struct sn76489_channel_t sn76489_channels[4];

// Initialises the SN76489.
void sn76489_init(void);

// Writes a control byte to the emulated PSG.
void sn76489_write(uint8_t value);

// Enables or disables channels on the left or right.
extern uint8_t sn76489_stereo_mask;

// Defines the clock frequency of the SN76489.
extern uint32_t sn76489_frequency;

// Defines the width of the SN76489's linear feedback shift register.
extern uint8_t sn76489_shift_register_width;

// Defines the tapped bits in the SN76489's white noise generator.
extern uint16_t sn76489_tapped_bits;

#endif

#endif