OSDN Git Service

f7e18438a7a5b8e206658710d6a2731b63ab24ed
[csp-qt/common_source_project-fm7.git] / source / src / vm / upd71071.h
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2007.08.14 -
6
7         [ uPD71071 ]
8 */
9
10 #ifndef _UPD71071_H_
11 #define _UPD71071_H_
12
13 #include "vm.h"
14 #include "../emu.h"
15 #include "device.h"
16
17 #define SIG_UPD71071_CH0        0
18 #define SIG_UPD71071_CH1        1
19 #define SIG_UPD71071_CH2        2
20 #define SIG_UPD71071_CH3        3
21
22 class UPD71071 : public DEVICE
23 {
24 private:
25         DEVICE* d_mem;
26 #ifdef SINGLE_MODE_DMA
27         DEVICE* d_dma;
28 #endif
29         outputs_t outputs_tc;
30         
31         struct {
32                 DEVICE* dev;
33                 uint32 areg, bareg;
34                 uint16 creg, bcreg;
35                 uint8 mode;
36         } dma[4];
37         
38         uint8 b16, selch, base;
39         uint16 cmd, tmp;
40         uint8 req, sreq, mask, tc;
41         
42 public:
43         UPD71071(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
44         {
45                 for(int i = 0; i < 4; i++) {
46                         dma[i].dev = vm->dummy;
47                 }
48 #ifdef SINGLE_MODE_DMA
49                 d_dma = NULL;
50 #endif
51                 init_output_signals(&outputs_tc);
52         }
53         ~UPD71071() {}
54         
55         // common functions
56         void reset();
57         void write_io8(uint32 addr, uint32 data);
58         uint32 read_io8(uint32 addr);
59         void write_signal(int id, uint32 data, uint32 mask);
60         void do_dma();
61         void save_state(FILEIO* state_fio);
62         bool load_state(FILEIO* state_fio);
63         
64         // unique functions
65         void set_context_memory(DEVICE* device)
66         {
67                 d_mem = device;
68         }
69         void set_context_ch0(DEVICE* device)
70         {
71                 dma[0].dev = device;
72         }
73         void set_context_ch1(DEVICE* device)
74         {
75                 dma[1].dev = device;
76         }
77         void set_context_ch2(DEVICE* device)
78         {
79                 dma[2].dev = device;
80         }
81         void set_context_ch3(DEVICE* device)
82         {
83                 dma[3].dev = device;
84         }
85 #ifdef SINGLE_MODE_DMA
86         void set_context_child_dma(DEVICE* device)
87         {
88                 d_dma = device;
89         }
90 #endif
91         void set_context_tc(DEVICE* device, int id, uint32 mask)
92         {
93                 register_output_signal(&outputs_tc, device, id, mask);
94         }
95 };
96
97 #endif
98