OSDN Git Service

9542d22017f72ca435c60389ae0bd5bf68b96c94
[csp-qt/common_source_project-fm7.git] / source / src / vm / bx1 / bx1.h
1 /*
2         CANON BX-1 Emulator 'eBX-1'
3
4         Author : Takeda.Toshiya
5         Date   : 2020.08.22-
6 */
7
8 #ifndef _BX1_H_
9 #define _BX1_H_
10
11 #define DEVICE_NAME             "CANON BX-1"
12 #define CONFIG_NAME             "bx1"
13
14 // device informations for virtual machine
15 #define FRAMES_PER_SEC          30
16 #define LINES_PER_FRAME         64
17 #define CPU_CLOCKS              500000 // 4MHz / ???
18 #define SCREEN_WIDTH            ((6 * 15 + 5) * 5)
19 #define SCREEN_HEIGHT           (7 * 5)
20 #define MAX_DRIVE               1
21 #define MEMORY_ADDR_MAX         0x10000
22 #define MEMORY_BANK_SIZE        0x1000
23 #define IO_ADDR_MAX             0x10000
24 #define HAS_MC6800
25
26 // device informations for win32
27 #define USE_FLOPPY_DISK         1
28 #define USE_NUMPAD_ENTER
29 #define USE_AUTO_KEY            6
30 #define USE_AUTO_KEY_RELEASE    12
31 #define USE_AUTO_KEY_CAPS
32 #define DONT_KEEEP_KEY_PRESSED
33 #define USE_SOUND_VOLUME        2
34 #define USE_DEBUGGER
35 #define USE_STATE
36
37 #include "../../common.h"
38 #include "../../fileio.h"
39 #include "../vm_template.h"
40
41 #ifdef USE_SOUND_VOLUME
42 static const _TCHAR *sound_device_caption[] = {
43         _T("Noise (FDD)"),
44 };
45 #endif
46
47 class EMU;
48 class DEVICE;
49 class EVENT;
50
51 class MC6800;
52 class IO;
53 class MEMORY;
54 class MC6843;
55 class MC6844;
56
57 namespace BX1 {
58         class DISPLAY;
59         class KEYBOARD;
60         class PRINTER;
61 }
62 class VM : public VM_TEMPLATE
63 {
64 protected:
65 //      EMU* emu;
66         
67         // devices
68         EVENT* event;
69         
70         MC6800* cpu;
71         IO* io;
72         MEMORY* memory;
73         MC6843* fdc;
74         MC6844* dma;
75         
76         BX1::DISPLAY* display;
77         BX1::KEYBOARD* keyboard;
78         BX1::PRINTER* printer;
79         
80         uint8_t bios_9000[0x5000]; // 9000h-DFFFh
81         uint8_t bios_f000[0x1000]; // F000h-FFFFh
82         uint8_t ram[0x4000];
83         
84 public:
85         // ----------------------------------------
86         // initialize
87         // ----------------------------------------
88         
89         VM(EMU_TEMPLATE* parent_emu);
90         ~VM();
91         
92         // ----------------------------------------
93         // for emulation class
94         // ----------------------------------------
95         
96         // drive virtual machine
97         void reset();
98         void run();
99         double get_frame_rate()
100         {
101                 return FRAMES_PER_SEC;
102         }
103         
104 #ifdef USE_DEBUGGER
105         // debugger
106         DEVICE *get_cpu(int index);
107 #endif
108         
109         // draw screen
110         void draw_screen();
111         
112         // sound generation
113         void initialize_sound(int rate, int samples);
114         uint16_t* create_sound(int* extra_frames);
115         int get_sound_buffer_ptr();
116 #ifdef USE_SOUND_VOLUME
117         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
118 #endif
119         
120         // notify key
121         void key_down(int code, bool repeat);
122         void key_up(int code);
123         
124         // user interface
125         void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
126         void close_floppy_disk(int drv);
127         bool is_floppy_disk_inserted(int drv);
128         void is_floppy_disk_protected(int drv, bool value);
129         bool is_floppy_disk_protected(int drv);
130         uint32_t is_floppy_disk_accessed();
131         bool is_frame_skippable();
132         
133         void update_config();
134         bool process_state(FILEIO* state_fio, bool loading);
135         
136         // ----------------------------------------
137         // for each device
138         // ----------------------------------------
139         
140         // devices
141         DEVICE* get_device(int id);
142 //      DEVICE* dummy;
143 //      DEVICE* first_device;
144 //      DEVICE* last_device;
145 };
146
147 #endif