OSDN Git Service

[VM][STATE][WIP] Apply csp_state_utils:: to some VMs.This is WIP.
[csp-qt/common_source_project-fm7.git] / source / src / vm / bubcom80 / bubcom80.h
1 /*
2         Systems Formulate BUBCOM80 Emulator 'eBUBCOM80'
3
4         Author : Takeda.Toshiya
5         Date   : 2018.05.08-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _BUBCOM80_H_
11 #define _BUBCOM80_H_
12
13 #define DEVICE_NAME             "Systems Formulate BUBCOM80"
14 #define CONFIG_NAME             "bubcom80"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          62.422
18 #define LINES_PER_FRAME         260
19 //#define CPU_CLOCKS            3993624
20 #define CPU_CLOCKS              4000000
21 #define SCREEN_WIDTH            640
22 #define SCREEN_HEIGHT           400
23 #define WINDOW_HEIGHT_ASPECT    480
24 #define MAX_DRIVE               4
25 #define MEMORY_ADDR_MAX         0x10000
26 #define MEMORY_BANK_SIZE        0x800
27 #define IO_ADDR_MAX             0x10000
28 #define SUPPORT_VARIABLE_TIMING
29
30 // device informations for win32
31 #define USE_FLOPPY_DISK         4
32 #define USE_TAPE                1
33 #define TAPE_BINARY_ONLY
34 #define USE_BUBBLE              2
35 #define USE_SHIFT_NUMPAD_KEY
36 #define USE_ALT_F10_KEY
37 #define USE_AUTO_KEY            5
38 #define USE_AUTO_KEY_RELEASE    6
39 #define USE_AUTO_KEY_NUMPAD
40 #define USE_SCREEN_FILTER
41 #define USE_SCANLINE
42 #define USE_SOUND_VOLUME        2
43 #define USE_JOYSTICK
44 #define USE_PRINTER
45 #define USE_PRINTER_TYPE        3
46 #define USE_DEBUGGER
47 #define USE_STATE
48
49 #include "../../common.h"
50 #include "../../fileio.h"
51
52 #ifdef USE_SOUND_VOLUME
53 static const _TCHAR *sound_device_caption[] = {
54         _T("Beep"), _T("Noise (FDD)"),
55 };
56 #endif
57
58 class csp_state_utils;
59 class EMU;
60 class DEVICE;
61 class EVENT;
62
63 class IO;
64 class LS393;
65 class MB8877;
66 class MC6850;
67 class MEMORY;
68 class PCM1BIT;
69 class Z80;
70 class Z80CTC;
71
72 class BUBBLECASETTE;
73 class CMT;
74 class DISPLAY;
75 class FLOPPY;
76 class KEYBOARD;
77 class MEMBUS;
78 class RTC;
79
80 class VM
81 {
82 protected:
83         EMU* emu;
84         
85         // devices
86         EVENT* event;
87         csp_state_utils *state_entry;
88         
89         IO* io;
90         LS393* flipflop;
91         MB8877* fdc;
92 //      MC6850* sio_rs;
93         MC6850* sio_cmt;
94 //      MC6850* sio_key;
95         PCM1BIT* pcm;
96         Z80* cpu;
97         Z80CTC* ctc;
98         
99         BUBBLECASETTE* bubblecasette[2];
100         CMT* cmt;
101         DEVICE* printer;
102         DISPLAY* display;
103         FLOPPY* floppy;
104         KEYBOARD* keyboard;
105         MEMBUS* membus;
106         RTC* rtc;
107         
108 public:
109         // ----------------------------------------
110         // initialize
111         // ----------------------------------------
112         
113         VM(EMU* parent_emu);
114         ~VM();
115         
116         // ----------------------------------------
117         // for emulation class
118         // ----------------------------------------
119         
120         // drive virtual machine
121         void reset();
122         void run();
123         double get_frame_rate();
124         
125 #ifdef USE_DEBUGGER
126         // debugger
127         DEVICE *get_cpu(int index);
128 #endif
129         
130         // draw screen
131         void draw_screen();
132         
133         // sound generation
134         void initialize_sound(int rate, int samples);
135         uint16_t* create_sound(int* extra_frames);
136         int get_sound_buffer_ptr();
137 #ifdef USE_SOUND_VOLUME
138         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
139 #endif
140         
141         // user interface
142         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
143         void close_floppy_disk(int drv);
144         bool is_floppy_disk_inserted(int drv);
145         void is_floppy_disk_protected(int drv, bool value);
146         bool is_floppy_disk_protected(int drv);
147         uint32_t is_floppy_disk_accessed();
148         void play_tape(int drv, const _TCHAR* file_path);
149         void rec_tape(int drv, const _TCHAR* file_path);
150         void close_tape(int drv);
151         bool is_tape_inserted(int drv);
152         void open_bubble_casette(int drv, const _TCHAR *path, int bank);
153         void close_bubble_casette(int drv);
154         bool is_bubble_casette_inserted(int drv);
155         bool is_bubble_casette_protected(int drv);
156         void is_bubble_casette_protected(int drv, bool flag);
157         bool is_frame_skippable();
158         
159         void update_config();
160         void decl_state();
161         void save_state(FILEIO* state_fio);
162         bool load_state(FILEIO* state_fio);
163         
164         // ----------------------------------------
165         // for each device
166         // ----------------------------------------
167         
168         // devices
169         DEVICE* get_device(int id);
170         DEVICE* dummy;
171         DEVICE* first_device;
172         DEVICE* last_device;
173 };
174
175 #endif