OSDN Git Service

c2c0078242f0ff56ca6b90496c347ceafdb79b88
[csp-qt/common_source_project-fm7.git] / source / src / vm / mc6847.h
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2010.08.03-
6
7         [ mc6847 ]
8 */
9
10 #ifndef _MC6847_H_
11 #define _MC6847_H_
12
13 //#include "vm.h"
14 //#include "../emu.h"
15 #include "device.h"
16
17 #define SIG_MC6847_AG           0
18 #define SIG_MC6847_AS           1
19 #define SIG_MC6847_INTEXT       2
20 #define SIG_MC6847_GM           3
21 #define SIG_MC6847_CSS          4
22 #define SIG_MC6847_INV          5
23 #define SIG_MC6847_ENABLE       6
24 #define SIG_MC6847_DISABLE      7
25
26 class MC6847_BASE : public DEVICE
27 {
28 protected:
29         DEVICE *d_cpu;
30         
31         // output signals
32         outputs_t outputs_vsync;
33         outputs_t outputs_hsync;
34         
35         uint8_t extfont[256 * 16];
36         uint8_t sg4[16 * 12];
37         uint8_t sg6[64 * 12];
38         uint8_t screen[192][256];
39         uint8_t *vram_ptr;
40         int vram_size;
41         scrntype_t palette_pc[16];
42         
43         bool ag, as;
44         bool intext;
45         uint8_t gm;
46         bool css, inv;
47         
48         bool vsync, hsync, disp;
49         int tWHS;
50         bool disabled;
51         
52         void set_vsync(bool val);
53         void set_hsync(bool val);
54         void set_disp(bool val);
55         void draw_cg(int xofs, int yofs);
56         void draw_rg(int xofs, int yofs);
57         virtual void draw_alpha();
58         
59 public:
60         MC6847_BASE(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
61         {
62                 d_cpu = NULL;
63                 ag = as = intext = css = inv = false;
64                 gm = 0;
65                 initialize_output_signals(&outputs_vsync);
66                 initialize_output_signals(&outputs_hsync);
67                 set_device_name(_T("MC6847 VIDEO DISPLAY CONTOROLLER"));
68         }
69         ~MC6847_BASE() {}
70         
71         // common functions
72         virtual void initialize();
73         void reset();
74         void write_signal(int id, uint32_t data, uint32_t mask);
75         void event_vline(int v, int clock);
76         void event_callback(int event_id, int err);
77         void update_timing(int new_clocks, double new_frames_per_sec, int new_lines_per_frame);
78         void decl_state();
79         void save_state(FILEIO* state_fio);
80         bool load_state(FILEIO* state_fio);
81         // unique functions
82         void set_context_cpu(DEVICE* device)
83         {
84                 d_cpu = device;
85         }
86         void set_context_vsync(DEVICE* device, int id, uint32_t mask)
87         {
88                 register_output_signal(&outputs_vsync, device, id, mask);
89         }
90         void set_context_hsync(DEVICE* device, int id, uint32_t mask)
91         {
92                 register_output_signal(&outputs_hsync, device, id, mask);
93         }
94         void set_vram_ptr(uint8_t* ptr, int size)
95         {
96                 vram_ptr = ptr; vram_size = size;
97         }
98         void load_font_image(const _TCHAR *file_path);
99         void draw_screen();
100 };
101
102 class MC6847 : public MC6847_BASE
103 {
104 protected:
105         void draw_alpha();
106 public:
107         MC6847(VM* parent_vm, EMU* parent_emu) : MC6847_BASE(parent_vm, parent_emu)
108         {
109         }
110         ~MC6847() {};
111
112         void initialize();
113 };
114
115 #endif
116