OSDN Git Service

[VM] Add PC-8001/mk2/8801/mk2.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc8801 / pc8801.h
index ae0fb0a..3b73723 100644 (file)
@@ -1,6 +1,10 @@
 /*
-       NEC PC-8801MA Emulator 'ePC-8801MA'
+       NEC PC-8001 Emulator 'ePC-8001'
+       NEC PC-8001mkII Emulator 'ePC-8001mkII'
        NEC PC-8001mkIISR Emulator 'ePC-8001mkIISR'
+       NEC PC-8801 Emulator 'ePC-8801'
+       NEC PC-8801mkII Emulator 'ePC-8801mkII'
+       NEC PC-8801MA Emulator 'ePC-8801MA'
 
        Author : Takeda.Toshiya
        Date   : 2012.02.16-
 #if defined(_PC8801MA)
 #define DEVICE_NAME            "NEC PC-8801MA"
 #define CONFIG_NAME            "pc8801ma"
+#elif defined(_PC8801MK2)
+#define DEVICE_NAME            "NEC PC-8801mkII"
+#define CONFIG_NAME            "pc8801mk2"
+#elif defined(_PC8801)
+#define DEVICE_NAME            "NEC PC-8801"
+#define CONFIG_NAME            "pc8801"
 #elif defined(_PC8001SR)
 #define DEVICE_NAME            "NEC PC-8001mkIISR"
 #define CONFIG_NAME            "pc8001mk2sr"
+#elif defined(_PC8001MK2)
+#define DEVICE_NAME            "NEC PC-8001mkII"
+#define CONFIG_NAME            "pc8001mk2"
+#elif defined(_PC8001)
+#define DEVICE_NAME            "NEC PC-8001"
+#define CONFIG_NAME            "pc8001"
+#endif
+
+#if defined(_PC8001) || defined(_PC8001MK2) || defined(_PC8001SR)
+#define PC8001_VARIANT
+#else
+#define PC8801_VARIANT
+#endif
+#if defined(_PC8801MA)
+#define PC8801SR_VARIANT
 #endif
 
-#if defined(_PC8001SR)
-#define MODE_PC80_V1   0
-#define MODE_PC80_V2   1
-#define MODE_PC80_N    2
+#if defined(PC8001_VARIANT)
+       #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
+       #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
-# ifndef _CONFIGURE_WITH_CMAKE
-#  define SUPPORT_PC88_SB2
-#  define SUPPORT_PC88_OPNA
-#  define PC88_EXRAM_BANKS     4
-# endif
-#define HAS_UPD4990A
-#endif
-#define SUPPORT_PC88_JOYSTICK
-# ifndef _CONFIGURE_WITH_CMAKE
-#  define SUPPORT_PC88_PCG8100
-# endif
+       #define SUPPORT_PC88_KANJI1
+       #define SUPPORT_PC88_KANJI2
+       #define SUPPORT_PC88_DICTIONARY
+       #define SUPPORT_PC88_HIGH_CLOCK
+       #define SUPPORT_PC88_OPN1
+       #define SUPPORT_PC88_OPN2
+       #define SUPPORT_PC88_OPNA
+       #define SUPPORT_PC88_CDROM
+       #define SUPPORT_PC88_VAB
+       #define SUPPORT_PC88_HMB20
+       #define SUPPORT_PC88_JOYSTICK
+       #if defined(SUPPORT_PC88_VAB)
+               // X88000
+               #define PC88_EXRAM_BANKS        8
+               #define PC88_VAB_PAGE           1
+       #else
+               #define PC88_EXRAM_BANKS        4
+       #endif
+       #define HAS_UPD4990A
+#elif defined(_PC8801MK2)
+       #define SUPPORT_PC88_KANJI1
+//     #define SUPPORT_PC88_KANJI2
+       #define SUPPORT_PC88_OPN2
+       #define SUPPORT_PC88_OPNA
+#elif defined(_PC8801)
+       #define SUPPORT_PC88_KANJI1
+//     #define SUPPORT_PC88_KANJI2
+//     #define SUPPORT_PC88_OPN2
+//     #define SUPPORT_PC88_OPNA
+#elif defined(_PC8001SR)
+       #define SUPPORT_PC88_KANJI1
+//     #define SUPPORT_PC88_KANJI2
+       #define SUPPORT_PC88_OPN1
+       #define SUPPORT_PC88_OPN2
+       #define SUPPORT_PC88_OPNA
+       #define PC88_EXRAM_BANKS        1
+#elif defined(_PC8001MK2)
+       #define SUPPORT_PC88_KANJI1
+//     #define SUPPORT_PC88_KANJI2
+       #define SUPPORT_PC88_OPN2
+       #define SUPPORT_PC88_OPNA
+       #define PC88_EXRAM_BANKS        1
+#elif defined(_PC8001)
+//     #define SUPPORT_PC88_KANJI1
+//     #define SUPPORT_PC88_KANJI2
+//     #define SUPPORT_PC88_OPN2
+//     #define SUPPORT_PC88_OPNA
+#endif
+#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)
+#if defined(PC8801_VARIANT)
 #define PC80S31K_NO_WAIT
 #endif
-#ifdef SUPPORT_PC88_OPNA
-#define HAS_YM2608
+#if defined(SUPPORT_PC88_CDROM)
+#define SCSI_HOST_AUTO_ACK
+#define SCSI_DEV_IMMEDIATE_SELECT
 #endif
 #define Z80_MEMORY_WAIT
 #define OVERRIDE_SOUND_FREQ_48000HZ    55467
-#define SUPPORT_VARIABLE_TIMING
 
-// 4:3
-#define SCREEN_WIDTH_ASPECT 640 
-#define SCREEN_HEIGHT_ASPECT 400
-#define WINDOW_WIDTH_ASPECT 640 
-#define WINDOW_HEIGHT_ASPECT 480
-// device informations for win32
 // device informations for win32
-#if defined(_PC8001SR)
+#if defined(PC8001_VARIANT)
 #define USE_BOOT_MODE          3
 #define USE_CPU_TYPE           2
 #else
 #define CPU_TYPE_DEFAULT       1
 #endif
 #define USE_DIPSWITCH
-#define USE_DEVICE_TYPE                2
-#define USE_FD1
-#define USE_FD2
-#define USE_TAPE
-#define USE_TAPE_PTR
+#define USE_JOYSTICK_TYPE      2
+#define USE_FLOPPY_DISK                2
+#define USE_TAPE               1
 #define TAPE_BINARY_ONLY
-#define NOTIFY_KEY_DOWN
-#define USE_SHIFT_NUMPAD_KEY
-#define USE_ALT_F10_KEY
+#if defined(SUPPORT_PC88_CDROM)
+#define USE_COMPACT_DISC       1
+#endif
+#define USE_KEY_LOCKED
 // 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_CRT_FILTER
+#define USE_SCREEN_FILTER
 #define USE_SCANLINE
-#define USE_SCREEN_ROTATE
-#define USE_ACCESS_LAMP
-#define USE_DISK_WRITE_PROTECT
-
-#ifdef SUPPORT_PC88_SB2
-#  define USE_SOUND_DEVICE_TYPE        3
-#elif defined(SUPPORT_PC88_OPNA)
-#  define USE_SOUND_DEVICE_TYPE        2
-#endif
-
-#if defined(DATAREC_SOUND)
-# if defined(SUPPORT_PC88_OPNA)
-#  define USE_MULTIPLE_SOUNDCARDS 3
-# else
-#  define USE_MULTIPLE_SOUNDCARDS 2
-# endif
+
+#if defined(_PC8801MA)
+       #define USE_SOUND_TYPE          6       // OPNA,OPN,OPN+OPNA,OPN+OPN,OPNA+OPNA,OPNA+OPN
+#elif defined(_PC8001SR)
+       #define USE_SOUND_TYPE          3       // OPN,OPN+OPN,OPN+OPNA
+#elif defined(_PC8001MK2) || defined(_PC8801MK2)
+       #define USE_SOUND_TYPE          3       // None,OPN,OPNA
+#endif
+#if defined(SUPPORT_PC88_OPN1)
+       #if defined(SUPPORT_PC88_OPNA)
+               #define SOUND_VOLUME_OPN1       4
+       #else
+               #define SOUND_VOLUME_OPN1       2
+       #endif
+#else
+       #define SOUND_VOLUME_OPN1       0
+#endif
+#if defined(SUPPORT_PC88_OPN2)
+       #if defined(SUPPORT_PC88_OPNA)
+               #define SOUND_VOLUME_OPN2       4
+       #else
+               #define SOUND_VOLUME_OPN2       2
+       #endif
+#else
+       #define SOUND_VOLUME_OPN2       0
+#endif
+ #if defined(SUPPORT_PC88_CDROM)
+#define SOUND_VOLUME_CDROM     1
+       #define SOUND_VOLUME_CDROM      1
+#else
+       #define SOUND_VOLUME_CDROM      0
+#endif
+#if defined(SUPPORT_PC88_HMB20)
+       #define SOUND_VOLUME_HMB20      1
 #else
-# if defined(SUPPORT_PC88_OPNA)
-#  define USE_MULTIPLE_SOUNDCARDS 2
-# else
-#  define USE_MULTIPLE_SOUNDCARDS 1
-# endif
+       #define SOUND_VOLUME_HMB20      0
 #endif
-//#define USE_DEBUGGER
+#if defined(SUPPORT_PC88_PCG8100)
+       #define SOUND_VOLUME_PCG8100    1
+#else
+       #define SOUND_VOLUME_PCG8100    0
+#endif
+#define USE_SOUND_VOLUME       (SOUND_VOLUME_OPN1 + SOUND_VOLUME_OPN2 + SOUND_VOLUME_CDROM + SOUND_VOLUME_HMB20 + SOUND_VOLUME_PCG8100 + 1 + 1)
+
+#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[USE_SOUND_VOLUME] = {
+#ifdef SUPPORT_PC88_OPN1
+       _T("OPN1 (FM)"), _T("OPN1 (PSG)"),
+#ifdef SUPPORT_PC88_OPNA
+       _T("OPN1 (ADPCM)"), _T("OPN1 (Rhythm)"),
+#endif
+#endif
+#ifdef SUPPORT_PC88_OPN2
+       _T("OPN2 (FM)"), _T("OPN2 (PSG)"),
+#ifdef SUPPORT_PC88_OPNA
+       _T("OPN2 (ADPCM)"), _T("OPN2 (Rhythm)"),
+#endif
+#endif
+#ifdef SUPPORT_PC88_CDROM
+       _T("CD-DA"),
+#endif
+#ifdef SUPPORT_PC88_HMB20
+       _T("HMB-20"),
+#endif
+#ifdef SUPPORT_PC88_PCG8100
+       _T("PCG-8100"),
+#endif
+       _T("Beep"), _T("Noise (FDD)"),
+};
+#endif
 
 class EMU;
 class DEVICE;
@@ -132,43 +244,71 @@ class EVENT;
 
 class I8251;
 class I8255;
+class NOISE;
 class PCM1BIT;
 class UPD1990A;
+#if defined(SUPPORT_PC88_OPN1) || defined(SUPPORT_PC88_OPN2)
 class YM2203;
+#endif
 class Z80;
 
 class PC80S31K;
 class UPD765A;
 
-#ifdef SUPPORT_PC88_PCG8100
-class I8253;
+#ifdef SUPPORT_PC88_CDROM
+class SCSI_HOST;
+class SCSI_CDROM;
 #endif
 
-class PC88;
+#ifdef SUPPORT_PC88_HMB20
+class YM2151;
+#endif
 
-class VM
+#ifdef SUPPORT_PC88_PCG8100
+class I8253;
+#endif
+namespace PC88DEV {
+       class PC88;
+}
+class VM : public VM_TEMPLATE
 {
 protected:
-       EMU* emu;
+       //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;
+#ifdef SUPPORT_PC88_OPN1
+       YM2203* pc88opn1;
+#endif
+#ifdef SUPPORT_PC88_OPN2
+       YM2203* pc88opn2;
 #endif
+       DEVICE* dummycpu;
        Z80* pc88cpu;
-       DEVICE *dummycpu;
-   
+       
        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_CDROM
+       SCSI_HOST* pc88scsi_host;
+       SCSI_CDROM* pc88scsi_cdrom;
+#endif
+
+#ifdef SUPPORT_PC88_HMB20
+       YM2151* pc88opm;
+#endif
        
 #ifdef SUPPORT_PC88_PCG8100
        I8253* pc88pit;
@@ -177,7 +317,7 @@ protected:
        PCM1BIT* pc88pcm2;
 #endif
        
-       PC88* pc88;
+       PC88DEV::PC88* pc88;
        
        int boot_mode;
        
@@ -196,7 +336,7 @@ public:
        // drive virtual machine
        void reset();
        void run();
-       double frame_rate();
+       double get_frame_rate();
        
 #ifdef USE_DEBUGGER
        // debugger
@@ -205,41 +345,52 @@ public:
        
        // draw screen
        void draw_screen();
-       int access_lamp();
        
        // sound generation
        void initialize_sound(int rate, int samples);
-       uint16* create_sound(int* extra_frames);
-       int sound_buffer_ptr();
+       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_disk(int drv, const _TCHAR* file_path, int bank);
-       void close_disk(int drv);
-       bool disk_inserted(int drv);
-       void set_disk_protected(int drv, bool value);
-       bool get_disk_protected(int drv);
-       void play_tape(const _TCHAR* file_path);
-       void rec_tape(const _TCHAR* file_path);
-       void close_tape();
-       bool tape_inserted();
-       bool now_skip();
+       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);
+#ifdef SUPPORT_PC88_CDROM
+       void open_compact_disc(int drv, const _TCHAR* file_path);
+       void close_compact_disc(int drv);
+       bool is_compact_disc_inserted(int drv);
+       uint32_t is_compact_disc_accessed();
+#endif
+       bool is_frame_skippable();
        
        void update_config();
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       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;
+       //DEVICE* dummy;
+       //DEVICE* first_device;
+       //DEVICE* last_device;
 };
 
 #endif