libdragon
Loading...
Searching...
No Matches
ay8910.h
1#ifndef __LIBDRAGON_AY8910_H
2#define __LIBDRAGON_AY8910_H
3
4#include <stdbool.h>
5#include <stdint.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
22#define AY8910_DECIMATE 3
23
30#define AY8910_OUTPUT_STEREO 1
31
37#define AY8910_VOLUME_ATTENUATE 0.8
38
52#define AY8910_CENTER_SILENCE 1
53
55typedef struct {
56 uint16_t tone_period;
57 uint8_t tone_vol;
58 uint8_t tone_en;
59 uint8_t noise_en;
60
61 uint16_t count;
62 uint8_t out;
63} AYChannel;
64
66typedef struct {
67 uint16_t period;
68 uint8_t shape;
69
70 uint8_t attack;
71 uint8_t alternate;
72 uint8_t hold;
73
74 uint16_t count;
75 int16_t step;
76 uint8_t vol;
77 uint8_t holding;
79
81typedef struct {
82 uint8_t period;
83
84 uint8_t count;
85 uint32_t out;
86} AYNoise;
87
100typedef struct {
101 uint8_t (*PortRead)(int idx);
102 void (*PortWrite)(int idx, uint8_t val);
103 uint8_t addr;
104 uint8_t regs[16];
105 AYChannel ch[3];
108} AY8910;
109
111void ay8910_reset(AY8910 *ay);
112
114void ay8910_set_ports(AY8910 *ay, uint8_t (*PortRead)(int), void (*PortWrite)(int, uint8_t));
115
117void ay8910_write_addr(AY8910 *ay, uint8_t addr);
118
120void ay8910_write_data(AY8910 *ay, uint8_t val);
121
123uint8_t ay8910_read_data(AY8910 *ay);
124
126bool ay8910_is_mute(AY8910 *ay);
127
133int ay8910_gen(AY8910 *ay, int16_t *out, int nsamples);
134
135#ifdef __cplusplus
136}
137#endif
138
139#endif
A AY-3-8910 emulator.
Definition ay8910.h:100
AYNoise ns
Configuration and state of the noise.
Definition ay8910.h:106
uint8_t addr
Current value on the address line.
Definition ay8910.h:103
AYEnvelope env
Configuration and state of the envelope.
Definition ay8910.h:107
A AY-3-8910 channel.
Definition ay8910.h:55
uint8_t out
Current output value for this channel.
Definition ay8910.h:62
uint16_t tone_period
Period (in ticks) of the current tone.
Definition ay8910.h:56
uint8_t tone_en
Enable flag of the tone (0 is enabled)
Definition ay8910.h:58
uint8_t tone_vol
Volume of the tone (0x10 -> use envelope)
Definition ay8910.h:57
uint16_t count
Current tick count for the period.
Definition ay8910.h:61
uint8_t noise_en
Enable flag of the noise for this channel (0 is enabled)
Definition ay8910.h:59
Envelope of AY-3-8910.
Definition ay8910.h:66
uint8_t holding
True if the envelope is currently holding.
Definition ay8910.h:77
uint8_t shape
Shape of the envelope (jigsaw, etc.)
Definition ay8910.h:68
uint16_t count
Current tick count for the period.
Definition ay8910.h:74
uint8_t alternate
True if attack and release alternate (jigsaw)
Definition ay8910.h:71
uint16_t period
Period (in ticks) of the envelope.
Definition ay8910.h:67
int16_t step
Current step of the envelope.
Definition ay8910.h:75
uint8_t vol
Current output volume.
Definition ay8910.h:76
uint8_t attack
0x0 if in attack, 0xF if in the release
Definition ay8910.h:70
uint8_t hold
True if the envelope holds after attack.
Definition ay8910.h:72
Noise of AY-3-8910.
Definition ay8910.h:81
uint32_t out
Current output value.
Definition ay8910.h:85
uint8_t count
Current tick count for the period.
Definition ay8910.h:84
uint8_t period
Period (in ticks) of the noise.
Definition ay8910.h:82