OSDN Git Service

3f9a0ec38f5da9bdb70ab32e4ade26db05c94c1a
[csp-qt/common_source_project-fm7.git] / source / src / vm / pasopia / pasopia.h
1 /*
2         TOSHIBA PASOPIA Emulator 'EmuPIA'
3
4         Author : Takeda.Toshiya
5         Date   : 2006.12.28 -
6
7         [ virtual machine ]
8 */
9
10 #ifndef _PASOPIA_H_
11 #define _PASOPIA_H_
12
13 #ifdef _LCD
14 #define DEVICE_NAME             "TOSHIBA PASOPIA with LCD"
15 #define CONFIG_NAME             "pasopialcd"
16 #else
17 #define DEVICE_NAME             "TOSHIBA PASOPIA"
18 #define CONFIG_NAME             "pasopia"
19 #endif
20
21 #define MODE_TBASIC_V1_0        0
22 #define MODE_TBASIC_V1_1        1
23 #define MODE_OABASIC            2
24 #define MODE_OABASIC_NO_DISK    3
25 #define MODE_MINI_PASCAL        4
26
27 #define DEVICE_RAM_PAC          0
28 #define DEVICE_KANJI_ROM        1
29 #define DEVICE_JOYSTICK         2
30
31 // device informations for virtual machine
32 #ifdef _LCD
33 #define FRAMES_PER_SEC          74.38
34 #define LINES_PER_FRAME         32
35 #define CHARS_PER_LINE          94
36 #define HD46505_HORIZ_FREQ      2380
37 #else
38 #define FRAMES_PER_SEC          59.92
39 #define LINES_PER_FRAME         262
40 #define CHARS_PER_LINE          57
41 #define HD46505_HORIZ_FREQ      15700
42 #endif
43 #define CPU_CLOCKS              3993600
44 #ifdef _LCD
45 #define SCREEN_WIDTH            320
46 #define SCREEN_HEIGHT           128
47 #else
48 #define SCREEN_WIDTH            640
49 #define SCREEN_HEIGHT           400
50 #define USE_CRT_MONITOR_4_3 1
51 #endif
52 #define MAX_DRIVE               4
53 #define SUPPORT_VARIABLE_TIMING
54
55 // device informations for win32
56 #define USE_BOOT_MODE           5
57 #define USE_DEVICE_TYPE         3
58 #define USE_TAPE
59 #define USE_FD1
60 #define USE_FD2
61 //#define USE_FD3
62 //#define USE_FD4
63 #define USE_BINARY_FILE1
64 #define USE_SHIFT_NUMPAD_KEY
65 #define USE_ALT_F10_KEY
66 #define USE_AUTO_KEY            5
67 #define USE_AUTO_KEY_RELEASE    6
68 #define USE_CRT_FILTER
69 #define USE_SCANLINE
70 #define USE_ACCESS_LAMP
71 #define USE_SOUND_VOLUME        2
72 #define USE_DEBUGGER
73 #define USE_JOYSTICK
74 #define USE_MOUSE
75 #define USE_STATE
76
77 #include "../../common.h"
78 #include "../../fileio.h"
79
80 #ifdef USE_SOUND_VOLUME
81 static const _TCHAR *sound_device_caption[] = {
82         _T("Beep"), _T("CMT"),
83 };
84 static const bool sound_device_monophonic[] = {
85         false, false,
86 };
87 #endif
88
89 class EMU;
90 class DEVICE;
91 class EVENT;
92
93 class DATAREC;
94 class HD46505;
95 class I8255;
96 class IO;
97 class LS393;
98 class NOT;
99 class PCM1BIT;
100 class UPD765A;
101 class Z80;
102 class Z80CTC;
103 class Z80PIO;
104
105 class FLOPPY;
106 class DISPLAY;
107 class KEYBOARD;
108 class MEMORY;
109 class PAC2;
110
111 class VM
112 {
113 protected:
114         EMU* emu;
115         
116         // devices
117         EVENT* event;
118         
119         DATAREC* drec;
120         HD46505* crtc;
121         I8255* pio0;
122         I8255* pio1;
123         I8255* pio2;
124         IO* io;
125         LS393* flipflop;
126         NOT* not_remote;
127         PCM1BIT* pcm;
128         UPD765A* fdc;
129         Z80* cpu;
130         Z80CTC* ctc;
131         Z80PIO* pio;
132         
133         FLOPPY* floppy;
134         DISPLAY* display;
135         KEYBOARD* key;
136         MEMORY* memory;
137         PAC2* pac2;
138         
139         int boot_mode;
140         
141 public:
142         // ----------------------------------------
143         // initialize
144         // ----------------------------------------
145         
146         VM(EMU* parent_emu);
147         ~VM();
148         
149         // ----------------------------------------
150         // for emulation class
151         // ----------------------------------------
152         
153         // drive virtual machine
154         void reset();
155         void run();
156         double frame_rate();
157         
158 #ifdef USE_DEBUGGER
159         // debugger
160         DEVICE *get_cpu(int index);
161 #endif
162         
163         // draw screen
164         void draw_screen();
165         int access_lamp();
166         
167         // sound generation
168         void initialize_sound(int rate, int samples);
169         uint16* create_sound(int* extra_frames);
170         int sound_buffer_ptr();
171 #ifdef USE_SOUND_VOLUME
172         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
173 #endif
174         
175         // user interface
176         void open_disk(int drv, const _TCHAR* file_path, int bank);
177         void close_disk(int drv);
178         bool disk_inserted(int drv);
179         void set_disk_protected(int drv, bool value);
180         bool get_disk_protected(int drv);
181         void play_tape(const _TCHAR* file_path);
182         void rec_tape(const _TCHAR* file_path);
183         void close_tape();
184         bool tape_inserted();
185         bool tape_playing();
186         bool tape_recording();
187         int tape_position();
188         void load_binary(int drv, const _TCHAR* file_path);
189         void save_binary(int drv, const _TCHAR* file_path) {}
190         bool now_skip();
191         
192         void update_config();
193         void save_state(FILEIO* state_fio);
194         bool load_state(FILEIO* state_fio);
195         
196         // ----------------------------------------
197         // for each device
198         // ----------------------------------------
199         
200         // devices
201         DEVICE* get_device(int id);
202         DEVICE* dummy;
203         DEVICE* first_device;
204         DEVICE* last_device;
205 };
206
207 #endif