diff --git a/core/debug/cpuhook.c b/core/debug/cpuhook.c new file mode 100644 index 0000000..b8c5b5b --- /dev/null +++ b/core/debug/cpuhook.c @@ -0,0 +1,47 @@ +/*************************************************************************************** + * Genesis Plus GX + * CPU hooking support + * + * Copyright feos (2019) + * + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: + * + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. + * + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. However, as a special exception, the + * source code distributed need not include anything that is normally distributed + * (in either source or binary form) with the major components (compiler, kernel, + * and so on) of the operating system on which the executable runs, unless that + * component itself accompanies the executable. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ + +#include +#include "cpuhook.h" + +void(*cpu_hook)(hook_type_t type, int width, unsigned int address, unsigned int value) = NULL; + +void set_cpu_hook(void(*hook)(hook_type_t type, int width, unsigned int address, unsigned int value)) +{ + cpu_hook = hook; +} \ No newline at end of file diff --git a/core/cpuhook.h b/core/debug/cpuhook.h similarity index 91% rename from core/cpuhook.h rename to core/debug/cpuhook.h index b656077..67af2c2 100644 --- a/core/cpuhook.h +++ b/core/debug/cpuhook.h @@ -3,7 +3,7 @@ * CPU hooking support * * Copyright DrMefistO (2018-2019) - + * * Copyright feos (2019) * * Redistribution and use of this code or any derivative works are permitted @@ -41,6 +41,7 @@ #ifndef _CPUHOOK_H_ #define _CPUHOOK_H_ + typedef enum { HOOK_ANY = (0 << 0), @@ -74,7 +75,15 @@ typedef enum { HOOK_M68K_REG = (1 << 13), } hook_type_t; + +/* CPU hook is called on read, write, and execute. + */ void (*cpu_hook)(hook_type_t type, int width, unsigned int address, unsigned int value); + +/* Use set_cpu_hook() to assign a callback that can process the data provided + * by cpu_hook(). + */ void set_cpu_hook(void(*hook)(hook_type_t type, int width, unsigned int address, unsigned int value)); + #endif /* _CPUHOOK_H_ */ \ No newline at end of file diff --git a/core/m68k/m68k.h b/core/m68k/m68k.h index 244e000..86b7908 100644 --- a/core/m68k/m68k.h +++ b/core/m68k/m68k.h @@ -43,7 +43,9 @@ #include #include "macros.h" +#ifdef HOOK_CPU #include "cpuhook.h" +#endif /* ======================================================================== */ /* ==================== ARCHITECTURE-DEPENDANT DEFINES ==================== */ diff --git a/core/m68k/m68kcpu.c b/core/m68k/m68kcpu.c index e4b48f2..1251845 100644 --- a/core/m68k/m68kcpu.c +++ b/core/m68k/m68kcpu.c @@ -72,19 +72,6 @@ static void default_set_fc_callback(unsigned int new_fc) #endif -/* CPU hook is called on read, write, and execute, if HOOK_CPU is defined in - * a makefile or an MSVC project. Use set_cpu_hook() to assign a callback - * that can process the data provided by cpu_hook(). - */ - -void (*cpu_hook)(hook_type_t type, int width, unsigned int address, unsigned int value) = NULL; - -void set_cpu_hook(void (*hook)(hook_type_t type, int width, unsigned int address, unsigned int value)) -{ - cpu_hook = hook; -} - - /* ======================================================================== */ /* ================================= API ================================== */ /* ======================================================================== */ diff --git a/libretro/libretro_msvc/genesis_plus_gx_libretro.vcxproj b/libretro/libretro_msvc/genesis_plus_gx_libretro.vcxproj index 00b7e10..bfe0f73 100644 --- a/libretro/libretro_msvc/genesis_plus_gx_libretro.vcxproj +++ b/libretro/libretro_msvc/genesis_plus_gx_libretro.vcxproj @@ -89,7 +89,7 @@ WIN32;_DEBUG;GENESISPLUSGXLIBRETRO_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);USE_LIBTREMOR;USE_LIBCHDR;PACKAGE_VERSION="1.3.2";FLAC_API_EXPORTS;FLAC__HAS_OGG=0;HAVE_LROUND;HAVE_STDINT_H;_7ZIP_ST;HAVE_FSEEKO;DEBUG;USE_16BPP_RENDERING;FRONTEND_SUPPORTS_RGB565;LSB_FIRST;BYTE_ORDER=LITTLE_ENDIAN;HAVE_ZLIB;__LIBRETRO__;M68K_OVERCLOCK_SHIFT=20;Z80_OVERCLOCK_SHIFT=20;HAVE_YM3438_CORE;INLINE=static __inline; true MultiThreadedDebug - ../../core/cd_hw/libchdr/src;../../core/cd_hw/libchdr/deps/libFLAC/include;../../core/cd_hw/libchdr/deps/lzma;../../core/cd_hw/libchdr/deps/zlib;../../core;../../core/z80;../../core/m68k;../../core/ntsc;../../core/sound;../../core/input_hw;../../core/cd_hw;../../core/cart_hw;../../core/cart_hw/svp;../../libretro;../../libretro/libretro-common/include;%(AdditionalIncludeDirectories) + ../../core/cd_hw/libchdr/src;../../core/cd_hw/libchdr/deps/libFLAC/include;../../core/cd_hw/libchdr/deps/lzma;../../core/cd_hw/libchdr/deps/zlib;../../core;../../core/z80;../../core/m68k;../../core/ntsc;../../core/sound;../../core/input_hw;../../core/cd_hw;../../core/cart_hw;../../core/cart_hw/svp;../../core/debug;../../libretro;../../libretro/libretro-common/include;%(AdditionalIncludeDirectories) true @@ -103,7 +103,7 @@ _DEBUG;GENESISPLUSGXLIBRETRO_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);USE_LIBTREMOR;USE_LIBCHDR;PACKAGE_VERSION="1.3.2";FLAC_API_EXPORTS;FLAC__HAS_OGG=0;HAVE_LROUND;HAVE_STDINT_H;_7ZIP_ST;HAVE_FSEEKO;DEBUG;USE_16BPP_RENDERING;FRONTEND_SUPPORTS_RGB565;LSB_FIRST;BYTE_ORDER=LITTLE_ENDIAN;HAVE_ZLIB;__LIBRETRO__;M68K_OVERCLOCK_SHIFT=20;Z80_OVERCLOCK_SHIFT=20;HAVE_YM3438_CORE;INLINE=static __inline; true MultiThreadedDebug - ../../core/cd_hw/libchdr/src;../../core/cd_hw/libchdr/deps/libFLAC/include;../../core/cd_hw/libchdr/deps/lzma;../../core/cd_hw/libchdr/deps/zlib;../../core;../../core/z80;../../core/m68k;../../core/ntsc;../../core/sound;../../core/input_hw;../../core/cd_hw;../../core/cart_hw;../../core/cart_hw/svp;../../libretro;../../libretro/libretro-common/include;%(AdditionalIncludeDirectories) + ../../core/cd_hw/libchdr/src;../../core/cd_hw/libchdr/deps/libFLAC/include;../../core/cd_hw/libchdr/deps/lzma;../../core/cd_hw/libchdr/deps/zlib;../../core;../../core/z80;../../core/m68k;../../core/ntsc;../../core/sound;../../core/input_hw;../../core/cd_hw;../../core/cart_hw;../../core/cart_hw/svp;../../core/debug;../../libretro;../../libretro/libretro-common/include;%(AdditionalIncludeDirectories) true @@ -119,7 +119,7 @@ WIN32;NDEBUG;GENESISPLUSGXLIBRETRO_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);USE_LIBTREMOR;USE_LIBCHDR;PACKAGE_VERSION="1.3.2";FLAC_API_EXPORTS;FLAC__HAS_OGG=0;HAVE_LROUND;HAVE_STDINT_H;_7ZIP_ST;HAVE_FSEEKO;NDEBUG;USE_16BPP_RENDERING;FRONTEND_SUPPORTS_RGB565;LSB_FIRST;BYTE_ORDER=LITTLE_ENDIAN;HAVE_ZLIB;__LIBRETRO__;M68K_OVERCLOCK_SHIFT=20;Z80_OVERCLOCK_SHIFT=20;HAVE_YM3438_CORE;INLINE=static __inline; true MultiThreaded - ../../core/cd_hw/libchdr/src;../../core/cd_hw/libchdr/deps/libFLAC/include;../../core/cd_hw/libchdr/deps/lzma;../../core/cd_hw/libchdr/deps/zlib;../../core;../../core/z80;../../core/m68k;../../core/ntsc;../../core/sound;../../core/input_hw;../../core/cd_hw;../../core/cart_hw;../../core/cart_hw/svp;../../libretro;../../libretro/libretro-common/include;%(AdditionalIncludeDirectories) + ../../core/cd_hw/libchdr/src;../../core/cd_hw/libchdr/deps/libFLAC/include;../../core/cd_hw/libchdr/deps/lzma;../../core/cd_hw/libchdr/deps/zlib;../../core;../../core/z80;../../core/m68k;../../core/ntsc;../../core/sound;../../core/input_hw;../../core/cd_hw;../../core/cart_hw;../../core/cart_hw/svp;../../core/debug;../../libretro;../../libretro/libretro-common/include;%(AdditionalIncludeDirectories) true @@ -137,7 +137,7 @@ NDEBUG;GENESISPLUSGXLIBRETRO_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);USE_LIBTREMOR;USE_LIBCHDR;PACKAGE_VERSION="1.3.2";FLAC_API_EXPORTS;FLAC__HAS_OGG=0;HAVE_LROUND;HAVE_STDINT_H;_7ZIP_ST;HAVE_FSEEKO;NDEBUG;USE_16BPP_RENDERING;FRONTEND_SUPPORTS_RGB565;LSB_FIRST;BYTE_ORDER=LITTLE_ENDIAN;HAVE_ZLIB;__LIBRETRO__;M68K_OVERCLOCK_SHIFT=20;Z80_OVERCLOCK_SHIFT=20;HAVE_YM3438_CORE;INLINE=static __inline; true MultiThreaded - ../../core/cd_hw/libchdr/src;../../core/cd_hw/libchdr/deps/libFLAC/include;../../core/cd_hw/libchdr/deps/lzma;../../core/cd_hw/libchdr/deps/zlib;../../core;../../core/z80;../../core/m68k;../../core/ntsc;../../core/sound;../../core/input_hw;../../core/cd_hw;../../core/cart_hw;../../core/cart_hw/svp;../../libretro;../../libretro/libretro-common/include;%(AdditionalIncludeDirectories) + ../../core/cd_hw/libchdr/src;../../core/cd_hw/libchdr/deps/libFLAC/include;../../core/cd_hw/libchdr/deps/lzma;../../core/cd_hw/libchdr/deps/zlib;../../core;../../core/z80;../../core/m68k;../../core/ntsc;../../core/sound;../../core/input_hw;../../core/cd_hw;../../core/cart_hw;../../core/cart_hw/svp;../../core/debug;../../libretro;../../libretro/libretro-common/include;%(AdditionalIncludeDirectories) true @@ -191,6 +191,7 @@ + @@ -308,7 +309,7 @@ - + diff --git a/libretro/libretro_msvc/genesis_plus_gx_libretro.vcxproj.filters b/libretro/libretro_msvc/genesis_plus_gx_libretro.vcxproj.filters index 765739f..611da69 100644 --- a/libretro/libretro_msvc/genesis_plus_gx_libretro.vcxproj.filters +++ b/libretro/libretro_msvc/genesis_plus_gx_libretro.vcxproj.filters @@ -82,6 +82,9 @@ {08366101-bc7b-4009-8f09-65804bdab6ea} + + {674da1b3-d904-4490-bb73-a63eb5ea9ced} + @@ -384,6 +387,9 @@ libretro + + core\debug + @@ -749,8 +755,8 @@ core - - core + + core\debug \ No newline at end of file