OSDN Git Service

[VM] Add PC-8001/mk2/8801/mk2.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc8801 / pc88.h
index a818307..497b33d 100644 (file)
@@ -1,7 +1,11 @@
 /*
-       NEC PC-98DO Emulator 'ePC-98DO'
-       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'
+       NEC PC-98DO Emulator 'ePC-98DO'
 
        Author : Takeda.Toshiya
        Date   : 2011.12.29-
 #include "../device.h"
 
 #define SIG_PC88_USART_IRQ     0
-#define SIG_PC88_SOUND_IRQ     1
-#ifdef SUPPORT_PC88_SB2
-#define SIG_PC88_SB2_IRQ       2
+#ifdef SUPPORT_PC88_OPN1
+#define SIG_PC88_OPN1_IRQ      1
+#endif
+#ifdef SUPPORT_PC88_OPN2
+#define SIG_PC88_OPN2_IRQ      2
+#endif
+#ifdef SUPPORT_PC88_CDROM
+#define SIG_PC88_SCSI_DRQ      3
 #endif
-#define SIG_PC88_USART_OUT     3
+#define SIG_PC88_USART_OUT     4
 
 #define CMT_BUFFER_SIZE                0x40000
 
-#if defined(_PC8001SR) && !defined(PC88_EXRAM_BANKS)
-#define PC88_EXRAM_BANKS       1
-#endif
-
-#if !defined(_PC8001SR)
+#if defined(PC8801_VARIANT)
 #define NIPPY_PATCH
 #endif
 
+#if defined(SUPPORT_PC88_OPN1) || defined(SUPPORT_PC88_OPN2)
 class YM2203;
+#endif
 class Z80;
+#ifdef SUPPORT_PC88_CDROM
+class SCSI_HOST;
+class SCSI_CDROM;
+#endif
 
 namespace PC88DEV {
 typedef struct {
@@ -102,12 +113,21 @@ typedef struct {
 class PC88 : public DEVICE
 {
 private:
-       YM2203 *d_opn;
-#ifdef SUPPORT_PC88_SB2
-       YM2203 *d_sb2;
+#ifdef SUPPORT_PC88_OPN1
+       YM2203 *d_opn1;
+#endif
+#ifdef SUPPORT_PC88_OPN2
+       YM2203 *d_opn2;
 #endif
        Z80 *d_cpu;
        DEVICE *d_pcm, *d_pio, *d_prn, *d_rtc, *d_sio;
+#ifdef SUPPORT_PC88_CDROM
+       SCSI_HOST* d_scsi_host;
+       SCSI_CDROM* d_scsi_cdrom;
+#endif
+#ifdef SUPPORT_PC88_HMB20
+       DEVICE *d_opm;
+#endif
 #ifdef SUPPORT_PC88_PCG8100
        DEVICE *d_pcg_pit, *d_pcg_pcm0, *d_pcg_pcm1, *d_pcg_pcm2;
 #endif
@@ -123,20 +143,32 @@ private:
 #endif
        uint8_t gvram[0xc000];
        uint8_t gvram_null[0x4000];
+#if defined(PC8801SR_VARIANT)
        uint8_t tvram[0x1000];
+#endif
+#if defined(PC8001_VARIANT)
+       uint8_t n80rom[0x8000];
 #if defined(_PC8001SR)
-       uint8_t n80mk2rom[0x8000];
-       uint8_t n80mk2srrom[0xa000];
+       uint8_t n80srrom[0xa000];
+#endif
 #else
        uint8_t n88rom[0x8000];
        uint8_t n88exrom[0x8000];
        uint8_t n80rom[0x8000];
 #endif
+//#ifdef SUPPORT_PC88_KANJI1
        uint8_t kanji1[0x20000];
+//#endif
+#ifdef SUPPORT_PC88_KANJI2
        uint8_t kanji2[0x20000];
+#endif
 #ifdef SUPPORT_PC88_DICTIONARY
        uint8_t dicrom[0x80000];
 #endif
+#ifdef SUPPORT_PC88_CDROM
+       uint8_t cdbios[0x10000];
+       bool cdbios_loaded;
+#endif
        
        // i/o port
        uint8_t port[256];
@@ -145,23 +177,30 @@ private:
        pc88_dmac_t dmac;
        
        // memory mapper
+#if defined(_PC8001SR) || defined(PC8801SR_VARIANT)
        uint8_t alu_reg[3];
+#endif
        uint8_t gvram_plane, gvram_sel;
        
        void update_timing();
        int get_m1_wait(bool addr_f000);
        int get_main_wait(bool read);
+#if defined(PC8801SR_VARIANT)
        int get_tvram_wait(bool read);
+#endif
        int get_gvram_wait(bool read);
        void update_gvram_wait();
        void update_gvram_sel();
-#if defined(_PC8001SR)
+#if defined(PC8001_VARIANT)
        void update_n80_write();
        void update_n80_read();
 #else
-       void update_low_memmap();
+       void update_low_write();
+       void update_low_read();
+#if defined(PC8801SR_VARIANT)
        void update_tvram_memmap();
 #endif
+#endif
        
        // cpu
        bool cpu_clock_low;
@@ -172,14 +211,17 @@ private:
        int m1_wait_clocks;
        int f000_m1_wait_clocks;
        int mem_wait_clocks_r, mem_wait_clocks_w;
+#if defined(PC8801SR_VARIANT)
        int tvram_wait_clocks_r, tvram_wait_clocks_w;
+#endif
        int gvram_wait_clocks_r, gvram_wait_clocks_w;
        int busreq_clocks;
        
        // screen
-       struct {
+       typedef struct palette_s {
                uint8_t b, r, g;
-       } palette[9];
+       } palette_t;
+       palette_t palette[10]; // 8 = digital back color, 9 = analog back color
        bool update_palette;
        bool hireso;
        
@@ -188,21 +230,28 @@ private:
        uint8_t text_color[200][80];
        bool text_reverse[200][80];
        uint8_t graph[400][640];
-       scrntype_t palette_text_pc[9];  // 0 = back color for attrib mode, 8 = black
-       scrntype_t palette_graph_pc[9];
-       scrntype_t line_palette_text_pc[400][9];
-       scrntype_t line_palette_graph_pc[400][9];
+       
+       palette_t palette_digital[9];
+       palette_t palette_analog [9];
+       palette_t palette_line_digital[400][9];
+       palette_t palette_line_analog [400][9];
+       bool palette_line_changed[400];
+#if defined(SUPPORT_PC88_VAB)
+       scrntype_t palette_vab_pc[0x10000];
+#endif
        
        void draw_text();
+#if defined(PC8001_VARIANT)
 #if defined(_PC8001SR)
        bool draw_320x200_color_graph();
+#endif
        bool draw_320x200_4color_graph();
        void draw_320x200_attrib_graph();
 #endif
        bool draw_640x200_color_graph();
        void draw_640x200_mono_graph();
        void draw_640x200_attrib_graph();
-#if !defined(_PC8001SR)
+#if defined(PC8801SR_VARIANT)
        void draw_640x400_mono_graph();
        void draw_640x400_attrib_graph();
 #endif
@@ -228,9 +277,11 @@ private:
        
        // intterrupt
        uint8_t intr_req;
-       bool intr_req_sound;
-#ifdef SUPPORT_PC88_SB2
-       bool intr_req_sb2;
+#ifdef SUPPORT_PC88_OPN1
+       bool intr_req_opn1;
+#endif
+#ifdef SUPPORT_PC88_OPN2
+       bool intr_req_opn2;
 #endif
        uint8_t intr_mask1, intr_mask2;
        void request_intr(int level, bool status);
@@ -258,6 +309,11 @@ private:
        uint8_t pcg_pattern[0x800];
 #endif
        
+#ifdef SUPPORT_PC88_CDROM
+       int cdda_register_id;
+       double cdda_volume;
+#endif
+       
 #ifdef NIPPY_PATCH
        // dirty patch for NIPPY
        bool nippy_patch;
@@ -265,7 +321,7 @@ private:
 public:
        PC88(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
-#if defined(_PC8001SR)
+#if defined(PC8001_VARIANT)
                set_device_name(_T("PC-8001 Core"));
 #else
                set_device_name(_T("PC-8801 Core"));
@@ -288,6 +344,7 @@ public:
 #endif
        
        uint32_t read_dma_data8(uint32_t addr);
+       void write_dma_data8(uint32_t addr, uint32_t data);
        void write_dma_io8(uint32_t addr, uint32_t data);
        
        void write_signal(int id, uint32_t data, uint32_t mask);
@@ -299,26 +356,26 @@ public:
        bool process_state(FILEIO* state_fio, bool loading);
        
        // unique functions
+#ifdef PC8801SR_VARIANT
        bool is_sr_mr()
        {
-#if !defined(_PC8001SR)
                return (n88rom[0x79d7] < 0x38);
-#else
-               return true;
-#endif
        }
+#endif
        void set_context_cpu(Z80* device)
        {
                d_cpu = device;
        }
-       void set_context_opn(YM2203* device)
+#ifdef SUPPORT_PC88_OPN1
+       void set_context_opn1(YM2203* device)
        {
-               d_opn = device;
+               d_opn1 = device;
        }
-#ifdef SUPPORT_PC88_SB2
-       void set_context_sb2(YM2203* device)
+#endif
+#ifdef SUPPORT_PC88_OPN2
+       void set_context_opn2(YM2203* device)
        {
-               d_sb2 = device;
+               d_opn2 = device;
        }
 #endif
        void set_context_pcm(DEVICE* device)
@@ -341,6 +398,22 @@ public:
        {
                d_sio = device;
        }
+#ifdef SUPPORT_PC88_CDROM
+       void set_context_scsi_host(SCSI_HOST* device)
+       {
+               d_scsi_host = device;
+       }
+       void set_context_scsi_cdrom(SCSI_CDROM* device)
+       {
+               d_scsi_cdrom = device;
+       }
+#endif
+#ifdef SUPPORT_PC88_HMB20
+       void set_context_opm(DEVICE* device)
+       {
+               d_opm = device;
+       }
+#endif
 #ifdef SUPPORT_PC88_PCG8100
        void set_context_pcg_pit(DEVICE* device)
        {