OSDN Git Service

[VM][General] Merge upstream 2016-03-01. (Pahse 1).
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz80k / memory.h
1 /*
2         SHARP MZ-80K/C Emulator 'EmuZ-80K'
3         SHARP MZ-1200 Emulator 'EmuZ-1200'
4
5         Author : Takeda.Toshiya
6         Date   : 2010.08.18-
7
8         SHARP MZ-80A Emulator 'EmuZ-80A'
9         Modify : Hideki Suga
10         Date   : 2014.12.10 -
11
12         [ memory ]
13 */
14
15 #ifndef _MEMORY_H_
16 #define _MEMORY_H_
17
18 #include "../vm.h"
19 #include "../../emu.h"
20 #include "../device.h"
21
22 #define SIG_MEMORY_VGATE        0
23 #if defined(SUPPORT_MZ80AIF)
24 #define SIG_MEMORY_FDC_IRQ      1
25 #define SIG_MEMORY_FDC_DRQ      2
26 #endif
27
28 class MEMORY : public DEVICE
29 {
30 private:
31         DEVICE *d_ctc, *d_pio;
32         
33         uint8_t* rbank[64];
34         uint8_t* wbank[64];
35         uint8_t wdmy[0x400];
36         uint8_t rdmy[0x400];
37         
38         uint8_t ram[0xd000];    // RAM 48KB + swap 4KB
39 #if defined(_MZ1200) || defined(_MZ80A)
40         uint8_t vram[0x800];    // VRAM 2KB
41 #else
42         uint8_t vram[0x400];    // VRAM 1KB
43 #endif
44         uint8_t ipl[0x1000];    // IPL 4KB
45 #if defined(_MZ1200) || defined(_MZ80A)
46         uint8_t ext[0x800];     // EXT 2KB
47 #endif
48         
49         bool tempo, blink;
50 #if defined(_MZ1200) || defined(_MZ80A)
51         bool hblank;
52         bool memory_swap;
53         void update_memory_swap();
54 #endif
55         
56 #if defined(SUPPORT_MZ80AIF)
57         uint8_t fdif[0x800];    // FD IF ROM 2KB
58         bool fdc_irq, fdc_drq;
59         void update_fdif_rom_bank();
60 #elif defined(SUPPORT_MZ80FIO)
61         uint8_t fdif[0x400];    // FD IF ROM 1KB
62 #endif
63         
64         uint8_t screen[200][320];
65         uint8_t font[0x800];
66 #if defined(_MZ1200)
67         uint8_t pcg[0x1000];    // PCG-1200
68 #else
69         uint8_t pcg[0x800];     // PCG-8000
70 #endif
71         scrntype_t palette_pc[2];
72         bool vgate;
73 #if defined(_MZ1200) || defined(_MZ80A)
74         bool reverse;
75 #endif
76 #if defined(_MZ80A)
77         uint32_t e200;          // scroll
78 #endif
79         uint8_t pcg_data;
80         uint8_t pcg_addr;
81         uint8_t pcg_ctrl;
82         
83 public:
84         MEMORY(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) {}
85         ~MEMORY() {}
86         
87         // common functions
88         void initialize();
89         void reset();
90         void event_vline(int v, int clock);
91         void event_callback(int event_id, int err);
92         void write_data8(uint32_t addr, uint32_t data);
93         uint32_t read_data8(uint32_t addr);
94         void write_signal(int id, uint32_t data, uint32_t mask);
95 #if defined(_MZ80K)
96         void update_config();
97 #endif
98         void save_state(FILEIO* state_fio);
99         bool load_state(FILEIO* state_fio);
100         
101         // unique functions
102         void set_context_ctc(DEVICE* device)
103         {
104                 d_ctc = device;
105         }
106         void set_context_pio(DEVICE* device)
107         {
108                 d_pio = device;
109         }
110         void draw_screen();
111 };
112
113 #endif
114