-
Notifications
You must be signed in to change notification settings - Fork 2
/
AY38910.h
113 lines (97 loc) · 2.51 KB
/
AY38910.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// AY38910.h
// AY-3-8910 / YM2149 sound chip emulator for arm32.
//
// Created by Fredrik Ahlström on 2006-03-07.
// Copyright © 2006-2024 Fredrik Ahlström. All rights reserved.
//
#ifndef AY38910_HEADER
#define AY38910_HEADER
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
u16 ch0Freq;
u16 ch0Addr;
u16 ch1Freq;
u16 ch1Addr;
u16 ch2Freq;
u16 ch2Addr;
u16 ch3Freq;
u16 ch3Addr;
u32 ayRng;
u32 ayEnvFreq;
u8 ayChState;
u8 ayChDisable;
u8 ayEnvType;
u8 ayEnvAddr;
u32 ayOldSample;
u16 *ayEnvVolumePtr;
u8 ayAttChg;
u8 ayRegIndex;
u8 ayPadding1[2];
s16 ayCalculatedVolumes[8];
u8 ayPortAOut;
u8 ayPortBOut;
u8 ayPortAIn;
u8 ayPortBIn;
u8 ayRegs[16];
u8 (*ayPortAInFptr)(u8, int);
u8 (*ayPortBInFptr)(u8, int);
void (*ayPortAOutFptr)(u8);
void (*ayPortBOutFptr)(u8);
} AY38910;
/**
* Reset/initialize AY38910 chip.
* @param *chip: The AY38910 chip.
*/
void ay38910Reset(AY38910 *chip);
/**
* Saves the state of the AY38910 chip to the destination.
* @param *destination: Where to save the state.
* @param *chip: The AY38910 chip to save.
* @return The size of the state.
*/
int ay38910SaveState(void *dest, const AY38910 *chip);
/**
* Loads the state of the AY38910 chip from the source.
* @param *chip: The AY38910 chip to load a state into.
* @param *source: Where to load the state from.
* @return The size of the state.
*/
int ay38910LoadState(AY38910 *chip, const void *source);
/**
* Gets the state size of a AY38910.
* @return The size of the state.
*/
int ay38910GetStateSize(void);
/**
* Renders count amount of samples, clocks the chip the same amount.
* Internal oversampling can be set by defining AY_UPSHIFT to a number.
* @param count: Number of samples to render.
* @param *dest: Pointer to buffer where sound is rendered.
* @param *chip: The AY38910 chip.
*/
void ay38910Mixer(int count, s16 *dest, AY38910 *chip);
/**
* Write index/register value to the AY38910 chip
* @param index: index to write.
* @param *chip: The AY38910 chip.
*/
void ay38910IndexW(u8 index, AY38910 *chip);
/**
* Write data value to the selected index/register or IO-port in the AY38910 chip
* @param value: value to write.
* @param *chip: The AY38910 chip.
*/
void ay38910DataW(u8 value, AY38910 *chip);
/**
* Read data from the selected index/register in the AY38910 chip
* @param *chip: The AY38910 chip.
* @return The value in the selected index/register or IO-port.
*/
u8 ay38910DataR(AY38910 *chip);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AY38910_HEADER