OSDN Git Service

[DOC] For release 2017-01-24.
[csp-qt/common_source_project-fm7.git] / source / src / vm / tms3631.h
1 /*
2         Skelton for retropc emulator
3
4         Origin : Neko Project 2
5         Author : Takeda.Toshiya
6         Date   : 2015.09.29-
7
8         [ TMS3631 ]
9 */
10
11 #ifndef _TMS3631_H_
12 #define _TMS3631_H_
13
14 #include "vm.h"
15 #include "../emu.h"
16 #include "device.h"
17
18 #define SIG_TMS3631_ENVELOP1    0
19 #define SIG_TMS3631_ENVELOP2    1
20 #define SIG_TMS3631_DATAREG     2
21 #define SIG_TMS3631_MASKREG     3
22
23 class TMS3631 : public DEVICE
24 {
25 private:
26         uint8_t envelop1, envelop2, datareg, maskreg;
27         
28         struct {
29                 uint32_t freq;
30                 uint32_t count;
31         } ch[8];
32         uint8_t channel;
33         bool set_key;
34         
35         uint32_t freq_table[64];
36         int vol, feet[16];
37         int volume_l, volume_r;
38         
39 public:
40         TMS3631(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
41         {
42                 volume_l = volume_r = 1024;
43                 set_device_name(_T("TMS3631 SSG"));
44         }
45         ~TMS3631() {}
46         
47         // common functions
48         void reset();
49         void write_signal(int id, uint32_t data, uint32_t mask);
50         void mix(int32_t* buffer, int cnt);
51         void set_volume(int ch, int decibel_l, int decibel_r);
52         void save_state(FILEIO* state_fio);
53         bool load_state(FILEIO* state_fio);
54         
55         // unique function
56         void initialize_sound(int rate, int volume);
57 };
58
59 #endif
60