diff --git a/CMakeLists.txt b/CMakeLists.txt index 004b8539..335e19b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,10 +244,11 @@ set(SDL2_TARGETS SDL2::SDL2 ${SDL2_LIBRARY_TEMP}) set( VBAMCORE_LIBS vbamcore + vbam-core-apu vbam-core-base + vbam-core-emulator vbam-fex ${SDL2_TARGETS} - ${SFML_LIBRARIES} ${OPENGL_LIBRARIES} ${ZLIB_LIBRARY} ) @@ -333,10 +334,8 @@ else() endif() # The debugger is enabled by default -if(NOT ENABLE_DEBUGGER) - add_compile_definitions(NO_DEBUGGER) -else() - add_compile_definitions(BKPT_SUPPORT) +if(ENABLE_DEBUGGER) + add_compile_definitions(VBAM_ENABLE_DEBUGGER) endif() # The ASM core is disabled by default because we don't know on which platform we are @@ -386,8 +385,7 @@ endif() if(NOT TRANSLATIONS_ONLY) add_subdirectory(third_party/include/stb) - add_subdirectory(src/core/fex) - add_subdirectory(src/core/base) + add_subdirectory(src/core) endif() set( @@ -416,120 +414,6 @@ if(ENABLE_FFMPEG) set(HDR_MAIN ${HDR_MAIN} src/common/ffmpeg.h) endif() -set( - SRC_GBA - src/gba/agbprint.cpp - src/gba/bios.cpp - src/gba/Cheats.cpp - src/gba/CheatSearch.cpp - # Built with flex -o debugger-expr-lex.cpp -P dexp_ debugger-expr.l - src/gba/debugger-expr-lex.cpp - # Built with bison -L c -o debugger-expr-yacc.cpp -H -p dexp_ debugger-expr.y - # The yyerrorlab label handler was manually commented out to silence a - # compiler warning. - src/gba/debugger-expr-yacc.cpp - src/gba/EEprom.cpp - src/gba/ereader.cpp - src/gba/Flash.cpp - src/gba/GBA.cpp - src/gba/GBAGfx.cpp - src/gba/GBALink.cpp - src/gba/GBASockClient.cpp - src/gba/GBA-thumb.cpp - src/gba/GBA-arm.cpp - src/gba/gbafilter.cpp - src/gba/Globals.cpp - src/gba/Mode0.cpp - src/gba/Mode1.cpp - src/gba/Mode2.cpp - src/gba/Mode3.cpp - src/gba/Mode4.cpp - src/gba/Mode5.cpp - src/gba/RTC.cpp - src/gba/Sound.cpp - src/gba/Sram.cpp -) - -if(ENABLE_DEBUGGER) - list(APPEND SRC_GBA - src/gba/BreakpointStructures.cpp - ) -endif() - -set( - HDR_GBA - src/gba/agbprint.h - src/gba/bios.h - src/gba/BreakpointStructures.h - src/gba/Cheats.h - src/gba/CheatSearch.h - src/gba/debugger-expr-yacc.hpp - src/gba/EEprom.h - src/gba/ereader.h - src/gba/Flash.h - src/gba/GBA.h - src/gba/GBAcpu.h - src/gba/gbafilter.h - src/gba/GBAGfx.h - src/gba/GBAinline.h - src/gba/GBALink.h - src/gba/GBASockClient.h - src/gba/Globals.h - src/gba/RTC.h - src/gba/Sound.h - src/gba/Sram.h -) - -set( - SRC_GB - src/gb/GB.cpp - src/gb/gbCartData.cpp - src/gb/gbCheats.cpp - src/gb/gbDis.cpp - src/gb/gbGfx.cpp - src/gb/gbGlobals.cpp - src/gb/gbMemory.cpp - src/gb/gbPrinter.cpp - src/gb/gbSGB.cpp - src/gb/gbSound.cpp -) - -set( - HDR_GB - src/gb/gb.h - src/gb/gbCartData.h - src/gb/gbCheats.h - src/gb/gbCodes.h - src/gb/gbCodesCB.h - src/gb/gbGlobals.h - src/gb/gbMemory.h - src/gb/gbPrinter.h - src/gb/gbSGB.h - src/gb/gbSound.h -) - -set( - SRC_APU - src/apu/Blip_Buffer.cpp - src/apu/Effects_Buffer.cpp - src/apu/Gb_Apu.cpp - src/apu/Gb_Apu_State.cpp - src/apu/Gb_Oscs.cpp - src/apu/Multi_Buffer.cpp -) - -set( - HDR_APU - src/apu/blargg_common.h #Unused(?) but in the VS projects - src/apu/blargg_config.h #Unused(?) but in the VS projects - src/apu/blargg_source.h - src/apu/Blip_Buffer.h - src/apu/Effects_Buffer.h - src/apu/Gb_Apu.h - src/apu/Gb_Oscs.h - src/apu/Multi_Buffer.h -) - set( SRC_SDL src/sdl/ConfigManager.cpp @@ -614,31 +498,6 @@ else() endif() -set( - SRC_DEBUGGER - src/gba/armdis.cpp - src/gba/elf.cpp -) - -set( - HDR_DEBUGGER - src/gba/armdis.h - src/gba/elf.h -) - -if(ENABLE_DEBUGGER) - set( - SRC_DEBUGGER - ${SRC_DEBUGGER} - src/gba/remote.cpp - ) - set( - HDR_DEBUGGER - ${HDR_DEBUGGER} - src/gba/remote.h - ) -endif() - include_directories( ${ZLIB_INCLUDE_DIR} third_party/include @@ -657,16 +516,8 @@ if(NOT TRANSLATIONS_ONLY) ${PROJECT_SRCS} ${SRC_MAIN} ${HDR_MAIN} - ${SRC_GBA} - ${HDR_GBA} - ${SRC_GB} - ${HDR_GB} - ${SRC_APU} - ${HDR_APU} ${SRC_FILTERS} ${HDR_FILTERS} - ${SRC_DEBUGGER} - ${HDR_DEBUGGER} ) target_include_directories(vbamcore PUBLIC ${SDL2_INCLUDE_DIRS}) endif() diff --git a/cmake-variants.yaml b/cmake-variants.yaml index aac32666..656cca49 100644 --- a/cmake-variants.yaml +++ b/cmake-variants.yaml @@ -21,3 +21,32 @@ linkage: short: Shared long: Create shared libraries/DLLs linkage: shared + +useLink: + default: withlink + choices: + withlink: + short: WithLink + long: Enable the Link feature + settings: + ENABLE_LINK: ON + nolink: + short: NoLink + long: Disable the Link feature + settings: + ENABLE_LINK: OFF + +useDebugger: + default: withdebugger + choices: + withdebugger: + short: WithDebugger + long: Enable the Debugger feature + settings: + ENABLE_DEBUGGER: ON + nodebugger: + short: NoDebugger + long: Disable the Debugger feature + settings: + ENABLE_DEBUGGER: OFF + ENABLE_SDL: OFF diff --git a/cmake/Toolchain-msvc.cmake b/cmake/Toolchain-msvc.cmake index d5cb12e9..566f497e 100644 --- a/cmake/Toolchain-msvc.cmake +++ b/cmake/Toolchain-msvc.cmake @@ -20,6 +20,7 @@ add_compile_definitions( __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS _CRT_SECURE_NO_WARNINGS + NOMINMAX ) add_compile_options( /W4 diff --git a/doc/DevInfo.txt b/doc/DevInfo.txt index d96b9ab2..166132fc 100644 --- a/doc/DevInfo.txt +++ b/doc/DevInfo.txt @@ -8,7 +8,7 @@ Known preprocessor switches: - SDL: Defined for the SDL version - GBA_LOGGING: Enables logging for the GBA core - FINAL_VERSION: Defined for release versions, disables additional GBA logging and completely disables GB logging. Increases the amount of CPU cycles being emulated in one go. -- BKPT_SUPPORT +- VBAM_ENABLE_DEBUGGER: Enable remote debugging support - MMX: Enable MMX instruction set - NO_ASM: Use C++ version of hq3x/4x filters - RGB555: Use 16bit colors with 5bit green instead of 6bit green in hq3x/4x filters (C++ version) diff --git a/src/Util_common.cpp b/src/Util_common.cpp index 44241c44..c0ea7e90 100644 --- a/src/Util_common.cpp +++ b/src/Util_common.cpp @@ -4,9 +4,10 @@ #include "core/base/port.h" #include "core/base/system.h" -#include "gba/Globals.h" -#include "gba/RTC.h" -#include "gba/gbafilter.h" +#include "core/gba/gbaFilter.h" +#include "core/gba/gbaFlash.h" +#include "core/gba/gbaGlobals.h" +#include "core/gba/gbaRtc.h" #if defined(_MSC_VER) #define strcasecmp _stricmp diff --git a/src/common/SoundSDL.cpp b/src/common/SoundSDL.cpp index bcfe4bae..e5ef6fc2 100644 --- a/src/common/SoundSDL.cpp +++ b/src/common/SoundSDL.cpp @@ -19,8 +19,8 @@ #include #include #include "SoundSDL.h" -#include "../gba/Globals.h" -#include "../gba/Sound.h" +#include "core/gba/gbaGlobals.h" +#include "core/gba/gbaSound.h" extern int emulating; diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt new file mode 100644 index 00000000..640e4459 --- /dev/null +++ b/src/core/CMakeLists.txt @@ -0,0 +1,131 @@ +add_subdirectory(apu) +add_subdirectory(base) +add_subdirectory(fex) + +# The vbam-core-emulator target contains both the Game Boy and Game Boy Advance +# emulators. These should be broken down into 2 separate targets. The issue lies +# with the Link and Sound emulation, which are tangled together between the two +# systems. +add_library(vbam-core-emulator OBJECT) + +target_sources(vbam-core-emulator + PRIVATE + # Game Boy + gb/internal/gbCodes.h + gb/internal/gbCodesCB.h + gb/gb.cpp + gb/gbCartData.cpp + gb/gbCheats.cpp + gb/gbDis.cpp + gb/gbGfx.cpp + gb/gbGlobals.cpp + gb/gbMemory.cpp + gb/gbPrinter.cpp + gb/gbSGB.cpp + gb/gbSound.cpp + + # Game Boy Advance + # Built with flex -o debugger-expr-lex.cpp -P dexp_ debugger-expr.l + gba/debugger-expr-lex.cpp + # Built with bison -L c -o debugger-expr-yacc.cpp -H -p dexp_ debugger-expr.y + # The yyerrorlab label handler was manually commented out to silence a + # compiler warning. + gba/debugger-expr-yacc.cpp + gba/gba.cpp + gba/gbaCpuArm.cpp + gba/gbaCpuArmDis.cpp + gba/gbaCpuThumb.cpp + gba/gbaCheats.cpp + gba/gbaCheatSearch.cpp + gba/gbaEeprom.cpp + gba/gbaElf.cpp + gba/gbaFilter.cpp + gba/gbaFlash.cpp + gba/gbaGfx.cpp + gba/gbaGlobals.cpp + gba/gbaMode0.cpp + gba/gbaMode1.cpp + gba/gbaMode2.cpp + gba/gbaMode3.cpp + gba/gbaMode4.cpp + gba/gbaMode5.cpp + gba/gbaPrint.cpp + gba/gbaRtc.cpp + gba/gbaSound.cpp + gba/internal/gbaBios.cpp + gba/internal/gbaBios.h + gba/internal/gbaEreader.cpp + gba/internal/gbaEreader.h + gba/internal/gbaSram.cpp + gba/internal/gbaSram.h + + PUBLIC + # Game Boy + gb/gb.h + gb/gbCartData.h + gb/gbCheats.h + gb/gbDis.h + gb/gbGfx.h + gb/gbGlobals.h + gb/gbMemory.h + gb/gbPrinter.h + gb/gbSGB.h + gb/gbSound.h + + # Game Boy Advance + gba/gba.h + gba/gbaCheats.h + gba/gbaCheatSearch.h + gba/gbaCpu.h + gba/gbaCpuArmDis.h + gba/gbaEeprom.h + gba/gbaElf.h + gba/gbaFilter.h + gba/gbaFlash.h + gba/gbaGfx.h + gba/gbaGlobals.h + gba/gbaInline.h + gba/gbaPrint.h + gba/gbaRtc.h + gba/gbaSound.h +) + +target_include_directories(vbam-core-base + PUBLIC ${ZLIB_INCLUDE_DIR} +) + +target_link_libraries(vbam-core-emulator + PRIVATE vbam-core-apu + PUBLIC vbam-core-base ${ZLIB_LIBRARY} +) + +if(ENABLE_DEBUGGER) + target_sources(vbam-core-emulator + PRIVATE + gba/gbaRemote.cpp + gba/internal/gbaBreakpoint.cpp + gba/internal/gbaBreakpoint.h + + PUBLIC + gba/gbaRemote.h + ) +endif() + +if(ENABLE_LINK) + target_sources(vbam-core-emulator + PRIVATE + gba/gbaLink.cpp + gba/internal/gbaSockClient.cpp + gba/internal/gbaSockClient.h + + PUBLIC + gba/gbaLink.h + ) + + target_include_directories(vbam-core-emulator + PRIVATE ${SFML_INCLUDE_DIR}) + + target_link_libraries(vbam-core-emulator + PRIVATE ${SFML_LIBRARIES}) +endif() + diff --git a/src/apu/Blip_Buffer.cpp b/src/core/apu/Blip_Buffer.cpp similarity index 99% rename from src/apu/Blip_Buffer.cpp rename to src/core/apu/Blip_Buffer.cpp index 098ab578..fb7e7984 100644 --- a/src/apu/Blip_Buffer.cpp +++ b/src/core/apu/Blip_Buffer.cpp @@ -1,6 +1,6 @@ // Blip_Buffer 0.4.1. http://www.slack.net/~ant/ -#include "Blip_Buffer.h" +#include "core/apu/Blip_Buffer.h" #include #include diff --git a/src/apu/Blip_Buffer.h b/src/core/apu/Blip_Buffer.h similarity index 100% rename from src/apu/Blip_Buffer.h rename to src/core/apu/Blip_Buffer.h diff --git a/src/core/apu/CMakeLists.txt b/src/core/apu/CMakeLists.txt new file mode 100644 index 00000000..222dae90 --- /dev/null +++ b/src/core/apu/CMakeLists.txt @@ -0,0 +1,24 @@ +# This defines the `vbam-core-apu` target. +# `vbam-core-apu` contains the core APU emulation code. + +add_library(vbam-core-apu OBJECT) + +target_sources(vbam-core-apu + PRIVATE + Blip_Buffer.cpp + Effects_Buffer.cpp + Gb_Apu.cpp + Gb_Apu_State.cpp + Gb_Oscs.cpp + Multi_Buffer.cpp + + PUBLIC + blargg_common.h + blargg_config.h + blargg_source.h + Blip_Buffer.h + Effects_Buffer.h + Gb_Apu.h + Gb_Oscs.h + Multi_Buffer.h +) diff --git a/src/apu/Effects_Buffer.cpp b/src/core/apu/Effects_Buffer.cpp similarity index 99% rename from src/apu/Effects_Buffer.cpp rename to src/core/apu/Effects_Buffer.cpp index 1bad7fdc..43d5acf6 100644 --- a/src/apu/Effects_Buffer.cpp +++ b/src/core/apu/Effects_Buffer.cpp @@ -1,6 +1,6 @@ // Game_Music_Emu $vers. http://www.slack.net/~ant/ -#include "Effects_Buffer.h" +#include "core/apu/Effects_Buffer.h" #include @@ -15,7 +15,7 @@ details. You should have received a copy of the GNU Lesser General Public License along with this module; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "blargg_source.h" +#include "core/apu/blargg_source.h" int const fixed_shift = 12; #define TO_FIXED( f ) fixed_t ((f) * ((fixed_t) 1 << fixed_shift)) diff --git a/src/apu/Effects_Buffer.h b/src/core/apu/Effects_Buffer.h similarity index 99% rename from src/apu/Effects_Buffer.h rename to src/core/apu/Effects_Buffer.h index 3627e70b..72599e24 100644 --- a/src/apu/Effects_Buffer.h +++ b/src/core/apu/Effects_Buffer.h @@ -6,7 +6,7 @@ #include -#include "Multi_Buffer.h" +#include "core/apu/Multi_Buffer.h" // See Simple_Effects_Buffer (below) for a simpler interface diff --git a/src/apu/Gb_Apu.cpp b/src/core/apu/Gb_Apu.cpp similarity index 99% rename from src/apu/Gb_Apu.cpp rename to src/core/apu/Gb_Apu.cpp index 3e4fff27..7fbcee53 100644 --- a/src/apu/Gb_Apu.cpp +++ b/src/core/apu/Gb_Apu.cpp @@ -1,6 +1,6 @@ // Gb_Snd_Emu 0.2.0. http://www.slack.net/~ant/ -#include "Gb_Apu.h" +#include "core/apu/Gb_Apu.h" /* Copyright (C) 2003-2007 Shay Green. This module is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser @@ -13,7 +13,7 @@ details. You should have received a copy of the GNU Lesser General Public License along with this module; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "blargg_source.h" +#include "core/apu/blargg_source.h" unsigned const vol_reg = 0xFF24; unsigned const stereo_reg = 0xFF25; diff --git a/src/apu/Gb_Apu.h b/src/core/apu/Gb_Apu.h similarity index 99% rename from src/apu/Gb_Apu.h rename to src/core/apu/Gb_Apu.h index 1db4e5bb..8fe53e6c 100644 --- a/src/apu/Gb_Apu.h +++ b/src/core/apu/Gb_Apu.h @@ -6,8 +6,8 @@ #include -#include "blargg_common.h" -#include "Gb_Oscs.h" +#include "core/apu/blargg_common.h" +#include "core/apu/Gb_Oscs.h" struct gb_apu_state_t; diff --git a/src/apu/Gb_Apu_State.cpp b/src/core/apu/Gb_Apu_State.cpp similarity index 98% rename from src/apu/Gb_Apu_State.cpp rename to src/core/apu/Gb_Apu_State.cpp index 6a523460..39a486c4 100644 --- a/src/apu/Gb_Apu_State.cpp +++ b/src/core/apu/Gb_Apu_State.cpp @@ -1,6 +1,6 @@ // Gb_Snd_Emu $vers. http://www.slack.net/~ant/ -#include "Gb_Apu.h" +#include "core/apu/Gb_Apu.h" #include @@ -15,7 +15,7 @@ details. You should have received a copy of the GNU Lesser General Public License along with this module; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "blargg_source.h" +#include "core/apu/blargg_source.h" #if GB_APU_CUSTOM_STATE #define REFLECT( x, y ) (save ? (io->y) = (x) : (x) = (io->y) ) diff --git a/src/apu/Gb_Oscs.cpp b/src/core/apu/Gb_Oscs.cpp similarity index 99% rename from src/apu/Gb_Oscs.cpp rename to src/core/apu/Gb_Oscs.cpp index 72ec8049..c17b95a0 100644 --- a/src/apu/Gb_Oscs.cpp +++ b/src/core/apu/Gb_Oscs.cpp @@ -1,6 +1,6 @@ // Gb_Snd_Emu 0.2.0. http://www.slack.net/~ant/ -#include "Gb_Apu.h" +#include "core/apu/Gb_Apu.h" /* Copyright (C) 2003-2007 Shay Green. This module is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser @@ -13,7 +13,7 @@ details. You should have received a copy of the GNU Lesser General Public License along with this module; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "blargg_source.h" +#include "core/apu/blargg_source.h" bool const cgb_02 = false; // enables bug in early CGB units that causes problems in some games bool const cgb_05 = false; // enables CGB-05 zombie behavior diff --git a/src/apu/Gb_Oscs.h b/src/core/apu/Gb_Oscs.h similarity index 99% rename from src/apu/Gb_Oscs.h rename to src/core/apu/Gb_Oscs.h index b81e5eaa..b7f355f9 100644 --- a/src/apu/Gb_Oscs.h +++ b/src/core/apu/Gb_Oscs.h @@ -6,7 +6,7 @@ #include -#include "Blip_Buffer.h" +#include "core/apu/Blip_Buffer.h" #ifndef GB_APU_OVERCLOCK #define GB_APU_OVERCLOCK 1 diff --git a/src/apu/Multi_Buffer.cpp b/src/core/apu/Multi_Buffer.cpp similarity index 98% rename from src/apu/Multi_Buffer.cpp rename to src/core/apu/Multi_Buffer.cpp index 0923766a..7aff8c03 100644 --- a/src/apu/Multi_Buffer.cpp +++ b/src/core/apu/Multi_Buffer.cpp @@ -1,6 +1,6 @@ // Blip_Buffer 0.4.1. http://www.slack.net/~ant/ -#include "Multi_Buffer.h" +#include "core/apu/Multi_Buffer.h" /* Copyright (C) 2003-2007 Shay Green. This module is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser @@ -13,7 +13,7 @@ details. You should have received a copy of the GNU Lesser General Public License along with this module; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "blargg_source.h" +#include "core/apu/blargg_source.h" #ifdef BLARGG_ENABLE_OPTIMIZER #include BLARGG_ENABLE_OPTIMIZER diff --git a/src/apu/Multi_Buffer.h b/src/core/apu/Multi_Buffer.h similarity index 99% rename from src/apu/Multi_Buffer.h rename to src/core/apu/Multi_Buffer.h index 093e879f..6f5efebf 100644 --- a/src/apu/Multi_Buffer.h +++ b/src/core/apu/Multi_Buffer.h @@ -4,8 +4,8 @@ #ifndef MULTI_BUFFER_H #define MULTI_BUFFER_H -#include "Blip_Buffer.h" -#include "blargg_common.h" +#include "core/apu/Blip_Buffer.h" +#include "core/apu/blargg_common.h" // Interface to one or more Blip_Buffers mapped to one or more channels // consisting of left, center, and right buffers. diff --git a/src/apu/blargg_common.h b/src/core/apu/blargg_common.h similarity index 99% rename from src/apu/blargg_common.h rename to src/core/apu/blargg_common.h index 5335bb28..e85f9b60 100644 --- a/src/apu/blargg_common.h +++ b/src/core/apu/blargg_common.h @@ -12,7 +12,7 @@ #undef BLARGG_COMMON_H // allow blargg_config.h to #include blargg_common.h -#include "blargg_config.h" +#include "core/apu/blargg_config.h" #ifndef BLARGG_COMMON_H #define BLARGG_COMMON_H diff --git a/src/apu/blargg_config.h b/src/core/apu/blargg_config.h similarity index 100% rename from src/apu/blargg_config.h rename to src/core/apu/blargg_config.h diff --git a/src/apu/blargg_source.h b/src/core/apu/blargg_source.h similarity index 100% rename from src/apu/blargg_source.h rename to src/core/apu/blargg_source.h diff --git a/src/gb/GB.cpp b/src/core/gb/gb.cpp similarity index 99% rename from src/gb/GB.cpp rename to src/core/gb/gb.cpp index 33fd8175..01fb1266 100644 --- a/src/gb/GB.cpp +++ b/src/core/gb/gb.cpp @@ -1,4 +1,4 @@ -#include "gb.h" +#include "core/gb/gb.h" #include #include @@ -8,17 +8,21 @@ #include #include -#include "../gba/GBALink.h" -#include "../gba/Sound.h" #include "core/base/file_util.h" #include "core/base/message.h" #include "core/base/sizes.h" #include "core/base/system.h" -#include "gbCheats.h" -#include "gbGlobals.h" -#include "gbMemory.h" -#include "gbSGB.h" -#include "gbSound.h" +#include "core/gb/gbCheats.h" +#include "core/gb/gbGfx.h" +#include "core/gb/gbGlobals.h" +#include "core/gb/gbMemory.h" +#include "core/gb/gbSGB.h" +#include "core/gb/gbSound.h" +#include "core/gba/gbaSound.h" + +#if !defined(NO_LINK) +#include "core/gba/gbaLink.h" +#endif // !defined(NOLINK) #if !defined(__LIBRETRO__) #include "core/base/image_util.h" @@ -4809,10 +4813,10 @@ void gbEmulate(int ticksToStop) case 0xCB: // extended opcode switch (opcode2) { -#include "gbCodesCB.h" +#include "core/gb/internal/gbCodesCB.h" } break; -#include "gbCodes.h" +#include "core/gb/internal/gbCodes.h" } execute = false; diff --git a/src/gb/gb.h b/src/core/gb/gb.h similarity index 89% rename from src/gb/gb.h rename to src/core/gb/gb.h index d2aa8a03..a3500780 100644 --- a/src/gb/gb.h +++ b/src/core/gb/gb.h @@ -1,14 +1,9 @@ -#ifndef GB_H -#define GB_H +#ifndef VBAM_CORE_GB_GB_H_ +#define VBAM_CORE_GB_GB_H_ #include -#include "gbCartData.h" - -#define gbWidth 160 -#define gbHeight 144 -#define sgbWidth 256 -#define sgbHeight 224 +#include "core/gb/gbCartData.h" const int GB_C_FLAG = 0x10; const int GB_H_FLAG = 0x20; @@ -28,7 +23,6 @@ typedef union { extern gbRegister AF, BC, DE, HL, SP, PC; extern uint16_t IFF; -int gbDis(char*, uint16_t); // Attempts to load the ROM file at `filename`. Returns true on success. bool gbLoadRom(const char* filename); @@ -67,4 +61,4 @@ extern int gbHardware; extern gbCartData g_gbCartData; extern struct EmulatedSystem GBSystem; -#endif // GB_H +#endif // VBAM_CORE_GB_GB_H_ diff --git a/src/gb/gbCartData.cpp b/src/core/gb/gbCartData.cpp similarity index 99% rename from src/gb/gbCartData.cpp rename to src/core/gb/gbCartData.cpp index 9c98de15..ca04b2cc 100644 --- a/src/gb/gbCartData.cpp +++ b/src/core/gb/gbCartData.cpp @@ -1,4 +1,4 @@ -#include "gbCartData.h" +#include "core/gb/gbCartData.h" #include #include diff --git a/src/gb/gbCartData.h b/src/core/gb/gbCartData.h similarity index 98% rename from src/gb/gbCartData.h rename to src/core/gb/gbCartData.h index bd99f5e7..573c77c2 100644 --- a/src/gb/gbCartData.h +++ b/src/core/gb/gbCartData.h @@ -1,7 +1,6 @@ -#ifndef VBAM_GB_GB_ROM_H_ -#define VBAM_GB_GB_ROM_H_ +#ifndef VBAM_CORE_GB_GBCARTDATA_H_ +#define VBAM_CORE_GB_GBCARTDATA_H_ -#include #include #include @@ -201,4 +200,4 @@ private: uint16_t actual_global_checksum_ = 0; }; -#endif // VBAM_GB_GB_ROM_H_ +#endif // VBAM_CORE_GB_GBCARTDATA_H_ diff --git a/src/gb/gbCheats.cpp b/src/core/gb/gbCheats.cpp similarity index 99% rename from src/gb/gbCheats.cpp rename to src/core/gb/gbCheats.cpp index c88132cf..07df41bd 100644 --- a/src/gb/gbCheats.cpp +++ b/src/core/gb/gbCheats.cpp @@ -1,15 +1,14 @@ -#include "gbCheats.h" +#include "core/gb/gbCheats.h" #include #include #include +#include "core/base/file_util.h" #include "core/base/message.h" #include "core/base/system.h" - -#include "core/base/file_util.h" -#include "gb.h" -#include "gbGlobals.h" +#include "core/gb/gb.h" +#include "core/gb/gbGlobals.h" gbCheat gbCheatList[MAX_CHEATS]; int gbCheatNumber = 0; diff --git a/src/gb/gbCheats.h b/src/core/gb/gbCheats.h similarity index 91% rename from src/gb/gbCheats.h rename to src/core/gb/gbCheats.h index 513513e9..37acc9c5 100644 --- a/src/gb/gbCheats.h +++ b/src/core/gb/gbCheats.h @@ -1,5 +1,5 @@ -#ifndef GBCHEATS_H -#define GBCHEATS_H +#ifndef VBAM_CORE_GB_GBCHEATS_H_ +#define VBAM_CORE_GB_GBCHEATS_H_ #include @@ -48,4 +48,4 @@ extern int gbCheatNumber; extern gbCheat gbCheatList[MAX_CHEATS]; extern bool gbCheatMap[0x10000]; -#endif // GBCHEATS_H +#endif // VBAM_CORE_GB_GBCHEATS_H_ diff --git a/src/gb/gbDis.cpp b/src/core/gb/gbDis.cpp similarity index 99% rename from src/gb/gbDis.cpp rename to src/core/gb/gbDis.cpp index 42202b7a..8061357b 100644 --- a/src/gb/gbDis.cpp +++ b/src/core/gb/gbDis.cpp @@ -1,6 +1,8 @@ +#include "core/gb/gbDis.h" + #include -#include "gbGlobals.h" +#include "core/gb/gbGlobals.h" typedef struct { uint8_t mask; diff --git a/src/core/gb/gbDis.h b/src/core/gb/gbDis.h new file mode 100644 index 00000000..3603db9d --- /dev/null +++ b/src/core/gb/gbDis.h @@ -0,0 +1,8 @@ +#ifndef VBAM_CORE_GB_GBDIS_H_ +#define VBAM_CORE_GB_GBDIS_H_ + +#include + +int gbDis(char*, uint16_t); + +#endif // VBAM_CORE_GB_GBDIS_H_ diff --git a/src/gb/gbGfx.cpp b/src/core/gb/gbGfx.cpp similarity index 99% rename from src/gb/gbGfx.cpp rename to src/core/gb/gbGfx.cpp index f9d3b1c6..b0835b41 100644 --- a/src/gb/gbGfx.cpp +++ b/src/core/gb/gbGfx.cpp @@ -1,8 +1,10 @@ +#include "core/gb/gbGfx.h" + #include #include "core/base/system.h" -#include "gbGlobals.h" -#include "gbSGB.h" +#include "core/gb/gbGlobals.h" +#include "core/gb/gbSGB.h" uint8_t gbInvertTab[256] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, diff --git a/src/core/gb/gbGfx.h b/src/core/gb/gbGfx.h new file mode 100644 index 00000000..151c784e --- /dev/null +++ b/src/core/gb/gbGfx.h @@ -0,0 +1,7 @@ +#ifndef VBAM_CORE_GB_GBGFX_H_ +#define VBAM_CORE_GB_GBGFX_H_ + +void gbRenderLine(); +void gbDrawSprites(bool); + +#endif // VBAM_CORE_GB_GBGFX_H_ diff --git a/src/gb/gbGlobals.cpp b/src/core/gb/gbGlobals.cpp similarity index 96% rename from src/gb/gbGlobals.cpp rename to src/core/gb/gbGlobals.cpp index 0e0e9f77..d1afecdf 100644 --- a/src/gb/gbGlobals.cpp +++ b/src/core/gb/gbGlobals.cpp @@ -1,4 +1,4 @@ -#include "gbGlobals.h" +#include "core/gb/gbGlobals.h" uint8_t* gbMemoryMap[16]; diff --git a/src/gb/gbGlobals.h b/src/core/gb/gbGlobals.h similarity index 92% rename from src/gb/gbGlobals.h rename to src/core/gb/gbGlobals.h index 7ca2943c..6dfe8766 100644 --- a/src/gb/gbGlobals.h +++ b/src/core/gb/gbGlobals.h @@ -1,5 +1,5 @@ -#ifndef GBGLOBALS_H -#define GBGLOBALS_H +#ifndef VBAM_CORE_GB_GBGLOBALS_H_ +#define VBAM_CORE_GB_GBGLOBALS_H_ #include @@ -59,9 +59,6 @@ extern int gbBorderRowSkip; extern int gbBorderColumnSkip; extern int gbDmaTicks; -extern void gbRenderLine(); -extern void gbDrawSprites(bool); - extern uint8_t (*gbSerialFunction)(uint8_t); -#endif // GBGLOBALS_H +#endif // VBAM_CORE_GB_GBGLOBALS_H_ diff --git a/src/gb/gbMemory.cpp b/src/core/gb/gbMemory.cpp similarity index 99% rename from src/gb/gbMemory.cpp rename to src/core/gb/gbMemory.cpp index 00b2fb52..402a91da 100644 --- a/src/gb/gbMemory.cpp +++ b/src/core/gb/gbMemory.cpp @@ -1,16 +1,15 @@ -#include "gbMemory.h" +#include "core/gb/gbMemory.h" #include #include "core/base/port.h" #include "core/base/sizes.h" #include "core/base/system.h" -#include "gb.h" -#include "gbGlobals.h" +#include "core/gb/gb.h" +#include "core/gb/gbGlobals.h" uint8_t gbDaysinMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; extern int gbGBCColorType; -extern gbRegister PC; mapperMBC1 gbDataMBC1 = { 0, // RAM enable diff --git a/src/gb/gbMemory.h b/src/core/gb/gbMemory.h similarity index 98% rename from src/gb/gbMemory.h rename to src/core/gb/gbMemory.h index 03816c80..4d6bcd9e 100644 --- a/src/gb/gbMemory.h +++ b/src/core/gb/gbMemory.h @@ -1,5 +1,5 @@ -#ifndef GBMEMORY_H -#define GBMEMORY_H +#ifndef VBAM_CORE_GB_GBMEMORY_H_ +#define VBAM_CORE_GB_GBMEMORY_H_ #include #include @@ -209,4 +209,4 @@ extern void memoryUpdateMapGS3(); #define HUC3_RTC_DATA_SIZE sizeof(int) * 4 + sizeof(uint64_t) -#endif // GBMEMORY_H +#endif // VBAM_CORE_GB_GBMEMORY_H_ diff --git a/src/gb/gbPrinter.cpp b/src/core/gb/gbPrinter.cpp similarity index 99% rename from src/gb/gbPrinter.cpp rename to src/core/gb/gbPrinter.cpp index 530d59a5..3b16cc58 100644 --- a/src/gb/gbPrinter.cpp +++ b/src/core/gb/gbPrinter.cpp @@ -1,4 +1,4 @@ -#include "gbPrinter.h" +#include "core/gb/gbPrinter.h" #include #include diff --git a/src/core/gb/gbPrinter.h b/src/core/gb/gbPrinter.h new file mode 100644 index 00000000..8b6343d0 --- /dev/null +++ b/src/core/gb/gbPrinter.h @@ -0,0 +1,8 @@ +#ifndef VBAM_CORE_GB_GBPRINTER_H_ +#define VBAM_CORE_GB_GBPRINTER_H_ + +#include + +uint8_t gbPrinterSend(uint8_t b); + +#endif // VBAM_CORE_GB_GBPRINTER_H_ diff --git a/src/gb/gbSGB.cpp b/src/core/gb/gbSGB.cpp similarity index 99% rename from src/gb/gbSGB.cpp rename to src/core/gb/gbSGB.cpp index c20333ad..e084b848 100644 --- a/src/gb/gbSGB.cpp +++ b/src/core/gb/gbSGB.cpp @@ -1,11 +1,13 @@ -#include -#include +#include "core/gb/gbSGB.h" + +#include +#include #include "core/base/file_util.h" #include "core/base/port.h" #include "core/base/system.h" -#include "gb.h" -#include "gbGlobals.h" +#include "core/gb/gb.h" +#include "core/gb/gbGlobals.h" extern uint8_t* g_pix; extern bool speedup; diff --git a/src/gb/gbSGB.h b/src/core/gb/gbSGB.h similarity index 87% rename from src/gb/gbSGB.h rename to src/core/gb/gbSGB.h index 0fb6cbee..3dbc374f 100644 --- a/src/gb/gbSGB.h +++ b/src/core/gb/gbSGB.h @@ -1,5 +1,5 @@ -#ifndef GBSGB_H -#define GBSGB_H +#ifndef VBAM_CORE_GB_GBSGB_H_ +#define VBAM_CORE_GB_GBSGB_H_ #include @@ -30,4 +30,4 @@ extern int gbSgbPacketTimeout; extern uint8_t gbSgbReadingController; extern int gbSgbFourPlayers; -#endif // GBSGB_H +#endif // VBAM_CORE_GB_GBSGB_H_ diff --git a/src/gb/gbSound.cpp b/src/core/gb/gbSound.cpp similarity index 98% rename from src/gb/gbSound.cpp rename to src/core/gb/gbSound.cpp index af7545f5..612ce20e 100644 --- a/src/gb/gbSound.cpp +++ b/src/core/gb/gbSound.cpp @@ -2,14 +2,14 @@ #include +#include "core/apu/Effects_Buffer.h" +#include "core/apu/Gb_Apu.h" #include "core/base/system.h" #include "core/base/file_util.h" -#include "../gba/Sound.h" -#include "gb.h" -#include "gbGlobals.h" +#include "core/gb/gb.h" +#include "core/gb/gbGlobals.h" +#include "core/gba/gbaSound.h" -#include "../apu/Effects_Buffer.h" -#include "../apu/Gb_Apu.h" extern long soundSampleRate; // current sound quality diff --git a/src/gb/gbSound.h b/src/core/gb/gbSound.h similarity index 95% rename from src/gb/gbSound.h rename to src/core/gb/gbSound.h index b63accab..7a39ca13 100644 --- a/src/gb/gbSound.h +++ b/src/core/gb/gbSound.h @@ -1,5 +1,5 @@ -#ifndef GBSOUND_H -#define GBSOUND_H +#ifndef VBAM_CORE_GB_GBSOUND_H_ +#define VBAM_CORE_GB_GBSOUND_H_ #include @@ -82,4 +82,4 @@ void gbSoundSaveGame(gzFile out); void gbSoundReadGame(int version, gzFile in); #endif -#endif // GBSOUND_H +#endif // VBAM_CORE_GB_GBSOUND_H_ diff --git a/src/gb/gbCodes.h b/src/core/gb/internal/gbCodes.h similarity index 100% rename from src/gb/gbCodes.h rename to src/core/gb/internal/gbCodes.h diff --git a/src/gb/gbCodesCB.h b/src/core/gb/internal/gbCodesCB.h similarity index 100% rename from src/gb/gbCodesCB.h rename to src/core/gb/internal/gbCodesCB.h diff --git a/src/gba/debugger-expr-lex.cpp b/src/core/gba/debugger-expr-lex.cpp similarity index 100% rename from src/gba/debugger-expr-lex.cpp rename to src/core/gba/debugger-expr-lex.cpp diff --git a/src/gba/debugger-expr-yacc.cpp b/src/core/gba/debugger-expr-yacc.cpp similarity index 99% rename from src/gba/debugger-expr-yacc.cpp rename to src/core/gba/debugger-expr-yacc.cpp index 5932e0d7..4028be39 100644 --- a/src/gba/debugger-expr-yacc.cpp +++ b/src/core/gba/debugger-expr-yacc.cpp @@ -77,9 +77,10 @@ #line 1 "debugger-expr.y" #include - -#include "GBA.h" + #include "core/base/port.h" +#include "core/gba/gba.h" +#include "core/gba/gbaGlobals.h" #include #include diff --git a/src/gba/debugger-expr-yacc.hpp b/src/core/gba/debugger-expr-yacc.hpp similarity index 100% rename from src/gba/debugger-expr-yacc.hpp rename to src/core/gba/debugger-expr-yacc.hpp diff --git a/src/gba/debugger-expr.l b/src/core/gba/debugger-expr.l similarity index 100% rename from src/gba/debugger-expr.l rename to src/core/gba/debugger-expr.l diff --git a/src/gba/debugger-expr.y b/src/core/gba/debugger-expr.y similarity index 98% rename from src/gba/debugger-expr.y rename to src/core/gba/debugger-expr.y index 9fe2c2e7..3ab9a046 100644 --- a/src/gba/debugger-expr.y +++ b/src/core/gba/debugger-expr.y @@ -1,8 +1,9 @@ %{ #include - -#include "GBA.h" + #include "core/base/port.h" +#include "core/gba/gba.h" +#include "core/gba/gbaGlobals.h" #include #include diff --git a/src/gba/GBA.cpp b/src/core/gba/gba.cpp similarity index 99% rename from src/gba/GBA.cpp rename to src/core/gba/gba.cpp index c55a096a..8a937cc2 100644 --- a/src/gba/GBA.cpp +++ b/src/core/gba/gba.cpp @@ -1,9 +1,10 @@ +#include "core/gba/gba.h" + #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #ifndef _MSC_VER #include @@ -11,24 +12,29 @@ #include "core/base/file_util.h" #include "core/base/message.h" -#include "core/base/system.h" #include "core/base/port.h" #include "core/base/sizes.h" -#include "Cheats.h" -#include "EEprom.h" -#include "Flash.h" -#include "GBA.h" -#include "GBAGfx.h" -#include "GBALink.h" -#include "GBAcpu.h" -#include "GBAinline.h" -#include "Globals.h" -#include "Sound.h" -#include "Sram.h" -#include "agbprint.h" -#include "bios.h" -#include "elf.h" -#include "ereader.h" +#include "core/base/system.h" +#include "core/gba/gbaCheats.h" +#include "core/gba/gbaCpu.h" +#include "core/gba/gbaEeprom.h" +#include "core/gba/gbaFlash.h" +#include "core/gba/gbaGlobals.h" +#include "core/gba/gbaGfx.h" +#include "core/gba/gbaInline.h" +#include "core/gba/gbaPrint.h" +#include "core/gba/gbaSound.h" +#include "core/gba/internal/gbaBios.h" +#include "core/gba/internal/gbaEreader.h" +#include "core/gba/internal/gbaSram.h" + +#if defined(VBAM_ENABLE_DEBUGGER) +#include "core/gba/gbaElf.h" +#endif // defined(VBAM_ENABLE_DEBUGGER) + +#if !defined(NO_LINK) +#include "core/gba/gbaLink.h" +#endif // !defined(NOLINK) #if !defined(__LIBRETRO__) #include "core/base/image_util.h" @@ -47,7 +53,7 @@ #endif extern int emulating; -bool debugger; +bool debugger = false; int SWITicks = 0; int IRQTicks = 0; @@ -85,7 +91,7 @@ int profilingTicksReload = 0; static profile_segment* profilSegment = NULL; #endif -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER uint8_t freezeWorkRAM[SIZE_WRAM]; uint8_t freezeInternalRAM[SIZE_IRAM]; uint8_t freezeVRAM[0x18000]; @@ -1423,9 +1429,9 @@ void CPUCleanUp() g_ioMem = NULL; } -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) elfCleanUp(); -#endif //NO_DEBUGGER +#endif // defined(VBAM_ENABLE_DEBUGGER) systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; @@ -1447,7 +1453,7 @@ void SetMapMasks() map[12].mask = 0x1FFFFFF; map[14].mask = 0xFFFF; -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER for (int i = 0; i < 16; i++) { map[i].size = map[i].mask + 1; map[i].trace = NULL; @@ -1497,7 +1503,7 @@ int CPULoadRom(const char* szFile) uint8_t* whereToLoad = coreOptions.cpuIsMultiBoot ? g_workRAM : g_rom; -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) if (CPUIsELF(szFile)) { FILE* f = utilOpenFile(szFile, "rb"); if (!f) { @@ -1519,7 +1525,7 @@ int CPULoadRom(const char* szFile) return 0; } } else -#endif //NO_DEBUGGER +#endif // defined(VBAM_ENABLE_DEBUGGER) if (szFile != NULL) { if (!utilLoad(szFile, utilIsGBAImage, @@ -2018,7 +2024,7 @@ void CPUSoftwareInterrupt(int comment) static bool disableMessage = false; if (armState) comment >>= 16; -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (comment == 0xff) { dbgOutput(NULL, reg[0].I); return; diff --git a/src/gba/GBA.h b/src/core/gba/gba.h similarity index 76% rename from src/gba/GBA.h rename to src/core/gba/gba.h index f8aa77fa..70059722 100644 --- a/src/gba/GBA.h +++ b/src/core/gba/gba.h @@ -1,5 +1,5 @@ -#ifndef GBA_H -#define GBA_H +#ifndef VBAM_CORE_GBA_GBA_H_ +#define VBAM_CORE_GBA_GBA_H_ #include @@ -58,7 +58,7 @@ enum { typedef struct { uint8_t* address; uint32_t mask; -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER uint8_t* breakPoints; uint8_t* searchMatch; uint8_t* trace; @@ -108,8 +108,9 @@ extern bool cpuSramEnabled; extern bool cpuFlashEnabled; extern bool cpuEEPROMEnabled; extern bool cpuEEPROMSensorEnabled; +extern bool debugger; -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER extern uint8_t freezeWorkRAM[0x40000]; extern uint8_t freezeInternalRAM[0x8000]; extern uint8_t freezeVRAM[0x18000]; @@ -118,7 +119,6 @@ extern uint8_t freezePRAM[0x400]; extern bool debugger_last; extern int oldreg[18]; extern char oldbuffer[10]; -extern bool debugger; #endif extern bool CPUReadGSASnapshot(const char*); @@ -195,9 +195,26 @@ extern struct EmulatedSystem GBASystem; #define R14_FIQ 43 #define SPSR_FIQ 44 -#include "Cheats.h" -#include "EEprom.h" -#include "Flash.h" -#include "Globals.h" +// register definitions +#define COMM_SIODATA32_L 0x120 // Lower 16bit on Normal mode +#define COMM_SIODATA32_H 0x122 // Higher 16bit on Normal mode +#define COMM_SIOCNT 0x128 +#define COMM_SIODATA8 0x12a // 8bit on Normal/UART mode, (up to 4x8bit with FIFO) +#define COMM_SIOMLT_SEND 0x12a // SIOMLT_SEND (16bit R/W) on MultiPlayer mode (local outgoing) +#define COMM_SIOMULTI0 0x120 // SIOMULTI0 (16bit) on MultiPlayer mode (Parent/Master) +#define COMM_SIOMULTI1 0x122 // SIOMULTI1 (16bit) on MultiPlayer mode (Child1/Slave1) +#define COMM_SIOMULTI2 0x124 // SIOMULTI2 (16bit) on MultiPlayer mode (Child2/Slave2) +#define COMM_SIOMULTI3 0x126 // SIOMULTI3 (16bit) on MultiPlayer mode (Child3/Slave3) +#define COMM_RCNT 0x134 // SIO Mode (4bit data) on GeneralPurpose mode +#define COMM_IR 0x136 // Infrared Register (16bit) 1bit data at a time(LED On/Off)? +#define COMM_JOYCNT 0x140 +#define COMM_JOY_RECV_L 0x150 // Send/Receive 8bit Lower first then 8bit Higher +#define COMM_JOY_RECV_H 0x152 +#define COMM_JOY_TRANS_L 0x154 // Send/Receive 8bit Lower first then 8bit Higher +#define COMM_JOY_TRANS_H 0x156 +#define COMM_JOYSTAT 0x158 // Send/Receive 8bit lower only -#endif // GBA_H +#define JOYSTAT_RECV 2 +#define JOYSTAT_SEND 8 + +#endif // VBAM_CORE_GBA_GBA_H_ diff --git a/src/gba/CheatSearch.cpp b/src/core/gba/gbaCheatSearch.cpp similarity index 99% rename from src/gba/CheatSearch.cpp rename to src/core/gba/gbaCheatSearch.cpp index e3219682..6b5c8413 100644 --- a/src/gba/CheatSearch.cpp +++ b/src/core/gba/gbaCheatSearch.cpp @@ -1,7 +1,7 @@ -#include -#include +#include "core/gba/gbaCheatSearch.h" -#include "CheatSearch.h" +#include +#include CheatSearchBlock cheatSearchBlocks[4]; diff --git a/src/gba/CheatSearch.h b/src/core/gba/gbaCheatSearch.h similarity index 90% rename from src/gba/CheatSearch.h rename to src/core/gba/gbaCheatSearch.h index 9fe7383e..c41cdb7e 100644 --- a/src/gba/CheatSearch.h +++ b/src/core/gba/gbaCheatSearch.h @@ -1,5 +1,5 @@ -#ifndef CHEATSEARCH_H -#define CHEATSEARCH_H +#ifndef VBAM_CORE_GBA_GBACHEATSEARCH_H_ +#define VBAM_CORE_GBA_GBACHEATSEARCH_H_ #include @@ -44,4 +44,4 @@ void cheatSearchUpdateValues(const CheatSearchData* cs); int32_t cheatSearchSignedRead(uint8_t* data, int off, int size); uint32_t cheatSearchRead(uint8_t* data, int off, int size); -#endif // CHEATSEARCH_H +#endif // VBAM_CORE_GBA_GBACHEATSEARCH_H_ diff --git a/src/gba/Cheats.cpp b/src/core/gba/gbaCheats.cpp similarity index 99% rename from src/gba/Cheats.cpp rename to src/core/gba/gbaCheats.cpp index f0daf47c..cbfc3aa3 100644 --- a/src/gba/Cheats.cpp +++ b/src/core/gba/gbaCheats.cpp @@ -1,13 +1,13 @@ -#include "Cheats.h" +#include "core/gba/gbaCheats.h" #include #include #include "core/base/file_util.h" #include "core/base/message.h" -#include "GBA.h" -#include "GBAinline.h" -#include "Globals.h" +#include "core/gba/gba.h" +#include "core/gba/gbaInline.h" +#include "core/gba/gbaGlobals.h" /** * Gameshark code types: (based on AR v1.0) @@ -2802,7 +2802,7 @@ extern int cpuNextEvent; extern void debuggerBreakOnWrite(uint32_t, uint32_t, uint32_t, int, int); -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER static uint8_t cheatsGetType(uint32_t address) { switch (address >> 24) { @@ -2824,7 +2824,7 @@ static uint8_t cheatsGetType(uint32_t address) } #endif -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER void cheatsWriteMemory(uint32_t address, uint32_t value) { if (cheatsNumber == 0) { diff --git a/src/gba/Cheats.h b/src/core/gba/gbaCheats.h similarity index 91% rename from src/gba/Cheats.h rename to src/core/gba/gbaCheats.h index f9e76887..8eadee7f 100644 --- a/src/gba/Cheats.h +++ b/src/core/gba/gbaCheats.h @@ -1,5 +1,5 @@ -#ifndef CHEATS_H -#define CHEATS_H +#ifndef VBAM_CORE_GBA_GBACHEATS_H_ +#define VBAM_CORE_GBA_GBACHEATS_H_ #include @@ -39,7 +39,7 @@ void cheatsReadGameSkip(gzFile file, int version); void cheatsSaveCheatList(const char* file); bool cheatsLoadCheatList(const char* file); #endif -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER void cheatsWriteMemory(uint32_t address, uint32_t value); void cheatsWriteHalfWord(uint32_t address, uint16_t value); void cheatsWriteByte(uint32_t address, uint8_t value); @@ -49,4 +49,4 @@ int cheatsCheckKeys(uint32_t keys, uint32_t extended); extern int cheatsNumber; extern CheatsData cheatsList[MAX_CHEATS]; -#endif // CHEATS_H +#endif // VBAM_CORE_GBA_GBACHEATS_H_ diff --git a/src/gba/GBAcpu.h b/src/core/gba/gbaCpu.h similarity index 96% rename from src/gba/GBAcpu.h rename to src/core/gba/gbaCpu.h index 69de3a64..10b719a1 100644 --- a/src/gba/GBAcpu.h +++ b/src/core/gba/gbaCpu.h @@ -1,5 +1,11 @@ -#ifndef GBACPU_H -#define GBACPU_H +#ifndef VBAM_CORE_GBA_GBACPU_H_ +#define VBAM_CORE_GBA_GBACPU_H_ + +#include + +#include "core/base/system.h" +#include "core/gba/gbaCheats.h" +#include "core/gba/gbaGlobals.h" extern int armExecute(); extern int thumbExecute(); @@ -234,4 +240,4 @@ inline void cpuMasterCodeCheck() } } -#endif // GBACPU_H +#endif // VBAM_CORE_GBA_GBACPU_H_ diff --git a/src/gba/GBA-arm.cpp b/src/core/gba/gbaCpuArm.cpp similarity index 99% rename from src/gba/GBA-arm.cpp rename to src/core/gba/gbaCpuArm.cpp index cdb6b20f..a9f03493 100644 --- a/src/gba/GBA-arm.cpp +++ b/src/core/gba/gbaCpuArm.cpp @@ -1,8 +1,12 @@ -#include "GBA.h" -#include "GBAcpu.h" -#include "GBAinline.h" -#include "Globals.h" -#include "remote.h" +#include "core/gba/gba.h" + +#include "core/gba/gbaCpu.h" +#include "core/gba/gbaInline.h" +#include "core/gba/gbaGlobals.h" + +#if defined(VBAM_ENABLE_DEBUGGER) +#include "core/gba/gbaRemote.h" +#endif // defined(VBAM_ENABLE_DEBUGGER) #ifdef PROFILING #include "prof/prof.h" @@ -31,7 +35,7 @@ static INSN_REGPARM void armUnknownInsn(uint32_t opcode) CPUUndefinedException(); } -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER static INSN_REGPARM void armBreakpoint(uint32_t opcode) { reg[15].I -= 4; @@ -81,7 +85,7 @@ static void count(uint32_t opcode, int cond_res) // Common macros ////////////////////////////////////////////////////////// -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER #define CONSOLE_OUTPUT(a, b) \ do { \ if ((opcode == 0xe0000000) && (reg[0].I == 0xC0DED00D)) { \ @@ -2610,7 +2614,7 @@ typedef INSN_REGPARM void (*insnfunc_t)(uint32_t opcode); REP16(insn), REP16(insn), REP16(insn), REP16(insn), \ REP16(insn), REP16(insn), REP16(insn), REP16(insn) #define arm_UI armUnknownInsn -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER #define arm_BP armBreakpoint #else #define arm_BP armUnknownInsn @@ -2839,7 +2843,7 @@ int armExecute() reg[15].I += 4; ARM_PREFETCH_NEXT; -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER uint32_t memAddr = armNextPC; memoryMap* m = &map[memAddr >> 24]; if (m->breakPoints && BreakARMCheck(m->breakPoints, memAddr & m->mask)) { @@ -2914,7 +2918,7 @@ int armExecute() count(opcode, cond_res); #endif -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (enableRegBreak) { if (lowRegBreakCounter[0]) breakReg_check(0); diff --git a/src/gba/armdis.cpp b/src/core/gba/gbaCpuArmDis.cpp similarity index 99% rename from src/gba/armdis.cpp rename to src/core/gba/gbaCpuArmDis.cpp index bca0c735..bc2b72ad 100644 --- a/src/gba/armdis.cpp +++ b/src/core/gba/gbaCpuArmDis.cpp @@ -1,4 +1,4 @@ -#include "armdis.h" +#include "core/gba/gbaCpuArmDis.h" /************************************************************************/ /* Arm/Thumb command set disassembler */ @@ -6,9 +6,8 @@ #include #include "core/base/port.h" -#include "GBA.h" -#include "armdis.h" -#include "elf.h" +#include "core/gba/gba.h" +#include "core/gba/gbaElf.h" struct Opcodes { uint32_t mask; diff --git a/src/gba/armdis.h b/src/core/gba/gbaCpuArmDis.h similarity index 79% rename from src/gba/armdis.h rename to src/core/gba/gbaCpuArmDis.h index f770e1f9..8bc8c209 100644 --- a/src/gba/armdis.h +++ b/src/core/gba/gbaCpuArmDis.h @@ -2,8 +2,8 @@ /* Arm/Thumb command set disassembler */ /************************************************************************/ -#ifndef __ARMDIS_H__ -#define __ARMDIS_H__ +#ifndef VBAM_CORE_GBA_GBACPUARMDIS_H_ +#define VBAM_CORE_GBA_GBACPUARMDIS_H_ #include @@ -13,4 +13,4 @@ int disThumb(uint32_t offset, char* dest, unsigned dest_sz, int flags); int disArm(uint32_t offset, char* dest, unsigned dest_sz, int flags); -#endif // __ARMDIS_H__ +#endif // VBAM_CORE_GBA_GBACPUARMDIS_H_ diff --git a/src/gba/GBA-thumb.cpp b/src/core/gba/gbaCpuThumb.cpp similarity index 99% rename from src/gba/GBA-thumb.cpp rename to src/core/gba/gbaCpuThumb.cpp index d0b47b85..ba91f6d9 100644 --- a/src/gba/GBA-thumb.cpp +++ b/src/core/gba/gbaCpuThumb.cpp @@ -6,11 +6,14 @@ #include #endif -#include "GBA.h" -#include "GBAcpu.h" -#include "GBAinline.h" -#include "Globals.h" -#include "remote.h" +#include "core/gba/gba.h" +#include "core/gba/gbaCpu.h" +#include "core/gba/gbaInline.h" +#include "core/gba/gbaGlobals.h" + +#if defined(VBAM_ENABLE_DEBUGGER) +#include "core/gba/gbaRemote.h" +#endif // defined(VBAM_ENABLE_DEBUGGER) #ifdef PROFILING #include "prof/prof.h" @@ -33,7 +36,7 @@ static INSN_REGPARM void thumbUnknownInsn(uint32_t opcode) CPUUndefinedException(); } -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER static INSN_REGPARM void thumbBreakpoint(uint32_t opcode) { reg[15].I -= 2; @@ -45,7 +48,7 @@ static INSN_REGPARM void thumbBreakpoint(uint32_t opcode) // Common macros ////////////////////////////////////////////////////////// -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER #define THUMB_CONSOLE_OUTPUT(a, b) \ do { \ if ((opcode == 0x4000) && (reg[0].I == 0xC0DED00D)) { \ @@ -1853,7 +1856,7 @@ static INSN_REGPARM void thumbF8(uint32_t opcode) typedef INSN_REGPARM void (*insnfunc_t)(uint32_t opcode); #define thumbUI thumbUnknownInsn -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER #define thumbBP thumbBreakpoint #else #define thumbBP thumbUnknownInsn @@ -2021,7 +2024,7 @@ int thumbExecute() reg[15].I += 2; THUMB_PREFETCH_NEXT; -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER uint32_t memAddr = armNextPC; memoryMap* m = &map[memAddr >> 24]; if (m->breakPoints && BreakThumbCheck(m->breakPoints, memAddr & m->mask)) { @@ -2035,7 +2038,7 @@ int thumbExecute() (*thumbInsnTable[opcode >> 6])(opcode); -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (enableRegBreak) { if (lowRegBreakCounter[0]) breakReg_check(0); diff --git a/src/gba/EEprom.cpp b/src/core/gba/gbaEeprom.cpp similarity index 98% rename from src/gba/EEprom.cpp rename to src/core/gba/gbaEeprom.cpp index c3ab1907..19b43b6a 100644 --- a/src/gba/EEprom.cpp +++ b/src/core/gba/gbaEeprom.cpp @@ -1,9 +1,9 @@ -#include "EEprom.h" +#include "core/gba/gbaEeprom.h" #include #include "core/base/file_util.h" -#include "GBA.h" +#include "core/gba/gba.h" extern int cpuDmaCount; diff --git a/src/gba/EEprom.h b/src/core/gba/gbaEeprom.h similarity index 88% rename from src/gba/EEprom.h rename to src/core/gba/gbaEeprom.h index 28f160ac..79c33d12 100644 --- a/src/gba/EEprom.h +++ b/src/core/gba/gbaEeprom.h @@ -1,5 +1,5 @@ -#ifndef EEPROM_H -#define EEPROM_H +#ifndef VBAM_CORE_GBA_GBAEEPROM_H_ +#define VBAM_CORE_GBA_GBAEEPROM_H_ #include @@ -29,4 +29,4 @@ extern int eepromSize; #define EEPROM_READDATA2 3 #define EEPROM_WRITEDATA 4 -#endif // EEPROM_H +#endif // VBAM_CORE_GBA_GBAEEPROM_H_ diff --git a/src/gba/elf.cpp b/src/core/gba/gbaElf.cpp similarity index 99% rename from src/gba/elf.cpp rename to src/core/gba/gbaElf.cpp index 24d5a84a..de1857f4 100644 --- a/src/gba/elf.cpp +++ b/src/core/gba/gbaElf.cpp @@ -1,11 +1,13 @@ +#include "core/gba/gbaElf.h" + #include #include #include #include "core/base/message.h" #include "core/base/port.h" -#include "GBA.h" -#include "elf.h" +#include "core/gba/gba.h" +#include "core/gba/gbaGlobals.h" #define elfReadMemory(addr) \ READ32LE((&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask])) diff --git a/src/gba/elf.h b/src/core/gba/gbaElf.h similarity index 97% rename from src/gba/elf.h rename to src/core/gba/gbaElf.h index efb61f24..95315499 100644 --- a/src/gba/elf.h +++ b/src/core/gba/gbaElf.h @@ -1,5 +1,5 @@ -#ifndef ELF_H -#define ELF_H +#ifndef VBAM_CORE_GBA_GBAELF_H_ +#define VBAM_CORE_GBA_GBAELF_H_ #include #include @@ -263,4 +263,4 @@ uint32_t elfDecodeLocation(Function*, ELFBlock*, LocationType*); uint32_t elfDecodeLocation(Function*, ELFBlock*, LocationType*, uint32_t); int elfFindLine(CompileUnit* unit, Function* func, uint32_t addr, const char**); -#endif // ELF_H +#endif // VBAM_CORE_GBA_GBAELF_H_ diff --git a/src/gba/gbafilter.cpp b/src/core/gba/gbaFilter.cpp similarity index 99% rename from src/gba/gbafilter.cpp rename to src/core/gba/gbaFilter.cpp index 9bfa544f..12b9f2d6 100644 --- a/src/gba/gbafilter.cpp +++ b/src/core/gba/gbaFilter.cpp @@ -1,6 +1,4 @@ -#include "gbafilter.h" - -#include +#include "core/gba/gbaFilter.h" extern int systemColorDepth; extern int systemRedShift; diff --git a/src/gba/gbafilter.h b/src/core/gba/gbaFilter.h similarity index 59% rename from src/gba/gbafilter.h rename to src/core/gba/gbaFilter.h index 246c6c95..0b8a7b89 100644 --- a/src/gba/gbafilter.h +++ b/src/core/gba/gbaFilter.h @@ -1,5 +1,5 @@ -#ifndef VBAM_GBA_GBAFILTER_H_ -#define VBAM_GBA_GBAFILTER_H_ +#ifndef VBAM_CORE_GBA_GBAFILTER_H_ +#define VBAM_CORE_GBA_GBAFILTER_H_ #include @@ -7,4 +7,4 @@ void gbafilter_pal(uint16_t* buf, int count); void gbafilter_pal32(uint32_t* buf, int count); void gbafilter_pad(uint8_t* buf, int count); -#endif // VBAM_GBA_GBAFILTER_H_ \ No newline at end of file +#endif // VBAM_CORE_GBA_GBAFILTER_H_ diff --git a/src/gba/Flash.cpp b/src/core/gba/gbaFlash.cpp similarity index 98% rename from src/gba/Flash.cpp rename to src/core/gba/gbaFlash.cpp index 48a5f7e5..2d533384 100644 --- a/src/gba/Flash.cpp +++ b/src/core/gba/gbaFlash.cpp @@ -1,12 +1,11 @@ -#include "Flash.h" +#include "core/gba/gbaFlash.h" -#include -#include -#include +#include +#include #include "core/base/file_util.h" -#include "GBA.h" -#include "Sram.h" +#include "core/gba/gba.h" +#include "core/gba/internal/gbaSram.h" #define FLASH_READ_ARRAY 0 #define FLASH_CMD_1 1 diff --git a/src/gba/Flash.h b/src/core/gba/gbaFlash.h similarity index 89% rename from src/gba/Flash.h rename to src/core/gba/gbaFlash.h index 8aa72770..02c3bcfd 100644 --- a/src/gba/Flash.h +++ b/src/core/gba/gbaFlash.h @@ -1,5 +1,5 @@ -#ifndef FLASH_H -#define FLASH_H +#ifndef VBAM_CORE_GBA_GBAFLASH_H_ +#define VBAM_CORE_GBA_GBAFLASH_H_ #include @@ -28,4 +28,4 @@ extern void flashInit(); extern int g_flashSize; -#endif // FLASH_H +#endif // VBAM_CORE_GBA_GBAFLASH_H_ diff --git a/src/gba/GBAGfx.cpp b/src/core/gba/gbaGfx.cpp similarity index 99% rename from src/gba/GBAGfx.cpp rename to src/core/gba/gbaGfx.cpp index e006d740..1411461f 100644 --- a/src/gba/GBAGfx.cpp +++ b/src/core/gba/gbaGfx.cpp @@ -1,4 +1,4 @@ -#include "GBAGfx.h" +#include "core/gba/gbaGfx.h" #if defined(TILED_RENDERING) #include diff --git a/src/gba/GBAGfx.h b/src/core/gba/gbaGfx.h similarity index 99% rename from src/gba/GBAGfx.h rename to src/core/gba/gbaGfx.h index 1fdc8143..a017a100 100644 --- a/src/gba/GBAGfx.h +++ b/src/core/gba/gbaGfx.h @@ -1,9 +1,11 @@ -#ifndef GFX_H -#define GFX_H +#ifndef VBAM_CORE_GBA_GBAGFX_H_ +#define VBAM_CORE_GBA_GBAGFX_H_ + +#include +#include #include "core/base/port.h" -#include "GBA.h" -#include "Globals.h" +#include "core/gba/gbaGlobals.h" //#define SPRITE_DEBUG @@ -1599,4 +1601,4 @@ static inline void gfxAlphaBlend(uint32_t* ta, uint32_t* tb, int ca, int cb) } } -#endif // GFX_H +#endif // VBAM_CORE_GBA_GBAGFX_H_ diff --git a/src/gba/Globals.cpp b/src/core/gba/gbaGlobals.cpp similarity index 95% rename from src/gba/Globals.cpp rename to src/core/gba/gbaGlobals.cpp index 5235f54c..ab3f9e63 100644 --- a/src/gba/Globals.cpp +++ b/src/core/gba/gbaGlobals.cpp @@ -1,6 +1,6 @@ -#include "GBA.h" +#include "core/gba/gbaGlobals.h" -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER int oldreg[18]; char oldbuffer[10]; #endif @@ -17,6 +17,9 @@ bool armIrqEnable = true; uint32_t armNextPC = 0x00000000; int armMode = 0x1f; uint32_t stop = 0x08000568; +// Joybus +bool gba_joybus_enabled = false; +bool gba_joybus_active = false; // this is an optional hack to change the backdrop/background color: // -1: disabled diff --git a/src/gba/Globals.h b/src/core/gba/gbaGlobals.h similarity index 95% rename from src/gba/Globals.h rename to src/core/gba/gbaGlobals.h index 24da7d17..823b0571 100644 --- a/src/gba/Globals.h +++ b/src/core/gba/gbaGlobals.h @@ -1,7 +1,7 @@ -#ifndef GLOBALS_H -#define GLOBALS_H +#ifndef VBAM_CORE_GBA_GBAGLOBALS_H_ +#define VBAM_CORE_GBA_GBAGLOBALS_H_ -#include "GBA.h" +#include "core/gba/gba.h" #define VERBOSE_SWI 1 #define VERBOSE_UNALIGNED_MEMORY 2 @@ -118,4 +118,4 @@ extern uint16_t IE; extern uint16_t IF; extern uint16_t IME; -#endif // GLOBALS_H +#endif // VBAM_CORE_GBA_GBAGLOBALS_H_ diff --git a/src/gba/GBAinline.h b/src/core/gba/gbaInline.h similarity index 96% rename from src/gba/GBAinline.h rename to src/core/gba/gbaInline.h index 7574973e..fd541db2 100644 --- a/src/gba/GBAinline.h +++ b/src/core/gba/gbaInline.h @@ -1,17 +1,21 @@ -#ifndef GBAINLINE_H -#define GBAINLINE_H +#ifndef VBAM_CORE_GBA_GBAINLINE_H_ +#define VBAM_CORE_GBA_GBAINLINE_H_ +#include #include -#include "core/base/system.h" #include "core/base/port.h" -#include "GBALink.h" -#include "GBAcpu.h" -#include "RTC.h" -#include "Sound.h" -#include "agbprint.h" -#include "remote.h" -#include "stdint.h" +#include "core/base/system.h" +#include "core/gba/gbaCpu.h" +#include "core/gba/gbaEeprom.h" +#include "core/gba/gbaFlash.h" +#include "core/gba/gbaPrint.h" +#include "core/gba/gbaRtc.h" +#include "core/gba/gbaSound.h" + +#if defined(VBAM_ENABLE_DEBUGGER) +#include "core/gba/gbaRemote.h" +#endif // defined(VBAM_ENABLE_DEBUGGER) extern const uint32_t objTilesAddress[3]; @@ -74,7 +78,7 @@ extern uint32_t myROM[]; static inline uint32_t CPUReadMemory(uint32_t address) { -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER memoryMap* m = &map[address >> 24]; if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) { if (debuggerBreakOnRead(address, 2)) { @@ -215,7 +219,7 @@ static inline uint32_t CPUReadMemory(uint32_t address) static inline uint32_t CPUReadHalfWord(uint32_t address) { -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER memoryMap* m = &map[address >> 24]; if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) { if (debuggerBreakOnRead(address, 1)) { @@ -362,7 +366,7 @@ static inline int16_t CPUReadHalfWordSigned(uint32_t address) static inline uint8_t CPUReadByte(uint32_t address) { -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER memoryMap* m = &map[address >> 24]; if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) { if (debuggerBreakOnRead(address, 0)) { @@ -467,7 +471,7 @@ static inline void CPUWriteMemory(uint32_t address, uint32_t value) } #endif -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER memoryMap* m = &map[address >> 24]; if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) { if (debuggerBreakOnWrite(address, value, 1)) { @@ -478,7 +482,7 @@ static inline void CPUWriteMemory(uint32_t address, uint32_t value) switch (address >> 24) { case 0x02: -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (*((uint32_t*)&freezeWorkRAM[address & 0x3FFFC])) cheatsWriteMemory(address & 0x203FFFC, value); else @@ -486,7 +490,7 @@ static inline void CPUWriteMemory(uint32_t address, uint32_t value) WRITE32LE(((uint32_t*)&g_workRAM[address & 0x3FFFC]), value); break; case 0x03: -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (*((uint32_t*)&freezeInternalRAM[address & 0x7ffc])) cheatsWriteMemory(address & 0x3007FFC, value); else @@ -501,7 +505,7 @@ static inline void CPUWriteMemory(uint32_t address, uint32_t value) goto unwritable; break; case 0x05: -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (*((uint32_t*)&freezePRAM[address & 0x3fc])) cheatsWriteMemory(address & 0x70003FC, value); else @@ -515,7 +519,7 @@ static inline void CPUWriteMemory(uint32_t address, uint32_t value) if ((address & 0x18000) == 0x18000) address &= 0x17fff; -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (*((uint32_t*)&freezeVRAM[address])) cheatsWriteMemory(address + 0x06000000, value); else @@ -524,7 +528,7 @@ static inline void CPUWriteMemory(uint32_t address, uint32_t value) WRITE32LE(((uint32_t*)&g_vram[address]), value); break; case 0x07: -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (*((uint32_t*)&freezeOAM[address & 0x3fc])) cheatsWriteMemory(address & 0x70003FC, value); else @@ -572,7 +576,7 @@ static inline void CPUWriteHalfWord(uint32_t address, uint16_t value) } #endif -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER memoryMap* m = &map[address >> 24]; if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) { if (debuggerBreakOnWrite(address, value, 1)) { @@ -583,7 +587,7 @@ static inline void CPUWriteHalfWord(uint32_t address, uint16_t value) switch (address >> 24) { case 2: -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (*((uint16_t*)&freezeWorkRAM[address & 0x3FFFE])) cheatsWriteHalfWord(address & 0x203FFFE, value); else @@ -591,7 +595,7 @@ static inline void CPUWriteHalfWord(uint32_t address, uint16_t value) WRITE16LE(((uint16_t*)&g_workRAM[address & 0x3FFFE]), value); break; case 3: -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (*((uint16_t*)&freezeInternalRAM[address & 0x7ffe])) cheatsWriteHalfWord(address & 0x3007ffe, value); else @@ -605,7 +609,7 @@ static inline void CPUWriteHalfWord(uint32_t address, uint16_t value) goto unwritable; break; case 5: -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (*((uint16_t*)&freezePRAM[address & 0x03fe])) cheatsWriteHalfWord(address & 0x70003fe, value); else @@ -618,7 +622,7 @@ static inline void CPUWriteHalfWord(uint32_t address, uint16_t value) return; if ((address & 0x18000) == 0x18000) address &= 0x17fff; -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (*((uint16_t*)&freezeVRAM[address])) cheatsWriteHalfWord(address + 0x06000000, value); else @@ -626,7 +630,7 @@ static inline void CPUWriteHalfWord(uint32_t address, uint16_t value) WRITE16LE(((uint16_t*)&g_vram[address]), value); break; case 7: -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (*((uint16_t*)&freezeOAM[address & 0x03fe])) cheatsWriteHalfWord(address & 0x70003fe, value); else @@ -670,7 +674,7 @@ static inline void CPUWriteHalfWord(uint32_t address, uint16_t value) static inline void CPUWriteByte(uint32_t address, uint8_t b) { -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER memoryMap* m = &map[address >> 24]; if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) { if (debuggerBreakOnWrite(address, b, 1)) { @@ -681,7 +685,7 @@ static inline void CPUWriteByte(uint32_t address, uint8_t b) switch (address >> 24) { case 2: -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (freezeWorkRAM[address & 0x3FFFF]) cheatsWriteByte(address & 0x203FFFF, b); else @@ -689,7 +693,7 @@ static inline void CPUWriteByte(uint32_t address, uint8_t b) g_workRAM[address & 0x3FFFF] = b; break; case 3: -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (freezeInternalRAM[address & 0x7fff]) cheatsWriteByte(address & 0x3007fff, b); else @@ -776,7 +780,7 @@ static inline void CPUWriteByte(uint32_t address, uint8_t b) // no need to switch // byte writes to OBJ VRAM are ignored if ((address) < objTilesAddress[((DISPCNT & 7) + 1) >> 2]) { -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (freezeVRAM[address]) cheatsWriteByte(address + 0x06000000, b); else @@ -819,4 +823,4 @@ static inline void CPUWriteByte(uint32_t address, uint8_t b) } } -#endif // GBAINLINE_H +#endif // VBAM_CORE_GBA_GBAINLINE_H_ diff --git a/src/gba/GBALink.cpp b/src/core/gba/gbaLink.cpp similarity index 99% rename from src/gba/GBALink.cpp rename to src/core/gba/gbaLink.cpp index 7cf34a93..c15f9823 100644 --- a/src/gba/GBALink.cpp +++ b/src/core/gba/gbaLink.cpp @@ -1,16 +1,46 @@ +#include "core/gba/gbaLink.h" + // This file was written by denopqrihg // with major changes by tjm + +#if defined(NO_LINK) +#error "This file should not be compiled with NO_LINK." +#endif // defined(NO_LINK) + +#if defined(_WIN32) + +#include + +#else // !defined(_WIN32) + +#include +#include +#include +#include +#include + +#endif // defined(_WIN32) + #include +#include #include #include -// malloc.h does not seem to exist on Mac OS 10.7 and is an error on FreeBSD -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) -#include +#include + +#ifdef ENABLE_NLS +#include +#define _(x) gettext(x) #else -#include +#define _(x) x #endif +#include "core/base/message.h" +#include "core/base/port.h" +#include "core/gba/gba.h" +#include "core/gba/gbaCpu.h" +#include "core/gba/internal/gbaSockClient.h" + #ifdef _MSC_VER #define snprintf _snprintf #endif @@ -33,8 +63,6 @@ const char* MakeInstanceFilename(const char* Input) return result; } -#ifndef NO_LINK - enum { SENDING = 0, RECEIVING = 1 @@ -50,10 +78,6 @@ enum siocnt_lo_32bit { SIO_IRQ_ENABLE = 0x4000 }; -// Joybus -bool gba_joybus_enabled = false; -bool gba_joybus_active = false; - // If disabled, gba core won't call any (non-joybus) link functions bool gba_link_enabled = false; @@ -67,29 +91,7 @@ uint16_t IP_LINK_PORT = 5738; std::string IP_LINK_BIND_ADDRESS = "*"; -#include "core/base/message.h" -#include "core/base/port.h" -#include "GBA.h" -#include "GBALink.h" -#include "GBASockClient.h" - -#include - -#ifdef ENABLE_NLS -#include -#define _(x) gettext(x) -#else -#define _(x) x -#endif - -#if (defined __WIN32__ || defined _WIN32) -#include -#else -#include -#include -#include -#include -#include +#if !defined(_WIN32) #define ReleaseSemaphore(sem, nrel, orel) \ do { \ @@ -97,7 +99,9 @@ std::string IP_LINK_BIND_ADDRESS = "*"; sem_post(sem); \ } while (0) #define WAIT_TIMEOUT -1 + #ifdef HAVE_SEM_TIMEDWAIT + int WaitForSingleObject(sem_t* s, int t) { struct timespec ts; @@ -334,7 +338,7 @@ bool EmuReseted = true; bool LinkIsWaiting = false; bool LinkFirstTime = true; -#if (defined __WIN32__ || defined _WIN32) +#if (defined _WIN32) static ConnectionState InitIPC(); static void StartCableIPC(uint16_t siocnt); @@ -4136,7 +4140,3 @@ static void CloseIPC() } #endif - -#else -bool gba_joybus_active = false; -#endif diff --git a/src/gba/GBALink.h b/src/core/gba/gbaLink.h similarity index 76% rename from src/gba/GBALink.h rename to src/core/gba/gbaLink.h index bd1d9ef5..ff4b4da1 100644 --- a/src/gba/GBALink.h +++ b/src/core/gba/gbaLink.h @@ -1,9 +1,13 @@ -#ifndef GBA_GBALINK_H -#define GBA_GBALINK_H +#ifndef VBAM_CORE_GBA_GBALINK_H_ +#define VBAM_CORE_GBA_GBALINK_H_ #include #include +#if defined(NO_LINK) +#error "This file should not be included with NO_LINK." +#endif // defined(NO_LINK) + extern uint16_t IP_LINK_PORT; extern std::string IP_LINK_BIND_ADDRESS; @@ -143,28 +147,6 @@ extern void CleanLocalLink(); extern const char* MakeInstanceFilename(const char* Input); -// register definitions -#define COMM_SIODATA32_L 0x120 // Lower 16bit on Normal mode -#define COMM_SIODATA32_H 0x122 // Higher 16bit on Normal mode -#define COMM_SIOCNT 0x128 -#define COMM_SIODATA8 0x12a // 8bit on Normal/UART mode, (up to 4x8bit with FIFO) -#define COMM_SIOMLT_SEND 0x12a // SIOMLT_SEND (16bit R/W) on MultiPlayer mode (local outgoing) -#define COMM_SIOMULTI0 0x120 // SIOMULTI0 (16bit) on MultiPlayer mode (Parent/Master) -#define COMM_SIOMULTI1 0x122 // SIOMULTI1 (16bit) on MultiPlayer mode (Child1/Slave1) -#define COMM_SIOMULTI2 0x124 // SIOMULTI2 (16bit) on MultiPlayer mode (Child2/Slave2) -#define COMM_SIOMULTI3 0x126 // SIOMULTI3 (16bit) on MultiPlayer mode (Child3/Slave3) -#define COMM_RCNT 0x134 // SIO Mode (4bit data) on GeneralPurpose mode -#define COMM_IR 0x136 // Infrared Register (16bit) 1bit data at a time(LED On/Off)? -#define COMM_JOYCNT 0x140 -#define COMM_JOY_RECV_L 0x150 // Send/Receive 8bit Lower first then 8bit Higher -#define COMM_JOY_RECV_H 0x152 -#define COMM_JOY_TRANS_L 0x154 // Send/Receive 8bit Lower first then 8bit Higher -#define COMM_JOY_TRANS_H 0x156 -#define COMM_JOYSTAT 0x158 // Send/Receive 8bit lower only - -#define JOYSTAT_RECV 2 -#define JOYSTAT_SEND 8 - #define JOYCNT_RESET 1 #define JOYCNT_RECV_COMPLETE 2 #define JOYCNT_SEND_COMPLETE 4 @@ -211,4 +193,4 @@ extern uint16_t gbLinkUpdateIPC(uint8_t b, int gbSerialOn); extern void BootLink(int m_type, const char* host, int timeout, bool m_hacks, int m_numplayers); -#endif /* GBA_GBALINK_H */ +#endif // VBAM_CORE_GBA_GBALINK_H_ diff --git a/src/gba/Mode0.cpp b/src/core/gba/gbaMode0.cpp similarity index 99% rename from src/gba/Mode0.cpp rename to src/core/gba/gbaMode0.cpp index 6be30b85..57c47938 100644 --- a/src/gba/Mode0.cpp +++ b/src/core/gba/gbaMode0.cpp @@ -1,6 +1,6 @@ -#include "GBA.h" -#include "GBAGfx.h" -#include "Globals.h" +#include "core/gba/gbaGfx.h" + +#include "core/gba/gbaGlobals.h" void mode0RenderLine() { diff --git a/src/gba/Mode1.cpp b/src/core/gba/gbaMode1.cpp similarity index 99% rename from src/gba/Mode1.cpp rename to src/core/gba/gbaMode1.cpp index 6abd412c..d60e8c7c 100644 --- a/src/gba/Mode1.cpp +++ b/src/core/gba/gbaMode1.cpp @@ -1,6 +1,6 @@ -#include "GBA.h" -#include "GBAGfx.h" -#include "Globals.h" +#include "core/gba/gbaGfx.h" + +#include "core/gba/gbaGlobals.h" void mode1RenderLine() { diff --git a/src/gba/Mode2.cpp b/src/core/gba/gbaMode2.cpp similarity index 99% rename from src/gba/Mode2.cpp rename to src/core/gba/gbaMode2.cpp index 7431b3c3..f55e3b87 100644 --- a/src/gba/Mode2.cpp +++ b/src/core/gba/gbaMode2.cpp @@ -1,6 +1,5 @@ -#include "GBA.h" -#include "GBAGfx.h" -#include "Globals.h" +#include "core/gba/gbaGfx.h" +#include "core/gba/gbaGlobals.h" void mode2RenderLine() { diff --git a/src/gba/Mode3.cpp b/src/core/gba/gbaMode3.cpp similarity index 99% rename from src/gba/Mode3.cpp rename to src/core/gba/gbaMode3.cpp index aca2db67..a78cb64a 100644 --- a/src/gba/Mode3.cpp +++ b/src/core/gba/gbaMode3.cpp @@ -1,6 +1,6 @@ -#include "GBA.h" -#include "GBAGfx.h" -#include "Globals.h" +#include "core/gba/gbaGfx.h" + +#include "core/gba/gbaGlobals.h" void mode3RenderLine() { diff --git a/src/gba/Mode4.cpp b/src/core/gba/gbaMode4.cpp similarity index 99% rename from src/gba/Mode4.cpp rename to src/core/gba/gbaMode4.cpp index e4529c08..8c04d4ca 100644 --- a/src/gba/Mode4.cpp +++ b/src/core/gba/gbaMode4.cpp @@ -1,6 +1,6 @@ -#include "GBA.h" -#include "GBAGfx.h" -#include "Globals.h" +#include "core/gba/gbaGfx.h" + +#include "core/gba/gbaGlobals.h" void mode4RenderLine() { diff --git a/src/gba/Mode5.cpp b/src/core/gba/gbaMode5.cpp similarity index 99% rename from src/gba/Mode5.cpp rename to src/core/gba/gbaMode5.cpp index 6d46b9ed..49c2f22a 100644 --- a/src/gba/Mode5.cpp +++ b/src/core/gba/gbaMode5.cpp @@ -1,6 +1,6 @@ -#include "GBA.h" -#include "GBAGfx.h" -#include "Globals.h" +#include "core/gba/gbaGfx.h" + +#include "core/gba/gbaGlobals.h" void mode5RenderLine() { diff --git a/src/gba/agbprint.cpp b/src/core/gba/gbaPrint.cpp similarity index 94% rename from src/gba/agbprint.cpp rename to src/core/gba/gbaPrint.cpp index ac480b3f..03ddb185 100644 --- a/src/gba/agbprint.cpp +++ b/src/core/gba/gbaPrint.cpp @@ -1,8 +1,7 @@ -#include "agbprint.h" +#include "core/gba/gbaPrint.h" #include "core/base/port.h" -#include "GBA.h" -#include "Globals.h" +#include "core/gba/gbaGlobals.h" #define debuggerWriteHalfWord(addr, value) \ WRITE16LE((uint16_t*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask], (value)) @@ -54,7 +53,7 @@ void agbPrintFlush() uint32_t address = (debuggerReadHalfWord(0x9fe20fa) << 16); if (address != 0xfd0000 && address != 0x1fd0000) { -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER dbgOutput("Did you forget to call AGBPrintInit?\n", 0); #endif // get rid of the text otherwise we will continue to be called @@ -66,7 +65,7 @@ void agbPrintFlush() while (get != put) { char c = data[get++]; -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER char s[2]; s[0] = c; s[1] = 0; diff --git a/src/gba/agbprint.h b/src/core/gba/gbaPrint.h similarity index 63% rename from src/gba/agbprint.h rename to src/core/gba/gbaPrint.h index 20e790ab..190063b2 100644 --- a/src/gba/agbprint.h +++ b/src/core/gba/gbaPrint.h @@ -1,5 +1,5 @@ -#ifndef AGBPRINT_H -#define AGBPRINT_H +#ifndef VBAM_CORE_GBA_GBAPRINT_H_ +#define VBAM_CORE_GBA_GBAPRINT_H_ #include @@ -9,4 +9,4 @@ void agbPrintReset(); bool agbPrintWrite(uint32_t address, uint16_t value); void agbPrintFlush(); -#endif // AGBPRINT_H +#endif // VBAM_CORE_GBA_GBAPRINT_H_ diff --git a/src/gba/remote.cpp b/src/core/gba/gbaRemote.cpp similarity index 99% rename from src/gba/remote.cpp rename to src/core/gba/gbaRemote.cpp index 2ffb3ae8..70524460 100644 --- a/src/gba/remote.cpp +++ b/src/core/gba/gbaRemote.cpp @@ -1,26 +1,11 @@ -#ifndef __LIBRETRO__ -#include -#include -#include +#include "core/gba/gbaRemote.h" -#include -#include -#include +#if !defined(VBAM_ENABLE_DEBUGGER) +#error "This file should only be compiled when VBAM_ENABLE_DEBUGGER is defined." +#endif // !defined(VBAM_ENABLE_DEBUGGER) + +#if defined(_WIN32) -#ifndef _WIN32 -#include -#include -#include -#ifdef HAVE_NETINET_IN_H -#include -#endif // HAVE_NETINET_IN_H -#ifdef HAVE_ARPA_INET_H -#include -#else // ! HAVE_ARPA_INET_H -#define socklen_t int -#endif // ! HAVE_ARPA_INET_H -#define SOCKET int -#else // _WIN32 #include #include #define socklen_t int @@ -28,16 +13,41 @@ #define read _read #define write _write #define strdup _strdup -#endif // _WIN32 -#include "BreakpointStructures.h" -#include "GBA.h" -#include "elf.h" -#include "remote.h" +#else // !defined(_WIN32) + +#include +#include +#include + +#ifdef HAVE_NETINET_IN_H +#include +#endif // HAVE_NETINET_IN_H + +#ifdef HAVE_ARPA_INET_H +#include +#else // ! HAVE_ARPA_INET_H +#define socklen_t int +#endif // ! HAVE_ARPA_INET_H + +#define SOCKET int + +#endif // defined(_WIN32) + +#include +#include +#include #include +#include #include +#include + +#include "core/gba/gba.h" +#include "core/gba/gbaElf.h" +#include "core/gba/gbaGlobals.h" +#include "core/gba/gbaRemote.h" +#include "core/gba/internal/gbaBreakpoint.h" -extern bool debugger; extern int emulating; extern void CPUUpdateCPSR(); @@ -3954,7 +3964,7 @@ void remoteWriteWatch(char* p, bool active) // return; //} -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER for (int i = 0; i < count; i++) { if ((address >> 24) == 2) freezeWorkRAM[address & 0x3ffff] = active; @@ -4296,5 +4306,3 @@ void monprintf(std::string line) remotePutPacket(dbgReply); } } - -#endif diff --git a/src/gba/remote.h b/src/core/gba/gbaRemote.h similarity index 89% rename from src/gba/remote.h rename to src/core/gba/gbaRemote.h index d71ed02f..486922a8 100644 --- a/src/gba/remote.h +++ b/src/core/gba/gbaRemote.h @@ -1,7 +1,11 @@ -#ifndef REMOTE_H -#define REMOTE_H +#ifndef VBAM_CORE_GBA_GBAREMOTE_H_ +#define VBAM_CORE_GBA_GBAREMOTE_H_ -#include "GBA.h" +#if !defined(VBAM_ENABLE_DEBUGGER) +#error "This file should only be included when VBAM_ENABLE_DEBUGGER is defined." +#endif // !defined(VBAM_ENABLE_DEBUGGER) + +#include #define BitSet(array, bit) ((uint8_t*)(array))[(bit) >> 3] |= (1 << ((bit)&7)) @@ -27,8 +31,6 @@ #define BreakCheck(array, addr, flag) \ ((uint8_t*)(array))[(addr) >> 1] & ((addr & 1) ? (flag << 4) : (flag & 0xf)) -extern bool debugger; - extern bool dexp_eval(char*, uint32_t*); extern void dexp_setVar(char*, uint32_t); extern void dexp_listVars(); @@ -76,4 +78,4 @@ void remoteOutput(const char* s, uint32_t addr); void remoteSetProtocol(int p); void remoteSetPort(int port); -#endif // REMOTE_H +#endif // VBAM_CORE_GBA_GBAREMOTE_H_ diff --git a/src/gba/RTC.cpp b/src/core/gba/gbaRtc.cpp similarity index 99% rename from src/gba/RTC.cpp rename to src/core/gba/gbaRtc.cpp index 49de350f..56bd17d5 100644 --- a/src/gba/RTC.cpp +++ b/src/core/gba/gbaRtc.cpp @@ -1,4 +1,4 @@ -#include "RTC.h" +#include "core/gba/gbaRtc.h" #include #include @@ -6,9 +6,8 @@ #include "core/base/file_util.h" #include "core/base/message.h" #include "core/base/port.h" -#include "GBA.h" -#include "GBAinline.h" -#include "Globals.h" +#include "core/gba/gba.h" +#include "core/gba/gbaInline.h" enum RTCSTATE { diff --git a/src/gba/RTC.h b/src/core/gba/gbaRtc.h similarity index 84% rename from src/gba/RTC.h rename to src/core/gba/gbaRtc.h index bffff538..ee9ab7fa 100644 --- a/src/gba/RTC.h +++ b/src/core/gba/gbaRtc.h @@ -1,5 +1,5 @@ -#ifndef RTC_H -#define RTC_H +#ifndef VBAM_CORE_GBA_GBARTC_H_ +#define VBAM_CORE_GBA_GBARTC_H_ #include @@ -23,4 +23,4 @@ void rtcReadGame(gzFile gzFile); void rtcSaveGame(gzFile gzFile); #endif // defined(__LIBRETRO__) -#endif // RTC_H +#endif // VBAM_CORE_GBA_GBARTC_H_ diff --git a/src/gba/Sound.cpp b/src/core/gba/gbaSound.cpp similarity index 99% rename from src/gba/Sound.cpp rename to src/core/gba/gbaSound.cpp index e9aceeed..e9f5cc48 100644 --- a/src/gba/Sound.cpp +++ b/src/core/gba/gbaSound.cpp @@ -1,16 +1,16 @@ -#include "Sound.h" +#include "core/gba/gbaSound.h" #include #include +#include "core/apu/Gb_Apu.h" +#include "core/apu/Multi_Buffer.h" #include "core/base/file_util.h" #include "core/base/port.h" #include "core/base/sound_driver.h" -#include "GBA.h" -#include "Globals.h" +#include "core/gba/gba.h" +#include "core/gba/gbaGlobals.h" -#include "../apu/Gb_Apu.h" -#include "../apu/Multi_Buffer.h" #define NR10 0x60 #define NR11 0x62 diff --git a/src/gba/Sound.h b/src/core/gba/gbaSound.h similarity index 95% rename from src/gba/Sound.h rename to src/core/gba/gbaSound.h index f37fb9bf..876a7fa8 100644 --- a/src/gba/Sound.h +++ b/src/core/gba/gbaSound.h @@ -1,5 +1,5 @@ -#ifndef SOUND_H -#define SOUND_H +#ifndef VBAM_CORE_GBA_GBASOUND_H_ +#define VBAM_CORE_GBA_GBASOUND_H_ #include @@ -92,4 +92,4 @@ class Multi_Buffer; void flush_samples(Multi_Buffer* buffer); -#endif // SOUND_H +#endif // VBAM_CORE_GBA_GBASOUND_H_ diff --git a/src/gba/bios.cpp b/src/core/gba/internal/gbaBios.cpp similarity index 99% rename from src/gba/bios.cpp rename to src/core/gba/internal/gbaBios.cpp index 173ddccb..aa238381 100644 --- a/src/gba/bios.cpp +++ b/src/core/gba/internal/gbaBios.cpp @@ -1,11 +1,12 @@ -#include -#include -#include +#include "core/gba/internal/gbaBios.h" -#include "GBA.h" -#include "GBAinline.h" -#include "Globals.h" -#include "bios.h" +#include +#include +#include + +#include "core/gba/gba.h" +#include "core/gba/gbaGlobals.h" +#include "core/gba/gbaInline.h" int16_t sineTable[256] = { (int16_t)0x0000u, (int16_t)0x0192u, (int16_t)0x0323u, (int16_t)0x04B5u, (int16_t)0x0645u, (int16_t)0x07D5u, (int16_t)0x0964u, (int16_t)0x0AF1u, diff --git a/src/gba/bios.h b/src/core/gba/internal/gbaBios.h similarity index 87% rename from src/gba/bios.h rename to src/core/gba/internal/gbaBios.h index 4865d45d..f22cd777 100644 --- a/src/gba/bios.h +++ b/src/core/gba/internal/gbaBios.h @@ -1,5 +1,7 @@ -#ifndef BIOS_H -#define BIOS_H +#ifndef VBAM_CORE_GBA_INTERNAL_GBABIOS_H_ +#define VBAM_CORE_GBA_INTERNAL_GBABIOS_H_ + +#include extern void BIOS_ArcTan(); extern void BIOS_ArcTan2(); @@ -33,4 +35,4 @@ extern void BIOS_SndDriverVSyncOff(); extern void BIOS_SndDriverVSyncOn(); extern void BIOS_SndChannelClear(); -#endif // BIOS_H +#endif // VBAM_CORE_GBA_INTERNAL_GBABIOS_H_ diff --git a/src/gba/BreakpointStructures.cpp b/src/core/gba/internal/gbaBreakpoint.cpp similarity index 98% rename from src/gba/BreakpointStructures.cpp rename to src/core/gba/internal/gbaBreakpoint.cpp index 257f57db..0dac4ac5 100644 --- a/src/gba/BreakpointStructures.cpp +++ b/src/core/gba/internal/gbaBreakpoint.cpp @@ -94,14 +94,19 @@ sh, shw, shalfword, int16_t short --> signed halfword w, word, uint2_t --> word sw, sword, int32_t, int --> signed word */ +#include "core/gba/internal/gbaBreakpoint.h" -#include -#include -#include -#include +#if !defined(VBAM_ENABLE_DEBUGGER) +#error "This file should only be compiled when VBAM_ENABLE_DEBUGGER is defined." +#endif // !defined(VBAM_ENABLE_DEBUGGER) -#include "BreakpointStructures.h" -#include "remote.h" +#include +#include +#include +#include + +#include "core/gba/gba.h" +#include "core/gba/gbaRemote.h" #if (defined __WIN32__ || defined _WIN32) #define strdup _strdup diff --git a/src/gba/BreakpointStructures.h b/src/core/gba/internal/gbaBreakpoint.h similarity index 89% rename from src/gba/BreakpointStructures.h rename to src/core/gba/internal/gbaBreakpoint.h index e55f1ded..cb468d49 100644 --- a/src/gba/BreakpointStructures.h +++ b/src/core/gba/internal/gbaBreakpoint.h @@ -1,5 +1,9 @@ -#ifndef VBA_BKS_H -#define VBA_BKS_H +#ifndef VBAM_CORE_GBA_INTERNAL_GBABREAKPOINT_H_ +#define VBAM_CORE_GBA_INTERNAL_GBABREAKPOINT_H_ + +#if !defined(VBAM_ENABLE_DEBUGGER) +#error "This file should only be included when VBAM_ENABLE_DEBUGGER is defined." +#endif // !defined(VBAM_ENABLE_DEBUGGER) #include @@ -63,4 +67,5 @@ bool doBreak(struct ConditionalBreak* toTest); // uint8_t printConditionalsFromAddress(uint32_t address); // void printAllFlagConditionals(uint8_t flag, bool orMode); // void printAllFlagConditionalsWithAddress(uint32_t address, uint8_t flag, bool orMode); -#endif + +#endif // VBAM_CORE_GBA_INTERNAL_GBABREAKPOINT_H_ diff --git a/src/gba/ereader.cpp b/src/core/gba/internal/gbaEreader.cpp similarity index 99% rename from src/gba/ereader.cpp rename to src/core/gba/internal/gbaEreader.cpp index f8dccd91..f0124b16 100644 --- a/src/gba/ereader.cpp +++ b/src/core/gba/internal/gbaEreader.cpp @@ -1,13 +1,13 @@ -#include -#include -#include -#include +#include "core/gba/internal/gbaEreader.h" + +#include +#include +#include #include "core/base/file_util.h" -#include "GBA.h" -#include "GBAinline.h" -#include "Globals.h" -#include "ereader.h" +#include "core/gba/gba.h" +#include "core/gba/gbaInline.h" +#include "core/gba/gbaGlobals.h" char US_Ereader[19] = "CARDE READERPSAE01"; char JAP_Ereader[19] = "CARDE READERPEAJ01"; diff --git a/src/gba/ereader.h b/src/core/gba/internal/gbaEreader.h similarity index 65% rename from src/gba/ereader.h rename to src/core/gba/internal/gbaEreader.h index 2fa3b8e0..061dce3d 100644 --- a/src/gba/ereader.h +++ b/src/core/gba/internal/gbaEreader.h @@ -1,9 +1,17 @@ +#ifndef VBAM_CORE_GBA_INTERNAL_GBAEREADER_H_ +#define VBAM_CORE_GBA_INTERNAL_GBAEREADER_H_ + +#include + extern unsigned char* DotCodeData; extern char filebuffer[]; + int OpenDotCodeFile(void); int CheckEReaderRegion(void); int LoadDotCodeData(int size, uint32_t* DCdata, unsigned long MEM1, unsigned long MEM2); void EReaderWriteMemory(uint32_t address, uint32_t value); void BIOS_EReader_ScanCard(int swi_num); + +#endif // VBAM_CORE_GBA_INTERNAL_GBAEREADER_H_ diff --git a/src/gba/GBASockClient.cpp b/src/core/gba/internal/gbaSockClient.cpp similarity index 93% rename from src/gba/GBASockClient.cpp rename to src/core/gba/internal/gbaSockClient.cpp index 56163213..a0320811 100644 --- a/src/gba/GBASockClient.cpp +++ b/src/core/gba/internal/gbaSockClient.cpp @@ -1,6 +1,8 @@ -#ifndef NO_LINK +#include "core/gba/internal/gbaSockClient.h" -#include "GBASockClient.h" +#if defined(NO_LINK) +#error "This file should not be compiled with NO_LINK." +#endif // defined(NO_LINK) // Currently only for Joybus communications @@ -95,4 +97,3 @@ bool GBASockClient::IsDisconnected() { return is_disconnected; } -#endif // NO_LINK diff --git a/src/gba/GBASockClient.h b/src/core/gba/internal/gbaSockClient.h similarity index 68% rename from src/gba/GBASockClient.h rename to src/core/gba/internal/gbaSockClient.h index f3aae70a..5fb063bb 100644 --- a/src/gba/GBASockClient.h +++ b/src/core/gba/internal/gbaSockClient.h @@ -1,4 +1,9 @@ -#pragma once +#ifndef VBAM_CORE_GBA_INTERNAL_GBASOCKCLIENT_H_ +#define VBAM_CORE_GBA_INTERNAL_GBASOCKCLIENT_H_ + +#if defined(NO_LINK) +#error "This file should not be included with NO_LINK." +#endif // defined(NO_LINK) #include @@ -26,3 +31,5 @@ private: int32_t clock_sync; bool is_disconnected; }; + +#endif // VBAM_CORE_GBA_INTERNAL_GBASOCKCLIENT_H_ diff --git a/src/gba/Sram.cpp b/src/core/gba/internal/gbaSram.cpp similarity index 80% rename from src/gba/Sram.cpp rename to src/core/gba/internal/gbaSram.cpp index 39aabaff..47a21f7a 100644 --- a/src/gba/Sram.cpp +++ b/src/core/gba/internal/gbaSram.cpp @@ -1,7 +1,7 @@ -#include "Sram.h" -#include "Flash.h" -#include "GBA.h" -#include "Globals.h" +#include "core/gba/internal/gbaSram.h" + +#include "core/gba/gbaFlash.h" +#include "core/gba/gba.h" uint8_t sramRead(uint32_t address) { diff --git a/src/gba/Sram.h b/src/core/gba/internal/gbaSram.h similarity index 55% rename from src/gba/Sram.h rename to src/core/gba/internal/gbaSram.h index 52191b17..e98697ef 100644 --- a/src/gba/Sram.h +++ b/src/core/gba/internal/gbaSram.h @@ -1,5 +1,5 @@ -#ifndef SRAM_H -#define SRAM_H +#ifndef VBAM_CORE_GBA_INTERNAL_GBASRAM_H_ +#define VBAM_CORE_GBA_INTERNAL_GBASRAM_H_ #include @@ -7,4 +7,4 @@ uint8_t sramRead(uint32_t address); void sramWrite(uint32_t address, uint8_t byte); void sramDelayedWrite(uint32_t address, uint8_t byte); -#endif // SRAM_H +#endif // VBAM_CORE_GBA_INTERNAL_GBASRAM_H_ diff --git a/src/gb/gbPrinter.h b/src/gb/gbPrinter.h deleted file mode 100644 index 8a8ada86..00000000 --- a/src/gb/gbPrinter.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef GBPRINTER_H -#define GBPRINTER_H - -#include - -uint8_t gbPrinterSend(uint8_t b); - -#endif // GBPRINTER_H diff --git a/src/gba/debugger-expr-lex.c b/src/gba/debugger-expr-lex.c deleted file mode 100644 index 6df02371..00000000 --- a/src/gba/debugger-expr-lex.c +++ /dev/null @@ -1 +0,0 @@ -#include "debugger-expr-lex.cpp" \ No newline at end of file diff --git a/src/libretro/Makefile.common b/src/libretro/Makefile.common index 5b0612ec..73437df1 100644 --- a/src/libretro/Makefile.common +++ b/src/libretro/Makefile.common @@ -30,47 +30,47 @@ SOURCES_CXX += \ $(CORE_DIR)/core/base/file_util_libretro.cpp SOURCES_CXX += \ - $(CORE_DIR)/apu/Gb_Oscs.cpp \ - $(CORE_DIR)/apu/Gb_Apu_State.cpp \ - $(CORE_DIR)/apu/Blip_Buffer.cpp \ - $(CORE_DIR)/apu/Multi_Buffer.cpp \ - $(CORE_DIR)/apu/Effects_Buffer.cpp \ - $(CORE_DIR)/apu/Gb_Apu.cpp + $(CORE_DIR)/core/apu/Gb_Oscs.cpp \ + $(CORE_DIR)/core/apu/Gb_Apu_State.cpp \ + $(CORE_DIR)/core/apu/Blip_Buffer.cpp \ + $(CORE_DIR)/core/apu/Multi_Buffer.cpp \ + $(CORE_DIR)/core/apu/Effects_Buffer.cpp \ + $(CORE_DIR)/core/apu/Gb_Apu.cpp SOURCES_CXX += \ - $(CORE_DIR)/gba/GBA-thumb.cpp \ - $(CORE_DIR)/gba/Sound.cpp \ - $(CORE_DIR)/gba/Mode1.cpp \ - $(CORE_DIR)/gba/CheatSearch.cpp \ - $(CORE_DIR)/gba/Globals.cpp \ - $(CORE_DIR)/gba/agbprint.cpp \ - $(CORE_DIR)/gba/Mode4.cpp \ - $(CORE_DIR)/gba/Mode3.cpp \ - $(CORE_DIR)/gba/Mode5.cpp \ - $(CORE_DIR)/gba/Mode2.cpp \ - $(CORE_DIR)/gba/ereader.cpp \ - $(CORE_DIR)/gba/GBA-arm.cpp \ - $(CORE_DIR)/gba/bios.cpp \ - $(CORE_DIR)/gba/Mode0.cpp \ - $(CORE_DIR)/gba/Flash.cpp \ - $(CORE_DIR)/gba/GBAGfx.cpp \ - $(CORE_DIR)/gba/Cheats.cpp \ - $(CORE_DIR)/gba/GBA.cpp \ - $(CORE_DIR)/gba/EEprom.cpp \ - $(CORE_DIR)/gba/RTC.cpp \ - $(CORE_DIR)/gba/Sram.cpp + $(CORE_DIR)/core/gba/gba.cpp \ + $(CORE_DIR)/core/gba/gbaCheats.cpp \ + $(CORE_DIR)/core/gba/gbaCheatSearch.cpp \ + $(CORE_DIR)/core/gba/gbaCpuArm.cpp \ + $(CORE_DIR)/core/gba/gbaCpuThumb.cpp \ + $(CORE_DIR)/core/gba/gbaEeprom.cpp \ + $(CORE_DIR)/core/gba/gbaFlash.cpp \ + $(CORE_DIR)/core/gba/gbaGfx.cpp \ + $(CORE_DIR)/core/gba/gbaGlobals.cpp \ + $(CORE_DIR)/core/gba/gbaMode0.cpp \ + $(CORE_DIR)/core/gba/gbaMode1.cpp \ + $(CORE_DIR)/core/gba/gbaMode2.cpp \ + $(CORE_DIR)/core/gba/gbaMode3.cpp \ + $(CORE_DIR)/core/gba/gbaMode4.cpp \ + $(CORE_DIR)/core/gba/gbaMode5.cpp \ + $(CORE_DIR)/core/gba/gbaPrint.cpp \ + $(CORE_DIR)/core/gba/gbaRtc.cpp \ + $(CORE_DIR)/core/gba/gbaSound.cpp \ + $(CORE_DIR)/core/gba/internal/gbaBios.cpp \ + $(CORE_DIR)/core/gba/internal/gbaEreader.cpp \ + $(CORE_DIR)/core/gba/internal/gbaSram.cpp \ SOURCES_CXX += \ - $(CORE_DIR)/gb/gbCartData.cpp \ - $(CORE_DIR)/gb/gbCheats.cpp \ - $(CORE_DIR)/gb/GB.cpp \ - $(CORE_DIR)/gb/gbGfx.cpp \ - $(CORE_DIR)/gb/gbGlobals.cpp \ - $(CORE_DIR)/gb/gbMemory.cpp \ - $(CORE_DIR)/gb/gbSGB.cpp \ - $(CORE_DIR)/gb/gbSound.cpp + $(CORE_DIR)/core/gb/gb.cpp \ + $(CORE_DIR)/core/gb/gbCartData.cpp \ + $(CORE_DIR)/core/gb/gbCheats.cpp \ + $(CORE_DIR)/core/gb/gbGfx.cpp \ + $(CORE_DIR)/core/gb/gbGlobals.cpp \ + $(CORE_DIR)/core/gb/gbMemory.cpp \ + $(CORE_DIR)/core/gb/gbSGB.cpp \ + $(CORE_DIR)/core/gb/gbSound.cpp # Filters SOURCES_CXX += \ $(CORE_DIR)/filters/interframe.cpp \ - $(CORE_DIR)/gba/gbafilter.cpp + $(CORE_DIR)/core/gba/gbaFilter.cpp diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 535b063b..cecbfd37 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -1,38 +1,30 @@ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include #include "SoundRetro.h" -#include "libretro.h" #include "libretro_core_options.h" #include "scrc32.h" -#include "core/base/system.h" #include "../Util.h" +#include "core/base/system.h" #include "core/base/file_util.h" -#include "core/base/port.h" #include "core/base/sizes.h" -#include "../apu/Blip_Buffer.h" -#include "../apu/Gb_Apu.h" -#include "../apu/Gb_Oscs.h" -#include "../gba/Cheats.h" -#include "../gba/EEprom.h" -#include "../gba/Flash.h" -#include "../gba/GBAGfx.h" -#include "../gba/Globals.h" -#include "../gba/RTC.h" -#include "../gba/Sound.h" -#include "../gba/bios.h" - -#include "../gb/gb.h" -#include "../gb/gbCheats.h" -#include "../gb/gbGlobals.h" -#include "../gb/gbMemory.h" -#include "../gb/gbSGB.h" -#include "../gb/gbSound.h" +#include "core/gb/gb.h" +#include "core/gb/gbCheats.h" +#include "core/gb/gbGlobals.h" +#include "core/gb/gbMemory.h" +#include "core/gb/gbSound.h" +#include "core/gba/gbaCheats.h" +#include "core/gba/gbaEeprom.h" +#include "core/gba/gbaFlash.h" +#include "core/gba/gbaGlobals.h" +#include "core/gba/gbaRtc.h" +#include "core/gba/gbaSound.h" #include "../filters/interframe.hpp" @@ -91,7 +83,7 @@ int emulating = 0; struct CoreOptions coreOptions; -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER void (*dbgOutput)(const char* s, uint32_t addr); void (*dbgSignal)(int sig, int number); #endif @@ -294,17 +286,17 @@ static void SetGBBorder(unsigned val) switch (val) { case 0: - _changed = ((systemWidth != gbWidth) || (systemHeight != gbHeight)) ? 1 : 0; - systemWidth = gbBorderLineSkip = gbWidth; - systemHeight = gbHeight; + _changed = ((systemWidth != kGBWidth) || (systemHeight != kGBHeight)) ? 1 : 0; + systemWidth = gbBorderLineSkip = kGBWidth; + systemHeight = kGBHeight; gbBorderColumnSkip = gbBorderRowSkip = 0; break; case 1: - _changed = ((systemWidth != sgbWidth) || (systemHeight != sgbHeight)) ? 1 : 0; - systemWidth = gbBorderLineSkip = sgbWidth; - systemHeight = sgbHeight; - gbBorderColumnSkip = (sgbWidth - gbWidth) >> 1; - gbBorderRowSkip = (sgbHeight - gbHeight) >> 1; + _changed = ((systemWidth != kSGBWidth) || (systemHeight != kSGBHeight)) ? 1 : 0; + systemWidth = gbBorderLineSkip = kSGBWidth; + systemHeight = kSGBHeight; + gbBorderColumnSkip = (kSGBWidth - kGBWidth) >> 1; + gbBorderRowSkip = (kSGBHeight - kGBHeight) >> 1; break; } @@ -582,8 +574,8 @@ void retro_get_system_av_info(struct retro_system_av_info *info) if (type == IMAGE_GB) { aspect = !gbBorderOn ? (10.0 / 9.0) : (8.0 / 7.0); - maxWidth = !gbBorderOn ? gbWidth : sgbWidth; - maxHeight = !gbBorderOn ? gbHeight : sgbHeight; + maxWidth = !gbBorderOn ? kGBWidth : kSGBWidth; + maxHeight = !gbBorderOn ? kGBHeight : kSGBHeight; } info->geometry.base_width = systemWidth; @@ -941,13 +933,13 @@ static void gb_init(void) gbCPUInit(biosfile, option_useBios); if (gbBorderOn) { - systemWidth = gbBorderLineSkip = sgbWidth; - systemHeight = sgbHeight; - gbBorderColumnSkip = (sgbWidth - gbWidth) >> 1; - gbBorderRowSkip = (sgbHeight - gbHeight) >> 1; + systemWidth = gbBorderLineSkip = kSGBWidth; + systemHeight = kSGBHeight; + gbBorderColumnSkip = (kSGBWidth - kGBWidth) >> 1; + gbBorderRowSkip = (kSGBHeight - kGBHeight) >> 1; } else { - systemWidth = gbBorderLineSkip = gbWidth; - systemHeight = gbHeight; + systemWidth = gbBorderLineSkip = kGBWidth; + systemHeight = kGBHeight; gbBorderColumnSkip = gbBorderRowSkip = 0; } diff --git a/src/sdl/ConfigManager.cpp b/src/sdl/ConfigManager.cpp index 25cb9a88..202c5835 100644 --- a/src/sdl/ConfigManager.cpp +++ b/src/sdl/ConfigManager.cpp @@ -5,7 +5,6 @@ #include #define _GNU_SOURCE 1 - #include #include #include @@ -15,17 +14,17 @@ #include #include -#include "iniparser.h" #include "../Util.h" -#include "../gb/gbGlobals.h" -#include "../gb/gbSound.h" -#include "../gba/Flash.h" -#include "../gba/GBA.h" -#include "../gba/RTC.h" -#include "../gba/Sound.h" -#include "../gba/agbprint.h" -#include "../gba/remote.h" #include "core/base/file_util.h" +#include "core/gb/gbGlobals.h" +#include "core/gb/gbSound.h" +#include "core/gba/gba.h" +#include "core/gba/gbaFlash.h" +#include "core/gba/gbaPrint.h" +#include "core/gba/gbaRemote.h" +#include "core/gba/gbaRtc.h" +#include "core/gba/gbaSound.h" +#include "iniparser.h" #ifndef _WIN32 #define GETCWD getcwd @@ -142,11 +141,11 @@ const char* preparedCheatCodes[MAX_CHEATS]; int patchNum = 0; char *patchNames[PATCH_MAX_NUM] = { NULL }; // and so on -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) void(*dbgMain)() = remoteStubMain; void(*dbgSignal)(int, int) = remoteStubSignal; void(*dbgOutput)(const char *, uint32_t) = debuggerOutput; -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) char* arg0 = NULL; @@ -705,7 +704,7 @@ int ReadOpts(int argc, char ** argv) patchNum++; } break; -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) case 'G': dbgMain = remoteStubMain; dbgSignal = remoteStubSignal; @@ -734,7 +733,7 @@ int ReadOpts(int argc, char ** argv) remoteSetProtocol(0); } break; -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) case 'N': coreOptions.parseDebug = false; break; diff --git a/src/sdl/SDL.cpp b/src/sdl/SDL.cpp index fc8c5837..0213940e 100644 --- a/src/sdl/SDL.cpp +++ b/src/sdl/SDL.cpp @@ -43,20 +43,21 @@ #include +#include "../Util.h" #include "core/base/file_util.h" #include "core/base/message.h" #include "core/base/patch.h" #include "core/base/version.h" -#include "../Util.h" -#include "../gb/gb.h" -#include "../gb/gbCheats.h" -#include "../gb/gbGlobals.h" -#include "../gb/gbSound.h" -#include "../gba/Cheats.h" -#include "../gba/Flash.h" -#include "../gba/GBA.h" -#include "../gba/RTC.h" -#include "../gba/Sound.h" +#include "core/gb/gb.h" +#include "core/gb/gbCheats.h" +#include "core/gb/gbGlobals.h" +#include "core/gb/gbSound.h" +#include "core/gba/gba.h" +#include "core/gba/gbaCheats.h" +#include "core/gba/gbaFlash.h" +#include "core/gba/gbaGlobals.h" +#include "core/gba/gbaRtc.h" +#include "core/gba/gbaSound.h" #include "../common/SoundSDL.h" diff --git a/src/sdl/debugger.cpp b/src/sdl/debugger.cpp index bd5ae751..b6c283fc 100644 --- a/src/sdl/debugger.cpp +++ b/src/sdl/debugger.cpp @@ -24,10 +24,10 @@ #include #include "core/base/port.h" -#include "../gba/GBA.h" -#include "../gba/Sound.h" -#include "../gba/armdis.h" -#include "../gba/elf.h" +#include "core/gba/gbaCpu.h" +#include "core/gba/gbaCpuArmDis.h" +#include "core/gba/gbaElf.h" +#include "core/gba/gbaSound.h" #include "exprNode.h" extern bool debugger; @@ -1747,7 +1747,7 @@ static void debuggerRegisters(int, char**) char* command[3] = { m, 0, one }; char buffer[10]; -#ifdef BKPT_SUPPORT +#ifdef VBAM_ENABLE_DEBUGGER if (debugger_last) { printf("R00=%08x R04=%08x R08=%08x R12=%08x\n", oldreg[0], oldreg[4], oldreg[8], oldreg[12]); diff --git a/src/sdl/expr.ypp b/src/sdl/expr.ypp index 25034ad6..69b392c8 100644 --- a/src/sdl/expr.ypp +++ b/src/sdl/expr.ypp @@ -5,7 +5,7 @@ #include #include "core/base/system.h" -#include "../gba/elf.h" +#include "core/gba/gbaElf.h" #include "exprNode.h" extern int yyerror(const char *); diff --git a/src/sdl/exprNode.cpp b/src/sdl/exprNode.cpp index f970b8a4..3d447867 100644 --- a/src/sdl/exprNode.cpp +++ b/src/sdl/exprNode.cpp @@ -21,8 +21,9 @@ #include #include "core/base/port.h" -#include "../gba/GBA.h" -#include "../gba/elf.h" +#include "core/gba/gba.h" +#include "core/gba/gbaElf.h" +#include "core/gba/gbaGlobals.h" #include "exprNode.h" #ifndef __GNUC__ diff --git a/src/sdl/exprNode.h b/src/sdl/exprNode.h index 394042df..c200c8be 100644 --- a/src/sdl/exprNode.h +++ b/src/sdl/exprNode.h @@ -17,7 +17,7 @@ // along with this program; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -#include "../gba/elf.h" +#include "core/gba/gbaElf.h" struct Node { Type* type; diff --git a/src/wx/cmdevents.cpp b/src/wx/cmdevents.cpp index 10732820..bab8465f 100644 --- a/src/wx/cmdevents.cpp +++ b/src/wx/cmdevents.cpp @@ -10,11 +10,19 @@ #include #include -#include "core/base/version.h" -#include "../gb/gbPrinter.h" -#include "../gba/agbprint.h" #include "config/option-proxy.h" #include "config/option.h" +#include "core/base/version.h" +#include "core/gb/gb.h" +#include "core/gb/gbCheats.h" +#include "core/gb/gbGlobals.h" +#include "core/gb/gbPrinter.h" +#include "core/gb/gbSound.h" +#include "core/gba/gbaCheats.h" +#include "core/gba/gbaEeprom.h" +#include "core/gba/gbaGlobals.h" +#include "core/gba/gbaPrint.h" +#include "core/gba/gbaSound.h" #include "dialogs/game-maker.h" #define GetXRCDialog(n) \ @@ -1758,7 +1766,7 @@ EVT_HANDLER_MASK(TileViewer, "Tile Viewer...", CMDEN_GB | CMDEN_GBA) TileViewer(); } -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) extern int remotePort; int GetGDBPort(MainFrame* mf) @@ -1779,28 +1787,28 @@ int GetGDBPort(MainFrame* mf) #endif 65535, mf); } -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) EVT_HANDLER(DebugGDBPort, "Configure port...") { -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) int port_selected = GetGDBPort(this); if (port_selected != -1) { gopts.gdb_port = port_selected; update_opts(); } -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) } EVT_HANDLER(DebugGDBBreakOnLoad, "Break on load") { -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) GetMenuOptionConfig("DebugGDBBreakOnLoad", config::OptionID::kPrefGDBBreakOnLoad); -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) } -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) void MainFrame::GDBBreak() { ModalPause mp; @@ -1879,18 +1887,18 @@ void MainFrame::GDBBreak() } } } -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) EVT_HANDLER_MASK(DebugGDBBreak, "Break into GDB", CMDEN_NGDB_GBA | CMDEN_GDB) { -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) GDBBreak(); -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) } EVT_HANDLER_MASK(DebugGDBDisconnect, "Disconnect GDB", CMDEN_GDB) { -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) debugger = false; dbgMain = NULL; dbgSignal = NULL; @@ -1900,7 +1908,7 @@ EVT_HANDLER_MASK(DebugGDBDisconnect, "Disconnect GDB", CMDEN_GDB) cmd_enable &= ~CMDEN_GDB; cmd_enable |= CMDEN_NGDB_GBA | CMDEN_NGDB_ANY; enable_menus(); -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) } // Options menu diff --git a/src/wx/config/internal/option-internal.cpp b/src/wx/config/internal/option-internal.cpp index 957ea3f5..8f71694d 100644 --- a/src/wx/config/internal/option-internal.cpp +++ b/src/wx/config/internal/option-internal.cpp @@ -11,8 +11,8 @@ #include #include "core/base/system.h" -#include "../gba/Sound.h" -#include "../gb/gbGlobals.h" +#include "core/gb/gbGlobals.h" +#include "core/gba/gbaSound.h" #include "opts.h" #define VBAM_OPTION_INTERNAL_INCLUDE diff --git a/src/wx/dialogs/gb-rom-info.cpp b/src/wx/dialogs/gb-rom-info.cpp index 98868586..504275bb 100644 --- a/src/wx/dialogs/gb-rom-info.cpp +++ b/src/wx/dialogs/gb-rom-info.cpp @@ -4,7 +4,7 @@ #include #include "core/base/sizes.h" -#include "../gb/gb.h" +#include "core/gb/gb.h" #include "dialogs/game-maker.h" #include "dialogs/validated-child.h" diff --git a/src/wx/dsound.cpp b/src/wx/dsound.cpp index 347b265e..a509e1b1 100644 --- a/src/wx/dsound.cpp +++ b/src/wx/dsound.cpp @@ -4,8 +4,8 @@ // Internals #include "core/base/sound_driver.h" #include "core/base/system.h" -#include "../gba/Globals.h" -#include "../gba/Sound.h" +#include "core/gba/gbaGlobals.h" +#include "core/gba/gbaSound.h" // DirectSound8 #define DIRECTSOUND_VERSION 0x0800 diff --git a/src/wx/faudio.cpp b/src/wx/faudio.cpp index f34fee82..6d2b478f 100644 --- a/src/wx/faudio.cpp +++ b/src/wx/faudio.cpp @@ -17,7 +17,7 @@ // Internals #include "core/base/system.h" // for systemMessage() -#include "../gba/Globals.h" +#include "core/gba/gbaGlobals.h" int GetFADevices(FAudio* fa, wxArrayString* names, wxArrayString* ids, const wxString* match) diff --git a/src/wx/gfxviewers.cpp b/src/wx/gfxviewers.cpp index 103fca1b..308013eb 100644 --- a/src/wx/gfxviewers.cpp +++ b/src/wx/gfxviewers.cpp @@ -6,6 +6,8 @@ #include #include "config/option-proxy.h" +#include "core/gb/gbGlobals.h" +#include "core/gba/gbaGlobals.h" #include "viewsupt.h" #include "wxvbam.h" diff --git a/src/wx/guiinit.cpp b/src/wx/guiinit.cpp index 175d5b27..f75aa800 100644 --- a/src/wx/guiinit.cpp +++ b/src/wx/guiinit.cpp @@ -33,9 +33,14 @@ #include #include "../Util.h" -#include "../gba/CheatSearch.h" #include "config/option-proxy.h" -#include "config/option.h" +#include "core/gb/gb.h" +#include "core/gb/gbCheats.h" +#include "core/gb/gbGlobals.h" +#include "core/gba/gbaCheats.h" +#include "core/gba/gbaCheatSearch.h" +#include "core/gba/gbaFlash.h" +#include "core/gba/gbaGlobals.h" #include "dialogs/accel-config.h" #include "dialogs/directories-config.h" #include "dialogs/display-config.h" @@ -2038,7 +2043,7 @@ bool MainFrame::BindControls() } #endif -#ifdef NO_DEBUGGER +#if !defined(VBAM_ENABLE_DEBUGGER) if (cmdtab[i].cmd_id == XRCID("DebugGDBBreak") || cmdtab[i].cmd_id == XRCID("DebugGDBDisconnect") || cmdtab[i].cmd_id == XRCID("DebugGDBBreakOnLoad") || cmdtab[i].cmd_id == XRCID("DebugGDBPort")) { @@ -2050,7 +2055,7 @@ bool MainFrame::BindControls() cmdtab[i].mi = NULL; continue; } -#endif +#endif // !defined(VBAM_ENABLE_DEBUGGER) #if defined(NO_ONLINEUPDATES) if (cmdtab[i].cmd_id == XRCID("UpdateEmu")) { @@ -2091,12 +2096,12 @@ bool MainFrame::BindControls() } } -#ifdef NO_DEBUGGER +#if !defined(VBAM_ENABLE_DEBUGGER) // remove this item from the menu completely wxMenuItem* gdbmi = XRCITEM("GDBMenu"); gdbmi->GetMenu()->Remove(gdbmi); gdbmi = nullptr; -#endif +#endif // !defined(VBAM_ENABLE_DEBUGGER) #ifdef NO_LINK // remove this item from the menu completely wxMenuItem* linkmi = XRCITEM("LinkMenu"); diff --git a/src/wx/openal.cpp b/src/wx/openal.cpp index b220ba4f..fe4c1559 100644 --- a/src/wx/openal.cpp +++ b/src/wx/openal.cpp @@ -14,8 +14,8 @@ #include "openal.h" // Internals -#include "../gba/Globals.h" // for 'speedup' and 'synchronize' -#include "../gba/Sound.h" +#include "core/gba/gbaGlobals.h" // for 'speedup' and 'synchronize' +#include "core/gba/gbaSound.h" // Debug #include diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index f780adc9..291f4a58 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #ifdef __WXGTK__ #include @@ -22,18 +21,26 @@ #include #include "../Util.h" -#include "core/base/file_util.h" -#include "core/base/patch.h" -#include "core/base/version.h" -#include "../gb/gbPrinter.h" -#include "../gba/RTC.h" -#include "../gba/agbprint.h" #include "../sdl/text.h" #include "background-input.h" #include "config/game-control.h" #include "config/option-proxy.h" #include "config/option.h" #include "config/user-input.h" +#include "core/base/file_util.h" +#include "core/base/patch.h" +#include "core/base/version.h" +#include "core/gb/gb.h" +#include "core/gb/gbCheats.h" +#include "core/gb/gbGlobals.h" +#include "core/gb/gbSound.h" +#include "core/gb/gbPrinter.h" +#include "core/gba/gbaCheats.h" +#include "core/gba/gbaGlobals.h" +#include "core/gba/gbaFlash.h" +#include "core/gba/gbaPrint.h" +#include "core/gba/gbaRtc.h" +#include "core/gba/gbaSound.h" #include "drawing.h" #include "filters.h" #include "wayland.h" @@ -530,11 +537,11 @@ void GameArea::LoadGame(const wxString& name) } #endif -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) if (OPTION(kPrefGDBBreakOnLoad)) { mf->GDBBreak(); } -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) } void GameArea::SetFrameTitle() @@ -626,11 +633,11 @@ void GameArea::UnloadGame(bool destruct) systemStopGameRecording(); systemStopGamePlayback(); -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) debugger = false; remoteCleanUp(); mf->cmd_enable |= CMDEN_NGDB_ANY; -#endif +#endif // VBAM_ENABLE_DEBUGGER if (loaded == IMAGE_GB) { gbCleanUp(); @@ -1087,7 +1094,7 @@ void GameArea::OnIdle(wxIdleEvent& event) wxGetApp().pending_load = wxEmptyString; LoadGame(pl); -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) if (OPTION(kPrefGDBBreakOnLoad)) { mf->GDBBreak(); } @@ -1096,7 +1103,7 @@ void GameArea::OnIdle(wxIdleEvent& event) wxLogError(_("Not a valid Game Boy Advance cartridge")); UnloadGame(); } -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) } // stupid wx doesn't resize to screen size @@ -1218,7 +1225,7 @@ void GameArea::OnIdle(wxIdleEvent& event) HideMenuBar(); event.RequestMore(); -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) if (debugger) { was_paused = true; dbgMain(); @@ -1231,7 +1238,7 @@ void GameArea::OnIdle(wxIdleEvent& event) return; } -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) emusys->emuMain(emusys->emuCount); #ifndef NO_LINK diff --git a/src/wx/sys.cpp b/src/wx/sys.cpp index 4e975519..fe3b0ce7 100644 --- a/src/wx/sys.cpp +++ b/src/wx/sys.cpp @@ -6,10 +6,13 @@ #include #include -#include "core/base/image_util.h" #include "../common/SoundSDL.h" #include "config/game-control.h" #include "config/option-proxy.h" +#include "core/base/image_util.h" +#include "core/gb/gbGlobals.h" +#include "core/gba/gbaGlobals.h" +#include "core/gba/gbaSound.h" #include "wxvbam.h" // These should probably be in vbamcore @@ -1274,7 +1277,7 @@ void systemOnSoundShutdown() { } -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) extern int (*remoteSendFnc)(char*, int); extern int (*remoteRecvFnc)(char*, int); @@ -1440,7 +1443,7 @@ bool debugWaitSocket() return debug_remote != NULL; } -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) void log(const char* defaultMsg, ...) { diff --git a/src/wx/viewers.cpp b/src/wx/viewers.cpp index 48001d29..edf14e0c 100644 --- a/src/wx/viewers.cpp +++ b/src/wx/viewers.cpp @@ -7,9 +7,12 @@ #include #include -#include "../gba/armdis.h" #include "config/option-proxy.h" -#include "keep-on-top-styler.h" +#include "core/gb/gb.h" +#include "core/gb/gbDis.h" +#include "core/gb/gbGlobals.h" +#include "core/gba/gbaCpu.h" +#include "core/gba/gbaCpuArmDis.h" #include "viewsupt.h" #include "wxvbam.h" @@ -344,7 +347,7 @@ void MainFrame::Disassemble(void) // for CPUWriteHalfWord // and CPURead... below -#include "../gba/GBAinline.h" +#include "core/gba/gbaInline.h" namespace Viewers { #include "ioregs.h" diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index afe1f582..028f9f38 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -30,7 +30,12 @@ #include #include -#include "../gba/remote.h" +#include "core/gb/gbGlobals.h" +#include "core/gba/gbaSound.h" + +#if defined(VBAM_ENABLE_DEBUGGER) +#include "core/gba/gbaRemote.h" +#endif // defined(VBAM_ENABLE_DEBUGGER) // The built-in xrc file #include "builtin-xrc.h" @@ -86,11 +91,11 @@ static const char kDotDir[] = "visualboyadvance-m"; } // namespace -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) void(*dbgMain)() = remoteStubMain; void(*dbgSignal)(int, int) = remoteStubSignal; void(*dbgOutput)(const char *, uint32_t) = debuggerOutput; -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) #ifdef __WXMSW__ diff --git a/src/wx/wxvbam.h b/src/wx/wxvbam.h index 8b54bffe..dfee5521 100644 --- a/src/wx/wxvbam.h +++ b/src/wx/wxvbam.h @@ -11,6 +11,7 @@ #include #include +#include "core/base/system.h" #include "config/option-observer.h" #include "widgets/dpi-support.h" #include "widgets/keep-on-top-styler.h" @@ -18,14 +19,9 @@ #include "wx/wxmisc.h" #include "wxhead.h" -#include "../gb/gb.h" -#include "../gb/gbCheats.h" -#include "../gb/gbGlobals.h" -#include "../gb/gbSound.h" -#include "../gba/Cheats.h" -#include "../gba/GBALink.h" -#include "../gba/Globals.h" -#include "../gba/Sound.h" +#ifndef NO_LINK +#include "core/gba/gbaLink.h" +#endif #ifndef NO_FFMPEG #include "../common/ffmpeg.h" @@ -728,7 +724,7 @@ extern bool GetFADevices(wxArrayString& names, wxArrayString& ids); #endif #endif -#ifndef NO_DEBUGGER +#if defined(VBAM_ENABLE_DEBUGGER) extern bool debugger; extern void (*dbgMain)(); extern void (*dbgSignal)(int, int); @@ -743,7 +739,7 @@ extern const wxString& debugGetSlavePty(); extern bool debugWaitPty(); extern bool debugStartListen(int port); extern bool debugWaitSocket(); -#endif +#endif // defined(VBAM_ENABLE_DEBUGGER) // supported movie format for game recording enum MVFormatID { diff --git a/src/wx/xaudio2.cpp b/src/wx/xaudio2.cpp index b0293eef..757c22d9 100644 --- a/src/wx/xaudio2.cpp +++ b/src/wx/xaudio2.cpp @@ -21,7 +21,7 @@ // Internals #include "core/base/system.h" // for systemMessage() -#include "../gba/Globals.h" +#include "core/gba/gbaGlobals.h" int GetXA2Devices(IXAudio2* xa, wxArrayString* names, wxArrayString* ids, const wxString* match)