OSDN Git Service

[General] Merge Upstream 2018-12-27.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 12 Jan 2019 09:39:04 +0000 (18:39 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Sat, 12 Jan 2019 09:39:04 +0000 (18:39 +0900)
23 files changed:
source/history.txt
source/src/vm/common_vm/CMakeLists.txt
source/src/vm/fm7/display.cpp
source/src/vm/fm7/vram.cpp
source/src/vm/libcpu_newdev/libcpu_i386/i386_opdef.cpp
source/src/vm/libcpu_newdev/libcpu_i386/i386op32.cpp
source/src/vm/libcpu_newdev/libcpu_i386/i386ops.cpp
source/src/vm/libcpu_newdev/libcpu_i386/i486ops.cpp
source/src/vm/libcpu_newdev/libcpu_i386/pentops.cpp
source/src/vm/libcpu_newdev/libcpu_i386/readme_takeda.txt
source/src/vm/mame/emu/cpu/i386/i386.c
source/src/vm/mame/emu/cpu/i386/i386op32.c
source/src/vm/mame/emu/cpu/i386/i386ops.c
source/src/vm/mame/emu/cpu/i386/i486ops.c
source/src/vm/mame/emu/cpu/i386/pentops.c
source/src/vm/mame/emu/cpu/i386/readme_takeda.txt
source/src/vm/pc6001/memory.cpp
source/src/vm/pc6001/psub.cpp
source/src/vm/pc6001/psub.h
source/src/vm/pc8801/pc88.cpp
source/src/vm/pc8801/pc88.h
source/src/vm/pc8801/pc8801.cpp
source/src/vm/scsi_cdrom.h

index 10dd5d3..f5dc54d 100644 (file)
@@ -1,3 +1,24 @@
+12/27/2018
+
+[PC6001/PSUB] improve keyboard irq
+[PC8801/PC88] improve initial memory map when CD BIOS is loaded
+[PC8801/PC88] support CD-DA fade in/out
+
+
+12/18/2018
+
+[VM/I386] improve i386 core based on MAME 0.204
+[VM/SCSI_CDROM] improve vendor specific command for NEC CD-ROM^2
+[VM/SCSI_DEV] fix to write buffer when current command is not WRITE6/10/12
+[VM/SCSI_DEV] fix Request Sense command to get correct data length
+[VM/SCSI_HDD] fix not to write buffer when current command is not WRITE6/10/12
+
+[PC8801/PC88] improve initial memory map when CD BIOS is loaded
+[PC8801/PC88] revert screen renderer fixes in 12/1/2018 except scanline issues
+[PC8801/PC88] fix dmac registers to clear higher 16bits of pair32_t
+[PC8801/PC88] fix dmac to read i/o in verify mode
+
+
 12/9/2018
 
 [VM/SCSI_CDROM] add vendor specific command for NEC CD-ROM^2
index 58feb49..59c0b69 100644 (file)
@@ -1,6 +1,6 @@
 message("* vm/common_vm")
 
-SET(THIS_LIB_VERSION 2.5.0)
+SET(THIS_LIB_VERSION 2.5.1)
 
 #include(cotire)
 set(s_vm_common_vm_srcs
index 7952848..67fb752 100644 (file)
@@ -960,8 +960,8 @@ void DISPLAY::copy_vram_blank_area(void)
 void DISPLAY::copy_vram_per_line(int begin, int end)
 {
        uint32_t src_offset;
-       uint32_t yoff_d1;
-       uint32_t yoff_d2;
+       uint32_t yoff_d1 = 0;
+       uint32_t yoff_d2 = 0;
        uint32_t yoff_d;
        uint32_t poff = 0;
        uint32_t src_base;
index cd93bee..9b804e1 100644 (file)
@@ -355,7 +355,7 @@ void DISPLAY::draw_screen2()
                                if(text_width40) {
                                        xlim = 40;
                                } else {
-                                       ylim = 80;
+                                       xlim = 80;
                                }
                                
                                for(x = 0; x < xlim; x++) {
index ce8fc20..9fd5771 100644 (file)
@@ -131,8 +131,10 @@ void I386_OPS_BASE::i386_load_segment_descriptor( int segment )
                if (!V8086_MODE)
                {
                        i386_load_protected_mode_segment(&cpustate->sreg[segment], NULL );
-                       if(cpustate->sreg[segment].selector)
-                               i386_set_descriptor_accessed(cpustate->sreg[segment].selector);
+                       {
+                               i386_set_descriptor_accessed(cpustate, cpustate->sreg[segment].selector);
+                               cpustate->sreg[segment].flags |= 0x0001;
+                       }
                }
                else
                {
@@ -142,6 +144,8 @@ void I386_OPS_BASE::i386_load_segment_descriptor( int segment )
                        cpustate->sreg[segment].d = 0;
                        cpustate->sreg[segment].valid = true;
                }
+//             if (segment == CS && cpustate->sreg[segment].flags != old_flags)
+//                     debugger_privilege_hook();
        }
        else
        {
@@ -215,6 +219,7 @@ UINT32 I386_OPS_BASE::get_flags()
 
 void I386_OPS_BASE::set_flags( UINT32 f )
 {
+       f &= cpustate->eflags_mask;;
        cpustate->CF = (f & 0x1) ? 1 : 0;
        cpustate->PF = (f & 0x4) ? 1 : 0;
        cpustate->AF = (f & 0x10) ? 1 : 0;
@@ -233,7 +238,7 @@ void I386_OPS_BASE::set_flags( UINT32 f )
        cpustate->VIF = (f & 0x80000) ? 1 : 0;
        cpustate->VIP = (f & 0x100000) ? 1 : 0;
        cpustate->ID = (f & 0x200000) ? 1 : 0;
-       cpustate->eflags = f & cpustate->eflags_mask;
+       cpustate->eflags = f;
 }
 
 void I386_OPS_BASE::sib_byte(UINT8 mod, UINT32* out_ea, UINT8* out_segment)
index 2b140ab..bfc9acc 100644 (file)
@@ -325,7 +325,7 @@ void I386_OPS_BASE::I386OP(bsr_r32_rm32)()      // Opcode 0x0f bd
        } else {
                cpustate->ZF = 0;
                dst = temp = 31;
-               while( (src & (1 << temp)) == 0 ) {
+               while( (src & (1U << temp)) == 0 ) {
                        temp--;
                        dst = temp;
                        CYCLES(CYCLES_BSR);
index 9c0d346..8154856 100644 (file)
@@ -704,6 +704,8 @@ void I386_OPS_BASE::I386OP(mov_cr_r32)()        // Opcode 0x0f 22
                case 0:
                        data &= 0xfffeffff; // wp not supported on 386
                        CYCLES(CYCLES_MOV_REG_CR0);
+//                     if (PROTECTED_MODE != BIT(data, 0))
+//                             debugger_privilege_hook();
                        break;
                case 2: CYCLES(CYCLES_MOV_REG_CR2); break;
                case 3:
index 8de0354..aaf141b 100644 (file)
@@ -156,14 +156,16 @@ void I386_OPS_BASE::I486OP(xadd_rm8_r8)()   // Opcode 0x0f c0
        if( modrm >= 0xc0 ) {
                UINT8 dst = LOAD_RM8(modrm);
                UINT8 src = LOAD_REG8(modrm);
+               UINT8 sum = ADD8(cpustate, dst, src);
                STORE_REG8(modrm, dst);
-               STORE_RM8(modrm, dst + src);
+               STORE_RM8(modrm, sum);
                CYCLES(CYCLES_XADD_REG_REG);
        } else {
                UINT32 ea = GetEA(modrm, 1, 1);
                UINT8 dst = READ8(ea);
                UINT8 src = LOAD_REG8(modrm);
-               WRITE8(ea, dst + src);
+               UINT8 sum = ADD8(cpustate, dst, src);
+               WRITE8(ea, sum);
                STORE_REG8(modrm, dst);
                CYCLES(CYCLES_XADD_REG_MEM);
        }
@@ -175,14 +177,16 @@ void I386_OPS_BASE::I486OP(xadd_rm16_r16)() // Opcode 0x0f c1
        if( modrm >= 0xc0 ) {
                UINT16 dst = LOAD_RM16(modrm);
                UINT16 src = LOAD_REG16(modrm);
+               UINT16 sum = ADD16(cpustate, dst, src);
                STORE_REG16(modrm, dst);
-               STORE_RM16(modrm, dst + src);
+               STORE_RM16(modrm, sum);
                CYCLES(CYCLES_XADD_REG_REG);
        } else {
                UINT32 ea = GetEA(modrm, 1, 2);
                UINT16 dst = READ16(ea);
                UINT16 src = LOAD_REG16(modrm);
-               WRITE16(ea, dst + src);
+               UINT16 sum = ADD16(cpustate, dst, src);
+               WRITE16(ea, sum);
                STORE_REG16(modrm, dst);
                CYCLES(CYCLES_XADD_REG_MEM);
        }
@@ -194,14 +198,16 @@ void I386_OPS_BASE::I486OP(xadd_rm32_r32)() // Opcode 0x0f c1
        if( modrm >= 0xc0 ) {
                UINT32 dst = LOAD_RM32(modrm);
                UINT32 src = LOAD_REG32(modrm);
-               STORE_REG32(modrm, dst);
-               STORE_RM32(modrm, dst + src);
+               UINT32 sum = ADD32(cpustate, dst, src);
+               STORE_REG32(modrm, dst);
+               STORE_RM32(modrm, sum);
                CYCLES(CYCLES_XADD_REG_REG);
        } else {
                UINT32 ea = GetEA(modrm, 1, 4);
                UINT32 dst = READ32(ea);
                UINT32 src = LOAD_REG32(modrm);
-               WRITE32(ea, dst + src);
+               UINT32 sum = ADD32(cpustate, dst, src);
+               WRITE32(ea, sum);
                STORE_REG32(modrm, dst);
                CYCLES(CYCLES_XADD_REG_MEM);
        }
@@ -224,7 +230,7 @@ void I386_OPS_BASE::I486OP(group0F01_16)()      // Opcode 0x0f 01
                                        ea = GetEA(modrm, 1, 6);
                                }
                                WRITE16(ea, cpustate->gdtr.limit);
-                               WRITE32(ea + 2, cpustate->gdtr.base & 0xffffff);
+                               WRITE32(ea + 2, cpustate->gdtr.base);
                                CYCLES(CYCLES_SGDT);
                                break;
                        }
@@ -240,7 +246,7 @@ void I386_OPS_BASE::I486OP(group0F01_16)()      // Opcode 0x0f 01
                                        ea = GetEA(modrm, 1, 6);
                                }
                                WRITE16(ea, cpustate->idtr.limit);
-                               WRITE32(ea + 2, cpustate->idtr.base & 0xffffff);
+                               WRITE32(ea + 2, cpustate->idtr.base);
                                CYCLES(CYCLES_SIDT);
                                break;
                        }
@@ -288,9 +294,9 @@ void I386_OPS_BASE::I486OP(group0F01_16)()      // Opcode 0x0f 01
                        }
                case 6:         /* LMSW */
                        {
-                               UINT16 b;
                                if(PROTECTED_MODE && cpustate->CPL)
                                        FAULT(FAULT_GP,0)
+                               UINT16 b;               
                                if( modrm >= 0xc0 ) {
                                        b = LOAD_RM16(modrm);
                                        CYCLES(CYCLES_LMSW_REG);
@@ -505,6 +511,8 @@ void I386_OPS_BASE::I486OP(mov_cr_r32)()        // Opcode 0x0f 22
                        CYCLES(CYCLES_MOV_REG_CR0);
                        if((oldcr ^ cpustate->cr[cr]) & 0x80010000)
                                vtlb_flush_dynamic(cpustate->vtlb);
+//                     if (PROTECTED_MODE != BIT(data, 0))
+//                             debugger_privilege_hook();
                        break;
                case 2: CYCLES(CYCLES_MOV_REG_CR2); break;
                case 3:
index 8d4a871..2207356 100644 (file)
@@ -15,11 +15,14 @@ void I386_OPS_BASE::PENTIUMOP(rdmsr)()          // Opcode 0x0f 32
        UINT8 valid_msr = 0;
 
        data = MSR_READ(REG32(ECX),&valid_msr);
-       REG32(EDX) = data >> 32;
-       REG32(EAX) = data & 0xffffffff;
 
        if(cpustate->CPL != 0 || valid_msr == 0) // if current privilege level isn't 0 or the register isn't recognized ...
                FAULT(FAULT_GP,0) // ... throw a general exception fault
+       else
+       {
+               REG32(EDX) = data >> 32;
+               REG32(EAX) = data & 0xffffffff;
+       }
 
        CYCLES(CYCLES_RDMSR);
 }
index 172c789..25b3acb 100644 (file)
@@ -1,5 +1,5 @@
 Based on MAME 0.152.
-Fixes in MAME 0.154 to 0.197 are applied.
+Fixes in MAME 0.154 to 0.204 are applied.
 
 cycle_table_rm/pm are changed from dynamic array to static array.
 convert char to _TCHAR in disassembler.
index d9ec646..9ff08d2 100644 (file)
@@ -144,11 +144,15 @@ static void i386_load_segment_descriptor(i386_state *cpustate, int segment )
 {
        if (PROTECTED_MODE)
        {
+               UINT16 old_flags = cpustate->sreg[segment].flags;
                if (!V8086_MODE)
                {
                        i386_load_protected_mode_segment(cpustate, &cpustate->sreg[segment], NULL );
                        if(cpustate->sreg[segment].selector)
+                       {
                                i386_set_descriptor_accessed(cpustate, cpustate->sreg[segment].selector);
+                               cpustate->sreg[segment].flags |= 0x0001;
+                       }
                }
                else
                {
@@ -158,6 +162,8 @@ static void i386_load_segment_descriptor(i386_state *cpustate, int segment )
                        cpustate->sreg[segment].d = 0;
                        cpustate->sreg[segment].valid = true;
                }
+//             if (segment == CS && cpustate->sreg[segment].flags != old_flags)
+//                     debugger_privilege_hook();
        }
        else
        {
@@ -231,6 +237,7 @@ static UINT32 get_flags(i386_state *cpustate)
 
 static void set_flags(i386_state *cpustate, UINT32 f )
 {
+       f &= cpustate->eflags_mask;;
        cpustate->CF = (f & 0x1) ? 1 : 0;
        cpustate->PF = (f & 0x4) ? 1 : 0;
        cpustate->AF = (f & 0x10) ? 1 : 0;
@@ -249,7 +256,7 @@ static void set_flags(i386_state *cpustate, UINT32 f )
        cpustate->VIF = (f & 0x80000) ? 1 : 0;
        cpustate->VIP = (f & 0x100000) ? 1 : 0;
        cpustate->ID = (f & 0x200000) ? 1 : 0;
-       cpustate->eflags = f & cpustate->eflags_mask;
+       cpustate->eflags = f;
 }
 
 static void sib_byte(i386_state *cpustate,UINT8 mod, UINT32* out_ea, UINT8* out_segment)
index 16ce7d0..6f8318c 100644 (file)
@@ -318,7 +318,7 @@ static void I386OP(bsr_r32_rm32)(i386_state *cpustate)      // Opcode 0x0f bd
        } else {
                cpustate->ZF = 0;
                dst = temp = 31;
-               while( (src & (1 << temp)) == 0 ) {
+               while( (src & (1U << temp)) == 0 ) {
                        temp--;
                        dst = temp;
                        CYCLES(cpustate,CYCLES_BSR);
index d1bcd5a..b74fa8a 100644 (file)
@@ -697,6 +697,8 @@ static void I386OP(mov_cr_r32)(i386_state *cpustate)        // Opcode 0x0f 22
                case 0:
                        data &= 0xfffeffff; // wp not supported on 386
                        CYCLES(cpustate,CYCLES_MOV_REG_CR0);
+//                     if (PROTECTED_MODE != BIT(data, 0))
+//                             debugger_privilege_hook();
                        break;
                case 2: CYCLES(cpustate,CYCLES_MOV_REG_CR2); break;
                case 3:
index 5db54a7..23923e0 100644 (file)
@@ -152,14 +152,16 @@ static void I486OP(xadd_rm8_r8)(i386_state *cpustate)   // Opcode 0x0f c0
        if( modrm >= 0xc0 ) {
                UINT8 dst = LOAD_RM8(modrm);
                UINT8 src = LOAD_REG8(modrm);
+               UINT8 sum = ADD8(cpustate, dst, src);
                STORE_REG8(modrm, dst);
-               STORE_RM8(modrm, dst + src);
+               STORE_RM8(modrm, sum);
                CYCLES(cpustate,CYCLES_XADD_REG_REG);
        } else {
                UINT32 ea = GetEA(cpustate,modrm,1,1);
                UINT8 dst = READ8(cpustate,ea);
                UINT8 src = LOAD_REG8(modrm);
-               WRITE8(cpustate,ea, dst + src);
+               UINT8 sum = ADD8(cpustate, dst, src);
+               WRITE8(cpustate,ea, sum);
                STORE_REG8(modrm, dst);
                CYCLES(cpustate,CYCLES_XADD_REG_MEM);
        }
@@ -171,14 +173,16 @@ static void I486OP(xadd_rm16_r16)(i386_state *cpustate) // Opcode 0x0f c1
        if( modrm >= 0xc0 ) {
                UINT16 dst = LOAD_RM16(modrm);
                UINT16 src = LOAD_REG16(modrm);
+               UINT16 sum = ADD16(cpustate, dst, src);
                STORE_REG16(modrm, dst);
-               STORE_RM16(modrm, dst + src);
+               STORE_RM16(modrm, sum);
                CYCLES(cpustate,CYCLES_XADD_REG_REG);
        } else {
                UINT32 ea = GetEA(cpustate,modrm,1,2);
                UINT16 dst = READ16(cpustate,ea);
                UINT16 src = LOAD_REG16(modrm);
-               WRITE16(cpustate,ea, dst + src);
+               UINT16 sum = ADD16(cpustate, dst, src);
+               WRITE16(cpustate,ea, sum);
                STORE_REG16(modrm, dst);
                CYCLES(cpustate,CYCLES_XADD_REG_MEM);
        }
@@ -190,14 +194,16 @@ static void I486OP(xadd_rm32_r32)(i386_state *cpustate) // Opcode 0x0f c1
        if( modrm >= 0xc0 ) {
                UINT32 dst = LOAD_RM32(modrm);
                UINT32 src = LOAD_REG32(modrm);
+               UINT32 sum = ADD32(cpustate, dst, src);
                STORE_REG32(modrm, dst);
-               STORE_RM32(modrm, dst + src);
+               STORE_RM32(modrm, sum);
                CYCLES(cpustate,CYCLES_XADD_REG_REG);
        } else {
                UINT32 ea = GetEA(cpustate,modrm,1,4);
                UINT32 dst = READ32(cpustate,ea);
                UINT32 src = LOAD_REG32(modrm);
-               WRITE32(cpustate,ea, dst + src);
+               UINT32 sum = ADD32(cpustate, dst, src);
+               WRITE32(cpustate,ea, sum);
                STORE_REG32(modrm, dst);
                CYCLES(cpustate,CYCLES_XADD_REG_MEM);
        }
@@ -220,7 +226,7 @@ static void I486OP(group0F01_16)(i386_state *cpustate)      // Opcode 0x0f 01
                                        ea = GetEA(cpustate,modrm,1,6);
                                }
                                WRITE16(cpustate,ea, cpustate->gdtr.limit);
-                               WRITE32(cpustate,ea + 2, cpustate->gdtr.base & 0xffffff);
+                               WRITE32(cpustate,ea + 2, cpustate->gdtr.base);
                                CYCLES(cpustate,CYCLES_SGDT);
                                break;
                        }
@@ -236,7 +242,7 @@ static void I486OP(group0F01_16)(i386_state *cpustate)      // Opcode 0x0f 01
                                        ea = GetEA(cpustate,modrm,1,6);
                                }
                                WRITE16(cpustate,ea, cpustate->idtr.limit);
-                               WRITE32(cpustate,ea + 2, cpustate->idtr.base & 0xffffff);
+                               WRITE32(cpustate,ea + 2, cpustate->idtr.base);
                                CYCLES(cpustate,CYCLES_SIDT);
                                break;
                        }
@@ -284,9 +290,9 @@ static void I486OP(group0F01_16)(i386_state *cpustate)      // Opcode 0x0f 01
                        }
                case 6:         /* LMSW */
                        {
-                               UINT16 b;
                                if(PROTECTED_MODE && cpustate->CPL)
                                        FAULT(FAULT_GP,0)
+                               UINT16 b;
                                if( modrm >= 0xc0 ) {
                                        b = LOAD_RM16(modrm);
                                        CYCLES(cpustate,CYCLES_LMSW_REG);
@@ -501,6 +507,8 @@ static void I486OP(mov_cr_r32)(i386_state *cpustate)        // Opcode 0x0f 22
                        CYCLES(cpustate,CYCLES_MOV_REG_CR0);
                        if((oldcr ^ cpustate->cr[cr]) & 0x80010000)
                                vtlb_flush_dynamic(cpustate->vtlb);
+//                     if (PROTECTED_MODE != BIT(data, 0))
+//                             debugger_privilege_hook();
                        break;
                case 2: CYCLES(cpustate,CYCLES_MOV_REG_CR2); break;
                case 3:
index 8968e06..ea38632 100644 (file)
@@ -59,11 +59,14 @@ static void PENTIUMOP(rdmsr)(i386_state* cpustate)          // Opcode 0x0f 32
        UINT8 valid_msr = 0;
 
        data = MSR_READ(cpustate,REG32(ECX),&valid_msr);
-       REG32(EDX) = data >> 32;
-       REG32(EAX) = data & 0xffffffff;
 
        if(cpustate->CPL != 0 || valid_msr == 0) // if current privilege level isn't 0 or the register isn't recognized ...
                FAULT(FAULT_GP,0) // ... throw a general exception fault
+       else
+       {
+               REG32(EDX) = data >> 32;
+               REG32(EAX) = data & 0xffffffff;
+       }
 
        CYCLES(cpustate,CYCLES_RDMSR);
 }
index 1e1b6a2..38b79c0 100644 (file)
@@ -1,5 +1,5 @@
 Based on MAME 0.152.
-Fixes in MAME 0.154 to 0.197 are applied.
+Fixes in MAME 0.154 to 0.204 are applied.
 
 cycle_table_rm/pm are changed from dynamic array to static array.
 
index 01baecc..ad4d63f 100644 (file)
@@ -698,12 +698,12 @@ void MEMORY::event_vline(int v, int clock)
 #ifdef _PC6001
                        if (v < 192) {
                                d_cpu->write_signal(SIG_CPU_BUSREQ, 1, 1);
-                               register_event_by_clock(this, EVENT_HBLANK, (double)CPU_CLOCKS / FRAMES_PER_SEC / LINES_PER_FRAME * 296 / 455, false, NULL);
+                               register_event_by_clock(this, EVENT_HBLANK, (uint64_t)((double)CPU_CLOCKS / FRAMES_PER_SEC / LINES_PER_FRAME * 296 / 455), false, NULL);
                        }
 #else
                        if (v < (CRTMode1 ? 200 : 192)) {
                                d_cpu->write_signal(SIG_CPU_BUSREQ, 1, 1);
-                               register_event_by_clock(this, EVENT_HBLANK, (double)CPU_CLOCKS / FRAMES_PER_SEC / LINES_PER_FRAME * (CRTMode1 ? 368 : 304) / 456, false, NULL);
+                               register_event_by_clock(this, EVENT_HBLANK, (uint64_t)((double)CPU_CLOCKS / FRAMES_PER_SEC / LINES_PER_FRAME * (CRTMode1 ? 368 : 304) / 456), false, NULL);
                        }
 #endif
                }
index 1c516e9..197b0b6 100644 (file)
@@ -632,18 +632,18 @@ uint8_t Keys7[256][2] =
   {0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x7f},
 };
 
-void PSUB::update_keyboard()
+void PSUB::update_keyboard(int code)
 {
-       for (int code=0; code < 256; code++) {
-               if (key_stat[code] & 0x80) {
+//     for (int code=0; code < 256; code++) {
+//             if (key_stat[code] & 0x80) {
                        if (code == VK_LSHIFT || code == VK_LCONTROL || code == VK_LMENU ||
-                           code == VK_RSHIFT || code == VK_RCONTROL || code == VK_RMENU) continue;
-                       if (code == VK_SHIFT || code == VK_CONTROL) continue;
-                       key_stat[code]=0;
-                       if (code == 0x75) {kanaMode = -1 * (kanaMode-1);continue;} // VK_F6
-                       if (code == 0x76) {katakana = -1 * (katakana-1);continue;} // VK_F7
-                       if (code == 0x77) {kbFlagGraph = -1 * (kbFlagGraph-1);continue;} // VK_F8
-                       p6key=code;
+                           code == VK_RSHIFT || code == VK_RCONTROL || code == VK_RMENU) return;
+                       if (code == VK_SHIFT || code == VK_CONTROL) return;
+//                     key_stat[code]=0;
+                       if (code == 0x75) {kanaMode = -1 * (kanaMode-1);return;} // VK_F6
+                       if (code == 0x76) {katakana = -1 * (katakana-1);return;} // VK_F7
+                       if (code == 0x77) {kbFlagGraph = -1 * (kbFlagGraph-1);return;} // VK_F8
+//                     p6key=code;
                        uint8_t *Keys;
                        uint8_t ascii=0;
                        if (kbFlagGraph) {
@@ -667,9 +667,13 @@ void PSUB::update_keyboard()
                        if ((kbFlagCtrl == 1) && (code >= 0x41) && (code <= 0x5a)) ascii = code - 0x41 + 1;
                        /* function key */
                        if (!kanaMode && (ascii>0xef && ascii<0xfa)) kbFlagFunc=1;
+                       /* send key code and raise irq */
+                       if (!ascii) return;
+                       p6key = ascii;
                        d_pio->write_signal(SIG_I8255_PORT_A, ascii, 0xff);
-               }
-       }
+                       d_timer->write_signal(SIG_TIMER_IRQ_SUB_CPU, 1, 1);
+//             }
+//     }
 }
 
 bool PSUB::play_tape(const _TCHAR* file_path)
@@ -876,8 +880,8 @@ void PSUB::initialize()
        fio = new FILEIO();
        play = rec = false;
        
-//     key_stat = emu->get_key_buffer();
-       memset(key_stat, 0, sizeof(key_stat));
+       key_stat = emu->get_key_buffer();
+//     memset(key_stat, 0, sizeof(key_stat));
        
        kbFlagCtrl=0;
        kbFlagGraph=0;
@@ -928,8 +932,8 @@ void PSUB::event_frame()
        if (key_stat[VK_UP]) stick0 |= STICK0_UP;
        if (key_stat[VK_F9]) stick0 |= STICK0_STOP;
        if (key_stat[VK_SHIFT]) stick0 |= STICK0_SHIFT;
-       update_keyboard();
-       if (p6key) d_timer->write_signal(SIG_TIMER_IRQ_SUB_CPU, 1, 1);
+//     update_keyboard();
+//     if (p6key) d_timer->write_signal(SIG_TIMER_IRQ_SUB_CPU, 1, 1);
        
        if(CasSkipFlag != 0) {
                request_skip_frames();
@@ -1053,12 +1057,13 @@ uint32_t PSUB::read_io8(uint32_t addr)
 
 void PSUB::key_down(int code)
 {
-       key_stat[code] = 0x80;
+//     key_stat[code] = 0x80;
+       update_keyboard(code);
 }
 
 void PSUB::key_up(int code)
 {
-       key_stat[code] = 0x00;
+//     key_stat[code] = 0x00;
 }
 
 #define STATE_VERSION  1
index 94d1bb4..852eb01 100644 (file)
@@ -40,8 +40,8 @@ private:
        int CasLength;
        int CasSkipFlag;
        
-//     const uint8_t* key_stat;
-       uint8_t key_stat[256];
+       const uint8_t* key_stat;
+//     uint8_t key_stat[256];
        int kbFlagFunc;
        int kbFlagGraph;
        int kbFlagCtrl;
@@ -51,7 +51,7 @@ private:
        int stick0;
        int StrigIntFlag;
        int StrigEventID;
-       void update_keyboard();
+       void update_keyboard(int code);
        
 public:
        PSUB(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
index a303ac5..e78c144 100644 (file)
@@ -18,7 +18,7 @@
 #include "../z80.h"
 
 #ifdef SUPPORT_PC88_CDROM
-//#include "../scsi_cdrom.h"
+#include "../scsi_cdrom.h"
 #include "../scsi_host.h"
 #endif
 
 #define EVENT_CMT_SEND 2
 #define EVENT_CMT_DCD  3
 #define EVENT_BEEP     4
+#ifdef SUPPORT_PC88_CDROM
+#define EVENT_FADE_IN  5
+#define EVENT_FADE_OUT 6
+#endif
 
 #define IRQ_USART      0
 #define IRQ_VRTC       1
@@ -292,7 +296,7 @@ void PC88::initialize()
        }
 #endif
 #ifdef SUPPORT_PC88_CDROM
-       if(config.boot_mode != MODE_PC88_N) {
+       if(config.boot_mode == MODE_PC88_V2) {
                if(fio->Fopen(create_local_path(_T("CDBIOS.ROM")), FILEIO_READ_BINARY)) {
                        fio->Fread(cdbios, 0x10000, 1);
                        fio->Fclose();
@@ -380,6 +384,9 @@ void PC88::initialize()
        // hack to update config.scan_line at first
        hireso = !(config.monitor_type == 0);
 #endif
+#ifdef SUPPORT_PC88_CDROM
+       cdda_register_id = -1;
+#endif
 }
 
 void PC88::release()
@@ -410,7 +417,11 @@ void PC88::reset()
        }
 //     port[0x70] = 0x80;      // XM8 version 1.10
        port[0x71] = port[0xf1] = 0xff;
-       
+#if defined(SUPPORT_PC88_CDROM)
+       if (cdbios_loaded) {
+               port[0x99]  = 0x10;
+       }
+#endif
        memset(alu_reg, 0, sizeof(alu_reg));
        gvram_plane = gvram_sel = 0;
        
@@ -423,8 +434,9 @@ void PC88::reset()
        }
        SET_BANK(0x8000, 0xffff, ram + 0x8000, ram + 0x8000);
 #else
-       SET_BANK(0x0000, 0x7fff, ram, n88rom);
+//     SET_BANK(0x0000, 0x7fff, ram, n88rom);
        SET_BANK(0x8000, 0xefff, ram + 0x8000, ram + 0x8000);
+       update_low_memmap();
        update_tvram_memmap();  // XM8 version 1.10
 #endif
        
@@ -506,6 +518,14 @@ void PC88::reset()
        write_io8(2, 0);
        write_io8(3, 0);
 #endif
+#ifdef SUPPORT_PC88_CDROM
+       if(cdda_register_id != -1) {
+               cancel_event(this, cdda_register_id);
+               cdda_register_id = -1;
+       }
+       cdda_volume = 100.0;
+       d_scsi_cdrom->set_volume((int)cdda_volume);
+#endif
 #ifdef NIPPY_PATCH
        // dirty patch for NIPPY
        nippy_patch = false;
@@ -653,7 +673,7 @@ void PC88::write_io8(uint32_t addr, uint32_t data)
 {
        addr &= 0xff;
 #ifdef _IO_DEBUG_LOG
-       this->out_debug_log(_T("%6x\tOUT8\t%02x,%02x\n"), d_cpu->get_pc(), addr, data);
+       this->out_debug_log(_T("%06x\tOUT8\t%02x,%02x\n"), d_cpu->get_pc(), addr, data);
 #endif
 #ifdef NIPPY_PATCH
        // dirty patch for NIPPY
@@ -982,7 +1002,7 @@ void PC88::write_io8(uint32_t addr, uint32_t data)
                break;
 #else
        case 0x71:
-               if(mod) {
+               if(mod & 0x01) {
                        update_low_memmap();
                }
                break;
@@ -1021,6 +1041,54 @@ void PC88::write_io8(uint32_t addr, uint32_t data)
                        d_scsi_host->write_signal(SIG_SCSI_RST, data, 0x80);
                }
                break;
+       case 0x98:
+               if(cdbios_loaded) {
+                       switch(data & 7) {
+                       case 0:
+                       case 1:
+                               if(cdda_register_id != -1) {
+                                       cancel_event(this, cdda_register_id);
+                               }
+                               d_scsi_cdrom->set_volume((int)(cdda_volume = 100.0));
+                               break;
+                       case 2:
+                       case 3:
+                               if(cdda_register_id != -1) {
+                                       cancel_event(this, cdda_register_id);
+                               }
+                               d_scsi_cdrom->set_volume((int)(cdda_volume = 0.0));
+                               break;
+                       case 4:
+                               if(cdda_register_id != -1) {
+                                       cancel_event(this, cdda_register_id);
+                               }
+                               register_event(this, EVENT_FADE_IN, 100, true, &cdda_register_id); // 100ms
+                               d_scsi_cdrom->set_volume((int)(cdda_volume = 0.0));
+                               break;
+                       case 5:
+                               if(cdda_register_id != -1) {
+                                       cancel_event(this, cdda_register_id);
+                               }
+                               register_event(this, EVENT_FADE_IN, 1500, true, &cdda_register_id); // 1500ms
+                               d_scsi_cdrom->set_volume((int)(cdda_volume = 0.0));
+                               break;
+                       case 6:
+                               if(cdda_register_id != -1) {
+                                       cancel_event(this, cdda_register_id);
+                               }
+                               register_event(this, EVENT_FADE_OUT, 100, true, &cdda_register_id); // 100ms
+                               d_scsi_cdrom->set_volume((int)(cdda_volume = 100.0));
+                               break;
+                       case 7:
+                               if(cdda_register_id != -1) {
+                                       cancel_event(this, cdda_register_id);
+                               }
+                               register_event(this, EVENT_FADE_OUT, 5000, true, &cdda_register_id); // 5000ms
+                               d_scsi_cdrom->set_volume((int)(cdda_volume = 100.0));
+                               break;
+                       }
+               }
+               break;
        case 0x99:
                if(cdbios_loaded && (mod & 0x10)) {
                        update_low_memmap();
@@ -1056,8 +1124,14 @@ void PC88::write_io8(uint32_t addr, uint32_t data)
                }
                break;
        case 0xe3:
+#ifdef PC88_IODATA_EXRAM
                if(mod) {
-                       update_low_memmap();
+#else
+               if(mod & 0x0f) {
+#endif
+                       if(PortE2_RDEN || PortE2_WREN) {
+                               update_low_memmap();
+                       }
                }
                break;
 #endif
@@ -1261,9 +1335,9 @@ uint32_t PC88::read_io8_debug(uint32_t addr)
                                val &= ~(0x80 | 0x20 | 0x10 | 0x08);
                                val |= (port[0x9f] & 0x01); // correct ???
                        }
-#ifdef _SCSI_DEBUG_LOG
-                       this->out_debug_log(_T("[SCSI_PC88] Status = %02X\n"), val);
-#endif
+                       #ifdef _SCSI_DEBUG_LOG
+                               this->out_debug_log(_T("[SCSI_PC88] Status = %02X\n"), val);
+                       #endif
                        return val;
                }
                break;
@@ -1275,9 +1349,14 @@ uint32_t PC88::read_io8_debug(uint32_t addr)
        case 0x92:
        case 0x93:
        case 0x96:
+               if(cdbios_loaded) {
+                       return 0x00;
+               }
+               break;
        case 0x99:
                if(cdbios_loaded) {
-                       return 0;
+//                     return 0xcd; // PC-8801MC
+                       return 0x00;
                }
                break;
        case 0x98:
@@ -1379,6 +1458,7 @@ uint32_t PC88::read_io8_debug(uint32_t addr)
 
 uint32_t PC88::read_dma_data8(uint32_t addr)
 {
+       // from ram
 #if defined(_PC8001SR)
        return ram[addr & 0xffff];
 #else
@@ -1390,6 +1470,12 @@ uint32_t PC88::read_dma_data8(uint32_t addr)
 #endif
 }
 
+void PC88::write_dma_data8(uint32_t addr, uint32_t data)
+{
+       // to ram
+       ram[addr & 0xffff] = data;
+}
+
 void PC88::write_dma_io8(uint32_t addr, uint32_t data)
 {
        // to crtc
@@ -1797,6 +1883,24 @@ void PC88::event_callback(int event_id, int err)
                beep_signal = !beep_signal;
                d_pcm->write_signal(SIG_PCM1BIT_SIGNAL, ((beep_on && beep_signal) || sing_signal) ? 1 : 0, 1);
                break;
+#ifdef SUPPORT_PC88_CDROM
+       case EVENT_FADE_IN:
+               if((cdda_volume += 0.1) >= 100.0) {
+                       cancel_event(this, cdda_register_id);
+                       cdda_register_id = -1;
+                       cdda_volume = 100.0;
+               }
+               d_scsi_cdrom->set_volume((int)cdda_volume);
+               break;
+       case EVENT_FADE_OUT:
+               if((cdda_volume -= 0.1) <= 0) {
+                       cancel_event(this, cdda_register_id);
+                       cdda_register_id = -1;
+                       cdda_volume = 0.0;
+               }
+               d_scsi_cdrom->set_volume((int)cdda_volume);
+               break;
+#endif
        }
 }
 
@@ -2103,38 +2207,8 @@ bool PC88::check_data_carrier()
 
 void PC88::draw_screen()
 {
-       // from ePC-8801MA\89ΓΌ
-       uint8_t ct = 0;
-       
-       if(crtc.status & 0x88) {
-               // dma underrun
-               crtc.status &= ~0x80;
-               ct = crtc.reverse ? 3 : 2;
-               memset(crtc.attrib.expand, ct, 200 * 80);
-#if 0
-               ct = 0;
-               memset(crtc.text.expand, 0, 200 * 80);
-#endif
-       }
-       // for Advanced Fantasian Opening (20line) (XM8 version 1.00)
-       if(!(crtc.status & 0x10) || Port53_TEXTDS) {
-//     if(!(crtc.status & 0x10) || (crtc.status & 8) || Port53_TEXTDS) {
-               ct = 2;
-       }
-       if(ct) {
-               memset(crtc.text.expand, 0, 200 * 80);
-               for(int y = 0; y < 200; y++) {
-                       for(int x = 0; x < 80; x++) {
-                               crtc.attrib.expand[y][x] &= 0xe0;
-                               crtc.attrib.expand[y][x] |= ct;
-                       }
-               }
-//             memset(crtc.attrib.expand, 2, 200 * 80);
-       }
-       
-       // for Xak2 opening
-       memset(text, 8, sizeof(text));
-       memset(graph, 0, sizeof(graph));
+       // render text screen
+       draw_text();
        
        // render graph screen
        bool disp_color_graph = true;
@@ -2146,8 +2220,10 @@ void PC88::draw_screen()
                } else if(Port31_V1_MONO) {
                        draw_640x200_mono_graph();
                } else {
+                       if(hireso) {
+                               draw_scanline_black = false;
+                       }
                        draw_640x200_attrib_graph();
-                       draw_scanline_black = false;
                }
                emu->set_vm_screen_lines(200);
        } else {
@@ -2164,7 +2240,9 @@ void PC88::draw_screen()
                        } else {
                                draw_640x200_attrib_graph();
                        }
-                       draw_scanline_black = false;
+                       if(hireso) {
+                               draw_scanline_black = false;
+                       }
                        emu->set_vm_screen_lines(200);
                }
        }
@@ -2173,21 +2251,22 @@ void PC88::draw_screen()
                disp_color_graph = draw_640x200_color_graph();
                emu->set_vm_screen_lines(200);
        } else if(!Port31_400LINE) {
+               if(hireso) {
+                       draw_scanline_black = false;
+               }
                draw_640x200_attrib_graph();
 //             draw_640x200_mono_graph();
-               draw_scanline_black = false;
                emu->set_vm_screen_lines(200);
        } else {
+               if(hireso) {
+                       draw_scanline_black = false;
+               }
                draw_640x400_attrib_graph();
 //             draw_640x400_mono_graph();
-               draw_scanline_black = false;
                emu->set_vm_screen_lines(400);
        }
 #endif
        
-       // render text screen
-       draw_text();
-       
        // create palette for each scanline
 #if !defined(_PC8001SR)
        int disp_line = crtc.height * crtc.char_height;
@@ -2283,7 +2362,7 @@ void PC88::draw_screen()
        if(!Port31_HCOLOR && Port31_400LINE) {
                for(int y = 0; y < 400; y++) {
                        scrntype_t* dest = emu->get_screen_buffer(y);
-                       uint8_t* src_t = text[y];
+                       uint8_t* src_t = text[y >> 1];
                        uint8_t* src_g = graph[y];
                        scrntype_t* pal_t;
                        scrntype_t* pal_g;
@@ -2310,7 +2389,7 @@ void PC88::draw_screen()
        {
                for(int y = 0; y < 400; y++) {
                        scrntype_t* dest = emu->get_screen_buffer(y);
-                       uint8_t* src_t = text[y];
+                       uint8_t* src_t = text[y >> 1];
                        uint8_t* src_g = graph[y];
                        scrntype_t* pal_t;
                        scrntype_t* pal_g;
@@ -2351,25 +2430,6 @@ void PC88::draw_screen()
        }
 }
 
-int PC88::get_char_height()
-{
-       int char_height = crtc.char_height;
-       
-       if(!hireso) {
-               char_height <<= 1;
-       }
-//     if(Port31_400LINE || !crtc.skip_line) {
-//             char_height >>= 1;
-//     }
-       if(crtc.skip_line) {
-               char_height <<= 1;
-       }
-       if(char_height == 0) {
-               char_height = 16;
-       }
-       return char_height;
-}
-
 /*
        attributes:
        
@@ -2385,12 +2445,45 @@ int PC88::get_char_height()
 
 void PC88::draw_text()
 {
-       int char_height = get_char_height();
+       if(crtc.status & 0x88) {
+               // dma underrun
+               crtc.status &= ~0x80;
+               memset(crtc.text.expand, 0, 200 * 80);
+               memset(crtc.attrib.expand, crtc.reverse ? 3 : 2, 200 * 80);
+       }
+       // for Advanced Fantasian Opening (20line) (XM8 version 1.00)
+       if(!(crtc.status & 0x10) || Port53_TEXTDS) {
+//     if(!(crtc.status & 0x10) || (crtc.status & 8) || Port53_TEXTDS) {
+               memset(crtc.text.expand, 0, 200 * 80);
+               for(int y = 0; y < 200; y++) {
+                       for(int x = 0; x < 80; x++) {
+                               crtc.attrib.expand[y][x] &= 0xe0;
+                               crtc.attrib.expand[y][x] |= 0x02;
+                       }
+               }
+//             memset(crtc.attrib.expand, 2, 200 * 80);
+       }
+       
+       // for Xak2 opening
+       memset(text, 8, sizeof(text));
+       memset(text_color, 7, sizeof(text_color));
+       memset(text_reverse, 0, sizeof(text_reverse));
+       
+       int char_height = crtc.char_height;
        uint8_t color_mask = Port30_COLOR ? 0 : 7;
        uint8_t code_expand, attr_expand;
        
-       for(int cy = 0, ytop = 0; cy < 64 && ytop < 400; cy++, ytop += char_height) {
-//     for(int cy = 0, ytop = 0; cy < crtc.height && ytop < 400; cy++, ytop += char_height) {
+       if(!hireso) {
+               char_height <<= 1;
+       }
+//     if(Port31_400LINE || !crtc.skip_line) {
+//             char_height >>= 1;
+//     }
+       if(crtc.skip_line) {
+               char_height <<= 1;
+       }
+//     for(int cy = 0, ytop = 0; cy < 64 && ytop < 400; cy++, ytop += char_height) {
+       for(int cy = 0, ytop = 0; cy < crtc.height && ytop < 400; cy++, ytop += char_height) {
                for(int x = 0, cx = 0; cx < crtc.width; x += 8, cx++) {
                        if(Port30_40 && (cx & 1)) {
                                // don't update code/attrib
@@ -2399,26 +2492,23 @@ void PC88::draw_text()
                                attr_expand = crtc.attrib.expand[cy][cx];
                        }
                        uint8_t attrib = attr_expand;//crtc.attrib.expand[cy][cx];
+//                     uint8_t color = !(Port30_COLOR && (attrib & 8)) ? 7 : (attrib & 0xe0) ? (attrib >> 5) : 8;
+                       uint8_t color = (attrib & 0xe0) ? ((attrib >> 5) | color_mask) : 8;
                        bool under_line = ((attrib & 8) != 0);
                        bool upper_line = ((attrib & 4) != 0);
                        bool secret = ((attrib & 2) != 0);
                        bool reverse = ((attrib & 1) != 0);
                        
-                       uint8_t color_fore = (attrib & 0xe0) ? ((attrib >> 5) | color_mask) : 8;
-                       uint8_t color_back = 0;
-#if 1
+                       uint8_t color_tmp = color;
+                       bool reverse_tmp = reverse;
+                       
                        // from ePC-8801MA\89ΓΌ
                        if(Port31_GRAPH && !Port31_HCOLOR) {
                                if(reverse) {
                                        reverse = false;
-                                       color_back = 0;//color_fore & 7;
-                                       color_fore = 8;
-                               } else {
-//                                     color_back = 8;
+                                       color = 8;
                                }
                        }
-#endif
-                       
                        uint8_t code = secret ? 0 : code_expand;//crtc.text.expand[cy][cx];
 #ifdef SUPPORT_PC88_PCG8100
                        uint8_t *pattern = ((attrib & 0x10) ? sg_pattern : pcg_pattern) + code * 8;
@@ -2442,57 +2532,19 @@ void PC88::draw_text()
                                if(reverse) {
                                        pat ^= 0xff;
                                }
-                               uint8_t *dest0 = &text[y    ][x];
-                               uint8_t *dest1 = &text[y + 1][x];
-#if 1
-                               // from ePC-8801MA\89ΓΌ
-                               uint8_t *src0 = &graph[y    ][x];
-                               uint8_t *src1 = &graph[y + 1][x];
+                               uint8_t *dest = &text[y >> 1][x];
+                               dest[0] = (pat & 0x80) ? color : 0;
+                               dest[1] = (pat & 0x40) ? color : 0;
+                               dest[2] = (pat & 0x20) ? color : 0;
+                               dest[3] = (pat & 0x10) ? color : 0;
+                               dest[4] = (pat & 0x08) ? color : 0;
+                               dest[5] = (pat & 0x04) ? color : 0;
+                               dest[6] = (pat & 0x02) ? color : 0;
+                               dest[7] = (pat & 0x01) ? color : 0;
                                
-                               if(Port31_GRAPH && !Port31_HCOLOR) {
-                                       dest0[0] = (pat & 0x80) ? color_fore : src0[0] ? 0 : color_back;
-                                       dest0[1] = (pat & 0x40) ? color_fore : src0[1] ? 0 : color_back;
-                                       dest0[2] = (pat & 0x20) ? color_fore : src0[2] ? 0 : color_back;
-                                       dest0[3] = (pat & 0x10) ? color_fore : src0[3] ? 0 : color_back;
-                                       dest0[4] = (pat & 0x08) ? color_fore : src0[4] ? 0 : color_back;
-                                       dest0[5] = (pat & 0x04) ? color_fore : src0[5] ? 0 : color_back;
-                                       dest0[6] = (pat & 0x02) ? color_fore : src0[6] ? 0 : color_back;
-                                       dest0[7] = (pat & 0x01) ? color_fore : src0[7] ? 0 : color_back;
-/*
-                                       if(Port31_400LINE) {
-*/
-                                       dest1[0] = (pat & 0x80) ? color_fore : src1[0] ? 0 : color_back;
-                                       dest1[1] = (pat & 0x40) ? color_fore : src1[1] ? 0 : color_back;
-                                       dest1[2] = (pat & 0x20) ? color_fore : src1[2] ? 0 : color_back;
-                                       dest1[3] = (pat & 0x10) ? color_fore : src1[3] ? 0 : color_back;
-                                       dest1[4] = (pat & 0x08) ? color_fore : src1[4] ? 0 : color_back;
-                                       dest1[5] = (pat & 0x04) ? color_fore : src1[5] ? 0 : color_back;
-                                       dest1[6] = (pat & 0x02) ? color_fore : src1[6] ? 0 : color_back;
-                                       dest1[7] = (pat & 0x01) ? color_fore : src1[7] ? 0 : color_back;
-/*
-                                       } else {
-                                               dest1[0] = (pat & 0x80) ? color_fore : color_back;
-                                               dest1[1] = (pat & 0x40) ? color_fore : color_back;
-                                               dest1[2] = (pat & 0x20) ? color_fore : color_back;
-                                               dest1[3] = (pat & 0x10) ? color_fore : color_back;
-                                               dest1[4] = (pat & 0x08) ? color_fore : color_back;
-                                               dest1[5] = (pat & 0x04) ? color_fore : color_back;
-                                               dest1[6] = (pat & 0x02) ? color_fore : color_back;
-                                               dest1[7] = (pat & 0x01) ? color_fore : color_back;
-                                       }
-*/
-                               } else
-#endif
-                               {
-                                       dest0[0] = dest1[0] = (pat & 0x80) ? color_fore : 0;
-                                       dest0[1] = dest1[1] = (pat & 0x40) ? color_fore : 0;
-                                       dest0[2] = dest1[2] = (pat & 0x20) ? color_fore : 0;
-                                       dest0[3] = dest1[3] = (pat & 0x10) ? color_fore : 0;
-                                       dest0[4] = dest1[4] = (pat & 0x08) ? color_fore : 0;
-                                       dest0[5] = dest1[5] = (pat & 0x04) ? color_fore : 0;
-                                       dest0[6] = dest1[6] = (pat & 0x02) ? color_fore : 0;
-                                       dest0[7] = dest1[7] = (pat & 0x01) ? color_fore : 0;
-                               }
+                               // store text attributes for monocolor graph screen
+                               text_color[y >> 1][cx] = color_tmp;
+                               text_reverse[y >> 1][cx] = reverse_tmp;
                        }
                }
        }
@@ -2607,26 +2659,20 @@ void PC88::draw_320x200_attrib_graph()
        uint8_t *gvram_r1 = Port53_G4DS ? gvram_null : (gvram + 0x6000);
        uint8_t *gvram_g1 = Port53_G5DS ? gvram_null : (gvram + 0xa000);
        
-       int char_height = get_char_height();
-       uint8_t color_mask = Port30_COLOR ? 0 : 7;
-       
        if(Port30_40) {
                for(int y = 0, addr = 0; y < 400; y += 2) {
-                       int cy = y / char_height;
                        for(int x = 0, cx = 0; x < 640; x += 16, cx += 2) {
+                               uint8_t color = text_color[y >> 1][cx];
                                uint8_t brg0 = gvram_b0[addr] | gvram_r0[addr] | gvram_g0[addr] |
                                               gvram_b1[addr] | gvram_r1[addr] | gvram_g1[addr];
-                               uint8_t brg1  = config.scan_line ? 0 : brg0;
-                               uint8_t attrib = crtc.attrib.expand[cy][cx];
-                               uint8_t color = (attrib >> 5) | color_mask;
-                               bool reverse = ((attrib & 1) != 0);
-                               if(reverse) {
+                               uint8_t brg1 = 0;
+                               if(text_reverse[y >> 1][cx]) {
                                        brg0 ^= 0xff;
                                        brg1 ^= 0xff;
                                }
                                addr++;
-                               uint8_t *dest1 = &graph[y    ][x];
-                               uint8_t *dest0 = &graph[y + 1][x];
+                               uint8_t *dest0 = &graph[y    ][x];
+                               uint8_t *dest1 = &graph[y + 1][x];
                                dest0[ 0] = dest0[ 1] = (brg0 & 0x80) ? color : 0;
                                dest0[ 2] = dest0[ 3] = (brg0 & 0x40) ? color : 0;
                                dest0[ 4] = dest0[ 5] = (brg0 & 0x20) ? color : 0;
@@ -2635,6 +2681,7 @@ void PC88::draw_320x200_attrib_graph()
                                dest0[10] = dest0[11] = (brg0 & 0x04) ? color : 0;
                                dest0[12] = dest0[13] = (brg0 & 0x02) ? color : 0;
                                dest0[14] = dest0[15] = (brg0 & 0x01) ? color : 0;
+                               if(!hireso) continue;
                                dest1[ 0] = dest1[ 1] = (brg1 & 0x80) ? color : 0;
                                dest1[ 2] = dest1[ 3] = (brg1 & 0x40) ? color : 0;
                                dest1[ 4] = dest1[ 5] = (brg1 & 0x20) ? color : 0;
@@ -2644,31 +2691,33 @@ void PC88::draw_320x200_attrib_graph()
                                dest1[12] = dest1[13] = (brg1 & 0x02) ? color : 0;
                                dest1[14] = dest1[15] = (brg1 & 0x01) ? color : 0;
                        }
+                       if(!hireso) {
+                               if(config.scan_line) {
+                                       memset(graph[y + 1], 0, 640);
+                               } else {
+                                       memcpy(graph[y + 1], graph[y], 640);
+                               }
+                       }
                }
        } else {
                for(int y = 0, addr = 0; y < 400; y += 2) {
-                       int cy = y / char_height;
                        for(int x = 0, cx = 0; x < 640; x += 16, cx += 2) {
+                               uint8_t color_l = text_color[y >> 1][cx + 0];
+                               uint8_t color_r = text_color[y >> 1][cx + 1];
                                uint8_t brg0 = gvram_b0[addr] | gvram_r0[addr] | gvram_g0[addr] |
                                               gvram_b1[addr] | gvram_r1[addr] | gvram_g1[addr];
-                               uint8_t brg1 = config.scan_line ? 0 : brg0;
-                               uint8_t attrib_l = crtc.attrib.expand[cy][cx + 0];
-                               uint8_t color_l = (attrib_l >> 5) | color_mask;
-                               bool reverse_l = ((attrib_l & 1) != 0);
-                               uint8_t attrib_r = crtc.attrib.expand[cy][cx + 1];
-                               uint8_t color_r = (attrib_r >> 5) | color_mask;
-                               bool reverse_r = ((attrib_r & 1) != 0);
-                               if(reverse_l) {
+                               uint8_t brg1 = 0;
+                               if(text_reverse[y >> 1][cx + 0]) {
                                        brg0 ^= 0xf0;
                                        brg0 ^= 0xf0;
                                }
-                               if(reverse_r) {
+                               if(text_reverse[y >> 1][cx + 1]) {
                                        brg1 ^= 0x0f;
                                        brg1 ^= 0x0f;
                                }
                                addr++;
-                               uint8_t *dest1 = &graph[y    ][x];
-                               uint8_t *dest0 = &graph[y + 1][x];
+                               uint8_t *dest0 = &graph[y    ][x];
+                               uint8_t *dest1 = &graph[y + 1][x];
                                dest0[ 0] = dest0[ 1] = (brg0 & 0x80) ? color_l : 0;
                                dest0[ 2] = dest0[ 3] = (brg0 & 0x40) ? color_l : 0;
                                dest0[ 4] = dest0[ 5] = (brg0 & 0x20) ? color_l : 0;
@@ -2677,6 +2726,7 @@ void PC88::draw_320x200_attrib_graph()
                                dest0[10] = dest0[11] = (brg0 & 0x04) ? color_r : 0;
                                dest0[12] = dest0[13] = (brg0 & 0x02) ? color_r : 0;
                                dest0[14] = dest0[15] = (brg0 & 0x01) ? color_r : 0;
+                               if(!hireso) continue;
                                dest1[ 0] = dest1[ 1] = (brg1 & 0x80) ? color_l : 0;
                                dest1[ 2] = dest1[ 3] = (brg1 & 0x40) ? color_l : 0;
                                dest1[ 4] = dest1[ 5] = (brg1 & 0x20) ? color_l : 0;
@@ -2686,6 +2736,13 @@ void PC88::draw_320x200_attrib_graph()
                                dest1[12] = dest1[13] = (brg1 & 0x02) ? color_r : 0;
                                dest1[14] = dest1[15] = (brg1 & 0x01) ? color_r : 0;
                        }
+                       if(!hireso) {
+                               if(config.scan_line) {
+                                       memset(graph[y + 1], 0, 640);
+                               } else {
+                                       memcpy(graph[y + 1], graph[y], 640);
+                               }
+                       }
                }
        }
 }
@@ -2772,23 +2829,12 @@ void PC88::draw_640x200_attrib_graph()
        uint8_t *gvram_r = Port53_G1DS ? gvram_null : (gvram + 0x4000);
        uint8_t *gvram_g = Port53_G2DS ? gvram_null : (gvram + 0x8000);
        
-       int char_height = get_char_height();
-       uint8_t color_mask = Port30_COLOR ? 0 : 7, color;
-       bool reverse;
-       
        for(int y = 0, addr = 0; y < 400; y += 2) {
-               int cy = y / char_height;
                for(int x = 0, cx = 0; x < 640; x += 8, cx++) {
+                       uint8_t color = text_color[y >> 1][cx];
                        uint8_t brg0 = gvram_b[addr] | gvram_r[addr] | gvram_g[addr];
-                       uint8_t brg1 = config.scan_line ? 0 : brg0;
-                       if(Port30_40 && (cx & 1)) {
-                               // don't update color
-                       } else {
-                               uint8_t attrib = crtc.attrib.expand[cy][cx];
-                               color = (attrib >> 5) | color_mask;
-                               reverse = ((attrib & 1) != 0);
-                       }
-                       if(reverse) {
+                       uint8_t brg1 = 0;
+                       if(text_reverse[y >> 1][cx]) {
                                brg0 ^= 0xff;
                                brg1 ^= 0xff;
                        }
@@ -2803,6 +2849,7 @@ void PC88::draw_640x200_attrib_graph()
                        dest0[5] = (brg0 & 0x04) ? color : 0;
                        dest0[6] = (brg0 & 0x02) ? color : 0;
                        dest0[7] = (brg0 & 0x01) ? color : 0;
+                       if(!hireso) continue;
                        dest1[0] = (brg1 & 0x80) ? color : 0;
                        dest1[1] = (brg1 & 0x40) ? color : 0;
                        dest1[2] = (brg1 & 0x20) ? color : 0;
@@ -2812,6 +2859,13 @@ void PC88::draw_640x200_attrib_graph()
                        dest1[6] = (brg1 & 0x02) ? color : 0;
                        dest1[7] = (brg1 & 0x01) ? color : 0;
                }
+               if(!hireso) {
+                       if(config.scan_line) {
+                               memset(graph[y + 1], 0, 640);
+                       } else {
+                               memcpy(graph[y + 1], graph[y], 640);
+                       }
+               }
        }
 }
 
@@ -2866,22 +2920,11 @@ void PC88::draw_640x400_attrib_graph()
        uint8_t *gvram_b = Port53_G0DS ? gvram_null : (gvram + 0x0000);
        uint8_t *gvram_r = Port53_G1DS ? gvram_null : (gvram + 0x4000);
        
-       int char_height = get_char_height();
-       uint8_t color_mask = Port30_COLOR ? 0 : 7, color;
-       bool reverse;
-       
        for(int y = 0, addr = 0; y < 200; y++) {
-               int cy = y / char_height;
                for(int x = 0, cx = 0; x < 640; x += 8, cx++) {
+                       uint8_t color = text_color[y >> 1][cx];
                        uint8_t b = gvram_b[addr];
-                       if(Port30_40 && (cx & 1)) {
-                               // don't update color
-                       } else {
-                               uint8_t attrib = crtc.attrib.expand[cy][cx];
-                               color = (attrib >> 5) | color_mask;
-                               reverse = ((attrib & 1) != 0);
-                       }
-                       if(reverse) {
+                       if(text_reverse[y >> 1][cx]) {
                                b ^= 0xff;
                        }
                        addr++;
@@ -2897,17 +2940,10 @@ void PC88::draw_640x400_attrib_graph()
                }
        }
        for(int y = 200, addr = 0; y < 400; y++) {
-               int cy = y / char_height;
                for(int x = 0, cx = 0; x < 640; x += 8, cx++) {
+                       uint8_t color = text_color[y >> 1][cx];
                        uint8_t r = gvram_r[addr];
-                       if(Port30_40 && (cx & 1)) {
-                               // don't update color
-                       } else {
-                               uint8_t attrib = crtc.attrib.expand[cy][cx];
-                               color = (attrib >> 5) | color_mask;
-                               reverse = ((attrib & 1) != 0);
-                       }
-                       if(reverse) {
+                       if(text_reverse[y >> 1][cx]) {
                                r ^= 0xff;
                        }
                        addr++;
@@ -3229,9 +3265,9 @@ underrun:
        if(exitline != -1) {
                for(int cy = exitline; cy < 200; cy++) {
                        memset(&text.expand[cy][0], 0, width);
-#if 0
+#if 1
                        // SORCERIAN Music Library ver-2.1
-                       memset(&attrib.expand[cy][0], 0xe0, width);
+                       memset(&attrib.expand[cy][0], 0xe0, width); // color=7
 #else
                        // from ePC-8801MA\89ΓΌ
                        memset(&attrib.expand[cy][0], 0x00, width);
@@ -3279,8 +3315,10 @@ void pc88_dmac_t::write_io8(uint32_t addr, uint32_t data)
                } else {
                        if((mode & 0x80) && c == 2) {
                                ch[3].addr.b.h = data;
+                               ch[3].addr.b.h2 = ch[3].addr.b.h3 = 0;
                        }
                        ch[c].addr.b.h = data;
+                       ch[c].addr.b.h2 = ch[c].addr.b.h3 = 0;
                }
                high_low = !high_low;
                break;
@@ -3296,9 +3334,11 @@ void pc88_dmac_t::write_io8(uint32_t addr, uint32_t data)
                } else {
                        if((mode & 0x80) && c == 2) {
                                ch[3].count.b.h = data & 0x3f;
+                               ch[3].count.b.h2 = ch[3].count.b.h3 = 0;
                                ch[3].mode = data & 0xc0;
                        }
                        ch[c].count.b.h = data & 0x3f;
+                       ch[c].count.b.h2 = ch[c].count.b.h3 = 0;
                        ch[c].mode = data & 0xc0;
                }
                high_low = !high_low;
@@ -3350,11 +3390,6 @@ uint32_t pc88_dmac_t::read_io8(uint32_t addr)
 void pc88_dmac_t::start(int c)
 {
        if(mode & (1 << c)) {
-#ifdef _SCSI_DEBUG_LOG
-               if(c == 1) {
-                       mem->out_debug_log(_T("[SCSI_PC88] DMA Start\n"));
-               }
-#endif
                status &= ~(1 << c);
                ch[c].running = true;
        } else {
@@ -3367,19 +3402,11 @@ void pc88_dmac_t::run(int c, int nbytes)
        if(ch[c].running) {
                while(nbytes > 0 && ch[c].count.sd >= 0) {
                        if(ch[c].mode == 0x80) {
-#ifdef _SCSI_DEBUG_LOG
-                               if(c == 1) {
-                                       mem->out_debug_log(_T("[SCSI_PC88] DMA Transfer Memory->I/O Addr=%04X\n"), ch[c].addr.w.l);
-                               }
-#endif
                                ch[c].io->write_dma_io8(0, mem->read_dma_data8(ch[c].addr.w.l));
                        } else if(ch[c].mode == 0x40) {
-#ifdef _SCSI_DEBUG_LOG
-                               if(c == 1) {
-                                       mem->out_debug_log(_T("[SCSI_PC88] DMA Trasfer I/O->Memory Addr=%04X\n"), ch[c].addr.w.l);
-                               }
-#endif
                                mem->write_dma_data8(ch[c].addr.w.l, ch[c].io->read_dma_io8(0));
+                       } else if(ch[c].mode == 0x00) {
+                               ch[c].io->read_dma_io8(0); // verify
                        }
                        ch[c].addr.sd++;
                        ch[c].count.sd--;
@@ -3395,11 +3422,13 @@ void pc88_dmac_t::finish(int c)
 {
        if(ch[c].running) {
                while(ch[c].count.sd >= 0) {
-//                     if(ch[c].mode == 0x80) {
+                       if(ch[c].mode == 0x80) {
                                ch[c].io->write_dma_io8(0, mem->read_dma_data8(ch[c].addr.w.l));
-//                     } else if(ch[c].mode == 0x40) {
-//                             mem->write_dma_data8(ch[c].addr.w.l, ch[c].io->read_dma_io8(0));
-//                     }
+                       } else if(ch[c].mode == 0x40) {
+                               mem->write_dma_data8(ch[c].addr.w.l, ch[c].io->read_dma_io8(0));
+                       } else if(ch[c].mode == 0x00) {
+                               ch[c].io->read_dma_io8(0); // verify
+                       }
                        ch[c].addr.sd++;
                        ch[c].count.sd--;
                }
@@ -3412,15 +3441,10 @@ void pc88_dmac_t::finish(int c)
                }
                status |= (1 << c);
                ch[c].running = false;
-#ifdef _SCSI_DEBUG_LOG
-               if(c == 1) {
-                       mem->out_debug_log(_T("[SCSI_PC88] DMA Finish\n"));
-               }
-#endif
        }
 }
 
-#define STATE_VERSION  9
+#define STATE_VERSION  10
 
 bool PC88::process_state(FILEIO* state_fio, bool loading)
 {
@@ -3578,6 +3602,10 @@ bool PC88::process_state(FILEIO* state_fio, bool loading)
        state_fio->StateValue(pcg_ctrl);
        state_fio->StateArray(pcg_pattern, sizeof(pcg_pattern), 1);
 #endif
+#ifdef SUPPORT_PC88_CDROM
+       state_fio->StateValue(cdda_register_id);
+       state_fio->StateValue(cdda_volume);
+#endif
 #ifdef NIPPY_PATCH
        state_fio->StateValue(nippy_patch);
 #endif
index 8c3f0c7..d7bfb4f 100644 (file)
@@ -40,7 +40,7 @@ class YM2203;
 class Z80;
 #ifdef SUPPORT_PC88_CDROM
 class SCSI_HOST;
-//class SCSI_CDROM;
+class SCSI_CDROM;
 #endif
 
 namespace PC88DEV {
@@ -117,7 +117,7 @@ private:
        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;
+       SCSI_CDROM* d_scsi_cdrom;
 #endif
 #ifdef SUPPORT_PC88_HMB20
        DEVICE *d_opm;
@@ -203,7 +203,9 @@ private:
        bool hireso;
        
        uint8_t sg_pattern[0x800];
-       uint8_t text[400][640];
+       uint8_t text[200][640];
+       uint8_t text_color[200][80];
+       bool text_reverse[200][80];
        uint8_t graph[400][640];
        
        palette_t palette_digital[9];
@@ -215,7 +217,6 @@ private:
        scrntype_t palette_vab_pc[0x10000];
 #endif
        
-       int get_char_height();
        void draw_text();
 #if defined(_PC8001SR)
        bool draw_320x200_color_graph();
@@ -281,6 +282,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;
@@ -311,6 +317,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);
@@ -369,10 +376,10 @@ public:
        {
                d_scsi_host = device;
        }
-//     void set_context_scsi_cdrom(SCSI_CDROM* device)
-//     {
-//             d_scsi_cdrom = device;
-//     }
+       void set_context_scsi_cdrom(SCSI_CDROM* device)
+       {
+               d_scsi_cdrom = device;
+       }
 #endif
 #ifdef SUPPORT_PC88_HMB20
        void set_context_opm(DEVICE* device)
index 7564c56..969c014 100644 (file)
@@ -220,7 +220,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        pc88->set_context_sio(pc88sio);
 #ifdef SUPPORT_PC88_CDROM
        pc88->set_context_scsi_host(pc88scsi_host);
-//     pc88->set_context_scsi_cdrom(pc88scsi_cdrom);
+       pc88->set_context_scsi_cdrom(pc88scsi_cdrom);
 #endif
 #ifdef SUPPORT_PC88_HMB20
        pc88->set_context_opm(pc88opm);
index 950f347..3f799ba 100644 (file)
@@ -121,6 +121,7 @@ public:
        int get_command_length(int value);
        void start_command();
        bool read_buffer(int length);
+       bool write_buffer(int length);
        
        // unique functions
        void set_context_done(DEVICE* device, int id, uint32_t mask)