From a3d44eb0d674170fc6b417e6b47ef903826c5eee Mon Sep 17 00:00:00 2001 From: "K.Ohta" Date: Fri, 28 Apr 2017 01:49:25 +0900 Subject: [PATCH] [General] Merge upstream 2017-04-16. --- source/build-cmake/cmake/config_commonsource.cmake | 3 +- source/build-cmake/cmake/config_sharedlibs.cmake | 3 +- source/history.txt | 18 ++++++ source/src/common.cpp | 74 ++++++++++++++++++---- source/src/common.h | 3 + source/src/vm/device.h | 4 +- source/src/vm/i386.h | 4 +- source/src/vm/i86.h | 4 +- source/src/vm/m6502.cpp | 2 +- source/src/vm/mc6809.h | 4 +- source/src/vm/mcs48.h | 4 +- source/src/vm/mz700/mz700.h | 13 ++-- 12 files changed, 102 insertions(+), 34 deletions(-) diff --git a/source/build-cmake/cmake/config_commonsource.cmake b/source/build-cmake/cmake/config_commonsource.cmake index 320326a92..a73e416c1 100644 --- a/source/build-cmake/cmake/config_commonsource.cmake +++ b/source/build-cmake/cmake/config_commonsource.cmake @@ -6,7 +6,8 @@ include(CheckFunctionExists) if(USE_DEVICES_SHARED_LIB) - add_definitions(-DUSE_DEVICES_SHARED_LIB) + //add_definitions(-DUSE_DEVICES_SHARED_LIB) + add_definitions(-DUSE_SHARED_DLL) set(I386_CPPS libcpu_newdev/i386.cpp libcpu_newdev/libcpu_i386/i386_real.cpp diff --git a/source/build-cmake/cmake/config_sharedlibs.cmake b/source/build-cmake/cmake/config_sharedlibs.cmake index 5bd1a4520..001440cde 100644 --- a/source/build-cmake/cmake/config_sharedlibs.cmake +++ b/source/build-cmake/cmake/config_sharedlibs.cmake @@ -11,7 +11,8 @@ cmake_policy(SET CMP0011 NEW) include(CheckFunctionExists) if(USE_DEVICES_SHARED_LIB) - add_definitions(-DUSE_DEVICES_SHARED_LIB) + #add_definitions(-DUSE_DEVICES_SHARED_LIB) + add_definitions(-DUSE_SHARED_DLL) endif() # Use cmake if enabled. find_program(USE_CCACHE ccache) diff --git a/source/history.txt b/source/history.txt index 1b63cf4ee..f0d5070b8 100644 --- a/source/history.txt +++ b/source/history.txt @@ -1,3 +1,21 @@ +4/16/2017 + +[VM/IO] revert the fix in 4/15/2017 +[VM/SN76489AN] revert the fix in 4/15/2017 + + +4/15/2017 + +[COMMON] add muldiv_s32 and muldiv_u32 to multiple 32bit integer +[COMMON] fix functions to support symbols + +[VM/IO] improve to use read/write_io8/16/32w() to get wait clock from device +[VM/SN76489AN] improve to return 32 + 16 * n for wait clock + +[MZ700] improve correct cpu clock and frame rate +[MZ800] improve correct cpu clock and frame rate + + 4/2/2017 [RESOURCE] improve menu items diff --git a/source/src/common.cpp b/source/src/common.cpp index 680e79f28..99b80b4ca 100644 --- a/source/src/common.cpp +++ b/source/src/common.cpp @@ -674,6 +674,44 @@ const _TCHAR *DLL_PREFIX create_string(const _TCHAR* format, ...) return (const _TCHAR *)buffer[output_index]; } +int32_t DLL_PREFIX muldiv_s32(int32_t nNumber, int32_t nNumerator, int32_t nDenominator) +{ + try { + int64_t tmp; + tmp = (int64_t)nNumber; + tmp *= (int64_t)nNumerator; + tmp /= (int64_t)nDenominator; + return (int32_t)tmp; + } catch(...) { + double tmp; + tmp = (double)nNumber; + tmp *= (double)nNumerator; + tmp /= (double)nDenominator; + if(tmp < 0) { + return (int32_t)(tmp - 0.5); + } else { + return (int32_t)(tmp + 0.5); + } + } +} + +uint32_t DLL_PREFIX muldiv_u32(uint32_t nNumber, uint32_t nNumerator, uint32_t nDenominator) +{ + try { + uint64_t tmp; + tmp = (uint64_t)nNumber; + tmp *= (uint64_t)nNumerator; + tmp /= (uint64_t)nDenominator; + return (uint32_t)tmp; + } catch(...) { + double tmp; + tmp = (double)nNumber; + tmp *= (double)nNumerator; + tmp /= (double)nDenominator; + return (uint32_t)(tmp + 0.5); + } +} + uint32_t DLL_PREFIX get_crc32(uint8_t data[], int size) { static bool initialized = false; @@ -863,12 +901,14 @@ bool DLL_PREFIX cur_time_t::load_state(void *f) const _TCHAR* DLL_PREFIX get_symbol(symbol_t *first_symbol, uint32_t addr) { - static _TCHAR name[1024]; + static _TCHAR name[8][1024]; + static unsigned int table_index = 0; + unsigned int output_index = (table_index++) & 7; for(symbol_t* symbol = first_symbol; symbol; symbol = symbol->next_symbol) { if(symbol->addr == addr) { - my_tcscpy_s(name, 1024, symbol->name); - return name; + my_tcscpy_s(name[output_index], 1024, symbol->name); + return name[output_index]; } } return NULL; @@ -876,32 +916,40 @@ const _TCHAR* DLL_PREFIX get_symbol(symbol_t *first_symbol, uint32_t addr) const _TCHAR* DLL_PREFIX get_value_or_symbol(symbol_t *first_symbol, const _TCHAR *format, uint32_t addr) { - static _TCHAR name[1024]; + static _TCHAR name[8][1024]; + static unsigned int table_index = 0; + unsigned int output_index = (table_index++) & 7; for(symbol_t* symbol = first_symbol; symbol; symbol = symbol->next_symbol) { if(symbol->addr == addr) { - my_tcscpy_s(name, 1024, symbol->name); - return name; +// my_tcscpy_s(name, 1024, symbol->name); + my_tcscpy_s(name[output_index], 1024, symbol->name); + return name[output_index]; +// return name; } } - my_stprintf_s(name, 1024, format, addr); - return name; +// my_stprintf_s(name, 1024, format, addr); +// return name; + my_stprintf_s(name[output_index], 1024, format, addr); + return name[output_index]; } const _TCHAR* DLL_PREFIX get_value_and_symbol(symbol_t *first_symbol, const _TCHAR *format, uint32_t addr) { - static _TCHAR name[1024]; + static _TCHAR name[8][1024]; + static unsigned int table_index = 0; + unsigned int output_index = (table_index++) & 7; - my_stprintf_s(name, 1024, format, addr); + my_stprintf_s(name[output_index], 1024, format, addr); for(symbol_t* symbol = first_symbol; symbol; symbol = symbol->next_symbol) { if(symbol->addr == addr) { _TCHAR temp[1024]; // my_stprintf_s(temp, 1024, _T(" (%s)"), symbol->name); my_stprintf_s(temp, 1024, _T(";%s"), symbol->name); - my_tcscat_s(name, 1024, temp); - return name; + my_tcscat_s(name[output_index], 1024, temp); + return name[output_index]; } } - return name; + return name[output_index]; } diff --git a/source/src/common.h b/source/src/common.h index d98e1eee0..cddb21845 100644 --- a/source/src/common.h +++ b/source/src/common.h @@ -533,6 +533,9 @@ const _TCHAR *DLL_PREFIX wchar_to_tchar(const wchar_t *ws); const wchar_t *DLL_PREFIX tchar_to_wchar(const _TCHAR *ts); // misc +int32_t DLL_PREFIX muldiv_s32(int32_t nNumber, int32_t nNumerator, int32_t nDenominator); +uint32_t DLL_PREFIX muldiv_u32(uint32_t nNumber, uint32_t nNumerator, uint32_t nDenominator); + uint32_t DLL_PREFIX get_crc32(uint8_t data[], int size); uint16_t DLL_PREFIX jis_to_sjis(uint16_t jis); diff --git a/source/src/vm/device.h b/source/src/vm/device.h index 4a5e7a8c9..4b197b1a5 100644 --- a/source/src/vm/device.h +++ b/source/src/vm/device.h @@ -19,7 +19,7 @@ #define USE_DEVICE_NAME #endif -#if defined(USE_DEVICES_SHARED_LIB) +#if defined(USE_SHARED_DLL) #include "libcpu_newdev/device.h" #else @@ -781,6 +781,6 @@ public: DEVICE* next_device; int this_device_id; }; -#endif //USE_DEVICES_SHARED_LIB +#endif // USE_SHARED_DLL #endif diff --git a/source/src/vm/i386.h b/source/src/vm/i386.h index a726465eb..b3c137220 100644 --- a/source/src/vm/i386.h +++ b/source/src/vm/i386.h @@ -10,7 +10,7 @@ #ifndef _I386_H_ #define _I386_H_ -#if defined(USE_DEVICES_SHARED_LIB) +#if defined(USE_SHARED_DLL) //#if 0 #include "libcpu_newdev/i386.h" #else @@ -168,5 +168,5 @@ public: void set_shutdown_flag(int shutdown); int get_shutdown_flag(); }; -#endif +#endif // USE_SHARED_DLL #endif diff --git a/source/src/vm/i86.h b/source/src/vm/i86.h index 137e81697..06a9e35f5 100644 --- a/source/src/vm/i86.h +++ b/source/src/vm/i86.h @@ -10,7 +10,7 @@ #ifndef _I86_H_ #define _I86_H_ -#if defined(USE_DEVICES_SHARED_LIB) +#if defined(USE_SHARED_DLL) #include "libcpu_newdev/i86.h" #else @@ -432,5 +432,5 @@ public: } #endif }; -#endif +#endif // USE_SHARED_DLL #endif diff --git a/source/src/vm/m6502.cpp b/source/src/vm/m6502.cpp index ff6d3a253..2f96e5e24 100644 --- a/source/src/vm/m6502.cpp +++ b/source/src/vm/m6502.cpp @@ -487,7 +487,7 @@ } \ if(!((A - tmp - c) & 0xff)) { \ P |= F_Z; \ - } + } \ if((A - tmp - c) & 0x80) { \ P |= F_N; \ } \ diff --git a/source/src/vm/mc6809.h b/source/src/vm/mc6809.h index 9db776f1e..306bacbde 100644 --- a/source/src/vm/mc6809.h +++ b/source/src/vm/mc6809.h @@ -11,7 +11,7 @@ #ifndef _MC6809_H_ #define _MC6809_H_ -#if defined(USE_DEVICES_SHARED_LIB) +#if defined(USE_SHARED_DLL) //#if 0 #include "libcpu_newdev/libcpu_mc6809/mc6809.h" #else @@ -562,6 +562,6 @@ public: } }; -#endif +#endif // USE_SHARED_DLL #endif diff --git a/source/src/vm/mcs48.h b/source/src/vm/mcs48.h index 6eb5ec038..9420ee476 100644 --- a/source/src/vm/mcs48.h +++ b/source/src/vm/mcs48.h @@ -11,7 +11,7 @@ #ifndef _MCS84_H_ #define _MCS48_H_ -#if defined(USE_DEVICES_SHARED_LIB) +#if defined(USE_SHARED_DLL) #include "libcpu_newdev/mcs48.h" #else #include "vm.h" @@ -130,6 +130,6 @@ public: void load_rom_image(const _TCHAR *file_path); uint8_t *get_rom_ptr(); }; -#endif +#endif // USE_SHARED_DLL #endif diff --git a/source/src/vm/mz700/mz700.h b/source/src/vm/mz700/mz700.h index 23f27949a..78f963f29 100644 --- a/source/src/vm/mz700/mz700.h +++ b/source/src/vm/mz700/mz700.h @@ -25,23 +25,20 @@ // device informations for virtual machine #if defined(_MZ800) -#define FRAMES_PER_SEC 50 +#define FRAMES_PER_SEC (3546895.0 / 228.0 / 312.0) #define LINES_PER_FRAME 312 -//#define CPU_CLOCKS 3546900 -// 228*312*50 -#define CPU_CLOCKS 3556800 +#define CPU_CLOCKS 3546895 #else -#define FRAMES_PER_SEC 60 +#define FRAMES_PER_SEC (3579545.0 / 228.0 / 262.0) #define LINES_PER_FRAME 262 -//#define CPU_CLOCKS 3579545 -// 228*262*60 -#define CPU_CLOCKS 3584160 +#define CPU_CLOCKS 3579545 #endif #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 400 #define WINDOW_HEIGHT_ASPECT 480 #define IO_ADDR_MAX 0x100 #define Z80_MEMORY_WAIT +#define Z80_IO_WAIT #if defined(_MZ800) || defined(_MZ1500) #define MAX_DRIVE 4 #define HAS_MB8876 -- 2.11.0