You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+32-212
Original file line number
Diff line number
Diff line change
@@ -11,10 +11,8 @@ Programming language: C and Z80 assembler
11
11
---
12
12
## Description
13
13
14
-
This project is an opensource library functions for access to internal or external MSX PSG AY-3-8910.
14
+
Library functions for access to internal or external MSX PSG AY-3-8910.
15
15
16
-
Designed for developing MSX applications using Small Device C Compiler (SDCC).
17
-
18
16
It does not use the BIOS so it can be used to program both ROMs or MSX-DOS executables.
19
17
20
18
This library is similar to the [PSG AY-3-8910 RT](https://github.com/mvac7/SDCC_AY38910RT_Lib), but instead of writing directly to the registers,
@@ -24,7 +22,7 @@ It is designed to work together with the [PT3player](https://github.com/mvac7/SD
24
22
25
23
In this same repository you will find a **short version**[(AY38910BF_S)](https://github.com/mvac7/SDCC_AY38910BF_Lib/tree/main/Short) with the essentials to work with player libraries.
*[WebMSX](https://webmsx.org/) emulator by Paulo A. Peccin >> [(gitHub)](https://github.com/ppeccin/webmsx)
86
-
* fMSX emulator by Marat Fayzullin [WEB](https://fms.komkon.org/fMSX/)
87
-
* Meisei emulator >> ?
88
-
89
-
90
-
<br/>
91
-
92
-
---
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
## Definitions
104
-
105
-
106
-
### AY Type
107
-
108
-
Label | Value
109
-
-- | --
110
-
AY_INTERNAL | 0
111
-
AY_EXTERNAL | 1
112
-
113
-
114
-
### AY Registers
115
-
116
-
Label | Value | Description
117
-
-- | -- | --
118
-
AY_ToneA | 0 | Channel A Tone Period (12 bits)
119
-
AY_ToneB | 2 | Channel B Tone Period (12 bits)
120
-
AY_ToneC | 4 | Channel C Tone Period (12 bits)
121
-
AY_Noise | 6 | Noise Period (5 bits)
122
-
AY_Mixer | 7 | Mixer
123
-
AY_AmpA | 8 | Channel Volume A (4 bits + B5 active Envelope)
124
-
AY_AmpB | 9 | Channel Volume B (4 bits + B5 active Envelope)
125
-
AY_AmpC | 10 | Channel Volume C (4 bits + B5 active Envelope)
126
-
AY_EnvPeriod | 11 | Envelope Period (16 bits)
127
-
AY_EnvShape | 13 | Envelope Shape
128
-
129
-
130
-
### Envelope shapes
131
-
132
-
The header file defines envelope shapes in case you prefer to use it instead
133
-
of the numerical form:
134
-
135
-
Label | Value
136
-
-- | --
137
-
AY_ENV_LowerBeat | 1
138
-
AY_ENV_Upper | 4
139
-
AY_ENV_LeftSaw | 8
140
-
AY_ENV_LowerTriangle | 10
141
-
AY_ENV_LowerHold | 11
142
-
AY_ENV_RightSaw | 12
143
-
AY_ENV_UpperHold | 13
144
-
AY_ENV_UpperTriangle | 14
145
-
146
-
**Attention!** The LowerBeat shape may be produced with the values: 0, 1, 2, 3 and 9.
147
-
The value 1 has been assigned to *LowerBeat* as 0 can be useful in case you need to control when the envelope is triggered. In this case 0 can act as a "don't
148
-
write the envelop" event. Remember that, every time the register 13 is written, the sound with the assigned shape is started.
149
-
150
-
The Upper shape may be produced with the values: 4, 5, 6, 7 and 15.
151
-
152
-
153
-
154
-
### AY channels
155
-
156
-
You can use it in the functions: SetTonePeriod, SetVolume and SetChannel
157
-
158
-
Label | Value
159
-
-- | --
160
-
AY_Channel_A | 0
161
-
AY_Channel_B | 1
162
-
AY_Channel_C | 2
163
-
164
-
165
-
166
-
## Functions
167
-
168
-
***AY_Init**() - Initialize the buffer
169
-
***SOUND**(register, value) - Write into a register of PSG
170
-
***GetSound**(register) - Read PSG register value
171
-
***SetTonePeriod**(channel, period) - Set Tone Period for any channel
172
-
***SetNoisePeriod**(period) - Set Noise Period
173
-
***SetEnvelopePeriod**(period) - Set Envelope Period
174
-
***SetVolume**(channel, volume) - Set volume channel
175
-
***SetChannel**(channel, isTone, isNoise) - Mixer. Enable/disable Tone and Noise channels.
176
-
***SetEnvelope**(shape) - Set envelope type. Plays the sound on channels that have a volume of 16.
177
-
***PlayAY**() - Send data from AYREGS buffer to AY registers. (Execute on each interruption of VBLANK).
178
-
179
-
180
-
181
-
## Set Internal or External AY
182
-
183
-
To indicate in which PSG the sounds are to be played, you have the **AY_TYPE** variable.
184
-
To select an external AY (ports 10h to 12h), like the one included in the MegaFlashROM SCC+, Flashjacks or other, you have to set the variable to 1 (or AY_EXTERNAL).
185
-
186
-
```
187
-
AY_TYPE = AY_EXTERNAL;
188
-
```
189
-
190
-
**Attention!** When you execute the AY_Init() function, it will be updated to the default value corresponding to the internal AY.
0 commit comments