OSDN Git Service

[VM][Qt][UI][EMU][WIP] Use EMU_TEMPLATE:: instead of EMU:: . Some VMs are not apply...
[csp-qt/common_source_project-fm7.git] / source / src / vm / yalky / yalky.h
1 /*
2         Yuasa Kyouiku System YALKY Emulator 'eYALKY'
3
4         Author : Takeda.Toshiya
5         Date   : 2016.03.28-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _YALKY_H_
11 #define _YALKY_H_
12
13 #define DEVICE_NAME             "Yuasa Kyouiku System YALKY"
14 #define CONFIG_NAME             "yalky"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          60
18 #define LINES_PER_FRAME         262
19 #define CPU_CLOCKS              3000000
20 #define SCREEN_WIDTH            256
21 #define SCREEN_HEIGHT           256
22 #define WINDOW_HEIGHT_ASPECT    192
23 #define HAS_I8085
24 #define DATAREC_SOUND
25 #define DATAREC_SOUND_LEFT
26 #define DATAREC_FAST_FWD_SPEED  10
27 #define DATAREC_FAST_REW_SPEED  10
28 #define MEMORY_ADDR_MAX         0x10000
29 #define MEMORY_BANK_SIZE        0x100
30
31 // device informations for win32
32 #define USE_SPECIAL_RESET
33 #define USE_TAPE                1
34 #define USE_AUTO_KEY            5
35 #define USE_AUTO_KEY_RELEASE    6
36 #define USE_AUTO_KEY_CAPS
37 #define USE_SOUND_VOLUME        2
38 #define USE_DEBUGGER
39 #define USE_STATE
40 #define USE_CPU_I8080
41
42 #include "../../common.h"
43 #include "../../fileio.h"
44 #include "../vm_template.h"
45
46 #ifdef USE_SOUND_VOLUME
47 static const _TCHAR *sound_device_caption[] = {
48         _T("CMT (Voice)"),      _T("Noise (CMT)"),
49 };
50 #endif
51
52 class EMU;
53 class DEVICE;
54 class EVENT;
55
56 class DATAREC;
57 class I8080;
58 class I8155;
59 class MEMORY;
60
61 namespace YALKY {
62         class IO;
63 }
64
65 class VM : public VM_TEMPLATE
66 {
67 protected:
68         //EMU* emu;
69         
70         // devices
71         //EVENT* event;
72         
73         DATAREC* drec;
74         I8080* cpu;
75         I8155* pio;
76         MEMORY* memory;
77         
78         YALKY::IO* io;
79         
80         uint8_t rom[0x2000];
81         uint8_t ram[0x100];
82         uint8_t vram[0x400];
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 special_reset();
99         void run();
100         double get_frame_rate()
101         {
102                 return FRAMES_PER_SEC;
103         }
104         
105 #ifdef USE_DEBUGGER
106         // debugger
107         DEVICE *get_cpu(int index);
108 #endif
109         
110         // draw screen
111         void draw_screen();
112         
113         // sound generation
114         void initialize_sound(int rate, int samples);
115         uint16_t* create_sound(int* extra_frames);
116         int get_sound_buffer_ptr();
117 #ifdef USE_SOUND_VOLUME
118         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
119 #endif
120         
121         // user interface
122         void play_tape(int drv, const _TCHAR* file_path);
123         void rec_tape(int drv, const _TCHAR* file_path);
124         void close_tape(int drv);
125         bool is_tape_inserted(int drv);
126         bool is_tape_playing(int drv);
127         bool is_tape_recording(int drv);
128         int get_tape_position(int drv);
129         const _TCHAR* get_tape_message(int drv);
130         void push_play(int drv);
131         void push_stop(int drv);
132         void push_fast_forward(int drv);
133         void push_fast_rewind(int drv);
134         void push_apss_forward(int drv) {}
135         void push_apss_rewind(int drv) {}
136         bool is_frame_skippable();
137         
138         double get_current_usec();
139         uint64_t get_current_clock_uint64();
140         
141         void update_config();
142         bool process_state(FILEIO* state_fio, bool loading);
143         
144         // ----------------------------------------
145         // for each device
146         // ----------------------------------------
147         
148         // devices
149         DEVICE* get_device(int id);
150         //DEVICE* dummy;
151         //DEVICE* first_device;
152         //DEVICE* last_device;
153 };
154
155 #endif