-/*\r
- NEC PC-8801MA Emulator 'ePC-8801MA'\r
- NEC PC-8001mkIISR Emulator 'ePC-8001mkIISR'\r
-\r
- Author : Takeda.Toshiya\r
- Date : 2012.02.16-\r
-\r
- [ virtual machine ]\r
-*/\r
-\r
-#ifndef _PC8801_H_\r
-#define _PC8801_H_\r
-\r
-#if defined(_PC8801MA)\r
-#define DEVICE_NAME "NEC PC-8801MA"\r
-#define CONFIG_NAME "pc8801ma"\r
-#elif defined(_PC8001SR)\r
-#define DEVICE_NAME "NEC PC-8001mkIISR"\r
-#define CONFIG_NAME "pc8001mk2sr"\r
-#endif\r
-\r
-#if defined(_PC8001SR)\r
-#define MODE_PC80_V1 0\r
-#define MODE_PC80_V2 1\r
-#define MODE_PC80_N 2\r
-#else\r
-#define MODE_PC88_V1S 0\r
-#define MODE_PC88_V1H 1\r
-#define MODE_PC88_V2 2\r
-#define MODE_PC88_N 3\r
-#endif\r
-\r
-#if defined(_PC8801MA)\r
-#define SUPPORT_PC88_DICTIONARY\r
-#define SUPPORT_PC88_HIGH_CLOCK\r
-#define SUPPORT_PC88_OPNA\r
-#define PC88_EXRAM_BANKS 4\r
-#define HAS_UPD4990A\r
-#endif\r
-#define SUPPORT_PC88_JOYSTICK\r
-#define SUPPORT_PC88_PCG8100\r
-\r
-// device informations for virtual machine\r
-#define FRAMES_PER_SEC 62.422\r
-#define LINES_PER_FRAME 260\r
-#define CPU_CLOCKS 3993624\r
-#define SCREEN_WIDTH 640\r
-#define SCREEN_HEIGHT 400\r
-#define MAX_DRIVE 2\r
-#define UPD765A_NO_ST1_EN_OR_FOR_RESULT7\r
-#ifdef SUPPORT_PC88_OPNA\r
-#define HAS_YM2608\r
-#endif\r
-#define Z80_MEMORY_WAIT\r
-#define PCM1BIT_HIGH_QUALITY\r
-#define OVERRIDE_SOUND_FREQ_48000HZ 55467\r
-#define SUPPORT_VARIABLE_TIMING\r
-\r
-// device informations for win32\r
-#if defined(_PC8001SR)\r
-#define USE_BOOT_MODE 3\r
-#else\r
-#define USE_BOOT_MODE 4\r
-#endif\r
-#define USE_CPU_TYPE 2\r
-#define USE_DIPSWITCH\r
-#define USE_DEVICE_TYPE 2\r
-#define USE_FD1\r
-#define USE_FD2\r
-#define USE_TAPE\r
-#define NOTIFY_KEY_DOWN\r
-#define USE_SHIFT_NUMPAD_KEY\r
-#define USE_ALT_F10_KEY\r
-// slow enough for N88-\93ú\96{\8cêBASIC\r
-#define USE_AUTO_KEY 8\r
-#define USE_AUTO_KEY_RELEASE 10\r
-#define USE_MONITOR_TYPE 2\r
-#define USE_CRT_FILTER\r
-#define USE_SCANLINE\r
-#define USE_ACCESS_LAMP\r
-#define USE_DEBUGGER\r
-#define USE_STATE\r
-\r
-#include "../../common.h"\r
-\r
-class EMU;\r
-class DEVICE;\r
-class EVENT;\r
-\r
-class BEEP;\r
-class I8251;\r
-class I8255;\r
-class PCM1BIT;\r
-class UPD1990A;\r
-class YM2203;\r
-class Z80;\r
-\r
-class PC80S31K;\r
-class UPD765A;\r
-\r
-#ifdef SUPPORT_PC88_PCG8100\r
-class I8253;\r
-#endif\r
-\r
-class PC88;\r
-\r
-class FILEIO;\r
-\r
-class VM\r
-{\r
-protected:\r
- EMU* emu;\r
- \r
- // devices\r
- EVENT* pc88event;\r
- \r
- BEEP* pc88beep;\r
- I8251* pc88sio;\r
- I8255* pc88pio;\r
- PCM1BIT* pc88pcm;\r
- UPD1990A* pc88rtc;\r
- YM2203* pc88opn;\r
- Z80* pc88cpu;\r
- \r
- PC80S31K* pc88sub;\r
- I8255* pc88pio_sub;\r
- UPD765A* pc88fdc_sub;\r
- Z80* pc88cpu_sub;\r
- \r
-#ifdef SUPPORT_PC88_PCG8100\r
- I8253* pc88pit;\r
- PCM1BIT* pc88pcm0;\r
- PCM1BIT* pc88pcm1;\r
- PCM1BIT* pc88pcm2;\r
-#endif\r
- \r
- PC88* pc88;\r
- \r
- int boot_mode;\r
- \r
-public:\r
- // ----------------------------------------\r
- // initialize\r
- // ----------------------------------------\r
- \r
- VM(EMU* parent_emu);\r
- ~VM();\r
- \r
- // ----------------------------------------\r
- // for emulation class\r
- // ----------------------------------------\r
- \r
- // drive virtual machine\r
- void reset();\r
- void run();\r
- double frame_rate();\r
- \r
-#ifdef USE_DEBUGGER\r
- // debugger\r
- DEVICE *get_cpu(int index);\r
-#endif\r
- \r
- // draw screen\r
- void draw_screen();\r
- int access_lamp();\r
- \r
- // sound generation\r
- void initialize_sound(int rate, int samples);\r
- uint16* create_sound(int* extra_frames);\r
- int sound_buffer_ptr();\r
- \r
- // notify key\r
- void key_down(int code, bool repeat);\r
- void key_up(int code);\r
- \r
- // user interface\r
- void open_disk(int drv, _TCHAR* file_path, int offset);\r
- void close_disk(int drv);\r
- bool disk_inserted(int drv);\r
- void play_tape(_TCHAR* file_path);\r
- void rec_tape(_TCHAR* file_path);\r
- void close_tape();\r
- bool tape_inserted();\r
- bool now_skip();\r
- \r
- void update_config();\r
- void save_state(FILEIO* state_fio);\r
- bool load_state(FILEIO* state_fio);\r
- \r
- // ----------------------------------------\r
- // for each device\r
- // ----------------------------------------\r
- \r
- // devices\r
- DEVICE* get_device(int id);\r
- DEVICE* dummy;\r
- DEVICE* first_device;\r
- DEVICE* last_device;\r
-};\r
-\r
-#endif\r
+/*
+ NEC PC-8801MA Emulator 'ePC-8801MA'
+ NEC PC-8001mkIISR Emulator 'ePC-8001mkIISR'
+
+ Author : Takeda.Toshiya
+ Date : 2012.02.16-
+
+ [ virtual machine ]
+*/
+
+#ifndef _PC8801_H_
+#define _PC8801_H_
+
+#if defined(_PC8801MA)
+#define DEVICE_NAME "NEC PC-8801MA"
+#define CONFIG_NAME "pc8801ma"
+#elif defined(_PC8001SR)
+#define DEVICE_NAME "NEC PC-8001mkIISR"
+#define CONFIG_NAME "pc8001mk2sr"
+#endif
+
+#if defined(_PC8001SR)
+#define MODE_PC80_V1 0
+#define MODE_PC80_V2 1
+#define MODE_PC80_N 2
+#else
+#define MODE_PC88_V1S 0
+#define MODE_PC88_V1H 1
+#define MODE_PC88_V2 2
+#define MODE_PC88_N 3
+#endif
+
+#if defined(_PC8801MA)
+#define SUPPORT_PC88_DICTIONARY
+#define SUPPORT_PC88_HIGH_CLOCK
+#define SUPPORT_PC88_OPNA
+#define SUPPORT_PC88_SB2
+#define PC88_EXRAM_BANKS 4
+#define HAS_UPD4990A
+#endif
+#define SUPPORT_PC88_JOYSTICK
+#define SUPPORT_PC88_PCG8100
+
+// device informations for virtual machine
+#define FRAMES_PER_SEC 62.422
+#define LINES_PER_FRAME 260
+#define CPU_CLOCKS 3993624
+#define SCREEN_WIDTH 640
+#define SCREEN_HEIGHT 400
+#define WINDOW_HEIGHT_ASPECT 480
+#define MAX_DRIVE 2
+#define UPD765A_NO_ST1_EN_OR_FOR_RESULT7
+#if defined(_PC8801MA)
+#define PC80S31K_NO_WAIT
+#endif
+#if defined(SUPPORT_PC88_OPNA) || defined(SUPPORT_PC88_SB2)
+#define HAS_YM2608
+#endif
+#define Z80_MEMORY_WAIT
+#define OVERRIDE_SOUND_FREQ_48000HZ 55467
+#define SUPPORT_VARIABLE_TIMING
+
+// device informations for win32
+#if defined(_PC8001SR)
+#define USE_BOOT_MODE 3
+#define USE_CPU_TYPE 2
+#else
+#define USE_BOOT_MODE 4
+#define USE_CPU_TYPE 3
+#endif
+#if defined(_PC8801MA)
+// V2 mode, 4MHz
+#define BOOT_MODE_DEFAULT 2
+#define CPU_TYPE_DEFAULT 1
+#endif
+#define USE_DIPSWITCH
+#define USE_JOYSTICK_TYPE 2
+#define USE_FLOPPY_DISK 2
+#define USE_TAPE 1
+#define TAPE_BINARY_ONLY
+#define NOTIFY_KEY_DOWN
+#define USE_KEY_LOCKED
+#define USE_SHIFT_NUMPAD_KEY
+#define USE_ALT_F10_KEY
+// slow enough for N88-\93ú\96{\8cêBASIC
+#define USE_AUTO_KEY 8
+#define USE_AUTO_KEY_RELEASE 10
+#define USE_AUTO_KEY_NUMPAD
+#define USE_MONITOR_TYPE 2
+#define USE_SCREEN_FILTER
+#define USE_SCANLINE
+#ifdef SUPPORT_PC88_OPNA
+#ifdef SUPPORT_PC88_SB2
+#define USE_SOUND_TYPE 6
+#else
+#define USE_SOUND_TYPE 2
+#endif
+#endif
+#if defined(SUPPORT_PC88_OPNA) && defined(SUPPORT_PC88_SB2) && defined(SUPPORT_PC88_PCG8100)
+#define USE_SOUND_VOLUME (4 + 4 + 1 + 1 + 1)
+#elif defined(SUPPORT_PC88_OPNA) && defined(SUPPORT_PC88_SB2) && !defined(SUPPORT_PC88_PCG8100)
+#define USE_SOUND_VOLUME (4 + 4 + 0 + 1 + 1)
+#elif defined(SUPPORT_PC88_OPNA) && !defined(SUPPORT_PC88_SB2) && defined(SUPPORT_PC88_PCG8100)
+#define USE_SOUND_VOLUME (4 + 0 + 1 + 1 + 1)
+#elif defined(SUPPORT_PC88_OPNA) && !defined(SUPPORT_PC88_SB2) && !defined(SUPPORT_PC88_PCG8100)
+#define USE_SOUND_VOLUME (4 + 0 + 0 + 1 + 1)
+#elif !defined(SUPPORT_PC88_OPNA) && defined(SUPPORT_PC88_SB2) && defined(SUPPORT_PC88_PCG8100)
+#define USE_SOUND_VOLUME (2 + 2 + 1 + 1 + 1)
+#elif !defined(SUPPORT_PC88_OPNA) && defined(SUPPORT_PC88_SB2) && !defined(SUPPORT_PC88_PCG8100)
+#define USE_SOUND_VOLUME (2 + 2 + 0 + 1 + 1)
+#elif !defined(SUPPORT_PC88_OPNA) && !defined(SUPPORT_PC88_SB2) && defined(SUPPORT_PC88_PCG8100)
+#define USE_SOUND_VOLUME (2 + 0 + 1 + 1 + 1)
+#elif !defined(SUPPORT_PC88_OPNA) && !defined(SUPPORT_PC88_SB2) && !defined(SUPPORT_PC88_PCG8100)
+#define USE_SOUND_VOLUME (2 + 0 + 0 + 1 + 1)
+#endif
+
+#define SUPPORT_TV_RENDER
+#define USE_JOYSTICK
+#define USE_MOUSE
+#define USE_PRINTER
+#define USE_PRINTER_TYPE 3
+#define USE_DEBUGGER
+#define USE_STATE
+#define USE_CPU_Z80
+
+#include "../../common.h"
+#include "../../fileio.h"
+#include "../vm_template.h"
+
+#ifdef USE_SOUND_VOLUME
+static const _TCHAR *sound_device_caption[] = {
+#ifdef SUPPORT_PC88_OPNA
+ _T("OPNA (FM)"), _T("OPNA (PSG)"), _T("OPNA (ADPCM)"), _T("OPNA (Rhythm)"),
+#else
+ _T("OPN (FM)"), _T("OPN (PSG)"),
+#endif
+#ifdef SUPPORT_PC88_SB2
+#ifdef SUPPORT_PC88_OPNA
+ _T("SB2 (FM)"), _T("SB2 (PSG)"), _T("SB2 (ADPCM)"), _T("SB2 (Rhythm)"),
+#else
+ _T("SB2 (FM)"), _T("SB2 (PSG)"),
+#endif
+#endif
+#ifdef SUPPORT_PC88_PCG8100
+ _T("PCG-8100"),
+#endif
+ _T("Beep"), _T("Noise (FDD)"),
+};
+#endif
+
+class EMU;
+class DEVICE;
+class EVENT;
+
+class I8251;
+class I8255;
+class NOISE;
+class PCM1BIT;
+class UPD1990A;
+class YM2203;
+class Z80;
+
+class PC80S31K;
+class UPD765A;
+
+#ifdef SUPPORT_PC88_PCG8100
+class I8253;
+#endif
+namespace PC88DEV {
+ class PC88;
+}
+class VM : public VM_TEMPLATE
+{
+protected:
+ //EMU* emu;
+ //csp_state_utils* state_entry;
+
+ // devices
+ EVENT* pc88event;
+
+ DEVICE* pc88prn;
+ I8251* pc88sio;
+ I8255* pc88pio;
+ PCM1BIT* pc88pcm;
+ UPD1990A* pc88rtc;
+ YM2203* pc88opn;
+#ifdef SUPPORT_PC88_SB2
+ YM2203* pc88sb2;
+#endif
+ DEVICE* dummycpu;
+ Z80* pc88cpu;
+
+ PC80S31K* pc88sub;
+ I8255* pc88pio_sub;
+ UPD765A* pc88fdc_sub;
+ NOISE* pc88noise_seek;
+ NOISE* pc88noise_head_down;
+ NOISE* pc88noise_head_up;
+ Z80* pc88cpu_sub;
+#ifdef SUPPORT_PC88_PCG8100
+ I8253* pc88pit;
+ PCM1BIT* pc88pcm0;
+ PCM1BIT* pc88pcm1;
+ PCM1BIT* pc88pcm2;
+#endif
+
+ PC88DEV::PC88* pc88;
+
+ int boot_mode;
+
+public:
+ // ----------------------------------------
+ // initialize
+ // ----------------------------------------
+
+ VM(EMU* parent_emu);
+ ~VM();
+
+ // ----------------------------------------
+ // for emulation class
+ // ----------------------------------------
+
+ // drive virtual machine
+ void reset();
+ void run();
+ double get_frame_rate();
+
+#ifdef USE_DEBUGGER
+ // debugger
+ DEVICE *get_cpu(int index);
+#endif
+
+ // draw screen
+ void draw_screen();
+
+ // sound generation
+ void initialize_sound(int rate, int samples);
+ uint16_t* create_sound(int* extra_frames);
+ int get_sound_buffer_ptr();
+#ifdef USE_SOUND_VOLUME
+ void set_sound_device_volume(int ch, int decibel_l, int decibel_r);
+#endif
+
+ // notify key
+ void key_down(int code, bool repeat);
+ void key_up(int code);
+ bool get_caps_locked();
+ bool get_kana_locked();
+
+ // user interface
+ void open_floppy_disk(int drv, const _TCHAR* file_path, int bank);
+ void close_floppy_disk(int drv);
+ bool is_floppy_disk_inserted(int drv);
+ void is_floppy_disk_protected(int drv, bool value);
+ bool is_floppy_disk_protected(int drv);
+ uint32_t is_floppy_disk_accessed();
+ void play_tape(int drv, const _TCHAR* file_path);
+ void rec_tape(int drv, const _TCHAR* file_path);
+ void close_tape(int drv);
+ bool is_tape_inserted(int drv);
+ bool is_frame_skippable();
+
+ void update_config();
+ bool process_state(FILEIO* state_fio, bool loading);
+
+ // ----------------------------------------
+ // for each device
+ // ----------------------------------------
+
+ // devices
+ DEVICE* get_device(int id);
+ //DEVICE* dummy;
+ //DEVICE* first_device;
+ //DEVICE* last_device;
+};
+
+#endif