OSDN Git Service

[VM][I8253][PC9801] Revert changes for i8253, and apply Upstream changes to PC9801...
authorK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 29 May 2017 02:08:55 +0000 (11:08 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 29 May 2017 02:08:55 +0000 (11:08 +0900)
24 files changed:
source/build-cmake/cmake/config_emufmr50.cmake
source/build-cmake/cmake/config_emupc9801.cmake
source/build-cmake/cmake/config_mz2500.cmake
source/build-cmake/cmake/config_mz700.cmake
source/build-cmake/cmake/config_mz80.cmake
source/build-cmake/cmake/config_pc8801.cmake
source/build-cmake/cmake/config_pc98ha.cmake
source/build-cmake/cmake/config_qc10.cmake
source/build-cmake/fm16pi/CMakeLists.txt
source/build-cmake/fmr30_i286/CMakeLists.txt
source/build-cmake/fmr30_i86/CMakeLists.txt
source/build-cmake/j3100gt/CMakeLists.txt
source/build-cmake/j3100sl/CMakeLists.txt
source/build-cmake/jx/CMakeLists.txt
source/build-cmake/multi8/CMakeLists.txt
source/build-cmake/mz2800/CMakeLists.txt
source/build-cmake/mz3500/CMakeLists.txt
source/src/vm/common_vm/CMakeLists.txt
source/src/vm/i8253.cpp
source/src/vm/i8253.h
source/src/vm/pc9801/CMakeLists.txt
source/src/vm/pc9801/display.cpp
source/src/vm/pc9801/floppy.cpp
source/src/vm/pc9801/itf.cpp

index 1fa9352..561243c 100644 (file)
@@ -12,8 +12,8 @@ set(WITH_JOYSTICK OFF)
 set(WITH_MOUSE ON)
 
 set(VMFILES
-#
-#                 mb8877.cpp
+
+                  i8253.cpp
                   msm58321.cpp
                   scsi_dev.cpp
                   scsi_host.cpp
@@ -30,6 +30,7 @@ set(VMFILES_LIB
                   mb8877.cpp
                   hd46505.cpp
                   upd71071.cpp
+#                 i8253.cpp
 
                   i8251.cpp
                   i8253.cpp
index 8b48146..aa89705 100644 (file)
@@ -6,8 +6,9 @@ set(WITH_MOUSE ON)
 
 set(VMFILES
                   i8237.cpp
+                  i8253.cpp
                   upd7220.cpp
-                  
+
                   event.cpp
                   io.cpp
                   memory.cpp
index 51bf2aa..146b815 100644 (file)
@@ -22,8 +22,9 @@ set(VMFILES_LIB_2500
 )
 
 set(VMFILES_BASE
+                  i8253.cpp               
                   mz1p17.cpp
-                  
+
                   event.cpp
                   memory.cpp
                   io.cpp
@@ -31,7 +32,7 @@ set(VMFILES_BASE
                   )
 set(VMFILES_LIB
                   datarec.cpp
-                  i8253.cpp
+#                 i8253.cpp
                   i8255.cpp
 
                   pcm1bit.cpp
index 6a38fd5..df6a8a1 100644 (file)
@@ -11,6 +11,7 @@ set(WITH_MOUSE ON)
 
 set(FLAG_USE_Z80 ON)
 set(VMFILES_BASE
+                  i8253.cpp
                   event.cpp
                   io.cpp
                   memory.cpp
@@ -28,7 +29,7 @@ set(VMFILES_MZ1500 ${VMFILES_MZ800}
 set(VMFILES_LIB
           datarec.cpp
           i8255.cpp
-          i8253.cpp
+#         i8253.cpp
                   
           beep.cpp
           pcm1bit.cpp
index 3e03be1..5ed2057 100644 (file)
@@ -25,6 +25,7 @@ set(VMFILES_BASE
 
 set(VMFILES_LIB
           beep.cpp
+#         i8253.cpp
           datarec.cpp
           ls393.cpp
           pcm1bit.cpp
index 36ca71e..6bb001d 100644 (file)
@@ -68,7 +68,7 @@ endif()
 add_definitions(-DPC88_EXRAM_BANKS=${PC88_EXTRAM_PAGES})
 
 if(USE_PCG)
-  set(VMFILES_LIB ${VMFILES_LIB}
+  set(VMFILES ${VMFILES}
             i8253.cpp
       )      
   add_definitions(-DSUPPORT_PC88_PCG8100)
index ba204b7..aa7c0fa 100644 (file)
@@ -5,6 +5,7 @@ set(WITH_JOYSTICK ON)
 set(WITH_MOUSE ON)
 
 set(VMFILES
+                  i8253.cpp
                   event.cpp
                   io.cpp
                   memory.cpp
@@ -12,7 +13,7 @@ set(VMFILES
 set(VMFILES_LIB
                   beep.cpp
                   i8251.cpp
-                  i8253.cpp
+#                 i8253.cpp
                   i8255.cpp
                   i8259.cpp
                   ls244.cpp
index c3c0368..d391b14 100644 (file)
@@ -6,6 +6,7 @@ set(WITH_MOUSE OFF)
 set(FLAG_USE_Z80 ON)
 set(VMFILES
                   i8237.cpp
+                  i8253.cpp
                   upd7220.cpp
                   
                   io.cpp
@@ -14,7 +15,7 @@ set(VMFILES
 )
 set(VMFILES_LIB
                   i8237_base.cpp
-                  i8253.cpp
+#                 i8253.cpp
                   i8255.cpp
                   i8259.cpp
                   upd7220_base.cpp
index a171c93..57bae09 100644 (file)
@@ -22,6 +22,7 @@ set(WITH_MOUSE ON)
 
 set(VMFILES
 #                 i286.cpp
+                  i8253.cpp
                   msm58321.cpp
                   event.cpp
                   io.cpp
index 5a80261..2ef27f6 100644 (file)
@@ -18,6 +18,7 @@ set(USE_FMGEN OFF)
 set(VMFILES
 #                 i286.cpp     
                   i8237.cpp
+                  i8253.cpp
                   fmr50/bios.cpp
                   
                   scsi_dev.cpp
@@ -31,7 +32,7 @@ set(VMFILES
 set(VMFILES_LIB
                   pcm1bit.cpp
                   i8251.cpp
-                  i8253.cpp
+#                 i8253.cpp
                   i8259.cpp
                   i8237_base.cpp
                   sn76489an.cpp
index 88c0282..dd9f7f0 100644 (file)
@@ -18,6 +18,7 @@ set(USE_FMGEN OFF)
 set(VMFILES
 #                 i286.cpp
                   i8237.cpp
+                  i8253.cpp
                   fmr50/bios.cpp
                   
                   scsi_dev.cpp
@@ -31,7 +32,7 @@ set(VMFILES
 set(VMFILES_LIB
                   pcm1bit.cpp
                   i8251.cpp
-                  i8253.cpp
+#                 i8253.cpp
                   i8259.cpp
                   i8237_base.cpp
                   sn76489an.cpp
index b507dbb..8ca8bee 100644 (file)
@@ -21,12 +21,13 @@ set(WITH_MOUSE ON)
 
 set(VMFILES
                   i8237.cpp
+                  i8253.cpp
                   io.cpp
                   event.cpp
 )
 set(VMFILES_LIB
                   i8237_base.cpp
-                  i8253.cpp
+#                 i8253.cpp
                   i8259.cpp
                   hd46505.cpp
                   pcm1bit.cpp
index 7a36dfd..b0fa8e0 100644 (file)
@@ -21,13 +21,14 @@ set(WITH_MOUSE ON)
 
 set(VMFILES
                   i8237.cpp
+                  i8253.cpp
                   io.cpp
                   event.cpp
 )
 
 set(VMFILES_LIB
                   i8237_base.cpp
-                  i8253.cpp
+#                 i8253.cpp
                   i8259.cpp
                   hd46505.cpp
                   pcm1bit.cpp
index b983679..620f553 100644 (file)
@@ -24,13 +24,14 @@ set(WITH_MOUSE ON)
 set(VMFILES_BASE
 #      i86.cpp
 
+      i8253.cpp
       io.cpp
       memory.cpp
       event.cpp
 )
 set(VMFILES_LIB
       i8251.cpp
-      i8253.cpp
+#      i8253.cpp
       i8255.cpp
       i8259.cpp
          
index 6a2b2f4..b0df6c3 100644 (file)
@@ -17,6 +17,7 @@ set(USE_FMGEN ON)
 set(EXEC_TARGET emumulti8)
 set(FLAG_USE_Z80 ON)
 set(VMFILES_BASE
+                  i8253.cpp
                   io.cpp
                   
                   event.cpp
@@ -25,7 +26,7 @@ set(VMFILES_LIB
                   datarec.cpp
                   hd46505.cpp
                   i8251.cpp
-                  i8253.cpp
+#                 i8253.cpp
                   i8255.cpp
                   i8259.cpp
                   beep.cpp
index 8ab9241..325a2a2 100644 (file)
@@ -19,13 +19,14 @@ set(WITH_JOYSTICK ON)
 set(WITH_MOUSE ON) 
 
 set(VMFILES
+                  i8253.cpp
                   mz1p17.cpp
                   
                   event.cpp
                   io.cpp
 )
 set(VMFILES_LIB
-                  i8253.cpp
+#                 i8253.cpp
                   i8255.cpp
                   i8259.cpp
                   rp5c01.cpp
index 0f9b912..7a7309c 100644 (file)
@@ -20,6 +20,7 @@ set(WITH_MOUSE ON)
 
 set(VMFILES
 #         z80.cpp
+          i8253.cpp
           
           upd7220.cpp
    
@@ -29,7 +30,7 @@ set(VMFILES
 )
 set(VMFILES_LIB
           i8251.cpp
-          i8253.cpp
+#         i8253.cpp
           i8255.cpp
                   
           ls244.cpp
index e6fbf5f..b1c19ff 100644 (file)
@@ -21,7 +21,7 @@ set(s_vm_common_vm_srcs
        ../i8155.cpp
        ../i8237_base.cpp
        ../i8251.cpp
-       ../i8253.cpp
+#      ../i8253.cpp
        ../i8255.cpp
        ../i8259.cpp
 #      ../i86.cpp
@@ -126,8 +126,8 @@ if(WIN32)
 #        ${SDL2_LIBRARIES}
 #        )
 #set_target_properties(CSPcommon_vm PROPERTIES
-#                           SOVERSION 1.1.10
-#                           VERSION 1.1.10
+#                           SOVERSION 1.1.11
+#                           VERSION 1.1.11
 #                           LINK_INTERFACE_LIBRARIES ""
 #                           )
 #generate_export_header(CSPcommon_vm
@@ -144,8 +144,8 @@ else()
     ${s_vm_common_vm_srcs}
   )
   set_target_properties(CSPcommon_vm PROPERTIES 
-     SOVERSION 1.1.10
-     VERSION 1.1.10
+     SOVERSION 1.1.11
+     VERSION 1.1.11
   )
   INSTALL(TARGETS CSPcommon_vm DESTINATION ${LIBCSP_INSTALL_DIR})
 endif()
index ce39c5e..9ee59df 100644 (file)
@@ -11,8 +11,6 @@
 
 void I8253::initialize()
 {
-       DEVICE::initialize();
-       __HAS_I8254 = osd->check_feature(_T("HAS_I8254"));
        for(int ch = 0; ch < 3; ch++) {
                counter[ch].prev_out = true;
                counter[ch].prev_in = false;
@@ -26,16 +24,11 @@ void I8253::initialize()
                counter[ch].low_write = counter[ch].high_write = false;
                counter[ch].delay = false;
                counter[ch].start = false;
-//#ifdef HAS_I8254
-               if(__HAS_I8254) {
-                       // 8254 read-back command
-                       counter[ch].null_count = true;
-                       counter[ch].status_latched = false;
-               } else {
-                       counter[ch].null_count = false;
-                       counter[ch].status_latched = false;
-               }                       
-//#endif
+#ifdef HAS_I8254
+               // 8254 read-back command
+               counter[ch].null_count = true;
+               counter[ch].status_latched = false;
+#endif
        }
 }
 
@@ -76,9 +69,9 @@ void I8253::write_io8(uint32_t addr, uint32_t data)
                        }
                        counter[ch].high_write = false;
                }
-//#ifdef HAS_I8254
-               if(__HAS_I8254) counter[ch].null_count = true;
-//#endif
+#ifdef HAS_I8254
+               counter[ch].null_count = true;
+#endif
                // set signal
                if(counter[ch].mode == 0) {
                        set_signal(ch, false);
@@ -102,8 +95,7 @@ void I8253::write_io8(uint32_t addr, uint32_t data)
                
        case 3: // ctrl reg
                if((data & 0xc0) == 0xc0) {
-//#ifdef HAS_I8254
-                       if(!__HAS_I8254) break;
+#ifdef HAS_I8254
                        // i8254 read-back command
                        for(ch = 0; ch < 3; ch++) {
                                uint8_t bit = 2 << ch;
@@ -121,7 +113,7 @@ void I8253::write_io8(uint32_t addr, uint32_t data)
                                        latch_count(ch);
                                }
                        }
-//#endif
+#endif
                        break;
                }
                ch = (data >> 6) & 3;
@@ -145,9 +137,9 @@ void I8253::write_io8(uint32_t addr, uint32_t data)
                                stop_count(ch);
                                counter[ch].count_reg = 0;
 //                     }
-//#ifdef HAS_I8254
-                               if(__HAS_I8254) counter[ch].null_count = true;
-//#endif
+#ifdef HAS_I8254
+                       counter[ch].null_count = true;
+#endif
                } else if(!counter[ch].count_latched) {
                        latch_count(ch);
                }
@@ -163,12 +155,12 @@ uint32_t I8253::read_io8(uint32_t addr)
        case 0:
        case 1:
        case 2:
-//#ifdef HAS_I8254
-               if((__HAS_I8254) && (counter[ch].status_latched)) {
+#ifdef HAS_I8254
+               if(counter[ch].status_latched) {
                        counter[ch].status_latched = false;
                        return counter[ch].status;
                }
-//#endif
+#endif
                // if not latched, through current count
                if(!counter[ch].count_latched) {
                        if(!counter[ch].low_read && !counter[ch].high_read) {
@@ -250,9 +242,9 @@ void I8253::input_clock(int ch, int clock)
                clock -= 1;
                counter[ch].delay = false;
                counter[ch].count = COUNT_VALUE(ch);
-//#ifdef HAS_I8254
-               if(__HAS_I8254) counter[ch].null_count = false;
-//#endif
+#ifdef HAS_I8254
+               counter[ch].null_count = false;
+#endif
        }
        
        // update counter
@@ -275,9 +267,9 @@ loop:
        if(counter[ch].count <= 0) {
                if(counter[ch].mode == 0 || counter[ch].mode == 2 || counter[ch].mode == 3) {
                        counter[ch].count += tmp;
-//#ifdef HAS_I8254
-                       if(__HAS_I8254) counter[ch].null_count = false;
-//#endif
+#ifdef HAS_I8254
+                       counter[ch].null_count = false;
+#endif
                        goto loop;
                } else {
                        counter[ch].start = false;
@@ -437,13 +429,11 @@ void I8253::save_state(FILEIO* state_fio)
                state_fio->FputInt32(counter[i].mode);
                state_fio->FputBool(counter[i].delay);
                state_fio->FputBool(counter[i].start);
-//#ifdef HAS_I8254
-               if(__HAS_I8254) {
-                       state_fio->FputBool(counter[i].null_count);
-                       state_fio->FputBool(counter[i].status_latched);
-                       state_fio->FputUint8(counter[i].status);
-               }
-//#endif
+#ifdef HAS_I8254
+               state_fio->FputBool(counter[i].null_count);
+               state_fio->FputBool(counter[i].status_latched);
+               state_fio->FputUint8(counter[i].status);
+#endif
                state_fio->FputUint64(counter[i].freq);
                state_fio->FputInt32(counter[i].register_id);
                state_fio->FputUint32(counter[i].input_clk);
@@ -477,13 +467,11 @@ bool I8253::load_state(FILEIO* state_fio)
                counter[i].mode = state_fio->FgetInt32();
                counter[i].delay = state_fio->FgetBool();
                counter[i].start = state_fio->FgetBool();
-//#ifdef HAS_I8254
-               if(__HAS_I8254) {
-                       counter[i].null_count = state_fio->FgetBool();
-                       counter[i].status_latched = state_fio->FgetBool();
-                       counter[i].status = state_fio->FgetUint8();
-               }
-//#endif
+#ifdef HAS_I8254
+               counter[i].null_count = state_fio->FgetBool();
+               counter[i].status_latched = state_fio->FgetBool();
+               counter[i].status = state_fio->FgetUint8();
+#endif
                counter[i].freq = state_fio->FgetUint64();
                counter[i].register_id = state_fio->FgetInt32();
                counter[i].input_clk = state_fio->FgetUint32();
index 2c44af0..a54ca00 100644 (file)
@@ -10,8 +10,8 @@
 #ifndef _I8253_H_
 #define _I8253_H_
 
-//#include "vm.h"
-//#include "../emu.h"
+#include "vm.h"
+#include "../emu.h"
 #include "device.h"
 
 #define SIG_I8253_CLOCK_0      0
@@ -38,11 +38,11 @@ private:
                int mode;
                bool delay;
                bool start;
-//#ifdef HAS_I8254
+#ifdef HAS_I8254
                bool null_count;
                bool status_latched;
                uint8_t status;
-//#endif
+#endif
                // constant clock
                uint64_t freq;
                int register_id;
@@ -53,8 +53,6 @@ private:
                outputs_t outputs;
        } counter[3];
        uint64_t cpu_clocks;
-
-       bool __HAS_I8254;
        
        void input_clock(int ch, int clock);
        void input_gate(int ch, bool signal);
@@ -71,7 +69,7 @@ public:
                        initialize_output_signals(&counter[i].outputs);
                        counter[i].freq = 0;
                }
-               set_device_name(_T("i8253 PIT"));
+               set_device_name(_T("8253 PIT"));
        }
        ~I8253() {}
        
@@ -88,6 +86,7 @@ public:
        }
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
+       
        // unique functions
        void set_context_ch0(DEVICE* device, int id, uint32_t mask)
        {
index d8d7e44..abf9185 100644 (file)
@@ -21,8 +21,8 @@ elseif(BUILD_PC9801U)
 elseif(BUILD_PC9801VF) 
   add_library(vm_pc9801  ${BASIC_VM_FILES} )
 elseif(BUILD_PC9801VM) 
-#  add_library(vm_pc9801  ${BASIC_VM_FILES} itf.cpp)
-  add_library(vm_pc9801  ${BASIC_VM_FILES})
+  add_library(vm_pc9801  ${BASIC_VM_FILES} itf.cpp)
+#  add_library(vm_pc9801  ${BASIC_VM_FILES})
 elseif(BUILD_PC98DO) 
   add_library(vm_pc9801  ${BASIC_VM_FILES})
 endif()
index 8c1a7dc..d0ae5bc 100644 (file)
@@ -130,8 +130,7 @@ void DISPLAY::initialize()
                tvram[0x3fee] = 8;
        }
 #ifndef HAS_UPD4990A
-       //dll_cur_time_t cur_time;
-       cur_time_t cur_time;
+       dll_cur_time_t cur_time;
        get_host_time(&cur_time);
        tvram[0x3ffe] = TO_BCD(cur_time.year);
 #endif
index c3066b7..8a5cb0e 100644 (file)
@@ -108,9 +108,9 @@ void FLOPPY::write_io8(uint32_t addr, uint32_t data)
                                }
                                register_event(this, EVENT_TIMER, 100000, false, &timer_id);
                        }
-                       if(modereg & 4) {
-                               d_fdc->write_signal(SIG_UPD765A_MOTOR, data, 0x08);
-                       }
+//                     if(modereg & 4) {
+//                             d_fdc->write_signal(SIG_UPD765A_MOTOR, data, 0x08);
+//                     }
                        ctrlreg = data;
                }
                break;
@@ -122,9 +122,6 @@ void FLOPPY::write_io8(uint32_t addr, uint32_t data)
                        d_fdc->set_drive_type(0, DRIVE_TYPE_2DD);
                        d_fdc->set_drive_type(1, DRIVE_TYPE_2DD);
                }
-               if(((data & 4) == 0) && (((modereg & 1) != 0) || ((data & 1) != 0))) {
-                       d_fdc->write_signal(SIG_UPD765A_MOTOR, 0x01, 0x01);
-               }
                modereg = data;
                break;
 #endif
@@ -210,12 +207,10 @@ void FLOPPY::write_signal(int id, uint32_t data, uint32_t mask)
                }
                break;
        case SIG_FLOPPY_DRQ:
-               if(ctrlreg & 0x04) {
-                       if(modereg & 1) {
-                               d_dma->write_signal(SIG_I8237_CH2, data, mask);
-                       } else {
-                               d_dma->write_signal(SIG_I8237_CH3, data, mask);
-                       }
+               if(modereg & 1) {
+                       d_dma->write_signal(SIG_I8237_CH2, data, mask);
+               } else {
+                       d_dma->write_signal(SIG_I8237_CH3, data, mask);
                }
                break;
 #endif
index a135856..0896ed5 100644 (file)
@@ -13,7 +13,7 @@ ITF::ITF(VM *parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
 {
        itf = NULL;
        ipl = NULL;
-       itf_bank = PC98_ITF_ITF;
+       itf_bank = PC98_ITF_IPL;
 }
 
 ITF::~ITF()
@@ -22,14 +22,15 @@ ITF::~ITF()
 
 void ITF::reset(void)
 {
-       itf_bank = PC98_ITF_ITF;
+       itf_bank = PC98_ITF_IPL;
 }
 
 // See: http://www.webtech.co.jp/company/doc/undocumented_mem/io_mem.txt .
 void ITF::write_io8(uint32_t addr, uint32_t data)
 {
-       switch(addr & 0x1) {
+       switch(addr & 0x3) {
        case 0x1:
+#if 0
                printf("SET %05x %02x\n", addr, data);
                if((data & 0xff) == 0x10) {
 #if defined(_PCH98S)
@@ -45,6 +46,19 @@ void ITF::write_io8(uint32_t addr, uint32_t data)
                        itf_bank = PC98_ITF_ITF;
                }
 #endif
+#else
+               // From MAME0185
+               if(((data & 0xf0) == 0x00) || ((data & 0xf0) == 0x10)) {
+                       if((data & 0xed) == 0x00) {
+                               if((data & 0x02) == 0) {
+                                       itf_bank = PC98_ITF_ITF;
+                               } else {
+                                       itf_bank = PC98_ITF_IPL;
+                               }
+                       }
+               }
+          
+#endif
                break;
        default:
                break;
@@ -74,7 +88,7 @@ uint32_t ITF::read_memory_mapped_io8(uint32_t addr)
 {
        uint32_t raddr = addr & 0xfffff;
        // ToDo: Address with i286/i386/i486.
-       //if(raddr < 0xe8000) return 0xff; // OK?
+       if(raddr < 0xe8000) return 0xff; // OK?
        switch(itf_bank) {
        case PC98_ITF_IPL:
                if(ipl == NULL) return 0xff;
@@ -82,9 +96,10 @@ uint32_t ITF::read_memory_mapped_io8(uint32_t addr)
                break;
        case PC98_ITF_ITF:
                if(itf == NULL) return 0xff;
-               raddr = raddr & 0x7fff;
-               printf("DATA: %05x %02x\n", addr, itf[raddr]);
-               return itf[raddr];
+//   printf("%05x\n", raddr);
+               if(raddr < 0xf8000) return 0xff;
+               //printf("DATA: %05x %02x\n", addr, itf[raddr]);
+               return itf[raddr & 0x7fff];
                break;
 #if defined(_PCH98S)
        case PC98_ITF_ITF: