OSDN Git Service

[VM] Add vm_template.h . This class, VM_TEMPLATE:: must be mother of VM:: .See fm7...
[csp-qt/common_source_project-fm7.git] / source / src / vm / hd46505.h
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2007.02.08 -
6
7         [ HD46505 ]
8 */
9
10 #ifndef _HD46505_H_
11 #define _HD46505_H_
12
13 //#include "vm.h"
14 //#include "../emu.h"
15 #include "device.h"
16
17 class HD46505 : public DEVICE
18 {
19
20 private:
21         // output signals
22         outputs_t outputs_disp;
23         outputs_t outputs_vblank;
24         outputs_t outputs_vsync;
25         outputs_t outputs_hsync;
26         
27         uint8_t regs[18];
28         bool regs_written[18];
29         int ch;
30         bool timing_changed;
31         
32         int cpu_clocks;
33 //#if defined(HD46505_CHAR_CLOCK)
34         double char_clock, next_char_clock;
35 //#elif defined(HD46505_HORIZ_FREQ)
36         double horiz_freq, next_horiz_freq;
37 //#endif
38         double frames_per_sec;
39         
40         int hz_total, hz_disp;
41         int hs_start, hs_end;
42         
43         int vt_total, vt_disp;
44         int vs_start, vs_end;
45         
46         int disp_end_clock;
47         int hs_start_clock, hs_end_clock;
48         
49         bool display, vblank, vsync, hsync;
50
51         int _SCREEN_WIDTH;
52         int _SCREEN_HEIGHT;
53         int _CHARS_PER_LINE;
54         int _LINES_PER_FRAME;
55         bool _E_HD46505_CHAR_CLOCK;
56         bool _E_HD46505_HORIZ_FREQ;
57         double _HD46505_CHAR_CLOCK;
58         double _HD46505_HORIZ_FREQ;
59         
60         void set_display(bool val);
61         void set_vblank(bool val);
62         void set_vsync(bool val);
63         void set_hsync(bool val);
64         
65 public:
66         HD46505(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
67         {
68                 initialize_output_signals(&outputs_disp);
69                 initialize_output_signals(&outputs_vblank);
70                 initialize_output_signals(&outputs_vsync);
71                 initialize_output_signals(&outputs_hsync);
72                 _SCREEN_WIDTH = 640;
73                 _SCREEN_HEIGHT = 200;
74                 _CHARS_PER_LINE = 80;
75                 _LINES_PER_FRAME = 200;
76                 _HD46505_CHAR_CLOCK = 0.0;
77                 _HD46505_HORIZ_FREQ = 0.0;
78                 _E_HD46505_CHAR_CLOCK = false;
79                 _E_HD46505_HORIZ_FREQ = false;
80                 set_device_name(_T("HD46505 CRTC"));
81         }
82         ~HD46505() {}
83         
84         // common functions
85         void initialize();
86         void reset();
87         void write_io8(uint32_t addr, uint32_t data);
88         uint32_t read_io8(uint32_t addr);
89         void event_pre_frame();
90         void event_frame();
91         void event_vline(int v, int clock);
92         void event_callback(int event_id, int err);
93         void update_timing(int new_clocks, double new_frames_per_sec, int new_lines_per_frame);
94         void decl_state();
95         void save_state(FILEIO* state_fio);
96         bool load_state(FILEIO* state_fio);
97         
98         // unique function
99         void set_context_disp(DEVICE* device, int id, uint32_t mask)
100         {
101                 register_output_signal(&outputs_disp, device, id, mask);
102         }
103         void set_context_vblank(DEVICE* device, int id, uint32_t mask)
104         {
105                 register_output_signal(&outputs_vblank, device, id, mask);
106         }
107         void set_context_vsync(DEVICE* device, int id, uint32_t mask)
108         {
109                 register_output_signal(&outputs_vsync, device, id, mask);
110         }
111         void set_context_hsync(DEVICE* device, int id, uint32_t mask)
112         {
113                 register_output_signal(&outputs_hsync, device, id, mask);
114         }
115 //#if defined(HD46505_CHAR_CLOCK)
116         void set_char_clock(double clock)
117         {
118                 next_char_clock = clock;
119         }
120 //#elif defined(HD46505_HORIZ_FREQ)
121         void set_horiz_freq(double freq)
122         {
123                 next_horiz_freq = freq;
124         }
125 //#endif
126         uint8_t* get_regs()
127         {
128                 return regs;
129         }
130 };
131
132 #endif
133