OSDN Git Service

[VM][WIP] Use namespace to devices per VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz2500 / memory80b.h
1 /*
2         SHARP MZ-80B Emulator 'EmuZ-80B'
3         SHARP MZ-2200 Emulator 'EmuZ-2200'
4
5         Author : Takeda.Toshiya
6         Date   : 2013.03.14-
7
8         I-O DATA PIO-3039 Emulator
9
10         Author : Mr.Suga
11         Data   : 2017.02.22-
12
13         [ memory/crtc ]
14 */
15
16 #ifndef _MEMORY_80B_H_
17 #define _MEMORY_80B_H_
18
19 #include "../vm.h"
20 #include "../../emu.h"
21 #include "../device.h"
22
23 #define SIG_MEMORY_VRAM_SEL     0
24 #define SIG_CRTC_WIDTH80        1
25 #define SIG_CRTC_REVERSE        2
26 #define SIG_CRTC_VGATE          3
27
28 class Z80;
29
30 namespace MZ80B {
31
32 class MEMORY : public DEVICE
33 {
34 private:
35         Z80 *d_cpu;
36         DEVICE *d_pio;
37         
38         // memory
39         uint8_t* rbank[32];
40         uint8_t* wbank[32];
41         bool is_vram[32];
42         uint8_t wdmy[0x800];
43         uint8_t rdmy[0x800];
44         uint8_t ram[0x10000];
45 #ifndef _MZ80B
46         uint8_t vram[0x10000];  // 0x4000 * (3 pages + dummy)
47 #else
48         uint8_t vram[0xc000];   // 0x4000 * (2 pages + dummy)
49 #endif
50         uint8_t tvram[0x1000];
51         uint8_t ipl[0x800];
52         
53         bool ipl_selected;
54         uint8_t vram_sel, vram_page;
55         void update_vram_map();
56         
57         // crtc
58 #ifndef _MZ80B
59         scrntype_t palette_color[8];
60 #endif
61         scrntype_t palette_green[2];
62         uint8_t font[0x800];
63         uint8_t screen_txt[200][640];
64         uint8_t screen_gra[200][640];
65         
66         uint8_t back_color, text_color, vram_mask;
67         bool width80, reverse;
68         bool vgate;
69         bool hblank;
70         
71 #ifdef _MZ80B
72         // PIO-3039
73         scrntype_t pio3039_color[8];
74         uint8_t pio3039_palette[8];
75         uint8_t screen_80b_green[200][640];
76         uint8_t screen_80b_vram1[200][640];
77         uint8_t screen_80b_vram2[200][640];
78         
79         bool pio3039_txt_sw;
80         uint8_t pio3039_data;
81 #else
82         void update_green_palette();
83 #endif
84         
85 public:
86         MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
87         {
88                 set_device_name(_T("Memory Bus(MZ80B/2000/2200)"));
89         }
90         ~MEMORY() {}
91         
92         // common functions
93         void initialize();
94         void reset();
95         void special_reset();
96         void write_data8(uint32_t addr, uint32_t data);
97         uint32_t read_data8(uint32_t addr);
98         uint32_t fetch_op(uint32_t addr, int *wait);
99         void write_io8(uint32_t addr, uint32_t data);
100         void write_signal(int id, uint32_t data, uint32_t mask);
101         void event_vline(int v, int clock);
102         void event_callback(int event_id, int err);
103         bool process_state(FILEIO* state_fio, bool loading);
104         
105         // unique function
106         void set_context_cpu(Z80* device)
107         {
108                 d_cpu = device;
109         }
110         void set_context_pio(DEVICE* device)
111         {
112                 d_pio = device;
113         }
114         void load_dat_image(const _TCHAR* file_path);
115         bool load_mzt_image(const _TCHAR* file_path);
116         void draw_screen();
117 };
118
119 }
120 #endif