libws libws
WSwan hardware library for the Wonderful toolchain
Loading...
Searching...
No Matches
Hardware defines - Sound I/O ports

Macros

#define WS_SOUND_FREQ_CH1_PORT   0x80
#define WS_SOUND_FREQ_CH2_PORT   0x82
#define WS_SOUND_FREQ_CH3_PORT   0x84
#define WS_SOUND_FREQ_CH4_PORT   0x86
#define WS_SOUND_VOL_CH1_PORT   0x88
#define WS_SOUND_VOL_CH2_PORT   0x89
#define WS_SOUND_VOICE_SAMPLE_PORT   0x89
#define WS_SOUND_VOL_CH3_PORT   0x8A
#define WS_SOUND_VOL_CH4_PORT   0x8B
#define WS_SOUND_SWEEP_PORT   0x8C
#define WS_SOUND_SWEEP_TIME_PORT   0x8D
#define WS_SOUND_NOISE_CTRL_PORT   0x8E
#define WS_SOUND_NOISE_CTRL_TAP_14   0x00
#define WS_SOUND_NOISE_CTRL_TAP_10   0x01
#define WS_SOUND_NOISE_CTRL_TAP_13   0x02
#define WS_SOUND_NOISE_CTRL_TAP_4   0x03
#define WS_SOUND_NOISE_CTRL_TAP_8   0x04
#define WS_SOUND_NOISE_CTRL_TAP_6   0x05
#define WS_SOUND_NOISE_CTRL_TAP_9   0x06
#define WS_SOUND_NOISE_CTRL_TAP_11   0x07
#define WS_SOUND_NOISE_CTRL_TAP_SHIFT   0
#define WS_SOUND_NOISE_CTRL_TAP_MASK   0x07
#define WS_SOUND_NOISE_CTRL_LENGTH_32767   0x00
#define WS_SOUND_NOISE_CTRL_LENGTH_1953   0x01
#define WS_SOUND_NOISE_CTRL_LENGTH_254   0x02
#define WS_SOUND_NOISE_CTRL_LENGTH_217   0x03
#define WS_SOUND_NOISE_CTRL_LENGTH_73   0x04
#define WS_SOUND_NOISE_CTRL_LENGTH_63   0x05
#define WS_SOUND_NOISE_CTRL_LENGTH_42   0x06
#define WS_SOUND_NOISE_CTRL_LENGTH_28   0x07
#define WS_SOUND_NOISE_CTRL_LENGTH_SHIFT   0
#define WS_SOUND_NOISE_CTRL_LENGTH_MASK   0x07
#define WS_SOUND_NOISE_CTRL_RESET   0x08
#define WS_SOUND_NOISE_CTRL_ENABLE   0x10
#define WS_SOUND_WAVE_BASE_PORT   0x8F
#define WS_SOUND_WAVE_BASE_ADDR(n)
#define WS_SOUND_CH_CTRL_PORT   0x90
#define WS_SOUND_CH_CTRL_CH1_ENABLE   0x01
#define WS_SOUND_CH_CTRL_CH2_ENABLE   0x02
#define WS_SOUND_CH_CTRL_CH3_ENABLE   0x04
#define WS_SOUND_CH_CTRL_CH4_ENABLE   0x08
#define WS_SOUND_CH_CTRL_CH2_VOICE   0x20
#define WS_SOUND_CH_CTRL_CH3_SWEEP   0x40
#define WS_SOUND_CH_CTRL_CH4_NOISE   0x80
#define WS_SOUND_OUT_CTRL_PORT   0x91
#define WS_SOUND_OUT_CTRL_HEADPHONE_DETECT   0x80
#define WS_SOUND_OUT_CTRL_HEADPHONE_ENABLE   0x08
#define WS_SOUND_OUT_CTRL_SPEAKER_ENABLE   0x01
#define WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_800   0x00
#define WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_400   0x02
#define WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_200   0x04
#define WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_100   0x06
#define WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_SHIFT   1
#define WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_MASK   0x06
#define WS_SOUND_NOISE_LFSR_PORT   0x92
#define WS_SOUND_VOICE_VOL_PORT   0x94
#define WS_SOUND_VOICE_VOL_LEFT_NONE   0x00
#define WS_SOUND_VOICE_VOL_LEFT_HALF   0x08
#define WS_SOUND_VOICE_VOL_LEFT_FULL   0x0C
#define WS_SOUND_VOICE_VOL_LEFT_SHIFT   2
#define WS_SOUND_VOICE_VOL_LEFT_MASK   0x0C
#define WS_SOUND_VOICE_VOL_RIGHT_NONE   0x00
#define WS_SOUND_VOICE_VOL_RIGHT_HALF   0x02
#define WS_SOUND_VOICE_VOL_RIGHT_FULL   0x03
#define WS_SOUND_VOICE_VOL_RIGHT_SHIFT   0
#define WS_SOUND_VOICE_VOL_RIGHT_MASK   0x03
#define WS_SOUND_TEST_PORT   0x95
#define WS_SOUND_TEST_HOLD_CH   0x01
#define WS_SOUND_TEST_FAST_SWEEP   0x02
#define WS_SOUND_TEST_CHOUT_R_PORT   0x96
#define WS_SOUND_TEST_CHOUT_L_PORT   0x98
#define WS_SOUND_TEST_CHOUT_M_PORT   0x9A
#define WS_SOUND_SPEAKER_VOL_PORT   0x9E

Detailed Description

Macro Definition Documentation

◆ WS_SOUND_CH_CTRL_CH1_ENABLE

#define WS_SOUND_CH_CTRL_CH1_ENABLE   0x01

Enable sound channel 1.

Definition at line 912 of file ports.h.

◆ WS_SOUND_CH_CTRL_CH2_ENABLE

#define WS_SOUND_CH_CTRL_CH2_ENABLE   0x02

Enable sound channel 2.

Definition at line 916 of file ports.h.

◆ WS_SOUND_CH_CTRL_CH2_VOICE

#define WS_SOUND_CH_CTRL_CH2_VOICE   0x20

Enable sound channel 2 in voice mode. This overrides the channel 2 enable bit.

Definition at line 928 of file ports.h.

◆ WS_SOUND_CH_CTRL_CH3_ENABLE

#define WS_SOUND_CH_CTRL_CH3_ENABLE   0x04

Enable sound channel 3.

Definition at line 920 of file ports.h.

◆ WS_SOUND_CH_CTRL_CH3_SWEEP

#define WS_SOUND_CH_CTRL_CH3_SWEEP   0x40

Enable applying a frequency sweep effect on sound channel 3.

Definition at line 932 of file ports.h.

◆ WS_SOUND_CH_CTRL_CH4_ENABLE

#define WS_SOUND_CH_CTRL_CH4_ENABLE   0x08

Enable sound channel 4.

Definition at line 924 of file ports.h.

◆ WS_SOUND_CH_CTRL_CH4_NOISE

#define WS_SOUND_CH_CTRL_CH4_NOISE   0x80

Provide samples to sound channel 4 from the LFSR noise generator, as opposed to the wavetable.

Definition at line 936 of file ports.h.

◆ WS_SOUND_CH_CTRL_PORT

#define WS_SOUND_CH_CTRL_PORT   0x90

Controls sound channels.

Definition at line 908 of file ports.h.

◆ WS_SOUND_FREQ_CH1_PORT

#define WS_SOUND_FREQ_CH1_PORT   0x80

Sound channel 1 frequency, stored as a divisor. Every 2048 - divisor cycles, the index of the sample to be fetched from the wavetable is incremented.

The resulting frequency is calculated as follows: sample rate = 3072000 Hz / (2048 - divisor).

Note that this refers to the sample rate of each sample in the wavetable, and needs to be scaled accordingly for a given waveform. For example, a 50% duty square wave (16 samples of 0 followed by 16 samples of 15) will have an effective sample rate of (3072000 / 32) Hz / (2048 - divisor), or 96000 Hz / (2048 - divisor).

Definition at line 823 of file ports.h.

◆ WS_SOUND_FREQ_CH2_PORT

#define WS_SOUND_FREQ_CH2_PORT   0x82

Sound channel 2 frequency, stored as a divisor. Ignored in voice mode.

Definition at line 828 of file ports.h.

◆ WS_SOUND_FREQ_CH3_PORT

#define WS_SOUND_FREQ_CH3_PORT   0x84

Sound channel 3 frequency, stored as a divisor.

Definition at line 833 of file ports.h.

◆ WS_SOUND_FREQ_CH4_PORT

#define WS_SOUND_FREQ_CH4_PORT   0x86

Sound channel 4 frequency, stored as a divisor.

Definition at line 838 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_ENABLE

#define WS_SOUND_NOISE_CTRL_ENABLE   0x10

Enable the LFSR noise generator.

Definition at line 897 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_LENGTH_1953

#define WS_SOUND_NOISE_CTRL_LENGTH_1953   0x01

Definition at line 881 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_LENGTH_217

#define WS_SOUND_NOISE_CTRL_LENGTH_217   0x03

Definition at line 883 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_LENGTH_254

#define WS_SOUND_NOISE_CTRL_LENGTH_254   0x02

Definition at line 882 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_LENGTH_28

#define WS_SOUND_NOISE_CTRL_LENGTH_28   0x07

Definition at line 887 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_LENGTH_32767

#define WS_SOUND_NOISE_CTRL_LENGTH_32767   0x00

Definition at line 880 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_LENGTH_42

#define WS_SOUND_NOISE_CTRL_LENGTH_42   0x06

Definition at line 886 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_LENGTH_63

#define WS_SOUND_NOISE_CTRL_LENGTH_63   0x05

Definition at line 885 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_LENGTH_73

#define WS_SOUND_NOISE_CTRL_LENGTH_73   0x04

Definition at line 884 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_LENGTH_MASK

#define WS_SOUND_NOISE_CTRL_LENGTH_MASK   0x07

Definition at line 889 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_LENGTH_SHIFT

#define WS_SOUND_NOISE_CTRL_LENGTH_SHIFT   0

Definition at line 888 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_PORT

#define WS_SOUND_NOISE_CTRL_PORT   0x8E

Definition at line 869 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_RESET

#define WS_SOUND_NOISE_CTRL_RESET   0x08

Reset the LFSR noise generator.

Definition at line 893 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_TAP_10

#define WS_SOUND_NOISE_CTRL_TAP_10   0x01

Definition at line 871 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_TAP_11

#define WS_SOUND_NOISE_CTRL_TAP_11   0x07

Definition at line 877 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_TAP_13

#define WS_SOUND_NOISE_CTRL_TAP_13   0x02

Definition at line 872 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_TAP_14

#define WS_SOUND_NOISE_CTRL_TAP_14   0x00

Definition at line 870 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_TAP_4

#define WS_SOUND_NOISE_CTRL_TAP_4   0x03

Definition at line 873 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_TAP_6

#define WS_SOUND_NOISE_CTRL_TAP_6   0x05

Definition at line 875 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_TAP_8

#define WS_SOUND_NOISE_CTRL_TAP_8   0x04

Definition at line 874 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_TAP_9

#define WS_SOUND_NOISE_CTRL_TAP_9   0x06

Definition at line 876 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_TAP_MASK

#define WS_SOUND_NOISE_CTRL_TAP_MASK   0x07

Definition at line 879 of file ports.h.

◆ WS_SOUND_NOISE_CTRL_TAP_SHIFT

#define WS_SOUND_NOISE_CTRL_TAP_SHIFT   0

Definition at line 878 of file ports.h.

◆ WS_SOUND_NOISE_LFSR_PORT

#define WS_SOUND_NOISE_LFSR_PORT   0x92

Definition at line 973 of file ports.h.

◆ WS_SOUND_OUT_CTRL_HEADPHONE_DETECT

#define WS_SOUND_OUT_CTRL_HEADPHONE_DETECT   0x80

Set if a headphone adapter is connected.

Definition at line 945 of file ports.h.

◆ WS_SOUND_OUT_CTRL_HEADPHONE_ENABLE

#define WS_SOUND_OUT_CTRL_HEADPHONE_ENABLE   0x08

Enable output to the headphone output on the EXT port.

Definition at line 949 of file ports.h.

◆ WS_SOUND_OUT_CTRL_PORT

#define WS_SOUND_OUT_CTRL_PORT   0x91

Controls sound output circuitry.

Definition at line 941 of file ports.h.

◆ WS_SOUND_OUT_CTRL_SPEAKER_ENABLE

#define WS_SOUND_OUT_CTRL_SPEAKER_ENABLE   0x01

Enable output to the internal speaker.

Definition at line 953 of file ports.h.

◆ WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_100

#define WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_100   0x06

Internal speaker volume: 100% (shift right by 3 bits).

Definition at line 969 of file ports.h.

◆ WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_200

#define WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_200   0x04

Internal speaker volume: 200% (shift right by 2 bits).

Definition at line 965 of file ports.h.

◆ WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_400

#define WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_400   0x02

Internal speaker volume: 400% (shift right by 1 bit).

Definition at line 961 of file ports.h.

◆ WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_800

#define WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_800   0x00

Internal speaker volume: 800% (shift right by 0 bits).

Definition at line 957 of file ports.h.

◆ WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_MASK

#define WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_MASK   0x06

Definition at line 971 of file ports.h.

◆ WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_SHIFT

#define WS_SOUND_OUT_CTRL_SPEAKER_VOLUME_SHIFT   1

Definition at line 970 of file ports.h.

◆ WS_SOUND_SPEAKER_VOL_PORT

#define WS_SOUND_SPEAKER_VOL_PORT   0x9E

Controls the internal speaker volume.

Definition at line 1033 of file ports.h.

◆ WS_SOUND_SWEEP_PORT

#define WS_SOUND_SWEEP_PORT   0x8C

Definition at line 865 of file ports.h.

◆ WS_SOUND_SWEEP_TIME_PORT

#define WS_SOUND_SWEEP_TIME_PORT   0x8D

Definition at line 867 of file ports.h.

◆ WS_SOUND_TEST_CHOUT_L_PORT

#define WS_SOUND_TEST_CHOUT_L_PORT   0x98

Sound test port: synthesizer (channel 1-4) left channel output sample in bits 0-9.

Definition at line 1023 of file ports.h.

◆ WS_SOUND_TEST_CHOUT_M_PORT

#define WS_SOUND_TEST_CHOUT_M_PORT   0x9A

Sound test port: synthesizer (channel 1-4) sum of output samples in bits 0-10.

Definition at line 1028 of file ports.h.

◆ WS_SOUND_TEST_CHOUT_R_PORT

#define WS_SOUND_TEST_CHOUT_R_PORT   0x96

Sound test port: synthesizer (channel 1-4) right channel output sample in bits 0-9.

Definition at line 1018 of file ports.h.

◆ WS_SOUND_TEST_FAST_SWEEP

#define WS_SOUND_TEST_FAST_SWEEP   0x02

Disables the sweep clock divisor, applying the sweep effect at a rate of 3072000 Hz.

Definition at line 1013 of file ports.h.

◆ WS_SOUND_TEST_HOLD_CH

#define WS_SOUND_TEST_HOLD_CH   0x01

Definition at line 1009 of file ports.h.

◆ WS_SOUND_TEST_PORT

#define WS_SOUND_TEST_PORT   0x95

Sound test port.

Definition at line 1008 of file ports.h.

◆ WS_SOUND_VOICE_SAMPLE_PORT

#define WS_SOUND_VOICE_SAMPLE_PORT   0x89

Sound channel 2 unsigned PCM sample; used in voice mode.

Definition at line 853 of file ports.h.

◆ WS_SOUND_VOICE_VOL_LEFT_FULL

#define WS_SOUND_VOICE_VOL_LEFT_FULL   0x0C

Channel 2 left voice volume: 100%.

Definition at line 987 of file ports.h.

◆ WS_SOUND_VOICE_VOL_LEFT_HALF

#define WS_SOUND_VOICE_VOL_LEFT_HALF   0x08

Channel 2 left voice volume: 50%.

Definition at line 983 of file ports.h.

◆ WS_SOUND_VOICE_VOL_LEFT_MASK

#define WS_SOUND_VOICE_VOL_LEFT_MASK   0x0C

Definition at line 989 of file ports.h.

◆ WS_SOUND_VOICE_VOL_LEFT_NONE

#define WS_SOUND_VOICE_VOL_LEFT_NONE   0x00

Channel 2 left voice volume: 0%.

Definition at line 979 of file ports.h.

◆ WS_SOUND_VOICE_VOL_LEFT_SHIFT

#define WS_SOUND_VOICE_VOL_LEFT_SHIFT   2

Definition at line 988 of file ports.h.

◆ WS_SOUND_VOICE_VOL_PORT

#define WS_SOUND_VOICE_VOL_PORT   0x94

Definition at line 975 of file ports.h.

◆ WS_SOUND_VOICE_VOL_RIGHT_FULL

#define WS_SOUND_VOICE_VOL_RIGHT_FULL   0x03

Channel 2 right voice volume: 100%.

Definition at line 1001 of file ports.h.

◆ WS_SOUND_VOICE_VOL_RIGHT_HALF

#define WS_SOUND_VOICE_VOL_RIGHT_HALF   0x02

Channel 2 right voice volume: 50%.

Definition at line 997 of file ports.h.

◆ WS_SOUND_VOICE_VOL_RIGHT_MASK

#define WS_SOUND_VOICE_VOL_RIGHT_MASK   0x03

Definition at line 1003 of file ports.h.

◆ WS_SOUND_VOICE_VOL_RIGHT_NONE

#define WS_SOUND_VOICE_VOL_RIGHT_NONE   0x00

Channel 2 right voice volume: 0%.

Definition at line 993 of file ports.h.

◆ WS_SOUND_VOICE_VOL_RIGHT_SHIFT

#define WS_SOUND_VOICE_VOL_RIGHT_SHIFT   0

Definition at line 1002 of file ports.h.

◆ WS_SOUND_VOL_CH1_PORT

#define WS_SOUND_VOL_CH1_PORT   0x88

Sound channel 1 volume.

Definition at line 843 of file ports.h.

◆ WS_SOUND_VOL_CH2_PORT

#define WS_SOUND_VOL_CH2_PORT   0x89

Sound channel 2 volume.

Definition at line 848 of file ports.h.

◆ WS_SOUND_VOL_CH3_PORT

#define WS_SOUND_VOL_CH3_PORT   0x8A

Sound channel 3 volume.

Definition at line 858 of file ports.h.

◆ WS_SOUND_VOL_CH4_PORT

#define WS_SOUND_VOL_CH4_PORT   0x8B

Sound channel 4 volume.

Definition at line 863 of file ports.h.

◆ WS_SOUND_WAVE_BASE_ADDR

#define WS_SOUND_WAVE_BASE_ADDR ( n)
Value:
(((unsigned int) (n)) >> 6)

Definition at line 903 of file ports.h.

◆ WS_SOUND_WAVE_BASE_PORT

#define WS_SOUND_WAVE_BASE_PORT   0x8F

Sound wavetable base address.

Definition at line 902 of file ports.h.