OSDN Git Service

[VM][General][WIP] Apply new (Upstream 2016-02-21) APIs to 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         [ memory/crtc ]
9 */
10
11 #ifndef _MEMORY_80B_H_
12 #define _MEMORY_80B_H_
13
14 #include "../vm.h"
15 #include "../../emu.h"
16 #include "../device.h"
17
18 #define SIG_MEMORY_VRAM_SEL     0
19 #define SIG_CRTC_WIDTH80        1
20 #define SIG_CRTC_REVERSE        2
21
22 class Z80;
23
24 class MEMORY : public DEVICE
25 {
26 private:
27         Z80 *d_cpu;
28         DEVICE *d_pio;
29         
30         // memory
31         uint8* rbank[32];
32         uint8* wbank[32];
33         bool is_vram[32];
34         uint8 wdmy[0x800];
35         uint8 rdmy[0x800];
36         uint8 ram[0x10000];
37 #ifndef _MZ80B
38         uint8 vram[0x10000];    // 0x4000 * (3 pages + dummy)
39 #else
40         uint8 vram[0xc000];     // 0x4000 * (2 pages + dummy)
41 #endif
42         uint8 tvram[0x1000];
43         uint8 ipl[0x800];
44         
45         bool ipl_selected;
46         uint8 vram_sel, vram_page;
47         void update_vram_map();
48         
49         // crtc
50 #ifndef _MZ80B
51         scrntype palette_color[8];
52 #endif
53         scrntype palette_green[2];
54         uint8 font[0x800];
55         uint8 screen_txt[200][640];
56         uint8 screen_gra[200][640];
57         uint8 back_color, text_color, vram_mask;
58         bool width80, reverse;
59         bool hblank;
60         void update_green_palette();
61         
62 public:
63         MEMORY(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) {}
64         ~MEMORY() {}
65         
66         // common functions
67         void initialize();
68         void reset();
69         void special_reset();
70         void write_data8(uint32 addr, uint32 data);
71         uint32 read_data8(uint32 addr);
72         uint32 fetch_op(uint32 addr, int *wait);
73         void write_io8(uint32 addr, uint32 data);
74         void write_signal(int id, uint32 data, uint32 mask);
75         void event_vline(int v, int clock);
76         void event_callback(int event_id, int err);
77         void save_state(FILEIO* state_fio);
78         bool load_state(FILEIO* state_fio);
79         
80         // unique function
81         void set_context_cpu(Z80* device)
82         {
83                 d_cpu = device;
84         }
85         void set_context_pio(DEVICE* device)
86         {
87                 d_pio = device;
88         }
89         void load_dat_image(const _TCHAR* file_path);
90         bool load_mzt_image(const _TCHAR* file_path);
91         void draw_screen();
92 };
93
94 #endif