OSDN Git Service

0fdf68c0132e6f2274f9abdf480792a13a52664a
[csp-qt/common_source_project-fm7.git] / source / src / vm / pasopia7 / pasopia7.h
1 /*
2         TOSHIBA PASOPIA 7 Emulator 'EmuPIA7'
3
4         Author : Takeda.Toshiya
5         Date   : 2006.09.20 -
6
7         [ virtual machine ]
8 */
9
10 #ifndef _PASOPIA7_H_
11 #define _PASOPIA7_H_
12
13 #ifdef _LCD
14 #define DEVICE_NAME             "TOSHIBA PASOPIA 7 with LCD"
15 #define CONFIG_NAME             "pasopia7lcd"
16 #else
17 #define DEVICE_NAME             "TOSHIBA PASOPIA 7"
18 #define CONFIG_NAME             "pasopia7"
19 #endif
20
21 // device informations for virtual machine
22 #ifdef _LCD
23 #define FRAMES_PER_SEC          74.38
24 #define LINES_PER_FRAME         32
25 #define CHARS_PER_LINE          94
26 #define HD46505_HORIZ_FREQ      (1789780.0 / 752.0)
27 #else
28 #define FRAMES_PER_SEC          59.92
29 #define LINES_PER_FRAME         262
30 #define CHARS_PER_LINE          57
31 #define HD46505_HORIZ_FREQ      (14318180.0 / 912.0)
32 #endif
33 #define CPU_CLOCKS              3993600
34 #ifdef _LCD
35 #define SCREEN_WIDTH            320
36 #define SCREEN_HEIGHT           128
37 #else
38 #define SCREEN_WIDTH            640
39 #define SCREEN_HEIGHT           400
40 #define WINDOW_HEIGHT_ASPECT    480
41 #endif
42 #define MAX_DRIVE               4
43 #define IO_ADDR_MAX             0x100
44 #define SUPPORT_VARIABLE_TIMING
45
46 // device informations for win32
47 #define USE_TAPE                1
48 #define USE_TAPE_BUTTON
49 #define USE_FLOPPY_DISK         2
50 #define USE_BINARY_FILE         2
51 #define USE_SHIFT_NUMPAD_KEY
52 #define USE_ALT_F10_KEY
53 #define USE_AUTO_KEY            5
54 #define USE_AUTO_KEY_RELEASE    6
55 #define USE_AUTO_KEY_NUMPAD
56 #define USE_SCREEN_FILTER
57 #define USE_SCANLINE
58 #define USE_SOUND_VOLUME        6
59 #define USE_JOYSTICK
60 #define USE_DEBUGGER
61 #define USE_STATE
62 #define USE_CPU_Z80
63
64 #include "../../common.h"
65 #include "../../fileio.h"
66 #include "../vm_template.h"
67
68 #ifdef USE_SOUND_VOLUME
69 static const _TCHAR *sound_device_caption[] = {
70         _T("PSG #1"), _T("PSG #2"), _T("Beep"), _T("CMT (Signal)"), _T("Noise (FDD)"), _T("Noise (CMT)"),
71 };
72 #endif
73
74 class csp_state_utils;
75 class EMU;
76 class DEVICE;
77 class EVENT;
78
79 class DATAREC;
80 class HD46505;
81 class I8255;
82 class IO;
83 class LS393;
84 class NOT;
85 class PCM1BIT;
86 class SN76489AN;
87 class UPD765A;
88 class Z80;
89 class Z80CTC;
90 class Z80PIO;
91
92 class FLOPPY;
93 class DISPLAY;
94 class IOBUS;
95 class IOTRAP;
96 class KEYBOARD;
97 class MEMORY;
98 class PAC2;
99
100 class VM : public VM_TEMPLATE
101 {
102 protected:
103         //EMU* emu;
104         //csp_state_utils *state_entry;
105         
106         // devices
107         //EVENT* event;
108         
109         DATAREC* drec;
110         HD46505* crtc;
111         I8255* pio0;
112         I8255* pio1;
113         I8255* pio2;
114         IO* io;
115         LS393* flipflop;
116         NOT* not_remote;
117         PCM1BIT* pcm;
118         SN76489AN* psg0;
119         SN76489AN* psg1;
120         UPD765A* fdc;
121         Z80* cpu;
122         Z80CTC* ctc;
123         Z80PIO* pio;
124         
125         FLOPPY* floppy;
126         DISPLAY* display;
127         IOBUS* iobus;
128         IOTRAP* iotrap;
129         KEYBOARD* key;
130         MEMORY* memory;
131         PAC2* pac2;
132         
133 public:
134         // ----------------------------------------
135         // initialize
136         // ----------------------------------------
137         
138         VM(EMU* parent_emu);
139         ~VM();
140         
141         // ----------------------------------------
142         // for emulation class
143         // ----------------------------------------
144         
145         // drive virtual machine
146         void reset();
147         void run();
148         double get_frame_rate();
149         
150 #ifdef USE_DEBUGGER
151         // debugger
152         DEVICE *get_cpu(int index);
153 #endif
154         
155         // draw screen
156         void draw_screen();
157         
158         // sound generation
159         void initialize_sound(int rate, int samples);
160         uint16_t* create_sound(int* extra_frames);
161         int get_sound_buffer_ptr();
162 #ifdef USE_SOUND_VOLUME
163         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
164 #endif
165         
166         // user interface
167         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
168         void close_floppy_disk(int drv);
169         bool is_floppy_disk_inserted(int drv);
170         void is_floppy_disk_protected(int drv, bool value);
171         bool is_floppy_disk_protected(int drv);
172         uint32_t is_floppy_disk_accessed();
173         void play_tape(int drv, const _TCHAR* file_path);
174         void rec_tape(int drv, const _TCHAR* file_path);
175         void close_tape(int drv);
176         bool is_tape_inserted(int drv);
177         bool is_tape_playing(int drv);
178         bool is_tape_recording(int drv);
179         int get_tape_position(int drv);
180         const _TCHAR* get_tape_message(int drv);
181         void push_play(int drv);
182         void push_stop(int drv);
183         void push_fast_forward(int drv);
184         void push_fast_rewind(int drv);
185         void push_apss_forward(int drv) {}
186         void push_apss_rewind(int drv) {}
187         void load_binary(int drv, const _TCHAR* file_path);
188         void save_binary(int drv, const _TCHAR* file_path) {}
189         bool is_frame_skippable();
190         
191         void update_config();
192         void decl_state();
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