-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpsg.h
82 lines (60 loc) · 1.5 KB
/
psg.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
#ifndef PSG_H
#define PSG_H
#define MASTER_CLOCK_RATE 21477270ll
// 32B + 44B
// 76B
typedef struct
{
s8 waveform_data[32];
u32 read_index;
u32 write_index;
u32 control;
u32 noise_control;
u32 frequency;
u32 frequency_step;
u32 balance;
u32 audio_data;
s32 l_volume;
s32 r_volume;
u32 update_frequency_step;
} psg_channel_struct;
// 456B + 64B + 368B + 32KB
// 32KB + 888B
typedef struct
{
psg_channel_struct psg_channels[6];
u32 current_channel_value;
u32 global_balance;
u32 lfo_control;
u32 lfo_frequency;
u32 psg_updated;
u64 last_cycles;
s64 lfo_cycles;
u32 lfo_period;
// Don't save in savestate, but do reconstruct the current_channel
// pointer upon loading.
u32 clock_step;
s8 noise_data[256 * 1024];
s32 volume_data[92];
psg_channel_struct *current_channel;
} psg_struct;
extern psg_struct psg;
extern const u32 step_fractional_bits_clock;
extern const u32 step_fractional_bits_frequency;
void psg_channel_select(u32 value);
void psg_global_balance(u32 value);
void psg_fine_frequency(u32 value);
void psg_rough_frequency(u32 value);
void psg_channel_control(u32 value);
void psg_channel_balance(u32 value);
void psg_sound_data(u32 value);
void psg_noise_control(u32 value);
void psg_lfo_frequency(u32 value);
void psg_lfo_control(u32 value);
void initialize_psg();
void reset_psg();
void update_psg();
void audio_exit();
void psg_load_savestate(savestate_load_type savestate_file);
void psg_store_savestate(savestate_store_type savestate_file);
#endif