OSDN Git Service

[VM][STATE] Use namespace {VMNAME} to separate per VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc6001 / timer.h
1 /*
2         NEC PC-6001 Emulator 'yaPC-6001'
3         NEC PC-6001mkII Emulator 'yaPC-6201'
4         NEC PC-6001mkIISR Emulator 'yaPC-6401'
5         NEC PC-6601 Emulator 'yaPC-6601'
6         NEC PC-6601SR Emulator 'yaPC-6801'
7
8         Author : Takeda.Toshiya
9         Date   : 2014.05.22-
10
11         [ timer ]
12 */
13
14 #ifndef _TIMER_H_
15 #define _TIMER_H_
16
17 #include "../vm.h"
18 #include "../../emu.h"
19 #include "../device.h"
20
21 #define SIG_TIMER_IRQ_SUB_CPU   0
22 #define SIG_TIMER_IRQ_JOYSTICK  1
23 #define SIG_TIMER_IRQ_TIMER     2
24 #define SIG_TIMER_IRQ_VOICE     3
25 #define SIG_TIMER_IRQ_VRTC      4
26 #define SIG_TIMER_IRQ_RS_232C   5
27 #define SIG_TIMER_IRQ_PRINTER   6
28 #define SIG_TIMER_IRQ_EXT_INT   7
29
30 #ifndef _PC6001
31 namespace PC6001 {
32         class MEMORY;
33 }
34 #endif
35
36 namespace PC6001 {
37 class TIMER : public DEVICE
38 {
39 private:
40         DEVICE *d_cpu, *d_sub;
41 #ifndef _PC6001
42         PC6001::MEMORY *d_mem;
43 #endif
44         
45         uint8_t IRQ, NewIRQ;
46         int timer_id;
47         
48 #ifndef _PC6001
49 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
50         uint8_t sr_vectors[8];
51         uint8_t portFA;
52         uint8_t portFB;
53 #endif
54         uint8_t portF3;
55         uint8_t portF4;
56         uint8_t portF5;
57         uint8_t portF6;
58         uint8_t portF7;
59 #endif
60         void update_intr();
61         
62 public:
63         TIMER(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) {}
64         ~TIMER() {}
65         
66         // common functions
67         void initialize();
68         void reset();
69 #ifndef _PC6001
70         void write_io8(uint32_t addr, uint32_t data);
71         uint32_t read_io8(uint32_t addr);
72 #endif
73         void event_callback(int event_id, int err);
74         void write_signal(int id, uint32_t data, uint32_t mask);
75         uint32_t get_intr_ack();
76         void notify_intr_reti();
77         bool process_state(FILEIO* state_fio, bool loading);
78         
79         // unique functions
80         void set_context_cpu(DEVICE* device)
81         {
82                 d_cpu = device;
83         }
84         void set_context_sub(DEVICE* device)
85         {
86                 d_sub = device;
87         }
88 #ifndef _PC6001
89         void set_context_memory(PC6001::MEMORY* device)
90         {
91                 d_mem = device;
92         }
93 #endif
94         void set_portB0(uint32_t data);
95 };
96 }
97 #endif