OSDN Git Service

[VM][FMTOWNS][MEMORY] Fix setup around memory banks by I/O 0404h and 0480h.
[csp-qt/common_source_project-fm7.git] / source / src / vm / fm16beta / main.h
1 /*
2         FUJITSU FM16beta Emulator 'eFM16beta'
3
4         Author : Takeda.Toshiya
5         Date   : 2017.12.28-
6
7         [ main system ]
8 */
9
10 #ifndef _EFM16BETA_MAIN_H_
11 #define _EFM16BETA_MAIN_H_
12
13 #include "../vm.h"
14 #include "../memory.h"
15
16 #define SIG_MAIN_IRQ0_TX        0       // RS-232C
17 #define SIG_MAIN_IRQ0_RX        1       // RS-232C
18 #define SIG_MAIN_IRQ0_SYN       2       // RS-232C
19 #define SIG_MAIN_IRQ1           3       // Keyboard
20 #define SIG_MAIN_IRQ2           4       // Expantion
21 #define SIG_MAIN_IRQ3           5       // DMA Controller
22 #define SIG_MAIN_IRQ4           6       // 320KB Floppy Disk
23 #define SIG_MAIN_IRQ5           7       // 1MB Floppy Disk
24 #define SIG_MAIN_IRQ6           8       // Hard Disk
25 #define SIG_MAIN_IRQ7           9       // Printer
26 #define SIG_MAIN_IRQ8           10      // PTM
27 #define SIG_MAIN_IRQ9           11      // User
28 #define SIG_MAIN_FIRQ0          12      // Sub system attention
29 #define SIG_MAIN_FIRQ1          13      // Break
30 #define SIG_MAIN_FIRQ2          14      // Expantion
31 #define SIG_MAIN_FIRQ3          15      // User
32
33 #define SIG_MAIN_SUB_BUSY       16
34
35 #define SIG_MAIN_DRQ_2HD        17
36 #define SIG_MAIN_DRQ_2D         18
37
38 #define SIG_MAIN_RTC_DATA       19
39 #define SIG_MAIN_RTC_BUSY       20
40
41 #ifdef HAS_I286
42 class I286;
43 #else
44 class I8086;
45 #endif
46 class I8237;
47 class MB8877;
48
49 namespace FM16BETA {
50
51 class MAINBUS : public MEMORY
52 {
53 private:
54         //csp_state_utils *state_entry;
55
56 #ifdef HAS_I286
57         I286 *d_cpu;
58         uint8_t rst;
59 #endif
60         I8237 *d_dma;
61         DEVICE *d_pic;
62         DEVICE *d_pcm;
63         DEVICE *d_keyboard;
64
65         // memory
66         uint8_t ram[0xfc000];
67         uint8_t rom[0x04000];
68         uint8_t direct;
69         
70         // main-sub
71         DEVICE *d_sub;
72         bool sub_busy;
73         
74         // 1mb fdd
75         MB8877 *d_fdc_2hd;
76         uint8_t sidereg_2hd, drvreg_2hd;
77         bool drq_2hd;
78         
79         // 320kb fdd
80         MB8877 *d_fdc_2d;
81         uint8_t sidereg_2d, drvreg_2d;
82         bool drq_2d;
83         
84         // rtc
85         DEVICE *d_rtc;
86         uint8_t rtc_data;
87         
88         // irq
89         uint8_t irq_enb, ext_irq_enb;
90         bool irq0_tx, irq0_rx, irq0_syn, irq1, irq2, irq3, irq4, irq5, irq6, irq7, irq8, irq9;
91         bool firq0, firq1, firq2, firq3;
92         bool int0, int1, int2, int3, int4, int5, int6, int7;
93         
94         void update_int0();
95         void update_int1();
96         void update_int2();
97         void update_int3();
98         void update_int4();
99         void update_int5();
100         void update_int6();
101         void update_int7();
102         
103 public:
104         MAINBUS(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : MEMORY(parent_vm, parent_emu)
105         {
106                 set_device_name(_T("Main System"));
107         }
108         ~MAINBUS() {}
109         
110         // common functions
111         void initialize();
112         void release();
113         void reset();
114         void __FASTCALL write_io8(uint32_t addr, uint32_t data);
115         uint32_t __FASTCALL read_io8(uint32_t addr);
116         void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask);
117         bool process_state(FILEIO* state_fio, bool loading);
118         
119         // unique functions
120 #ifdef HAS_I286
121         void set_context_cpu(I286* device)
122         {
123                 d_cpu = device;
124         }
125 #endif
126         void set_context_dma(I8237* device)
127         {
128                 d_dma = device;
129         }
130         void set_context_fdc_2hd(MB8877* device)
131         {
132                 d_fdc_2hd = device;
133         }
134         void set_context_fdc_2d(MB8877* device)
135         {
136                 d_fdc_2d = device;
137         }
138         void set_context_pic(DEVICE* device)
139         {
140                 d_pic = device;
141         }
142         void set_context_pcm(DEVICE* device)
143         {
144                 d_pcm = device;
145         }
146         void set_context_rtc(DEVICE* device)
147         {
148                 d_rtc = device;
149         }
150         void set_context_sub(DEVICE* device)
151         {
152                 d_sub = device;
153         }
154         void set_context_keyboard(DEVICE* device)
155         {
156                 d_keyboard = device;
157         }
158 };
159
160 }
161 #endif /* _EFM16BETA_MAIN_H_ */