OSDN Git Service

[VM][COMMON_VM] Add RP5C01, uPD1990A and uPD16434.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 24 May 2017 14:54:41 +0000 (23:54 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 24 May 2017 14:54:41 +0000 (23:54 +0900)
23 files changed:
source/build-cmake/cmake/config_emupc9801.cmake
source/build-cmake/cmake/config_msx.cmake
source/build-cmake/cmake/config_mz2500.cmake
source/build-cmake/cmake/config_mz5500.cmake
source/build-cmake/cmake/config_pc8201.cmake
source/build-cmake/cmake/config_pc8801.cmake
source/build-cmake/cmake/config_x1.cmake
source/build-cmake/cmake/config_z80tvgame.cmake
source/build-cmake/fp200/CMakeLists.txt
source/build-cmake/j3100gt/CMakeLists.txt
source/build-cmake/j3100sl/CMakeLists.txt
source/build-cmake/mz2800/CMakeLists.txt
source/build-cmake/mz3500/CMakeLists.txt
source/build-cmake/n5200/CMakeLists.txt
source/build-cmake/pc2001/CMakeLists.txt
source/src/vm/common_vm/CMakeLists.txt
source/src/vm/noise.h
source/src/vm/rp5c01.cpp
source/src/vm/rp5c01.h
source/src/vm/upd16434.cpp
source/src/vm/upd16434.h
source/src/vm/upd1990a.cpp
source/src/vm/upd1990a.h

index 2e7e4ee..ae33503 100644 (file)
@@ -6,7 +6,6 @@ set(WITH_MOUSE ON)
 
 set(VMFILES
                   i8237.cpp
-                  upd1990a.cpp
                   upd7220.cpp
                   
                   event.cpp
@@ -21,6 +20,7 @@ set(VMFILES_LIB
                   i8259.cpp
                   ls244.cpp
                   pc80s31k.cpp
+                  upd1990a.cpp
                   upd7220_base.cpp
                   upd765a.cpp
                   ym2203.cpp
index 547ee1b..4c402d8 100644 (file)
@@ -8,7 +8,6 @@ message("** Start of configure CommonSourceProject,MSX Series Qt **")
 message("")
 
 set(VMFILES_BASE
-       i8255.cpp
        datarec.cpp
        event.cpp
        io.cpp
@@ -16,11 +15,12 @@ set(VMFILES_BASE
 )
 
 set(VMFILES_LIB
-       prnfile.cpp
-       ym2413.cpp
        ay_3_891x.cpp
-       pcm1bit.cpp
+       i8255.cpp
        not.cpp
+       pcm1bit.cpp
+       ym2413.cpp
+       prnfile.cpp
 )
 set(FLAG_USE_Z80 ON)
 
@@ -39,11 +39,11 @@ add_definitions(-D_CONFIGURE_WITH_CMAKE)
 add_definitions(-D_MSX_VDP_MESS)
 
 set(VMFILES_MSX2 ${VMFILES_BASE}
-       rp5c01.cpp
 )
 
 set(VMFILES_MSX2_LIB ${VMFILES_LIB}
        v9938.cpp
+       rp5c01.cpp
 )
 
 set(VMFILES_LIB ${VMFILES_LIB} disk.cpp)
@@ -72,26 +72,26 @@ set(VMFILES_LIB_HX20 ${VMFILES_LIB}
 )
 
 set(VMFILES_FSA1 ${VMFILES_BASE}
-       rp5c01.cpp
 )
 set(VMFILES_LIB_FSA1 ${VMFILES_LIB}
+       rp5c01.cpp
        v9938.cpp
        disk.cpp
 )
 
 set(VMFILES_HBF1XDJ ${VMFILES_BASE}
-       rp5c01.cpp
 )
 set(VMFILES_LIB_HBF1XDJ ${VMFILES_LIB}
+       rp5c01.cpp
        v9938.cpp
        disk.cpp
 )
 
 set(VMFILES_MSX2PLUS ${VMFILES_BASE}
-       rp5c01.cpp
 )
 
 set(VMFILES_LIB_MSX2PLUS ${VMFILES_LIB}
+       rp5c01.cpp
        v9938.cpp
        disk.cpp
 )
index 794f8b9..39cbcf0 100644 (file)
@@ -13,13 +13,12 @@ set(WITH_MOUSE ON)
 set(FLAG_USE_Z80 ON)
 set(VMFILES_2500
                   w3100a.cpp
-                  rp5c01.cpp
-                  
 )
 set(VMFILES_LIB_2500
-                  z80sio.cpp
                   ls393.cpp
+                  rp5c01.cpp
                   ym2203.cpp
+                  z80sio.cpp
 )
 
 set(VMFILES_BASE
index 071b155..87cd1d9 100644 (file)
@@ -10,7 +10,6 @@ set(VMFILES
 #                 i286.cpp
                   
                   i8237.cpp
-                  rp5c01.cpp
                   
                   upd7220.cpp
                   z80ctc.cpp
@@ -22,13 +21,14 @@ set(VMFILES
 
 set(VMFILES_LIB
                   i8237_base.cpp
-                  upd7220_base.cpp
                   i8255.cpp
                   i8259.cpp
                   ls393.cpp
                   not.cpp
                   
                   prnfile.cpp
+                  rp5c01.cpp
+                  upd7220_base.cpp
                   upd765a.cpp
                   ym2203.cpp
                   z80sio.cpp
index 4d0f43f..a95b6bc 100644 (file)
@@ -12,7 +12,6 @@ set(WITH_JOYSTICK OFF)
 set(WITH_MOUSE OFF)
 set(VMFILES
           i8080.cpp
-          upd1990a.cpp
                   
           io.cpp
           datarec.cpp
@@ -22,6 +21,7 @@ set(VMFILES
 set(VMFILES_LIB
           i8155.cpp
           pcm1bit.cpp
+          upd1990a.cpp
 )                 
 
 
index 447b3f6..ff072aa 100644 (file)
@@ -8,12 +8,6 @@ set(WITH_JOYSTICK ON)
 set(WITH_MOUSE ON)
 
 set(VMFILES
-#                 z80dma.cpp
-#
-#                 pc80s31k.cpp
-#                 upd765a.cpp
-                  
-                  
                   z80ctc.cpp
                   datarec.cpp
                   event.cpp
@@ -21,19 +15,21 @@ set(VMFILES
                   memory.cpp
 )
 set(VMFILES_LIB
-               z80dma.cpp
-               z80sio.cpp
+               beep.cpp
+               i8251.cpp
+               i8255.cpp
   
                pc80s31k.cpp
-               upd765a.cpp
-               beep.cpp
                pcm1bit.cpp
+               upd1990a.cpp
+               upd765a.cpp
+               ym2203.cpp
                z80pio.cpp
+               z80dma.cpp
+               z80sio.cpp
                disk.cpp
+               
                prnfile.cpp
-               ym2203.cpp
-               i8251.cpp
-               i8255.cpp
 )
 set(FLAG_USE_Z80 ON)
 
@@ -61,22 +57,18 @@ add_definitions(-D_CONFIGURE_WITH_CMAKE)
 if(BUILD_PC8001SR)
   set(EXEC_TARGET emupc8001sr)
   add_definitions(-D_PC8001SR)
-  set(VMFILES ${VMFILES}  upd1990a.cpp)
   set(RESOURCE ${CMAKE_SOURCE_DIR}/../../src/qt/common/qrc/pc8001mk2sr.qrc)
   
 elseif(BUILD_PC8801MA)
   set(EXEC_TARGET emupc8801ma)
   add_definitions(-D_PC8801MA)
-  set(VMFILES ${VMFILES}
-              upd1990a.cpp
-  )
   set(RESOURCE ${CMAKE_SOURCE_DIR}/../../src/qt/common/qrc/pc8801ma.qrc)
 endif()
 
 add_definitions(-DPC88_EXRAM_BANKS=${PC88_EXTRAM_PAGES})
 
 if(USE_PCG)
-  set(VMFILES ${VMFILES}
+  set(VMFILES_LIB ${VMFILES_LIB}
             i8253.cpp
       )      
   add_definitions(-DSUPPORT_PC88_PCG8100)
index 00b565a..d3aae42 100644 (file)
@@ -13,7 +13,6 @@ set(USE_FMGEN ON)
 set(WITH_JOYSTICK ON)
 set(WITH_MOUSE ON)
 set(VMFILES
-                  upd1990a.cpp
                   z80ctc.cpp
 
                   datarec.cpp
@@ -23,17 +22,17 @@ set(VMFILES
                   mz1p17.cpp
 )
 set(VMFILES_LIB
-                  z80sio.cpp
-                  z80pio.cpp
-
+                  ay_3_891x.cpp
+                  beep.cpp
                   i8255.cpp
                   hd46505.cpp
-                  mcs48.cpp
-                  beep.cpp
-                  ym2151.cpp
-                  ym2203.cpp
-                  ay_3_891x.cpp
                   mb8877.cpp
+                  upd1990a.cpp
+                  ym2151.cpp
+#                 ym2203.cpp
+                  z80sio.cpp
+                  z80pio.cpp
+                  
                   disk.cpp
                   prnfile.cpp
 )
index 078b7db..c2e35d6 100644 (file)
@@ -21,8 +21,8 @@ set(WITH_DEBUGGER ON CACHE BOOL "Build with debugger.")
 add_definitions(-D_Z80TVGAME)
 if(BUILD_I8255)
   set(EXEC_TARGET emuz80tvgame_i8255)
-  set(VMFILES ${VMFILES_BASE} i8255.cpp)
-  set(VMFILES_LIB   pcm1bit.cpp)
+  set(VMFILES ${VMFILES_BASE})
+  set(VMFILES_LIB   pcm1bit.cpp i8255.cpp)
   add_definitions(-D_USE_I8255)
   set(RESOURCE ${CMAKE_SOURCE_DIR}/../../src/qt/common/qrc/z80tvgame_i8255.qrc)
 else()
index f9ab5ef..37b9b7d 100644 (file)
@@ -21,13 +21,13 @@ set(WITH_MOUSE OFF)
 
 set(VMFILES
                   i8080.cpp
-                  rp5c01.cpp
                   
                   datarec.cpp
                   memory.cpp
                   event.cpp
 )
 set(VMFILES_LIB
+                  rp5c01.cpp
 )
 
 set(BUILD_SHARED_LIBS OFF)
index f711d0f..b507dbb 100644 (file)
@@ -63,7 +63,7 @@ elseif(BUILD_J3100SL)
   set(EXEC_TARGET emuj3100sl)
   set(RESOURCE ${CMAKE_SOURCE_DIR}/../../src/qt/common/qrc/j3100sl.qrc)
   add_definitions(-D_J3100SL)
-  set(VMFILES ${VMFILES
+  set(VMFILES_LIB ${VMFILES_LIB
 #               i86.cpp 
               rp5c01.cpp
               )
@@ -72,7 +72,7 @@ elseif(BUILD_J3100SS)
   set(EXEC_TARGET emuj3100ss)
   set(RESOURCE ${CMAKE_SOURCE_DIR}/../../src/qt/common/qrc/j3100ss.qrc)
   add_definitions(-D_J3100SS)
-  set(VMFILES ${VMFILES
+  set(VMFILES_LIB ${VMFILES_LIB
 #               i86.cpp 
               rp5c01.cpp
               )
@@ -80,7 +80,7 @@ elseif(BUILD_J3100SE)
   set(EXEC_TARGET emuj3100se)
   set(RESOURCE ${CMAKE_SOURCE_DIR}/../../src/qt/common/qrc/j3100se.qrc)
   add_definitions(-D_J3100SE)
-  set(VMFILES ${VMFILES
+  set(VMFILES_LIB ${VMFILES_LIB
 #               i86.cpp 
               rp5c01.cpp
               )
index 1bd4205..7a36dfd 100644 (file)
@@ -64,7 +64,7 @@ elseif(BUILD_J3100SL)
   set(EXEC_TARGET emuj3100sl)
   set(RESOURCE ${CMAKE_SOURCE_DIR}/../../src/qt/common/qrc/j3100sl.qrc)
   add_definitions(-D_J3100SL)
-  set(VMFILES ${VMFILES
+  set(VMFILES_LIB ${VMFILES_LIB
 #               i86.cpp 
               rp5c01.cpp
               )
@@ -73,7 +73,7 @@ elseif(BUILD_J3100SS)
   set(EXEC_TARGET emuj3100ss)
   set(RESOURCE ${CMAKE_SOURCE_DIR}/../../src/qt/common/qrc/j3100ss.qrc)
   add_definitions(-D_J3100SS)
-  set(VMFILES ${VMFILES
+  set(VMFILES_LIB ${VMFILES_LIB
                i86.cpp 
               rp5c01.cpp
               )
@@ -81,7 +81,7 @@ elseif(BUILD_J3100SE)
   set(EXEC_TARGET emuj3100se)
   set(RESOURCE ${CMAKE_SOURCE_DIR}/../../src/qt/common/qrc/j3100se.qrc)
   add_definitions(-D_J3100SE)
-  set(VMFILES ${VMFILES
+  set(VMFILES_LIB ${VMFILES_LIB
 #               i86.cpp 
               rp5c01.cpp
               )
index c0b15a2..8ab9241 100644 (file)
@@ -19,8 +19,6 @@ set(WITH_JOYSTICK ON)
 set(WITH_MOUSE ON) 
 
 set(VMFILES
-                  rp5c01.cpp
-
                   mz1p17.cpp
                   
                   event.cpp
@@ -30,6 +28,7 @@ set(VMFILES_LIB
                   i8253.cpp
                   i8255.cpp
                   i8259.cpp
+                  rp5c01.cpp
                   z80sio.cpp
                   z80pio.cpp
                   prnfile.cpp
index 93e4dd0..0f9b912 100644 (file)
@@ -21,7 +21,6 @@ set(WITH_MOUSE ON)
 set(VMFILES
 #         z80.cpp
           
-          upd1990a.cpp
           upd7220.cpp
    
           mz1p17.cpp
@@ -36,6 +35,7 @@ set(VMFILES_LIB
           ls244.cpp
           not.cpp
           pcm1bit.cpp
+          upd1990a.cpp
           upd765a.cpp
           upd7220_base.cpp
           
index 1b8bf71..de92d8f 100644 (file)
@@ -24,8 +24,6 @@ set(WITH_MOUSE ON)
 set(VMFILES_BASE
 #                  i386.cpp
                   i8237.cpp
-                  
-                  upd1990a.cpp
                   upd7220.cpp
                   
                   io.cpp
@@ -38,6 +36,7 @@ set(VMFILES_LIB
                   i8253.cpp
                   i8255.cpp
                   i8259.cpp
+                  upd1990a.cpp
                   upd7220_base.cpp
                   upd765a.cpp
                   disk.cpp
index 25f64b2..230e96c 100644 (file)
@@ -21,7 +21,6 @@ set(WITH_DEBUGGER ON)
 
 set(VMFILES
 #                 upd16434.cpp
-                  upd1990a.cpp
                   upd7810.cpp
                   
                   datarec.cpp
@@ -31,6 +30,7 @@ set(VMFILES
 )
 set(VMFILES_LIB
                   upd16434.cpp
+                  upd1990a.cpp
                   pcm1bit.cpp
 )
 set(BUILD_SHARED_LIBS OFF)
index 00a552f..c1bb8dc 100644 (file)
@@ -55,7 +55,7 @@ set(s_vm_common_vm_srcs
        ../pcm1bit.cpp
        ../prnfile.cpp
        ../ptf20.cpp
-#      ../rp5c01.cpp
+       ../rp5c01.cpp
 #      ../scsi_cdrom.cpp
 #      ../scsi_dev.cpp
 #      ../scsi_hdd.cpp
@@ -68,7 +68,7 @@ set(s_vm_common_vm_srcs
        ../tms9918a.cpp
 #      ../tms9995.cpp
        ../upd16434.cpp
-#      ../upd1990a.cpp
+       ../upd1990a.cpp
        ../upd4991a.cpp
        ../upd71071.cpp
        ../upd7220_base.cpp
@@ -120,8 +120,8 @@ else()
     ${s_vm_common_vm_srcs}
   )
   set_target_properties(CSPcommon_vm PROPERTIES 
-     SOVERSION 1.1.7
-     VERSION 1.1.7
+     SOVERSION 1.1.8
+     VERSION 1.1.8
   )
   INSTALL(TARGETS CSPcommon_vm DESTINATION ${LIBCSP_INSTALL_DIR})
 endif()
index 86e591c..99fe269 100644 (file)
@@ -10,8 +10,8 @@
 #ifndef _NOISE_H_
 #define _NOISE_H_
 
-#include "vm.h"
-#include "../emu.h"
+//#include "vm.h"
+//#include "../emu.h"
 #include "device.h"
 
 class NOISE : public DEVICE
index 74a3ff7..80a6884 100644 (file)
@@ -18,19 +18,23 @@ DLL_PREFIX_I struct cur_time_s cur_time;
 void RP5C01::initialize()
 {
        DEVICE::initialize();
-#ifndef HAS_RP5C15
-       // load ram image
-       memset(ram, 0, sizeof(ram));
-       modified = false;
-       
-       // FIXME: we need to consider the multiple chips case
-       FILEIO* fio = new FILEIO();
-       if(fio->Fopen(create_local_path(_T("RP5C01.BIN")), FILEIO_READ_BINARY)) {
-               fio->Fread(ram, sizeof(ram), 1);
-               fio->Fclose();
+       __HAS_RP5C15 = osd->check_feature(_T("HAS_RP5C15"));
+       if(__HAS_RP5C15) set_device_name(_T("RP-5C15 RTC"));
+//#ifndef HAS_RP5C15
+       if(!__HAS_RP5C15) {
+               // load ram image
+               memset(ram, 0, sizeof(ram));
+               modified = false;
+               
+               // FIXME: we need to consider the multiple chips case
+               FILEIO* fio = new FILEIO();
+               if(fio->Fopen(create_local_path(_T("RP5C01.BIN")), FILEIO_READ_BINARY)) {
+                       fio->Fread(ram, sizeof(ram), 1);
+                       fio->Fclose();
+               }
+               delete fio;
        }
-       delete fio;
-#endif
+//#endif
        
        // initialize rtc
        memset(regs, 0, sizeof(regs));
@@ -50,49 +54,59 @@ void RP5C01::initialize()
 
 void RP5C01::release()
 {
-#ifndef HAS_RP5C15
-       // save ram image
-       if(modified) {
-               // FIXME: we need to consider the multiple chips case
-               FILEIO* fio = new FILEIO();
-               if(fio->Fopen(create_local_path(_T("RP5C01.BIN")), FILEIO_WRITE_BINARY)) {
-                       fio->Fwrite(ram, sizeof(ram), 1);
-                       fio->Fclose();
+//#ifndef HAS_RP5C15
+       if(!__HAS_RP5C15) {
+               // save ram image
+               if(modified) {
+                       // FIXME: we need to consider the multiple chips case
+                       FILEIO* fio = new FILEIO();
+                       if(fio->Fopen(create_local_path(_T("RP5C01.BIN")), FILEIO_WRITE_BINARY)) {
+                               fio->Fwrite(ram, sizeof(ram), 1);
+                               fio->Fclose();
+                       }
+                       delete fio;
                }
-               delete fio;
        }
-#endif
+//#endif
 }
 
 void RP5C01::write_io8(uint32_t addr, uint32_t data)
 {
        addr &= 0x0f;
        if(addr <= 0x0c) {
-#ifndef HAS_RP5C15
-               switch(regs[0x0d] & 3) {
-#else
-               switch(regs[0x0d] & 1) {
-#endif
+               uint8_t nmask;
+               if(!__HAS_RP5C15) {
+                       nmask = 3;
+               } else {
+                       nmask = 1;
+               }
+//#ifndef HAS_RP5C15
+//             switch(regs[0x0d] & 3) {
+//#else
+               switch(regs[0x0d] & nmask) {
+//#endif
                case 0:
                        if(time[addr] != data) {
                                time[addr] = data;
                                write_to_cur_time();
                        }
                        return;
-#ifndef HAS_RP5C15
+//#ifndef HAS_RP5C15
                case 2:
+                       if(__HAS_RP5C15) break;
                        if(ram[addr] != data) {
                                ram[addr] = data;
                                modified = true;
                        }
                        return;
                case 3:
+                       if(__HAS_RP5C15) break;
                        if(ram[addr + 13] != data) {
                                ram[addr + 13] = data;
                                modified = true;
                        }
                        return;
-#endif
+//#endif
                }
        }
        
@@ -105,21 +119,28 @@ void RP5C01::write_io8(uint32_t addr, uint32_t data)
                        read_from_cur_time();
                }
        } else if(addr == 0x0f) {
-#ifndef HAS_RP5C15
-               switch(regs[0x0d] & 3) {
-#else
-               switch(regs[0x0d] & 1) {
-#endif
+               uint8_t nmask;
+               if(!__HAS_RP5C15) {
+                       nmask = 3;
+               } else {
+                       nmask = 1;
+               }
+//#ifndef HAS_RP5C15
+//             switch(regs[0x0d] & 3) {
+//#else
+               switch(regs[0x0d] & nmask) {
+//#endif
                case 0:
                        if(data & 3) {
                                // timer reset
                        }
                        break;
                case 1:
-#ifndef HAS_RP5C15
+//#ifndef HAS_RP5C15
                case 2:
                case 3:
-#endif
+//#endif
+                       if(__HAS_RP5C15) break;
                        if(data & 2) {
                                // timer reset
                        }
@@ -138,19 +159,27 @@ uint32_t RP5C01::read_io8(uint32_t addr)
 {
        addr &= 0x0f;
        if(addr <= 0x0c) {
-#ifndef HAS_RP5C15
-               switch(regs[0x0d] & 3) {
-#else
-               switch(regs[0x0d] & 1) {
-#endif
+               uint8_t nmask;
+               if(!__HAS_RP5C15) {
+                       nmask = 3;
+               } else {
+                       nmask = 1;
+               }
+//#ifndef HAS_RP5C15
+//             switch(regs[0x0d] & 3) {
+//#else
+               switch(regs[0x0d] & nmask) {
+//#endif
                case 0:
                        return time[addr];
-#ifndef HAS_RP5C15
+//#ifndef HAS_RP5C15
                case 2:
+                       if(__HAS_RP5C15) return regs[addr];
                        return ram[addr];
                case 3:
+                       if(__HAS_RP5C15) return regs[addr];
                        return ram[addr + 13];
-#endif
+//#endif
                }
        }
        if(addr == 0x0b) {
@@ -286,10 +315,12 @@ void RP5C01::save_state(FILEIO* state_fio)
        state_fio->FputInt32(register_id);
        state_fio->Fwrite(regs, sizeof(regs), 1);
        state_fio->Fwrite(time, sizeof(time), 1);
-#ifndef HAS_RP5C15
-       state_fio->Fwrite(ram, sizeof(ram), 1);
-       state_fio->FputBool(modified);
-#endif
+//#ifndef HAS_RP5C15
+       if(!__HAS_RP5C15) {
+               state_fio->Fwrite(ram, sizeof(ram), 1);
+               state_fio->FputBool(modified);
+       }
+//#endif
        state_fio->FputBool(alarm);
        state_fio->FputBool(pulse_1hz);
        state_fio->FputBool(pulse_16hz);
@@ -310,10 +341,12 @@ bool RP5C01::load_state(FILEIO* state_fio)
        register_id = state_fio->FgetInt32();
        state_fio->Fread(regs, sizeof(regs), 1);
        state_fio->Fread(time, sizeof(time), 1);
-#ifndef HAS_RP5C15
-       state_fio->Fread(ram, sizeof(ram), 1);
-       modified = state_fio->FgetBool();
-#endif
+//#ifndef HAS_RP5C15
+       if(!__HAS_RP5C15) {
+               state_fio->Fread(ram, sizeof(ram), 1);
+               modified = state_fio->FgetBool();
+       }
+//#endif
        alarm = state_fio->FgetBool();
        pulse_1hz = state_fio->FgetBool();
        pulse_16hz = state_fio->FgetBool();
index b0dcd5e..d5db22f 100644 (file)
 #ifndef _RP5C01_H_
 #define _RP5C01_H_
 
-#include "vm.h"
-#include "../emu.h"
+//#include "vm.h"
+//#include "../emu.h"
 #include "device.h"
 
-//class VM;
-//class EMU;
+class VM;
+class EMU;
 class RP5C01 : public DEVICE
 {
 private:
@@ -28,12 +28,14 @@ private:
        
        uint8_t regs[16];
        uint8_t time[13];
-#ifndef HAS_RP5C15
+//#ifndef HAS_RP5C15
        uint8_t ram[26];
        bool modified;
-#endif
+//#endif
        bool alarm, pulse_1hz, pulse_16hz;
        int count_16hz;
+
+       bool __HAS_RP5C15;
        
        void update_pulse();
        void read_from_cur_time();
index 99e1f92..69a9753 100644 (file)
@@ -8,8 +8,8 @@
        [ uPD16434 ]
 */
 
-#include "vm.h"
-#include "emu.h"
+//#include "vm.h"
+//#include "emu.h"
 #include "upd16434.h"
 
 /*
@@ -326,6 +326,11 @@ static const uint8_t font[5 * 256] = {
        0x00, 0x00, 0x00, 0x00, 0x00,
 };
 
+void UPD16434::initialize()
+{
+   DEVICE::initialize();
+}
+
 void UPD16434::reset()
 {
        pointer = 0;
@@ -437,14 +442,14 @@ void UPD16434::draw(int xoffset)
        scrntype_t color_back = RGB_COLOR(160, 168, 160);       // back
        
        for(int y = 0; y < 24; y++) {
-               scrntype_t* dest = emu->get_screen_buffer(y) + xoffset;
+               scrntype_t* dest = osd->get_vm_screen_buffer(y) + xoffset;
                for(int x = 0; x < 60; x++) {
                        dest[x] = color_back;
                }
        }
        for(int b = 0; b < 8; b++) {
-               scrntype_t* dest_u = emu->get_screen_buffer(b + (b == 7) +  2) + xoffset;
-               scrntype_t* dest_l = emu->get_screen_buffer(b + (b == 7) + 13) + xoffset;
+               scrntype_t* dest_u = osd->get_vm_screen_buffer(b + (b == 7) +  2) + xoffset;
+               scrntype_t* dest_l = osd->get_vm_screen_buffer(b + (b == 7) + 13) + xoffset;
                uint8_t bit = 0x01 << b;
                
                for(int j = 0; j < 0x32; j++) {
index ac970eb..d6dd893 100644 (file)
@@ -36,6 +36,7 @@ public:
        ~UPD16434() {}
        
        // common functions
+       void initialize();
        void reset();
        void save_state(FILEIO* state_fio);
        bool load_state(FILEIO* state_fio);
index b8a63e4..1021e0c 100644 (file)
@@ -18,6 +18,8 @@ DLL_PREFIX_I struct cur_time_s cur_time;
 void UPD1990A::initialize()
 {
        DEVICE::initialize();
+       __HAS_UPD4990A = osd->check_feature(_T("HAS_UPD4990A"));
+       if(__HAS_UPD4990A) set_device_name(_T("uPD4990A_RTC"));
        // initialize rtc
        get_host_time(&cur_time);
        
@@ -33,15 +35,19 @@ void UPD1990A::write_signal(int id, uint32_t data, uint32_t mask)
                if(!clk && next) {
                        if((mode & 0x0f) == 1) {
                                uint64_t bit = 1;
-#ifdef HAS_UPD4990A
-                               if(mode & 0x80) {
-                                       bit <<= (52 - 1);
+//#ifdef HAS_UPD4990A
+                               if(__HAS_UPD4990A) {
+                                       if(mode & 0x80) {
+                                               bit <<= (52 - 1);
+                                       } else {
+//#endif
+                                               bit <<= (40 - 1);
+//#ifdef HAS_UPD4990A
+                                       }
                                } else {
-#endif
+//#endif
                                        bit <<= (40 - 1);
-#ifdef HAS_UPD4990A
-                               }
-#endif
+                               }                                       
                                shift_data >>= 1;
                                if(din) {
                                        shift_data |= bit;
@@ -53,23 +59,27 @@ void UPD1990A::write_signal(int id, uint32_t data, uint32_t mask)
                                dout_changed = true;
                                write_signals(&outputs_dout, (shift_data & 1) ? 0xffffffff : 0);
                        }
-#ifdef HAS_UPD4990A
-                       shift_cmd = (shift_cmd >> 1) | (din ? 8 : 0);
-#endif
+//#ifdef HAS_UPD4990A
+                       if(__HAS_UPD4990A) shift_cmd = (shift_cmd >> 1) | (din ? 8 : 0);
+//#endif
                }
                clk = next;
        } else if(id == SIG_UPD1990A_STB) {
                bool next = ((data & mask) != 0);
                if(!stb && next/* && !clk*/) {
-#ifdef HAS_UPD4990A
-                       if(cmd == 7) {
-                               mode = shift_cmd | 0x80;
+//#ifdef HAS_UPD4990A
+                       if(__HAS_UPD4990A) {
+                               if(cmd == 7) {
+                                       mode = shift_cmd | 0x80;
+                               } else {
+//#endif
+                                       mode = cmd;
+//#ifdef HAS_UPD4990A
+                               }
                        } else {
-#endif
                                mode = cmd;
-#ifdef HAS_UPD4990A
                        }
-#endif
+//#endif
                        switch(mode & 0x0f) {
                        case 0x02:
                                {
@@ -85,14 +95,16 @@ void UPD1990A::write_signal(int id, uint32_t data, uint32_t mask)
                                        cur_time.day_of_week = tmp & 0x0f;
                                        tmp >>= 4;
                                        cur_time.month = tmp & 0x0f;
-#ifdef HAS_UPD4990A
-                                       if(mode & 0x80) {
-                                               tmp >>= 4;
-                                               cur_time.year = FROM_BCD(tmp);
-                                               cur_time.update_year();
-                                               cur_time.update_day_of_week();
+//#ifdef HAS_UPD4990A
+                                       if(__HAS_UPD4990A) {
+                                               if(mode & 0x80) {
+                                                       tmp >>= 4;
+                                                       cur_time.year = FROM_BCD(tmp);
+                                                       cur_time.update_year();
+                                                       cur_time.update_day_of_week();
+                                               }
                                        }
-#endif
+//#endif
                                }
                                hold = true;
                                break;
@@ -100,12 +112,14 @@ void UPD1990A::write_signal(int id, uint32_t data, uint32_t mask)
                                // after all bits are read, lsb of second data can be read
                                shift_data = TO_BCD(cur_time.second);
                                //shift_data = 0;
-#ifdef HAS_UPD4990A
-                               if(mode & 0x80) {
-                                       shift_data <<= 8;
-                                       shift_data |= TO_BCD(cur_time.year);
+//#ifdef HAS_UPD4990A
+                               if(__HAS_UPD4990A) {
+                                       if(mode & 0x80) {
+                                               shift_data <<= 8;
+                                               shift_data |= TO_BCD(cur_time.year);
+                                       }
                                }
-#endif
+//#endif
                                shift_data <<= 4;
                                shift_data |= cur_time.month;
                                shift_data <<= 4;
@@ -126,26 +140,28 @@ void UPD1990A::write_signal(int id, uint32_t data, uint32_t mask)
                        case 0x04:
                        case 0x05:
                        case 0x06:
-#ifdef HAS_UPD4990A
+//#ifdef HAS_UPD4990A
                        case 0x07:
                        case 0x08:
                        case 0x09:
                        case 0x0a:
                        case 0x0b:
-#endif
+//#endif
+                               if(!__HAS_UPD4990A && ((mode & 0x0f) > 0x06)) break;
+
                                if(tpmode != (mode & 0x0f)) {
                                        if(outputs_tp.count != 0) {
                                                static const double tbl[] = {
                                                        1000000.0 / 128.0,      // 64Hz
                                                        1000000.0 / 512.0,      // 256Hz
                                                        1000000.0 / 2048.0,     // 2048Hz
-#ifdef HAS_UPD4990A
+//#ifdef HAS_UPD4990A
                                                        1000000.0 / 4098.0,     // 4096Hz
                                                        1000000.0,              // 1sec
                                                        1000000.0 * 10,         // 10sec
                                                        1000000.0 * 30,         // 30sec
                                                        1000000.0 * 60          // 60sec
-#endif
+//#endif
                                                };
                                                if(register_id_tp != -1) {
                                                        cancel_event(this, register_id_tp);
@@ -156,6 +172,8 @@ void UPD1990A::write_signal(int id, uint32_t data, uint32_t mask)
                                        tpmode = mode & 0x0f;
                                }
                                break;
+                       default:
+                               break;
                        }
                        // reset counter hold
                        switch(mode & 0x0f) {
@@ -233,9 +251,9 @@ void UPD1990A::save_state(FILEIO* state_fio)
        state_fio->FputUint32(dout);
        state_fio->FputBool(dout_changed);
        state_fio->FputInt32(register_id_tp);
-#ifdef HAS_UPD4990A
-       state_fio->FputUint8(shift_cmd);
-#endif
+//#ifdef HAS_UPD4990A
+       if(__HAS_UPD4990A) state_fio->FputUint8(shift_cmd);
+//#endif
 }
 
 bool UPD1990A::load_state(FILEIO* state_fio)
@@ -262,9 +280,9 @@ bool UPD1990A::load_state(FILEIO* state_fio)
        dout = state_fio->FgetUint32();
        dout_changed = state_fio->FgetBool();
        register_id_tp = state_fio->FgetInt32();
-#ifdef HAS_UPD4990A
-       shift_cmd = state_fio->FgetUint8();
-#endif
+//#ifdef HAS_UPD4990A
+       if(__HAS_UPD4990A) shift_cmd = state_fio->FgetUint8();
+//#endif
        return true;
 }
 
index baf449e..af9b4f3 100644 (file)
@@ -18,8 +18,8 @@
 #define SIG_UPD1990A_C2                5
 #define SIG_UPD1990A_DIN       6
 
-#include "vm.h"
-#include "../emu.h"
+//#include "vm.h"
+//#include "../emu.h"
 #include "device.h"
 
 class UPD1990A : public DEVICE
@@ -39,10 +39,10 @@ private:
        bool dout_changed;
        int register_id_tp;
        
-#ifdef HAS_UPD4990A
+//#ifdef HAS_UPD4990A
        uint8_t shift_cmd;
-#endif
-       
+//#endif
+       bool __HAS_UPD4990A;    
 public:
        UPD1990A(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
        {
@@ -54,13 +54,13 @@ public:
                hold = false;
                dout = 0;
                dout_changed = false;
-#ifdef HAS_UPD4990A
+               __HAS_UPD4990A = false;
+//#ifdef HAS_UPD4990A
                shift_cmd = 0;
-               set_device_name(_T("uPD4990A RTC"));
-#else
-               set_device_name(_T("uPD1990A RTC"));
-#endif
+//             set_device_name(_T("uPD4990A RTC"));
+//#else
                set_device_name(_T("uPD1990A RTC"));
+//#endif
        }
        ~UPD1990A() {}