OSDN Git Service

fcff1fccf8cd1909103d5c23e880e6ed3e5dd29d
[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 WINDOW_HEIGHT_ASPECT    480
51 #define USE_CRT_MONITOR_4_3 1
52 #endif
53 #define MAX_DRIVE               4
54 #define SUPPORT_VARIABLE_TIMING
55
56 // device informations for win32
57 #define USE_BOOT_MODE           5
58 #define USE_DEVICE_TYPE         3
59 #define USE_TAPE
60 #define USE_FD1
61 #define USE_FD2
62 //#define USE_FD3
63 //#define USE_FD4
64 #define USE_BINARY_FILE1
65 #define USE_SHIFT_NUMPAD_KEY
66 #define USE_ALT_F10_KEY
67 #define USE_AUTO_KEY            5
68 #define USE_AUTO_KEY_RELEASE    6
69 #define USE_CRT_FILTER
70 #define USE_SCANLINE
71 #define USE_ACCESS_LAMP
72 #define USE_SOUND_VOLUME        2
73 #define USE_DEBUGGER
74 #define USE_JOYSTICK
75 #define USE_MOUSE
76 #define USE_STATE
77
78 #include "../../common.h"
79 #include "../../fileio.h"
80
81 #ifdef USE_SOUND_VOLUME
82 static const _TCHAR *sound_device_caption[] = {
83         _T("Beep"), _T("CMT"),
84 };
85 #endif
86
87 class EMU;
88 class DEVICE;
89 class EVENT;
90
91 class DATAREC;
92 class HD46505;
93 class I8255;
94 class IO;
95 class LS393;
96 class NOT;
97 class PCM1BIT;
98 class UPD765A;
99 class Z80;
100 class Z80CTC;
101 class Z80PIO;
102
103 class FLOPPY;
104 class DISPLAY;
105 class KEYBOARD;
106 class MEMORY;
107 class PAC2;
108
109 class VM
110 {
111 protected:
112         EMU* emu;
113         
114         // devices
115         EVENT* event;
116         
117         DATAREC* drec;
118         HD46505* crtc;
119         I8255* pio0;
120         I8255* pio1;
121         I8255* pio2;
122         IO* io;
123         LS393* flipflop;
124         NOT* not_remote;
125         PCM1BIT* pcm;
126         UPD765A* fdc;
127         Z80* cpu;
128         Z80CTC* ctc;
129         Z80PIO* pio;
130         
131         FLOPPY* floppy;
132         DISPLAY* display;
133         KEYBOARD* key;
134         MEMORY* memory;
135         PAC2* pac2;
136         
137         int boot_mode;
138         
139 public:
140         // ----------------------------------------
141         // initialize
142         // ----------------------------------------
143         
144         VM(EMU* parent_emu);
145         ~VM();
146         
147         // ----------------------------------------
148         // for emulation class
149         // ----------------------------------------
150         
151         // drive virtual machine
152         void reset();
153         void run();
154         double get_frame_rate();
155         
156 #ifdef USE_DEBUGGER
157         // debugger
158         DEVICE *get_cpu(int index);
159 #endif
160         
161         // draw screen
162         void draw_screen();
163         int get_access_lamp_status();
164         
165         // sound generation
166         void initialize_sound(int rate, int samples);
167         uint16* create_sound(int* extra_frames);
168         int get_sound_buffer_ptr();
169 #ifdef USE_SOUND_VOLUME
170         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
171 #endif
172         
173         // user interface
174         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
175         void close_floppy_disk(int drv);
176         bool is_floppy_disk_inserted(int drv);
177         void is_floppy_disk_protected(int drv, bool value);
178         bool is_floppy_disk_protected(int drv);
179         void play_tape(const _TCHAR* file_path);
180         void rec_tape(const _TCHAR* file_path);
181         void close_tape();
182         bool is_tape_inserted();
183         bool is_tape_playing();
184         bool is_tape_recording();
185         int get_tape_position();
186         void load_binary(int drv, const _TCHAR* file_path);
187         void save_binary(int drv, const _TCHAR* file_path) {}
188         bool is_frame_skippable();
189         
190         void update_config();
191         void save_state(FILEIO* state_fio);
192         bool load_state(FILEIO* state_fio);
193         
194         // ----------------------------------------
195         // for each device
196         // ----------------------------------------
197         
198         // devices
199         DEVICE* get_device(int id);
200         DEVICE* dummy;
201         DEVICE* first_device;
202         DEVICE* last_device;
203 };
204
205 #endif