OSDN Git Service

[VM][WIP] Use namespace to devices per VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / j3100 / j3100.h
1 /*
2         TOSHIBA J-3100GT Emulator 'eJ-3100GT'
3         TOSHIBA J-3100SL Emulator 'eJ-3100SL'
4
5         Author : Takeda.Toshiya
6         Date   : 2011.08.16-
7
8         [ virtual machine ]
9 */
10
11 #ifndef _J3100_H_
12 #define _J3100_H_
13
14 #if defined(_J3100GT)
15 #define DEVICE_NAME             "TOSHIBA J-3100GT"
16 #define CONFIG_NAME             "j3100gt"
17 #elif defined(_J3100SL)
18 #define DEVICE_NAME             "TOSHIBA J-3100SL"
19 #define CONFIG_NAME             "j3100sl"
20 #endif
21
22 // device informations for virtual machine
23
24 #if defined(_J3100SL) || defined(_J3100SS) || defined(_J3100SE)
25 #define TYPE_SL
26 #endif
27
28 // TODO: check refresh rate
29 #define FRAMES_PER_SEC          59.9
30 // \97v\92²\8d¸
31 #define LINES_PER_FRAME         440
32 #define CHARS_PER_LINE          54
33 #define CPU_CLOCKS              9545456
34 #define SCREEN_WIDTH            640
35 #define SCREEN_HEIGHT           400
36 #define MAX_DRIVE               2
37 #define UPD765A_SENCE_INTSTAT_RESULT
38 #define UPD765A_EXT_DRVSEL
39 #ifdef TYPE_SL
40 #define HAS_I86
41 #define I8259_MAX_CHIPS         1
42 #else
43 #define HAS_I286
44 #define I8259_MAX_CHIPS         2
45 #endif
46 #if !(defined(_J3100SS) || defined(_J3100SE))
47 #define HAS_I8254
48 #endif
49 #define SINGLE_MODE_DMA
50 #define IO_ADDR_MAX             0x10000
51
52 // device informations for win32
53 #define USE_FLOPPY_DISK         2
54 #define NOTIFY_KEY_DOWN
55 #define USE_ALT_F10_KEY
56 #define USE_AUTO_KEY            5
57 #define USE_AUTO_KEY_RELEASE    6
58 #define USE_AUTO_KEY_NUMPAD
59 #define USE_SOUND_VOLUME        2
60 #define USE_CPU_I286
61
62 #include "../../common.h"
63 #include "../../fileio.h"
64 #include "../vm_template.h"
65
66 #ifdef USE_SOUND_VOLUME
67 static const _TCHAR *sound_device_caption[] = {
68         _T("Beep"), _T("Noise (FDD)"),
69 };
70 #endif
71
72 class EMU;
73 class DEVICE;
74 class EVENT;
75
76 class HD46505;
77 class I8237;
78 //class I8250;
79 class I8253;
80 class I8259;
81 //#if defined(HAS_I286)
82 class I286;
83 //#else
84 //class I86;
85 //#endif
86 class IO;
87 class PCM1BIT;
88 class UPD765A;
89 #ifdef TYPE_SL
90 class RP5C01;
91 #else
92 class HD146818P;
93 #endif
94
95 namespace J3100 {
96         class DISPLAY;
97         class DMAREG;
98         class FLOPPY;
99         class SASI;
100 #ifndef TYPE_SL
101         class KEYBOARD;
102         class MEMORY;
103         class SYSTEM;
104 #endif
105 }
106
107 #ifdef TYPE_SL
108 namespace J3100SL {
109         class KEYBOARD;
110         class MEMORY;
111         class SYSTEM;
112 }
113 #endif
114
115 class VM : public VM_TEMPLATE
116 {
117 protected:
118         //EMU* emu;
119         
120         // devices
121         //EVENT* event;
122         
123         HD46505* crtc;
124         I8237* dma;
125 //      I8250* sio;
126         I8253* pit;
127         I8259* pic;
128 //#if defined(HAS_I286)
129         I286* cpu;
130 //#else
131 //      I86* cpu;
132 //#endif
133         IO* io;
134         PCM1BIT* pcm;
135         UPD765A* fdc;
136 #ifdef TYPE_SL
137         RP5C01* rtc;
138 #else
139         HD146818P* rtc;
140         I8237* dma2;
141 #endif
142         
143         J3100::DISPLAY* display;
144         J3100::DMAREG* dmareg;
145         J3100::FLOPPY* floppy;
146         J3100::SASI* sasi;
147 #ifdef TYPE_SL
148         J3100SL::KEYBOARD* keyboard;
149         J3100SL::MEMORY* memory;
150         J3100SL::SYSTEM* system;
151 #else
152         J3100::KEYBOARD* keyboard;
153         J3100::MEMORY* memory;
154         J3100::SYSTEM* system;
155 #endif
156         
157 public:
158         // ----------------------------------------
159         // initialize
160         // ----------------------------------------
161         
162         VM(EMU* parent_emu);
163         ~VM();
164         
165         // ----------------------------------------
166         // for emulation class
167         // ----------------------------------------
168         
169         // drive virtual machine
170         void reset();
171         void notify_power_off() { }
172         void run();
173         
174 #ifdef USE_DEBUGGER
175         // debugger
176         DEVICE *get_cpu(int index);
177 #endif
178         
179         // draw screen
180         void draw_screen();
181         
182         // sound generation
183         void initialize_sound(int rate, int samples);
184         uint16_t* create_sound(int* extra_frames);
185         int get_sound_buffer_ptr();
186 #ifdef USE_SOUND_VOLUME
187         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
188 #endif
189         
190         // notify key
191         void key_down(int code, bool repeat);
192         void key_up(int code);
193         
194         // user interface
195         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
196         void close_floppy_disk(int drv);
197         bool is_floppy_disk_inserted(int drv);
198         void is_floppy_disk_protected(int drv, bool value);
199         bool is_floppy_disk_protected(int drv);
200         uint32_t is_floppy_disk_accessed();
201         bool is_frame_skippable();
202         
203         void update_config();
204         bool process_state(FILEIO* state_fio, bool loading);
205         
206         // ----------------------------------------
207         // for each device
208         // ----------------------------------------
209         
210         // devices
211         DEVICE* get_device(int id);
212         //DEVICE* dummy;
213         //DEVICE* first_device;
214         //DEVICE* last_device;
215 };
216
217 #endif