OSDN Git Service

[General] Convert sourcecode's CRLF format: DOS(WINDOWS) to Unix, to apply patches...
[csp-qt/common_source_project-fm7.git] / source / src / vm / hc20 / memory.h
1 /*
2         EPSON HC-20 Emulator 'eHC-20'
3
4         Author : Takeda.Toshiya
5         Date   : 2011.05.23-
6
7         [ memory ]
8 */
9
10 #ifndef _MEMORY_H_
11 #define _MEMORY_H_
12
13 #include "../vm.h"
14 #include "../../emu.h"
15 #include "../device.h"
16
17 #define SIG_MEMORY_PORT_2       0
18 #define SIG_MEMORY_PORT_3       1
19 #define SIG_MEMORY_PORT_4       2
20 #define SIG_MEMORY_SIO_MAIN     3
21 #define SIG_MEMORY_SIO_TF20     4
22 #define SIG_MEMORY_RTC_IRQ      5
23
24 #define CMT_BUFFER_SIZE         0x10000
25
26 class BEEP;
27 class FIFO;
28
29 class MEMORY : public DEVICE
30 {
31 private:
32         BEEP *d_beep;
33         DEVICE *d_cpu, *d_rtc, *d_tf20;
34         
35         uint8 wdmy[0x2000];
36         uint8 rdmy[0x2000];
37         uint8* wbank[8];
38         uint8* rbank[8];
39         
40         // memory with expansion unit
41         uint8 ram[0x8000];      // 0000h-7fffh
42         uint8 rom[0x8000];      // 8000h-ffffh (internal)
43         uint8 ext[0x4000];      // 8000h-bfffh
44         
45         FIFO *cmd_buf;
46         bool sio_select;
47         bool special_cmd_masked;
48         uint8 slave_mem[0x10000];
49         
50         typedef struct {
51                 double freq;
52                 int period;
53                 int remain;
54         } sound_t;
55         sound_t sound[256];
56         int sound_ptr;
57         int sound_count;
58         uint8 sound_reply;
59         double sound_freq;
60         double tone_table[57];
61         
62         uint8 key_stat[256], key_flag[256];
63         int key_data, key_strobe, key_intmask;
64         
65         uint8 cmt_buffer[CMT_BUFFER_SIZE];
66         int cmt_count;
67         bool cmt_play, cmt_rec;
68         FILEIO* cmt_fio;
69         
70         typedef struct {
71                 uint8 buffer[80];
72                 int bank;
73                 int addr;
74         } lcd_t;
75         lcd_t lcd[6];
76         
77         scrntype lcd_render[32][120];
78         scrntype pd, pb;
79         uint8 lcd_select, lcd_data;
80         int lcd_clock;
81         
82         int int_status;
83         int int_mask;
84         
85         void update_sound();
86         void update_keyboard();
87         void update_intr();
88         void send_to_slave(uint8 val);
89         void send_to_main(uint8 val);
90         
91 public:
92         MEMORY(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) {}
93         ~MEMORY() {}
94         
95         // common functions
96         void initialize();
97         void release();
98         void reset();
99         void write_data8(uint32 addr, uint32 data);
100         uint32 read_data8(uint32 addr);
101         void write_signal(int id, uint32 data, uint32 mask);
102         void event_callback(int event_id, int err);
103         
104         // unitque function
105         void set_context_beep(BEEP* device)
106         {
107                 d_beep = device;
108         }
109         void set_context_cpu(DEVICE* device)
110         {
111                 d_cpu = device;
112         }
113         void set_context_rtc(DEVICE* device)
114         {
115                 d_rtc = device;
116         }
117         void set_context_tf20(DEVICE* device)
118         {
119                 d_tf20 = device;
120         }
121         void notify_power_off();
122         void key_down(int code);
123         void key_up(int code);
124         void play_tape(_TCHAR* file_path);
125         void rec_tape(_TCHAR* file_path);
126         void close_tape();
127         bool tape_inserted()
128         {
129                 return (cmt_play || cmt_rec);
130         }
131         void draw_screen();
132 };
133
134 #endif
135