OSDN Git Service

f050867a3f094cfaacc32ea38afcf6b7bda49aaf
[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 class PC6001_MEMORY;
32 #endif
33
34 class TIMER : public DEVICE
35 {
36 private:
37         DEVICE *d_cpu, *d_sub;
38 #ifndef _PC6001
39         PC6001_MEMORY *d_mem;
40 #endif
41         
42         uint8_t IRQ, NewIRQ;
43         int timer_id;
44         
45 #ifndef _PC6001
46 #if defined(_PC6601SR) || defined(_PC6001MK2SR)
47         uint8_t sr_vectors[8];
48         uint8_t portFA;
49         uint8_t portFB;
50 #endif
51         uint8_t portF3;
52         uint8_t portF4;
53         uint8_t portF5;
54         uint8_t portF6;
55         uint8_t portF7;
56 #endif
57         void update_intr();
58         
59 public:
60         TIMER(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) {}
61         ~TIMER() {}
62         
63         // common functions
64         void initialize();
65         void reset();
66 #ifndef _PC6001
67         void write_io8(uint32_t addr, uint32_t data);
68         uint32_t read_io8(uint32_t addr);
69 #endif
70         void event_callback(int event_id, int err);
71         void write_signal(int id, uint32_t data, uint32_t mask);
72         uint32_t get_intr_ack();
73         void notify_intr_reti();
74         bool process_state(FILEIO* state_fio, bool loading);
75         
76         // unique functions
77         void set_context_cpu(DEVICE* device)
78         {
79                 d_cpu = device;
80         }
81         void set_context_sub(DEVICE* device)
82         {
83                 d_sub = device;
84         }
85 #ifndef _PC6001
86         void set_context_memory(PC6001_MEMORY* device)
87         {
88                 d_mem = device;
89         }
90 #endif
91         void set_portB0(uint32_t data);
92 };
93 #endif