2 NEC PC-98DO Emulator 'ePC-98DO'
3 NEC PC-8801MA Emulator 'ePC-8801MA'
4 NEC PC-8001mkIISR Emulator 'ePC-8001mkIISR'
6 Author : Takeda.Toshiya
16 #include "../../emu.h"
17 #include "../device.h"
19 #define SIG_PC88_USART_IRQ 0
20 #define SIG_PC88_SOUND_IRQ 1
21 #ifdef SUPPORT_PC88_SB2
22 #define SIG_PC88_SB2_IRQ 2
24 #define SIG_PC88_USART_OUT 3
26 #define CMT_BUFFER_SIZE 0x40000
28 #if defined(_PC8001SR) && !defined(PC88_EXRAM_BANKS)
29 #define PC88_EXRAM_BANKS 1
32 #if !defined(_PC8001SR)
43 uint8_t cursor, attrib;
52 uint8_t expand[200][80];
55 uint8_t expand[200][80];
62 uint8_t buffer[120 * 200];
66 uint8_t mode, reverse, intr_mask, status;
69 void reset(bool hireso);
70 void write_cmd(uint8_t data);
71 void write_param(uint8_t data);
72 uint32_t read_param();
73 uint32_t read_status();
76 void write_buffer(uint8_t data);
77 uint8_t read_buffer(int ofs);
79 void expand_buffer(bool hireso, bool line400);
80 void set_attrib(uint8_t code);
95 void write_io8(uint32_t addr, uint32_t data);
96 uint32_t read_io8(uint32_t addr);
98 void run(int c, int nbytes);
102 class PC88 : public DEVICE
106 #ifdef SUPPORT_PC88_SB2
110 DEVICE *d_pcm, *d_pio, *d_prn, *d_rtc, *d_sio;
111 #ifdef SUPPORT_PC88_PCG8100
112 DEVICE *d_pcg_pit, *d_pcg_pcm0, *d_pcg_pcm1, *d_pcg_pcm2;
117 uint8_t wdmy[0x1000];
118 uint8_t rdmy[0x1000];
120 uint8_t ram[0x10000];
121 #if defined(PC88_EXRAM_BANKS)
122 uint8_t exram[0x8000 * PC88_EXRAM_BANKS];
124 uint8_t gvram[0xc000];
125 uint8_t gvram_null[0x4000];
126 uint8_t tvram[0x1000];
127 #if defined(_PC8001SR)
128 uint8_t n80mk2rom[0x8000];
129 uint8_t n80mk2srrom[0xa000];
131 uint8_t n88rom[0x8000];
132 uint8_t n88exrom[0x8000];
133 uint8_t n80rom[0x8000];
135 uint8_t kanji1[0x20000];
136 uint8_t kanji2[0x20000];
137 #ifdef SUPPORT_PC88_DICTIONARY
138 uint8_t dicrom[0x80000];
149 uint8_t gvram_plane, gvram_sel;
151 void update_timing();
152 int get_m1_wait(bool addr_f000);
153 int get_main_wait(bool read);
154 int get_tvram_wait(bool read);
155 int get_gvram_wait(bool read);
156 void update_gvram_wait();
157 void update_gvram_sel();
158 #if defined(_PC8001SR)
159 void update_n80_write();
160 void update_n80_read();
162 void update_low_memmap();
163 void update_tvram_memmap();
168 #if defined(SUPPORT_PC88_HIGH_CLOCK)
169 bool cpu_clock_high_fe2;
173 int f000_m1_wait_clocks;
174 int mem_wait_clocks_r, mem_wait_clocks_w;
175 int tvram_wait_clocks_r, tvram_wait_clocks_w;
176 int gvram_wait_clocks_r, gvram_wait_clocks_w;
186 uint8_t sg_pattern[0x800];
187 uint8_t text[200][640];
188 uint8_t text_color[200][80];
189 bool text_reverse[200][80];
190 uint8_t graph[400][640];
191 scrntype_t palette_text_pc[9]; // 0 = back color for attrib mode, 8 = black
192 scrntype_t palette_graph_pc[9];
195 #if defined(_PC8001SR)
196 bool draw_320x200_color_graph();
197 bool draw_320x200_4color_graph();
198 void draw_320x200_attrib_graph();
200 bool draw_640x200_color_graph();
201 void draw_640x200_mono_graph();
202 void draw_640x200_attrib_graph();
203 #if !defined(_PC8001SR)
204 void draw_640x400_mono_graph();
205 void draw_640x400_attrib_graph();
213 uint8_t key_status[256];
214 uint8_t key_caps, key_kana;
216 #ifdef SUPPORT_PC88_JOYSTICK
218 const uint32_t *joystick_status;
219 const int32_t* mouse_status;
220 uint32_t mouse_strobe_clock;
221 uint32_t mouse_strobe_clock_lim;
223 int mouse_dx, mouse_dy;
224 int mouse_lx, mouse_ly;
230 #ifdef SUPPORT_PC88_SB2
233 uint8_t intr_mask1, intr_mask2;
234 void request_intr(int level, bool status);
239 bool cmt_play, cmt_rec;
240 _TCHAR rec_file_path[_MAX_PATH];
241 int cmt_bufptr, cmt_bufcnt;
242 uint8_t cmt_buffer[CMT_BUFFER_SIZE];
243 int cmt_data_carrier[1024], cmt_data_carrier_cnt;
247 bool check_data_carrier();
250 bool beep_on, beep_signal, sing_signal;
252 #ifdef SUPPORT_PC88_PCG8100
255 uint8_t pcg_data, pcg_ctrl;
256 uint8_t pcg_pattern[0x800];
260 // dirty patch for NIPPY
264 PC88(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
266 #if defined(_PC8001SR)
267 set_device_name(_T("PC-8001 Core"));
269 set_device_name(_T("PC-8801 Core"));
279 void write_data8w(uint32_t addr, uint32_t data, int* wait);
280 uint32_t read_data8w(uint32_t addr, int* wait);
281 uint32_t fetch_op(uint32_t addr, int *wait);
282 void write_io8(uint32_t addr, uint32_t data);
283 uint32_t read_io8(uint32_t addr);
285 uint32_t read_io8_debug(uint32_t addr);
288 uint32_t read_dma_data8(uint32_t addr);
289 void write_dma_io8(uint32_t addr, uint32_t data);
291 void write_signal(int id, uint32_t data, uint32_t mask);
292 void event_callback(int event_id, int err);
294 void event_vline(int v, int clock);
295 uint32_t get_intr_ack();
296 void notify_intr_ei();
297 bool process_state(FILEIO* state_fio, bool loading);
302 #if !defined(_PC8001SR)
303 return (n88rom[0x79d7] < 0x38);
308 void set_context_cpu(Z80* device)
312 void set_context_opn(YM2203* device)
316 #ifdef SUPPORT_PC88_SB2
317 void set_context_sb2(YM2203* device)
322 void set_context_pcm(DEVICE* device)
326 void set_context_pio(DEVICE* device)
330 void set_context_prn(DEVICE* device)
334 void set_context_rtc(DEVICE* device)
338 void set_context_sio(DEVICE* device)
342 #ifdef SUPPORT_PC88_PCG8100
343 void set_context_pcg_pit(DEVICE* device)
347 void set_context_pcg_pcm0(DEVICE* device)
351 void set_context_pcg_pcm1(DEVICE* device)
355 void set_context_pcg_pcm2(DEVICE* device)
360 void key_down(int code, bool repeat);
361 bool get_caps_locked()
363 return (key_caps != 0);
365 bool get_kana_locked()
367 return (key_kana != 0);
370 void play_tape(const _TCHAR* file_path);
371 void rec_tape(const _TCHAR* file_path);
373 bool is_tape_inserted()
375 return (cmt_play || cmt_rec);
377 bool is_frame_skippable();