Register
PSG_SetRegister
void PSG_SetRegister(
u8 reg,
u8 value
)

Set the value of a given register

Parameters
reg
u8

Register to set

value
u8

Value to set

PSG_GetRegister
u8 PSG_GetRegister(
u8 reg
)

Get the value of a given register

Parameters
reg
u8

Register to get

Return

Value of the register

Helper
PSG_SetTone
void PSG_SetTone(
u8 chan,
u16 period
)

Set the tone period of a given channel (tone generator control register)

Parameters
chan
u8

Channel to set (0 to 2; or PSG_CHANNEL_A, PSG_CHANNEL_B, PSG_CHANNEL_C)

period
u16

Period to set (12-bits value)

PSG_SetNoise
void PSG_SetNoise(
u8 period
)

Set the noise period (noise generator control register)

Parameters
period
u8

Period to set (5-bits value)

PSG_SetMixer
void PSG_SetMixer(
u8 mix
)

Setup mixer by enabling tune and noise generators for each channel (mixer control enable register)

Parameters
mix
u8

Mixer value to set

PSG_SetVolume
void PSG_SetVolume(
u8 chan,
u8 vol
)

Set the volume of a given channel (Amplitude control register)

Parameters
chan
u8

Channel to set (0 to 2; or PSG_CHANNEL_A, PSG_CHANNEL_B, PSG_CHANNEL_C)

vol
u8

Volume to set (4-bits value)

PSG_SetEnvelope
void PSG_SetEnvelope(
u16 period
)

Set the envelope period (Envelope priod control register)

Parameters
period
u16

Period to set (16-bits value)

PSG_SetShape
void PSG_SetShape(
u8 shape
)

Set the envelope shape (Envelope shape control register)

Parameters
shape
u8

Shape to set (4-bits value)

PSG_EnableTone
void PSG_EnableTone(
u8 chan,
bool val
)

Enable/disable tone on the given channel

Parameters
chan
u8

Channel to set (0 to 2; or PSG_CHANNEL_A, PSG_CHANNEL_B, PSG_CHANNEL_C)

val
bool

TRUE to enable, FALSE to disable

PSG_EnableNoise
void PSG_EnableNoise(
u8 chan,
bool val
)

Enable/disable noise on the given channel

Parameters
chan
u8

Channel to set (0 to 2; or PSG_CHANNEL_A, PSG_CHANNEL_B, PSG_CHANNEL_C)

val
bool

TRUE to enable, FALSE to disable

PSG_EnableEnvelope
void PSG_EnableEnvelope(
u8 chan,
bool val
)

Enable/disable envelope on the given channel

Parameters
chan
u8

Channel to set (0 to 2; or PSG_CHANNEL_A, PSG_CHANNEL_B, PSG_CHANNEL_C)

PSG_Mute
void PSG_Mute()

Silent the PSG (set according registers)

PSG_Resume
void PSG_Resume()

Resume PSG sound

Indirect
PSG_Apply
void PSG_Apply()

Send data to PSG registers #0 to #13