OSDN Git Service

4c6bda15f9228576d5d97799e3133d8c4cdeed5c
[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 #include "../vm_template.h"
79
80 #ifdef USE_SOUND_VOLUME
81 static const _TCHAR *sound_device_caption[] = {
82         _T("Beep"), _T("CMT (Signal)"), _T("Noise (FDD)"), _T("Noise (CMT)"),
83 };
84 #endif
85
86 class EMU;
87 class DEVICE;
88 class EVENT;
89
90 class DATAREC;
91 class HD46505;
92 class I8255;
93 class IO;
94 class LS393;
95 class NOT;
96 class PCM1BIT;
97 class UPD765A;
98 class Z80;
99 class Z80CTC;
100 class Z80PIO;
101
102 namespace PASOPIA {
103         class FLOPPY;
104         class DISPLAY;
105         class KEYBOARD;
106         class MEMORY;
107         class PAC2;
108 }
109
110 class VM : public VM_TEMPLATE
111 {
112 protected:
113         //EMU* emu;
114         //csp_state_utils *state_entry;
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         PASOPIA::FLOPPY* floppy;
134         PASOPIA::DISPLAY* display;
135         PASOPIA::KEYBOARD* key;
136         PASOPIA::MEMORY* memory;
137         PASOPIA::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 get_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         
166         // sound generation
167         void initialize_sound(int rate, int samples);
168         uint16_t* create_sound(int* extra_frames);
169         int get_sound_buffer_ptr();
170 #ifdef USE_SOUND_VOLUME
171         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
172 #endif
173         
174         // user interface
175         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
176         void close_floppy_disk(int drv);
177         bool is_floppy_disk_inserted(int drv);
178         void is_floppy_disk_protected(int drv, bool value);
179         bool is_floppy_disk_protected(int drv);
180         uint32_t is_floppy_disk_accessed();
181         void play_tape(int drv, const _TCHAR* file_path);
182         void rec_tape(int drv, const _TCHAR* file_path);
183         void close_tape(int drv);
184         bool is_tape_inserted(int drv);
185         bool is_tape_playing(int drv);
186         bool is_tape_recording(int drv);
187         int get_tape_position(int drv);
188         const _TCHAR* get_tape_message(int drv);
189         void push_play(int drv);
190         void push_stop(int drv);
191         void push_fast_forward(int drv);
192         void push_fast_rewind(int drv);
193         void push_apss_forward(int drv) {}
194         void push_apss_rewind(int drv) {}
195         void load_binary(int drv, const _TCHAR* file_path);
196         void save_binary(int drv, const _TCHAR* file_path) {}
197         bool is_frame_skippable();
198         
199         void update_config();
200         bool process_state(FILEIO* state_fio, bool loading);
201         
202         // ----------------------------------------
203         // for each device
204         // ----------------------------------------
205         
206         // devices
207         DEVICE* get_device(int id);
208         //DEVICE* dummy;
209         //DEVICE* first_device;
210         //DEVICE* last_device;
211 };
212
213 #endif