OSDN Git Service

[VM][WIP] Use namespace to devices per VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / jr800 / jr800.h
1 /*
2         National JR-800 Emulator 'eJR-800'
3
4         Author : Takeda.Toshiya
5         Date   : 2017.03.13-
6
7         [ virtual machine ]
8 */
9
10 #ifndef _JR800_H_
11 #define _JR800_H_
12
13 #define DEVICE_NAME             "National JR-800"
14 #define CONFIG_NAME             "jr800"
15
16 // device informations for virtual machine
17 #define FRAMES_PER_SEC          72
18 #define LINES_PER_FRAME         64
19 #define CPU_CLOCKS              491520
20 #define SCREEN_WIDTH            192
21 #define SCREEN_HEIGHT           64
22 #define HAS_HD6301
23 #define MEMORY_ADDR_MAX         0x10000
24 #define MEMORY_BANK_SIZE        0x100
25
26 // device informations for win32
27 #define WINDOW_MODE_BASE        2
28 #define USE_TAPE                1
29 #define USE_TAPE_BUTTON
30 #define USE_AUTO_KEY            6
31 #define USE_AUTO_KEY_RELEASE    10
32 //#define USE_AUTO_KEY_CAPS
33 #define USE_SOUND_VOLUME        3
34 #define USE_DEBUGGER
35 #define USE_STATE
36 #define USE_CPU_HD6301
37
38 #include "../../common.h"
39 #include "../../fileio.h"
40 #include "../vm_template.h"
41
42 #ifdef USE_SOUND_VOLUME
43 static const _TCHAR *sound_device_caption[] = {
44         _T("Beep"), _T("CMT (Signal)"), _T("Noise (CMT)"),
45 };
46 #endif
47
48 class csp_state_utils;
49 class EMU;
50 class DEVICE;
51 class EVENT;
52
53 class DATAREC;
54 class HD44102;
55 //class MC6800;
56 class HD6301;
57 class MEMORY;
58 class PCM1BIT;
59
60 namespace JR800 {
61         class IO;
62 }
63 class VM : public VM_TEMPLATE
64 {
65 protected:
66         //EMU* emu;
67         //csp_state_utils *state_entry;
68         
69         // devices
70         //EVENT* event;
71         
72         DATAREC* drec;
73         HD44102* lcd[8];
74         //MC6800* cpu;
75         HD6301* cpu;
76         MEMORY* memory;
77         PCM1BIT* pcm;
78         
79         JR800::IO* io;
80         
81         uint8_t ram[0x6000];
82         uint8_t rom[0x8000];
83         
84 public:
85         // ----------------------------------------
86         // initialize
87         // ----------------------------------------
88         
89         VM(EMU* parent_emu);
90         ~VM();
91         
92         // ----------------------------------------
93         // for emulation class
94         // ----------------------------------------
95         
96         // drive virtual machine
97         void reset();
98         void run();
99         
100 #ifdef USE_DEBUGGER
101         // debugger
102         DEVICE *get_cpu(int index);
103 #endif
104         
105         // draw screen
106         void draw_screen();
107         
108         // sound generation
109         void initialize_sound(int rate, int samples);
110         uint16_t* create_sound(int* extra_frames);
111         int get_sound_buffer_ptr();
112 #ifdef USE_SOUND_VOLUME
113         void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
114 #endif
115         
116         // user interface
117         void play_tape(int drv, const _TCHAR* file_path);
118         void rec_tape(int drv, const _TCHAR* file_path);
119         void close_tape(int drv);
120         bool is_tape_inserted(int drv);
121         bool is_tape_playing(int drv);
122         bool is_tape_recording(int drv);
123         int get_tape_position(int drv);
124         const _TCHAR* get_tape_message(int drv);
125         void push_play(int drv);
126         void push_stop(int drv);
127         void push_fast_forward(int drv);
128         void push_fast_rewind(int drv);
129         void push_apss_forward(int drv) {}
130         void push_apss_rewind(int drv) {}
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