OSDN Git Service

[VM][WIP] Use namespace to devices per VMs.
[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 _MZ80A_MEMORY_H_
16 #define _MZ80A_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 namespace MZ80 {
29
30 class MEMORY : public DEVICE
31 {
32 private:
33         DEVICE *d_ctc, *d_pio;
34         
35         uint8_t* rbank[64];
36         uint8_t* wbank[64];
37         uint8_t wdmy[0x400];
38         uint8_t rdmy[0x400];
39         
40         uint8_t ram[0xd000];    // RAM 48KB + swap 4KB
41 #if defined(_MZ1200) || defined(_MZ80A)
42         uint8_t vram[0x800];    // VRAM 2KB
43 #else
44         uint8_t vram[0x400];    // VRAM 1KB
45 #endif
46         uint8_t ipl[0x1000];    // IPL 4KB
47 #if defined(_MZ1200) || defined(_MZ80A)
48         uint8_t ext[0x800];     // EXT 2KB
49 #endif
50         
51         bool tempo, blink;
52 #if defined(_MZ1200) || defined(_MZ80A)
53         bool hblank;
54         bool memory_swap;
55         void update_memory_swap();
56 #endif
57         
58 #if defined(SUPPORT_MZ80AIF)
59         uint8_t fdif[0x800];    // FD IF ROM 2KB
60         bool fdc_irq, fdc_drq;
61         void update_fdif_rom_bank();
62 #elif defined(SUPPORT_MZ80FIO)
63         uint8_t fdif[0x400];    // FD IF ROM 1KB
64 #endif
65         
66         uint8_t screen[200][320];
67         uint8_t font[0x800];
68 #if defined(_MZ1200)
69         uint8_t pcg[0x1000];    // PCG-1200
70 #else
71         uint8_t pcg[0x800];     // PCG-8000
72 #endif
73         scrntype_t palette_pc[2];
74         bool vgate;
75 #if defined(_MZ1200) || defined(_MZ80A)
76         bool reverse;
77 #endif
78 #if defined(_MZ80A)
79         uint32_t e200;          // scroll
80 #endif
81         uint8_t pcg_data;
82         uint8_t pcg_addr;
83         uint8_t pcg_ctrl;
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"));
89         }
90         ~MEMORY() {}
91         
92         // common functions
93         void initialize();
94         void reset();
95         void event_vline(int v, int clock);
96         void event_callback(int event_id, int err);
97         void write_data8(uint32_t addr, uint32_t data);
98         uint32_t read_data8(uint32_t addr);
99         void write_signal(int id, uint32_t data, uint32_t mask);
100 #if defined(_MZ80K)
101         void update_config();
102 #endif
103         bool process_state(FILEIO* state_fio, bool loading);
104         
105         // unique functions
106         void set_context_ctc(DEVICE* device)
107         {
108                 d_ctc = device;
109         }
110         void set_context_pio(DEVICE* device)
111         {
112                 d_pio = device;
113         }
114         void draw_screen();
115 };
116
117 }
118 #endif
119