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 / fp1100 / main.h
1 /*
2         CASIO FP-1100 Emulator 'eFP-1100'
3
4         Author : Takeda.Toshiya
5         Date   : 2010.06.17-
6
7         [ main pcb ]
8 */
9
10 #ifndef _MAIN_H_
11 #define _MAIN_H_
12
13 #include "../vm.h"
14 #include "../../emu.h"
15 #include "../device.h"
16
17 #define SIG_MAIN_INTS   0
18 #define SIG_MAIN_INTA   1
19 #define SIG_MAIN_INTB   2
20 #define SIG_MAIN_INTC   3
21 #define SIG_MAIN_INTD   4
22 #define SIG_MAIN_COMM   5
23
24 class MAIN : public DEVICE
25 {
26 private:
27         // to main cpu
28         DEVICE *d_cpu;
29         // to sub pcb
30         DEVICE *d_sub;
31         // to slots
32         DEVICE *d_slot[2][4];
33         
34         uint8 *wbank[16];
35         uint8 *rbank[16];
36         int wait[16];
37         uint8 wdmy[0x1000];
38         uint8 rdmy[0x1000];
39         uint8 ram[0x10000];
40         uint8 rom[0x9000];
41         
42         uint8 comm_data;
43         bool rom_sel;
44         uint8 slot_sel;
45         uint8 slot_exp[2];
46         
47         uint8 intr_mask;
48         uint8 intr_request;
49         uint8 intr_in_service;
50         
51         void update_memory_map();
52         void update_intr();
53         
54 public:
55         MAIN(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
56         {
57                 intr_mask = intr_request = intr_in_service = 0;
58         }
59         ~MAIN() {}
60         
61         // common functions
62         void initialize();
63         void reset();
64         void write_data8(uint32 addr, uint32 data);
65         uint32 read_data8(uint32 addr);
66 #ifdef Z80_MEMORY_WAIT
67         void write_data8w(uint32 addr, uint32 data, int *wait);
68         uint32 read_data8w(uint32 addr, int *wait);
69 #endif
70         void write_io8(uint32 addr, uint32 data);
71         uint32 read_io8(uint32 addr);
72 #ifdef Z80_IO_WAIT
73         void write_io8w(uint32 addr, uint32 data, int *wait);
74         uint32 read_io8w(uint32 addr, int *wait);
75 #endif
76         void write_signal(int id, uint32 data, uint32 mask);
77         uint32 get_intr_ack();
78         void notify_intr_reti();
79         void notify_intr_ei();
80         void save_state(FILEIO* state_fio);
81         bool load_state(FILEIO* state_fio);
82         
83         // unique functions
84         void set_context_cpu(DEVICE *device)
85         {
86                 d_cpu = device;
87         }
88         void set_context_sub(DEVICE *device)
89         {
90                 d_sub = device;
91         }
92         void set_context_slot(int slot, DEVICE *device)
93         {
94                 slot &= 7;
95                 d_slot[slot >> 2][slot & 3] = device;
96         }
97 };
98
99 #endif