OSDN Git Service

[VM][WIP] Use namespace to devices per VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / msx / scc.h
1 /*
2         Common Source Code Project
3         MSX Series (experimental)
4
5         Origin : emu2212
6         modified by umaiboux
7         Date   : 2016.04.xx-
8
9         [ SCC ]
10 */
11
12 #ifndef _SCC_H_
13 #define _SCC_H_
14
15 #include "../vm.h"
16 #include "../../emu.h"
17 #include "../device.h"
18
19 #define SCC EMU2212
20
21 #define SCC_STANDARD 0
22 #define SCC_ENHANCED 1
23
24 #define SCC_MASK_CH(x) (1<<(x))
25
26 namespace MSX {
27         
28 typedef struct __SCC {
29
30   uint32_t clk, rate ,base_incr, quality ;
31
32   int32_t out, prev, next;
33   uint32_t type ;
34   uint32_t mode ;
35   uint32_t active;
36   uint32_t base_adr;
37   uint32_t mask ;
38   
39   uint32_t realstep ;
40   uint32_t scctime ;
41   uint32_t sccstep ;
42
43   uint32_t incr[5] ;
44
45   int8_t  wave[5][32] ;
46
47   uint32_t count[5] ;
48   uint32_t freq[5] ;
49   uint32_t phase[5] ;
50   uint32_t volume[5] ;
51   uint32_t offset[5] ;
52   uint8_t reg[0x100-0xC0];
53
54   int ch_enable ;
55   int ch_enable_next ;
56
57   int cycle_4bit ;
58   int cycle_8bit ;
59   int refresh ;
60   int rotate[5] ;
61
62 } SCC ;
63
64
65 SCC *SCC_new(uint32_t c, uint32_t r) ;
66 void SCC_reset(SCC *scc) ;
67 void SCC_set_rate(SCC *scc, uint32_t r);
68 void SCC_set_quality(SCC *scc, uint32_t q) ;
69 void SCC_set_type(SCC *scc, uint32_t type) ;
70 void SCC_delete(SCC *scc) ;
71 int16_t SCC_calc(SCC *scc) ;
72 void SCC_write(SCC *scc, uint32_t adr, uint32_t val) ;
73 void SCC_writeReg(SCC *scc, uint32_t adr, uint32_t val) ;
74 uint32_t SCC_read(SCC *scc, uint32_t adr) ;
75 uint32_t SCC_setMask(SCC *scc, uint32_t adr) ;
76 uint32_t SCC_toggleMask(SCC *scc, uint32_t adr) ;
77
78 #undef SCC
79
80 class SCC : public DEVICE
81 {
82 private:
83         EMU2212 *emu2212;
84         int volume_l, volume_r;
85         void save_load_state(FILEIO* state_fio, bool is_save);
86         
87 public:
88         SCC(VM_TEMPLATE* parent_vm, EMU* parent_emu);
89         ~SCC() {}
90         
91         // common functions
92         void write_data8(uint32_t addr, uint32_t data);
93         uint32_t read_data8(uint32_t addr);
94         void initialize();
95         void release();
96         void reset();
97         void mix(int32_t* buffer, int cnt);
98         void set_volume(int ch, int decibel_l, int decibel_r);
99         bool process_state(FILEIO* state_fio, bool loading);
100         
101         // unique functions
102         void initialize_sound(int rate, int clock, int samples);
103 };
104
105 }
106 #endif