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)
42 uint8_t cursor, attrib;
51 uint8_t expand[200][80];
54 uint8_t expand[200][80];
61 uint8_t buffer[120 * 200];
65 uint8_t mode, reverse, intr_mask, status;
68 void reset(bool hireso);
69 void write_cmd(uint8_t data);
70 void write_param(uint8_t data);
71 uint32_t read_param();
72 uint32_t read_status();
75 void write_buffer(uint8_t data);
76 uint8_t read_buffer(int ofs);
78 void expand_buffer(bool hireso, bool line400);
79 void set_attrib(uint8_t code);
94 void write_io8(uint32_t addr, uint32_t data);
95 uint32_t read_io8(uint32_t addr);
97 void run(int c, int nbytes);
101 class PC88 : public DEVICE
105 #ifdef SUPPORT_PC88_SB2
109 DEVICE *d_pcm, *d_pio, *d_prn, *d_rtc, *d_sio;
110 #ifdef SUPPORT_PC88_PCG8100
111 DEVICE *d_pcg_pit, *d_pcg_pcm0, *d_pcg_pcm1, *d_pcg_pcm2;
116 uint8_t wdmy[0x1000];
117 uint8_t rdmy[0x1000];
119 uint8_t ram[0x10000];
120 #if defined(PC88_EXRAM_BANKS)
121 uint8_t exram[0x8000 * PC88_EXRAM_BANKS];
123 uint8_t gvram[0xc000];
124 uint8_t gvram_null[0x4000];
125 uint8_t tvram[0x1000];
126 #if defined(_PC8001SR)
127 uint8_t n80mk2rom[0x8000];
128 uint8_t n80mk2srrom[0xa000];
130 uint8_t n88rom[0x8000];
131 uint8_t n88exrom[0x8000];
132 uint8_t n80rom[0x8000];
134 uint8_t kanji1[0x20000];
135 uint8_t kanji2[0x20000];
136 #ifdef SUPPORT_PC88_DICTIONARY
137 uint8_t dicrom[0x80000];
148 uint8_t gvram_plane, gvram_sel;
150 void update_timing();
151 int get_m1_wait(bool addr_f000);
152 int get_main_wait(bool read);
153 int get_tvram_wait(bool read);
154 int get_gvram_wait(bool read);
155 void update_gvram_wait();
156 void update_gvram_sel();
157 #if defined(_PC8001SR)
158 void update_n80_write();
159 void update_n80_read();
161 void update_low_memmap();
162 void update_tvram_memmap();
167 #if defined(SUPPORT_PC88_HIGH_CLOCK)
168 bool cpu_clock_high_fe2;
172 int f000_m1_wait_clocks;
173 int mem_wait_clocks_r, mem_wait_clocks_w;
174 int tvram_wait_clocks_r, tvram_wait_clocks_w;
175 int gvram_wait_clocks_r, gvram_wait_clocks_w;
185 uint8_t sg_pattern[0x800];
186 uint8_t text[200][640];
187 uint8_t text_color[200][80];
188 bool text_reverse[200][80];
189 uint8_t graph[400][640];
190 scrntype_t palette_text_pc[9]; // 0 = back color for attrib mode, 8 = black
191 scrntype_t palette_graph_pc[9];
194 #if defined(_PC8001SR)
195 bool draw_320x200_color_graph();
196 bool draw_320x200_4color_graph();
197 void draw_320x200_attrib_graph();
199 bool draw_640x200_color_graph();
200 void draw_640x200_mono_graph();
201 void draw_640x200_attrib_graph();
202 #if !defined(_PC8001SR)
203 void draw_640x400_mono_graph();
204 void draw_640x400_attrib_graph();
212 uint8_t key_status[256];
213 uint8_t key_caps, key_kana;
215 #ifdef SUPPORT_PC88_JOYSTICK
217 const uint32_t *joystick_status;
218 const int32_t* mouse_status;
219 uint32_t mouse_strobe_clock;
220 uint32_t mouse_strobe_clock_lim;
222 int mouse_dx, mouse_dy;
223 int mouse_lx, mouse_ly;
229 #ifdef SUPPORT_PC88_SB2
232 uint8_t intr_mask1, intr_mask2;
233 void request_intr(int level, bool status);
238 bool cmt_play, cmt_rec;
239 _TCHAR rec_file_path[_MAX_PATH];
240 int cmt_bufptr, cmt_bufcnt;
241 uint8_t cmt_buffer[CMT_BUFFER_SIZE];
242 int cmt_data_carrier[1024], cmt_data_carrier_cnt;
246 bool check_data_carrier();
249 bool beep_on, beep_signal, sing_signal;
251 #ifdef SUPPORT_PC88_PCG8100
254 uint8_t pcg_data, pcg_ctrl;
255 uint8_t pcg_pattern[0x800];
259 // dirty patch for NIPPY
262 void decl_state_crtc();
263 void decl_state_dmac();
266 PC88(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
268 #if defined(_PC8001SR)
269 set_device_name(_T("PC-8001 Core"));
271 set_device_name(_T("PC-8801 Core"));
281 void write_data8w(uint32_t addr, uint32_t data, int* wait);
282 uint32_t read_data8w(uint32_t addr, int* wait);
283 uint32_t fetch_op(uint32_t addr, int *wait);
284 void write_io8(uint32_t addr, uint32_t data);
285 uint32_t read_io8(uint32_t addr);
287 uint32_t read_io8_debug(uint32_t addr);
290 uint32_t read_dma_data8(uint32_t addr);
291 void write_dma_io8(uint32_t addr, uint32_t data);
293 void write_signal(int id, uint32_t data, uint32_t mask);
294 void event_callback(int event_id, int err);
296 void event_vline(int v, int clock);
297 uint32_t get_intr_ack();
298 void notify_intr_ei();
300 void save_state(FILEIO* state_fio);
301 bool load_state(FILEIO* state_fio);
306 #if !defined(_PC8001SR)
307 return (n88rom[0x79d7] < 0x38);
312 void set_context_cpu(Z80* device)
316 void set_context_opn(YM2203* device)
320 #ifdef SUPPORT_PC88_SB2
321 void set_context_sb2(YM2203* device)
326 void set_context_pcm(DEVICE* device)
330 void set_context_pio(DEVICE* device)
334 void set_context_prn(DEVICE* device)
338 void set_context_rtc(DEVICE* device)
342 void set_context_sio(DEVICE* device)
346 #ifdef SUPPORT_PC88_PCG8100
347 void set_context_pcg_pit(DEVICE* device)
351 void set_context_pcg_pcm0(DEVICE* device)
355 void set_context_pcg_pcm1(DEVICE* device)
359 void set_context_pcg_pcm2(DEVICE* device)
364 void key_down(int code, bool repeat);
365 bool get_caps_locked()
367 return (key_caps != 0);
369 bool get_kana_locked()
371 return (key_kana != 0);
374 void play_tape(const _TCHAR* file_path);
375 void rec_tape(const _TCHAR* file_path);
377 bool is_tape_inserted()
379 return (cmt_play || cmt_rec);
381 bool is_frame_skippable();