Use the PSG

From F256 Foenix
Jump to navigationJump to search

The PSG is inside the FPGA of the F256Jr, F256K, F256Jr2 and F256K2[edit | edit source]

The F256 machines have a dual PSG based on the SN76489 inside the Beatrix FPGA which generate 3 tones of square wave and one noise generator each.

Register Name Address Description
PSG_LEFT 0xD600 Send all formatted commands here to the left PSG
PSG_RIGHT 0xD610 Send all formatted commands here to the right PSG
PSG_COMBINED_LEFT_RIGHT 0xD608 Send all formatted commands here to both PSG
SYS1 0xD6A1 System Ctrl reg: bit2 sets PSG_ST = psg status. if 0, left and right are mixed to monaural output. if 1, left and right are normal stereo

Command Formats[edit | edit source]

Example:

To produce a 440 Hz A on Tone 1, send these bytes to address 0xD600 (left PSG)

0b1001 0100 (middle volume "attenuation" command)
0b1000 1101 (low byte of the note)
0b0000 1111 (high byte of the note).

to stop the sound, send to 0xD600:

0b1001 1111 (max attenuation closes off the sound)

Frequency bytes in C, meant for tone 1[edit | edit source]

The high nybble of the low byte is set at 8 for tone 1, replace with A for tone 2, or with C for tone 3

uint8_t psgLow[] = {

0x86, 0x8d,0x87,0x84,0x84,0x87,0x8d,0x84,0x8e,0x8b,0x89,0x89,

0x8b, 0x8e,0x83,0x8a,0x82,0x8b,0x86,0x82,0x8f,0x8d,0x8c,0x8c,

0x8d, 0x8f,0x81,0x85,0x89,0x8d,0x83,0x89,0x8f,0x86,0x8e,0x86,

0x8e, 0x87,0x80,0x8a,0x84,0x8e,0x89,0x84,0x8f,0x8b,0x87,0x83,

0x8f, 0x8b,0x88,0x85,0x82,0x8f,0x8c,0x8a,0x87,0x85,0x83,0x81,

0x8f, 0x8d,0x8c,0x8a};


uint8_t psgHigh[] = {

0x3f, 0x3b,0x38,0x35,0x32,0x2f,0x2c,0x2a,0x27,0x25,0x23,0x21,

0x1f, 0x1d,0x1c,0x1a,0x19,0x17,0x16,0x15,0x13,0x12,0x11,0x10,

0xf, 0xe,0xe,0xd,0xc,0xb,0xb,0xa,0x9,0x9,0x8,0x8,

0x7, 0x7,0x7,0x6,0x6,0x5,0x5,0x5,0x4,0x4,0x4,0x4,

0x3, 0x3,0x3,0x3,0x3,0x2,0x2,0x2,0x2,0x2,0x2,0x2,

0x1, 0x1,0x1,0x1};