OSDN Git Service

[GENERAL][BUILD] Merge upstream 2015-07-31.
[csp-qt/common_source_project-fm7.git] / source / src / vm / ym2151.h
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2009.03.08-
6
7         [ YM2151 ]
8 */
9
10 #ifndef _YM2151_H_
11 #define _YM2151_H_
12
13 #include "vm.h"
14 #include "../emu.h"
15 #include "device.h"
16 #include "fmgen/opm.h"
17
18 #if defined(_WIN32)
19 #define SUPPORT_MAME_FM_DLL
20 #include "fmdll/fmdll.h"
21 #endif
22
23 #define SIG_YM2151_MUTE         0
24
25 class YM2151 : public DEVICE
26 {
27 private:
28         // output signals
29         outputs_t outputs_irq;
30         
31         FM::OPM* opm;
32 #ifdef SUPPORT_MAME_FM_DLL
33         CFMDLL* fmdll;
34         LPVOID* dllchip;
35         struct {
36                 bool written;
37                 uint8 data;
38         } port_log[0x100];
39 #endif
40         
41         int chip_clock;
42         uint8 ch;
43         bool irq_prev, mute;
44         
45         uint32 clock_prev;
46         uint32 clock_accum;
47         uint32 clock_const;
48         int timer_event_id;
49         
50         uint32 clock_busy;
51         bool busy;
52         
53         void update_count();
54         void update_event();
55         void update_interrupt();
56         
57 public:
58         YM2151(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
59         {
60                 init_output_signals(&outputs_irq);
61         }
62         ~YM2151() {}
63         
64         // common functions
65         void initialize();
66         void release();
67         void reset();
68         void write_io8(uint32 addr, uint32 data);
69         uint32 read_io8(uint32 addr);
70         void write_signal(int id, uint32 data, uint32 mask);
71         void event_vline(int v, int clock);
72         void event_callback(int event_id, int error);
73         void mix(int32* buffer, int cnt);
74         void update_timing(int new_clocks, double new_frames_per_sec, int new_lines_per_frame);
75         void save_state(FILEIO* state_fio);
76         bool load_state(FILEIO* state_fio);
77         
78         // unique functions
79         void set_context_irq(DEVICE* device, int id, uint32 mask)
80         {
81                 register_output_signal(&outputs_irq, device, id, mask);
82         }
83         void init(int rate, int clock, int samples, int vol);
84         void SetReg(uint addr, uint data); // for patch
85 };
86
87 #endif
88