OSDN Git Service

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