OSDN Git Service

[VM][General][WIP] Apply new (Upstream 2016-02-21) APIs to 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_FD1
54 #define USE_FD2
55 #define NOTIFY_KEY_DOWN
56 #define USE_ALT_F10_KEY
57 #define USE_AUTO_KEY            5
58 #define USE_AUTO_KEY_RELEASE    6
59 #define USE_ACCESS_LAMP
60 #define USE_SOUND_VOLUME        1
61
62 #include "../../common.h"
63 #include "../../fileio.h"
64
65 #ifdef USE_SOUND_VOLUME
66 static const _TCHAR *sound_device_caption[] = {
67         _T("Beep"),
68 };
69 #endif
70
71 class EMU;
72 class DEVICE;
73 class EVENT;
74
75 class HD46505;
76 class I8237;
77 //class I8250;
78 class I8253;
79 class I8259;
80 class I86;
81 class IO;
82 class PCM1BIT;
83 class UPD765A;
84 #ifdef TYPE_SL
85 class RP5C01;
86 #else
87 class HD146818P;
88 #endif
89
90 class DISPLAY;
91 class DMAREG;
92 class FLOPPY;
93 class KEYBOARD;
94 class MEMORY;
95 class SASI;
96 class SYSTEM;
97
98 class VM
99 {
100 protected:
101         EMU* emu;
102         
103         // devices
104         EVENT* event;
105         
106         HD46505* crtc;
107         I8237* dma;
108 //      I8250* sio;
109         I8253* pit;
110         I8259* pic;
111         I86* cpu;
112         IO* io;
113         PCM1BIT* pcm;
114         UPD765A* fdc;
115 #ifdef TYPE_SL
116         RP5C01* rtc;
117 #else
118         HD146818P* rtc;
119         I8237* dma2;
120 #endif
121         
122         DISPLAY* display;
123         DMAREG* dmareg;
124         FLOPPY* floppy;
125         KEYBOARD* keyboard;
126         MEMORY* memory;
127         SASI* sasi;
128         SYSTEM* system;
129         
130 public:
131         // ----------------------------------------
132         // initialize
133         // ----------------------------------------
134         
135         VM(EMU* parent_emu);
136         ~VM();
137         
138         // ----------------------------------------
139         // for emulation class
140         // ----------------------------------------
141         
142         // drive virtual machine
143         void reset();
144         void notify_power_off();
145         void run();
146         
147         // draw screen
148         void draw_screen();
149         int get_access_lamp_status();
150         
151         // sound generation
152         void initialize_sound(int rate, int samples);
153         uint16* create_sound(int* extra_frames);
154         int get_sound_buffer_ptr();
155 #ifdef USE_SOUND_VOLUME
156         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
157 #endif
158         
159         // notify key
160         void key_down(int code, bool repeat);
161         void key_up(int code);
162         
163         // user interface
164         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
165         void close_floppy_disk(int drv);
166         bool is_floppy_disk_inserted(int drv);
167         void is_floppy_disk_protected(int drv, bool value);
168         bool is_floppy_disk_protected(int drv);
169         bool is_frame_skippable();
170         
171         void update_config();
172         
173         // ----------------------------------------
174         // for each device
175         // ----------------------------------------
176         
177         // devices
178         DEVICE* get_device(int id);
179         DEVICE* dummy;
180         DEVICE* first_device;
181         DEVICE* last_device;
182 };
183
184 #endif