OSDN Git Service

[VM][WIP] Set default name to devices, these are WIP.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pcm1bit.h
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2007.02.09 -
6
7         [ 1bit PCM ]
8 */
9
10 #ifndef _PCM1BIT_H_
11 #define _PCM1BIT_H_
12
13 #include "vm.h"
14 #include "../emu.h"
15 #include "device.h"
16
17 #define SIG_PCM1BIT_SIGNAL      0
18 #define SIG_PCM1BIT_ON          1
19 #define SIG_PCM1BIT_MUTE        2
20
21 class PCM1BIT : public DEVICE
22 {
23 private:
24         bool signal, on, mute;
25         int changed;
26         uint32_t prev_clock;
27         int positive_clocks, negative_clocks;
28         int max_vol, last_vol_l, last_vol_r;
29         int volume_l, volume_r;
30         
31 public:
32         PCM1BIT(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
33         {
34                 volume_l = volume_r = 1024;
35                 set_device_name(_T("1BIT PCM"));
36         }
37         ~PCM1BIT() {}
38         
39         // common functions
40         void initialize();
41         void reset();
42         void write_signal(int id, uint32_t data, uint32_t mask);
43         void event_frame();
44         void mix(int32_t* buffer, int cnt);
45         void set_volume(int ch, int decibel_l, int decibel_r);
46         void save_state(FILEIO* state_fio);
47         bool load_state(FILEIO* state_fio);
48         // unique function
49         void initialize_sound(int rate, int volume);
50 };
51
52 #endif
53