From e5c61e0093a9219cdf95b01eb74aa0f48250d01f Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Oct 2016 13:13:44 -0700 Subject: [PATCH 01/56] Python: Preliminary, incomplete bindings --- CMakeLists.txt | 7 +++++ src/arm/arm.h | 4 +-- src/core/log.c | 14 +++++++++ src/core/log.h | 4 +++ src/debugger/debugger.h | 2 +- src/platform/python/CMakeLists.txt | 20 +++++++++++++ src/platform/python/__init__.py | 0 src/platform/python/_builder.h | 6 ++++ src/platform/python/_builder.py | 20 +++++++++++++ src/platform/python/mCore.py | 47 ++++++++++++++++++++++++++++++ src/util/table.c | 8 +++++ src/util/table.h | 5 ++++ 12 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 src/platform/python/CMakeLists.txt create mode 100644 src/platform/python/__init__.py create mode 100644 src/platform/python/_builder.h create mode 100644 src/platform/python/_builder.py create mode 100644 src/platform/python/mCore.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b048f9cc..f74c7dce0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ set(BUILD_PERF OFF CACHE BOOL "Build performance profiling tool") set(BUILD_TEST OFF CACHE BOOL "Build testing harness") set(BUILD_SUITE OFF CACHE BOOL "Build test suite") set(BUILD_EXAMPLE OFF CACHE BOOL "Build example frontends") +set(BUILD_PYTHON OFF CACHE BOOL "Build Python bindings") set(BUILD_STATIC OFF CACHE BOOL "Build a static library") set(BUILD_SHARED ON CACHE BOOL "Build a shared library") set(SKIP_LIBRARY OFF CACHE BOOL "Skip building the library (useful for only building libretro or OpenEmu cores)") @@ -750,6 +751,11 @@ if(BUILD_SUITE) add_test(${BINARY_NAME}-suite ${BINARY_NAME}-suite) endif() +if(BUILD_PYTHON) + enable_testing() + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/python ${CMAKE_CURRENT_BINARY_DIR}/python) +endif() + if(BUILD_EXAMPLE) add_executable(${BINARY_NAME}-example-server ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/example/client-server/server.c) target_link_libraries(${BINARY_NAME}-example-server ${BINARY_NAME}) @@ -833,6 +839,7 @@ if(NOT QUIET) message(STATUS " Profiling: ${BUILD_PERF}") message(STATUS " Test harness: ${BUILD_TEST}") message(STATUS " Test suite: ${BUILD_SUITE}") + message(STATUS " Python bindings: ${BUILD_PYTHON}") message(STATUS " Examples: ${BUILD_EXAMPLE}") message(STATUS "Cores:") message(STATUS " Libretro core: ${BUILD_LIBRETRO}") diff --git a/src/arm/arm.h b/src/arm/arm.h index 947cedf15..274906e71 100644 --- a/src/arm/arm.h +++ b/src/arm/arm.h @@ -73,7 +73,7 @@ union PSR { unsigned z : 1; unsigned c : 1; unsigned v : 1; - unsigned : 20; + unsigned unused : 20; unsigned i : 1; unsigned f : 1; unsigned t : 1; @@ -83,7 +83,7 @@ union PSR { unsigned t : 1; unsigned f : 1; unsigned i : 1; - unsigned : 20; + unsigned unused : 20; unsigned v : 1; unsigned c : 1; unsigned z : 1; diff --git a/src/core/log.c b/src/core/log.c index 880379fd9..125907e9a 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -44,4 +44,18 @@ const char* mLogCategoryName(int category) { return 0; } +void mLog(int category, enum mLogLevel level, const char* format, ...) { + struct mLogger* context = mLogGetContext(); + va_list args; + va_start(args, format); + if (context) { + context->log(context, category, level, format, args); + } else { + printf("%s: ", mLogCategoryName(category)); + vprintf(format, args); + printf("\n"); + } + va_end(args); +} + mLOG_DEFINE_CATEGORY(STATUS, "Status") diff --git a/src/core/log.h b/src/core/log.h index 03fb31ee9..43be3d374 100644 --- a/src/core/log.h +++ b/src/core/log.h @@ -30,6 +30,7 @@ int mLogGenerateCategory(const char*); const char* mLogCategoryName(int); ATTRIBUTE_FORMAT(printf, 3, 4) +#ifndef __NO_INLINE__ static inline void mLog(int category, enum mLogLevel level, const char* format, ...) { struct mLogger* context = mLogGetContext(); va_list args; @@ -43,6 +44,9 @@ static inline void mLog(int category, enum mLogLevel level, const char* format, } va_end(args); } +#else +void mLog(int category, enum mLogLevel level, const char* format, ...); +#endif #define mLOG(CATEGORY, LEVEL, ...) mLog(_mLOG_CAT_ ## CATEGORY (), mLOG_ ## LEVEL, __VA_ARGS__) diff --git a/src/debugger/debugger.h b/src/debugger/debugger.h index a4ce367f6..fed4c4978 100644 --- a/src/debugger/debugger.h +++ b/src/debugger/debugger.h @@ -35,7 +35,7 @@ enum mDebuggerState { enum mWatchpointType { WATCHPOINT_WRITE = 1, WATCHPOINT_READ = 2, - WATCHPOINT_RW = WATCHPOINT_WRITE | WATCHPOINT_READ + WATCHPOINT_RW = 3 }; enum mBreakpointType { diff --git a/src/platform/python/CMakeLists.txt b/src/platform/python/CMakeLists.txt new file mode 100644 index 000000000..cd30b551f --- /dev/null +++ b/src/platform/python/CMakeLists.txt @@ -0,0 +1,20 @@ +set(PY_INCLUDE_DIRS -I${CMAKE_SOURCE_DIR}/src) +get_property(INCLUDE_DIRECTORIES DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) +get_property(COMPILE_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS) +foreach(INCLUDE_DIR IN LISTS INCLUDE_DIRECTORIES) + list(APPEND PY_INCLUDE_DIRS -I${INCLUDE_DIR}) +endforeach() +foreach(COMPILE_DEF IN LISTS COMPILE_DEFINITIONS) + list(APPEND PY_COMPILE_DEFS -D${COMPILE_DEF}) +endforeach() + +add_custom_command(OUTPUT _builder.h + COMMAND ${CMAKE_C_COMPILER} ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} -fno-inline -E -P -c ${CMAKE_CURRENT_SOURCE_DIR}/_builder.h -o _builder.h + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.h) +add_custom_target(_builder.h ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_builder.h) + +add_custom_command(OUTPUT ${BINARY_NAME}/_pylib.so + COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_builder.h) +add_custom_target(_pylib.so ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}/_pylib.so) \ No newline at end of file diff --git a/src/platform/python/__init__.py b/src/platform/python/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/platform/python/_builder.h b/src/platform/python/_builder.h new file mode 100644 index 000000000..4c34f6f37 --- /dev/null +++ b/src/platform/python/_builder.h @@ -0,0 +1,6 @@ +#define COMMON_H +#define ATTRIBUTE_FORMAT(X, Y, Z) +typedef long time_t; +typedef ... va_list; +#include +#include "core/core.h" \ No newline at end of file diff --git a/src/platform/python/_builder.py b/src/platform/python/_builder.py new file mode 100644 index 000000000..bcd0bb544 --- /dev/null +++ b/src/platform/python/_builder.py @@ -0,0 +1,20 @@ +import cffi +import os.path +import subprocess +import sys + +ffi = cffi.FFI() +src = os.path.join(os.path.dirname(__file__), "..", "..") + +ffi.set_source("mgba._pylib", """ +#include "util/common.h" +#include "core/core.h" +""", include_dirs=[src], + extra_compile_args=sys.argv[1:], + libraries=["mgba"], + library_dirs=[os.path.join(os.getcwd(), "..")]) + +with open(os.path.join(os.getcwd(), "_builder.h")) as core: + ffi.cdef(core.read()) + +ffi.compile() \ No newline at end of file diff --git a/src/platform/python/mCore.py b/src/platform/python/mCore.py new file mode 100644 index 000000000..f9700d7df --- /dev/null +++ b/src/platform/python/mCore.py @@ -0,0 +1,47 @@ +from _pylib import ffi, lib + +def find(path): + core = lib.mCoreFind(path.encode('UTF-8')) + if core == ffi.NULL: + return None + return mCore(core) + +class mCore: + def __init__(self, native): + self._core = ffi.gc(native, self._deinit) + + def init(self): + return bool(self._core.init(self._core)) + + def _deinit(self): + self._core.deinit(self._core) + + def loadFile(self, path): + return bool(lib.mCoreLoadFile(self._core, path.encode('UTF-8'))) + + def autoloadSave(self): + return bool(lib.mCoreAutoloadSave(self._core)) + + def autoloadPatch(self): + return bool(lib.mCoreAutoloadPatch(self._core)) + + def platform(self): + return self._core.platform(self._core) + + def desiredVideoDimensions(self): + width = ffi.new("unsigned*") + height = ffi.new("unsigned*") + self._core.desiredVideoDimensions(self._core, width, height) + return width[0], height[0] + + def reset(self): + self._core.reset(self._core) + + def runFrame(self): + self._core.runFrame(self._core) + + def runLoop(self): + self._core.runLoop(self._core) + + def step(self): + self._core.step(self._core) diff --git a/src/util/table.c b/src/util/table.c index ebc756c29..3f4deb013 100644 --- a/src/util/table.c +++ b/src/util/table.c @@ -163,6 +163,14 @@ size_t TableSize(const struct Table* table) { return table->size; } +void HashTableInit(struct Table* table, size_t initialSize, void (deinitializer(void*))) { + TableInit(table, initialSize, deinitializer); +} + +void HashTableDeinit(struct Table* table) { + TableDeinit(table); +} + void* HashTableLookup(const struct Table* table, const char* key) { uint32_t hash = hash32(key, strlen(key), 0); const struct TableList* list; diff --git a/src/util/table.h b/src/util/table.h index 5dee643fd..a443defbb 100644 --- a/src/util/table.h +++ b/src/util/table.h @@ -29,6 +29,7 @@ void TableClear(struct Table*); void TableEnumerate(const struct Table*, void (handler(uint32_t key, void* value, void* user)), void* user); size_t TableSize(const struct Table*); +#ifndef __NO_INLINE__ static inline void HashTableInit(struct Table* table, size_t initialSize, void (deinitializer(void*))) { TableInit(table, initialSize, deinitializer); } @@ -36,6 +37,10 @@ static inline void HashTableInit(struct Table* table, size_t initialSize, void ( static inline void HashTableDeinit(struct Table* table) { TableDeinit(table); } +#else +void HashTableInit(struct Table* table, size_t initialSize, void (deinitializer(void*))); +void HashTableDeinit(struct Table* table); +#endif void* HashTableLookup(const struct Table*, const char* key); void HashTableInsert(struct Table*, const char* key, void* value); From f72a582382134370cdde110f6a46c59b4932cf17 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Oct 2016 16:02:32 -0700 Subject: [PATCH 02/56] Debugger: Fix included file --- src/debugger/debugger.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debugger/debugger.h b/src/debugger/debugger.h index fed4c4978..e41c56fc6 100644 --- a/src/debugger/debugger.h +++ b/src/debugger/debugger.h @@ -8,7 +8,7 @@ #include "util/common.h" -#include "arm/arm.h" +#include "core/cpu.h" #include "core/log.h" #include "util/vector.h" From 227cbea37a1196f34e8884a5331f54c5f30c6e01 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Oct 2016 17:05:14 -0700 Subject: [PATCH 03/56] All: Remove duplicate functions --- src/core/log.h | 16 ---------------- src/util/table.h | 10 ---------- 2 files changed, 26 deletions(-) diff --git a/src/core/log.h b/src/core/log.h index 43be3d374..b75c49118 100644 --- a/src/core/log.h +++ b/src/core/log.h @@ -30,23 +30,7 @@ int mLogGenerateCategory(const char*); const char* mLogCategoryName(int); ATTRIBUTE_FORMAT(printf, 3, 4) -#ifndef __NO_INLINE__ -static inline void mLog(int category, enum mLogLevel level, const char* format, ...) { - struct mLogger* context = mLogGetContext(); - va_list args; - va_start(args, format); - if (context) { - context->log(context, category, level, format, args); - } else { - printf("%s: ", mLogCategoryName(category)); - vprintf(format, args); - printf("\n"); - } - va_end(args); -} -#else void mLog(int category, enum mLogLevel level, const char* format, ...); -#endif #define mLOG(CATEGORY, LEVEL, ...) mLog(_mLOG_CAT_ ## CATEGORY (), mLOG_ ## LEVEL, __VA_ARGS__) diff --git a/src/util/table.h b/src/util/table.h index a443defbb..843bab80e 100644 --- a/src/util/table.h +++ b/src/util/table.h @@ -29,18 +29,8 @@ void TableClear(struct Table*); void TableEnumerate(const struct Table*, void (handler(uint32_t key, void* value, void* user)), void* user); size_t TableSize(const struct Table*); -#ifndef __NO_INLINE__ -static inline void HashTableInit(struct Table* table, size_t initialSize, void (deinitializer(void*))) { - TableInit(table, initialSize, deinitializer); -} - -static inline void HashTableDeinit(struct Table* table) { - TableDeinit(table); -} -#else void HashTableInit(struct Table* table, size_t initialSize, void (deinitializer(void*))); void HashTableDeinit(struct Table* table); -#endif void* HashTableLookup(const struct Table*, const char* key); void HashTableInsert(struct Table*, const char* key, void* value); From bd7b394e491b65ed397c960c67715ad6a6d52861 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Oct 2016 17:06:08 -0700 Subject: [PATCH 04/56] All: Unfortunate evils committed in the name of pycparser --- src/gb/gb.h | 1 - src/gb/video.h | 8 +++---- src/gba/memory.h | 2 +- src/gba/video.h | 8 +++---- src/lr35902/isa-lr35902.c | 30 +++++++++++++++++++++++++ src/lr35902/lr35902.h | 34 ++--------------------------- src/third-party/blip_buf/blip_buf.h | 2 +- 7 files changed, 42 insertions(+), 43 deletions(-) diff --git a/src/gb/gb.h b/src/gb/gb.h index 89e38c6de..32206d9d3 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -119,7 +119,6 @@ void GBHalt(struct LR35902Core* cpu); struct VFile; bool GBLoadROM(struct GB* gb, struct VFile* vf); bool GBLoadSave(struct GB* gb, struct VFile* vf); -void GBYankROM(struct GB* gb); void GBUnloadROM(struct GB* gb); void GBSynthesizeROM(struct VFile* vf); diff --git a/src/gb/video.h b/src/gb/video.h index a2ddccdb3..f6071c917 100644 --- a/src/gb/video.h +++ b/src/gb/video.h @@ -17,17 +17,17 @@ enum { GB_VIDEO_HORIZONTAL_PIXELS = 160, GB_VIDEO_VERTICAL_PIXELS = 144, GB_VIDEO_VBLANK_PIXELS = 10, - GB_VIDEO_VERTICAL_TOTAL_PIXELS = GB_VIDEO_VERTICAL_PIXELS + GB_VIDEO_VBLANK_PIXELS, + GB_VIDEO_VERTICAL_TOTAL_PIXELS = 154, // TODO: Figure out exact lengths GB_VIDEO_MODE_2_LENGTH = 76, GB_VIDEO_MODE_3_LENGTH_BASE = 171, GB_VIDEO_MODE_0_LENGTH_BASE = 209, - GB_VIDEO_HORIZONTAL_LENGTH = GB_VIDEO_MODE_0_LENGTH_BASE + GB_VIDEO_MODE_2_LENGTH + GB_VIDEO_MODE_3_LENGTH_BASE, + GB_VIDEO_HORIZONTAL_LENGTH = 456, - GB_VIDEO_MODE_1_LENGTH = GB_VIDEO_HORIZONTAL_LENGTH * GB_VIDEO_VBLANK_PIXELS, - GB_VIDEO_TOTAL_LENGTH = GB_VIDEO_HORIZONTAL_LENGTH * GB_VIDEO_VERTICAL_TOTAL_PIXELS, + GB_VIDEO_MODE_1_LENGTH = 65664, + GB_VIDEO_TOTAL_LENGTH = 70224, GB_BASE_MAP = 0x1800, GB_SIZE_MAP = 0x0400 diff --git a/src/gba/memory.h b/src/gba/memory.h index 08d89e9df..acd9459cc 100644 --- a/src/gba/memory.h +++ b/src/gba/memory.h @@ -116,7 +116,7 @@ struct GBAMemory { uint32_t* wram; uint32_t* iwram; uint32_t* rom; - uint16_t io[SIZE_IO >> 1]; + uint16_t io[512]; struct GBACartridgeHardware hw; struct GBASavedata savedata; diff --git a/src/gba/video.h b/src/gba/video.h index da9f85848..d9c440bea 100644 --- a/src/gba/video.h +++ b/src/gba/video.h @@ -19,13 +19,13 @@ enum { VIDEO_HBLANK_PIXELS = 68, VIDEO_HDRAW_LENGTH = 1006, VIDEO_HBLANK_LENGTH = 226, - VIDEO_HORIZONTAL_LENGTH = VIDEO_HDRAW_LENGTH + VIDEO_HBLANK_LENGTH, + VIDEO_HORIZONTAL_LENGTH = 1232, VIDEO_VERTICAL_PIXELS = 160, VIDEO_VBLANK_PIXELS = 68, - VIDEO_VERTICAL_TOTAL_PIXELS = VIDEO_VERTICAL_PIXELS + VIDEO_VBLANK_PIXELS, + VIDEO_VERTICAL_TOTAL_PIXELS = 228, - VIDEO_TOTAL_LENGTH = VIDEO_HORIZONTAL_LENGTH * VIDEO_VERTICAL_TOTAL_PIXELS, + VIDEO_TOTAL_LENGTH = 280896, OBJ_HBLANK_FREE_LENGTH = 954, OBJ_LENGTH = 1210, @@ -177,7 +177,7 @@ struct GBAVideo { // VCOUNT int vcount; - uint16_t palette[SIZE_PALETTE_RAM >> 1]; + uint16_t palette[512]; uint16_t* vram; union GBAOAM oam; diff --git a/src/lr35902/isa-lr35902.c b/src/lr35902/isa-lr35902.c index c9298f57d..d8f10211f 100644 --- a/src/lr35902/isa-lr35902.c +++ b/src/lr35902/isa-lr35902.c @@ -8,6 +8,36 @@ #include "lr35902/emitter-lr35902.h" #include "lr35902/lr35902.h" +static inline uint16_t LR35902ReadHL(struct LR35902Core* cpu) { + uint16_t hl; + LOAD_16LE(hl, 0, &cpu->hl); + return hl; +} + +static inline void LR35902WriteHL(struct LR35902Core* cpu, uint16_t hl) { + STORE_16LE(hl, 0, &cpu->hl); +} + +static inline uint16_t LR35902ReadBC(struct LR35902Core* cpu) { + uint16_t bc; + LOAD_16LE(bc, 0, &cpu->bc); + return bc; +} + +static inline void LR35902WriteBC(struct LR35902Core* cpu, uint16_t bc) { + STORE_16LE(bc, 0, &cpu->bc); +} + +static inline uint16_t LR35902ReadDE(struct LR35902Core* cpu) { + uint16_t de; + LOAD_16LE(de, 0, &cpu->de); + return de; +} + +static inline void LR35902WriteDE(struct LR35902Core* cpu, uint16_t de) { + STORE_16LE(de, 0, &cpu->de); +} + #define DEFINE_INSTRUCTION_LR35902(NAME, BODY) \ static void _LR35902Instruction ## NAME (struct LR35902Core* cpu) { \ UNUSED(cpu); \ diff --git a/src/lr35902/lr35902.h b/src/lr35902/lr35902.h index 84eddfb73..a98c699a0 100644 --- a/src/lr35902/lr35902.h +++ b/src/lr35902/lr35902.h @@ -21,9 +21,9 @@ union FlagRegister { unsigned n : 1; unsigned h : 1; unsigned c : 1; - unsigned : 4; + unsigned unused : 4; #else - unsigned : 4; + unsigned unused : 4; unsigned c : 1; unsigned h : 1; unsigned n : 1; @@ -125,36 +125,6 @@ struct LR35902Core { struct mCPUComponent** components; }; -static inline uint16_t LR35902ReadHL(struct LR35902Core* cpu) { - uint16_t hl; - LOAD_16LE(hl, 0, &cpu->hl); - return hl; -} - -static inline void LR35902WriteHL(struct LR35902Core* cpu, uint16_t hl) { - STORE_16LE(hl, 0, &cpu->hl); -} - -static inline uint16_t LR35902ReadBC(struct LR35902Core* cpu) { - uint16_t bc; - LOAD_16LE(bc, 0, &cpu->bc); - return bc; -} - -static inline void LR35902WriteBC(struct LR35902Core* cpu, uint16_t bc) { - STORE_16LE(bc, 0, &cpu->bc); -} - -static inline uint16_t LR35902ReadDE(struct LR35902Core* cpu) { - uint16_t de; - LOAD_16LE(de, 0, &cpu->de); - return de; -} - -static inline void LR35902WriteDE(struct LR35902Core* cpu, uint16_t de) { - STORE_16LE(de, 0, &cpu->de); -} - void LR35902Init(struct LR35902Core* cpu); void LR35902Deinit(struct LR35902Core* cpu); void LR35902SetComponents(struct LR35902Core* cpu, struct mCPUComponent* master, int extra, struct mCPUComponent** extras); diff --git a/src/third-party/blip_buf/blip_buf.h b/src/third-party/blip_buf/blip_buf.h index 52703643c..22b0a3ec8 100644 --- a/src/third-party/blip_buf/blip_buf.h +++ b/src/third-party/blip_buf/blip_buf.h @@ -24,7 +24,7 @@ void blip_set_rates( blip_t*, double clock_rate, double sample_rate ); enum { /** Maximum clock_rate/sample_rate ratio. For a given sample_rate, clock_rate must not be greater than sample_rate*blip_max_ratio. */ -blip_max_ratio = 1 << 20 }; +blip_max_ratio = 0x100000 }; /** Clears entire buffer. Afterwards, blip_samples_avail() == 0. */ void blip_clear( blip_t* ); From d53497cb32309ef83b530986bc110e03ef2d1ebd Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Oct 2016 17:06:50 -0700 Subject: [PATCH 05/56] Python: More binding skeleton --- src/platform/python/_builder.h | 16 +++++++++++++++- src/platform/python/_builder.py | 12 +++++++++++- src/platform/python/arm.py | 16 ++++++++++++++++ src/platform/python/gb.py | 5 +++++ src/platform/python/gba.py | 5 +++++ src/platform/python/lr35902.py | 5 +++++ src/platform/python/mCore.py | 20 +++++++++++++++++++- 7 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 src/platform/python/arm.py create mode 100644 src/platform/python/gb.py create mode 100644 src/platform/python/gba.py create mode 100644 src/platform/python/lr35902.py diff --git a/src/platform/python/_builder.h b/src/platform/python/_builder.h index 4c34f6f37..777b60c26 100644 --- a/src/platform/python/_builder.h +++ b/src/platform/python/_builder.h @@ -1,6 +1,20 @@ #define COMMON_H +#define extern +#define _TIME_H_ +#define _SYS_TIME_H_ #define ATTRIBUTE_FORMAT(X, Y, Z) +#define DECL_BITFIELD(newtype, oldtype) typedef oldtype newtype +#define DECL_BIT(type, name, bit) +#define DECL_BITS(type, name, bit, nbits) typedef long time_t; typedef ... va_list; #include -#include "core/core.h" \ No newline at end of file +#include "core/core.h" +#ifdef M_CORE_GBA +#include "arm/arm.h" +#include "gba/gba.h" +#endif +#ifdef M_CORE_GB +#include "lr35902/lr35902.h" +#include "gb/gb.h" +#endif diff --git a/src/platform/python/_builder.py b/src/platform/python/_builder.py index bcd0bb544..f1e389d2d 100644 --- a/src/platform/python/_builder.py +++ b/src/platform/python/_builder.py @@ -9,12 +9,22 @@ src = os.path.join(os.path.dirname(__file__), "..", "..") ffi.set_source("mgba._pylib", """ #include "util/common.h" #include "core/core.h" +#include "arm/arm.h" +#include "gba/gba.h" +#include "lr35902/lr35902.h" +#include "gb/gb.h" """, include_dirs=[src], extra_compile_args=sys.argv[1:], libraries=["mgba"], library_dirs=[os.path.join(os.getcwd(), "..")]) with open(os.path.join(os.getcwd(), "_builder.h")) as core: - ffi.cdef(core.read()) + lines = [] + for line in core: + line = line.strip() + if line.startswith('#'): + continue + lines.append(line) + ffi.cdef('\n'.join(lines)) ffi.compile() \ No newline at end of file diff --git a/src/platform/python/arm.py b/src/platform/python/arm.py new file mode 100644 index 000000000..29d27e932 --- /dev/null +++ b/src/platform/python/arm.py @@ -0,0 +1,16 @@ +from _pylib import ffi, lib + +class _ARMRegisters: + def __init__(self, cpu): + self._cpu = cpu + + def __getitem__(self, r): + if r > lib.ARM_PC: + raise IndexError("Register out of range") + return int(self._cpu._native.gprs[r]) + +class ARMCore: + def __init__(self, native): + self._native = ffi.cast("struct ARMCore*", native) + self.gprs = _ARMRegisters(self) + diff --git a/src/platform/python/gb.py b/src/platform/python/gb.py new file mode 100644 index 000000000..edcb72d5c --- /dev/null +++ b/src/platform/python/gb.py @@ -0,0 +1,5 @@ +from _pylib import ffi, lib + +class GB: + def __init__(self, native): + self._native = ffi.cast("struct GB*", native) diff --git a/src/platform/python/gba.py b/src/platform/python/gba.py new file mode 100644 index 000000000..825754836 --- /dev/null +++ b/src/platform/python/gba.py @@ -0,0 +1,5 @@ +from _pylib import ffi, lib + +class GBA: + def __init__(self, native): + self._native = ffi.cast("struct GBA*", native) diff --git a/src/platform/python/lr35902.py b/src/platform/python/lr35902.py new file mode 100644 index 000000000..eaef019cc --- /dev/null +++ b/src/platform/python/lr35902.py @@ -0,0 +1,5 @@ +from _pylib import ffi, lib + +class LR35902Core: + def __init__(self, native): + self._native = ffi.cast("struct LR35902*", native) diff --git a/src/platform/python/mCore.py b/src/platform/python/mCore.py index f9700d7df..9086a63ff 100644 --- a/src/platform/python/mCore.py +++ b/src/platform/python/mCore.py @@ -11,7 +11,15 @@ class mCore: self._core = ffi.gc(native, self._deinit) def init(self): - return bool(self._core.init(self._core)) + success = bool(self._core.init(self._core)) + if success: + if hasattr(self, 'PLATFORM_GBA') and self.platform() == self.PLATFORM_GBA: + self.cpu = ARMCore(self._core.cpu) + self.board = GBA(self._core.board) + if hasattr(self, 'PLATFORM_GB') and self.platform() == self.PLATFORM_GB: + self.cpu = LR35902Core(self._core.cpu) + self.board = GB(self._core.board) + return success def _deinit(self): self._core.deinit(self._core) @@ -45,3 +53,13 @@ class mCore: def step(self): self._core.step(self._core) + +if hasattr(lib, 'PLATFORM_GBA'): + from .gba import GBA + from .arm import ARMCore + mCore.PLATFORM_GBA = lib.PLATFORM_GBA + +if hasattr(lib, 'PLATFORM_GB'): + from .gb import GB + from .lr35902 import LR35902Core + mCore.PLATFORM_GB = lib.PLATFORM_GB \ No newline at end of file From a0b794364f55cff7d62281fe525ce1a2edd96d41 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Oct 2016 17:38:52 -0700 Subject: [PATCH 06/56] Python: More basic framework --- src/platform/python/arm.py | 23 +++++++++++------ src/platform/python/gb.py | 2 +- src/platform/python/gba.py | 2 +- src/platform/python/lr35902.py | 47 +++++++++++++++++++++++++++++++++- src/platform/python/mCore.py | 44 +++++++++++++++++++++++-------- 5 files changed, 97 insertions(+), 21 deletions(-) diff --git a/src/platform/python/arm.py b/src/platform/python/arm.py index 29d27e932..8692523d6 100644 --- a/src/platform/python/arm.py +++ b/src/platform/python/arm.py @@ -1,16 +1,23 @@ from _pylib import ffi, lib class _ARMRegisters: - def __init__(self, cpu): - self._cpu = cpu + def __init__(self, cpu): + self._cpu = cpu - def __getitem__(self, r): - if r > lib.ARM_PC: - raise IndexError("Register out of range") - return int(self._cpu._native.gprs[r]) + def __getitem__(self, r): + if r > lib.ARM_PC: + raise IndexError("Register out of range") + return self._cpu._native.gprs[r] + + def __setitem__(self, r, value): + if r >= lib.ARM_PC: + raise IndexError("Register out of range") + self._cpu._native.gprs[r] = value class ARMCore: def __init__(self, native): - self._native = ffi.cast("struct ARMCore*", native) - self.gprs = _ARMRegisters(self) + self._native = ffi.cast("struct ARMCore*", native) + self.gprs = _ARMRegisters(self) + self.cpsr = self._native.cpsr + self.spsr = self._native.spsr diff --git a/src/platform/python/gb.py b/src/platform/python/gb.py index edcb72d5c..8184ad30e 100644 --- a/src/platform/python/gb.py +++ b/src/platform/python/gb.py @@ -2,4 +2,4 @@ from _pylib import ffi, lib class GB: def __init__(self, native): - self._native = ffi.cast("struct GB*", native) + self._native = ffi.cast("struct GB*", native) diff --git a/src/platform/python/gba.py b/src/platform/python/gba.py index 825754836..709e85b2d 100644 --- a/src/platform/python/gba.py +++ b/src/platform/python/gba.py @@ -2,4 +2,4 @@ from _pylib import ffi, lib class GBA: def __init__(self, native): - self._native = ffi.cast("struct GBA*", native) + self._native = ffi.cast("struct GBA*", native) diff --git a/src/platform/python/lr35902.py b/src/platform/python/lr35902.py index eaef019cc..8272e37a5 100644 --- a/src/platform/python/lr35902.py +++ b/src/platform/python/lr35902.py @@ -2,4 +2,49 @@ from _pylib import ffi, lib class LR35902Core: def __init__(self, native): - self._native = ffi.cast("struct LR35902*", native) + self._native = ffi.cast("struct LR35902Core*", native) + + def __getattr__(self, key): + if key == 'a': + return self._native.a + if key == 'b': + return self._native.b + if key == 'c': + return self._native.c + if key == 'd': + return self._native.d + if key == 'e': + return self._native.e + if key == 'f': + return self._native.f + if key == 'h': + return self._native.h + if key == 'l': + return self._native.l + if key == 'sp': + return self._native.sp + if key == 'pc': + return self._native.pc + raise AttributeError() + + def __setattr__(self, key, value): + if key == 'a': + self._native.a = value & 0xF0 + if key == 'b': + self._native.b = value + if key == 'c': + self._native.c = value + if key == 'd': + self._native.d = value + if key == 'e': + self._native.e = value + if key == 'f': + self._native.f = value + if key == 'h': + self._native.h = value + if key == 'l': + self._native.l = value + if key == 'sp': + self._native.sp = value + else: + self.__dict__[key] = value \ No newline at end of file diff --git a/src/platform/python/mCore.py b/src/platform/python/mCore.py index 9086a63ff..2339dd91a 100644 --- a/src/platform/python/mCore.py +++ b/src/platform/python/mCore.py @@ -6,20 +6,25 @@ def find(path): return None return mCore(core) +def loadPath(path): + core = find(path) + if not core or not core.loadFile(path): + return None + return core + class mCore: def __init__(self, native): self._core = ffi.gc(native, self._deinit) - - def init(self): success = bool(self._core.init(self._core)) - if success: - if hasattr(self, 'PLATFORM_GBA') and self.platform() == self.PLATFORM_GBA: - self.cpu = ARMCore(self._core.cpu) - self.board = GBA(self._core.board) - if hasattr(self, 'PLATFORM_GB') and self.platform() == self.PLATFORM_GB: - self.cpu = LR35902Core(self._core.cpu) - self.board = GB(self._core.board) - return success + if not success: + raise RuntimeError("Failed to initialize core") + + if hasattr(self, 'PLATFORM_GBA') and self.platform() == self.PLATFORM_GBA: + self.cpu = ARMCore(self._core.cpu) + self.board = GBA(self._core.board) + if hasattr(self, 'PLATFORM_GB') and self.platform() == self.PLATFORM_GB: + self.cpu = LR35902Core(self._core.cpu) + self.board = GB(self._core.board) def _deinit(self): self._core.deinit(self._core) @@ -54,6 +59,25 @@ class mCore: def step(self): self._core.step(self._core) + def frameCounter(self): + return self._core.frameCounter(self._core) + + def frameCycles(self): + return self._core.frameCycles(self._core) + + def frequency(self): + return self._core.frequency(self._core) + + def getGameTitle(self): + title = ffi.new("char[16]") + self._core.getGameTitle(self._core, title) + return ffi.string(title, 16).decode("ascii") + + def getGameCode(self): + code = ffi.new("char[12]") + self._core.getGameCode(self._core, code) + return ffi.string(code, 12).decode("ascii") + if hasattr(lib, 'PLATFORM_GBA'): from .gba import GBA from .arm import ARMCore From 99a85aaf3aaef60af2a768a1ee35a449a655ba75 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Oct 2016 21:26:20 -0700 Subject: [PATCH 07/56] Debugger: Fix build --- src/arm/debugger/debugger.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/arm/debugger/debugger.h b/src/arm/debugger/debugger.h index aaedfc0fc..a7aca430e 100644 --- a/src/arm/debugger/debugger.h +++ b/src/arm/debugger/debugger.h @@ -5,6 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "debugger/debugger.h" +#include "arm/arm.h" + struct ARMDebugBreakpoint { uint32_t address; bool isSw; From 0d1d5c988e2f60abb5c05a8cd61bdd9ec16d94f1 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 13 Oct 2016 23:02:01 -0700 Subject: [PATCH 08/56] Python: Basic setup.py --- src/platform/python/CMakeLists.txt | 18 +++++++++++++----- src/platform/python/{ => mgba}/__init__.py | 0 src/platform/python/{ => mgba}/arm.py | 0 src/platform/python/{mCore.py => mgba/core.py} | 8 ++++---- src/platform/python/{ => mgba}/gb.py | 0 src/platform/python/{ => mgba}/gba.py | 0 src/platform/python/{ => mgba}/lr35902.py | 0 src/platform/python/setup.py.in | 18 ++++++++++++++++++ 8 files changed, 35 insertions(+), 9 deletions(-) rename src/platform/python/{ => mgba}/__init__.py (100%) rename src/platform/python/{ => mgba}/arm.py (100%) rename src/platform/python/{mCore.py => mgba/core.py} (95%) rename src/platform/python/{ => mgba}/gb.py (100%) rename src/platform/python/{ => mgba}/gba.py (100%) rename src/platform/python/{ => mgba}/lr35902.py (100%) create mode 100644 src/platform/python/setup.py.in diff --git a/src/platform/python/CMakeLists.txt b/src/platform/python/CMakeLists.txt index cd30b551f..b4ccc216f 100644 --- a/src/platform/python/CMakeLists.txt +++ b/src/platform/python/CMakeLists.txt @@ -8,13 +8,21 @@ foreach(COMPILE_DEF IN LISTS COMPILE_DEFINITIONS) list(APPEND PY_COMPILE_DEFS -D${COMPILE_DEF}) endforeach() +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py) + add_custom_command(OUTPUT _builder.h COMMAND ${CMAKE_C_COMPILER} ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} -fno-inline -E -P -c ${CMAKE_CURRENT_SOURCE_DIR}/_builder.h -o _builder.h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.h) add_custom_target(_builder.h ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_builder.h) -add_custom_command(OUTPUT ${BINARY_NAME}/_pylib.so - COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_builder.h) -add_custom_target(_pylib.so ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}/_pylib.so) \ No newline at end of file +add_custom_target(${BINARY_NAME}-pylib COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py + DEPENDS _builder.h) + +add_custom_command(OUTPUT ${BINARY_NAME}/__init__.py + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${BINARY_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME} + COMMAND python ${CMAKE_CURRENT_BINARY_DIR}/setup.py build + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/setup.py + DEPENDS ${BINARY_NAME}-pylib) + +add_custom_target(${BINARY_NAME}-py ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}/__init__.py) diff --git a/src/platform/python/__init__.py b/src/platform/python/mgba/__init__.py similarity index 100% rename from src/platform/python/__init__.py rename to src/platform/python/mgba/__init__.py diff --git a/src/platform/python/arm.py b/src/platform/python/mgba/arm.py similarity index 100% rename from src/platform/python/arm.py rename to src/platform/python/mgba/arm.py diff --git a/src/platform/python/mCore.py b/src/platform/python/mgba/core.py similarity index 95% rename from src/platform/python/mCore.py rename to src/platform/python/mgba/core.py index 2339dd91a..88d08bc09 100644 --- a/src/platform/python/mCore.py +++ b/src/platform/python/mgba/core.py @@ -4,7 +4,7 @@ def find(path): core = lib.mCoreFind(path.encode('UTF-8')) if core == ffi.NULL: return None - return mCore(core) + return Core(core) def loadPath(path): core = find(path) @@ -12,7 +12,7 @@ def loadPath(path): return None return core -class mCore: +class Core: def __init__(self, native): self._core = ffi.gc(native, self._deinit) success = bool(self._core.init(self._core)) @@ -81,9 +81,9 @@ class mCore: if hasattr(lib, 'PLATFORM_GBA'): from .gba import GBA from .arm import ARMCore - mCore.PLATFORM_GBA = lib.PLATFORM_GBA + Core.PLATFORM_GBA = lib.PLATFORM_GBA if hasattr(lib, 'PLATFORM_GB'): from .gb import GB from .lr35902 import LR35902Core - mCore.PLATFORM_GB = lib.PLATFORM_GB \ No newline at end of file + Core.PLATFORM_GB = lib.PLATFORM_GB \ No newline at end of file diff --git a/src/platform/python/gb.py b/src/platform/python/mgba/gb.py similarity index 100% rename from src/platform/python/gb.py rename to src/platform/python/mgba/gb.py diff --git a/src/platform/python/gba.py b/src/platform/python/mgba/gba.py similarity index 100% rename from src/platform/python/gba.py rename to src/platform/python/mgba/gba.py diff --git a/src/platform/python/lr35902.py b/src/platform/python/mgba/lr35902.py similarity index 100% rename from src/platform/python/lr35902.py rename to src/platform/python/mgba/lr35902.py diff --git a/src/platform/python/setup.py.in b/src/platform/python/setup.py.in new file mode 100644 index 000000000..857c91fd7 --- /dev/null +++ b/src/platform/python/setup.py.in @@ -0,0 +1,18 @@ +from setuptools import setup + +classifiers = [ + "Programming Language :: Python :: 2", +# "Programming Language :: Python :: 3", + "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)" +] + + +setup(name="${BINARY_NAME}", + version="${VERSION_STRING}", + author="Jeffrey Pfau", + author_email="jeffrey@endrift.com", + url="http://github.com/mgba-emu/mgba/", + packages=["mgba"], + license="MPL 2.0", + classifiers=classifiers + ) \ No newline at end of file From 606d35ba6cc6170f200dde15ba5c839a9c553474 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 14 Oct 2016 15:30:40 -0700 Subject: [PATCH 09/56] Python: Add VFS bindings --- src/platform/python/_builder.h | 5 +- src/platform/python/_builder.py | 11 ++- src/platform/python/mgba/core.py | 18 +++++ src/platform/python/mgba/vfs.py | 126 +++++++++++++++++++++++++++++++ src/platform/python/setup.py.in | 4 +- src/platform/python/vfs-py.c | 46 +++++++++++ src/platform/python/vfs-py.h | 28 +++++++ src/util/vfs.h | 7 +- 8 files changed, 238 insertions(+), 7 deletions(-) create mode 100644 src/platform/python/mgba/vfs.py create mode 100644 src/platform/python/vfs-py.c create mode 100644 src/platform/python/vfs-py.h diff --git a/src/platform/python/_builder.h b/src/platform/python/_builder.h index 777b60c26..ace007289 100644 --- a/src/platform/python/_builder.h +++ b/src/platform/python/_builder.h @@ -1,14 +1,15 @@ #define COMMON_H -#define extern #define _TIME_H_ #define _SYS_TIME_H_ #define ATTRIBUTE_FORMAT(X, Y, Z) #define DECL_BITFIELD(newtype, oldtype) typedef oldtype newtype #define DECL_BIT(type, name, bit) #define DECL_BITS(type, name, bit, nbits) -typedef long time_t; +typedef int... time_t; +typedef int... off_t; typedef ... va_list; #include +#include "platform/python/vfs-py.h" #include "core/core.h" #ifdef M_CORE_GBA #include "arm/arm.h" diff --git a/src/platform/python/_builder.py b/src/platform/python/_builder.py index f1e389d2d..6a59604ae 100644 --- a/src/platform/python/_builder.py +++ b/src/platform/python/_builder.py @@ -13,10 +13,19 @@ ffi.set_source("mgba._pylib", """ #include "gba/gba.h" #include "lr35902/lr35902.h" #include "gb/gb.h" +#include "util/vfs.h" + +struct VFile* VFileFromPython(void* fileobj); + +struct VFilePy { + struct VFile d; + void* fileobj; +}; """, include_dirs=[src], extra_compile_args=sys.argv[1:], libraries=["mgba"], - library_dirs=[os.path.join(os.getcwd(), "..")]) + library_dirs=[os.path.join(os.getcwd(), "..")], + sources=[os.path.join(os.path.dirname(__file__), path) for path in ["vfs-py.c"]]) with open(os.path.join(os.getcwd(), "_builder.h")) as core: lines = [] diff --git a/src/platform/python/mgba/core.py b/src/platform/python/mgba/core.py index 88d08bc09..57c8824fd 100644 --- a/src/platform/python/mgba/core.py +++ b/src/platform/python/mgba/core.py @@ -6,12 +6,24 @@ def find(path): return None return Core(core) +def findVF(vf): + core = lib.mCoreFindVF(vf.handle()) + if core == ffi.NULL: + return None + return Core(core) + def loadPath(path): core = find(path) if not core or not core.loadFile(path): return None return core +def loadVF(vf): + core = findVF(vf) + if not core or not core.loadROM(vf): + return None + return core + class Core: def __init__(self, native): self._core = ffi.gc(native, self._deinit) @@ -32,6 +44,12 @@ class Core: def loadFile(self, path): return bool(lib.mCoreLoadFile(self._core, path.encode('UTF-8'))) + def isROM(self, vf): + return bool(self._core.isROM(vf.handle())) + + def loadROM(self, vf): + return bool(self._core.loadROM(self._core, vf.handle())) + def autoloadSave(self): return bool(lib.mCoreAutoloadSave(self._core)) diff --git a/src/platform/python/mgba/vfs.py b/src/platform/python/mgba/vfs.py new file mode 100644 index 000000000..b73d2004c --- /dev/null +++ b/src/platform/python/mgba/vfs.py @@ -0,0 +1,126 @@ +from _pylib import ffi, lib +import mmap +import os + +@ffi.def_extern() +def _vfpClose(vf): + vfp = ffi.cast("struct VFilePy*", vf) + ffi.from_handle(vfp.fileobj).close() + +@ffi.def_extern() +def _vfpSeek(vf, offset, whence): + vfp = ffi.cast("struct VFilePy*", vf) + f = ffi.from_handle(vfp.fileobj) + f.seek(offset, whence) + return f.tell() + +@ffi.def_extern() +def _vfpRead(vf, buffer, size): + vfp = ffi.cast("struct VFilePy*", vf) + pybuf = ffi.buffer(buffer, size) + return ffi.from_handle(vfp.fileobj).readinto(pybuf) + +@ffi.def_extern() +def _vfpWrite(vf, buffer, size): + vfp = ffi.cast("struct VFilePy*", vf) + pybuf = ffi.buffer(buffer, size) + return ffi.from_handle(vfp.fileobj).write(pybuf) + +@ffi.def_extern() +def _vfpMap(vf, size, flags): + pass + +@ffi.def_extern() +def _vfpUnmap(vf, memory, size): + pass + +@ffi.def_extern() +def _vfpTruncate(vf, size): + vfp = ffi.cast("struct VFilePy*", vf) + ffi.from_handle(vfp.fileobj).truncate(size) + +@ffi.def_extern() +def _vfpSize(vf): + vfp = ffi.cast("struct VFilePy*", vf) + f = ffi.from_handle(vfp.fileobj) + pos = f.tell() + f.seek(0, os.SEEK_END) + size = f.tell() + f.seek(pos, os.SEEK_SET) + return size + +@ffi.def_extern() +def _vfpSync(vf, buffer, size): + vfp = ffi.cast("struct VFilePy*", vf) + f = ffi.from_handle(vfp.fileobj) + if buffer and size: + pos = f.tell() + f.seek(0, os.SEEK_SET) + _vfpWrite(vf, buffer, size) + f.seek(pos, os.SEEK_SET) + f.flush() + os.fsync() + return True + +def open(f): + handle = ffi.new_handle(f) + vf = VFile(lib.VFileFromPython(handle)) + # Prevent garbage collection + vf._fileobj = f + vf._handle = handle + return vf + +def openPath(path, mode="r"): + flags = 0 + if mode.startswith("r"): + flags |= os.O_RDONLY + elif mode.startswith("w"): + flags |= os.O_WRONLY | os.O_CREAT | os.O_TRUNC + elif mode.startswith("a"): + flags |= os.O_WRONLY | os.O_CREAT | os.O_APPEND + else: + return None + + if "+" in mode[1:]: + flags |= os.O_RDWR + if "x" in mode[1:]: + flags |= os.O_EXCL + + return VFile(lib.VFileOpen(path.encode("UTF-8"), flags)) + +class VFile: + def __init__(self, vf): + self._vf = vf + + def handle(self): + return self._vf + + def close(self): + return self._vf.close(self._vf) + + def seek(self, offset, whence): + return self._vf.seek(self._vf, offset, whence) + + def read(self, buffer, size): + return self._vf.read(self._vf, buffer, size) + + def readline(self, buffer, size): + return self._vf.readline(self._vf, buffer, size) + + def write(self, buffer, size): + return self._vf.write(self._vf, buffer, size) + + def map(self, size, flags): + return self._vf.map(self._vf, size, flags) + + def unmap(self, memory, size): + self._vf.unmap(self._vf, memory, size) + + def truncate(self, size): + self._vf.truncate(self._vf, size) + + def size(self): + return self._vf.size(self._vf) + + def sync(self, buffer, size): + return self._vf.sync(self._vf, buffer, size) diff --git a/src/platform/python/setup.py.in b/src/platform/python/setup.py.in index 857c91fd7..133474831 100644 --- a/src/platform/python/setup.py.in +++ b/src/platform/python/setup.py.in @@ -1,4 +1,5 @@ from setuptools import setup +import re classifiers = [ "Programming Language :: Python :: 2", @@ -6,9 +7,8 @@ classifiers = [ "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)" ] - setup(name="${BINARY_NAME}", - version="${VERSION_STRING}", + version=re.sub("/", "-", "${VERSION_STRING}"), author="Jeffrey Pfau", author_email="jeffrey@endrift.com", url="http://github.com/mgba-emu/mgba/", diff --git a/src/platform/python/vfs-py.c b/src/platform/python/vfs-py.c new file mode 100644 index 000000000..51b1f182b --- /dev/null +++ b/src/platform/python/vfs-py.c @@ -0,0 +1,46 @@ +/* Copyright (c) 2013-2016 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "util/vfs.h" + +struct VFilePy { + struct VFile d; + void* fileobj; +}; + +bool _vfpClose(struct VFile* vf); +off_t _vfpSeek(struct VFile* vf, off_t offset, int whence); +ssize_t _vfpRead(struct VFile* vf, void* buffer, size_t size); +ssize_t _vfpWrite(struct VFile* vf, const void* buffer, size_t size); +void* _vfpMap(struct VFile* vf, size_t size, int flags); +void _vfpUnmap(struct VFile* vf, void* memory, size_t size); +void _vfpTruncate(struct VFile* vf, size_t size); +ssize_t _vfpSize(struct VFile* vf); +bool _vfpSync(struct VFile* vf, const void* buffer, size_t size); + +struct VFile* VFileFromPython(void* fileobj) { + if (!fileobj) { + return 0; + } + + struct VFilePy* vfp = malloc(sizeof(struct VFilePy)); + if (!vfp) { + return 0; + } + + vfp->fileobj = fileobj; + vfp->d.close = _vfpClose; + vfp->d.seek = _vfpSeek; + vfp->d.read = _vfpRead; + vfp->d.readline = VFileReadline; + vfp->d.write = _vfpWrite; + vfp->d.map = _vfpMap; + vfp->d.unmap = _vfpUnmap; + vfp->d.truncate = _vfpTruncate; + vfp->d.size = _vfpSize; + vfp->d.sync = _vfpSync; + + return &vfp->d; +} diff --git a/src/platform/python/vfs-py.h b/src/platform/python/vfs-py.h new file mode 100644 index 000000000..82a5ac0cf --- /dev/null +++ b/src/platform/python/vfs-py.h @@ -0,0 +1,28 @@ +/* Copyright (c) 2013-2016 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "util/vfs.h" + +struct VFilePy { + struct VFile d; + void* fileobj; +}; + +struct VFile* VFileFromPython(void* fileobj); + +extern "Python+C" { + +bool _vfpClose(struct VFile* vf); +off_t _vfpSeek(struct VFile* vf, off_t offset, int whence); +ssize_t _vfpRead(struct VFile* vf, void* buffer, size_t size); +ssize_t _vfpWrite(struct VFile* vf, const void* buffer, size_t size); +void* _vfpMap(struct VFile* vf, size_t size, int flags); +void _vfpUnmap(struct VFile* vf, void* memory, size_t size); +void _vfpTruncate(struct VFile* vf, size_t size); +ssize_t _vfpSize(struct VFile* vf); +bool _vfpSync(struct VFile* vf, const void* buffer, size_t size); + +} \ No newline at end of file diff --git a/src/util/vfs.h b/src/util/vfs.h index 19c71da92..398372887 100644 --- a/src/util/vfs.h +++ b/src/util/vfs.h @@ -65,12 +65,11 @@ struct VDir { struct VFile* VFileOpen(const char* path, int flags); struct VFile* VFileOpenFD(const char* path, int flags); -struct VFile* VFileFOpen(const char* path, const char* mode); struct VFile* VFileFromFD(int fd); + struct VFile* VFileFromMemory(void* mem, size_t size); struct VFile* VFileFromConstMemory(const void* mem, size_t size); struct VFile* VFileMemChunk(const void* mem, size_t size); -struct VFile* VFileFromFILE(FILE* file); struct VDir* VDirOpen(const char* path); struct VDir* VDirOpenArchive(const char* path); @@ -83,7 +82,11 @@ struct VDir* VDirOpenZip(const char* path, int flags); struct VDir* VDirOpen7z(const char* path, int flags); #endif +#if defined(WII) || defined(_3DS) +struct VFile* VFileFOpen(const char* path, const char* mode); +struct VFile* VFileFromFILE(FILE* file); struct VDir* VDeviceList(void); +#endif void separatePath(const char* path, char* dirname, char* basename, char* extension); From f06d0c8a06af25ea836735231803888e84d1b84c Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 14 Oct 2016 15:32:17 -0700 Subject: [PATCH 10/56] All: Ignore *.pyc --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2241cd0aa..37cb57e2d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.user* *~ *.swp +*.pyc From 511261b0ffbac7af94d5c33c17f255b74003da5c Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 14 Oct 2016 16:47:09 -0700 Subject: [PATCH 11/56] Python: Add license headers --- src/platform/python/mgba/arm.py | 5 +++++ src/platform/python/mgba/core.py | 5 +++++ src/platform/python/mgba/gb.py | 5 +++++ src/platform/python/mgba/gba.py | 5 +++++ src/platform/python/mgba/lr35902.py | 5 +++++ 5 files changed, 25 insertions(+) diff --git a/src/platform/python/mgba/arm.py b/src/platform/python/mgba/arm.py index 8692523d6..48878fc81 100644 --- a/src/platform/python/mgba/arm.py +++ b/src/platform/python/mgba/arm.py @@ -1,3 +1,8 @@ +# Copyright (c) 2013-2016 Jeffrey Pfau +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. from _pylib import ffi, lib class _ARMRegisters: diff --git a/src/platform/python/mgba/core.py b/src/platform/python/mgba/core.py index 57c8824fd..d031d8439 100644 --- a/src/platform/python/mgba/core.py +++ b/src/platform/python/mgba/core.py @@ -1,3 +1,8 @@ +# Copyright (c) 2013-2016 Jeffrey Pfau +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. from _pylib import ffi, lib def find(path): diff --git a/src/platform/python/mgba/gb.py b/src/platform/python/mgba/gb.py index 8184ad30e..8754a4476 100644 --- a/src/platform/python/mgba/gb.py +++ b/src/platform/python/mgba/gb.py @@ -1,3 +1,8 @@ +# Copyright (c) 2013-2016 Jeffrey Pfau +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. from _pylib import ffi, lib class GB: diff --git a/src/platform/python/mgba/gba.py b/src/platform/python/mgba/gba.py index 709e85b2d..9f8bd0a49 100644 --- a/src/platform/python/mgba/gba.py +++ b/src/platform/python/mgba/gba.py @@ -1,3 +1,8 @@ +# Copyright (c) 2013-2016 Jeffrey Pfau +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. from _pylib import ffi, lib class GBA: diff --git a/src/platform/python/mgba/lr35902.py b/src/platform/python/mgba/lr35902.py index 8272e37a5..3766eeaf8 100644 --- a/src/platform/python/mgba/lr35902.py +++ b/src/platform/python/mgba/lr35902.py @@ -1,3 +1,8 @@ +# Copyright (c) 2013-2016 Jeffrey Pfau +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. from _pylib import ffi, lib class LR35902Core: From f5312fef786ec0dcad9646fe272bbefd52daa5ff Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 14 Oct 2016 17:50:47 -0700 Subject: [PATCH 12/56] Python: VFS fixes --- src/platform/python/mgba/core.py | 6 +++--- src/platform/python/mgba/vfs.py | 36 ++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/platform/python/mgba/core.py b/src/platform/python/mgba/core.py index d031d8439..b3887d980 100644 --- a/src/platform/python/mgba/core.py +++ b/src/platform/python/mgba/core.py @@ -12,7 +12,7 @@ def find(path): return Core(core) def findVF(vf): - core = lib.mCoreFindVF(vf.handle()) + core = lib.mCoreFindVF(vf.handle) if core == ffi.NULL: return None return Core(core) @@ -50,10 +50,10 @@ class Core: return bool(lib.mCoreLoadFile(self._core, path.encode('UTF-8'))) def isROM(self, vf): - return bool(self._core.isROM(vf.handle())) + return bool(self._core.isROM(vf.handle)) def loadROM(self, vf): - return bool(self._core.loadROM(self._core, vf.handle())) + return bool(self._core.loadROM(self._core, vf.handle)) def autoloadSave(self): return bool(lib.mCoreAutoloadSave(self._core)) diff --git a/src/platform/python/mgba/vfs.py b/src/platform/python/mgba/vfs.py index b73d2004c..1f1d0f8aa 100644 --- a/src/platform/python/mgba/vfs.py +++ b/src/platform/python/mgba/vfs.py @@ -1,3 +1,8 @@ +# Copyright (c) 2013-2016 Jeffrey Pfau +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. from _pylib import ffi, lib import mmap import os @@ -18,13 +23,15 @@ def _vfpSeek(vf, offset, whence): def _vfpRead(vf, buffer, size): vfp = ffi.cast("struct VFilePy*", vf) pybuf = ffi.buffer(buffer, size) - return ffi.from_handle(vfp.fileobj).readinto(pybuf) + ffi.from_handle(vfp.fileobj).readinto(pybuf) + return size @ffi.def_extern() def _vfpWrite(vf, buffer, size): vfp = ffi.cast("struct VFilePy*", vf) pybuf = ffi.buffer(buffer, size) - return ffi.from_handle(vfp.fileobj).write(pybuf) + ffi.from_handle(vfp.fileobj).write(pybuf) + return size @ffi.def_extern() def _vfpMap(vf, size, flags): @@ -90,37 +97,34 @@ def openPath(path, mode="r"): class VFile: def __init__(self, vf): - self._vf = vf - - def handle(self): - return self._vf + self.handle = vf def close(self): - return self._vf.close(self._vf) + return self.handle.close(self.handle) def seek(self, offset, whence): - return self._vf.seek(self._vf, offset, whence) + return self.handle.seek(self.handle, offset, whence) def read(self, buffer, size): - return self._vf.read(self._vf, buffer, size) + return self.handle.read(self.handle, buffer, size) def readline(self, buffer, size): - return self._vf.readline(self._vf, buffer, size) + return self.handle.readline(self.handle, buffer, size) def write(self, buffer, size): - return self._vf.write(self._vf, buffer, size) + return self.handle.write(self.handle, buffer, size) def map(self, size, flags): - return self._vf.map(self._vf, size, flags) + return self.handle.map(self.handle, size, flags) def unmap(self, memory, size): - self._vf.unmap(self._vf, memory, size) + self.handle.unmap(self.handle, memory, size) def truncate(self, size): - self._vf.truncate(self._vf, size) + self.handle.truncate(self.handle, size) def size(self): - return self._vf.size(self._vf) + return self.handle.size(self.handle) def sync(self, buffer, size): - return self._vf.sync(self._vf, buffer, size) + return self.handle.sync(self.handle, buffer, size) From 0723646354a46d5ad6ef33089af288684f350b41 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 14 Oct 2016 17:51:24 -0700 Subject: [PATCH 13/56] Python: Add image and PNG-write bindings --- src/platform/python/CMakeLists.txt | 2 +- src/platform/python/_builder.h | 16 ++++++++++++++-- src/platform/python/_builder.py | 1 + src/platform/python/mgba/core.py | 3 +++ src/platform/python/mgba/image.py | 26 ++++++++++++++++++++++++++ src/platform/python/mgba/png.py | 24 ++++++++++++++++++++++++ 6 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 src/platform/python/mgba/image.py create mode 100644 src/platform/python/mgba/png.py diff --git a/src/platform/python/CMakeLists.txt b/src/platform/python/CMakeLists.txt index b4ccc216f..4945a793c 100644 --- a/src/platform/python/CMakeLists.txt +++ b/src/platform/python/CMakeLists.txt @@ -4,7 +4,7 @@ get_property(COMPILE_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY COMPILE_ foreach(INCLUDE_DIR IN LISTS INCLUDE_DIRECTORIES) list(APPEND PY_INCLUDE_DIRS -I${INCLUDE_DIR}) endforeach() -foreach(COMPILE_DEF IN LISTS COMPILE_DEFINITIONS) +foreach(COMPILE_DEF IN LISTS COMPILE_DEFINITIONS FEATURE_DEFINES) list(APPEND PY_COMPILE_DEFS -D${COMPILE_DEF}) endforeach() diff --git a/src/platform/python/_builder.h b/src/platform/python/_builder.h index ace007289..a58cb6dad 100644 --- a/src/platform/python/_builder.h +++ b/src/platform/python/_builder.h @@ -1,16 +1,28 @@ #define COMMON_H -#define _TIME_H_ +#define PNG_H #define _SYS_TIME_H_ +#define _TIME_H_ + #define ATTRIBUTE_FORMAT(X, Y, Z) #define DECL_BITFIELD(newtype, oldtype) typedef oldtype newtype #define DECL_BIT(type, name, bit) #define DECL_BITS(type, name, bit, nbits) + typedef int... time_t; typedef int... off_t; typedef ... va_list; +typedef ...* png_structp; +typedef ...* png_infop; +typedef ...* png_unknown_chunkp; + #include -#include "platform/python/vfs-py.h" + #include "core/core.h" +#include "platform/python/vfs-py.h" + +#ifdef USE_PNG +#include "util/png-io.h" +#endif #ifdef M_CORE_GBA #include "arm/arm.h" #include "gba/gba.h" diff --git a/src/platform/python/_builder.py b/src/platform/python/_builder.py index 6a59604ae..0394069e9 100644 --- a/src/platform/python/_builder.py +++ b/src/platform/python/_builder.py @@ -13,6 +13,7 @@ ffi.set_source("mgba._pylib", """ #include "gba/gba.h" #include "lr35902/lr35902.h" #include "gb/gb.h" +#include "util/png-io.h" #include "util/vfs.h" struct VFile* VFileFromPython(void* fileobj); diff --git a/src/platform/python/mgba/core.py b/src/platform/python/mgba/core.py index b3887d980..8e2350813 100644 --- a/src/platform/python/mgba/core.py +++ b/src/platform/python/mgba/core.py @@ -70,6 +70,9 @@ class Core: self._core.desiredVideoDimensions(self._core, width, height) return width[0], height[0] + def setVideoBuffer(self, image): + self._core.setVideoBuffer(self._core, image.buffer, image.stride) + def reset(self): self._core.reset(self._core) diff --git a/src/platform/python/mgba/image.py b/src/platform/python/mgba/image.py new file mode 100644 index 000000000..ded9de9c6 --- /dev/null +++ b/src/platform/python/mgba/image.py @@ -0,0 +1,26 @@ +# Copyright (c) 2013-2016 Jeffrey Pfau +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +from _pylib import ffi, lib +from . import png + +class Image: + def __init__(self, width, height, stride=0): + self.width = width + self.height = height + self.stride = stride + self.constitute() + + def constitute(self): + if self.stride <= 0: + self.stride = self.width + self.buffer = ffi.new("color_t[{}]".format(self.stride * self.height)) + + def savePNG(self, f): + p = png.PNG(f) + success = p.writeHeader(self) + success = success and p.writePixels(self) + p.writeClose() + return success \ No newline at end of file diff --git a/src/platform/python/mgba/png.py b/src/platform/python/mgba/png.py new file mode 100644 index 000000000..75be631fb --- /dev/null +++ b/src/platform/python/mgba/png.py @@ -0,0 +1,24 @@ +# Copyright (c) 2013-2016 Jeffrey Pfau +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +from _pylib import ffi, lib +from . import vfs + +class PNG: + def __init__(self, f): + self.vf = vfs.open(f) + + def writeHeader(self, image): + self._png = lib.PNGWriteOpen(self.vf.handle) + self._info = lib.PNGWriteHeader(self._png, image.width, image.height) + return self._info != ffi.NULL + + def writePixels(self, image): + return lib.PNGWritePixels(self._png, image.width, image.height, image.stride, image.buffer) + + def writeClose(self): + lib.PNGWriteClose(self._png, self._info) + del self._png + del self._info \ No newline at end of file From 33295b129779e8e5e6d8b15829b5fdc0b07e421f Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 15 Oct 2016 00:44:56 -0700 Subject: [PATCH 14/56] Python: Python 3 support --- src/platform/python/CMakeLists.txt | 6 ++++-- src/platform/python/mgba/arm.py | 2 +- src/platform/python/mgba/core.py | 4 ++-- src/platform/python/mgba/gb.py | 2 +- src/platform/python/mgba/gba.py | 2 +- src/platform/python/mgba/image.py | 4 ++-- src/platform/python/mgba/lr35902.py | 4 ++-- src/platform/python/mgba/png.py | 4 ++-- src/platform/python/mgba/vfs.py | 2 +- src/platform/python/setup.py.in | 4 +++- 10 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/platform/python/CMakeLists.txt b/src/platform/python/CMakeLists.txt index 4945a793c..4a56b1474 100644 --- a/src/platform/python/CMakeLists.txt +++ b/src/platform/python/CMakeLists.txt @@ -1,3 +1,5 @@ +find_program(PYTHON python) + set(PY_INCLUDE_DIRS -I${CMAKE_SOURCE_DIR}/src) get_property(INCLUDE_DIRECTORIES DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) get_property(COMPILE_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS) @@ -15,13 +17,13 @@ add_custom_command(OUTPUT _builder.h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.h) add_custom_target(_builder.h ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_builder.h) -add_custom_target(${BINARY_NAME}-pylib COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} +add_custom_target(${BINARY_NAME}-pylib COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py DEPENDS _builder.h) add_custom_command(OUTPUT ${BINARY_NAME}/__init__.py COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${BINARY_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME} - COMMAND python ${CMAKE_CURRENT_BINARY_DIR}/setup.py build + COMMAND ${PYTHON} ${CMAKE_CURRENT_BINARY_DIR}/setup.py build DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/setup.py DEPENDS ${BINARY_NAME}-pylib) diff --git a/src/platform/python/mgba/arm.py b/src/platform/python/mgba/arm.py index 48878fc81..a594a6823 100644 --- a/src/platform/python/mgba/arm.py +++ b/src/platform/python/mgba/arm.py @@ -3,7 +3,7 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib class _ARMRegisters: def __init__(self, cpu): diff --git a/src/platform/python/mgba/core.py b/src/platform/python/mgba/core.py index 8e2350813..10b0ccd5d 100644 --- a/src/platform/python/mgba/core.py +++ b/src/platform/python/mgba/core.py @@ -3,7 +3,7 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib def find(path): core = lib.mCoreFind(path.encode('UTF-8')) @@ -31,7 +31,7 @@ def loadVF(vf): class Core: def __init__(self, native): - self._core = ffi.gc(native, self._deinit) + self._core = ffi.gc(native, native.deinit) success = bool(self._core.init(self._core)) if not success: raise RuntimeError("Failed to initialize core") diff --git a/src/platform/python/mgba/gb.py b/src/platform/python/mgba/gb.py index 8754a4476..1d141e966 100644 --- a/src/platform/python/mgba/gb.py +++ b/src/platform/python/mgba/gb.py @@ -3,7 +3,7 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib class GB: def __init__(self, native): diff --git a/src/platform/python/mgba/gba.py b/src/platform/python/mgba/gba.py index 9f8bd0a49..a425c5b42 100644 --- a/src/platform/python/mgba/gba.py +++ b/src/platform/python/mgba/gba.py @@ -3,7 +3,7 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib class GBA: def __init__(self, native): diff --git a/src/platform/python/mgba/image.py b/src/platform/python/mgba/image.py index ded9de9c6..907077433 100644 --- a/src/platform/python/mgba/image.py +++ b/src/platform/python/mgba/image.py @@ -3,7 +3,7 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib from . import png class Image: @@ -23,4 +23,4 @@ class Image: success = p.writeHeader(self) success = success and p.writePixels(self) p.writeClose() - return success \ No newline at end of file + return success diff --git a/src/platform/python/mgba/lr35902.py b/src/platform/python/mgba/lr35902.py index 3766eeaf8..6c1ffcddb 100644 --- a/src/platform/python/mgba/lr35902.py +++ b/src/platform/python/mgba/lr35902.py @@ -3,7 +3,7 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib class LR35902Core: def __init__(self, native): @@ -52,4 +52,4 @@ class LR35902Core: if key == 'sp': self._native.sp = value else: - self.__dict__[key] = value \ No newline at end of file + self.__dict__[key] = value diff --git a/src/platform/python/mgba/png.py b/src/platform/python/mgba/png.py index 75be631fb..bc1ff836c 100644 --- a/src/platform/python/mgba/png.py +++ b/src/platform/python/mgba/png.py @@ -3,7 +3,7 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib from . import vfs class PNG: @@ -21,4 +21,4 @@ class PNG: def writeClose(self): lib.PNGWriteClose(self._png, self._info) del self._png - del self._info \ No newline at end of file + del self._info diff --git a/src/platform/python/mgba/vfs.py b/src/platform/python/mgba/vfs.py index 1f1d0f8aa..158c07639 100644 --- a/src/platform/python/mgba/vfs.py +++ b/src/platform/python/mgba/vfs.py @@ -3,7 +3,7 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib import mmap import os diff --git a/src/platform/python/setup.py.in b/src/platform/python/setup.py.in index 133474831..045e6de4e 100644 --- a/src/platform/python/setup.py.in +++ b/src/platform/python/setup.py.in @@ -3,7 +3,7 @@ import re classifiers = [ "Programming Language :: Python :: 2", -# "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3", "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)" ] @@ -13,6 +13,8 @@ setup(name="${BINARY_NAME}", author_email="jeffrey@endrift.com", url="http://github.com/mgba-emu/mgba/", packages=["mgba"], + setup_requires=['cffi>=1.6'], + install_requires=['cffi>=1.6'], license="MPL 2.0", classifiers=classifiers ) \ No newline at end of file From 1dff579ad4a6e5ccb1152b8cddd74975b970b0b3 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 15 Oct 2016 11:54:01 -0700 Subject: [PATCH 15/56] Python: Add basic logging interface --- src/platform/python/_builder.h | 3 +++ src/platform/python/_builder.py | 10 +++++++++- src/platform/python/log.c | 27 ++++++++++++++++++++++++++ src/platform/python/log.h | 15 +++++++++++++++ src/platform/python/mgba/log.py | 34 +++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 src/platform/python/log.c create mode 100644 src/platform/python/log.h create mode 100644 src/platform/python/mgba/log.py diff --git a/src/platform/python/_builder.h b/src/platform/python/_builder.h index a58cb6dad..3531a15b1 100644 --- a/src/platform/python/_builder.h +++ b/src/platform/python/_builder.h @@ -15,10 +15,13 @@ typedef ...* png_structp; typedef ...* png_infop; typedef ...* png_unknown_chunkp; +void free(void*); + #include #include "core/core.h" #include "platform/python/vfs-py.h" +#include "platform/python/log.h" #ifdef USE_PNG #include "util/png-io.h" diff --git a/src/platform/python/_builder.py b/src/platform/python/_builder.py index 0394069e9..97730cce7 100644 --- a/src/platform/python/_builder.py +++ b/src/platform/python/_builder.py @@ -9,6 +9,7 @@ src = os.path.join(os.path.dirname(__file__), "..", "..") ffi.set_source("mgba._pylib", """ #include "util/common.h" #include "core/core.h" +#include "core/log.h" #include "arm/arm.h" #include "gba/gba.h" #include "lr35902/lr35902.h" @@ -22,11 +23,18 @@ struct VFilePy { struct VFile d; void* fileobj; }; + +struct mLogger* mLoggerPythonCreate(void* pyobj); + +struct mLoggerPy { + struct mLogger d; + void* pyobj; +}; """, include_dirs=[src], extra_compile_args=sys.argv[1:], libraries=["mgba"], library_dirs=[os.path.join(os.getcwd(), "..")], - sources=[os.path.join(os.path.dirname(__file__), path) for path in ["vfs-py.c"]]) + sources=[os.path.join(os.path.dirname(__file__), path) for path in ["vfs-py.c", "log.c"]]) with open(os.path.join(os.getcwd(), "_builder.h")) as core: lines = [] diff --git a/src/platform/python/log.c b/src/platform/python/log.c new file mode 100644 index 000000000..aeb77f69f --- /dev/null +++ b/src/platform/python/log.c @@ -0,0 +1,27 @@ +/* Copyright (c) 2013-2016 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "core/log.h" + +struct mLoggerPy { + struct mLogger d; + void* pyobj; +}; + +void _pyLog(void* logger, int category, enum mLogLevel level, const char* message); + +static void _pyLogShim(struct mLogger* logger, int category, enum mLogLevel level, const char* format, va_list args) { + struct mLoggerPy* pylogger = (struct mLoggerPy*) logger; + char message[256] = {0}; + vsnprintf(message, sizeof(message) - 1, format, args); + _pyLog(pylogger, category, level, message); +} + +struct mLogger* mLoggerPythonCreate(void* pyobj) { + struct mLoggerPy* logger = malloc(sizeof(*logger)); + logger->d.log = _pyLogShim; + logger->pyobj = pyobj; + return &logger->d; +} \ No newline at end of file diff --git a/src/platform/python/log.h b/src/platform/python/log.h new file mode 100644 index 000000000..5ee1f7119 --- /dev/null +++ b/src/platform/python/log.h @@ -0,0 +1,15 @@ +/* Copyright (c) 2013-2016 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "core/log.h" + +struct mLoggerPy { + struct mLogger d; + void* pyobj; +}; + +struct mLogger* mLoggerPythonCreate(void* pyobj); + +extern "Python+C" void _pyLog(void* logger, int category, enum mLogLevel level, const char* message); diff --git a/src/platform/python/mgba/log.py b/src/platform/python/mgba/log.py new file mode 100644 index 000000000..846861e02 --- /dev/null +++ b/src/platform/python/mgba/log.py @@ -0,0 +1,34 @@ +# Copyright (c) 2013-2016 Jeffrey Pfau +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +from ._pylib import ffi, lib + +@ffi.def_extern() +def _pyLog(logger, category, level, message): + l = ffi.cast("struct mLoggerPy*", logger) + ffi.from_handle(l.pyobj).log(category, level, ffi.string(message).decode('UTF-8')) + +def installDefault(logger): + lib.mLogSetDefaultLogger(logger._native) + +class Logger(object): + FATAL = lib.mLOG_FATAL + DEBUG = lib.mLOG_DEBUG + INFO = lib.mLOG_INFO + WARN = lib.mLOG_WARN + ERROR = lib.mLOG_ERROR + STUB = lib.mLOG_STUB + GAME_ERROR = lib.mLOG_GAME_ERROR + + def __init__(self): + self._handle = ffi.new_handle(self) + self._native = ffi.gc(lib.mLoggerPythonCreate(self._handle), lib.free) + + @staticmethod + def categoryName(category): + return ffi.string(lib.mLogCategoryName(category)).decode('UTF-8') + + def log(self, category, level, message): + print("{}: {}".format(self.categoryName(category), message)) From 35658689366d3b78ce819a73cb3e475b2fb4c061 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 17 Oct 2016 12:01:59 -0700 Subject: [PATCH 16/56] Python: Fix Linux build --- src/platform/python/_builder.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platform/python/_builder.h b/src/platform/python/_builder.h index 3531a15b1..7ffdd422e 100644 --- a/src/platform/python/_builder.h +++ b/src/platform/python/_builder.h @@ -1,6 +1,8 @@ #define COMMON_H #define PNG_H +#define _SYS_TIME_H #define _SYS_TIME_H_ +#define _TIME_H #define _TIME_H_ #define ATTRIBUTE_FORMAT(X, Y, Z) From 5e0641cb0e9b6b71c19954da443a8f7b5813c507 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 17 Oct 2016 22:37:54 -0700 Subject: [PATCH 17/56] Python: Add some tile manipulation --- src/platform/python/_builder.h | 3 +++ src/platform/python/_builder.py | 5 +++- src/platform/python/mgba/image.py | 43 +++++++++++++++++++++++++++++++ src/platform/python/mgba/tile.py | 36 ++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/platform/python/mgba/tile.py diff --git a/src/platform/python/_builder.h b/src/platform/python/_builder.h index 7ffdd422e..97539a639 100644 --- a/src/platform/python/_builder.h +++ b/src/platform/python/_builder.h @@ -22,6 +22,7 @@ void free(void*); #include #include "core/core.h" +#include "core/tile-cache.h" #include "platform/python/vfs-py.h" #include "platform/python/log.h" @@ -31,8 +32,10 @@ void free(void*); #ifdef M_CORE_GBA #include "arm/arm.h" #include "gba/gba.h" +#include "gba/renderers/tile-cache.h" #endif #ifdef M_CORE_GB #include "lr35902/lr35902.h" #include "gb/gb.h" +#include "gb/renderers/tile-cache.h" #endif diff --git a/src/platform/python/_builder.py b/src/platform/python/_builder.py index 97730cce7..666aefe33 100644 --- a/src/platform/python/_builder.py +++ b/src/platform/python/_builder.py @@ -10,10 +10,13 @@ ffi.set_source("mgba._pylib", """ #include "util/common.h" #include "core/core.h" #include "core/log.h" +#include "core/tile-cache.h" #include "arm/arm.h" #include "gba/gba.h" +#include "gba/renderers/tile-cache.h" #include "lr35902/lr35902.h" #include "gb/gb.h" +#include "gb/renderers/tile-cache.h" #include "util/png-io.h" #include "util/vfs.h" @@ -45,4 +48,4 @@ with open(os.path.join(os.getcwd(), "_builder.h")) as core: lines.append(line) ffi.cdef('\n'.join(lines)) -ffi.compile() \ No newline at end of file +ffi.compile() diff --git a/src/platform/python/mgba/image.py b/src/platform/python/mgba/image.py index 907077433..f76945b32 100644 --- a/src/platform/python/mgba/image.py +++ b/src/platform/python/mgba/image.py @@ -24,3 +24,46 @@ class Image: success = success and p.writePixels(self) p.writeClose() return success + +def u16ToU32(c): + r = c & 0x1F + g = (c >> 5) & 0x1F + b = (c >> 10) & 0x1F + a = (c >> 15) & 1 + abgr = r << 3 + abgr |= g << 11 + abgr |= b << 19 + abgr |= (a * 0xFF) << 24 + return abgr + +def u32ToU16(c): + r = (c >> 3) & 0x1F + g = (c >> 11) & 0x1F + b = (c >> 19) & 0x1F + a = c >> 31 + abgr = r + abgr |= g << 5 + abgr |= b << 10 + abgr |= a << 15 + return abgr + +if ffi.sizeof("color_t") == 2: + def colorToU16(c): + return c + + colorToU32 = u16ToU32 + + def u16ToColor(c): + return c + + u32ToColor = u32ToU16 +else: + def colorToU32(c): + return c + + colorToU16 = u32ToU16 + + def u32ToColor(c): + return c + + u16ToColor = u16ToU32 diff --git a/src/platform/python/mgba/tile.py b/src/platform/python/mgba/tile.py new file mode 100644 index 000000000..06a64366d --- /dev/null +++ b/src/platform/python/mgba/tile.py @@ -0,0 +1,36 @@ +# Copyright (c) 2013-2016 Jeffrey Pfau +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +from ._pylib import ffi, lib +from . import image + +class Tile: + def __init__(self, data): + self.buffer = data + + def toImage(self): + i = image.Image(8, 8) + self.composite(i, 0, 0) + return i + + def composite(self, i, x, y): + for iy in range(8): + for ix in range(8): + i.buffer[ix + x + (iy + y) * i.stride] = image.u16ToColor(self.buffer[ix + iy * 8]) + +class TileView: + def __init__(self, core): + self.core = core + self.cache = ffi.gc(ffi.new("struct mTileCache*"), lib.mTileCacheDeinit) + if core.platform() == core.PLATFORM_GBA: + lib.GBAVideoTileCacheInit(self.cache) + lib.GBAVideoTileCacheAssociate(self.cache, ffi.addressof(self.core.board._native, "video")) + if core.platform() == core.PLATFORM_GB: + lib.GBVideoTileCacheInit(self.cache) + lib.GBVideoTileCacheAssociate(self.cache, ffi.addressof(self.core.board._native, "video")) + lib.mTileCacheSetPalette(self.cache, 0) + + def getTile(self, tile, palette): + return Tile(lib.mTileCacheGetTile(self.cache, tile, palette)) From 303a7685a28b2ccbbc4c7bb6cc62a75fcdc0116c Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 18 Oct 2016 14:32:17 -0700 Subject: [PATCH 18/56] Python: Reindent, fix up TileView interface --- src/platform/python/mgba/core.py | 8 ++++++- src/platform/python/mgba/gb.py | 8 +++++++ src/platform/python/mgba/gba.py | 8 +++++++ src/platform/python/mgba/tile.py | 39 ++++++++++++++------------------ src/platform/python/setup.py.in | 4 ++-- 5 files changed, 42 insertions(+), 25 deletions(-) diff --git a/src/platform/python/mgba/core.py b/src/platform/python/mgba/core.py index 10b0ccd5d..8bf339846 100644 --- a/src/platform/python/mgba/core.py +++ b/src/platform/python/mgba/core.py @@ -4,6 +4,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from ._pylib import ffi, lib +from . import tile +from cached_property import cached_property def find(path): core = lib.mCoreFind(path.encode('UTF-8')) @@ -43,6 +45,10 @@ class Core: self.cpu = LR35902Core(self._core.cpu) self.board = GB(self._core.board) + @cached_property + def tiles(self): + return tile.TileView(self) + def _deinit(self): self._core.deinit(self._core) @@ -112,4 +118,4 @@ if hasattr(lib, 'PLATFORM_GBA'): if hasattr(lib, 'PLATFORM_GB'): from .gb import GB from .lr35902 import LR35902Core - Core.PLATFORM_GB = lib.PLATFORM_GB \ No newline at end of file + Core.PLATFORM_GB = lib.PLATFORM_GB diff --git a/src/platform/python/mgba/gb.py b/src/platform/python/mgba/gb.py index 1d141e966..0b5f0f79d 100644 --- a/src/platform/python/mgba/gb.py +++ b/src/platform/python/mgba/gb.py @@ -8,3 +8,11 @@ from ._pylib import ffi, lib class GB: def __init__(self, native): self._native = ffi.cast("struct GB*", native) + + def _initTileCache(self, cache): + lib.GBVideoTileCacheInit(cache) + lib.GBVideoTileCacheAssociate(cache, ffi.addressof(self._native.video)) + + def _deinitTileCache(self, cache): + self._native.video.renderer.cache = ffi.NULL + lib.mTileCacheDeinit(cache) diff --git a/src/platform/python/mgba/gba.py b/src/platform/python/mgba/gba.py index a425c5b42..4a66222d9 100644 --- a/src/platform/python/mgba/gba.py +++ b/src/platform/python/mgba/gba.py @@ -8,3 +8,11 @@ from ._pylib import ffi, lib class GBA: def __init__(self, native): self._native = ffi.cast("struct GBA*", native) + + def _initTileCache(self, cache): + lib.GBAVideoTileCacheInit(cache) + lib.GBAVideoTileCacheAssociate(cache, ffi.addressof(self._native.video)) + + def _deinitTileCache(self, cache): + self._native.video.renderer.cache = ffi.NULL + lib.mTileCacheDeinit(cache) diff --git a/src/platform/python/mgba/tile.py b/src/platform/python/mgba/tile.py index 06a64366d..1728e8927 100644 --- a/src/platform/python/mgba/tile.py +++ b/src/platform/python/mgba/tile.py @@ -7,30 +7,25 @@ from ._pylib import ffi, lib from . import image class Tile: - def __init__(self, data): - self.buffer = data + def __init__(self, data): + self.buffer = data - def toImage(self): - i = image.Image(8, 8) - self.composite(i, 0, 0) - return i + def toImage(self): + i = image.Image(8, 8) + self.composite(i, 0, 0) + return i - def composite(self, i, x, y): - for iy in range(8): - for ix in range(8): - i.buffer[ix + x + (iy + y) * i.stride] = image.u16ToColor(self.buffer[ix + iy * 8]) + def composite(self, i, x, y): + for iy in range(8): + for ix in range(8): + i.buffer[ix + x + (iy + y) * i.stride] = image.u16ToColor(self.buffer[ix + iy * 8]) class TileView: - def __init__(self, core): - self.core = core - self.cache = ffi.gc(ffi.new("struct mTileCache*"), lib.mTileCacheDeinit) - if core.platform() == core.PLATFORM_GBA: - lib.GBAVideoTileCacheInit(self.cache) - lib.GBAVideoTileCacheAssociate(self.cache, ffi.addressof(self.core.board._native, "video")) - if core.platform() == core.PLATFORM_GB: - lib.GBVideoTileCacheInit(self.cache) - lib.GBVideoTileCacheAssociate(self.cache, ffi.addressof(self.core.board._native, "video")) - lib.mTileCacheSetPalette(self.cache, 0) + def __init__(self, core): + self.core = core + self.cache = ffi.gc(ffi.new("struct mTileCache*"), core.board._deinitTileCache) + core.board._initTileCache(self.cache) + lib.mTileCacheSetPalette(self.cache, 0) - def getTile(self, tile, palette): - return Tile(lib.mTileCacheGetTile(self.cache, tile, palette)) + def getTile(self, tile, palette): + return Tile(lib.mTileCacheGetTile(self.cache, tile, palette)) diff --git a/src/platform/python/setup.py.in b/src/platform/python/setup.py.in index 045e6de4e..1884778cf 100644 --- a/src/platform/python/setup.py.in +++ b/src/platform/python/setup.py.in @@ -14,7 +14,7 @@ setup(name="${BINARY_NAME}", url="http://github.com/mgba-emu/mgba/", packages=["mgba"], setup_requires=['cffi>=1.6'], - install_requires=['cffi>=1.6'], + install_requires=['cffi>=1.6', 'cached-property'], license="MPL 2.0", classifiers=classifiers - ) \ No newline at end of file + ) From a9ccb0fdd723cfa45a226925e2a059c05057389c Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 18 Oct 2016 15:07:14 -0700 Subject: [PATCH 19/56] Python: Clean up Core interface so boards inherit Core --- src/platform/python/mgba/core.py | 31 ++++++++++++++++--------------- src/platform/python/mgba/gb.py | 5 ++++- src/platform/python/mgba/gba.py | 7 +++++-- src/platform/python/mgba/tile.py | 4 ++-- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/platform/python/mgba/core.py b/src/platform/python/mgba/core.py index 8bf339846..9dbb80415 100644 --- a/src/platform/python/mgba/core.py +++ b/src/platform/python/mgba/core.py @@ -11,13 +11,13 @@ def find(path): core = lib.mCoreFind(path.encode('UTF-8')) if core == ffi.NULL: return None - return Core(core) + return Core._init(core) def findVF(vf): core = lib.mCoreFindVF(vf.handle) if core == ffi.NULL: return None - return Core(core) + return Core._init(core) def loadPath(path): core = find(path) @@ -31,24 +31,26 @@ def loadVF(vf): return None return core -class Core: +class Core(object): def __init__(self, native): - self._core = ffi.gc(native, native.deinit) - success = bool(self._core.init(self._core)) - if not success: - raise RuntimeError("Failed to initialize core") - - if hasattr(self, 'PLATFORM_GBA') and self.platform() == self.PLATFORM_GBA: - self.cpu = ARMCore(self._core.cpu) - self.board = GBA(self._core.board) - if hasattr(self, 'PLATFORM_GB') and self.platform() == self.PLATFORM_GB: - self.cpu = LR35902Core(self._core.cpu) - self.board = GB(self._core.board) + self._core = native @cached_property def tiles(self): return tile.TileView(self) + @classmethod + def _init(cls, native): + core = ffi.gc(native, native.deinit) + success = bool(core.init(core)) + if not success: + raise RuntimeError("Failed to initialize core") + if hasattr(cls, 'PLATFORM_GBA') and core.platform(core) == cls.PLATFORM_GBA: + return GBA(core) + if hasattr(cls, 'PLATFORM_GB') and core.platform(core) == cls.PLATFORM_GB: + return GB(core) + return Core(core) + def _deinit(self): self._core.deinit(self._core) @@ -112,7 +114,6 @@ class Core: if hasattr(lib, 'PLATFORM_GBA'): from .gba import GBA - from .arm import ARMCore Core.PLATFORM_GBA = lib.PLATFORM_GBA if hasattr(lib, 'PLATFORM_GB'): diff --git a/src/platform/python/mgba/gb.py b/src/platform/python/mgba/gb.py index 0b5f0f79d..bb34d4dad 100644 --- a/src/platform/python/mgba/gb.py +++ b/src/platform/python/mgba/gb.py @@ -4,10 +4,13 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from ._pylib import ffi, lib +from . import core, lr35902 class GB: def __init__(self, native): - self._native = ffi.cast("struct GB*", native) + super(GB, self).__init__(native) + self._native = ffi.cast("struct GB*", native.board) + self.cpu = lr35902.LR35902Core(self._core.cpu) def _initTileCache(self, cache): lib.GBVideoTileCacheInit(cache) diff --git a/src/platform/python/mgba/gba.py b/src/platform/python/mgba/gba.py index 4a66222d9..9ed401709 100644 --- a/src/platform/python/mgba/gba.py +++ b/src/platform/python/mgba/gba.py @@ -4,10 +4,13 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from ._pylib import ffi, lib +from . import core, arm -class GBA: +class GBA(core.Core): def __init__(self, native): - self._native = ffi.cast("struct GBA*", native) + super(GBA, self).__init__(native) + self._native = ffi.cast("struct GBA*", native.board) + self.cpu = arm.ARMCore(self._core.cpu) def _initTileCache(self, cache): lib.GBAVideoTileCacheInit(cache) diff --git a/src/platform/python/mgba/tile.py b/src/platform/python/mgba/tile.py index 1728e8927..e8fe07271 100644 --- a/src/platform/python/mgba/tile.py +++ b/src/platform/python/mgba/tile.py @@ -23,8 +23,8 @@ class Tile: class TileView: def __init__(self, core): self.core = core - self.cache = ffi.gc(ffi.new("struct mTileCache*"), core.board._deinitTileCache) - core.board._initTileCache(self.cache) + self.cache = ffi.gc(ffi.new("struct mTileCache*"), core._deinitTileCache) + core._initTileCache(self.cache) lib.mTileCacheSetPalette(self.cache, 0) def getTile(self, tile, palette): From 9b915fb13d559d3213c7b4ea8c28244c30cf8907 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 18 Oct 2016 15:31:21 -0700 Subject: [PATCH 20/56] Python: Add GBA sprite accessors --- src/platform/python/mgba/gba.py | 46 +++++++++++++++++++++++++++++--- src/platform/python/mgba/tile.py | 16 +++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/platform/python/mgba/gba.py b/src/platform/python/mgba/gba.py index 9ed401709..12096eaec 100644 --- a/src/platform/python/mgba/gba.py +++ b/src/platform/python/mgba/gba.py @@ -4,13 +4,16 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from ._pylib import ffi, lib -from . import core, arm +from .arm import ARMCore +from .core import Core +from .tile import Sprite -class GBA(core.Core): +class GBA(Core): def __init__(self, native): super(GBA, self).__init__(native) self._native = ffi.cast("struct GBA*", native.board) - self.cpu = arm.ARMCore(self._core.cpu) + self.sprites = GBAObjs(self) + self.cpu = ARMCore(self._core.cpu) def _initTileCache(self, cache): lib.GBAVideoTileCacheInit(cache) @@ -19,3 +22,40 @@ class GBA(core.Core): def _deinitTileCache(self, cache): self._native.video.renderer.cache = ffi.NULL lib.mTileCacheDeinit(cache) + +class GBASprite(Sprite): + TILE_BASE = 0x800 + PALETTE_BASE = 0x10 + + def __init__(self, obj): + self._a = obj.a + self._b = obj.b + self._c = obj.c + self.x = self._b & 0x1FF + self.y = self._a & 0xFF + self._shape = self._a >> 14 + self._size = self._b >> 14 + self._256Color = bool(self._b & 0x2000) + self.width, self.height = lib.GBAVideoObjSizes[self._shape * 4 + self._size] + self.tile = self._c & 0x3FF + if self._256Color: + self.paletteId = 0 + else: + self.paletteId = self._c >> 12 + +class GBAObjs: + def __init__(self, core): + self._core = core + self._obj = core._native.video.oam.obj + + def __len__(self): + return 128 + + def __getitem__(self, index): + if index >= len(self): + raise IndexError() + sprite = GBASprite(self._obj[index]) + map1D = bool(self._core._native.memory.io[0] & 0x40) + # TODO: 256 colors + sprite.constitute(self._core.tiles, 0 if map1D else 0x20) + return sprite diff --git a/src/platform/python/mgba/tile.py b/src/platform/python/mgba/tile.py index e8fe07271..b9fec1c53 100644 --- a/src/platform/python/mgba/tile.py +++ b/src/platform/python/mgba/tile.py @@ -29,3 +29,19 @@ class TileView: def getTile(self, tile, palette): return Tile(lib.mTileCacheGetTile(self.cache, tile, palette)) + +class Sprite(object): + TILE_BASE = 0 + PALETTE_BASE = 0 + + def constitute(self, tileView, tilePitch): + i = image.Image(self.width, self.height) + tileId = self.tile + self.TILE_BASE + for y in range(self.height // 8): + for x in range(self.width // 8): + tile = tileView.getTile(tileId, self.paletteId + self.PALETTE_BASE) + tile.composite(i, x * 8, y * 8) + tileId += 1 + if tilePitch: + tileId += tilePitch - self.width // 8 + self.image = i From 9a104508acb0ae61d1df9fda576cfe2fdfc3731f Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 18 Oct 2016 18:36:13 -0700 Subject: [PATCH 21/56] Python: Add support for 256-color sprites --- src/platform/python/mgba/gba.py | 10 +++++----- src/platform/python/mgba/tile.py | 22 ++++++++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/platform/python/mgba/gba.py b/src/platform/python/mgba/gba.py index 12096eaec..6ad761f00 100644 --- a/src/platform/python/mgba/gba.py +++ b/src/platform/python/mgba/gba.py @@ -24,8 +24,8 @@ class GBA(Core): lib.mTileCacheDeinit(cache) class GBASprite(Sprite): - TILE_BASE = 0x800 - PALETTE_BASE = 0x10 + TILE_BASE = 0x800, 0x400 + PALETTE_BASE = 0x10, 1 def __init__(self, obj): self._a = obj.a @@ -35,11 +35,12 @@ class GBASprite(Sprite): self.y = self._a & 0xFF self._shape = self._a >> 14 self._size = self._b >> 14 - self._256Color = bool(self._b & 0x2000) + self._256Color = bool(self._a & 0x2000) self.width, self.height = lib.GBAVideoObjSizes[self._shape * 4 + self._size] self.tile = self._c & 0x3FF if self._256Color: self.paletteId = 0 + self.tile >>= 1 else: self.paletteId = self._c >> 12 @@ -56,6 +57,5 @@ class GBAObjs: raise IndexError() sprite = GBASprite(self._obj[index]) map1D = bool(self._core._native.memory.io[0] & 0x40) - # TODO: 256 colors - sprite.constitute(self._core.tiles, 0 if map1D else 0x20) + sprite.constitute(self._core.tiles, 0 if map1D else 0x20, int(sprite._256Color)) return sprite diff --git a/src/platform/python/mgba/tile.py b/src/platform/python/mgba/tile.py index b9fec1c53..4d89f8869 100644 --- a/src/platform/python/mgba/tile.py +++ b/src/platform/python/mgba/tile.py @@ -26,22 +26,32 @@ class TileView: self.cache = ffi.gc(ffi.new("struct mTileCache*"), core._deinitTileCache) core._initTileCache(self.cache) lib.mTileCacheSetPalette(self.cache, 0) + self.paletteSet = 0 def getTile(self, tile, palette): return Tile(lib.mTileCacheGetTile(self.cache, tile, palette)) -class Sprite(object): - TILE_BASE = 0 - PALETTE_BASE = 0 + def setPalette(self, paletteSet): + if paletteSet > 1 or paletteSet < 0: + raise IndexError("Palette Set ID out of bounds") + lib.mTileCacheSetPalette(self.cache, paletteSet) + self.paletteSet = paletteSet - def constitute(self, tileView, tilePitch): +class Sprite(object): + TILE_BASE = 0, 0 + PALETTE_BASE = 0, 0 + + def constitute(self, tileView, tilePitch, paletteSet): + oldPaletteSet = tileView.paletteSet + tileView.setPalette(paletteSet) i = image.Image(self.width, self.height) - tileId = self.tile + self.TILE_BASE + tileId = self.tile + self.TILE_BASE[paletteSet] for y in range(self.height // 8): for x in range(self.width // 8): - tile = tileView.getTile(tileId, self.paletteId + self.PALETTE_BASE) + tile = tileView.getTile(tileId, self.paletteId + self.PALETTE_BASE[paletteSet]) tile.composite(i, x * 8, y * 8) tileId += 1 if tilePitch: tileId += tilePitch - self.width // 8 self.image = i + tileView.setPalette(oldPaletteSet) From 471bbf1da5ace6f817c666e8520dfbb17442f688 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 18 Oct 2016 19:04:43 -0700 Subject: [PATCH 22/56] Python: Sprite access in GB core --- src/platform/python/mgba/gb.py | 43 +++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/platform/python/mgba/gb.py b/src/platform/python/mgba/gb.py index bb34d4dad..33dbc0aae 100644 --- a/src/platform/python/mgba/gb.py +++ b/src/platform/python/mgba/gb.py @@ -4,13 +4,16 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from ._pylib import ffi, lib -from . import core, lr35902 +from .lr35902 import LR35902Core +from .core import Core +from .tile import Sprite -class GB: +class GB(Core): def __init__(self, native): super(GB, self).__init__(native) self._native = ffi.cast("struct GB*", native.board) - self.cpu = lr35902.LR35902Core(self._core.cpu) + self.sprites = GBObjs(self) + self.cpu = LR35902Core(self._core.cpu) def _initTileCache(self, cache): lib.GBVideoTileCacheInit(cache) @@ -19,3 +22,37 @@ class GB: def _deinitTileCache(self, cache): self._native.video.renderer.cache = ffi.NULL lib.mTileCacheDeinit(cache) + +class GBSprite(Sprite): + PALETTE_BASE = 8, + + def __init__(self, obj, core): + self.x = obj.x + self.y = obj.y + self.tile = obj.tile + self._attr = obj.attr + self.width = 8 + lcdc = core._native.memory.io[0x40] + self.height = 16 if lcdc & 4 else 8 + if core._native.model >= lib.GB_MODEL_CGB: + if self._attr & 8: + self.tile += 512 + self.paletteId = self._attr & 7 + else: + self.paletteId = (self._attr >> 4) & 1 + + +class GBObjs: + def __init__(self, core): + self._core = core + self._obj = core._native.video.oam.obj + + def __len__(self): + return 40 + + def __getitem__(self, index): + if index >= len(self): + raise IndexError() + sprite = GBSprite(self._obj[index], self._core) + sprite.constitute(self._core.tiles, 0, 0) + return sprite From 9d44445d642658d72cfa6ac39d06abf62ad95733 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 19 Oct 2016 00:20:43 -0700 Subject: [PATCH 23/56] Python: Much cleaner LR35902 access --- src/platform/python/mgba/lr35902.py | 154 ++++++++++++++++++++-------- 1 file changed, 111 insertions(+), 43 deletions(-) diff --git a/src/platform/python/mgba/lr35902.py b/src/platform/python/mgba/lr35902.py index 6c1ffcddb..77400c0b0 100644 --- a/src/platform/python/mgba/lr35902.py +++ b/src/platform/python/mgba/lr35902.py @@ -9,47 +9,115 @@ class LR35902Core: def __init__(self, native): self._native = ffi.cast("struct LR35902Core*", native) - def __getattr__(self, key): - if key == 'a': - return self._native.a - if key == 'b': - return self._native.b - if key == 'c': - return self._native.c - if key == 'd': - return self._native.d - if key == 'e': - return self._native.e - if key == 'f': - return self._native.f - if key == 'h': - return self._native.h - if key == 'l': - return self._native.l - if key == 'sp': - return self._native.sp - if key == 'pc': - return self._native.pc - raise AttributeError() + @property + def a(self): + return self._native.a - def __setattr__(self, key, value): - if key == 'a': - self._native.a = value & 0xF0 - if key == 'b': - self._native.b = value - if key == 'c': - self._native.c = value - if key == 'd': - self._native.d = value - if key == 'e': - self._native.e = value - if key == 'f': - self._native.f = value - if key == 'h': - self._native.h = value - if key == 'l': - self._native.l = value - if key == 'sp': - self._native.sp = value - else: - self.__dict__[key] = value + @property + def b(self): + return self._native.b + + @property + def c(self): + return self._native.c + + @property + def d(self): + return self._native.d + + @property + def e(self): + return self._native.e + + @property + def f(self): + return self._native.f + + @property + def h(self): + return self._native.h + + @property + def l(self): + return self._native.l + + @property + def sp(self): + return self._native.sp + + @property + def pc(self): + return self._native.pc + + @property + def af(self): + return (self.a << 8) | self.f + + @property + def bc(self): + return (self.b << 8) | self.c + + @property + def de(self): + return (self.d << 8) | self.e + + @property + def hl(self): + return (self.h << 8) | self.l + + @a.setter + def a(self, value): + self._native.a = value + + @b.setter + def b(self, value): + self._native.b = value + + @c.setter + def c(self, value): + self._native.c = value + + @d.setter + def d(self, value): + self._native.d = value + + @e.setter + def e(self, value): + self._native.e = value + + @f.setter + def f(self, value): + self._native.f.packed = value + self._native.f.unused = 0 + + @h.setter + def h(self, value): + self._native.h = value + + @l.setter + def l(self, value): + self._native.l = value + + @sp.setter + def sp(self, value): + self._native.sp = value + + @af.setter + def af(self, value): + self.a = value >> 8 + self.f = value & 0xFF + + @bc.setter + def bc(self, value): + self.b = value >> 8 + self.c = value & 0xFF + + @de.setter + def de(self, value): + self.d = value >> 8 + self.e = value & 0xFF + + @hl.setter + def hl(self, value): + self.h = value >> 8 + self.l = value & 0xFF From adc45c9bdc2b20d1a439a9a21945a870f85adb15 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 19 Oct 2016 13:49:34 -0700 Subject: [PATCH 24/56] Python: Add more mCore functions --- src/platform/python/mgba/core.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/platform/python/mgba/core.py b/src/platform/python/mgba/core.py index 9dbb80415..fe1a1f1f2 100644 --- a/src/platform/python/mgba/core.py +++ b/src/platform/python/mgba/core.py @@ -63,6 +63,15 @@ class Core(object): def loadROM(self, vf): return bool(self._core.loadROM(self._core, vf.handle)) + def loadSave(self, vf): + return bool(self._core.loadSave(self._core, vf.handle)) + + def loadTemporarySave(self, vf): + return bool(self._core.loadTemporarySave(self._core, vf.handle)) + + def loadPatch(self, vf): + return bool(self._core.loadPatch(self._core, vf.handle)) + def autoloadSave(self): return bool(lib.mCoreAutoloadSave(self._core)) From 572eb40d420984f477269200dd7988eba09552bd Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 26 Oct 2016 22:44:42 -0700 Subject: [PATCH 25/56] Python: Add key functions --- src/platform/python/_builder.h | 2 ++ src/platform/python/_builder.py | 1 + src/platform/python/mgba/core.py | 18 ++++++++++++++++++ src/platform/python/mgba/gb.py | 9 +++++++++ src/platform/python/mgba/gba.py | 11 +++++++++++ 5 files changed, 41 insertions(+) diff --git a/src/platform/python/_builder.h b/src/platform/python/_builder.h index 97539a639..bb5f8b75c 100644 --- a/src/platform/python/_builder.h +++ b/src/platform/python/_builder.h @@ -32,10 +32,12 @@ void free(void*); #ifdef M_CORE_GBA #include "arm/arm.h" #include "gba/gba.h" +#include "gba/input.h" #include "gba/renderers/tile-cache.h" #endif #ifdef M_CORE_GB #include "lr35902/lr35902.h" #include "gb/gb.h" +#include "gba/input.h" #include "gb/renderers/tile-cache.h" #endif diff --git a/src/platform/python/_builder.py b/src/platform/python/_builder.py index 666aefe33..31cdade94 100644 --- a/src/platform/python/_builder.py +++ b/src/platform/python/_builder.py @@ -13,6 +13,7 @@ ffi.set_source("mgba._pylib", """ #include "core/tile-cache.h" #include "arm/arm.h" #include "gba/gba.h" +#include "gba/input.h" #include "gba/renderers/tile-cache.h" #include "lr35902/lr35902.h" #include "gb/gb.h" diff --git a/src/platform/python/mgba/core.py b/src/platform/python/mgba/core.py index fe1a1f1f2..ad051e33d 100644 --- a/src/platform/python/mgba/core.py +++ b/src/platform/python/mgba/core.py @@ -102,6 +102,24 @@ class Core(object): def step(self): self._core.step(self._core) + @staticmethod + def _keysToInt(*args, **kwargs): + keys = 0 + if 'raw' in kwargs: + keys = kwargs['raw'] + for key in args: + keys |= 1 << key + return keys + + def setKeys(self, *args, **kwargs): + self._core.setKeys(self._core, self._keysToInt(*args, **kwargs)) + + def addKeys(self, *args, **kwargs): + self._core.addKeys(self._core, self._keysToInt(*args, **kwargs)) + + def clearKeys(self, *args, **kwargs): + self._core.clearKeys(self._core, self._keysToInt(*args, **kwargs)) + def frameCounter(self): return self._core.frameCounter(self._core) diff --git a/src/platform/python/mgba/gb.py b/src/platform/python/mgba/gb.py index 33dbc0aae..d8d549cdd 100644 --- a/src/platform/python/mgba/gb.py +++ b/src/platform/python/mgba/gb.py @@ -9,6 +9,15 @@ from .core import Core from .tile import Sprite class GB(Core): + KEY_A = lib.GBA_KEY_A + KEY_B = lib.GBA_KEY_B + KEY_SELECT = lib.GBA_KEY_SELECT + KEY_START = lib.GBA_KEY_START + KEY_DOWN = lib.GBA_KEY_DOWN + KEY_UP = lib.GBA_KEY_UP + KEY_LEFT = lib.GBA_KEY_LEFT + KEY_RIGHT = lib.GBA_KEY_RIGHT + def __init__(self, native): super(GB, self).__init__(native) self._native = ffi.cast("struct GB*", native.board) diff --git a/src/platform/python/mgba/gba.py b/src/platform/python/mgba/gba.py index 6ad761f00..7a664d5e9 100644 --- a/src/platform/python/mgba/gba.py +++ b/src/platform/python/mgba/gba.py @@ -9,6 +9,17 @@ from .core import Core from .tile import Sprite class GBA(Core): + KEY_A = lib.GBA_KEY_A + KEY_B = lib.GBA_KEY_B + KEY_SELECT = lib.GBA_KEY_SELECT + KEY_START = lib.GBA_KEY_START + KEY_DOWN = lib.GBA_KEY_DOWN + KEY_UP = lib.GBA_KEY_UP + KEY_LEFT = lib.GBA_KEY_LEFT + KEY_RIGHT = lib.GBA_KEY_RIGHT + KEY_L = lib.GBA_KEY_L + KEY_R = lib.GBA_KEY_R + def __init__(self, native): super(GBA, self).__init__(native) self._native = ffi.cast("struct GBA*", native.board) From e2bcd2e05ad4d8fa879a5b32f56c91e1f5e4c964 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 27 Oct 2016 18:39:52 -0700 Subject: [PATCH 26/56] Python: Add memory access --- src/platform/python/mgba/gb.py | 13 ++++++ src/platform/python/mgba/gba.py | 19 +++++++++ src/platform/python/mgba/memory.py | 64 ++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 src/platform/python/mgba/memory.py diff --git a/src/platform/python/mgba/gb.py b/src/platform/python/mgba/gb.py index d8d549cdd..eed40e189 100644 --- a/src/platform/python/mgba/gb.py +++ b/src/platform/python/mgba/gb.py @@ -6,6 +6,7 @@ from ._pylib import ffi, lib from .lr35902 import LR35902Core from .core import Core +from .memory import Memory from .tile import Sprite class GB(Core): @@ -32,6 +33,18 @@ class GB(Core): self._native.video.renderer.cache = ffi.NULL lib.mTileCacheDeinit(cache) +class GBMemory(Memory): + def __init__(self, core): + super(GBMemory, self).__init__(core, 0x10000) + + self.cart = Memory(core, lib.GB_SIZE_CART_BANK0 * 2, lib.GB_BASE_CART_BANK0) + self.vram = Memory(core, lib.GB_SIZE_VRAM, lib.GB_BASE_VRAM) + self.sram = Memory(core, lib.GB_SIZE_EXTERNAL_RAM, lib.GB_REGION_EXTERNAL_RAM) + self.iwram = Memory(core, lib.GB_SIZE_WORKING_RAM_BANK0, lib.GB_BASE_WORKING_RAM_BANK0) + self.oam = Memory(core, lib.GB_SIZE_OAM, lib.GB_BASE_OAM) + self.io = Memory(core, lib.GB_SIZE_IO, lib.GB_BASE_IO) + self.hram = Memory(core, lib.GB_SIZE_HRAM, lib.GB_BASE_HRAM) + class GBSprite(Sprite): PALETTE_BASE = 8, diff --git a/src/platform/python/mgba/gba.py b/src/platform/python/mgba/gba.py index 7a664d5e9..40e059a4c 100644 --- a/src/platform/python/mgba/gba.py +++ b/src/platform/python/mgba/gba.py @@ -7,6 +7,7 @@ from ._pylib import ffi, lib from .arm import ARMCore from .core import Core from .tile import Sprite +from .memory import Memory class GBA(Core): KEY_A = lib.GBA_KEY_A @@ -25,6 +26,7 @@ class GBA(Core): self._native = ffi.cast("struct GBA*", native.board) self.sprites = GBAObjs(self) self.cpu = ARMCore(self._core.cpu) + self.memory = GBAMemory(self._core) def _initTileCache(self, cache): lib.GBAVideoTileCacheInit(cache) @@ -34,6 +36,23 @@ class GBA(Core): self._native.video.renderer.cache = ffi.NULL lib.mTileCacheDeinit(cache) +class GBAMemory(Memory): + def __init__(self, core): + super(GBAMemory, self).__init__(core, 0x100000000) + + self.bios = Memory(core, lib.SIZE_BIOS, lib.BASE_BIOS) + self.wram = Memory(core, lib.SIZE_WORKING_RAM, lib.BASE_WORKING_RAM) + self.iwram = Memory(core, lib.SIZE_WORKING_IRAM, lib.BASE_WORKING_IRAM) + self.io = Memory(core, lib.SIZE_IO, lib.BASE_IO) + self.palette = Memory(core, lib.SIZE_PALETTE_RAM, lib.BASE_PALETTE_RAM) + self.vram = Memory(core, lib.SIZE_VRAM, lib.BASE_VRAM) + self.oam = Memory(core, lib.SIZE_OAM, lib.BASE_OAM) + self.cart0 = Memory(core, lib.SIZE_CART0, lib.BASE_CART0) + self.cart1 = Memory(core, lib.SIZE_CART1, lib.BASE_CART1) + self.cart2 = Memory(core, lib.SIZE_CART2, lib.BASE_CART2) + self.cart = self.cart0 + self.sram = Memory(core, lib.SIZE_CART_SRAM, lib.BASE_CART_SRAM) + class GBASprite(Sprite): TILE_BASE = 0x800, 0x400 PALETTE_BASE = 0x10, 1 diff --git a/src/platform/python/mgba/memory.py b/src/platform/python/mgba/memory.py new file mode 100644 index 000000000..7827e578d --- /dev/null +++ b/src/platform/python/mgba/memory.py @@ -0,0 +1,64 @@ +# Copyright (c) 2013-2016 Jeffrey Pfau +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +from ._pylib import ffi, lib + +class MemoryView(object): + def __init__(self, core, width, size, base=0, sign="u"): + self._core = core + self._width = width + self._size = size + self._base = base + self._busRead = getattr(self._core, "busRead" + str(width * 8)) + self._busWrite = getattr(self._core, "busWrite" + str(width * 8)) + self._rawRead = getattr(self._core, "rawRead" + str(width * 8)) + self._rawWrite = getattr(self._core, "rawWrite" + str(width * 8)) + self._mask = (1 << (width * 8)) - 1 # Used to force values to fit within range so that negative values work + if sign == "u" or sign == "unsigned": + self._type = "uint{}_t".format(width * 8) + elif sign == "i" or sign == "s" or sign == "signed": + self._type = "int{}_t".format(width * 8) + else: + raise ValueError("Invalid sign type: '{}'".format(sign)) + + def _addrCheck(self, address): + if address >= self._size or address + self._width > self._size: + raise IndexError() + if address < 0: + raise IndexError() + + def __len__(self): + return self._size + + def __getitem__(self, address): + self._addrCheck(address) + return int(ffi.cast(self._type, self._busRead(self._core, self._base + address))) + + def __setitem__(self, address, value): + self._addrCheck(address) + self._busWrite(self._core, self._base + address, value & self._mask) + + def rawRead(self, address, segment=-1): + self._addrCheck(address) + return int(ffi.cast(self._type, self._rawRead(self._core, self._base + address, segment))) + + def rawWrite(self, address, value, segment=-1): + self._addrCheck(address) + self._rawWrite(self._core, self._base + address, segment, value & self._mask) + +class Memory(object): + def __init__(self, core, size, base=0): + self.size = size + self.base = base + + self.u8 = MemoryView(core, 1, size, base, "u") + self.u16 = MemoryView(core, 2, size, base, "u") + self.u32 = MemoryView(core, 4, size, base, "u") + self.s8 = MemoryView(core, 1, size, base, "s") + self.s16 = MemoryView(core, 2, size, base, "s") + self.s32 = MemoryView(core, 4, size, base, "s") + + def __len__(self): + return self._size From 7bd5ae9a701d00dd2668ae4ad5ddc3ba2785a333 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 28 Oct 2016 00:33:47 -0700 Subject: [PATCH 27/56] Core: Add flags.h generated file --- CMakeLists.txt | 3 ++ src/core/flags.h.in | 88 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 src/core/flags.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index f74c7dce0..0b8241f07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,6 +151,9 @@ add_custom_target(version-info ALL include(${CMAKE_CURRENT_SOURCE_DIR}/version.cmake) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/core/version.c.in ${CMAKE_CURRENT_BINARY_DIR}/version.c) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/core/flags.h.in ${CMAKE_CURRENT_BINARY_DIR}/flags.h) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/flags.h DESTINATION include/mgba COMPONENT lib${BINARY_NAME}) + list(APPEND UTIL_SRC ${CMAKE_CURRENT_BINARY_DIR}/version.c) source_group("Generated sources" FILES ${CMAKE_CURRENT_BINARY_DIR}/version.c) diff --git a/src/core/flags.h.in b/src/core/flags.h.in new file mode 100644 index 000000000..e6cc2e01c --- /dev/null +++ b/src/core/flags.h.in @@ -0,0 +1,88 @@ +#ifndef FLAGS_H +#define FLAGS_H + +#ifndef MINIMAL_CORE +#cmakedefine MINIMAL_CORE @MINIMAL_CORE@ +#endif + +// BUILD flags + +#ifndef BUILD_GL +#cmakedefine BUILD_GL +#endif + +#ifndef BUILD_GLES2 +#cmakedefine BUILD_GLES2 +#endif + +// COLOR flags + +#ifndef COLOR_16_BIT +#cmakedefine COLOR_16_BIT +#endif + +#ifndef COLOR_5_6_5 +#cmakedefine COLOR_5_6_5 +#endif + +// M_CORE flags + +#ifndef M_CORE_GBA +#cmakedefine M_CORE_GBA +#endif + +#ifndef M_CORE_GB +#cmakedefine M_CORE_GB +#endif + +// USE flags + +#ifndef USE_EDITLINE +#cmakedefine USE_EDITLINE +#endif + +#ifndef USE_EPOXY +#cmakedefine USE_EPOXY +#endif + +#ifndef USE_FFMPEG +#cmakedefine USE_FFMPEG +#endif + +#ifndef USE_GDB_STUB +#cmakedefine USE_GDB_STUB +#endif + +#ifndef USE_LIBAV +#cmakedefine USE_LIBAV +#endif + +#ifndef USE_LIBZIP +#cmakedefine USE_LIBZIP +#endif + +#ifndef USE_LZMA +#cmakedefine USE_LZMA +#endif + +#ifndef USE_MAGICK +#cmakedefine USE_MAGICK +#endif + +#ifndef USE_MINIZIP +#cmakedefine USE_MINIZIP +#endif + +#ifndef USE_PNG +#cmakedefine USE_PNG +#endif + +#ifndef USE_PTHREADS +#cmakedefine USE_PTHREADS +#endif + +#ifndef USE_ZLIB +#cmakedefine USE_ZLIB +#endif + +#endif From 34964495171d71264e34874e001046c471b2df74 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 28 Oct 2016 15:39:43 -0700 Subject: [PATCH 28/56] Python: Flags cleanup --- src/platform/python/CMakeLists.txt | 29 ++++----------------- src/platform/python/_builder.h | 3 +++ src/platform/python/_builder.py | 42 +++++++++++++++++++----------- src/platform/python/setup.py.in | 6 ++++- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/platform/python/CMakeLists.txt b/src/platform/python/CMakeLists.txt index 4a56b1474..b3841c45d 100644 --- a/src/platform/python/CMakeLists.txt +++ b/src/platform/python/CMakeLists.txt @@ -1,30 +1,11 @@ find_program(PYTHON python) -set(PY_INCLUDE_DIRS -I${CMAKE_SOURCE_DIR}/src) -get_property(INCLUDE_DIRECTORIES DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) -get_property(COMPILE_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS) -foreach(INCLUDE_DIR IN LISTS INCLUDE_DIRECTORIES) - list(APPEND PY_INCLUDE_DIRS -I${INCLUDE_DIR}) -endforeach() -foreach(COMPILE_DEF IN LISTS COMPILE_DEFINITIONS FEATURE_DEFINES) - list(APPEND PY_COMPILE_DEFS -D${COMPILE_DEF}) -endforeach() - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py) -add_custom_command(OUTPUT _builder.h - COMMAND ${CMAKE_C_COMPILER} ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} -fno-inline -E -P -c ${CMAKE_CURRENT_SOURCE_DIR}/_builder.h -o _builder.h - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.h) -add_custom_target(_builder.h ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_builder.h) - -add_custom_target(${BINARY_NAME}-pylib COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py - DEPENDS _builder.h) - -add_custom_command(OUTPUT ${BINARY_NAME}/__init__.py - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${BINARY_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME} - COMMAND ${PYTHON} ${CMAKE_CURRENT_BINARY_DIR}/setup.py build +add_custom_command(OUTPUT build/lib/${BINARY_NAME}/__init__.py + COMMAND BINDIR=${CMAKE_CURRENT_BINARY_DIR}/.. ${PYTHON} ${CMAKE_CURRENT_BINARY_DIR}/setup.py build --build-base ${CMAKE_CURRENT_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/setup.py - DEPENDS ${BINARY_NAME}-pylib) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py) -add_custom_target(${BINARY_NAME}-py ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}/__init__.py) +add_custom_target(${BINARY_NAME}-py ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/build/lib/${BINARY_NAME}/__init__.py) diff --git a/src/platform/python/_builder.h b/src/platform/python/_builder.h index bb5f8b75c..d074ae4c5 100644 --- a/src/platform/python/_builder.h +++ b/src/platform/python/_builder.h @@ -20,6 +20,9 @@ typedef ...* png_unknown_chunkp; void free(void*); #include +#undef const + +#include "flags.h" #include "core/core.h" #include "core/tile-cache.h" diff --git a/src/platform/python/_builder.py b/src/platform/python/_builder.py index 31cdade94..4bf78ce53 100644 --- a/src/platform/python/_builder.py +++ b/src/platform/python/_builder.py @@ -1,12 +1,22 @@ import cffi -import os.path +import os, os.path +import shlex import subprocess import sys ffi = cffi.FFI() -src = os.path.join(os.path.dirname(__file__), "..", "..") +pydir = os.path.dirname(os.path.abspath(__file__)) +srcdir = os.path.join(pydir, "..", "..") +bindir = os.environ.get("BINDIR", os.path.join(os.getcwd(), "..")) + +cpp = shlex.split(os.environ.get("CPP", "cc -E")) +cppflags = shlex.split(os.environ.get("CPPFLAGS", "")) +if __name__ == "__main__": + cppflags.extend(sys.argv[1:]) +cppflags.extend(["-I" + srcdir, "-I" + bindir]) ffi.set_source("mgba._pylib", """ +#include "flags.h" #include "util/common.h" #include "core/core.h" #include "core/log.h" @@ -34,19 +44,21 @@ struct mLoggerPy { struct mLogger d; void* pyobj; }; -""", include_dirs=[src], - extra_compile_args=sys.argv[1:], +""", include_dirs=[srcdir], + extra_compile_args=cppflags, libraries=["mgba"], - library_dirs=[os.path.join(os.getcwd(), "..")], - sources=[os.path.join(os.path.dirname(__file__), path) for path in ["vfs-py.c", "log.c"]]) + library_dirs=[bindir], + sources=[os.path.join(pydir, path) for path in ["vfs-py.c", "log.c"]]) -with open(os.path.join(os.getcwd(), "_builder.h")) as core: - lines = [] - for line in core: - line = line.strip() - if line.startswith('#'): - continue - lines.append(line) - ffi.cdef('\n'.join(lines)) +preprocessed = subprocess.check_output(cpp + ["-fno-inline", "-P"] + cppflags + [os.path.join(pydir, "_builder.h")], universal_newlines=True) -ffi.compile() +lines = [] +for line in preprocessed.splitlines(): + line = line.strip() + if line.startswith('#'): + continue + lines.append(line) +ffi.cdef('\n'.join(lines)) + +if __name__ == "__main__": + ffi.compile() diff --git a/src/platform/python/setup.py.in b/src/platform/python/setup.py.in index 1884778cf..31ce6cd52 100644 --- a/src/platform/python/setup.py.in +++ b/src/platform/python/setup.py.in @@ -2,9 +2,12 @@ from setuptools import setup import re classifiers = [ + "Programming Language :: C", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", - "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)" + "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", + "Topic :: Games/Entertainment", + "Topic :: System :: Emulators" ] setup(name="${BINARY_NAME}", @@ -15,6 +18,7 @@ setup(name="${BINARY_NAME}", packages=["mgba"], setup_requires=['cffi>=1.6'], install_requires=['cffi>=1.6', 'cached-property'], + cffi_modules=["_builder.py:ffi"], license="MPL 2.0", classifiers=classifiers ) From 3310210dc7b7ea79f711dc0e41076c2bf4589c9d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 28 Oct 2016 16:50:51 -0700 Subject: [PATCH 29/56] Python: Add NullLogger --- src/platform/python/mgba/log.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/platform/python/mgba/log.py b/src/platform/python/mgba/log.py index 846861e02..a3412b186 100644 --- a/src/platform/python/mgba/log.py +++ b/src/platform/python/mgba/log.py @@ -32,3 +32,7 @@ class Logger(object): def log(self, category, level, message): print("{}: {}".format(self.categoryName(category), message)) + +class NullLogger(Logger): + def log(self, category, level, message): + pass From 6f591996a8307bde8d424ab37a0db67956097187 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 6 Nov 2016 21:23:18 -0800 Subject: [PATCH 30/56] Python: Add hook preventing functions that need resets from being called --- src/platform/python/mgba/core.py | 13 +++++++++++++ src/platform/python/mgba/gb.py | 3 ++- src/platform/python/mgba/gba.py | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/platform/python/mgba/core.py b/src/platform/python/mgba/core.py index ad051e33d..8d86e3127 100644 --- a/src/platform/python/mgba/core.py +++ b/src/platform/python/mgba/core.py @@ -31,9 +31,17 @@ def loadVF(vf): return None return core +def needsReset(f): + def wrapper(self, *args, **kwargs): + if not self._wasReset: + raise RuntimeError("Core must be reset first") + return f(self, *args, **kwargs) + return wrapper + class Core(object): def __init__(self, native): self._core = native + self._wasReset = False @cached_property def tiles(self): @@ -92,13 +100,17 @@ class Core(object): def reset(self): self._core.reset(self._core) + self._wasReset = True + @needsReset def runFrame(self): self._core.runFrame(self._core) + @needsReset def runLoop(self): self._core.runLoop(self._core) + @needsReset def step(self): self._core.step(self._core) @@ -120,6 +132,7 @@ class Core(object): def clearKeys(self, *args, **kwargs): self._core.clearKeys(self._core, self._keysToInt(*args, **kwargs)) + @needsReset def frameCounter(self): return self._core.frameCounter(self._core) diff --git a/src/platform/python/mgba/gb.py b/src/platform/python/mgba/gb.py index eed40e189..0caf7ec99 100644 --- a/src/platform/python/mgba/gb.py +++ b/src/platform/python/mgba/gb.py @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. from ._pylib import ffi, lib from .lr35902 import LR35902Core -from .core import Core +from .core import Core, needsReset from .memory import Memory from .tile import Sprite @@ -25,6 +25,7 @@ class GB(Core): self.sprites = GBObjs(self) self.cpu = LR35902Core(self._core.cpu) + @needsReset def _initTileCache(self, cache): lib.GBVideoTileCacheInit(cache) lib.GBVideoTileCacheAssociate(cache, ffi.addressof(self._native.video)) diff --git a/src/platform/python/mgba/gba.py b/src/platform/python/mgba/gba.py index 40e059a4c..123c953ce 100644 --- a/src/platform/python/mgba/gba.py +++ b/src/platform/python/mgba/gba.py @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. from ._pylib import ffi, lib from .arm import ARMCore -from .core import Core +from .core import Core, needsReset from .tile import Sprite from .memory import Memory @@ -28,6 +28,7 @@ class GBA(Core): self.cpu = ARMCore(self._core.cpu) self.memory = GBAMemory(self._core) + @needsReset def _initTileCache(self, cache): lib.GBAVideoTileCacheInit(cache) lib.GBAVideoTileCacheAssociate(cache, ffi.addressof(self._native.video)) From 2706cf991d032e09e8d71166e56b50437fe82dbd Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 15 Nov 2016 15:30:14 -0800 Subject: [PATCH 31/56] Python: Make cartridge memory size cap properly --- src/platform/python/mgba/gba.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/platform/python/mgba/gba.py b/src/platform/python/mgba/gba.py index 123c953ce..0b8e12fee 100644 --- a/src/platform/python/mgba/gba.py +++ b/src/platform/python/mgba/gba.py @@ -26,7 +26,6 @@ class GBA(Core): self._native = ffi.cast("struct GBA*", native.board) self.sprites = GBAObjs(self) self.cpu = ARMCore(self._core.cpu) - self.memory = GBAMemory(self._core) @needsReset def _initTileCache(self, cache): @@ -37,8 +36,12 @@ class GBA(Core): self._native.video.renderer.cache = ffi.NULL lib.mTileCacheDeinit(cache) + def reset(self): + super(GBA, self).reset() + self.memory = GBAMemory(self._core, self._native.memory.romSize) + class GBAMemory(Memory): - def __init__(self, core): + def __init__(self, core, romSize=lib.SIZE_CART0): super(GBAMemory, self).__init__(core, 0x100000000) self.bios = Memory(core, lib.SIZE_BIOS, lib.BASE_BIOS) @@ -48,10 +51,11 @@ class GBAMemory(Memory): self.palette = Memory(core, lib.SIZE_PALETTE_RAM, lib.BASE_PALETTE_RAM) self.vram = Memory(core, lib.SIZE_VRAM, lib.BASE_VRAM) self.oam = Memory(core, lib.SIZE_OAM, lib.BASE_OAM) - self.cart0 = Memory(core, lib.SIZE_CART0, lib.BASE_CART0) - self.cart1 = Memory(core, lib.SIZE_CART1, lib.BASE_CART1) - self.cart2 = Memory(core, lib.SIZE_CART2, lib.BASE_CART2) + self.cart0 = Memory(core, romSize, lib.BASE_CART0) + self.cart1 = Memory(core, romSize, lib.BASE_CART1) + self.cart2 = Memory(core, romSize, lib.BASE_CART2) self.cart = self.cart0 + self.rom = self.cart0 self.sram = Memory(core, lib.SIZE_CART_SRAM, lib.BASE_CART_SRAM) class GBASprite(Sprite): From 74803ac15b4d22bac87b231200eeb42e7ce93d6e Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 15 Nov 2016 15:30:30 -0800 Subject: [PATCH 32/56] Python: Add slicing to memory operations --- src/platform/python/mgba/memory.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/platform/python/mgba/memory.py b/src/platform/python/mgba/memory.py index 7827e578d..a7f52e22e 100644 --- a/src/platform/python/mgba/memory.py +++ b/src/platform/python/mgba/memory.py @@ -24,9 +24,15 @@ class MemoryView(object): raise ValueError("Invalid sign type: '{}'".format(sign)) def _addrCheck(self, address): - if address >= self._size or address + self._width > self._size: + if isinstance(address, slice): + start = address.start or 0 + stop = self._size - self._width if address.stop is None else address.stop + else: + start = address + stop = address + self._width + if start >= self._size or stop > self._size: raise IndexError() - if address < 0: + if start < 0 or stop < 0: raise IndexError() def __len__(self): @@ -34,11 +40,24 @@ class MemoryView(object): def __getitem__(self, address): self._addrCheck(address) - return int(ffi.cast(self._type, self._busRead(self._core, self._base + address))) + if isinstance(address, slice): + start = address.start or 0 + stop = self._size - self._width if address.stop is None else address.stop + step = address.step or self._width + return [int(ffi.cast(self._type, self._busRead(self._core, self._base + a))) for a in range(start, stop, step)] + else: + return int(ffi.cast(self._type, self._busRead(self._core, self._base + address))) def __setitem__(self, address, value): self._addrCheck(address) - self._busWrite(self._core, self._base + address, value & self._mask) + if isinstance(address, slice): + start = address.start or 0 + stop = self._size - self._width if address.stop is None else address.stop + step = address.step or self._width + for a in range(start, stop, step): + self._busWrite(self._core, self._base + a, value[a] & self._mask) + else: + self._busWrite(self._core, self._base + address, value & self._mask) def rawRead(self, address, segment=-1): self._addrCheck(address) From 55a9bf3ca790fb93901dc0ea6bff168ba23aafa7 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 20 Dec 2016 18:51:12 -0800 Subject: [PATCH 33/56] All: Fix broken #ifdefs --- src/gba/rr/vbm.c | 2 +- src/util/vfs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gba/rr/vbm.c b/src/gba/rr/vbm.c index 5a3f0d0b6..c9ebca2e4 100644 --- a/src/gba/rr/vbm.c +++ b/src/gba/rr/vbm.c @@ -245,7 +245,7 @@ bool GBAVBMSetStream(struct GBAVBMContext* vbm, struct VFile* vf) { uint8_t flags; vf->read(vf, &flags, sizeof(flags)); if (flags & 2) { -#if USE_ZLIB +#ifdef USE_ZLIB vbm->d.initFrom = INIT_FROM_SAVEGAME; #else // zlib is needed to parse the savegame diff --git a/src/util/vfs.c b/src/util/vfs.c index 5f6533762..27932c717 100644 --- a/src/util/vfs.c +++ b/src/util/vfs.c @@ -104,7 +104,7 @@ struct VDir* VDirOpenArchive(const char* path) { dir = VDirOpenZip(path, 0); } #endif -#if USE_LZMA +#ifdef USE_LZMA if (!dir) { dir = VDirOpen7z(path, 0); } From f9caf8541a69cf5dd6569bcb557de764983e5571 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 20 Dec 2016 18:58:49 -0800 Subject: [PATCH 34/56] SDL: Update sdl-gles2.c --- src/platform/sdl/gles2-sdl.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/platform/sdl/gles2-sdl.c b/src/platform/sdl/gles2-sdl.c index c45821ddf..7d55362c9 100644 --- a/src/platform/sdl/gles2-sdl.c +++ b/src/platform/sdl/gles2-sdl.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2015 Jeffrey Pfau +/* Copyright (c) 2013-2016 Jeffrey Pfau * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,16 +7,20 @@ #include "gl-common.h" +#include "core/thread.h" + +#ifndef __APPLE__ #include +#endif static bool mSDLGLES2Init(struct mSDLRenderer* renderer); -static void mSDLGLES2RunloopGBA(struct mSDLRenderer* renderer, void* user); +static void mSDLGLES2Runloop(struct mSDLRenderer* renderer, void* user); static void mSDLGLES2Deinit(struct mSDLRenderer* renderer); void mSDLGLES2Create(struct mSDLRenderer* renderer) { renderer->init = mSDLGLES2Init; renderer->deinit = mSDLGLES2Deinit; - renderer->runloop = mSDLGLES2RunloopGBA; + renderer->runloop = mSDLGLES2Runloop; } bool mSDLGLES2Init(struct mSDLRenderer* renderer) { @@ -93,8 +97,13 @@ bool mSDLGLES2Init(struct mSDLRenderer* renderer) { mSDLGLCommonInit(renderer); #endif - renderer->d.outputBuffer = memalign(16, VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4); - renderer->d.outputBufferStride = VIDEO_HORIZONTAL_PIXELS; +#ifndef __APPLE__ + renderer->outputBuffer = memalign(16, renderer->width * renderer->height * BYTES_PER_PIXEL); +#else + posix_memalign((void**) &renderer->outputBuffer, 16, renderer->width * renderer->height * BYTES_PER_PIXEL); +#endif + memset(renderer->outputBuffer, 0, renderer->width * renderer->height * BYTES_PER_PIXEL); + renderer->core->setVideoBuffer(renderer->core, renderer->outputBuffer, renderer->width); mGLES2ContextCreate(&renderer->gl2); renderer->gl2.d.user = renderer; @@ -107,17 +116,17 @@ bool mSDLGLES2Init(struct mSDLRenderer* renderer) { } void mSDLGLES2Runloop(struct mSDLRenderer* renderer, void* user) { - struct GBAThread* context = user; + struct mCoreThread* context = user; SDL_Event event; struct VideoBackend* v = &renderer->gl2.d; while (context->state < THREAD_EXITING) { while (SDL_PollEvent(&event)) { - mSDLHandleEventGBA(context, &renderer->player, &event); + mSDLHandleEvent(context, &renderer->player, &event); } if (mCoreSyncWaitFrameStart(&context->sync)) { - v->postFrame(v, renderer->d.outputBuffer); + v->postFrame(v, renderer->outputBuffer); } mCoreSyncWaitFrameEnd(&context->sync); v->drawFrame(v); @@ -142,5 +151,5 @@ void mSDLGLES2Deinit(struct mSDLRenderer* renderer) { #elif SDL_VERSION_ATLEAST(2, 0, 0) SDL_GL_DeleteContext(renderer->glCtx); #endif - free(renderer->d.outputBuffer); + free(renderer->outputBuffer); } From 91a503397b3d36bc6c06bbec2bd074b74beb56fe Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 20 Dec 2016 18:59:46 -0800 Subject: [PATCH 35/56] Core: Update flags.h --- src/core/flags.h.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/flags.h.in b/src/core/flags.h.in index e6cc2e01c..aa2236dd1 100644 --- a/src/core/flags.h.in +++ b/src/core/flags.h.in @@ -37,6 +37,12 @@ // USE flags +#ifndef MINIMAL_CORE + +#ifndef USE_DEBUGGERS +#cmakedefine USE_DEBUGGERS +#endif + #ifndef USE_EDITLINE #cmakedefine USE_EDITLINE #endif @@ -86,3 +92,5 @@ #endif #endif + +#endif From 361e8e95b4bd7c9ca18dea8c5edcd0d5efcf8a46 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 25 Dec 2016 15:23:53 -0800 Subject: [PATCH 36/56] Python: Make Python bindings depend on library --- src/platform/python/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/platform/python/CMakeLists.txt b/src/platform/python/CMakeLists.txt index b3841c45d..adda679bd 100644 --- a/src/platform/python/CMakeLists.txt +++ b/src/platform/python/CMakeLists.txt @@ -5,6 +5,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in ${CMAKE_CURRENT_BINARY_DI add_custom_command(OUTPUT build/lib/${BINARY_NAME}/__init__.py COMMAND BINDIR=${CMAKE_CURRENT_BINARY_DIR}/.. ${PYTHON} ${CMAKE_CURRENT_BINARY_DIR}/setup.py build --build-base ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${BINARY_NAME} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/setup.py DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py) From ceea51b55ea2f112c49b4ad22e6d70b08ad430e7 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 25 Dec 2016 20:39:11 -0800 Subject: [PATCH 37/56] GB: First pass at lockstep multiplayer --- CMakeLists.txt | 13 +- src/core/lockstep.c | 16 ++ src/core/lockstep.h | 37 ++++ src/gb/gb.c | 5 + src/gb/gb.h | 1 + src/gb/io.c | 4 +- src/gb/sio.c | 47 ++++- src/gb/sio.h | 20 ++ src/gb/sio/lockstep.c | 231 ++++++++++++++++++++++ src/gb/sio/lockstep.h | 44 +++++ src/gba/sio/lockstep.c | 86 ++++---- src/gba/sio/lockstep.h | 32 +-- src/platform/qt/GBAApp.h | 1 + src/platform/qt/MultiplayerController.cpp | 136 +++++++++++-- src/platform/qt/MultiplayerController.h | 20 +- 15 files changed, 590 insertions(+), 103 deletions(-) create mode 100644 src/core/lockstep.c create mode 100644 src/core/lockstep.h create mode 100644 src/gb/sio/lockstep.c create mode 100644 src/gb/sio/lockstep.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b048f9cc..8be589a23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,8 @@ file(GLOB UTIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/*.[cSs]) file(GLOB UTIL_TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/test/*.c) file(GLOB GUI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/gui/*.c ${CMAKE_CURRENT_SOURCE_DIR}/src/feature/gui/*.c) file(GLOB GBA_RENDERER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/renderers/*.c) -file(GLOB SIO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/sio/lockstep.c) +file(GLOB GBA_SIO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gba/sio/lockstep.c) +file(GLOB GB_SIO_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gb/sio/lockstep.c) file(GLOB GB_RENDERER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/gb/renderers/*.c) file(GLOB THIRD_PARTY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/inih/*.c) set(CLI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/feature/commandline.c) @@ -59,9 +60,9 @@ set(CORE_VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-mem.c) set(VFS_SRC) source_group("ARM core" FILES ${ARM_SRC}) source_group("LR35902 core" FILES ${LR35902_SRC}) -source_group("GBA board" FILES ${GBA_SRC} ${GBA_RENDERER_SRC} ${SIO_SRC}) +source_group("GBA board" FILES ${GBA_SRC} ${GBA_RENDERER_SRC} ${GBA_SIO_SRC}) source_group("GBA extra" FILES ${GBA_CHEATS_SRC} ${GBA_RR_SRC}) -source_group("GB board" FILES ${GB_SRC}) +source_group("GB board" FILES ${GB_SRC} ${GB_SIO_SRC}) source_group("Utilities" FILES ${UTIL_SRC}) include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src) @@ -616,7 +617,11 @@ if(NOT MINIMAL_CORE) list(APPEND SRC ${GBA_RR_SRC} ${GBA_EXTRA_SRC} - ${SIO_SRC}) + ${GBA_SIO_SRC}) + endif() + if(M_CORE_GB) + list(APPEND SRC + ${GB_SIO_SRC}) endif() list(APPEND SRC ${FEATURE_SRC} diff --git a/src/core/lockstep.c b/src/core/lockstep.c new file mode 100644 index 000000000..28bc03355 --- /dev/null +++ b/src/core/lockstep.c @@ -0,0 +1,16 @@ +/* Copyright (c) 2013-2016 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "lockstep.h" + +void mLockstepInit(struct mLockstep* lockstep) { + lockstep->attached = 0; + lockstep->transferActive = 0; +#ifndef NDEBUG + lockstep->transferId = 0; +#endif +} + +// TODO: Migrate nodes diff --git a/src/core/lockstep.h b/src/core/lockstep.h new file mode 100644 index 000000000..cea0fd1d8 --- /dev/null +++ b/src/core/lockstep.h @@ -0,0 +1,37 @@ +/* Copyright (c) 2013-2016 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef SIO_LOCKSTEP_H +#define SIO_LOCKSTEP_H + +#include "util/common.h" + +enum mLockstepPhase { + TRANSFER_IDLE = 0, + TRANSFER_STARTING, + TRANSFER_STARTED, + TRANSFER_FINISHING, + TRANSFER_FINISHED +}; + +struct mLockstep { + int attached; + enum mLockstepPhase transferActive; + int32_t transferCycles; + + bool (*signal)(struct mLockstep*, unsigned mask); + bool (*wait)(struct mLockstep*, unsigned mask); + void (*addCycles)(struct mLockstep*, int id, int32_t cycles); + int32_t (*useCycles)(struct mLockstep*, int id, int32_t cycles); + void (*unload)(struct mLockstep*, int id); + void* context; +#ifndef NDEBUG + int transferId; +#endif +}; + +void mLockstepInit(struct mLockstep*); + +#endif diff --git a/src/gb/gb.c b/src/gb/gb.c index 9a307e23d..6a47ccf63 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -433,6 +433,7 @@ void GBReset(struct LR35902Core* cpu) { } gb->cpuBlocked = false; + gb->earlyExit = false; gb->doubleSpeed = 0; cpu->memory.setActiveRegion(cpu, cpu->pc); @@ -548,6 +549,10 @@ void GBProcessEvents(struct LR35902Core* cpu) { } while (gb->cpuBlocked); cpu->nextEvent = nextEvent; + if (gb->earlyExit) { + gb->earlyExit = false; + break; + } if (cpu->halted) { cpu->cycles = cpu->nextEvent; if (!gb->memory.ie || !gb->memory.ime) { diff --git a/src/gb/gb.h b/src/gb/gb.h index 89e38c6de..dba27742a 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -79,6 +79,7 @@ struct GB { struct mAVStream* stream; bool cpuBlocked; + bool earlyExit; struct mTimingEvent eiPending; unsigned doubleSpeed; }; diff --git a/src/gb/io.c b/src/gb/io.c index bcdee83da..4a3d5e59d 100644 --- a/src/gb/io.c +++ b/src/gb/io.c @@ -158,6 +158,9 @@ void GBIOReset(struct GB* gb) { void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) { switch (address) { + case REG_SB: + GBSIOWriteSB(&gb->sio, value); + break; case REG_SC: GBSIOWriteSC(&gb->sio, value); break; @@ -338,7 +341,6 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) { } break; case REG_JOYP: - case REG_SB: case REG_TIMA: case REG_TMA: // Handled transparently by the registers diff --git a/src/gb/sio.c b/src/gb/sio.c index 2758cafa4..097b53f26 100644 --- a/src/gb/sio.c +++ b/src/gb/sio.c @@ -9,6 +9,13 @@ #include "gb/io.h" #include "gb/serialize.h" +mLOG_DEFINE_CATEGORY(GB_SIO, "GB Serial I/O"); + +const int GBSIOCyclesPerTransfer[2] = { + 512, + 16 +}; + void _GBSIOProcessEvents(struct mTiming* timing, void* context, uint32_t cyclesLate); void GBSIOInit(struct GBSIO* sio) { @@ -17,6 +24,8 @@ void GBSIOInit(struct GBSIO* sio) { sio->event.name = "GB SIO"; sio->event.callback = _GBSIOProcessEvents; sio->event.priority = 0x30; + + sio->driver = NULL; } void GBSIOReset(struct GBSIO* sio) { @@ -29,6 +38,26 @@ void GBSIODeinit(struct GBSIO* sio) { // Nothing to do yet } +void GBSIOSetDriver(struct GBSIO* sio, struct GBSIODriver* driver) { + if (sio->driver) { + if (sio->driver->deinit) { + sio->driver->deinit(sio->driver); + } + } + if (driver) { + driver->p = sio; + + if (driver->init) { + if (!driver->init(driver)) { + driver->deinit(driver); + mLOG(GB_SIO, ERROR, "Could not initialize SIO driver"); + return; + } + } + } + sio->driver = driver; +} + void _GBSIOProcessEvents(struct mTiming* timing, void* context, uint32_t cyclesLate) { UNUSED(cyclesLate); struct GBSIO* sio = context; @@ -38,19 +67,29 @@ void _GBSIOProcessEvents(struct mTiming* timing, void* context, uint32_t cyclesL if (!sio->remainingBits) { sio->p->memory.io[REG_IF] |= (1 << GB_IRQ_SIO); sio->p->memory.io[REG_SC] = GBRegisterSCClearEnable(sio->p->memory.io[REG_SC]); + sio->pendingSB = 0xFF; GBUpdateIRQs(sio->p); } else { mTimingSchedule(timing, &sio->event, sio->period); } } +void GBSIOWriteSB(struct GBSIO* sio, uint8_t sb) { + if (!sio->driver) { + return; + } + sio->driver->writeSB(sio->driver, sb); +} + void GBSIOWriteSC(struct GBSIO* sio, uint8_t sc) { - sio->period = 0x1000; // TODO Shift Clock + sio->period = GBSIOCyclesPerTransfer[GBRegisterSCGetClockSpeed(sc)]; // TODO Shift Clock if (GBRegisterSCIsEnable(sc)) { - if (GBRegisterSCIsShiftClock(sc)) { - mTimingSchedule(&sio->p->timing, &sio->event, sio->period); - } + mTimingDeschedule(&sio->p->timing, &sio->event); + mTimingSchedule(&sio->p->timing, &sio->event, sio->period); sio->remainingBits = 8; } + if (sio->driver) { + sio->driver->writeSC(sio->driver, sc); + } } diff --git a/src/gb/sio.h b/src/gb/sio.h index 715b5b9c8..e5dbe6bbd 100644 --- a/src/gb/sio.h +++ b/src/gb/sio.h @@ -8,13 +8,22 @@ #include "util/common.h" +#include "core/log.h" #include "core/timing.h" +#define MAX_GBS 2 + +extern const int GBSIOCyclesPerTransfer[2]; + +mLOG_DECLARE_CATEGORY(GB_SIO); + struct GB; +struct GBSIODriver; struct GBSIO { struct GB* p; struct mTimingEvent event; + struct GBSIODriver* driver; int32_t nextEvent; int32_t period; @@ -23,6 +32,15 @@ struct GBSIO { uint8_t pendingSB; }; +struct GBSIODriver { + struct GBSIO* p; + + bool (*init)(struct GBSIODriver* driver); + void (*deinit)(struct GBSIODriver* driver); + void (*writeSB)(struct GBSIODriver* driver, uint8_t value); + uint8_t (*writeSC)(struct GBSIODriver* driver, uint8_t value); +}; + DECL_BITFIELD(GBRegisterSC, uint8_t); DECL_BIT(GBRegisterSC, ShiftClock, 0); DECL_BIT(GBRegisterSC, ClockSpeed, 1); @@ -31,6 +49,8 @@ DECL_BIT(GBRegisterSC, Enable, 7); void GBSIOInit(struct GBSIO* sio); void GBSIOReset(struct GBSIO* sio); void GBSIODeinit(struct GBSIO* sio); +void GBSIOSetDriver(struct GBSIO* sio, struct GBSIODriver* driver); void GBSIOWriteSC(struct GBSIO* sio, uint8_t sc); +void GBSIOWriteSB(struct GBSIO* sio, uint8_t sb); #endif diff --git a/src/gb/sio/lockstep.c b/src/gb/sio/lockstep.c new file mode 100644 index 000000000..08d1b8cbc --- /dev/null +++ b/src/gb/sio/lockstep.c @@ -0,0 +1,231 @@ +/* Copyright (c) 2013-2016 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "lockstep.h" + +#include "gb/gb.h" +#include "gb/io.h" + +#define LOCKSTEP_INCREMENT 500 + +static bool GBSIOLockstepNodeInit(struct GBSIODriver* driver); +static void GBSIOLockstepNodeDeinit(struct GBSIODriver* driver); +static void GBSIOLockstepNodeWriteSB(struct GBSIODriver* driver, uint8_t value); +static uint8_t GBSIOLockstepNodeWriteSC(struct GBSIODriver* driver, uint8_t value); +static void _GBSIOLockstepNodeProcessEvents(struct mTiming* timing, void* driver, uint32_t cyclesLate); + +void GBSIOLockstepInit(struct GBSIOLockstep* lockstep) { + mLockstepInit(&lockstep->d); + lockstep->players[0] = NULL; + lockstep->players[1] = NULL; + lockstep->pendingSB[0] = 0xFF; + lockstep->pendingSB[1] = 0xFF; +} + +void GBSIOLockstepNodeCreate(struct GBSIOLockstepNode* node) { + node->d.init = GBSIOLockstepNodeInit; + node->d.deinit = GBSIOLockstepNodeDeinit; + node->d.writeSB = GBSIOLockstepNodeWriteSB; + node->d.writeSC = GBSIOLockstepNodeWriteSC; +} + +bool GBSIOLockstepAttachNode(struct GBSIOLockstep* lockstep, struct GBSIOLockstepNode* node) { + if (lockstep->d.attached == MAX_GBS) { + return false; + } + lockstep->players[lockstep->d.attached] = node; + node->p = lockstep; + node->id = lockstep->d.attached; + ++lockstep->d.attached; + return true; +} + +void GBSIOLockstepDetachNode(struct GBSIOLockstep* lockstep, struct GBSIOLockstepNode* node) { + if (lockstep->d.attached == 0) { + return; + } + int i; + for (i = 0; i < lockstep->d.attached; ++i) { + if (lockstep->players[i] != node) { + continue; + } + for (++i; i < lockstep->d.attached; ++i) { + lockstep->players[i - 1] = lockstep->players[i]; + lockstep->players[i - 1]->id = i - 1; + } + --lockstep->d.attached; + break; + } +} + +bool GBSIOLockstepNodeInit(struct GBSIODriver* driver) { + struct GBSIOLockstepNode* node = (struct GBSIOLockstepNode*) driver; + mLOG(GB_SIO, DEBUG, "Lockstep %i: Node init", node->id); + node->event.context = node; + node->event.name = "GB SIO Lockstep"; + node->event.callback = _GBSIOLockstepNodeProcessEvents; + node->event.priority = 0x80; + + node->nextEvent = 0; + node->eventDiff = 0; + mTimingSchedule(&driver->p->p->timing, &node->event, 0); +#ifndef NDEBUG + node->phase = node->p->d.transferActive; + node->transferId = node->p->d.transferId; +#endif + return true; +} + +void GBSIOLockstepNodeDeinit(struct GBSIODriver* driver) { + struct GBSIOLockstepNode* node = (struct GBSIOLockstepNode*) driver; + node->p->d.unload(&node->p->d, node->id); + mTimingDeschedule(&driver->p->p->timing, &node->event); +} + +static void _finishTransfer(struct GBSIOLockstepNode* node) { + if (node->transferFinished) { + return; + } + struct GBSIO* sio = node->d.p; + sio->pendingSB = node->p->pendingSB[!node->id]; + node->transferFinished = true; +#ifndef NDEBUG + ++node->transferId; +#endif +} + + +static int32_t _masterUpdate(struct GBSIOLockstepNode* node) { + bool needsToWait = false; + int i; + switch (node->p->d.transferActive) { + case TRANSFER_IDLE: + // If the master hasn't initiated a transfer, it can keep going. + node->nextEvent += LOCKSTEP_INCREMENT; + break; + case TRANSFER_STARTING: + // Start the transfer, but wait for the other GBs to catch up + node->transferFinished = false; + needsToWait = true; + ATOMIC_STORE(node->p->d.transferActive, TRANSFER_STARTED); + node->nextEvent += 128; + break; + case TRANSFER_STARTED: + // All the other GBs have caught up and are sleeping, we can all continue now + node->nextEvent += 128; + ATOMIC_STORE(node->p->d.transferActive, TRANSFER_FINISHING); + break; + case TRANSFER_FINISHING: + // Finish the transfer + // We need to make sure the other GBs catch up so they don't get behind + node->nextEvent += LOCKSTEP_INCREMENT - 256; // Split the cycles to avoid waiting too long +#ifndef NDEBUG + ATOMIC_ADD(node->p->d.transferId, 1); +#endif + needsToWait = true; + ATOMIC_STORE(node->p->d.transferActive, TRANSFER_FINISHED); + break; + case TRANSFER_FINISHED: + // Everything's settled. We're done. + _finishTransfer(node); + node->nextEvent += LOCKSTEP_INCREMENT; + ATOMIC_STORE(node->p->d.transferActive, TRANSFER_IDLE); + break; + } + int mask = 0; + for (i = 1; i < node->p->d.attached; ++i) { + mask |= 1 << i; + } + if (mask) { + if (needsToWait) { + if (!node->p->d.wait(&node->p->d, mask)) { + abort(); + } + } else { + node->p->d.signal(&node->p->d, mask); + } + } + // Tell the other GBs they can continue up to where we were + node->p->d.addCycles(&node->p->d, 0, node->eventDiff); +#ifndef NDEBUG + node->phase = node->p->d.transferActive; +#endif + if (needsToWait) { + return 0; + } + return node->nextEvent; +} + +static uint32_t _slaveUpdate(struct GBSIOLockstepNode* node) { + bool signal = false; + switch (node->p->d.transferActive) { + case TRANSFER_IDLE: + node->p->d.addCycles(&node->p->d, node->id, LOCKSTEP_INCREMENT); + break; + case TRANSFER_STARTING: + case TRANSFER_FINISHING: + break; + case TRANSFER_STARTED: + node->transferFinished = false; + signal = true; + break; + case TRANSFER_FINISHED: + _finishTransfer(node); + signal = true; + break; + } +#ifndef NDEBUG + node->phase = node->p->d.transferActive; +#endif + if (signal) { + node->p->d.signal(&node->p->d, 1 << node->id); + } + return 0; +} + +static void _GBSIOLockstepNodeProcessEvents(struct mTiming* timing, void* user, uint32_t cyclesLate) { + struct GBSIOLockstepNode* node = user; + if (node->p->d.attached < 2) { + return; + } + int32_t cycles = 0; + node->nextEvent -= cyclesLate; + if (node->nextEvent <= 0) { + if (!node->id) { + cycles = _masterUpdate(node); + } else { + cycles = _slaveUpdate(node); + cycles += node->p->d.useCycles(&node->p->d, node->id, node->eventDiff); + } + node->eventDiff = 0; + } else { + cycles = node->nextEvent; + } + if (cycles > 0) { + node->nextEvent = 0; + node->eventDiff += cycles; + mTimingDeschedule(timing, &node->event); + mTimingSchedule(timing, &node->event, cycles); + } else { + node->d.p->p->earlyExit = true; + mTimingSchedule(timing, &node->event, cyclesLate + 1); + } +} + +static void GBSIOLockstepNodeWriteSB(struct GBSIODriver* driver, uint8_t value) { + struct GBSIOLockstepNode* node = (struct GBSIOLockstepNode*) driver; + node->p->pendingSB[node->id] = value; +} + +static uint8_t GBSIOLockstepNodeWriteSC(struct GBSIODriver* driver, uint8_t value) { + struct GBSIOLockstepNode* node = (struct GBSIOLockstepNode*) driver; + if (!node->id && (value & 0x81) == 0x81) { + node->p->d.transferActive = TRANSFER_STARTING; + node->p->d.transferCycles = GBSIOCyclesPerTransfer[(value >> 1) & 1]; + mTimingDeschedule(&driver->p->p->timing, &node->event); + mTimingSchedule(&driver->p->p->timing, &node->event, 0); + } + return value; +} diff --git a/src/gb/sio/lockstep.h b/src/gb/sio/lockstep.h new file mode 100644 index 000000000..85100ebae --- /dev/null +++ b/src/gb/sio/lockstep.h @@ -0,0 +1,44 @@ +/* Copyright (c) 2013-2016 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef GB_SIO_LOCKSTEP_H +#define GB_SIO_LOCKSTEP_H + +#include "util/common.h" + +#include "core/lockstep.h" +#include "core/timing.h" +#include "gb/sio.h" + +struct GBSIOLockstep { + struct mLockstep d; + struct GBSIOLockstepNode* players[MAX_GBS]; + + uint8_t pendingSB[MAX_GBS]; +}; + +struct GBSIOLockstepNode { + struct GBSIODriver d; + struct GBSIOLockstep* p; + struct mTimingEvent event; + + volatile int32_t nextEvent; + int32_t eventDiff; + int id; + bool transferFinished; +#ifndef NDEBUG + int transferId; + enum mLockstepPhase phase; +#endif +}; + +void GBSIOLockstepInit(struct GBSIOLockstep*); + +void GBSIOLockstepNodeCreate(struct GBSIOLockstepNode*); + +bool GBSIOLockstepAttachNode(struct GBSIOLockstep*, struct GBSIOLockstepNode*); +void GBSIOLockstepDetachNode(struct GBSIOLockstep*, struct GBSIOLockstepNode*); + +#endif diff --git a/src/gba/sio/lockstep.c b/src/gba/sio/lockstep.c index 1fd3d6b6d..142222a7b 100644 --- a/src/gba/sio/lockstep.c +++ b/src/gba/sio/lockstep.c @@ -20,6 +20,7 @@ static uint16_t GBASIOLockstepNodeNormalWriteRegister(struct GBASIODriver* drive static void _GBASIOLockstepNodeProcessEvents(struct mTiming* timing, void* driver, uint32_t cyclesLate); void GBASIOLockstepInit(struct GBASIOLockstep* lockstep) { + mLockstepInit(&lockstep->d); lockstep->players[0] = 0; lockstep->players[1] = 0; lockstep->players[2] = 0; @@ -28,16 +29,7 @@ void GBASIOLockstepInit(struct GBASIOLockstep* lockstep) { lockstep->multiRecv[1] = 0xFFFF; lockstep->multiRecv[2] = 0xFFFF; lockstep->multiRecv[3] = 0xFFFF; - lockstep->attached = 0; lockstep->attachedMulti = 0; - lockstep->transferActive = 0; -#ifndef NDEBUG - lockstep->transferId = 0; -#endif -} - -void GBASIOLockstepDeinit(struct GBASIOLockstep* lockstep) { - UNUSED(lockstep); } void GBASIOLockstepNodeCreate(struct GBASIOLockstepNode* node) { @@ -49,30 +41,30 @@ void GBASIOLockstepNodeCreate(struct GBASIOLockstepNode* node) { } bool GBASIOLockstepAttachNode(struct GBASIOLockstep* lockstep, struct GBASIOLockstepNode* node) { - if (lockstep->attached == MAX_GBAS) { + if (lockstep->d.attached == MAX_GBAS) { return false; } - lockstep->players[lockstep->attached] = node; + lockstep->players[lockstep->d.attached] = node; node->p = lockstep; - node->id = lockstep->attached; - ++lockstep->attached; + node->id = lockstep->d.attached; + ++lockstep->d.attached; return true; } void GBASIOLockstepDetachNode(struct GBASIOLockstep* lockstep, struct GBASIOLockstepNode* node) { - if (lockstep->attached == 0) { + if (lockstep->d.attached == 0) { return; } int i; - for (i = 0; i < lockstep->attached; ++i) { + for (i = 0; i < lockstep->d.attached; ++i) { if (lockstep->players[i] != node) { continue; } - for (++i; i < lockstep->attached; ++i) { + for (++i; i < lockstep->d.attached; ++i) { lockstep->players[i - 1] = lockstep->players[i]; lockstep->players[i - 1]->id = i - 1; } - --lockstep->attached; + --lockstep->d.attached; break; } } @@ -103,7 +95,7 @@ bool GBASIOLockstepNodeLoad(struct GBASIODriver* driver) { node->d.writeRegister = GBASIOLockstepNodeMultiWriteRegister; node->d.p->rcnt |= 3; ++node->p->attachedMulti; - node->d.p->multiplayerControl.ready = node->p->attachedMulti == node->p->attached; + node->d.p->multiplayerControl.ready = node->p->attachedMulti == node->p->d.attached; if (node->id) { node->d.p->rcnt |= 4; node->d.p->multiplayerControl.slave = 1; @@ -116,8 +108,8 @@ bool GBASIOLockstepNodeLoad(struct GBASIODriver* driver) { break; } #ifndef NDEBUG - node->phase = node->p->transferActive; - node->transferId = node->p->transferId; + node->phase = node->p->d.transferActive; + node->transferId = node->p->d.transferId; #endif return true; } @@ -132,7 +124,7 @@ bool GBASIOLockstepNodeUnload(struct GBASIODriver* driver) { default: break; } - node->p->unload(node->p, node->id); + node->p->d.unload(&node->p->d, node->id); mTimingDeschedule(&driver->p->p->timing, &node->event); return true; } @@ -141,11 +133,11 @@ static uint16_t GBASIOLockstepNodeMultiWriteRegister(struct GBASIODriver* driver struct GBASIOLockstepNode* node = (struct GBASIOLockstepNode*) driver; if (address == REG_SIOCNT) { mLOG(GBA_SIO, DEBUG, "Lockstep %i: SIOCNT <- %04x", node->id, value); - if (value & 0x0080 && node->p->transferActive == TRANSFER_IDLE) { + if (value & 0x0080 && node->p->d.transferActive == TRANSFER_IDLE) { if (!node->id && node->d.p->multiplayerControl.ready) { mLOG(GBA_SIO, DEBUG, "Lockstep %i: Transfer initiated", node->id); - node->p->transferActive = TRANSFER_STARTING; - node->p->transferCycles = GBASIOCyclesPerTransfer[node->d.p->multiplayerControl.baud][node->p->attached - 1]; + node->p->d.transferActive = TRANSFER_STARTING; + node->p->d.transferCycles = GBASIOCyclesPerTransfer[node->d.p->multiplayerControl.baud][node->p->d.attached - 1]; mTimingDeschedule(&driver->p->p->timing, &node->event); mTimingSchedule(&driver->p->p->timing, &node->event, 0); } else { @@ -218,11 +210,11 @@ static void _finishTransfer(struct GBASIOLockstepNode* node) { static int32_t _masterUpdate(struct GBASIOLockstepNode* node) { bool needsToWait = false; int i; - switch (node->p->transferActive) { + switch (node->p->d.transferActive) { case TRANSFER_IDLE: // If the master hasn't initiated a transfer, it can keep going. node->nextEvent += LOCKSTEP_INCREMENT; - node->d.p->multiplayerControl.ready = node->p->attachedMulti == node->p->attached; + node->d.p->multiplayerControl.ready = node->p->attachedMulti == node->p->d.attached; break; case TRANSFER_STARTING: // Start the transfer, but wait for the other GBAs to catch up @@ -232,51 +224,51 @@ static int32_t _masterUpdate(struct GBASIOLockstepNode* node) { node->p->multiRecv[2] = 0xFFFF; node->p->multiRecv[3] = 0xFFFF; needsToWait = true; - ATOMIC_STORE(node->p->transferActive, TRANSFER_STARTED); + ATOMIC_STORE(node->p->d.transferActive, TRANSFER_STARTED); node->nextEvent += 512; break; case TRANSFER_STARTED: // All the other GBAs have caught up and are sleeping, we can all continue now node->p->multiRecv[0] = node->d.p->p->memory.io[REG_SIOMLT_SEND >> 1]; node->nextEvent += 512; - ATOMIC_STORE(node->p->transferActive, TRANSFER_FINISHING); + ATOMIC_STORE(node->p->d.transferActive, TRANSFER_FINISHING); break; case TRANSFER_FINISHING: // Finish the transfer // We need to make sure the other GBAs catch up so they don't get behind - node->nextEvent += node->p->transferCycles - 1024; // Split the cycles to avoid waiting too long + node->nextEvent += node->p->d.transferCycles - 1024; // Split the cycles to avoid waiting too long #ifndef NDEBUG - ATOMIC_ADD(node->p->transferId, 1); + ATOMIC_ADD(node->p->d.transferId, 1); #endif needsToWait = true; - ATOMIC_STORE(node->p->transferActive, TRANSFER_FINISHED); + ATOMIC_STORE(node->p->d.transferActive, TRANSFER_FINISHED); break; case TRANSFER_FINISHED: // Everything's settled. We're done. _finishTransfer(node); node->nextEvent += LOCKSTEP_INCREMENT; - ATOMIC_STORE(node->p->transferActive, TRANSFER_IDLE); + ATOMIC_STORE(node->p->d.transferActive, TRANSFER_IDLE); break; } int mask = 0; - for (i = 1; i < node->p->attached; ++i) { + for (i = 1; i < node->p->d.attached; ++i) { if (node->p->players[i]->mode == node->mode) { mask |= 1 << i; } } if (mask) { if (needsToWait) { - if (!node->p->wait(node->p, mask)) { + if (!node->p->d.wait(&node->p->d, mask)) { abort(); } } else { - node->p->signal(node->p, mask); + node->p->d.signal(&node->p->d, mask); } } // Tell the other GBAs they can continue up to where we were - node->p->addCycles(node->p, 0, node->eventDiff); + node->p->d.addCycles(&node->p->d, 0, node->eventDiff); #ifndef NDEBUG - node->phase = node->p->transferActive; + node->phase = node->p->d.transferActive; #endif if (needsToWait) { return 0; @@ -285,12 +277,12 @@ static int32_t _masterUpdate(struct GBASIOLockstepNode* node) { } static uint32_t _slaveUpdate(struct GBASIOLockstepNode* node) { - node->d.p->multiplayerControl.ready = node->p->attachedMulti == node->p->attached; + node->d.p->multiplayerControl.ready = node->p->attachedMulti == node->p->d.attached; bool signal = false; - switch (node->p->transferActive) { + switch (node->p->d.transferActive) { case TRANSFER_IDLE: if (!node->d.p->multiplayerControl.ready) { - node->p->addCycles(node->p, node->id, LOCKSTEP_INCREMENT); + node->p->d.addCycles(&node->p->d, node->id, LOCKSTEP_INCREMENT); } break; case TRANSFER_STARTING: @@ -329,17 +321,17 @@ static uint32_t _slaveUpdate(struct GBASIOLockstepNode* node) { break; } #ifndef NDEBUG - node->phase = node->p->transferActive; + node->phase = node->p->d.transferActive; #endif if (signal) { - node->p->signal(node->p, 1 << node->id); + node->p->d.signal(&node->p->d, 1 << node->id); } return 0; } static void _GBASIOLockstepNodeProcessEvents(struct mTiming* timing, void* user, uint32_t cyclesLate) { struct GBASIOLockstepNode* node = user; - if (node->p->attached < 2) { + if (node->p->d.attached < 2) { return; } int32_t cycles = 0; @@ -349,7 +341,7 @@ static void _GBASIOLockstepNodeProcessEvents(struct mTiming* timing, void* user, cycles = _masterUpdate(node); } else { cycles = _slaveUpdate(node); - cycles += node->p->useCycles(node->p, node->id, node->eventDiff); + cycles += node->p->d.useCycles(&node->p->d, node->id, node->eventDiff); } node->eventDiff = 0; } else { @@ -377,13 +369,13 @@ static uint16_t GBASIOLockstepNodeNormalWriteRegister(struct GBASIODriver* drive if (value & 0x0080 && !node->id) { // Internal shift clock if (value & 1) { - node->p->transferActive = TRANSFER_STARTING; + node->p->d.transferActive = TRANSFER_STARTING; } // Frequency if (value & 2) { - node->p->transferCycles = GBA_ARM7TDMI_FREQUENCY / 1024; + node->p->d.transferCycles = GBA_ARM7TDMI_FREQUENCY / 1024; } else { - node->p->transferCycles = GBA_ARM7TDMI_FREQUENCY / 8192; + node->p->d.transferCycles = GBA_ARM7TDMI_FREQUENCY / 8192; } } } else if (address == REG_SIODATA32_LO) { diff --git a/src/gba/sio/lockstep.h b/src/gba/sio/lockstep.h index 6da3d0dc3..90391b61d 100644 --- a/src/gba/sio/lockstep.h +++ b/src/gba/sio/lockstep.h @@ -3,40 +3,23 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef SIO_LOCKSTEP_H -#define SIO_LOCKSTEP_H +#ifndef GBA_SIO_LOCKSTEP_H +#define GBA_SIO_LOCKSTEP_H +#include "util/common.h" + +#include "core/lockstep.h" #include "core/timing.h" #include "gba/sio.h" -enum GBASIOLockstepPhase { - TRANSFER_IDLE = 0, - TRANSFER_STARTING, - TRANSFER_STARTED, - TRANSFER_FINISHING, - TRANSFER_FINISHED -}; - struct GBASIOLockstep { + struct mLockstep d; struct GBASIOLockstepNode* players[MAX_GBAS]; - int attached; int attachedMulti; int attachedNormal; uint16_t multiRecv[MAX_GBAS]; uint32_t normalRecv[MAX_GBAS]; - enum GBASIOLockstepPhase transferActive; - int32_t transferCycles; - - bool (*signal)(struct GBASIOLockstep*, unsigned mask); - bool (*wait)(struct GBASIOLockstep*, unsigned mask); - void (*addCycles)(struct GBASIOLockstep*, int id, int32_t cycles); - int32_t (*useCycles)(struct GBASIOLockstep*, int id, int32_t cycles); - void (*unload)(struct GBASIOLockstep*, int id); - void* context; -#ifndef NDEBUG - int transferId; -#endif }; struct GBASIOLockstepNode { @@ -52,12 +35,11 @@ struct GBASIOLockstepNode { bool transferFinished; #ifndef NDEBUG int transferId; - enum GBASIOLockstepPhase phase; + enum mLockstepPhase phase; #endif }; void GBASIOLockstepInit(struct GBASIOLockstep*); -void GBASIOLockstepDeinit(struct GBASIOLockstep*); void GBASIOLockstepNodeCreate(struct GBASIOLockstepNode*); diff --git a/src/platform/qt/GBAApp.h b/src/platform/qt/GBAApp.h index d54712744..ea7fa1267 100644 --- a/src/platform/qt/GBAApp.h +++ b/src/platform/qt/GBAApp.h @@ -16,6 +16,7 @@ struct NoIntroDB; extern "C" { #include "core/log.h" +#include "gba/sio.h" } mLOG_DECLARE_CATEGORY(QT); diff --git a/src/platform/qt/MultiplayerController.cpp b/src/platform/qt/MultiplayerController.cpp index 489c2b1e2..49afdf125 100644 --- a/src/platform/qt/MultiplayerController.cpp +++ b/src/platform/qt/MultiplayerController.cpp @@ -11,15 +11,17 @@ extern "C" { #ifdef M_CORE_GBA #include "gba/gba.h" #endif +#ifdef M_CORE_GB +#include "gb/gb.h" +#endif } - using namespace QGBA; MultiplayerController::MultiplayerController() { - GBASIOLockstepInit(&m_lockstep); + mLockstepInit(&m_lockstep); m_lockstep.context = this; - m_lockstep.signal = [](GBASIOLockstep* lockstep, unsigned mask) { + m_lockstep.signal = [](mLockstep* lockstep, unsigned mask) { MultiplayerController* controller = static_cast(lockstep->context); Player* player = &controller->m_players[0]; bool woke = false; @@ -33,7 +35,7 @@ MultiplayerController::MultiplayerController() { controller->m_lock.unlock(); return woke; }; - m_lockstep.wait = [](GBASIOLockstep* lockstep, unsigned mask) { + m_lockstep.wait = [](mLockstep* lockstep, unsigned mask) { MultiplayerController* controller = static_cast(lockstep->context); controller->m_lock.lock(); Player* player = &controller->m_players[0]; @@ -47,7 +49,7 @@ MultiplayerController::MultiplayerController() { controller->m_lock.unlock(); return slept; }; - m_lockstep.addCycles = [](GBASIOLockstep* lockstep, int id, int32_t cycles) { + m_lockstep.addCycles = [](mLockstep* lockstep, int id, int32_t cycles) { if (cycles < 0) { abort(); } @@ -56,14 +58,27 @@ MultiplayerController::MultiplayerController() { if (!id) { for (int i = 1; i < controller->m_players.count(); ++i) { Player* player = &controller->m_players[i]; - if (player->node->d.p->mode != controller->m_players[0].node->d.p->mode) { + if (player->controller->platform() == PLATFORM_GBA && player->gbaNode->d.p->mode != controller->m_players[0].gbaNode->d.p->mode) { player->controller->setSync(true); continue; } player->controller->setSync(false); player->cyclesPosted += cycles; if (player->awake < 1) { - player->node->nextEvent += player->cyclesPosted; + switch (player->controller->platform()) { +#ifdef M_CORE_GBA + case PLATFORM_GBA: + player->gbaNode->nextEvent += player->cyclesPosted; + break; +#endif +#ifdef M_CORE_GB + case PLATFORM_GB: + player->gbNode->nextEvent += player->cyclesPosted; + break; +#endif + default: + break; + } mCoreThreadStopWaiting(player->controller->thread()); player->awake = 1; } @@ -74,7 +89,7 @@ MultiplayerController::MultiplayerController() { } controller->m_lock.unlock(); }; - m_lockstep.useCycles = [](GBASIOLockstep* lockstep, int id, int32_t cycles) { + m_lockstep.useCycles = [](mLockstep* lockstep, int id, int32_t cycles) { MultiplayerController* controller = static_cast(lockstep->context); controller->m_lock.lock(); Player* player = &controller->m_players[id]; @@ -87,7 +102,7 @@ MultiplayerController::MultiplayerController() { controller->m_lock.unlock(); return cycles; }; - m_lockstep.unload = [](GBASIOLockstep* lockstep, int id) { + m_lockstep.unload = [](mLockstep* lockstep, int id) { MultiplayerController* controller = static_cast(lockstep->context); controller->m_lock.lock(); Player* player = &controller->m_players[id]; @@ -102,9 +117,35 @@ MultiplayerController::MultiplayerController() { for (int i = 1; i < controller->m_players.count(); ++i) { Player* player = &controller->m_players[i]; player->controller->setSync(true); - player->cyclesPosted += lockstep->players[0]->eventDiff; + switch (player->controller->platform()) { +#ifdef M_CORE_GBA + case PLATFORM_GBA: + player->cyclesPosted += reinterpret_cast(lockstep)->players[0]->eventDiff; + break; +#endif +#ifdef M_CORE_GB + case PLATFORM_GB: + player->cyclesPosted += reinterpret_cast(lockstep)->players[0]->eventDiff; + break; +#endif + default: + break; + } if (player->awake < 1) { - player->node->nextEvent += player->cyclesPosted; + switch (player->controller->platform()) { +#ifdef M_CORE_GBA + case PLATFORM_GBA: + player->gbaNode->nextEvent += player->cyclesPosted; + break; +#endif +#ifdef M_CORE_GB + case PLATFORM_GB: + player->gbNode->nextEvent += player->cyclesPosted; + break; +#endif + default: + break; + } mCoreThreadStopWaiting(player->controller->thread()); player->awake = 1; } @@ -114,29 +155,44 @@ MultiplayerController::MultiplayerController() { }; } -MultiplayerController::~MultiplayerController() { - GBASIOLockstepDeinit(&m_lockstep); -} - bool MultiplayerController::attachGame(GameController* controller) { if (m_lockstep.attached == MAX_GBAS) { return false; } + if (m_lockstep.attached == 0) { + switch (controller->platform()) { +#ifdef M_CORE_GBA + case PLATFORM_GBA: + GBASIOLockstepInit(&m_gbaLockstep); + break; +#endif +#ifdef M_CORE_GB + case PLATFORM_GB: + GBSIOLockstepInit(&m_gbLockstep); + break; +#endif + default: + return false; + } + } + mCoreThread* thread = controller->thread(); if (!thread) { return false; } + switch (controller->platform()) { #ifdef M_CORE_GBA - if (controller->platform() == PLATFORM_GBA) { + case PLATFORM_GBA: { GBA* gba = static_cast(thread->core->board); GBASIOLockstepNode* node = new GBASIOLockstepNode; GBASIOLockstepNodeCreate(node); - GBASIOLockstepAttachNode(&m_lockstep, node); + GBASIOLockstepAttachNode(&m_gbaLockstep, node); m_players.append({ controller, + nullptr, node, 1, 0, @@ -149,6 +205,31 @@ bool MultiplayerController::attachGame(GameController* controller) { return true; } #endif +#ifdef M_CORE_GB + case PLATFORM_GB: { + GB* gb = static_cast(thread->core->board); + + GBSIOLockstepNode* node = new GBSIOLockstepNode; + GBSIOLockstepNodeCreate(node); + GBSIOLockstepAttachNode(&m_gbLockstep, node); + m_players.append({ + controller, + node, + nullptr, + 1, + 0, + 0 + }); + + GBSIOSetDriver(&gb->sio, &node->d); + + emit gameAttached(); + return true; + } +#endif + default: + break; + } return false; } @@ -161,17 +242,34 @@ void MultiplayerController::detachGame(GameController* controller) { for (int i = 0; i < m_players.count(); ++i) { m_players[i].controller->threadInterrupt(); } + switch (controller->platform()) { #ifdef M_CORE_GBA - if (controller->platform() == PLATFORM_GBA) { + case PLATFORM_GBA: { GBA* gba = static_cast(thread->core->board); GBASIOLockstepNode* node = reinterpret_cast(gba->sio.drivers.multiplayer); GBASIOSetDriver(&gba->sio, nullptr, SIO_MULTI); if (node) { - GBASIOLockstepDetachNode(&m_lockstep, node); + GBASIOLockstepDetachNode(&m_gbaLockstep, node); delete node; } + break; } #endif +#ifdef M_CORE_GB + case PLATFORM_GB: { + GB* gb = static_cast(thread->core->board); + GBSIOLockstepNode* node = reinterpret_cast(gb->sio.driver); + GBSIOSetDriver(&gb->sio, nullptr); + if (node) { + GBSIOLockstepDetachNode(&m_gbLockstep, node); + delete node; + } + break; + } +#endif + default: + break; + } controller->threadContinue(); for (int i = 0; i < m_players.count(); ++i) { diff --git a/src/platform/qt/MultiplayerController.h b/src/platform/qt/MultiplayerController.h index 166fa83c0..78be7dc35 100644 --- a/src/platform/qt/MultiplayerController.h +++ b/src/platform/qt/MultiplayerController.h @@ -11,7 +11,13 @@ #include extern "C" { +#include "core/lockstep.h" +#ifdef M_CORE_GBA #include "gba/sio/lockstep.h" +#endif +#ifdef M_CORE_GB +#include "gb/sio/lockstep.h" +#endif } namespace QGBA { @@ -23,7 +29,6 @@ Q_OBJECT public: MultiplayerController(); - ~MultiplayerController(); bool attachGame(GameController*); void detachGame(GameController*); @@ -38,12 +43,21 @@ signals: private: struct Player { GameController* controller; - GBASIOLockstepNode* node; + GBSIOLockstepNode* gbNode; + GBASIOLockstepNode* gbaNode; int awake; int32_t cyclesPosted; unsigned waitMask; }; - GBASIOLockstep m_lockstep; + union { + mLockstep m_lockstep; +#ifdef M_CORE_GB + GBSIOLockstep m_gbLockstep; +#endif +#ifdef M_CORE_GBA + GBASIOLockstep m_gbaLockstep; +#endif + }; QList m_players; QMutex m_lock; }; From 269b18d8aab439ebb08ff4b02d744a41bf79fb78 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 26 Dec 2016 12:03:23 -0800 Subject: [PATCH 38/56] GB SIO: Some fixes --- src/gb/sio.c | 24 ++++++++++++++++-------- src/gb/sio/lockstep.c | 7 ++++++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/gb/sio.c b/src/gb/sio.c index 097b53f26..f25cb3b96 100644 --- a/src/gb/sio.c +++ b/src/gb/sio.c @@ -61,14 +61,20 @@ void GBSIOSetDriver(struct GBSIO* sio, struct GBSIODriver* driver) { void _GBSIOProcessEvents(struct mTiming* timing, void* context, uint32_t cyclesLate) { UNUSED(cyclesLate); struct GBSIO* sio = context; - --sio->remainingBits; - sio->p->memory.io[REG_SB] &= ~(8 >> sio->remainingBits); - sio->p->memory.io[REG_SB] |= sio->pendingSB & ~(8 >> sio->remainingBits); + bool doIRQ = false; + if (sio->remainingBits) { + doIRQ = true; + --sio->remainingBits; + sio->p->memory.io[REG_SB] &= ~(128 >> sio->remainingBits); + sio->p->memory.io[REG_SB] |= sio->pendingSB & (128 >> sio->remainingBits); + } if (!sio->remainingBits) { - sio->p->memory.io[REG_IF] |= (1 << GB_IRQ_SIO); sio->p->memory.io[REG_SC] = GBRegisterSCClearEnable(sio->p->memory.io[REG_SC]); - sio->pendingSB = 0xFF; - GBUpdateIRQs(sio->p); + if (doIRQ) { + sio->p->memory.io[REG_IF] |= (1 << GB_IRQ_SIO); + GBUpdateIRQs(sio->p); + sio->pendingSB = 0xFF; + } } else { mTimingSchedule(timing, &sio->event, sio->period); } @@ -85,8 +91,10 @@ void GBSIOWriteSC(struct GBSIO* sio, uint8_t sc) { sio->period = GBSIOCyclesPerTransfer[GBRegisterSCGetClockSpeed(sc)]; // TODO Shift Clock if (GBRegisterSCIsEnable(sc)) { mTimingDeschedule(&sio->p->timing, &sio->event); - mTimingSchedule(&sio->p->timing, &sio->event, sio->period); - sio->remainingBits = 8; + if (GBRegisterSCIsShiftClock(sc)) { + mTimingSchedule(&sio->p->timing, &sio->event, sio->period); + sio->remainingBits = 8; + } } if (sio->driver) { sio->driver->writeSC(sio->driver, sc); diff --git a/src/gb/sio/lockstep.c b/src/gb/sio/lockstep.c index 08d1b8cbc..26ddf83c3 100644 --- a/src/gb/sio/lockstep.c +++ b/src/gb/sio/lockstep.c @@ -8,7 +8,7 @@ #include "gb/gb.h" #include "gb/io.h" -#define LOCKSTEP_INCREMENT 500 +#define LOCKSTEP_INCREMENT 512 static bool GBSIOLockstepNodeInit(struct GBSIODriver* driver); static void GBSIOLockstepNodeDeinit(struct GBSIODriver* driver); @@ -90,6 +90,11 @@ static void _finishTransfer(struct GBSIOLockstepNode* node) { } struct GBSIO* sio = node->d.p; sio->pendingSB = node->p->pendingSB[!node->id]; + if (GBRegisterSCIsEnable(sio->p->memory.io[REG_SC])) { + sio->remainingBits = 8; + mTimingDeschedule(&sio->p->timing, &sio->event); + mTimingSchedule(&sio->p->timing, &sio->event, 0); + } node->transferFinished = true; #ifndef NDEBUG ++node->transferId; From c662b59e9942bfffd69ed6754cc334de86f89e63 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 26 Dec 2016 17:13:53 -0800 Subject: [PATCH 39/56] GB: Allow player 2 to act as shift clock --- src/gb/sio/lockstep.c | 16 +++++++++++----- src/gb/sio/lockstep.h | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gb/sio/lockstep.c b/src/gb/sio/lockstep.c index 26ddf83c3..67a8f68aa 100644 --- a/src/gb/sio/lockstep.c +++ b/src/gb/sio/lockstep.c @@ -22,6 +22,7 @@ void GBSIOLockstepInit(struct GBSIOLockstep* lockstep) { lockstep->players[1] = NULL; lockstep->pendingSB[0] = 0xFF; lockstep->pendingSB[1] = 0xFF; + lockstep->masterClaimed = false; } void GBSIOLockstepNodeCreate(struct GBSIOLockstepNode* node) { @@ -135,6 +136,7 @@ static int32_t _masterUpdate(struct GBSIOLockstepNode* node) { case TRANSFER_FINISHED: // Everything's settled. We're done. _finishTransfer(node); + ATOMIC_STORE(node->p->masterClaimed, false); node->nextEvent += LOCKSTEP_INCREMENT; ATOMIC_STORE(node->p->d.transferActive, TRANSFER_IDLE); break; @@ -226,11 +228,15 @@ static void GBSIOLockstepNodeWriteSB(struct GBSIODriver* driver, uint8_t value) static uint8_t GBSIOLockstepNodeWriteSC(struct GBSIODriver* driver, uint8_t value) { struct GBSIOLockstepNode* node = (struct GBSIOLockstepNode*) driver; - if (!node->id && (value & 0x81) == 0x81) { - node->p->d.transferActive = TRANSFER_STARTING; - node->p->d.transferCycles = GBSIOCyclesPerTransfer[(value >> 1) & 1]; - mTimingDeschedule(&driver->p->p->timing, &node->event); - mTimingSchedule(&driver->p->p->timing, &node->event, 0); + if ((value & 0x81) == 0x81 && node->p->d.attached > 1) { + bool claimed = false; + if (ATOMIC_CMPXCHG(node->p->masterClaimed, claimed, true)) { + node->p->d.transferActive = TRANSFER_STARTING; + node->p->d.transferCycles = GBSIOCyclesPerTransfer[(value >> 1) & 1]; + mTimingDeschedule(&driver->p->p->timing, &driver->p->event); + mTimingDeschedule(&driver->p->p->timing, &node->event); + mTimingSchedule(&driver->p->p->timing, &node->event, 0); + } } return value; } diff --git a/src/gb/sio/lockstep.h b/src/gb/sio/lockstep.h index 85100ebae..a2a85457d 100644 --- a/src/gb/sio/lockstep.h +++ b/src/gb/sio/lockstep.h @@ -17,6 +17,7 @@ struct GBSIOLockstep { struct GBSIOLockstepNode* players[MAX_GBS]; uint8_t pendingSB[MAX_GBS]; + bool masterClaimed; }; struct GBSIOLockstepNode { From daaa2fa5236df5e8976e7e0ba7ac39e0d9233422 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 26 Dec 2016 17:20:51 -0800 Subject: [PATCH 40/56] GB SIO: Support faster transfer speeds --- src/gb/sio/lockstep.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gb/sio/lockstep.c b/src/gb/sio/lockstep.c index 67a8f68aa..d52401a66 100644 --- a/src/gb/sio/lockstep.c +++ b/src/gb/sio/lockstep.c @@ -116,17 +116,17 @@ static int32_t _masterUpdate(struct GBSIOLockstepNode* node) { node->transferFinished = false; needsToWait = true; ATOMIC_STORE(node->p->d.transferActive, TRANSFER_STARTED); - node->nextEvent += 128; + node->nextEvent += 4; break; case TRANSFER_STARTED: // All the other GBs have caught up and are sleeping, we can all continue now - node->nextEvent += 128; + node->nextEvent += 4; ATOMIC_STORE(node->p->d.transferActive, TRANSFER_FINISHING); break; case TRANSFER_FINISHING: // Finish the transfer // We need to make sure the other GBs catch up so they don't get behind - node->nextEvent += LOCKSTEP_INCREMENT - 256; // Split the cycles to avoid waiting too long + node->nextEvent += node->d.p->period - 8; // Split the cycles to avoid waiting too long #ifndef NDEBUG ATOMIC_ADD(node->p->d.transferId, 1); #endif From 2f1cb61d0197893cf0c3861e9130ff1aeaefb0b0 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 26 Dec 2016 21:01:55 -0800 Subject: [PATCH 41/56] All: Add C++ header guards --- CHANGES | 1 + src/arm/arm.h | 4 ++++ src/arm/debugger/cli-debugger.h | 4 ++++ src/arm/debugger/debugger.h | 11 +++++++++++ src/arm/debugger/memory-debugger.h | 4 ++++ src/arm/decoder.h | 6 ++++++ src/arm/isa-arm.h | 4 ++++ src/arm/isa-thumb.h | 4 ++++ src/core/cheats.h | 4 ++++ src/core/config.h | 4 ++++ src/core/core.h | 4 ++++ src/core/cpu.h | 4 ++++ src/core/directories.h | 4 ++++ src/core/input.h | 4 ++++ src/core/interface.h | 4 ++++ src/core/library.h | 4 ++++ src/core/lockstep.h | 4 ++++ src/core/log.h | 4 ++++ src/core/rewind.h | 4 ++++ src/core/serialize.h | 4 ++++ src/core/sync.h | 4 ++++ src/core/thread.h | 4 ++++ src/core/tile-cache.h | 4 ++++ src/core/timing.h | 4 ++++ src/debugger/cli-debugger.h | 4 ++++ src/debugger/debugger.h | 3 +++ src/debugger/gdb-stub.h | 4 ++++ src/debugger/parser.h | 5 +++++ src/feature/commandline.h | 4 ++++ src/feature/editline/cli-el-backend.h | 7 ++++++- src/feature/ffmpeg/ffmpeg-encoder.h | 6 ++++++ src/feature/gui/gui-config.h | 4 ++++ src/feature/gui/gui-runner.h | 4 ++++ src/feature/gui/remap.h | 4 ++++ src/feature/imagemagick/imagemagick-gif-encoder.c | 1 + src/feature/imagemagick/imagemagick-gif-encoder.h | 8 +++++++- src/gb/audio.h | 4 ++++ src/gb/cheats.h | 4 ++++ src/gb/core.h | 6 ++++++ src/gb/extra/cli.h | 6 ++++++ src/gb/gb.h | 4 ++++ src/gb/interface.h | 4 ++++ src/gb/io.h | 4 ++++ src/gb/mbc.h | 4 ++++ src/gb/memory.h | 4 ++++ src/gb/overrides.h | 4 ++++ src/gb/renderers/software.h | 4 ++++ src/gb/renderers/tile-cache.h | 4 ++++ src/gb/serialize.h | 4 ++++ src/gb/sio.h | 4 ++++ src/gb/sio/lockstep.h | 4 ++++ src/gb/timer.h | 4 ++++ src/gb/video.h | 4 ++++ src/gba/audio.h | 4 ++++ src/gba/bios.h | 4 ++++ src/gba/cheats.h | 4 ++++ src/gba/cheats/gameshark.h | 6 ++++++ src/gba/cheats/parv3.h | 6 ++++++ src/gba/core.h | 6 ++++++ src/gba/dma.h | 4 ++++ src/gba/extra/cli.h | 6 ++++++ src/gba/gba.h | 4 ++++ src/gba/hardware.h | 4 ++++ src/gba/hle-bios.h | 4 ++++ src/gba/input.h | 6 ++++++ src/gba/interface.h | 4 ++++ src/gba/io.h | 4 ++++ src/gba/memory.h | 4 ++++ src/gba/overrides.h | 4 ++++ src/gba/renderers/thread-proxy.h | 6 ++++++ src/gba/renderers/tile-cache.h | 4 ++++ src/gba/renderers/video-software.h | 4 ++++ src/gba/rr/mgm.h | 4 ++++ src/gba/rr/rr.h | 4 ++++ src/gba/rr/vbm.h | 9 +++++++++ src/gba/savedata.h | 4 ++++ src/gba/serialize.h | 4 ++++ src/gba/sharkport.h | 4 ++++ src/gba/sio.h | 4 ++++ src/gba/sio/lockstep.h | 4 ++++ src/gba/timer.h | 5 +++++ src/gba/vfame.h | 4 ++++ src/gba/video.h | 4 ++++ src/lr35902/debugger/cli-debugger.h | 4 ++++ src/lr35902/debugger/debugger.h | 11 +++++++++++ src/lr35902/isa-lr35902.h | 4 ++++ src/lr35902/lr35902.h | 4 ++++ src/platform/opengl/gl.h | 6 ++++++ src/platform/opengl/gles2.h | 6 ++++++ src/platform/posix/threading.h | 4 ++++ src/platform/qt/AboutScreen.cpp | 2 -- src/platform/qt/ArchiveInspector.cpp | 2 -- src/platform/qt/AssetTile.cpp | 2 -- src/platform/qt/AssetTile.h | 2 -- src/platform/qt/AssetView.cpp | 2 -- src/platform/qt/AudioDevice.cpp | 2 -- src/platform/qt/AudioProcessorQt.cpp | 2 -- src/platform/qt/AudioProcessorSDL.cpp | 2 -- src/platform/qt/AudioProcessorSDL.h | 2 -- src/platform/qt/CheatsModel.cpp | 2 -- src/platform/qt/CheatsView.cpp | 2 -- src/platform/qt/ConfigController.cpp | 2 -- src/platform/qt/ConfigController.h | 2 -- src/platform/qt/DebuggerConsoleController.cpp | 2 -- src/platform/qt/DebuggerConsoleController.h | 2 -- src/platform/qt/Display.cpp | 2 -- src/platform/qt/Display.h | 2 -- src/platform/qt/DisplayGL.cpp | 2 -- src/platform/qt/DisplayGL.h | 2 -- src/platform/qt/DisplayQt.cpp | 2 -- src/platform/qt/GBAApp.cpp | 2 -- src/platform/qt/GBAApp.h | 2 -- src/platform/qt/GBAKeyEditor.cpp | 2 -- src/platform/qt/GBAKeyEditor.h | 2 -- src/platform/qt/GBAOverride.cpp | 2 -- src/platform/qt/GBAOverride.h | 2 -- src/platform/qt/GBOverride.cpp | 2 -- src/platform/qt/GBOverride.h | 2 -- src/platform/qt/GDBController.h | 2 -- src/platform/qt/GIFView.h | 2 -- src/platform/qt/GameController.cpp | 2 -- src/platform/qt/GameController.h | 2 -- src/platform/qt/GamepadAxisEvent.h | 2 -- src/platform/qt/GamepadButtonEvent.h | 2 -- src/platform/qt/IOViewer.cpp | 2 -- src/platform/qt/InputController.cpp | 2 -- src/platform/qt/InputController.h | 2 -- src/platform/qt/InputProfile.h | 2 -- src/platform/qt/LibraryModel.cpp | 2 -- src/platform/qt/LibraryModel.h | 2 -- src/platform/qt/LoadSaveState.cpp | 2 -- src/platform/qt/LogController.h | 2 -- src/platform/qt/MemoryModel.cpp | 2 -- src/platform/qt/MemoryModel.h | 2 -- src/platform/qt/MemoryView.cpp | 2 -- src/platform/qt/MessagePainter.cpp | 2 -- src/platform/qt/MultiplayerController.cpp | 2 -- src/platform/qt/MultiplayerController.h | 2 -- src/platform/qt/ObjView.cpp | 2 -- src/platform/qt/ObjView.h | 2 -- src/platform/qt/OverrideView.cpp | 4 ---- src/platform/qt/OverrideView.h | 2 -- src/platform/qt/PaletteView.cpp | 2 -- src/platform/qt/ROMInfo.cpp | 2 -- src/platform/qt/SensorView.cpp | 2 -- src/platform/qt/SettingsView.cpp | 2 -- src/platform/qt/ShaderSelector.cpp | 2 -- src/platform/qt/Swatch.cpp | 2 -- src/platform/qt/TileView.cpp | 2 -- src/platform/qt/TileView.h | 2 -- src/platform/qt/VFileDevice.h | 2 -- src/platform/qt/VideoView.cpp | 2 -- src/platform/qt/VideoView.h | 2 -- src/platform/qt/Window.cpp | 2 -- src/platform/qt/Window.h | 2 -- src/platform/sdl/gl-common.h | 7 +++++++ src/platform/sdl/main.h | 7 +++++++ src/platform/sdl/sdl-audio.h | 4 ++++ src/platform/sdl/sdl-events.h | 4 ++++ src/platform/video-backend.h | 4 ++++ src/util/circle-buffer.h | 4 ++++ src/util/common.h | 12 ++++++++++++ src/util/configuration.h | 6 ++++++ src/util/crc32.h | 4 ++++ src/util/export.h | 4 ++++ src/util/formatting.h | 4 ++++ src/util/gui.h | 4 ++++ src/util/gui/file-select.h | 6 ++++++ src/util/gui/font.h | 4 ++++ src/util/gui/menu.h | 6 ++++++ src/util/hash.h | 4 ++++ src/util/math.h | 4 ++++ src/util/memory.h | 4 ++++ src/util/nointro.h | 4 ++++ src/util/patch-fast.h | 4 ++++ src/util/patch-ips.h | 4 ++++ src/util/patch-ups.h | 4 ++++ src/util/patch.h | 4 ++++ src/util/png-io.h | 4 ++++ src/util/ring-fifo.h | 4 ++++ src/util/socket.h | 4 ++++ src/util/string.h | 4 ++++ src/util/table.h | 4 ++++ src/util/text-codec.h | 4 ++++ src/util/threading.h | 4 ++++ src/util/vector.h | 4 ++++ src/util/vfs.h | 4 ++++ 187 files changed, 551 insertions(+), 134 deletions(-) diff --git a/CHANGES b/CHANGES index 151863e1c..ef9a32039 100644 --- a/CHANGES +++ b/CHANGES @@ -69,6 +69,7 @@ Misc: - GB Memory: Reset ROM bank when loading a ROM - GBA DMA: Refactor DMA out of memory.c - GBA DMA: Move DMAs to using absolute timing + - All: Add C++ header guards 0.5.1: (2016-10-05) Bugfixes: diff --git a/src/arm/arm.h b/src/arm/arm.h index 947cedf15..b8ddad47a 100644 --- a/src/arm/arm.h +++ b/src/arm/arm.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/cpu.h" enum { @@ -175,4 +177,6 @@ void ARMRun(struct ARMCore* cpu); void ARMRunLoop(struct ARMCore* cpu); void ARMRunFake(struct ARMCore* cpu, uint32_t opcode); +CXX_GUARD_END + #endif diff --git a/src/arm/debugger/cli-debugger.h b/src/arm/debugger/cli-debugger.h index e0e26b79f..c4e6bff6e 100644 --- a/src/arm/debugger/cli-debugger.h +++ b/src/arm/debugger/cli-debugger.h @@ -8,7 +8,11 @@ #include "util/common.h" +CXX_GUARD_START + struct CLIDebuggerSystem; void ARMCLIDebuggerCreate(struct CLIDebuggerSystem* debugger); +CXX_GUARD_END + #endif diff --git a/src/arm/debugger/debugger.h b/src/arm/debugger/debugger.h index aaedfc0fc..105702ccb 100644 --- a/src/arm/debugger/debugger.h +++ b/src/arm/debugger/debugger.h @@ -3,6 +3,13 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef ARM_DEBUGGER_H +#define ARM_DEBUGGER_H + +#include "util/common.h" + +CXX_GUARD_START + #include "debugger/debugger.h" struct ARMDebugBreakpoint { @@ -40,3 +47,7 @@ struct ARMDebugger { struct mDebuggerPlatform* ARMDebuggerPlatformCreate(void); bool ARMDebuggerSetSoftwareBreakpoint(struct mDebuggerPlatform* debugger, uint32_t address, enum ExecutionMode mode); void ARMDebuggerClearSoftwareBreakpoint(struct mDebuggerPlatform* debugger, uint32_t address); + +CXX_GUARD_END + +#endif diff --git a/src/arm/debugger/memory-debugger.h b/src/arm/debugger/memory-debugger.h index 58a717617..b27dec8d8 100644 --- a/src/arm/debugger/memory-debugger.h +++ b/src/arm/debugger/memory-debugger.h @@ -8,9 +8,13 @@ #include "util/common.h" +CXX_GUARD_START + struct ARMDebugger; void ARMDebuggerInstallMemoryShim(struct ARMDebugger* debugger); void ARMDebuggerRemoveMemoryShim(struct ARMDebugger* debugger); +CXX_GUARD_END + #endif diff --git a/src/arm/decoder.h b/src/arm/decoder.h index 6ca478046..eabd30272 100644 --- a/src/arm/decoder.h +++ b/src/arm/decoder.h @@ -6,6 +6,10 @@ #ifndef ARM_DECODER_H #define ARM_DECODER_H +#include "util/common.h" + +CXX_GUARD_START + #include "arm.h" // Bit 0: a register is involved with this operand @@ -214,4 +218,6 @@ bool ARMDecodeThumbCombine(struct ARMInstructionInfo* info1, struct ARMInstructi struct ARMInstructionInfo* out); int ARMDisassemble(struct ARMInstructionInfo* info, uint32_t pc, char* buffer, int blen); +CXX_GUARD_END + #endif diff --git a/src/arm/isa-arm.h b/src/arm/isa-arm.h index f4694bead..7f3063171 100644 --- a/src/arm/isa-arm.h +++ b/src/arm/isa-arm.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #define ARM_PREFETCH_CYCLES (1 + cpu->memory.activeSeqCycles32) struct ARMCore; @@ -15,4 +17,6 @@ struct ARMCore; typedef void (*ARMInstruction)(struct ARMCore*, uint32_t opcode); extern const ARMInstruction _armTable[0x1000]; +CXX_GUARD_END + #endif diff --git a/src/arm/isa-thumb.h b/src/arm/isa-thumb.h index dd018441e..71ddd06ed 100644 --- a/src/arm/isa-thumb.h +++ b/src/arm/isa-thumb.h @@ -8,9 +8,13 @@ #include "util/common.h" +CXX_GUARD_START + struct ARMCore; typedef void (*ThumbInstruction)(struct ARMCore*, uint16_t opcode); extern const ThumbInstruction _thumbTable[0x400]; +CXX_GUARD_END + #endif diff --git a/src/core/cheats.h b/src/core/cheats.h index 1cc3dedc6..774dbede5 100644 --- a/src/core/cheats.h +++ b/src/core/cheats.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/cpu.h" #include "core/log.h" #include "util/vector.h" @@ -100,4 +102,6 @@ bool mCheatSaveFile(struct mCheatDevice*, struct VFile*); void mCheatRefresh(struct mCheatDevice*, struct mCheatSet*); +CXX_GUARD_END + #endif diff --git a/src/core/config.h b/src/core/config.h index 806fadde3..d76646c35 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "util/configuration.h" struct mCoreConfig { @@ -91,4 +93,6 @@ const struct Configuration* mCoreConfigGetOverridesConst(const struct mCoreConfi void mCoreConfigFreeOpts(struct mCoreOptions* opts); +CXX_GUARD_END + #endif diff --git a/src/core/core.h b/src/core/core.h index 106275202..f5592adc8 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/config.h" #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 #include "core/directories.h" @@ -159,4 +161,6 @@ void mCoreInitConfig(struct mCore* core, const char* port); void mCoreLoadConfig(struct mCore* core); void mCoreLoadForeignConfig(struct mCore* core, const struct mCoreConfig* config); +CXX_GUARD_END + #endif diff --git a/src/core/cpu.h b/src/core/cpu.h index e55f5a19f..079e9eb5c 100644 --- a/src/core/cpu.h +++ b/src/core/cpu.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + enum mCPUComponentType { CPU_COMPONENT_DEBUGGER, CPU_COMPONENT_CHEAT_DEVICE, @@ -20,4 +22,6 @@ struct mCPUComponent { void (*deinit)(struct mCPUComponent* component); }; +CXX_GUARD_END + #endif diff --git a/src/core/directories.h b/src/core/directories.h index 55f3df513..b56787a9a 100644 --- a/src/core/directories.h +++ b/src/core/directories.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 struct VDir; @@ -34,4 +36,6 @@ struct mCoreOptions; void mDirectorySetMapOptions(struct mDirectorySet* dirs, const struct mCoreOptions* opts); #endif +CXX_GUARD_END + #endif diff --git a/src/core/input.h b/src/core/input.h index 4a7fc5a7b..01d55f26b 100644 --- a/src/core/input.h +++ b/src/core/input.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + struct Configuration; struct mInputPlatformInfo { @@ -60,4 +62,6 @@ const char* mInputGetCustomValue(const struct Configuration* config, const char* void mInputSetCustomValue(struct Configuration* config, const char* platformName, uint32_t type, const char* key, const char* value, const char* profile); +CXX_GUARD_END + #endif diff --git a/src/core/interface.h b/src/core/interface.h index 3d35cb059..805f555f1 100644 --- a/src/core/interface.h +++ b/src/core/interface.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + struct mCore; #ifdef COLOR_16_BIT @@ -84,4 +86,6 @@ struct mRumble { void (*setRumble)(struct mRumble*, int enable); }; +CXX_GUARD_END + #endif diff --git a/src/core/library.h b/src/core/library.h index cb9f2a48c..8a4fa68ff 100644 --- a/src/core/library.h +++ b/src/core/library.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/core.h" #include "util/vector.h" @@ -34,4 +36,6 @@ struct VFile; void mLibraryLoadDirectory(struct mLibrary* library, struct VDir* dir); void mLibraryAddEntry(struct mLibrary* library, const char* filename, struct VFile* vf); +CXX_GUARD_END + #endif diff --git a/src/core/lockstep.h b/src/core/lockstep.h index cea0fd1d8..be9e939b7 100644 --- a/src/core/lockstep.h +++ b/src/core/lockstep.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + enum mLockstepPhase { TRANSFER_IDLE = 0, TRANSFER_STARTING, @@ -34,4 +36,6 @@ struct mLockstep { void mLockstepInit(struct mLockstep*); +CXX_GUARD_END + #endif diff --git a/src/core/log.h b/src/core/log.h index 03fb31ee9..680638324 100644 --- a/src/core/log.h +++ b/src/core/log.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + enum mLogLevel { mLOG_FATAL = 0x01, mLOG_ERROR = 0x02, @@ -58,4 +60,6 @@ static inline void mLog(int category, enum mLogLevel level, const char* format, mLOG_DECLARE_CATEGORY(STATUS) +CXX_GUARD_END + #endif diff --git a/src/core/rewind.h b/src/core/rewind.h index 50844c545..3d951ae1a 100644 --- a/src/core/rewind.h +++ b/src/core/rewind.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "util/vector.h" DECLARE_VECTOR(mCoreRewindPatches, struct PatchFast); @@ -28,4 +30,6 @@ struct mCore; void mCoreRewindAppend(struct mCoreRewindContext*, struct mCore*); bool mCoreRewindRestore(struct mCoreRewindContext*, struct mCore*); +CXX_GUARD_END + #endif diff --git a/src/core/serialize.h b/src/core/serialize.h index d639aaae4..b901fbe40 100644 --- a/src/core/serialize.h +++ b/src/core/serialize.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + enum mStateExtdataTag { EXTDATA_NONE = 0, EXTDATA_SCREENSHOT = 1, @@ -44,4 +46,6 @@ bool mCoreSaveStateNamed(struct mCore* core, struct VFile* vf, int flags); bool mCoreLoadStateNamed(struct mCore* core, struct VFile* vf, int flags); void* mCoreExtractState(struct mCore* core, struct VFile* vf, struct mStateExtdata* extdata); +CXX_GUARD_END + #endif diff --git a/src/core/sync.h b/src/core/sync.h index 8932951aa..19add7e76 100644 --- a/src/core/sync.h +++ b/src/core/sync.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "util/threading.h" struct mCoreSync { @@ -36,4 +38,6 @@ void mCoreSyncLockAudio(struct mCoreSync* sync); void mCoreSyncUnlockAudio(struct mCoreSync* sync); void mCoreSyncConsumeAudio(struct mCoreSync* sync); +CXX_GUARD_END + #endif diff --git a/src/core/thread.h b/src/core/thread.h index b28569212..07ec8b9a0 100644 --- a/src/core/thread.h +++ b/src/core/thread.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/log.h" #include "core/rewind.h" #include "core/sync.h" @@ -97,4 +99,6 @@ void mCoreThreadSetRewinding(struct mCoreThread* threadContext, bool); struct mCoreThread* mCoreThreadGet(void); struct mLogger* mCoreThreadLogger(void); +CXX_GUARD_END + #endif diff --git a/src/core/tile-cache.h b/src/core/tile-cache.h index 052dca884..b1f780f55 100644 --- a/src/core/tile-cache.h +++ b/src/core/tile-cache.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + DECL_BITFIELD(mTileCacheConfiguration, uint32_t); DECL_BIT(mTileCacheConfiguration, ShouldStore, 0); @@ -57,4 +59,6 @@ void mTileCacheSetPalette(struct mTileCache* cache, int palette); const uint16_t* mTileCacheGetTile(struct mTileCache* cache, unsigned tileId, unsigned paletteId); const uint16_t* mTileCacheGetTileIfDirty(struct mTileCache* cache, struct mTileCacheEntry* entry, unsigned tileId, unsigned paletteId); +CXX_GUARD_END + #endif diff --git a/src/core/timing.h b/src/core/timing.h index ed99ff2e6..815215dd8 100644 --- a/src/core/timing.h +++ b/src/core/timing.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + struct mTiming; struct mTimingEvent { void* context; @@ -37,4 +39,6 @@ int32_t mTimingTick(struct mTiming* timing, int32_t cycles); int32_t mTimingCurrentTime(const struct mTiming* timing); int32_t mTimingNextEvent(struct mTiming* timing); +CXX_GUARD_END + #endif diff --git a/src/debugger/cli-debugger.h b/src/debugger/cli-debugger.h index 98e19b5ab..c82a8b493 100644 --- a/src/debugger/cli-debugger.h +++ b/src/debugger/cli-debugger.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "debugger.h" struct CLIDebugger; @@ -86,4 +88,6 @@ void CLIDebuggerAttachBackend(struct CLIDebugger*, struct CLIDebuggerBackend*); bool CLIDebuggerTabComplete(struct CLIDebugger*, const char* token, bool initial, size_t len); +CXX_GUARD_END + #endif diff --git a/src/debugger/debugger.h b/src/debugger/debugger.h index a4ce367f6..cc564499d 100644 --- a/src/debugger/debugger.h +++ b/src/debugger/debugger.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "arm/arm.h" #include "core/log.h" #include "util/vector.h" @@ -111,5 +113,6 @@ void mDebuggerAttach(struct mDebugger*, struct mCore*); void mDebuggerRun(struct mDebugger*); void mDebuggerEnter(struct mDebugger*, enum mDebuggerEntryReason, struct mDebuggerEntryInfo*); +CXX_GUARD_END #endif diff --git a/src/debugger/gdb-stub.h b/src/debugger/gdb-stub.h index 6e723e48e..84b086a60 100644 --- a/src/debugger/gdb-stub.h +++ b/src/debugger/gdb-stub.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "debugger/debugger.h" #include "util/socket.h" @@ -47,4 +49,6 @@ void GDBStubShutdown(struct GDBStub*); void GDBStubUpdate(struct GDBStub*); +CXX_GUARD_END + #endif diff --git a/src/debugger/parser.h b/src/debugger/parser.h index c68f08d9e..39ac6d262 100644 --- a/src/debugger/parser.h +++ b/src/debugger/parser.h @@ -7,6 +7,9 @@ #define PARSER_H #include "util/common.h" + +CXX_GUARD_START + #include "debugger.h" enum LexState { @@ -62,4 +65,6 @@ void parseLexedExpression(struct ParseTree* tree, struct LexVector* lv); void lexFree(struct LexVector* lv); void parseFree(struct ParseTree* tree); +CXX_GUARD_END + #endif diff --git a/src/feature/commandline.h b/src/feature/commandline.h index 9fbb64f79..0b672eb34 100644 --- a/src/feature/commandline.h +++ b/src/feature/commandline.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "debugger/debugger.h" struct mArguments { @@ -49,4 +51,6 @@ void version(const char* arg0); void initParserForGraphics(struct mSubParser* parser, struct mGraphicsOpts* opts); +CXX_GUARD_END + #endif diff --git a/src/feature/editline/cli-el-backend.h b/src/feature/editline/cli-el-backend.h index df3986e07..68fb32a1c 100644 --- a/src/feature/editline/cli-el-backend.h +++ b/src/feature/editline/cli-el-backend.h @@ -6,9 +6,12 @@ #ifndef CLI_EL_BACKEND_H #define CLI_EL_BACKEND_H -#include "debugger/cli-debugger.h" #include "util/common.h" +CXX_GUARD_START + +#include "debugger/cli-debugger.h" + #include struct CLIDebuggerEditLineBackend { @@ -20,4 +23,6 @@ struct CLIDebuggerEditLineBackend { struct CLIDebuggerBackend* CLIDebuggerEditLineBackendCreate(void); +CXX_GUARD_END + #endif diff --git a/src/feature/ffmpeg/ffmpeg-encoder.h b/src/feature/ffmpeg/ffmpeg-encoder.h index 6a8d9bf4a..b8017769f 100644 --- a/src/feature/ffmpeg/ffmpeg-encoder.h +++ b/src/feature/ffmpeg/ffmpeg-encoder.h @@ -6,6 +6,10 @@ #ifndef FFMPEG_ENCODER #define FFMPEG_ENCODER +#include "util/common.h" + +CXX_GUARD_START + #include "gba/gba.h" #include @@ -83,4 +87,6 @@ bool FFmpegEncoderOpen(struct FFmpegEncoder*, const char* outfile); void FFmpegEncoderClose(struct FFmpegEncoder*); bool FFmpegEncoderIsOpen(struct FFmpegEncoder*); +CXX_GUARD_END + #endif diff --git a/src/feature/gui/gui-config.h b/src/feature/gui/gui-config.h index 0771f2133..539bd109e 100644 --- a/src/feature/gui/gui-config.h +++ b/src/feature/gui/gui-config.h @@ -8,8 +8,12 @@ #include "util/common.h" +CXX_GUARD_START + struct mGUIRunner; struct GUIMenuItem; void mGUIShowConfig(struct mGUIRunner* runner, struct GUIMenuItem* extra, size_t nExtra); +CXX_GUARD_END + #endif diff --git a/src/feature/gui/gui-runner.h b/src/feature/gui/gui-runner.h index 556c4f269..1293b1e97 100644 --- a/src/feature/gui/gui-runner.h +++ b/src/feature/gui/gui-runner.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/config.h" #include "feature/gui/remap.h" #include "gba/hardware.h" @@ -75,4 +77,6 @@ void mGUIDeinit(struct mGUIRunner*); void mGUIRun(struct mGUIRunner*, const char* path); void mGUIRunloop(struct mGUIRunner*); +CXX_GUARD_END + #endif diff --git a/src/feature/gui/remap.h b/src/feature/gui/remap.h index ab6a0e70c..de0cd6e8a 100644 --- a/src/feature/gui/remap.h +++ b/src/feature/gui/remap.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + struct GUIInputKeys { const char* name; uint32_t id; @@ -20,4 +22,6 @@ struct mInputMap; void mGUIRemapKeys(struct GUIParams*, struct mInputMap*, const struct GUIInputKeys*); +CXX_GUARD_END + #endif diff --git a/src/feature/imagemagick/imagemagick-gif-encoder.c b/src/feature/imagemagick/imagemagick-gif-encoder.c index 2eb4ad358..ccd8ea426 100644 --- a/src/feature/imagemagick/imagemagick-gif-encoder.c +++ b/src/feature/imagemagick/imagemagick-gif-encoder.c @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "imagemagick-gif-encoder.h" +#include "gba/gba.h" #include "gba/video.h" #include "util/string.h" diff --git a/src/feature/imagemagick/imagemagick-gif-encoder.h b/src/feature/imagemagick/imagemagick-gif-encoder.h index 554813737..366c8f6b7 100644 --- a/src/feature/imagemagick/imagemagick-gif-encoder.h +++ b/src/feature/imagemagick/imagemagick-gif-encoder.h @@ -6,7 +6,11 @@ #ifndef IMAGEMAGICK_GIF_ENCODER #define IMAGEMAGICK_GIF_ENCODER -#include "gba/gba.h" +#include "util/common.h" + +CXX_GUARD_START + +#include "core/interface.h" #define MAGICKCORE_HDRI_ENABLE 0 #define MAGICKCORE_QUANTUM_DEPTH 8 @@ -33,4 +37,6 @@ bool ImageMagickGIFEncoderOpen(struct ImageMagickGIFEncoder*, const char* outfil bool ImageMagickGIFEncoderClose(struct ImageMagickGIFEncoder*); bool ImageMagickGIFEncoderIsOpen(struct ImageMagickGIFEncoder*); +CXX_GUARD_END + #endif diff --git a/src/gb/audio.h b/src/gb/audio.h index 4c38fcef8..bd47a72e9 100644 --- a/src/gb/audio.h +++ b/src/gb/audio.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/timing.h" #include "third-party/blip_buf/blip_buf.h" @@ -240,4 +242,6 @@ struct GBSerializedState; void GBAudioSerialize(const struct GBAudio* audio, struct GBSerializedState* state); void GBAudioDeserialize(struct GBAudio* audio, const struct GBSerializedState* state); +CXX_GUARD_END + #endif diff --git a/src/gb/cheats.h b/src/gb/cheats.h index 1e5b4da24..5b2f7e3a0 100644 --- a/src/gb/cheats.h +++ b/src/gb/cheats.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/cheats.h" #include "util/vector.h" @@ -36,4 +38,6 @@ struct GBCheatSet { struct mCheatDevice* GBCheatDeviceCreate(void); +CXX_GUARD_END + #endif diff --git a/src/gb/core.h b/src/gb/core.h index 10f7dc70d..5839b6709 100644 --- a/src/gb/core.h +++ b/src/gb/core.h @@ -6,7 +6,13 @@ #ifndef GB_CORE_H #define GB_CORE_H +#include "util/common.h" + +CXX_GUARD_START + struct mCore; struct mCore* GBCoreCreate(void); +CXX_GUARD_END + #endif diff --git a/src/gb/extra/cli.h b/src/gb/extra/cli.h index 013843ce5..343ef1546 100644 --- a/src/gb/extra/cli.h +++ b/src/gb/extra/cli.h @@ -6,6 +6,10 @@ #ifndef GB_CLI_H #define GB_CLI_H +#include "util/common.h" + +CXX_GUARD_START + #include "debugger/cli-debugger.h" struct GBCLIDebugger { @@ -19,4 +23,6 @@ struct GBCLIDebugger { struct CLIDebuggerSystem* GBCLIDebuggerCreate(struct mCore*); +CXX_GUARD_END + #endif diff --git a/src/gb/gb.h b/src/gb/gb.h index dba27742a..f270e58bf 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/log.h" #include "core/timing.h" @@ -141,4 +143,6 @@ void GBGetGameCode(const struct GB* gba, char* out); void GBFrameEnded(struct GB* gb); +CXX_GUARD_END + #endif diff --git a/src/gb/interface.h b/src/gb/interface.h index 246b8f858..2764c2a9b 100644 --- a/src/gb/interface.h +++ b/src/gb/interface.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + enum GBModel { GB_MODEL_AUTODETECT = 0xFF, GB_MODEL_DMG = 0x00, @@ -32,4 +34,6 @@ enum GBMemoryBankControllerType { GB_MBC5_RUMBLE = 0x105 }; +CXX_GUARD_END + #endif diff --git a/src/gb/io.h b/src/gb/io.h index ffd6f47c9..756157565 100644 --- a/src/gb/io.h +++ b/src/gb/io.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/log.h" mLOG_DECLARE_CATEGORY(GB_IO); @@ -118,4 +120,6 @@ struct GBSerializedState; void GBIOSerialize(const struct GB* gb, struct GBSerializedState* state); void GBIODeserialize(struct GB* gb, const struct GBSerializedState* state); +CXX_GUARD_END + #endif diff --git a/src/gb/mbc.h b/src/gb/mbc.h index c750db707..b38b53096 100644 --- a/src/gb/mbc.h +++ b/src/gb/mbc.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/log.h" mLOG_DECLARE_CATEGORY(GB_MBC); @@ -37,4 +39,6 @@ void GBMBCRTCWrite(struct GB* gb); uint8_t GBMBC7Read(struct GBMemory*, uint16_t address); void GBMBC7Write(struct GBMemory*, uint16_t address, uint8_t value); +CXX_GUARD_END + #endif diff --git a/src/gb/memory.h b/src/gb/memory.h index cb3cf1b1d..1117bb4b5 100644 --- a/src/gb/memory.h +++ b/src/gb/memory.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/log.h" #include "core/timing.h" #include "gb/interface.h" @@ -175,4 +177,6 @@ struct GBSerializedState; void GBMemorySerialize(const struct GB* gb, struct GBSerializedState* state); void GBMemoryDeserialize(struct GB* gb, const struct GBSerializedState* state); +CXX_GUARD_END + #endif diff --git a/src/gb/overrides.h b/src/gb/overrides.h index fc4f8f39a..1779aea16 100644 --- a/src/gb/overrides.h +++ b/src/gb/overrides.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "gb/interface.h" struct GBCartridgeOverride { @@ -24,4 +26,6 @@ struct GB; void GBOverrideApply(struct GB*, const struct GBCartridgeOverride*); void GBOverrideApplyDefaults(struct GB*); +CXX_GUARD_END + #endif diff --git a/src/gb/renderers/software.h b/src/gb/renderers/software.h index 6ea90a6e1..9f2b9e519 100644 --- a/src/gb/renderers/software.h +++ b/src/gb/renderers/software.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/core.h" #include "gb/gb.h" #include "gb/video.h" @@ -36,4 +38,6 @@ struct GBVideoSoftwareRenderer { void GBVideoSoftwareRendererCreate(struct GBVideoSoftwareRenderer*); +CXX_GUARD_END + #endif diff --git a/src/gb/renderers/tile-cache.h b/src/gb/renderers/tile-cache.h index 630b9e8e9..7a96ec866 100644 --- a/src/gb/renderers/tile-cache.h +++ b/src/gb/renderers/tile-cache.h @@ -8,10 +8,14 @@ #include "util/common.h" +CXX_GUARD_START + struct GBVideo; struct mTileCache; void GBVideoTileCacheInit(struct mTileCache* cache); void GBVideoTileCacheAssociate(struct mTileCache* cache, struct GBVideo* video); +CXX_GUARD_END + #endif diff --git a/src/gb/serialize.h b/src/gb/serialize.h index 3329141db..9819af85a 100644 --- a/src/gb/serialize.h +++ b/src/gb/serialize.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/core.h" #include "gb/gb.h" @@ -370,4 +372,6 @@ struct GBSerializedState { bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state); void GBSerialize(struct GB* gb, struct GBSerializedState* state); +CXX_GUARD_END + #endif diff --git a/src/gb/sio.h b/src/gb/sio.h index e5dbe6bbd..e101f9c3f 100644 --- a/src/gb/sio.h +++ b/src/gb/sio.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/log.h" #include "core/timing.h" @@ -53,4 +55,6 @@ void GBSIOSetDriver(struct GBSIO* sio, struct GBSIODriver* driver); void GBSIOWriteSC(struct GBSIO* sio, uint8_t sc); void GBSIOWriteSB(struct GBSIO* sio, uint8_t sb); +CXX_GUARD_END + #endif diff --git a/src/gb/sio/lockstep.h b/src/gb/sio/lockstep.h index a2a85457d..2b1b52815 100644 --- a/src/gb/sio/lockstep.h +++ b/src/gb/sio/lockstep.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/lockstep.h" #include "core/timing.h" #include "gb/sio.h" @@ -42,4 +44,6 @@ void GBSIOLockstepNodeCreate(struct GBSIOLockstepNode*); bool GBSIOLockstepAttachNode(struct GBSIOLockstep*, struct GBSIOLockstepNode*); void GBSIOLockstepDetachNode(struct GBSIOLockstep*, struct GBSIOLockstepNode*); +CXX_GUARD_END + #endif diff --git a/src/gb/timer.h b/src/gb/timer.h index 9ce673b56..0a6ebcea9 100644 --- a/src/gb/timer.h +++ b/src/gb/timer.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/timing.h" DECL_BITFIELD(GBRegisterTAC, uint8_t); @@ -38,4 +40,6 @@ struct GBSerializedState; void GBTimerSerialize(const struct GBTimer* timer, struct GBSerializedState* state); void GBTimerDeserialize(struct GBTimer* timer, const struct GBSerializedState* state); +CXX_GUARD_END + #endif diff --git a/src/gb/video.h b/src/gb/video.h index a2ddccdb3..0c7824478 100644 --- a/src/gb/video.h +++ b/src/gb/video.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/interface.h" #include "core/timing.h" #include "gb/interface.h" @@ -143,4 +145,6 @@ struct GBSerializedState; void GBVideoSerialize(const struct GBVideo* video, struct GBSerializedState* state); void GBVideoDeserialize(struct GBVideo* video, const struct GBSerializedState* state); +CXX_GUARD_END + #endif diff --git a/src/gba/audio.h b/src/gba/audio.h index 7f8175380..3a6d07348 100644 --- a/src/gba/audio.h +++ b/src/gba/audio.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/log.h" #include "gb/audio.h" #include "util/circle-buffer.h" @@ -116,4 +118,6 @@ void GBAAudioDeserialize(struct GBAAudio* audio, const struct GBASerializedState float GBAAudioCalculateRatio(float inputSampleRate, float desiredFPS, float desiredSampleRatio); +CXX_GUARD_END + #endif diff --git a/src/gba/bios.h b/src/gba/bios.h index fdda39402..7d2bed194 100644 --- a/src/gba/bios.h +++ b/src/gba/bios.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "arm/arm.h" #include "core/log.h" @@ -20,4 +22,6 @@ uint32_t GBAChecksum(uint32_t* memory, size_t size); extern const uint32_t GBA_BIOS_CHECKSUM; extern const uint32_t GBA_DS_BIOS_CHECKSUM; +CXX_GUARD_END + #endif diff --git a/src/gba/cheats.h b/src/gba/cheats.h index 31f5acadc..6dcd01f53 100644 --- a/src/gba/cheats.h +++ b/src/gba/cheats.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "arm/arm.h" #include "core/cheats.h" @@ -174,4 +176,6 @@ bool GBACheatAddVBALine(struct GBACheatSet*, const char* line); int GBACheatAddressIsReal(uint32_t address); +CXX_GUARD_END + #endif diff --git a/src/gba/cheats/gameshark.h b/src/gba/cheats/gameshark.h index 09bdfe997..86736f492 100644 --- a/src/gba/cheats/gameshark.h +++ b/src/gba/cheats/gameshark.h @@ -6,6 +6,10 @@ #ifndef GBA_CHEATS_GAMESHARK_H #define GBA_CHEATS_GAMESHARK_H +#include "util/common.h" + +CXX_GUARD_START + #include "gba/cheats.h" extern const uint32_t GBACheatGameSharkSeeds[4]; @@ -16,4 +20,6 @@ void GBACheatSetGameSharkVersion(struct GBACheatSet* cheats, int version); bool GBACheatAddGameSharkRaw(struct GBACheatSet* cheats, uint32_t op1, uint32_t op2); int GBACheatGameSharkProbability(uint32_t op1, uint32_t op2); +CXX_GUARD_END + #endif diff --git a/src/gba/cheats/parv3.h b/src/gba/cheats/parv3.h index 66a0e26fe..2723d673f 100644 --- a/src/gba/cheats/parv3.h +++ b/src/gba/cheats/parv3.h @@ -6,6 +6,10 @@ #ifndef GBA_CHEATS_PARV3_H #define GBA_CHEATS_PARV3_H +#include "util/common.h" + +CXX_GUARD_START + #include "gba/cheats.h" extern const uint32_t GBACheatProActionReplaySeeds[4]; @@ -13,4 +17,6 @@ extern const uint32_t GBACheatProActionReplaySeeds[4]; bool GBACheatAddProActionReplayRaw(struct GBACheatSet* cheats, uint32_t op1, uint32_t op2); int GBACheatProActionReplayProbability(uint32_t op1, uint32_t op2); +CXX_GUARD_END + #endif diff --git a/src/gba/core.h b/src/gba/core.h index c68277c25..add75ede7 100644 --- a/src/gba/core.h +++ b/src/gba/core.h @@ -6,7 +6,13 @@ #ifndef GBA_CORE_H #define GBA_CORE_H +#include "util/common.h" + +CXX_GUARD_START + struct mCore; struct mCore* GBACoreCreate(void); +CXX_GUARD_END + #endif diff --git a/src/gba/dma.h b/src/gba/dma.h index 405a9e554..984980c87 100644 --- a/src/gba/dma.h +++ b/src/gba/dma.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + struct GBA; void GBADMAInit(struct GBA* gba); void GBADMAReset(struct GBA* gba); @@ -23,4 +25,6 @@ void GBADMARunHblank(struct GBA* gba, int32_t cycles); void GBADMARunVblank(struct GBA* gba, int32_t cycles); void GBADMAUpdate(struct GBA* gba); +CXX_GUARD_END + #endif diff --git a/src/gba/extra/cli.h b/src/gba/extra/cli.h index 347f45437..e77f8439d 100644 --- a/src/gba/extra/cli.h +++ b/src/gba/extra/cli.h @@ -6,6 +6,10 @@ #ifndef GBA_CLI_H #define GBA_CLI_H +#include "util/common.h" + +CXX_GUARD_START + #include "debugger/cli-debugger.h" struct mCore; @@ -21,4 +25,6 @@ struct GBACLIDebugger { struct GBACLIDebugger* GBACLIDebuggerCreate(struct mCore*); +CXX_GUARD_END + #endif diff --git a/src/gba/gba.h b/src/gba/gba.h index cfcaa94e3..7adc8bd2b 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "arm/arm.h" #include "core/log.h" #include "core/timing.h" @@ -175,4 +177,6 @@ void GBAGetGameTitle(const struct GBA* gba, char* out); void GBAFrameStarted(struct GBA* gba); void GBAFrameEnded(struct GBA* gba); +CXX_GUARD_END + #endif diff --git a/src/gba/hardware.h b/src/gba/hardware.h index bf7915c2c..0329fbf5e 100644 --- a/src/gba/hardware.h +++ b/src/gba/hardware.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "arm/macros.h" #include "core/log.h" #include "core/timing.h" @@ -144,4 +146,6 @@ struct GBASerializedState; void GBAHardwareSerialize(const struct GBACartridgeHardware* gpio, struct GBASerializedState* state); void GBAHardwareDeserialize(struct GBACartridgeHardware* gpio, const struct GBASerializedState* state); +CXX_GUARD_END + #endif diff --git a/src/gba/hle-bios.h b/src/gba/hle-bios.h index 6aa4cb92f..a696d7f6b 100644 --- a/src/gba/hle-bios.h +++ b/src/gba/hle-bios.h @@ -8,6 +8,10 @@ #include "util/common.h" +CXX_GUARD_START + extern const uint8_t hleBios[]; +CXX_GUARD_END + #endif diff --git a/src/gba/input.h b/src/gba/input.h index 5b3a418c1..cf2da1469 100644 --- a/src/gba/input.h +++ b/src/gba/input.h @@ -6,6 +6,10 @@ #ifndef GBA_INPUT_H #define GBA_INPUT_H +#include "util/common.h" + +CXX_GUARD_START + #include "core/input.h" extern const struct mInputPlatformInfo GBAInputInfo; @@ -25,4 +29,6 @@ enum GBAKey { GBA_KEY_NONE = -1 }; +CXX_GUARD_END + #endif diff --git a/src/gba/interface.h b/src/gba/interface.h index e0d27de98..2c9df6be3 100644 --- a/src/gba/interface.h +++ b/src/gba/interface.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/interface.h" enum GBASIOMode { @@ -42,4 +44,6 @@ struct GBASIODriver { uint16_t (*writeRegister)(struct GBASIODriver* driver, uint32_t address, uint16_t value); }; +CXX_GUARD_END + #endif diff --git a/src/gba/io.h b/src/gba/io.h index 5a73bce34..b7e6aaddd 100644 --- a/src/gba/io.h +++ b/src/gba/io.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "gba/gba.h" enum GBAIORegisters { @@ -173,4 +175,6 @@ struct GBASerializedState; void GBAIOSerialize(struct GBA* gba, struct GBASerializedState* state); void GBAIODeserialize(struct GBA* gba, const struct GBASerializedState* state); +CXX_GUARD_END + #endif diff --git a/src/gba/memory.h b/src/gba/memory.h index 08d89e9df..c9a81f4f3 100644 --- a/src/gba/memory.h +++ b/src/gba/memory.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "arm/arm.h" #include "core/timing.h" @@ -180,4 +182,6 @@ struct GBASerializedState; void GBAMemorySerialize(const struct GBAMemory* memory, struct GBASerializedState* state); void GBAMemoryDeserialize(struct GBAMemory* memory, const struct GBASerializedState* state); +CXX_GUARD_END + #endif diff --git a/src/gba/overrides.h b/src/gba/overrides.h index 58c005588..c86c0e728 100644 --- a/src/gba/overrides.h +++ b/src/gba/overrides.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "gba/savedata.h" #define IDLE_LOOP_NONE 0xFFFFFFFF @@ -28,4 +30,6 @@ struct GBA; void GBAOverrideApply(struct GBA*, const struct GBACartridgeOverride*); void GBAOverrideApplyDefaults(struct GBA*); +CXX_GUARD_END + #endif diff --git a/src/gba/renderers/thread-proxy.h b/src/gba/renderers/thread-proxy.h index 3f39176c4..2914f203b 100644 --- a/src/gba/renderers/thread-proxy.h +++ b/src/gba/renderers/thread-proxy.h @@ -6,6 +6,10 @@ #ifndef VIDEO_THREAD_PROXY_H #define VIDEO_THREAD_PROXY_H +#include "util/common.h" + +CXX_GUARD_START + #include "gba/video.h" #include "util/threading.h" #include "util/ring-fifo.h" @@ -38,4 +42,6 @@ struct GBAVideoThreadProxyRenderer { void GBAVideoThreadProxyRendererCreate(struct GBAVideoThreadProxyRenderer* renderer, struct GBAVideoRenderer* backend); +CXX_GUARD_END + #endif diff --git a/src/gba/renderers/tile-cache.h b/src/gba/renderers/tile-cache.h index 04463a4ec..2afa25696 100644 --- a/src/gba/renderers/tile-cache.h +++ b/src/gba/renderers/tile-cache.h @@ -8,10 +8,14 @@ #include "util/common.h" +CXX_GUARD_START + struct GBAVideo; struct mTileCache; void GBAVideoTileCacheInit(struct mTileCache* cache); void GBAVideoTileCacheAssociate(struct mTileCache* cache, struct GBAVideo* video); +CXX_GUARD_END + #endif diff --git a/src/gba/renderers/video-software.h b/src/gba/renderers/video-software.h index c6def6d60..96f0445df 100644 --- a/src/gba/renderers/video-software.h +++ b/src/gba/renderers/video-software.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/core.h" #include "gba/video.h" @@ -162,4 +164,6 @@ struct GBAVideoSoftwareRenderer { void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer); +CXX_GUARD_START + #endif diff --git a/src/gba/rr/mgm.h b/src/gba/rr/mgm.h index 9c494d50f..f45351a7b 100644 --- a/src/gba/rr/mgm.h +++ b/src/gba/rr/mgm.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "gba/rr/rr.h" struct GBA; @@ -80,4 +82,6 @@ void GBAMGMContextCreate(struct GBAMGMContext*); bool GBAMGMSetStream(struct GBAMGMContext* mgm, struct VDir* stream); bool GBAMGMCreateStream(struct GBAMGMContext* mgm, enum GBARRInitFrom initFrom); +CXX_GUARD_END + #endif diff --git a/src/gba/rr/rr.h b/src/gba/rr/rr.h index eb2964e1e..dcc7ea782 100644 --- a/src/gba/rr/rr.h +++ b/src/gba/rr/rr.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/log.h" #include "gba/serialize.h" @@ -58,4 +60,6 @@ void GBARRDestroy(struct GBARRContext*); void GBARRInitRecord(struct GBA*); void GBARRInitPlay(struct GBA*); +CXX_GUARD_END + #endif diff --git a/src/gba/rr/vbm.h b/src/gba/rr/vbm.h index a314b9b0b..e38f83261 100644 --- a/src/gba/rr/vbm.h +++ b/src/gba/rr/vbm.h @@ -3,8 +3,13 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef GBA_VBM_H +#define GBA_VBM_H + #include "util/common.h" +CXX_GUARD_START + #include "gba/rr/rr.h" struct GBAVBMContext { @@ -19,3 +24,7 @@ struct GBAVBMContext { void GBAVBMContextCreate(struct GBAVBMContext*); bool GBAVBMSetStream(struct GBAVBMContext*, struct VFile*); + +CXX_GUARD_END + +#endif diff --git a/src/gba/savedata.h b/src/gba/savedata.h index 98feb52b4..bd2c8fc97 100644 --- a/src/gba/savedata.h +++ b/src/gba/savedata.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/log.h" mLOG_DECLARE_CATEGORY(GBA_SAVE); @@ -119,4 +121,6 @@ struct GBASerializedState; void GBASavedataSerialize(const struct GBASavedata* savedata, struct GBASerializedState* state); void GBASavedataDeserialize(struct GBASavedata* savedata, const struct GBASerializedState* state); +CXX_GUARD_END + #endif diff --git a/src/gba/serialize.h b/src/gba/serialize.h index 6db9eec1e..301eae0a9 100644 --- a/src/gba/serialize.h +++ b/src/gba/serialize.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/core.h" #include "gba/gba.h" #include "gb/serialize.h" @@ -333,4 +335,6 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state); struct GBASerializedState* GBAAllocateState(void); void GBADeallocateState(struct GBASerializedState* state); +CXX_GUARD_END + #endif diff --git a/src/gba/sharkport.h b/src/gba/sharkport.h index 520ec246e..18bb0c64b 100644 --- a/src/gba/sharkport.h +++ b/src/gba/sharkport.h @@ -8,10 +8,14 @@ #include "util/common.h" +CXX_GUARD_START + struct GBA; struct VFile; bool GBASavedataImportSharkPort(struct GBA* gba, struct VFile* vf, bool testChecksum); bool GBASavedataExportSharkPort(const struct GBA* gba, struct VFile* vf); +CXX_GUARD_END + #endif diff --git a/src/gba/sio.h b/src/gba/sio.h index d9cfc83f0..f626979dd 100644 --- a/src/gba/sio.h +++ b/src/gba/sio.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/log.h" #include "gba/interface.h" @@ -78,4 +80,6 @@ void GBASIOWriteRCNT(struct GBASIO* sio, uint16_t value); void GBASIOWriteSIOCNT(struct GBASIO* sio, uint16_t value); uint16_t GBASIOWriteRegister(struct GBASIO* sio, uint32_t address, uint16_t value); +CXX_GUARD_END + #endif diff --git a/src/gba/sio/lockstep.h b/src/gba/sio/lockstep.h index 90391b61d..cecfbc733 100644 --- a/src/gba/sio/lockstep.h +++ b/src/gba/sio/lockstep.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/lockstep.h" #include "core/timing.h" #include "gba/sio.h" @@ -46,4 +48,6 @@ void GBASIOLockstepNodeCreate(struct GBASIOLockstepNode*); bool GBASIOLockstepAttachNode(struct GBASIOLockstep*, struct GBASIOLockstepNode*); void GBASIOLockstepDetachNode(struct GBASIOLockstep*, struct GBASIOLockstepNode*); +CXX_GUARD_END + #endif diff --git a/src/gba/timer.h b/src/gba/timer.h index 08314a4cf..1edce1c9e 100644 --- a/src/gba/timer.h +++ b/src/gba/timer.h @@ -7,6 +7,9 @@ #define GBA_TIMER_H #include "util/common.h" + +CXX_GUARD_START + #include "core/timing.h" DECL_BITFIELD(GBATimerFlags, uint32_t); @@ -30,4 +33,6 @@ void GBATimerUpdateRegister(struct GBA* gba, int timer); void GBATimerWriteTMCNT_LO(struct GBA* gba, int timer, uint16_t value); void GBATimerWriteTMCNT_HI(struct GBA* gba, int timer, uint16_t value); +CXX_GUARD_END + #endif diff --git a/src/gba/vfame.h b/src/gba/vfame.h index d418f7a9b..fa226efa3 100644 --- a/src/gba/vfame.h +++ b/src/gba/vfame.h @@ -11,6 +11,8 @@ #include "util/common.h" +CXX_GUARD_START + enum GBAVFameCartType { VFAME_NO = 0, VFAME_STANDARD = 1, @@ -31,4 +33,6 @@ void GBAVFameSramWrite(struct GBAVFameCart* cart, uint32_t address, uint8_t valu uint32_t GBAVFameModifyRomAddress(struct GBAVFameCart* cart, uint32_t address, size_t romSize); uint32_t GBAVFameGetPatternValue(uint32_t address, int bits); +CXX_GUARD_END + #endif diff --git a/src/gba/video.h b/src/gba/video.h index da9f85848..01ef2b55e 100644 --- a/src/gba/video.h +++ b/src/gba/video.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/core.h" #include "core/timing.h" #include "gba/memory.h" @@ -199,4 +201,6 @@ void GBAVideoDeserialize(struct GBAVideo* video, const struct GBASerializedState extern const int GBAVideoObjSizes[16][2]; +CXX_GUARD_END + #endif diff --git a/src/lr35902/debugger/cli-debugger.h b/src/lr35902/debugger/cli-debugger.h index 5e6a8b1a3..a229f03cc 100644 --- a/src/lr35902/debugger/cli-debugger.h +++ b/src/lr35902/debugger/cli-debugger.h @@ -8,7 +8,11 @@ #include "util/common.h" +CXX_GUARD_START + struct CLIDebuggerSystem; void LR35902CLIDebuggerCreate(struct CLIDebuggerSystem* debugger); +CXX_GUARD_END + #endif diff --git a/src/lr35902/debugger/debugger.h b/src/lr35902/debugger/debugger.h index 53e022c30..9697f5fc5 100644 --- a/src/lr35902/debugger/debugger.h +++ b/src/lr35902/debugger/debugger.h @@ -3,6 +3,13 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef LR35902_DEBUGGER_H +#define LR35902_DEBUGGER_H + +#include "util/common.h" + +CXX_GUARD_START + #include "debugger/debugger.h" struct LR35902DebugBreakpoint { @@ -28,3 +35,7 @@ struct LR35902Debugger { }; struct mDebuggerPlatform* LR35902DebuggerPlatformCreate(void); + +CXX_GUARD_END + +#endif diff --git a/src/lr35902/isa-lr35902.h b/src/lr35902/isa-lr35902.h index 0b73c8deb..60e278f4e 100644 --- a/src/lr35902/isa-lr35902.h +++ b/src/lr35902/isa-lr35902.h @@ -8,9 +8,13 @@ #include "util/common.h" +CXX_GUARD_START + struct LR35902Core; typedef void (*LR35902Instruction)(struct LR35902Core*); extern const LR35902Instruction _lr35902InstructionTable[0x100]; +CXX_GUARD_END + #endif diff --git a/src/lr35902/lr35902.h b/src/lr35902/lr35902.h index 84eddfb73..102f3941e 100644 --- a/src/lr35902/lr35902.h +++ b/src/lr35902/lr35902.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/cpu.h" #include "lr35902/isa-lr35902.h" @@ -167,4 +169,6 @@ void LR35902RaiseIRQ(struct LR35902Core* cpu, uint8_t vector); void LR35902Tick(struct LR35902Core* cpu); void LR35902Run(struct LR35902Core* cpu); +CXX_GUARD_END + #endif diff --git a/src/platform/opengl/gl.h b/src/platform/opengl/gl.h index 0370e2ea7..b5cda4ce7 100644 --- a/src/platform/opengl/gl.h +++ b/src/platform/opengl/gl.h @@ -6,6 +6,10 @@ #ifndef GL_H #define GL_H +#include "util/common.h" + +CXX_GUARD_START + #ifdef USE_EPOXY #include #elif defined(__APPLE__) @@ -27,4 +31,6 @@ struct mGLContext { void mGLContextCreate(struct mGLContext*); +CXX_GUARD_END + #endif diff --git a/src/platform/opengl/gles2.h b/src/platform/opengl/gles2.h index fabdebc14..03cbaf0ae 100644 --- a/src/platform/opengl/gles2.h +++ b/src/platform/opengl/gles2.h @@ -6,6 +6,10 @@ #ifndef GLES2_H #define GLES2_H +#include "util/common.h" + +CXX_GUARD_START + #ifdef USE_EPOXY #include #elif defined(BUILD_GL) @@ -94,4 +98,6 @@ struct VDir; bool mGLES2ShaderLoad(struct VideoShader*, struct VDir*); void mGLES2ShaderFree(struct VideoShader*); +CXX_GUARD_END + #endif diff --git a/src/platform/posix/threading.h b/src/platform/posix/threading.h index e13240f3e..0b958af54 100644 --- a/src/platform/posix/threading.h +++ b/src/platform/posix/threading.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include #include #if defined(__FreeBSD__) || defined(__OpenBSD__) @@ -94,4 +96,6 @@ static inline int ThreadSetName(const char* name) { #endif } +CXX_GUARD_END + #endif diff --git a/src/platform/qt/AboutScreen.cpp b/src/platform/qt/AboutScreen.cpp index e2743ce4e..895eaec74 100644 --- a/src/platform/qt/AboutScreen.cpp +++ b/src/platform/qt/AboutScreen.cpp @@ -5,9 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "AboutScreen.h" -extern "C" { #include "core/version.h" -} #include #include diff --git a/src/platform/qt/ArchiveInspector.cpp b/src/platform/qt/ArchiveInspector.cpp index 368b47a0d..11854ed95 100644 --- a/src/platform/qt/ArchiveInspector.cpp +++ b/src/platform/qt/ArchiveInspector.cpp @@ -5,9 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ArchiveInspector.h" -extern "C" { #include "util/vfs.h" -} using namespace QGBA; diff --git a/src/platform/qt/AssetTile.cpp b/src/platform/qt/AssetTile.cpp index e2e39b18d..7066a78bf 100644 --- a/src/platform/qt/AssetTile.cpp +++ b/src/platform/qt/AssetTile.cpp @@ -9,7 +9,6 @@ #include -extern "C" { #include "core/interface.h" #ifdef M_CORE_GBA #include "gba/memory.h" @@ -17,7 +16,6 @@ extern "C" { #ifdef M_CORE_GB #include "gb/memory.h" #endif -} using namespace QGBA; diff --git a/src/platform/qt/AssetTile.h b/src/platform/qt/AssetTile.h index b8cd6b53a..59800405a 100644 --- a/src/platform/qt/AssetTile.h +++ b/src/platform/qt/AssetTile.h @@ -10,9 +10,7 @@ #include "ui_AssetTile.h" -extern "C" { #include "core/tile-cache.h" -} namespace QGBA { diff --git a/src/platform/qt/AssetView.cpp b/src/platform/qt/AssetView.cpp index ebb337ed1..21420ae25 100644 --- a/src/platform/qt/AssetView.cpp +++ b/src/platform/qt/AssetView.cpp @@ -7,11 +7,9 @@ #include -extern "C" { #ifdef M_CORE_GBA #include "gba/gba.h" #endif -} using namespace QGBA; diff --git a/src/platform/qt/AudioDevice.cpp b/src/platform/qt/AudioDevice.cpp index 5f61dbb58..ae34d3221 100644 --- a/src/platform/qt/AudioDevice.cpp +++ b/src/platform/qt/AudioDevice.cpp @@ -7,10 +7,8 @@ #include "LogController.h" -extern "C" { #include "core/thread.h" #include "gba/audio.h" -} using namespace QGBA; diff --git a/src/platform/qt/AudioProcessorQt.cpp b/src/platform/qt/AudioProcessorQt.cpp index b999124bb..0f29105ec 100644 --- a/src/platform/qt/AudioProcessorQt.cpp +++ b/src/platform/qt/AudioProcessorQt.cpp @@ -10,9 +10,7 @@ #include -extern "C" { #include "core/thread.h" -} using namespace QGBA; diff --git a/src/platform/qt/AudioProcessorSDL.cpp b/src/platform/qt/AudioProcessorSDL.cpp index 08c1fe908..d869f8836 100644 --- a/src/platform/qt/AudioProcessorSDL.cpp +++ b/src/platform/qt/AudioProcessorSDL.cpp @@ -7,9 +7,7 @@ #include "LogController.h" -extern "C" { #include "core/thread.h" -} using namespace QGBA; diff --git a/src/platform/qt/AudioProcessorSDL.h b/src/platform/qt/AudioProcessorSDL.h index 2559ed49e..cd1d53957 100644 --- a/src/platform/qt/AudioProcessorSDL.h +++ b/src/platform/qt/AudioProcessorSDL.h @@ -9,9 +9,7 @@ #ifdef BUILD_SDL -extern "C" { #include "platform/sdl/sdl-audio.h" -} namespace QGBA { diff --git a/src/platform/qt/CheatsModel.cpp b/src/platform/qt/CheatsModel.cpp index 5d6b8cf65..d822b305f 100644 --- a/src/platform/qt/CheatsModel.cpp +++ b/src/platform/qt/CheatsModel.cpp @@ -10,9 +10,7 @@ #include -extern "C" { #include "core/cheats.h" -} using namespace QGBA; diff --git a/src/platform/qt/CheatsView.cpp b/src/platform/qt/CheatsView.cpp index a990ff25f..41799530a 100644 --- a/src/platform/qt/CheatsView.cpp +++ b/src/platform/qt/CheatsView.cpp @@ -11,7 +11,6 @@ #include #include -extern "C" { #include "core/cheats.h" #ifdef M_CORE_GBA #include "gba/cheats.h" @@ -19,7 +18,6 @@ extern "C" { #ifdef M_CORE_GB #include "gb/cheats.h" #endif -} using namespace QGBA; diff --git a/src/platform/qt/ConfigController.cpp b/src/platform/qt/ConfigController.cpp index 50462d7e8..d008fd756 100644 --- a/src/platform/qt/ConfigController.cpp +++ b/src/platform/qt/ConfigController.cpp @@ -11,9 +11,7 @@ #include #include -extern "C" { #include "feature/commandline.h" -} using namespace QGBA; diff --git a/src/platform/qt/ConfigController.h b/src/platform/qt/ConfigController.h index 4d8ab80a0..1953ccfbf 100644 --- a/src/platform/qt/ConfigController.h +++ b/src/platform/qt/ConfigController.h @@ -15,11 +15,9 @@ #include -extern "C" { #include "core/config.h" #include "util/configuration.h" #include "feature/commandline.h" -} class QAction; class QMenu; diff --git a/src/platform/qt/DebuggerConsoleController.cpp b/src/platform/qt/DebuggerConsoleController.cpp index 22cc9b3ff..0ac49fa0d 100644 --- a/src/platform/qt/DebuggerConsoleController.cpp +++ b/src/platform/qt/DebuggerConsoleController.cpp @@ -9,9 +9,7 @@ #include -extern "C" { #include "debugger/cli-debugger.h" -} using namespace QGBA; diff --git a/src/platform/qt/DebuggerConsoleController.h b/src/platform/qt/DebuggerConsoleController.h index 1128aabca..bac31e20b 100644 --- a/src/platform/qt/DebuggerConsoleController.h +++ b/src/platform/qt/DebuggerConsoleController.h @@ -12,9 +12,7 @@ #include #include -extern "C" { #include "debugger/cli-debugger.h" -} namespace QGBA { diff --git a/src/platform/qt/Display.cpp b/src/platform/qt/Display.cpp index a8af613ec..81526be51 100644 --- a/src/platform/qt/Display.cpp +++ b/src/platform/qt/Display.cpp @@ -8,13 +8,11 @@ #include "DisplayGL.h" #include "DisplayQt.h" -extern "C" { #ifdef M_CORE_GB #include "gb/video.h" #elif defined(M_CORE_GBA) #include "gba/video.h" #endif -} using namespace QGBA; diff --git a/src/platform/qt/Display.h b/src/platform/qt/Display.h index 841cd4278..66ce63110 100644 --- a/src/platform/qt/Display.h +++ b/src/platform/qt/Display.h @@ -6,9 +6,7 @@ #ifndef QGBA_DISPLAY #define QGBA_DISPLAY -extern "C" { #include "util/common.h" -} #include diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp index c565b545e..f59474428 100644 --- a/src/platform/qt/DisplayGL.cpp +++ b/src/platform/qt/DisplayGL.cpp @@ -8,7 +8,6 @@ #include #include -extern "C" { #include "core/core.h" #include "core/thread.h" #ifdef BUILD_GL @@ -20,7 +19,6 @@ extern "C" { #include #endif #endif -} using namespace QGBA; diff --git a/src/platform/qt/DisplayGL.h b/src/platform/qt/DisplayGL.h index 5803dfd92..d89c26418 100644 --- a/src/platform/qt/DisplayGL.h +++ b/src/platform/qt/DisplayGL.h @@ -22,9 +22,7 @@ #include #include -extern "C" { #include "platform/video-backend.h" -} namespace QGBA { diff --git a/src/platform/qt/DisplayQt.cpp b/src/platform/qt/DisplayQt.cpp index b11294638..5dec87215 100644 --- a/src/platform/qt/DisplayQt.cpp +++ b/src/platform/qt/DisplayQt.cpp @@ -7,10 +7,8 @@ #include -extern "C" { #include "core/core.h" #include "core/thread.h" -} using namespace QGBA; diff --git a/src/platform/qt/GBAApp.cpp b/src/platform/qt/GBAApp.cpp index 377f9f67d..284145535 100644 --- a/src/platform/qt/GBAApp.cpp +++ b/src/platform/qt/GBAApp.cpp @@ -16,12 +16,10 @@ #include #include -extern "C" { #include "core/version.h" #include "feature/commandline.h" #include "util/nointro.h" #include "util/socket.h" -} using namespace QGBA; diff --git a/src/platform/qt/GBAApp.h b/src/platform/qt/GBAApp.h index ea7fa1267..988b55f11 100644 --- a/src/platform/qt/GBAApp.h +++ b/src/platform/qt/GBAApp.h @@ -14,10 +14,8 @@ struct NoIntroDB; -extern "C" { #include "core/log.h" #include "gba/sio.h" -} mLOG_DECLARE_CATEGORY(QT); diff --git a/src/platform/qt/GBAKeyEditor.cpp b/src/platform/qt/GBAKeyEditor.cpp index 0c33058ba..439b4294c 100644 --- a/src/platform/qt/GBAKeyEditor.cpp +++ b/src/platform/qt/GBAKeyEditor.cpp @@ -16,9 +16,7 @@ #include "KeyEditor.h" #ifdef BUILD_SDL -extern "C" { #include "platform/sdl/sdl-events.h" -} #endif using namespace QGBA; diff --git a/src/platform/qt/GBAKeyEditor.h b/src/platform/qt/GBAKeyEditor.h index bbd839063..a2b1391fc 100644 --- a/src/platform/qt/GBAKeyEditor.h +++ b/src/platform/qt/GBAKeyEditor.h @@ -11,9 +11,7 @@ #include #include -extern "C" { #include "gba/input.h" -} class QComboBox; class QTimer; diff --git a/src/platform/qt/GBAOverride.cpp b/src/platform/qt/GBAOverride.cpp index 1181162e2..bd165454a 100644 --- a/src/platform/qt/GBAOverride.cpp +++ b/src/platform/qt/GBAOverride.cpp @@ -5,9 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "GBAOverride.h" -extern "C" { #include "core/core.h" -} using namespace QGBA; diff --git a/src/platform/qt/GBAOverride.h b/src/platform/qt/GBAOverride.h index 71d67f90d..8f2042684 100644 --- a/src/platform/qt/GBAOverride.h +++ b/src/platform/qt/GBAOverride.h @@ -8,9 +8,7 @@ #include "Override.h" -extern "C" { #include "gba/overrides.h" -} namespace QGBA { diff --git a/src/platform/qt/GBOverride.cpp b/src/platform/qt/GBOverride.cpp index d04e90082..6aa4fd205 100644 --- a/src/platform/qt/GBOverride.cpp +++ b/src/platform/qt/GBOverride.cpp @@ -5,11 +5,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "GBOverride.h" -extern "C" { #include "core/core.h" #include "gb/gb.h" #include "util/crc32.h" -} using namespace QGBA; diff --git a/src/platform/qt/GBOverride.h b/src/platform/qt/GBOverride.h index 5fb7c057d..6d35618fc 100644 --- a/src/platform/qt/GBOverride.h +++ b/src/platform/qt/GBOverride.h @@ -8,9 +8,7 @@ #include "Override.h" -extern "C" { #include "gb/overrides.h" -} namespace QGBA { diff --git a/src/platform/qt/GDBController.h b/src/platform/qt/GDBController.h index fa295a074..aac3852b8 100644 --- a/src/platform/qt/GDBController.h +++ b/src/platform/qt/GDBController.h @@ -10,9 +10,7 @@ #ifdef USE_GDB_STUB -extern "C" { #include "debugger/gdb-stub.h" -} namespace QGBA { diff --git a/src/platform/qt/GIFView.h b/src/platform/qt/GIFView.h index ccfeddbc0..6641d8d94 100644 --- a/src/platform/qt/GIFView.h +++ b/src/platform/qt/GIFView.h @@ -12,9 +12,7 @@ #include "ui_GIFView.h" -extern "C" { #include "feature/imagemagick/imagemagick-gif-encoder.h" -} namespace QGBA { diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index eb5ef964c..d31ffa1a3 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -17,7 +17,6 @@ #include -extern "C" { #include "core/config.h" #include "core/directories.h" #include "core/serialize.h" @@ -34,7 +33,6 @@ extern "C" { #include "gb/renderers/tile-cache.h" #endif #include "util/vfs.h" -} using namespace QGBA; using namespace std; diff --git a/src/platform/qt/GameController.h b/src/platform/qt/GameController.h index 17282ad3a..30369c538 100644 --- a/src/platform/qt/GameController.h +++ b/src/platform/qt/GameController.h @@ -15,7 +15,6 @@ #include -extern "C" { #include "core/core.h" #include "core/thread.h" #include "gba/cheats.h" @@ -25,7 +24,6 @@ extern "C" { #ifdef BUILD_SDL #include "platform/sdl/sdl-events.h" #endif -} struct Configuration; struct GBAAudio; diff --git a/src/platform/qt/GamepadAxisEvent.h b/src/platform/qt/GamepadAxisEvent.h index 09a1b015d..6416041bd 100644 --- a/src/platform/qt/GamepadAxisEvent.h +++ b/src/platform/qt/GamepadAxisEvent.h @@ -8,9 +8,7 @@ #include -extern "C" { #include "gba/input.h" -} namespace QGBA { diff --git a/src/platform/qt/GamepadButtonEvent.h b/src/platform/qt/GamepadButtonEvent.h index 375a0e05f..82419191e 100644 --- a/src/platform/qt/GamepadButtonEvent.h +++ b/src/platform/qt/GamepadButtonEvent.h @@ -8,9 +8,7 @@ #include -extern "C" { #include "gba/input.h" -} namespace QGBA { diff --git a/src/platform/qt/IOViewer.cpp b/src/platform/qt/IOViewer.cpp index a69c6e731..b7b9bdd50 100644 --- a/src/platform/qt/IOViewer.cpp +++ b/src/platform/qt/IOViewer.cpp @@ -12,9 +12,7 @@ #include #include -extern "C" { #include "gba/io.h" -} using namespace QGBA; diff --git a/src/platform/qt/InputController.cpp b/src/platform/qt/InputController.cpp index 82a3ad1e4..c8a86f1cb 100644 --- a/src/platform/qt/InputController.cpp +++ b/src/platform/qt/InputController.cpp @@ -14,10 +14,8 @@ #include #include -extern "C" { #include "core/interface.h" #include "util/configuration.h" -} using namespace QGBA; diff --git a/src/platform/qt/InputController.h b/src/platform/qt/InputController.h index 307007867..ce33b8b28 100644 --- a/src/platform/qt/InputController.h +++ b/src/platform/qt/InputController.h @@ -14,13 +14,11 @@ class QTimer; -extern "C" { #include "gba/input.h" #ifdef BUILD_SDL #include "platform/sdl/sdl-events.h" #endif -} struct mRotationSource; struct mRumble; diff --git a/src/platform/qt/InputProfile.h b/src/platform/qt/InputProfile.h index 7180a70d1..d0d80e155 100644 --- a/src/platform/qt/InputProfile.h +++ b/src/platform/qt/InputProfile.h @@ -8,9 +8,7 @@ #include "GamepadAxisEvent.h" -extern "C" { #include "gba/interface.h" -} namespace QGBA { diff --git a/src/platform/qt/LibraryModel.cpp b/src/platform/qt/LibraryModel.cpp index 5341268e9..da085cf0a 100644 --- a/src/platform/qt/LibraryModel.cpp +++ b/src/platform/qt/LibraryModel.cpp @@ -5,9 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "LibraryModel.h" -extern "C" { #include "util/vfs.h" -} using namespace QGBA; diff --git a/src/platform/qt/LibraryModel.h b/src/platform/qt/LibraryModel.h index 3cf80f355..d11cdaaf7 100644 --- a/src/platform/qt/LibraryModel.h +++ b/src/platform/qt/LibraryModel.h @@ -8,9 +8,7 @@ #include -extern "C" { #include "core/library.h" -} struct VDir; diff --git a/src/platform/qt/LoadSaveState.cpp b/src/platform/qt/LoadSaveState.cpp index 4c6786a12..64210ce75 100644 --- a/src/platform/qt/LoadSaveState.cpp +++ b/src/platform/qt/LoadSaveState.cpp @@ -14,13 +14,11 @@ #include #include -extern "C" { #include "core/serialize.h" #ifdef M_CORE_GBA #include "gba/serialize.h" #endif #include "util/memory.h" -} using namespace QGBA; diff --git a/src/platform/qt/LogController.h b/src/platform/qt/LogController.h index bf02a9b85..b630f33e6 100644 --- a/src/platform/qt/LogController.h +++ b/src/platform/qt/LogController.h @@ -11,9 +11,7 @@ #include #include -extern "C" { #include "gba/gba.h" -} namespace QGBA { diff --git a/src/platform/qt/MemoryModel.cpp b/src/platform/qt/MemoryModel.cpp index a97e54f3c..888e020d0 100644 --- a/src/platform/qt/MemoryModel.cpp +++ b/src/platform/qt/MemoryModel.cpp @@ -19,9 +19,7 @@ #include #include -extern "C" { #include "core/core.h" -} using namespace QGBA; diff --git a/src/platform/qt/MemoryModel.h b/src/platform/qt/MemoryModel.h index 2defb510e..1e0fbd645 100644 --- a/src/platform/qt/MemoryModel.h +++ b/src/platform/qt/MemoryModel.h @@ -13,9 +13,7 @@ #include #include -extern "C" { #include "util/text-codec.h" -} struct mCore; diff --git a/src/platform/qt/MemoryView.cpp b/src/platform/qt/MemoryView.cpp index 07ad16254..9fdfb0704 100644 --- a/src/platform/qt/MemoryView.cpp +++ b/src/platform/qt/MemoryView.cpp @@ -8,7 +8,6 @@ #include "GameController.h" -extern "C" { #include "core/core.h" #ifdef M_CORE_GBA #include "gba/memory.h" @@ -16,7 +15,6 @@ extern "C" { #ifdef M_CORE_GB #include "gb/memory.h" #endif -} using namespace QGBA; diff --git a/src/platform/qt/MessagePainter.cpp b/src/platform/qt/MessagePainter.cpp index 7aa19a98e..6cb9b7835 100644 --- a/src/platform/qt/MessagePainter.cpp +++ b/src/platform/qt/MessagePainter.cpp @@ -9,9 +9,7 @@ #include -extern "C" { #include "gba/video.h" -} using namespace QGBA; diff --git a/src/platform/qt/MultiplayerController.cpp b/src/platform/qt/MultiplayerController.cpp index 49afdf125..850dd350e 100644 --- a/src/platform/qt/MultiplayerController.cpp +++ b/src/platform/qt/MultiplayerController.cpp @@ -7,14 +7,12 @@ #include "GameController.h" -extern "C" { #ifdef M_CORE_GBA #include "gba/gba.h" #endif #ifdef M_CORE_GB #include "gb/gb.h" #endif -} using namespace QGBA; diff --git a/src/platform/qt/MultiplayerController.h b/src/platform/qt/MultiplayerController.h index 78be7dc35..ca88757fe 100644 --- a/src/platform/qt/MultiplayerController.h +++ b/src/platform/qt/MultiplayerController.h @@ -10,7 +10,6 @@ #include #include -extern "C" { #include "core/lockstep.h" #ifdef M_CORE_GBA #include "gba/sio/lockstep.h" @@ -18,7 +17,6 @@ extern "C" { #ifdef M_CORE_GB #include "gb/sio/lockstep.h" #endif -} namespace QGBA { diff --git a/src/platform/qt/ObjView.cpp b/src/platform/qt/ObjView.cpp index 569b24890..da6910c43 100644 --- a/src/platform/qt/ObjView.cpp +++ b/src/platform/qt/ObjView.cpp @@ -10,13 +10,11 @@ #include #include -extern "C" { #include "gba/gba.h" #ifdef M_CORE_GB #include "gb/gb.h" #include "gb/io.h" #endif -} using namespace QGBA; diff --git a/src/platform/qt/ObjView.h b/src/platform/qt/ObjView.h index 61cf43282..afa5f1c2a 100644 --- a/src/platform/qt/ObjView.h +++ b/src/platform/qt/ObjView.h @@ -11,9 +11,7 @@ #include "ui_ObjView.h" -extern "C" { #include "core/tile-cache.h" -} namespace QGBA { diff --git a/src/platform/qt/OverrideView.cpp b/src/platform/qt/OverrideView.cpp index 249baac52..d5875ebd0 100644 --- a/src/platform/qt/OverrideView.cpp +++ b/src/platform/qt/OverrideView.cpp @@ -12,16 +12,12 @@ #ifdef M_CORE_GBA #include "GBAOverride.h" -extern "C" { #include "gba/gba.h" -} #endif #ifdef M_CORE_GB #include "GBOverride.h" -extern "C" { #include "gb/gb.h" -} #endif using namespace QGBA; diff --git a/src/platform/qt/OverrideView.h b/src/platform/qt/OverrideView.h index dc31f2223..aad6709ab 100644 --- a/src/platform/qt/OverrideView.h +++ b/src/platform/qt/OverrideView.h @@ -9,9 +9,7 @@ #include #ifdef M_CORE_GB -extern "C" { #include "gb/overrides.h" -} #endif #include "ui_OverrideView.h" diff --git a/src/platform/qt/PaletteView.cpp b/src/platform/qt/PaletteView.cpp index dd917b555..8f756bec1 100644 --- a/src/platform/qt/PaletteView.cpp +++ b/src/platform/qt/PaletteView.cpp @@ -12,7 +12,6 @@ #include #include -extern "C" { #include "core/core.h" #include "util/export.h" #ifdef M_CORE_GA @@ -22,7 +21,6 @@ extern "C" { #include "gb/gb.h" #endif #include "util/vfs.h" -} using namespace QGBA; diff --git a/src/platform/qt/ROMInfo.cpp b/src/platform/qt/ROMInfo.cpp index 4271dc07d..bdea67c43 100644 --- a/src/platform/qt/ROMInfo.cpp +++ b/src/platform/qt/ROMInfo.cpp @@ -8,7 +8,6 @@ #include "GBAApp.h" #include "GameController.h" -extern "C" { #include "core/core.h" #ifdef M_CORE_GB #include "gb/gb.h" @@ -17,7 +16,6 @@ extern "C" { #include "gba/gba.h" #endif #include "util/nointro.h" -} using namespace QGBA; diff --git a/src/platform/qt/SensorView.cpp b/src/platform/qt/SensorView.cpp index a5997ac3b..6305d801c 100644 --- a/src/platform/qt/SensorView.cpp +++ b/src/platform/qt/SensorView.cpp @@ -9,10 +9,8 @@ #include "GamepadAxisEvent.h" #include "InputController.h" -extern "C" { #include "core/core.h" #include "gba/gba.h" -} using namespace QGBA; diff --git a/src/platform/qt/SettingsView.cpp b/src/platform/qt/SettingsView.cpp index 8302ddb34..ef11f79ba 100644 --- a/src/platform/qt/SettingsView.cpp +++ b/src/platform/qt/SettingsView.cpp @@ -13,10 +13,8 @@ #include "InputController.h" #include "ShortcutView.h" -extern "C" { #include "core/serialize.h" #include "gba/gba.h" -} using namespace QGBA; diff --git a/src/platform/qt/ShaderSelector.cpp b/src/platform/qt/ShaderSelector.cpp index 3f60aeb61..b5f8feccd 100644 --- a/src/platform/qt/ShaderSelector.cpp +++ b/src/platform/qt/ShaderSelector.cpp @@ -17,14 +17,12 @@ #include #include -extern "C" { #include "core/version.h" #include "platform/video-backend.h" #if !defined(_WIN32) || defined(USE_EPOXY) #include "platform/opengl/gles2.h" #endif -} using namespace QGBA; diff --git a/src/platform/qt/Swatch.cpp b/src/platform/qt/Swatch.cpp index f672a404d..5ff1fc2b6 100644 --- a/src/platform/qt/Swatch.cpp +++ b/src/platform/qt/Swatch.cpp @@ -8,9 +8,7 @@ #include #include -extern "C" { #include "core/interface.h" -} using namespace QGBA; diff --git a/src/platform/qt/TileView.cpp b/src/platform/qt/TileView.cpp index 5ac2edc84..c8b383741 100644 --- a/src/platform/qt/TileView.cpp +++ b/src/platform/qt/TileView.cpp @@ -10,11 +10,9 @@ #include #include -extern "C" { #ifdef M_CORE_GB #include "gb/gb.h" #endif -} using namespace QGBA; diff --git a/src/platform/qt/TileView.h b/src/platform/qt/TileView.h index 37b5ca78d..aef5b526f 100644 --- a/src/platform/qt/TileView.h +++ b/src/platform/qt/TileView.h @@ -11,9 +11,7 @@ #include "ui_TileView.h" -extern "C" { #include "core/tile-cache.h" -} namespace QGBA { diff --git a/src/platform/qt/VFileDevice.h b/src/platform/qt/VFileDevice.h index a99b39dba..2cdd85d14 100644 --- a/src/platform/qt/VFileDevice.h +++ b/src/platform/qt/VFileDevice.h @@ -8,9 +8,7 @@ #include -extern "C" { #include "util/vfs.h" -} namespace QGBA { diff --git a/src/platform/qt/VideoView.cpp b/src/platform/qt/VideoView.cpp index bb3805a4e..0e8433af0 100644 --- a/src/platform/qt/VideoView.cpp +++ b/src/platform/qt/VideoView.cpp @@ -13,9 +13,7 @@ #include #ifdef M_CORE_GB -extern "C" { #include "gb/video.h" -} #endif using namespace QGBA; diff --git a/src/platform/qt/VideoView.h b/src/platform/qt/VideoView.h index 360de48df..aeb4c0b02 100644 --- a/src/platform/qt/VideoView.h +++ b/src/platform/qt/VideoView.h @@ -12,9 +12,7 @@ #include "ui_VideoView.h" -extern "C" { #include "feature/ffmpeg/ffmpeg-encoder.h" -} namespace QGBA { diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 42f367b51..ca3ca0fae 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -42,7 +42,6 @@ #include "TileView.h" #include "VideoView.h" -extern "C" { #include "core/version.h" #ifdef M_CORE_GB #include "gb/gb.h" @@ -50,7 +49,6 @@ extern "C" { #include "feature/commandline.h" #include "util/nointro.h" #include "util/vfs.h" -} using namespace QGBA; diff --git a/src/platform/qt/Window.h b/src/platform/qt/Window.h index 14212bb5c..557b99a80 100644 --- a/src/platform/qt/Window.h +++ b/src/platform/qt/Window.h @@ -13,10 +13,8 @@ #include -extern "C" { #include "core/thread.h" #include "gba/gba.h" -} #include "InputController.h" #include "LoadSaveState.h" diff --git a/src/platform/sdl/gl-common.h b/src/platform/sdl/gl-common.h index 62f3a407c..4a22c1b34 100644 --- a/src/platform/sdl/gl-common.h +++ b/src/platform/sdl/gl-common.h @@ -5,9 +5,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef SDL_GL_COMMON_H #define SDL_GL_COMMON_H + +#include "util/common.h" + +CXX_GUARD_START + #include "main.h" void mSDLGLCommonSwap(struct VideoBackend* context); void mSDLGLCommonInit(struct mSDLRenderer* renderer); +CXX_GUARD_END + #endif diff --git a/src/platform/sdl/main.h b/src/platform/sdl/main.h index ccfb052a5..d8f34909b 100644 --- a/src/platform/sdl/main.h +++ b/src/platform/sdl/main.h @@ -6,6 +6,10 @@ #ifndef SDL_MAIN_H #define SDL_MAIN_H +#include "util/common.h" + +CXX_GUARD_START + #ifdef M_CORE_GBA #include "gba/renderers/video-software.h" #endif @@ -106,4 +110,7 @@ void mSDLGLCreate(struct mSDLRenderer* renderer); #if defined(BUILD_GLES2) || defined(USE_EPOXY) void mSDLGLES2Create(struct mSDLRenderer* renderer); #endif + +CXX_GUARD_END + #endif diff --git a/src/platform/sdl/sdl-audio.h b/src/platform/sdl/sdl-audio.h index e51832d5d..f7001cb61 100644 --- a/src/platform/sdl/sdl-audio.h +++ b/src/platform/sdl/sdl-audio.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/log.h" #include @@ -36,4 +38,6 @@ void mSDLDeinitAudio(struct mSDLAudio* context); void mSDLPauseAudio(struct mSDLAudio* context); void mSDLResumeAudio(struct mSDLAudio* context); +CXX_GUARD_END + #endif diff --git a/src/platform/sdl/sdl-events.h b/src/platform/sdl/sdl-events.h index 435072d2a..eea7bb7ba 100644 --- a/src/platform/sdl/sdl-events.h +++ b/src/platform/sdl/sdl-events.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/interface.h" #include "core/log.h" #include "util/circle-buffer.h" @@ -110,4 +112,6 @@ void mSDLResumeScreensaver(struct mSDLEvents*); void mSDLSetScreensaverSuspendable(struct mSDLEvents*, bool suspendable); #endif +CXX_GUARD_END + #endif diff --git a/src/platform/video-backend.h b/src/platform/video-backend.h index b67b676be..31d7a5301 100644 --- a/src/platform/video-backend.h +++ b/src/platform/video-backend.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #ifdef _WIN32 #include typedef HWND WHandle; @@ -44,4 +46,6 @@ struct VideoShader { size_t nPasses; }; +CXX_GUARD_END + #endif diff --git a/src/util/circle-buffer.h b/src/util/circle-buffer.h index 77650ca84..e0cdc7bf2 100644 --- a/src/util/circle-buffer.h +++ b/src/util/circle-buffer.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + struct CircleBuffer { void* data; size_t capacity; @@ -30,4 +32,6 @@ int CircleBufferRead32(struct CircleBuffer* buffer, int32_t* value); size_t CircleBufferRead(struct CircleBuffer* buffer, void* output, size_t length); size_t CircleBufferDump(const struct CircleBuffer* buffer, void* output, size_t length); +CXX_GUARD_END + #endif diff --git a/src/util/common.h b/src/util/common.h index 050db0513..28d62e061 100644 --- a/src/util/common.h +++ b/src/util/common.h @@ -6,6 +6,16 @@ #ifndef COMMON_H #define COMMON_H +#ifdef __cplusplus +#define CXX_GUARD_START extern "C" { +#define CXX_GUARD_END } +#else +#define CXX_GUARD_START +#define CXX_GUARD_END +#endif + +CXX_GUARD_START + #include #include #include @@ -177,4 +187,6 @@ typedef intptr_t ssize_t; #define ROR(I, ROTATE) ((((uint32_t) (I)) >> ROTATE) | ((uint32_t) (I) << ((-ROTATE) & 31))) +CXX_GUARD_END + #endif diff --git a/src/util/configuration.h b/src/util/configuration.h index 5d16324dd..54134dab9 100644 --- a/src/util/configuration.h +++ b/src/util/configuration.h @@ -6,6 +6,10 @@ #ifndef CONFIGURATION_H #define CONFIGURATION_H +#include "util/common.h" + +CXX_GUARD_START + #include "util/table.h" struct VFile; @@ -35,4 +39,6 @@ bool ConfigurationWriteSection(const struct Configuration*, const char* path, co void ConfigurationEnumerateSections(const struct Configuration* configuration, void (*handler)(const char* sectionName, void* user), void* user); +CXX_GUARD_END + #endif diff --git a/src/util/crc32.h b/src/util/crc32.h index 5e34b3feb..cb88f4337 100644 --- a/src/util/crc32.h +++ b/src/util/crc32.h @@ -8,10 +8,14 @@ #include "util/common.h" +CXX_GUARD_START + struct VFile; uint32_t doCrc32(const void* buf, size_t size); uint32_t updateCrc32(uint32_t crc, const void* buf, size_t size); uint32_t fileCrc32(struct VFile* file, size_t endOffset); +CXX_GUARD_END + #endif diff --git a/src/util/export.h b/src/util/export.h index 3e933620c..bbdb37ea2 100644 --- a/src/util/export.h +++ b/src/util/export.h @@ -8,9 +8,13 @@ #include "util/common.h" +CXX_GUARD_START + struct VFile; bool exportPaletteRIFF(struct VFile* vf, size_t entries, const uint16_t* colors); bool exportPaletteACT(struct VFile* vf, size_t entries, const uint16_t* colors); +CXX_GUARD_END + #endif diff --git a/src/util/formatting.h b/src/util/formatting.h index b09c12944..ff1745aa6 100644 --- a/src/util/formatting.h +++ b/src/util/formatting.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "locale.h" #if defined(__APPLE__) || defined(__FreeBSD__) @@ -29,4 +31,6 @@ float strtof_u(const char* restrict str, char** restrict end); struct tm* localtime_r(const time_t* timep, struct tm* result); #endif +CXX_GUARD_END + #endif diff --git a/src/util/gui.h b/src/util/gui.h index fe7d851a0..526feab95 100644 --- a/src/util/gui.h +++ b/src/util/gui.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "core/input.h" #include "util/vector.h" @@ -81,4 +83,6 @@ void GUIPollInput(struct GUIParams* params, uint32_t* newInput, uint32_t* heldIn enum GUICursorState GUIPollCursor(struct GUIParams* params, unsigned* x, unsigned* y); void GUIInvalidateKeys(struct GUIParams* params); +CXX_GUARD_END + #endif diff --git a/src/util/gui/file-select.h b/src/util/gui/file-select.h index e804d66a7..c7df6668e 100644 --- a/src/util/gui/file-select.h +++ b/src/util/gui/file-select.h @@ -6,10 +6,16 @@ #ifndef GUI_FILE_CHOOSER_H #define GUI_FILE_CHOOSER_H +#include "util/common.h" + +CXX_GUARD_START + #include "util/gui.h" struct VFile; bool GUISelectFile(struct GUIParams*, char* outPath, size_t outLen, bool (*filter)(struct VFile*)); +CXX_GUARD_END + #endif diff --git a/src/util/gui/font.h b/src/util/gui/font.h index 7c936ffb9..464440025 100644 --- a/src/util/gui/font.h +++ b/src/util/gui/font.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + struct GUIFont; struct GUIFont* GUIFontCreate(void); void GUIFontDestroy(struct GUIFont*); @@ -84,4 +86,6 @@ void GUIFontDrawGlyph(const struct GUIFont*, int x, int y, uint32_t color, uint3 void GUIFontDrawIcon(const struct GUIFont*, int x, int y, enum GUIAlignment, enum GUIOrientation, uint32_t color, enum GUIIcon); void GUIFontDrawIconSize(const struct GUIFont* font, int x, int y, int w, int h, uint32_t color, enum GUIIcon icon); +CXX_GUARD_END + #endif diff --git a/src/util/gui/menu.h b/src/util/gui/menu.h index eb34d99cd..b99bfac2d 100644 --- a/src/util/gui/menu.h +++ b/src/util/gui/menu.h @@ -6,6 +6,10 @@ #ifndef GUI_MENU_H #define GUI_MENU_H +#include "util/common.h" + +CXX_GUARD_START + #include "util/vector.h" struct GUIMenu; @@ -49,4 +53,6 @@ enum GUIMenuExitReason GUIShowMessageBox(struct GUIParams* params, int buttons, void GUIDrawBattery(struct GUIParams* params); void GUIDrawClock(struct GUIParams* params); +CXX_GUARD_END + #endif diff --git a/src/util/hash.h b/src/util/hash.h index 7a8e82099..31fd1f2b1 100644 --- a/src/util/hash.h +++ b/src/util/hash.h @@ -8,6 +8,10 @@ #include "util/common.h" +CXX_GUARD_START + uint32_t hash32(const void* key, int len, uint32_t seed); +CXX_GUARD_END + #endif diff --git a/src/util/math.h b/src/util/math.h index 31709e20a..6a69345f8 100644 --- a/src/util/math.h +++ b/src/util/math.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + static inline uint32_t popcount32(unsigned bits) { bits = bits - ((bits >> 1) & 0x55555555); bits = (bits & 0x33333333) + ((bits >> 2) & 0x33333333); @@ -56,4 +58,6 @@ static inline uint32_t toPow2(uint32_t bits) { return 1 << (32 - lz); } +CXX_GUARD_END + #endif diff --git a/src/util/memory.h b/src/util/memory.h index e78d87c7a..444f5c6bb 100644 --- a/src/util/memory.h +++ b/src/util/memory.h @@ -8,7 +8,11 @@ #include "util/common.h" +CXX_GUARD_START + void* anonymousMemoryMap(size_t size); void mappedMemoryFree(void* memory, size_t size); +CXX_GUARD_END + #endif diff --git a/src/util/nointro.h b/src/util/nointro.h index 50f4a23d2..46eb4088f 100644 --- a/src/util/nointro.h +++ b/src/util/nointro.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + struct NoIntroGame { const char* name; const char* romName; @@ -26,4 +28,6 @@ struct NoIntroDB* NoIntroDBLoad(struct VFile* vf); void NoIntroDBDestroy(struct NoIntroDB* db); bool NoIntroDBLookupGameByCRC(const struct NoIntroDB* db, uint32_t crc32, struct NoIntroGame* game); +CXX_GUARD_END + #endif diff --git a/src/util/patch-fast.h b/src/util/patch-fast.h index 34988160c..95a2503a4 100644 --- a/src/util/patch-fast.h +++ b/src/util/patch-fast.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #include "util/patch.h" #include "util/vector.h" @@ -31,4 +33,6 @@ void initPatchFast(struct PatchFast*); void deinitPatchFast(struct PatchFast*); bool diffPatchFast(struct PatchFast* patch, const void* restrict in, const void* restrict out, size_t size); +CXX_GUARD_END + #endif diff --git a/src/util/patch-ips.h b/src/util/patch-ips.h index 39c8f6e65..d730e68ba 100644 --- a/src/util/patch-ips.h +++ b/src/util/patch-ips.h @@ -8,8 +8,12 @@ #include "util/common.h" +CXX_GUARD_START + struct Patch; bool loadPatchIPS(struct Patch* patch); +CXX_GUARD_END + #endif diff --git a/src/util/patch-ups.h b/src/util/patch-ups.h index 23293409b..bc29c1afa 100644 --- a/src/util/patch-ups.h +++ b/src/util/patch-ups.h @@ -8,8 +8,12 @@ #include "util/common.h" +CXX_GUARD_START + struct Patch; bool loadPatchUPS(struct Patch* patch); +CXX_GUARD_END + #endif diff --git a/src/util/patch.h b/src/util/patch.h index f84d859df..e0af658ee 100644 --- a/src/util/patch.h +++ b/src/util/patch.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + struct VFile; struct Patch { @@ -19,4 +21,6 @@ struct Patch { bool loadPatch(struct VFile* vf, struct Patch* patch); +CXX_GUARD_END + #endif diff --git a/src/util/png-io.h b/src/util/png-io.h index d0fff9c70..25680e9c9 100644 --- a/src/util/png-io.h +++ b/src/util/png-io.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #ifdef USE_PNG #include @@ -37,4 +39,6 @@ void PNGReadClose(png_structp png, png_infop info, png_infop end); #endif +CXX_GUARD_END + #endif diff --git a/src/util/ring-fifo.h b/src/util/ring-fifo.h index 6ceb02ff7..a98d5f1f7 100644 --- a/src/util/ring-fifo.h +++ b/src/util/ring-fifo.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + struct RingFIFO { void* data; size_t capacity; @@ -22,4 +24,6 @@ void RingFIFOClear(struct RingFIFO* buffer); size_t RingFIFOWrite(struct RingFIFO* buffer, const void* value, size_t length); size_t RingFIFORead(struct RingFIFO* buffer, void* output, size_t length); +CXX_GUARD_END + #endif diff --git a/src/util/socket.h b/src/util/socket.h index 6ffe13608..12e509f83 100644 --- a/src/util/socket.h +++ b/src/util/socket.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #if defined(__cplusplus) && !defined(restrict) #define restrict __restrict__ #endif @@ -316,4 +318,6 @@ static inline int SocketPoll(size_t nSockets, Socket* reads, Socket* writes, Soc return result; } +CXX_GUARD_END + #endif diff --git a/src/util/string.h b/src/util/string.h index 4bf161f8a..04b0fce63 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #ifndef HAVE_STRNDUP // This is sometimes a macro char* strndup(const char* start, size_t len); @@ -36,4 +38,6 @@ const char* hex4(const char* line, uint8_t* out); void rtrim(char* string); +CXX_GUARD_END + #endif diff --git a/src/util/table.h b/src/util/table.h index 5dee643fd..1305b995e 100644 --- a/src/util/table.h +++ b/src/util/table.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + struct TableList; struct Table { @@ -46,4 +48,6 @@ void HashTableClear(struct Table*); void HashTableEnumerate(const struct Table*, void (handler(const char* key, void* value, void* user)), void* user); size_t HashTableSize(const struct Table*); +CXX_GUARD_END + #endif diff --git a/src/util/text-codec.h b/src/util/text-codec.h index e17436c7b..4ea3f8596 100644 --- a/src/util/text-codec.h +++ b/src/util/text-codec.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + struct TextCodecNode; struct TextCodec { struct TextCodecNode* forwardRoot; @@ -29,4 +31,6 @@ void TextCodecStartEncode(struct TextCodec*, struct TextCodecIterator*); ssize_t TextCodecAdvance(struct TextCodecIterator*, uint8_t byte, uint8_t* output, size_t outputLength); ssize_t TextCodecFinish(struct TextCodecIterator*, uint8_t* output, size_t outputLength); +CXX_GUARD_END + #endif diff --git a/src/util/threading.h b/src/util/threading.h index 32d805c67..21ed062b2 100644 --- a/src/util/threading.h +++ b/src/util/threading.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #ifndef DISABLE_THREADING #ifdef USE_PTHREADS #include "platform/posix/threading.h" @@ -85,4 +87,6 @@ static inline int ConditionWake(Condition* cond) { } #endif +CXX_GUARD_END + #endif diff --git a/src/util/vector.h b/src/util/vector.h index dee7ed77a..8e35caa79 100644 --- a/src/util/vector.h +++ b/src/util/vector.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #define DECLARE_VECTOR(NAME, TYPE) \ struct NAME { \ TYPE* vector; \ @@ -84,4 +86,6 @@ return member - (const TYPE*) vector->vector; \ } \ +CXX_GUARD_END + #endif diff --git a/src/util/vfs.h b/src/util/vfs.h index 19c71da92..d1ac0e69f 100644 --- a/src/util/vfs.h +++ b/src/util/vfs.h @@ -8,6 +8,8 @@ #include "util/common.h" +CXX_GUARD_START + #ifdef _WIN32 #include #include @@ -97,4 +99,6 @@ ssize_t VFileWrite16LE(struct VFile* vf, int16_t hword); ssize_t VFileRead32LE(struct VFile* vf, void* word); ssize_t VFileRead16LE(struct VFile* vf, void* hword); +CXX_GUARD_END + #endif From f7ac90d74eba6bc556b609bb788e5a9d84926968 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 26 Dec 2016 21:02:57 -0800 Subject: [PATCH 42/56] Util: Add ifndef guard for UNUSED define --- src/util/common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/common.h b/src/util/common.h index 28d62e061..bfe4f3a92 100644 --- a/src/util/common.h +++ b/src/util/common.h @@ -56,7 +56,9 @@ typedef intptr_t ssize_t; #define SSIZE_MAX ((ssize_t) (SIZE_MAX >> 1)) #endif +#ifndef UNUSED #define UNUSED(V) (void)(V) +#endif #ifndef M_PI #define M_PI 3.141592654f From 03ca7515b3e79a1d2c34ca93e7d5d1c487820a7a Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 26 Dec 2016 22:26:31 -0800 Subject: [PATCH 43/56] GBA SIO: Add some basic JOY bus constants --- src/gba/sio.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gba/sio.h b/src/gba/sio.h index f626979dd..cdb0d50b7 100644 --- a/src/gba/sio.h +++ b/src/gba/sio.h @@ -23,6 +23,16 @@ enum { RCNT_INITIAL = 0x8000 }; +enum { + JOY_CMD_RESET = 0xFF, + JOY_CMD_POLL = 0x00, + JOY_CMD_TRANS = 0x14, + JOY_CMD_RECV = 0x15, + + JOYSTAT_TRANS_BIT = 8, + JOYSTAT_RECV_BIT = 2, +}; + struct GBASIODriverSet { struct GBASIODriver* normal; struct GBASIODriver* multiplayer; From 463ce997397850e6ea5ca27fb5c806e2edca4e89 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 26 Dec 2016 23:27:32 -0800 Subject: [PATCH 44/56] All: Include cleanup --- src/gba/cheats.c | 1 + src/gba/gba.h | 3 +++ src/gba/video.h | 1 - src/platform/qt/AudioDevice.cpp | 1 + src/platform/qt/AudioProcessorQt.cpp | 1 + src/platform/sdl/sdl-audio.c | 1 + 6 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gba/cheats.c b/src/gba/cheats.c index 81497ec62..8b5f5804b 100644 --- a/src/gba/cheats.c +++ b/src/gba/cheats.c @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "cheats.h" +#include "core/core.h" #include "gba/cheats/gameshark.h" #include "gba/cheats/parv3.h" #include "gba/gba.h" diff --git a/src/gba/gba.h b/src/gba/gba.h index 7adc8bd2b..bcbdc544e 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h @@ -152,8 +152,11 @@ void GBAHalt(struct GBA* gba); void GBAStop(struct GBA* gba); void GBADebug(struct GBA* gba, uint16_t value); +#ifdef USE_DEBUGGERS +struct mDebugger; void GBAAttachDebugger(struct GBA* gba, struct mDebugger* debugger); void GBADetachDebugger(struct GBA* gba); +#endif void GBASetBreakpoint(struct GBA* gba, struct mCPUComponent* component, uint32_t address, enum ExecutionMode mode, uint32_t* opcode); diff --git a/src/gba/video.h b/src/gba/video.h index 01ef2b55e..c25df5ef8 100644 --- a/src/gba/video.h +++ b/src/gba/video.h @@ -10,7 +10,6 @@ CXX_GUARD_START -#include "core/core.h" #include "core/timing.h" #include "gba/memory.h" diff --git a/src/platform/qt/AudioDevice.cpp b/src/platform/qt/AudioDevice.cpp index ae34d3221..44d1139af 100644 --- a/src/platform/qt/AudioDevice.cpp +++ b/src/platform/qt/AudioDevice.cpp @@ -7,6 +7,7 @@ #include "LogController.h" +#include "core/core.h" #include "core/thread.h" #include "gba/audio.h" diff --git a/src/platform/qt/AudioProcessorQt.cpp b/src/platform/qt/AudioProcessorQt.cpp index 0f29105ec..ec9b1bdfb 100644 --- a/src/platform/qt/AudioProcessorQt.cpp +++ b/src/platform/qt/AudioProcessorQt.cpp @@ -10,6 +10,7 @@ #include +#include "core/core.h" #include "core/thread.h" using namespace QGBA; diff --git a/src/platform/sdl/sdl-audio.c b/src/platform/sdl/sdl-audio.c index 913fc99a1..c731cfba7 100644 --- a/src/platform/sdl/sdl-audio.c +++ b/src/platform/sdl/sdl-audio.c @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "sdl-audio.h" +#include "core/core.h" #include "core/thread.h" #include "gba/gba.h" From 75d9085eefa51c7d5a6a5436e4692e6daf0cc4e4 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 27 Dec 2016 02:11:54 -0800 Subject: [PATCH 45/56] GBA I/O: Clear JOYSTAT RECV flag when reading JOY_RECV registers --- CHANGES | 1 + src/gba/io.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index ef9a32039..b9174874f 100644 --- a/CHANGES +++ b/CHANGES @@ -70,6 +70,7 @@ Misc: - GBA DMA: Refactor DMA out of memory.c - GBA DMA: Move DMAs to using absolute timing - All: Add C++ header guards + - GBA I/O: Clear JOYSTAT RECV flag when reading JOY_RECV registers 0.5.1: (2016-10-05) Bugfixes: diff --git a/src/gba/io.c b/src/gba/io.c index 0168b31ab..0ec739915 100644 --- a/src/gba/io.c +++ b/src/gba/io.c @@ -806,6 +806,11 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) { mLOG(GBA_IO, GAME_ERROR, "Read from write-only I/O register: %03X", address); return 0; + case REG_JOY_RECV_LO: + case REG_JOY_RECV_HI: + gba->memory.io[REG_JOYSTAT >> 1] &= ~JOYSTAT_RECV_BIT; + break; + case REG_SOUNDBIAS: case REG_KEYCNT: case REG_POSTFLG: @@ -862,8 +867,6 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) { case REG_SIOMULTI3: case REG_SIOMLT_SEND: case REG_JOYCNT: - case REG_JOY_RECV_LO: - case REG_JOY_RECV_HI: case REG_JOY_TRANS_LO: case REG_JOY_TRANS_HI: case REG_JOYSTAT: From 9cbbd9f255fda8a27a025a1f244d4e22028f199f Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 27 Dec 2016 03:48:41 -0800 Subject: [PATCH 46/56] GBA I/O: Set JOYSTAT TRANS flag when writing JOY_TRANS registers --- CHANGES | 1 + src/gba/io.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index b9174874f..43cdc4881 100644 --- a/CHANGES +++ b/CHANGES @@ -71,6 +71,7 @@ Misc: - GBA DMA: Move DMAs to using absolute timing - All: Add C++ header guards - GBA I/O: Clear JOYSTAT RECV flag when reading JOY_RECV registers + - GBA I/O: Set JOYSTAT TRANS flag when writing JOY_TRANS registers 0.5.1: (2016-10-05) Bugfixes: diff --git a/src/gba/io.c b/src/gba/io.c index 0ec739915..c705a3cc3 100644 --- a/src/gba/io.c +++ b/src/gba/io.c @@ -524,13 +524,15 @@ void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) { value &= 0xC1FF; GBASIOWriteRCNT(&gba->sio, value); break; + case REG_JOY_TRANS_LO: + case REG_JOY_TRANS_HI: + gba->memory.io[REG_JOYSTAT >> 1] |= JOYSTAT_TRANS_BIT; + // Fall through case REG_SIOMLT_SEND: case REG_JOYCNT: case REG_JOYSTAT: case REG_JOY_RECV_LO: case REG_JOY_RECV_HI: - case REG_JOY_TRANS_LO: - case REG_JOY_TRANS_HI: value = GBASIOWriteRegister(&gba->sio, address, value); break; From 20367765b87c354a949ec4ee0a4e1da60d7e4a95 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 27 Dec 2016 04:03:44 -0800 Subject: [PATCH 47/56] GUI: Fix build --- src/feature/gui/gui-config.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/feature/gui/gui-config.c b/src/feature/gui/gui-config.c index 72c311cc1..16f13a2f9 100644 --- a/src/feature/gui/gui-config.c +++ b/src/feature/gui/gui-config.c @@ -6,6 +6,7 @@ #include "gui-config.h" #include "core/config.h" +#include "core/core.h" #include "feature/gui/gui-runner.h" #include "feature/gui/remap.h" #include "gba/gba.h" From d752df421f09a993092563df349736acdedbb7f5 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 27 Dec 2016 04:12:15 -0800 Subject: [PATCH 48/56] 3DS: Fix build --- src/platform/3ds/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/platform/3ds/main.c b/src/platform/3ds/main.c index 727ab71fa..3042a67d8 100644 --- a/src/platform/3ds/main.c +++ b/src/platform/3ds/main.c @@ -4,6 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "core/core.h" #ifdef M_CORE_GBA #include "gba/gba.h" #include "gba/input.h" From 2d02719fa57d4e4a33168955a8e0c34dfabc301a Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 28 Dec 2016 19:05:57 -0800 Subject: [PATCH 49/56] Revert "GBA Video: Fix out-of-order OBJWIN" This reverts commit f34f45257a6c52ea2e96e8ba75e8f7bfe8d5e245. --- src/gba/renderers/video-software.c | 32 +++++------------------------- src/gba/renderers/video-software.h | 2 -- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index e4c7e90d7..8b1fdd5d0 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -459,7 +459,6 @@ static void _breakWindowInner(struct GBAVideoSoftwareRenderer* softwareRenderer, static void _cleanOAM(struct GBAVideoSoftwareRenderer* renderer) { int i; int oamMax = 0; - int objwinMax = 0; for (i = 0; i < 128; ++i) { struct GBAObj obj; LOAD_16(obj.a, 0, &renderer->d.oam->obj[i].a); @@ -471,22 +470,14 @@ static void _cleanOAM(struct GBAVideoSoftwareRenderer* renderer) { height <<= GBAObjAttributesAGetDoubleSize(obj.a); } if (GBAObjAttributesAGetY(obj.a) < VIDEO_VERTICAL_PIXELS || GBAObjAttributesAGetY(obj.a) + height >= VIDEO_VERTICAL_TOTAL_PIXELS) { - if (GBAObjAttributesAGetMode(obj.a) == OBJ_MODE_OBJWIN) { - renderer->objwinSprites[objwinMax].y = GBAObjAttributesAGetY(obj.a); - renderer->objwinSprites[objwinMax].endY = GBAObjAttributesAGetY(obj.a) + height; - renderer->objwinSprites[objwinMax].obj = obj; - ++objwinMax; - } else { - renderer->sprites[oamMax].y = GBAObjAttributesAGetY(obj.a); - renderer->sprites[oamMax].endY = GBAObjAttributesAGetY(obj.a) + height; - renderer->sprites[oamMax].obj = obj; - ++oamMax; - } + renderer->sprites[oamMax].y = GBAObjAttributesAGetY(obj.a); + renderer->sprites[oamMax].endY = GBAObjAttributesAGetY(obj.a) + height; + renderer->sprites[oamMax].obj = obj; + ++oamMax; } } } renderer->oamMax = oamMax; - renderer->objwinMax = objwinMax; renderer->oamDirty = 0; } @@ -742,20 +733,7 @@ static void _drawScanline(struct GBAVideoSoftwareRenderer* renderer, int y) { } int i; int drawn; - for (i = 0; i < renderer->objwinMax; ++i) { - int localY = y; - if (renderer->spriteCyclesRemaining <= 0) { - break; - } - struct GBAVideoSoftwareSprite* sprite = &renderer->objwinSprites[i]; - if (GBAObjAttributesAIsMosaic(sprite->obj.a)) { - localY = mosaicY; - } - if ((localY < sprite->y && (sprite->endY - 256 < 0 || localY >= sprite->endY - 256)) || localY >= sprite->endY) { - continue; - } - GBAVideoSoftwareRendererPreprocessSprite(renderer, &sprite->obj, localY); - } + for (i = 0; i < renderer->oamMax; ++i) { int localY = y; if (renderer->spriteCyclesRemaining <= 0) { diff --git a/src/gba/renderers/video-software.h b/src/gba/renderers/video-software.h index 96f0445df..e292eb233 100644 --- a/src/gba/renderers/video-software.h +++ b/src/gba/renderers/video-software.h @@ -154,9 +154,7 @@ struct GBAVideoSoftwareRenderer { int oamDirty; int oamMax; - int objwinMax; struct GBAVideoSoftwareSprite sprites[128]; - struct GBAVideoSoftwareSprite objwinSprites[128]; int start; int end; From 19b164d560f6382b2e8ee55cc8a6eec22951ae29 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 28 Dec 2016 19:16:33 -0800 Subject: [PATCH 50/56] Libretro: Fix disabling BIOS --- CHANGES | 1 + src/platform/libretro/libretro.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 43cdc4881..ca1415751 100644 --- a/CHANGES +++ b/CHANGES @@ -44,6 +44,7 @@ Bugfixes: - GB Memory: Fix HDMA5 value after DMA completes - GB Video: Hblank IRQs should mask LYC=LY IRQs - GB Audio: Reset envelope timer when reseting sound channel + - Libretro: Fix disabling BIOS Misc: - SDL: Remove scancode key input - GBA Video: Clean up unused timers diff --git a/src/platform/libretro/libretro.c b/src/platform/libretro/libretro.c index 40f8ba00b..b290ee28b 100644 --- a/src/platform/libretro/libretro.c +++ b/src/platform/libretro/libretro.c @@ -413,7 +413,7 @@ bool retro_load_game(const struct retro_game_info* game) { gba->luminanceSource = &lux; const char* sysDir = 0; - if (environCallback(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &sysDir)) { + if (core->opts.useBios && environCallback(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &sysDir)) { char biosPath[PATH_MAX]; snprintf(biosPath, sizeof(biosPath), "%s%s%s", sysDir, PATH_SEP, "gba_bios.bin"); struct VFile* bios = VFileOpen(biosPath, O_RDONLY); From fa884d071ecaa3e05ff20b45a67bf9500dd3d6b6 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 30 Dec 2016 17:00:22 -0800 Subject: [PATCH 51/56] All: Migrate includes to separate directory --- CMakeLists.txt | 4 +-- {src/util => include/mgba-util}/arm-algo.h | 0 .../mgba-util}/circle-buffer.h | 2 +- {src/util => include/mgba-util}/common.h | 0 .../mgba-util}/configuration.h | 4 +-- {src/util => include/mgba-util}/crc32.h | 2 +- {src/util => include/mgba-util}/export.h | 2 +- {src/util => include/mgba-util}/formatting.h | 2 +- {src/util => include/mgba-util}/gui.h | 7 ++-- .../mgba-util}/gui/file-select.h | 4 +-- .../mgba-util}/gui/font-metrics.h | 2 +- {src/util => include/mgba-util}/gui/font.h | 2 +- {src/util => include/mgba-util}/gui/menu.h | 4 +-- {src/util => include/mgba-util}/hash.h | 2 +- {src/util => include/mgba-util}/math.h | 2 +- {src/util => include/mgba-util}/memory.h | 2 +- {src/util => include/mgba-util}/nointro.h | 2 +- {src/util => include/mgba-util}/patch.h | 2 +- .../mgba-util/patch/fast.h | 6 ++-- .../mgba-util/patch/ips.h | 2 +- .../mgba-util/patch/ups.h | 2 +- .../mgba-util}/platform/3ds/3ds-vfs.h | 2 +- .../mgba-util}/platform/3ds/threading.h | 2 +- .../mgba-util}/platform/posix/threading.h | 2 +- .../mgba-util}/platform/psp2/sce-vfs.h | 0 .../mgba-util}/platform/psp2/threading.h | 0 .../mgba-util}/platform/windows/getopt.h | 0 .../mgba-util}/platform/windows/threading.h | 2 +- {src/util => include/mgba-util}/png-io.h | 2 +- {src/util => include/mgba-util}/ring-fifo.h | 2 +- {src/util => include/mgba-util}/socket.h | 2 +- {src/util => include/mgba-util}/string.h | 2 +- {src/util => include/mgba-util}/table.h | 2 +- {src/util => include/mgba-util}/text-codec.h | 2 +- {src/util => include/mgba-util}/threading.h | 10 +++--- {src/util => include/mgba-util}/vector.h | 2 +- {src/util => include/mgba-util}/vfs.h | 4 +-- .../blip_buf => include/mgba/core}/blip_buf.h | 0 {src => include/mgba}/core/cheats.h | 8 ++--- {src => include/mgba}/core/config.h | 4 +-- {src => include/mgba}/core/core.h | 13 +++---- {src => include/mgba}/core/cpu.h | 2 +- {src => include/mgba}/core/directories.h | 2 +- {src => include/mgba}/core/input.h | 2 +- {src => include/mgba}/core/interface.h | 2 +- {src => include/mgba}/core/library.h | 6 ++-- {src => include/mgba}/core/lockstep.h | 2 +- {src => include/mgba}/core/log.h | 2 +- {src => include/mgba}/core/rewind.h | 4 +-- {src => include/mgba}/core/serialize.h | 2 +- {src => include/mgba}/core/sync.h | 4 +-- {src => include/mgba}/core/thread.h | 10 +++--- {src => include/mgba}/core/tile-cache.h | 2 +- {src => include/mgba}/core/timing.h | 2 +- {src => include/mgba}/core/version.h | 0 {src => include/mgba}/gb/core.h | 2 +- {src => include/mgba}/gb/interface.h | 2 +- {src => include/mgba}/gba/core.h | 2 +- {src => include/mgba}/gba/interface.h | 4 +-- {src => include/mgba/internal}/arm/arm.h | 4 +-- .../internal}/arm/debugger/cli-debugger.h | 2 +- .../mgba/internal}/arm/debugger/debugger.h | 6 ++-- .../internal}/arm/debugger/memory-debugger.h | 2 +- .../mgba/internal}/arm/decoder-inlines.h | 0 {src => include/mgba/internal}/arm/decoder.h | 4 +-- .../mgba/internal}/arm/emitter-arm.h | 0 .../mgba/internal}/arm/emitter-inlines.h | 0 .../mgba/internal}/arm/emitter-thumb.h | 0 {src => include/mgba/internal}/arm/isa-arm.h | 2 +- .../mgba/internal}/arm/isa-inlines.h | 0 .../mgba/internal}/arm/isa-thumb.h | 2 +- {src => include/mgba/internal}/arm/macros.h | 2 +- .../mgba/internal}/debugger/cli-debugger.h | 4 +-- .../mgba/internal}/debugger/debugger.h | 8 ++--- .../mgba/internal}/debugger/gdb-stub.h | 6 ++-- .../mgba/internal}/debugger/parser.h | 4 +-- {src => include/mgba/internal}/gb/audio.h | 9 +++-- {src => include/mgba/internal}/gb/cheats.h | 6 ++-- {src => include/mgba/internal}/gb/extra/cli.h | 4 +-- {src => include/mgba/internal}/gb/gb.h | 21 ++++++------ {src => include/mgba/internal}/gb/io.h | 4 +-- {src => include/mgba/internal}/gb/mbc.h | 4 +-- {src => include/mgba/internal}/gb/memory.h | 10 +++--- {src => include/mgba/internal}/gb/overrides.h | 4 +-- .../mgba/internal}/gb/renderers/software.h | 8 ++--- .../mgba/internal}/gb/renderers/tile-cache.h | 2 +- {src => include/mgba/internal}/gb/serialize.h | 6 ++-- {src => include/mgba/internal}/gb/sio.h | 6 ++-- .../mgba/internal}/gb/sio/lockstep.h | 8 ++--- {src => include/mgba/internal}/gb/timer.h | 4 +-- {src => include/mgba/internal}/gb/video.h | 9 ++--- {src => include/mgba/internal}/gba/audio.h | 8 ++--- {src => include/mgba/internal}/gba/bios.h | 6 ++-- {src => include/mgba/internal}/gba/cheats.h | 6 ++-- {src => include/mgba/internal}/gba/dma.h | 2 +- .../mgba/internal}/gba/extra/cli.h | 4 +-- {src => include/mgba/internal}/gba/gba.h | 19 +++++------ {src => include/mgba/internal}/gba/hardware.h | 9 +++-- {src => include/mgba/internal}/gba/input.h | 4 +-- {src => include/mgba/internal}/gba/io.h | 5 +-- {src => include/mgba/internal}/gba/memory.h | 13 +++---- .../mgba/internal}/gba/overrides.h | 4 +-- .../internal}/gba/renderers/thread-proxy.h | 8 ++--- .../mgba/internal}/gba/renderers/tile-cache.h | 2 +- .../internal}/gba/renderers/video-software.h | 6 ++-- {src => include/mgba/internal}/gba/rr/mgm.h | 4 +-- {src => include/mgba/internal}/gba/rr/rr.h | 6 ++-- {src => include/mgba/internal}/gba/rr/vbm.h | 4 +-- {src => include/mgba/internal}/gba/savedata.h | 4 +-- .../mgba/internal}/gba/serialize.h | 8 ++--- .../mgba/internal}/gba/sharkport.h | 2 +- {src => include/mgba/internal}/gba/sio.h | 6 ++-- .../mgba/internal}/gba/sio/lockstep.h | 8 ++--- {src => include/mgba/internal}/gba/timer.h | 4 +-- {src => include/mgba/internal}/gba/vfame.h | 2 +- {src => include/mgba/internal}/gba/video.h | 6 ++-- .../internal}/lr35902/debugger/cli-debugger.h | 2 +- .../internal}/lr35902/debugger/debugger.h | 4 +-- .../mgba/internal}/lr35902/emitter-lr35902.h | 0 .../mgba/internal}/lr35902/isa-lr35902.h | 2 +- .../mgba/internal}/lr35902/lr35902.h | 6 ++-- src/arm/arm.c | 8 ++--- src/arm/debugger/cli-debugger.c | 12 +++---- src/arm/debugger/debugger.c | 10 +++--- src/arm/debugger/memory-debugger.c | 6 ++-- src/arm/decoder-arm.c | 8 ++--- src/arm/decoder-thumb.c | 8 ++--- src/arm/decoder.c | 4 +-- src/arm/isa-arm.c | 8 ++--- src/arm/isa-thumb.c | 6 ++-- src/core/cheats.c | 8 ++--- src/core/config.c | 12 +++---- src/core/core.c | 19 ++++++----- src/core/directories.c | 6 ++-- src/core/input.c | 6 ++-- src/core/interface.c | 4 +-- src/core/library.c | 4 +-- src/core/lockstep.c | 2 +- src/core/log.c | 4 +-- src/core/rewind.c | 8 ++--- src/core/serialize.c | 12 +++---- src/core/sync.c | 2 +- src/core/test/core.c | 4 +-- src/core/test/core.h | 2 +- src/core/thread.c | 10 +++--- src/core/tile-cache.c | 4 +-- src/core/timing.c | 2 +- src/core/version.c.in | 2 +- src/debugger/cli-debugger.c | 10 +++--- src/debugger/debugger.c | 8 ++--- src/debugger/gdb-stub.c | 10 +++--- src/debugger/parser.c | 4 +-- src/feature/commandline.c | 8 ++--- src/feature/commandline.h | 4 +-- src/feature/editline/cli-el-backend.c | 2 +- src/feature/editline/cli-el-backend.h | 4 +-- src/feature/ffmpeg/ffmpeg-encoder.c | 4 +-- src/feature/ffmpeg/ffmpeg-encoder.h | 4 +-- src/feature/gui/gui-config.c | 10 +++--- src/feature/gui/gui-config.h | 2 +- src/feature/gui/gui-runner.c | 22 ++++++------ src/feature/gui/gui-runner.h | 10 +++--- src/feature/gui/remap.c | 4 +-- src/feature/gui/remap.h | 2 +- .../imagemagick/imagemagick-gif-encoder.c | 6 ++-- .../imagemagick/imagemagick-gif-encoder.h | 4 +-- src/gb/audio.c | 13 +++---- src/gb/cheats.c | 10 +++--- src/gb/core.c | 29 ++++++++-------- src/gb/extra/cli.c | 14 ++++---- src/gb/gb.c | 21 ++++++------ src/gb/io.c | 8 ++--- src/gb/mbc.c | 9 ++--- src/gb/memory.c | 15 ++++---- src/gb/overrides.c | 8 ++--- src/gb/renderers/software.c | 8 ++--- src/gb/renderers/tile-cache.c | 8 ++--- src/gb/serialize.c | 7 ++-- src/gb/sio.c | 8 ++--- src/gb/sio/lockstep.c | 6 ++-- src/gb/test/core.c | 8 ++--- src/gb/test/gb.h | 2 +- src/gb/test/mbc.c | 10 +++--- src/gb/test/memory.c | 10 +++--- src/gb/test/rtc.c | 10 +++--- src/gb/timer.c | 8 ++--- src/gb/video.c | 17 +++++----- src/gba/audio.c | 16 +++++---- src/gba/bios.c | 12 +++---- src/gba/cheats.c | 8 ++--- src/gba/cheats/codebreaker.c | 8 ++--- src/gba/cheats/gameshark.c | 6 ++-- src/gba/cheats/gameshark.h | 5 ++- src/gba/cheats/parv3.c | 6 ++-- src/gba/cheats/parv3.h | 5 ++- src/gba/core.c | 30 ++++++++-------- src/gba/dma.c | 6 ++-- src/gba/extra/cli.c | 12 ++++--- src/gba/gba.c | 34 ++++++++----------- src/gba/hardware.c | 11 +++--- src/gba/hle-bios.c | 2 +- src/gba/hle-bios.h | 2 +- src/gba/hle-bios.make | 2 +- src/gba/input.c | 4 +-- src/gba/io.c | 12 +++---- src/gba/memory.c | 20 ++++++----- src/gba/overrides.c | 8 ++--- src/gba/renderers/software-bg.c | 4 +-- src/gba/renderers/software-mode0.c | 4 +-- src/gba/renderers/software-obj.c | 2 +- src/gba/renderers/software-private.h | 3 +- src/gba/renderers/thread-proxy.c | 10 +++--- src/gba/renderers/tile-cache.c | 7 ++-- src/gba/renderers/video-software.c | 13 ++++--- src/gba/rr/mgm.c | 8 ++--- src/gba/rr/rr.c | 7 ++-- src/gba/rr/vbm.c | 8 ++--- src/gba/savedata.c | 11 +++--- src/gba/serialize.c | 15 ++++---- src/gba/sharkport.c | 7 ++-- src/gba/sio.c | 5 +-- src/gba/sio/lockstep.c | 7 ++-- src/gba/test/core.c | 4 +-- src/gba/test/gba.h | 2 +- src/gba/timer.c | 6 ++-- src/gba/vfame.c | 6 ++-- src/gba/video.c | 19 +++++------ src/lr35902/debugger/cli-debugger.c | 8 ++--- src/lr35902/debugger/debugger.c | 6 ++-- src/lr35902/isa-lr35902.c | 6 ++-- src/lr35902/lr35902.c | 4 +-- src/platform/3ds/3ds-memory.c | 2 +- src/platform/3ds/3ds-vfs.c | 6 ++-- src/platform/3ds/ctru-heap.c | 2 +- src/platform/3ds/gui-font.c | 8 ++--- src/platform/3ds/main.c | 23 +++++++------ src/platform/3ds/socket.c | 2 +- src/platform/example/client-server/client.c | 6 ++-- src/platform/example/client-server/server.c | 4 +-- src/platform/libretro/libretro.c | 34 +++++++++---------- src/platform/openemu/mGBAGameCore.m | 27 ++++++++------- src/platform/opengl/gl.c | 2 +- src/platform/opengl/gl.h | 2 +- src/platform/opengl/gles2.c | 10 +++--- src/platform/opengl/gles2.h | 2 +- src/platform/posix/memory.c | 2 +- src/platform/psp2/gui-font.c | 6 ++-- src/platform/psp2/main.c | 10 +++--- src/platform/psp2/psp2-common.h | 2 +- src/platform/psp2/psp2-context.c | 22 ++++++------ src/platform/psp2/psp2-context.h | 4 +-- src/platform/psp2/psp2-memory.c | 4 +-- src/platform/psp2/sce-vfs.c | 6 ++-- src/platform/python/_builder.h | 22 ++++++------ src/platform/python/_builder.py | 31 +++++++++-------- src/platform/python/log.c | 4 +-- src/platform/python/log.h | 2 +- src/platform/python/vfs-py.c | 2 +- src/platform/python/vfs-py.h | 4 +-- src/platform/qt/AboutScreen.cpp | 2 +- src/platform/qt/ArchiveInspector.cpp | 2 +- src/platform/qt/AssetTile.cpp | 6 ++-- src/platform/qt/AssetTile.h | 2 +- src/platform/qt/AssetView.cpp | 4 --- src/platform/qt/AudioDevice.cpp | 7 ++-- src/platform/qt/AudioProcessorQt.cpp | 4 +-- src/platform/qt/AudioProcessorSDL.cpp | 2 +- src/platform/qt/CheatsModel.cpp | 3 +- src/platform/qt/CheatsView.cpp | 6 ++-- src/platform/qt/ConfigController.h | 4 +-- src/platform/qt/DebuggerConsoleController.cpp | 2 +- src/platform/qt/DebuggerConsoleController.h | 2 +- src/platform/qt/Display.cpp | 4 +-- src/platform/qt/Display.h | 2 +- src/platform/qt/DisplayGL.cpp | 4 +-- src/platform/qt/DisplayQt.cpp | 4 +-- src/platform/qt/GBAApp.cpp | 11 +++--- src/platform/qt/GBAApp.h | 3 +- src/platform/qt/GBAKeyEditor.h | 2 +- src/platform/qt/GBAOverride.cpp | 2 +- src/platform/qt/GBAOverride.h | 2 +- src/platform/qt/GBOverride.cpp | 6 ++-- src/platform/qt/GBOverride.h | 2 +- src/platform/qt/GDBController.h | 2 +- src/platform/qt/GIFView.cpp | 3 ++ src/platform/qt/GameController.cpp | 25 +++++++------- src/platform/qt/GameController.h | 10 +++--- src/platform/qt/GamepadAxisEvent.h | 2 +- src/platform/qt/GamepadButtonEvent.h | 2 +- src/platform/qt/IOViewer.cpp | 6 ++-- src/platform/qt/InputController.cpp | 4 +-- src/platform/qt/InputController.h | 2 +- src/platform/qt/InputProfile.h | 2 +- src/platform/qt/LibraryModel.cpp | 2 +- src/platform/qt/LibraryModel.h | 2 +- src/platform/qt/LoadSaveState.cpp | 8 ++--- src/platform/qt/LogController.h | 2 -- src/platform/qt/MemoryModel.cpp | 3 +- src/platform/qt/MemoryModel.h | 2 +- src/platform/qt/MemoryView.cpp | 6 ++-- src/platform/qt/MessagePainter.cpp | 2 +- src/platform/qt/MultiplayerController.cpp | 4 +-- src/platform/qt/MultiplayerController.h | 6 ++-- src/platform/qt/ObjView.cpp | 6 ++-- src/platform/qt/ObjView.h | 2 +- src/platform/qt/OverrideView.cpp | 4 +-- src/platform/qt/OverrideView.h | 2 +- src/platform/qt/PaletteView.cpp | 12 +++---- src/platform/qt/ROMInfo.cpp | 8 ++--- src/platform/qt/SensorView.cpp | 4 +-- src/platform/qt/SettingsView.cpp | 4 +-- src/platform/qt/ShaderSelector.cpp | 3 +- src/platform/qt/Swatch.cpp | 2 +- src/platform/qt/TileView.cpp | 2 +- src/platform/qt/TileView.h | 2 +- src/platform/qt/VFileDevice.cpp | 2 ++ src/platform/qt/VFileDevice.h | 3 +- src/platform/qt/VideoView.cpp | 4 --- src/platform/qt/Window.cpp | 9 ++--- src/platform/qt/Window.h | 3 +- src/platform/sdl/gl-common.c | 2 +- src/platform/sdl/gl-common.h | 2 +- src/platform/sdl/gl-sdl.c | 4 +-- src/platform/sdl/main.c | 28 +++++---------- src/platform/sdl/main.h | 10 +----- src/platform/sdl/sdl-audio.c | 9 ++--- src/platform/sdl/sdl-audio.h | 4 +-- src/platform/sdl/sdl-events.c | 21 +++++------- src/platform/sdl/sdl-events.h | 10 +++--- src/platform/test/fuzz-main.c | 20 ++++++----- src/platform/test/perf-main.c | 18 +++++----- src/platform/test/tbl-fuzz-main.c | 4 +-- src/platform/video-backend.h | 2 +- src/platform/wii/gui-font.c | 4 +-- src/platform/wii/main.c | 21 ++++++------ src/platform/wii/wii-memory.c | 2 +- src/platform/windows/vfs-w32.c | 4 +-- src/third-party/blip_buf/blip_buf.c | 2 +- src/util/circle-buffer.c | 2 +- src/util/configuration.c | 8 ++--- src/util/crc32.c | 4 +-- src/util/export.c | 6 ++-- src/util/formatting.c | 2 +- src/util/gui.c | 2 +- src/util/gui/file-select.c | 8 ++--- src/util/gui/font-metrics.c | 2 +- src/util/gui/font.c | 4 +-- src/util/gui/menu.c | 6 ++-- src/util/hash.c | 2 +- src/util/nointro.c | 9 +++-- src/util/patch-fast.c | 2 +- src/util/patch-ips.c | 6 ++-- src/util/patch-ups.c | 8 ++--- src/util/patch.c | 6 ++-- src/util/png-io.c | 4 +-- src/util/ring-fifo.c | 4 +-- src/util/string.c | 2 +- src/util/table.c | 6 ++-- src/util/test/suite.h | 2 +- src/util/test/text-codec.c | 4 +-- src/util/test/util.h | 2 +- src/util/test/vfs.c | 2 +- src/util/text-codec.c | 8 ++--- src/util/vfs.c | 8 ++--- src/util/vfs/vfs-devlist.c | 2 +- src/util/vfs/vfs-dirent.c | 4 +-- src/util/vfs/vfs-fd.c | 2 +- src/util/vfs/vfs-file.c | 4 +-- src/util/vfs/vfs-lzma.c | 4 +-- src/util/vfs/vfs-mem.c | 4 +-- src/util/vfs/vfs-zip.c | 6 ++-- 371 files changed, 1099 insertions(+), 1111 deletions(-) rename {src/util => include/mgba-util}/arm-algo.h (100%) rename {src/util => include/mgba-util}/circle-buffer.h (97%) rename {src/util => include/mgba-util}/common.h (100%) rename {src/util => include/mgba-util}/configuration.h (96%) rename {src/util => include/mgba-util}/crc32.h (94%) rename {src/util => include/mgba-util}/export.h (94%) rename {src/util => include/mgba-util}/formatting.h (96%) rename {src/util => include/mgba-util}/gui.h (93%) rename {src/util => include/mgba-util}/gui/file-select.h (88%) rename {src/util => include/mgba-util}/gui/font-metrics.h (92%) rename {src/util => include/mgba-util}/gui/font.h (98%) rename {src/util => include/mgba-util}/gui/menu.h (95%) rename {src/util => include/mgba-util}/hash.h (92%) rename {src/util => include/mgba-util}/math.h (98%) rename {src/util => include/mgba-util}/memory.h (93%) rename {src/util => include/mgba-util}/nointro.h (96%) rename {src/util => include/mgba-util}/patch.h (95%) rename src/util/patch-fast.h => include/mgba-util/patch/fast.h (89%) rename src/util/patch-ips.h => include/mgba-util/patch/ips.h (92%) rename src/util/patch-ups.h => include/mgba-util/patch/ups.h (92%) rename {src => include/mgba-util}/platform/3ds/3ds-vfs.h (94%) rename {src => include/mgba-util}/platform/3ds/threading.h (98%) rename {src => include/mgba-util}/platform/posix/threading.h (98%) rename {src => include/mgba-util}/platform/psp2/sce-vfs.h (100%) rename {src => include/mgba-util}/platform/psp2/threading.h (100%) rename {src => include/mgba-util}/platform/windows/getopt.h (100%) rename {src => include/mgba-util}/platform/windows/threading.h (98%) rename {src/util => include/mgba-util}/png-io.h (97%) rename {src/util => include/mgba-util}/ring-fifo.h (96%) rename {src/util => include/mgba-util}/socket.h (99%) rename {src/util => include/mgba-util}/string.h (97%) rename {src/util => include/mgba-util}/table.h (97%) rename {src/util => include/mgba-util}/text-codec.h (97%) rename {src/util => include/mgba-util}/threading.h (87%) rename {src/util => include/mgba-util}/vector.h (99%) rename {src/util => include/mgba-util}/vfs.h (97%) rename {src/third-party/blip_buf => include/mgba/core}/blip_buf.h (100%) rename {src => include/mgba}/core/cheats.h (95%) rename {src => include/mgba}/core/config.h (98%) rename {src => include/mgba}/core/core.h (95%) rename {src => include/mgba}/core/cpu.h (95%) rename {src => include/mgba}/core/directories.h (97%) rename {src => include/mgba}/core/input.h (98%) rename {src => include/mgba}/core/interface.h (98%) rename {src => include/mgba}/core/library.h (90%) rename {src => include/mgba}/core/lockstep.h (96%) rename {src => include/mgba}/core/log.h (97%) rename {src => include/mgba}/core/rewind.h (93%) rename {src => include/mgba}/core/serialize.h (97%) rename {src => include/mgba}/core/sync.h (94%) rename {src => include/mgba}/core/thread.h (95%) rename {src => include/mgba}/core/tile-cache.h (98%) rename {src => include/mgba}/core/timing.h (97%) rename {src => include/mgba}/core/version.h (100%) rename {src => include/mgba}/gb/core.h (92%) rename {src => include/mgba}/gb/interface.h (96%) rename {src => include/mgba}/gba/core.h (92%) rename {src => include/mgba}/gba/interface.h (94%) rename {src => include/mgba/internal}/arm/arm.h (98%) rename {src => include/mgba/internal}/arm/debugger/cli-debugger.h (93%) rename {src => include/mgba/internal}/arm/debugger/debugger.h (93%) rename {src => include/mgba/internal}/arm/debugger/memory-debugger.h (94%) rename {src => include/mgba/internal}/arm/decoder-inlines.h (100%) rename {src => include/mgba/internal}/arm/decoder.h (98%) rename {src => include/mgba/internal}/arm/emitter-arm.h (100%) rename {src => include/mgba/internal}/arm/emitter-inlines.h (100%) rename {src => include/mgba/internal}/arm/emitter-thumb.h (100%) rename {src => include/mgba/internal}/arm/isa-arm.h (94%) rename {src => include/mgba/internal}/arm/isa-inlines.h (100%) rename {src => include/mgba/internal}/arm/isa-thumb.h (93%) rename {src => include/mgba/internal}/arm/macros.h (93%) rename {src => include/mgba/internal}/debugger/cli-debugger.h (97%) rename {src => include/mgba/internal}/debugger/debugger.h (95%) rename {src => include/mgba/internal}/debugger/gdb-stub.h (90%) rename {src => include/mgba/internal}/debugger/parser.h (94%) rename {src => include/mgba/internal}/gb/audio.h (98%) rename {src => include/mgba/internal}/gb/cheats.h (89%) rename {src => include/mgba/internal}/gb/extra/cli.h (86%) rename {src => include/mgba/internal}/gb/gb.h (90%) rename {src => include/mgba/internal}/gb/io.h (97%) rename {src => include/mgba/internal}/gb/mbc.h (94%) rename {src => include/mgba/internal}/gb/memory.h (96%) rename {src => include/mgba/internal}/gb/overrides.h (92%) rename {src => include/mgba/internal}/gb/renderers/software.h (85%) rename {src => include/mgba/internal}/gb/renderers/tile-cache.h (94%) rename {src => include/mgba/internal}/gb/serialize.h (99%) rename {src => include/mgba/internal}/gb/sio.h (93%) rename {src => include/mgba/internal}/gb/sio/lockstep.h (88%) rename {src => include/mgba/internal}/gb/timer.h (94%) rename {src => include/mgba/internal}/gb/video.h (96%) rename {src => include/mgba/internal}/gba/audio.h (96%) rename {src => include/mgba/internal}/gba/bios.h (89%) rename {src => include/mgba/internal}/gba/cheats.h (97%) rename {src => include/mgba/internal}/gba/dma.h (96%) rename {src => include/mgba/internal}/gba/extra/cli.h (86%) rename {src => include/mgba/internal}/gba/gba.h (93%) rename {src => include/mgba/internal}/gba/hardware.h (96%) rename {src => include/mgba/internal}/gba/input.h (91%) rename {src => include/mgba/internal}/gba/io.h (98%) rename {src => include/mgba/internal}/gba/memory.h (95%) rename {src => include/mgba/internal}/gba/overrides.h (92%) rename {src => include/mgba/internal}/gba/renderers/thread-proxy.h (87%) rename {src => include/mgba/internal}/gba/renderers/tile-cache.h (94%) rename {src => include/mgba/internal}/gba/renderers/video-software.h (97%) rename {src => include/mgba/internal}/gba/rr/mgm.h (96%) rename {src => include/mgba/internal}/gba/rr/rr.h (94%) rename {src => include/mgba/internal}/gba/rr/vbm.h (89%) rename {src => include/mgba/internal}/gba/savedata.h (98%) rename {src => include/mgba/internal}/gba/serialize.h (98%) rename {src => include/mgba/internal}/gba/sharkport.h (94%) rename {src => include/mgba/internal}/gba/sio.h (95%) rename {src => include/mgba/internal}/gba/sio/lockstep.h (89%) rename {src => include/mgba/internal}/gba/timer.h (93%) rename {src => include/mgba/internal}/gba/vfame.h (97%) rename {src => include/mgba/internal}/gba/video.h (98%) rename {src => include/mgba/internal}/lr35902/debugger/cli-debugger.h (93%) rename {src => include/mgba/internal}/lr35902/debugger/debugger.h (92%) rename {src => include/mgba/internal}/lr35902/emitter-lr35902.h (100%) rename {src => include/mgba/internal}/lr35902/isa-lr35902.h (94%) rename {src => include/mgba/internal}/lr35902/lr35902.h (96%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7ce8b389..4f6295731 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ source_group("GBA board" FILES ${GBA_SRC} ${GBA_RENDERER_SRC} ${GBA_SIO_SRC}) source_group("GBA extra" FILES ${GBA_CHEATS_SRC} ${GBA_RR_SRC}) source_group("GB board" FILES ${GB_SRC} ${GB_SIO_SRC}) source_group("Utilities" FILES ${UTIL_SRC}) -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src) +include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type (e.g. Release or Debug)" FORCE) @@ -774,7 +774,7 @@ if(BUILD_EXAMPLE) target_link_libraries(${BINARY_NAME}-example-client ${BINARY_NAME} ${SDL_LIBRARY} ${SDLMAIN_LIBRARY} ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY}) set_target_properties(${BINARY_NAME}-example-client PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}" - INCLUDE_DIRECTORIES "${SDL_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/src") + INCLUDE_DIRECTORIES "${SDL_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/src;${CMAKE_CURRENT_SOURCE_DIR}/include") endif() endif() diff --git a/src/util/arm-algo.h b/include/mgba-util/arm-algo.h similarity index 100% rename from src/util/arm-algo.h rename to include/mgba-util/arm-algo.h diff --git a/src/util/circle-buffer.h b/include/mgba-util/circle-buffer.h similarity index 97% rename from src/util/circle-buffer.h rename to include/mgba-util/circle-buffer.h index e0cdc7bf2..28d436e03 100644 --- a/src/util/circle-buffer.h +++ b/include/mgba-util/circle-buffer.h @@ -6,7 +6,7 @@ #ifndef CIRCLE_BUFFER_H #define CIRCLE_BUFFER_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/common.h b/include/mgba-util/common.h similarity index 100% rename from src/util/common.h rename to include/mgba-util/common.h diff --git a/src/util/configuration.h b/include/mgba-util/configuration.h similarity index 96% rename from src/util/configuration.h rename to include/mgba-util/configuration.h index 54134dab9..e2e6ba7d3 100644 --- a/src/util/configuration.h +++ b/include/mgba-util/configuration.h @@ -6,11 +6,11 @@ #ifndef CONFIGURATION_H #define CONFIGURATION_H -#include "util/common.h" +#include CXX_GUARD_START -#include "util/table.h" +#include struct VFile; diff --git a/src/util/crc32.h b/include/mgba-util/crc32.h similarity index 94% rename from src/util/crc32.h rename to include/mgba-util/crc32.h index cb88f4337..225998bb9 100644 --- a/src/util/crc32.h +++ b/include/mgba-util/crc32.h @@ -6,7 +6,7 @@ #ifndef CRC32_H #define CRC32_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/export.h b/include/mgba-util/export.h similarity index 94% rename from src/util/export.h rename to include/mgba-util/export.h index bbdb37ea2..92047b93b 100644 --- a/src/util/export.h +++ b/include/mgba-util/export.h @@ -6,7 +6,7 @@ #ifndef EXPORT_H #define EXPORT_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/formatting.h b/include/mgba-util/formatting.h similarity index 96% rename from src/util/formatting.h rename to include/mgba-util/formatting.h index ff1745aa6..4395879aa 100644 --- a/src/util/formatting.h +++ b/include/mgba-util/formatting.h @@ -6,7 +6,7 @@ #ifndef FORMATTING_H #define FORMATTING_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/gui.h b/include/mgba-util/gui.h similarity index 93% rename from src/util/gui.h rename to include/mgba-util/gui.h index 526feab95..183fcfa80 100644 --- a/src/util/gui.h +++ b/include/mgba-util/gui.h @@ -6,12 +6,13 @@ #ifndef GUI_H #define GUI_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/input.h" -#include "util/vector.h" +// TODO: Fix layering violation +#include +#include struct GUIFont; diff --git a/src/util/gui/file-select.h b/include/mgba-util/gui/file-select.h similarity index 88% rename from src/util/gui/file-select.h rename to include/mgba-util/gui/file-select.h index c7df6668e..1d27673a2 100644 --- a/src/util/gui/file-select.h +++ b/include/mgba-util/gui/file-select.h @@ -6,11 +6,11 @@ #ifndef GUI_FILE_CHOOSER_H #define GUI_FILE_CHOOSER_H -#include "util/common.h" +#include CXX_GUARD_START -#include "util/gui.h" +#include struct VFile; diff --git a/src/util/gui/font-metrics.h b/include/mgba-util/gui/font-metrics.h similarity index 92% rename from src/util/gui/font-metrics.h rename to include/mgba-util/gui/font-metrics.h index 8cb3ffeb4..c60d6dfc8 100644 --- a/src/util/gui/font-metrics.h +++ b/include/mgba-util/gui/font-metrics.h @@ -6,7 +6,7 @@ #ifndef DEFAULT_FONT_METRICS_H #define DEFAULT_FONT_METRICS_H -#include "util/gui/font.h" +#include extern struct GUIFontGlyphMetric defaultFontMetrics[]; extern struct GUIIconMetric defaultIconMetrics[]; diff --git a/src/util/gui/font.h b/include/mgba-util/gui/font.h similarity index 98% rename from src/util/gui/font.h rename to include/mgba-util/gui/font.h index 464440025..3ace00071 100644 --- a/src/util/gui/font.h +++ b/include/mgba-util/gui/font.h @@ -6,7 +6,7 @@ #ifndef GUI_FONT_H #define GUI_FONT_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/gui/menu.h b/include/mgba-util/gui/menu.h similarity index 95% rename from src/util/gui/menu.h rename to include/mgba-util/gui/menu.h index b99bfac2d..72a099a15 100644 --- a/src/util/gui/menu.h +++ b/include/mgba-util/gui/menu.h @@ -6,11 +6,11 @@ #ifndef GUI_MENU_H #define GUI_MENU_H -#include "util/common.h" +#include CXX_GUARD_START -#include "util/vector.h" +#include struct GUIMenu; struct GUIMenuItem { diff --git a/src/util/hash.h b/include/mgba-util/hash.h similarity index 92% rename from src/util/hash.h rename to include/mgba-util/hash.h index 31fd1f2b1..7376ba425 100644 --- a/src/util/hash.h +++ b/include/mgba-util/hash.h @@ -6,7 +6,7 @@ #ifndef HASH_H #define HASH_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/math.h b/include/mgba-util/math.h similarity index 98% rename from src/util/math.h rename to include/mgba-util/math.h index 6a69345f8..eaf2087a2 100644 --- a/src/util/math.h +++ b/include/mgba-util/math.h @@ -6,7 +6,7 @@ #ifndef UTIL_MATH_H #define UTIL_MATH_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/memory.h b/include/mgba-util/memory.h similarity index 93% rename from src/util/memory.h rename to include/mgba-util/memory.h index 444f5c6bb..325f748f6 100644 --- a/src/util/memory.h +++ b/include/mgba-util/memory.h @@ -6,7 +6,7 @@ #ifndef MEMORY_H #define MEMORY_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/nointro.h b/include/mgba-util/nointro.h similarity index 96% rename from src/util/nointro.h rename to include/mgba-util/nointro.h index 46eb4088f..6c8a3e6b5 100644 --- a/src/util/nointro.h +++ b/include/mgba-util/nointro.h @@ -6,7 +6,7 @@ #ifndef NOINTRO_H #define NOINTRO_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/patch.h b/include/mgba-util/patch.h similarity index 95% rename from src/util/patch.h rename to include/mgba-util/patch.h index e0af658ee..7bf81dc93 100644 --- a/src/util/patch.h +++ b/include/mgba-util/patch.h @@ -6,7 +6,7 @@ #ifndef PATCH_H #define PATCH_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/patch-fast.h b/include/mgba-util/patch/fast.h similarity index 89% rename from src/util/patch-fast.h rename to include/mgba-util/patch/fast.h index 95a2503a4..6657a0419 100644 --- a/src/util/patch-fast.h +++ b/include/mgba-util/patch/fast.h @@ -6,12 +6,12 @@ #ifndef PATCH_FAST_H #define PATCH_FAST_H -#include "util/common.h" +#include CXX_GUARD_START -#include "util/patch.h" -#include "util/vector.h" +#include +#include #define PATCH_FAST_EXTENT 256 diff --git a/src/util/patch-ips.h b/include/mgba-util/patch/ips.h similarity index 92% rename from src/util/patch-ips.h rename to include/mgba-util/patch/ips.h index d730e68ba..2047d21e7 100644 --- a/src/util/patch-ips.h +++ b/include/mgba-util/patch/ips.h @@ -6,7 +6,7 @@ #ifndef PATCH_IPS_H #define PATCH_IPS_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/patch-ups.h b/include/mgba-util/patch/ups.h similarity index 92% rename from src/util/patch-ups.h rename to include/mgba-util/patch/ups.h index bc29c1afa..2e53cda45 100644 --- a/src/util/patch-ups.h +++ b/include/mgba-util/patch/ups.h @@ -6,7 +6,7 @@ #ifndef PATCH_UPS_H #define PATCH_UPS_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/platform/3ds/3ds-vfs.h b/include/mgba-util/platform/3ds/3ds-vfs.h similarity index 94% rename from src/platform/3ds/3ds-vfs.h rename to include/mgba-util/platform/3ds/3ds-vfs.h index 35c6dfbe7..71344b76e 100644 --- a/src/platform/3ds/3ds-vfs.h +++ b/include/mgba-util/platform/3ds/3ds-vfs.h @@ -6,7 +6,7 @@ #ifndef N3DS_VFS_H #define N3DS_VFS_H -#include "util/vfs.h" +#include #include <3ds.h> diff --git a/src/platform/3ds/threading.h b/include/mgba-util/platform/3ds/threading.h similarity index 98% rename from src/platform/3ds/threading.h rename to include/mgba-util/platform/3ds/threading.h index 69d48c6cb..0eda3dd43 100644 --- a/src/platform/3ds/threading.h +++ b/include/mgba-util/platform/3ds/threading.h @@ -6,7 +6,7 @@ #ifndef N3DS_THREADING_H #define N3DS_THREADING_H -#include "util/common.h" +#include #include <3ds.h> #include diff --git a/src/platform/posix/threading.h b/include/mgba-util/platform/posix/threading.h similarity index 98% rename from src/platform/posix/threading.h rename to include/mgba-util/platform/posix/threading.h index 0b958af54..b880c548d 100644 --- a/src/platform/posix/threading.h +++ b/include/mgba-util/platform/posix/threading.h @@ -6,7 +6,7 @@ #ifndef POSIX_THREADING_H #define POSIX_THREADING_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/platform/psp2/sce-vfs.h b/include/mgba-util/platform/psp2/sce-vfs.h similarity index 100% rename from src/platform/psp2/sce-vfs.h rename to include/mgba-util/platform/psp2/sce-vfs.h diff --git a/src/platform/psp2/threading.h b/include/mgba-util/platform/psp2/threading.h similarity index 100% rename from src/platform/psp2/threading.h rename to include/mgba-util/platform/psp2/threading.h diff --git a/src/platform/windows/getopt.h b/include/mgba-util/platform/windows/getopt.h similarity index 100% rename from src/platform/windows/getopt.h rename to include/mgba-util/platform/windows/getopt.h diff --git a/src/platform/windows/threading.h b/include/mgba-util/platform/windows/threading.h similarity index 98% rename from src/platform/windows/threading.h rename to include/mgba-util/platform/windows/threading.h index efcf3a091..33af88b58 100644 --- a/src/platform/windows/threading.h +++ b/include/mgba-util/platform/windows/threading.h @@ -6,7 +6,7 @@ #ifndef WINDOWS_THREADING_H #define WINDOWS_THREADING_H -#include "util/common.h" +#include #define _WIN32_WINNT 0x0600 #include diff --git a/src/util/png-io.h b/include/mgba-util/png-io.h similarity index 97% rename from src/util/png-io.h rename to include/mgba-util/png-io.h index 25680e9c9..1f8fea331 100644 --- a/src/util/png-io.h +++ b/include/mgba-util/png-io.h @@ -6,7 +6,7 @@ #ifndef PNG_IO_H #define PNG_IO_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/ring-fifo.h b/include/mgba-util/ring-fifo.h similarity index 96% rename from src/util/ring-fifo.h rename to include/mgba-util/ring-fifo.h index a98d5f1f7..c5b1fdcc5 100644 --- a/src/util/ring-fifo.h +++ b/include/mgba-util/ring-fifo.h @@ -6,7 +6,7 @@ #ifndef RING_FIFO_H #define RING_FIFO_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/socket.h b/include/mgba-util/socket.h similarity index 99% rename from src/util/socket.h rename to include/mgba-util/socket.h index 12e509f83..327c2c69c 100644 --- a/src/util/socket.h +++ b/include/mgba-util/socket.h @@ -6,7 +6,7 @@ #ifndef SOCKET_H #define SOCKET_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/string.h b/include/mgba-util/string.h similarity index 97% rename from src/util/string.h rename to include/mgba-util/string.h index 04b0fce63..831ce8e44 100644 --- a/src/util/string.h +++ b/include/mgba-util/string.h @@ -6,7 +6,7 @@ #ifndef UTIL_STRING_H #define UTIL_STRING_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/table.h b/include/mgba-util/table.h similarity index 97% rename from src/util/table.h rename to include/mgba-util/table.h index 6e3979476..a03fb3734 100644 --- a/src/util/table.h +++ b/include/mgba-util/table.h @@ -6,7 +6,7 @@ #ifndef TABLE_H #define TABLE_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/text-codec.h b/include/mgba-util/text-codec.h similarity index 97% rename from src/util/text-codec.h rename to include/mgba-util/text-codec.h index 4ea3f8596..284705a19 100644 --- a/src/util/text-codec.h +++ b/include/mgba-util/text-codec.h @@ -6,7 +6,7 @@ #ifndef TEXT_CODEC_H #define TEXT_CODEC_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/threading.h b/include/mgba-util/threading.h similarity index 87% rename from src/util/threading.h rename to include/mgba-util/threading.h index 21ed062b2..d59ebcc5a 100644 --- a/src/util/threading.h +++ b/include/mgba-util/threading.h @@ -6,19 +6,19 @@ #ifndef THREADING_H #define THREADING_H -#include "util/common.h" +#include CXX_GUARD_START #ifndef DISABLE_THREADING #ifdef USE_PTHREADS -#include "platform/posix/threading.h" +#include #elif _WIN32 -#include "platform/windows/threading.h" +#include #elif PSP2 -#include "platform/psp2/threading.h" +#include #elif _3DS -#include "platform/3ds/threading.h" +#include #else #define DISABLE_THREADING #endif diff --git a/src/util/vector.h b/include/mgba-util/vector.h similarity index 99% rename from src/util/vector.h rename to include/mgba-util/vector.h index 8e35caa79..0839d61b2 100644 --- a/src/util/vector.h +++ b/include/mgba-util/vector.h @@ -6,7 +6,7 @@ #ifndef VECTOR_H #define VECTOR_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/util/vfs.h b/include/mgba-util/vfs.h similarity index 97% rename from src/util/vfs.h rename to include/mgba-util/vfs.h index f05b7fc8a..abe723d98 100644 --- a/src/util/vfs.h +++ b/include/mgba-util/vfs.h @@ -6,7 +6,7 @@ #ifndef VFS_H #define VFS_H -#include "util/common.h" +#include CXX_GUARD_START @@ -84,7 +84,7 @@ struct VDir* VDirOpenZip(const char* path, int flags); struct VDir* VDirOpen7z(const char* path, int flags); #endif -#if defined(WII) || defined(_3DS) +#if defined(__wii__) || defined(_3DS) struct VFile* VFileFOpen(const char* path, const char* mode); struct VFile* VFileFromFILE(FILE* file); struct VDir* VDeviceList(void); diff --git a/src/third-party/blip_buf/blip_buf.h b/include/mgba/core/blip_buf.h similarity index 100% rename from src/third-party/blip_buf/blip_buf.h rename to include/mgba/core/blip_buf.h diff --git a/src/core/cheats.h b/include/mgba/core/cheats.h similarity index 95% rename from src/core/cheats.h rename to include/mgba/core/cheats.h index 774dbede5..7960ae58b 100644 --- a/src/core/cheats.h +++ b/include/mgba/core/cheats.h @@ -6,13 +6,13 @@ #ifndef CHEATS_H #define CHEATS_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/cpu.h" -#include "core/log.h" -#include "util/vector.h" +#include +#include +#include #define MAX_ROM_PATCHES 4 diff --git a/src/core/config.h b/include/mgba/core/config.h similarity index 98% rename from src/core/config.h rename to include/mgba/core/config.h index d76646c35..6fe37ce6d 100644 --- a/src/core/config.h +++ b/include/mgba/core/config.h @@ -6,11 +6,11 @@ #ifndef M_CORE_CONFIG_H #define M_CORE_CONFIG_H -#include "util/common.h" +#include CXX_GUARD_START -#include "util/configuration.h" +#include struct mCoreConfig { struct Configuration configTable; diff --git a/src/core/core.h b/include/mgba/core/core.h similarity index 95% rename from src/core/core.h rename to include/mgba/core/core.h index f5592adc8..473e6f876 100644 --- a/src/core/core.h +++ b/include/mgba/core/core.h @@ -6,20 +6,21 @@ #ifndef M_CORE_H #define M_CORE_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/config.h" +#include #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 -#include "core/directories.h" +#include #endif #ifndef MINIMAL_CORE -#include "core/input.h" +#include #endif -#include "core/interface.h" +#include #ifdef USE_DEBUGGERS -#include "debugger/debugger.h" +// TODO: Fix layering violation +#include #endif enum mPlatform { diff --git a/src/core/cpu.h b/include/mgba/core/cpu.h similarity index 95% rename from src/core/cpu.h rename to include/mgba/core/cpu.h index 079e9eb5c..fe6caedd3 100644 --- a/src/core/cpu.h +++ b/include/mgba/core/cpu.h @@ -6,7 +6,7 @@ #ifndef M_CPU_H #define M_CPU_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/core/directories.h b/include/mgba/core/directories.h similarity index 97% rename from src/core/directories.h rename to include/mgba/core/directories.h index b56787a9a..8715c1025 100644 --- a/src/core/directories.h +++ b/include/mgba/core/directories.h @@ -6,7 +6,7 @@ #ifndef DIRECTORIES_H #define DIRECTORIES_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/core/input.h b/include/mgba/core/input.h similarity index 98% rename from src/core/input.h rename to include/mgba/core/input.h index 01d55f26b..0d9955981 100644 --- a/src/core/input.h +++ b/include/mgba/core/input.h @@ -6,7 +6,7 @@ #ifndef M_INPUT_H #define M_INPUT_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/core/interface.h b/include/mgba/core/interface.h similarity index 98% rename from src/core/interface.h rename to include/mgba/core/interface.h index 805f555f1..2e78390cf 100644 --- a/src/core/interface.h +++ b/include/mgba/core/interface.h @@ -6,7 +6,7 @@ #ifndef CORE_INTERFACE_H #define CORE_INTERFACE_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/core/library.h b/include/mgba/core/library.h similarity index 90% rename from src/core/library.h rename to include/mgba/core/library.h index 8a4fa68ff..be5dec001 100644 --- a/src/core/library.h +++ b/include/mgba/core/library.h @@ -6,12 +6,12 @@ #ifndef M_LIBRARY_H #define M_LIBRARY_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/core.h" -#include "util/vector.h" +#include +#include struct mLibraryEntry { char* filename; diff --git a/src/core/lockstep.h b/include/mgba/core/lockstep.h similarity index 96% rename from src/core/lockstep.h rename to include/mgba/core/lockstep.h index be9e939b7..06c1bc6b6 100644 --- a/src/core/lockstep.h +++ b/include/mgba/core/lockstep.h @@ -6,7 +6,7 @@ #ifndef SIO_LOCKSTEP_H #define SIO_LOCKSTEP_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/core/log.h b/include/mgba/core/log.h similarity index 97% rename from src/core/log.h rename to include/mgba/core/log.h index 9986fcbd7..6c8615c93 100644 --- a/src/core/log.h +++ b/include/mgba/core/log.h @@ -6,7 +6,7 @@ #ifndef M_LOG_H #define M_LOG_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/core/rewind.h b/include/mgba/core/rewind.h similarity index 93% rename from src/core/rewind.h rename to include/mgba/core/rewind.h index 3d951ae1a..a1a748d3d 100644 --- a/src/core/rewind.h +++ b/include/mgba/core/rewind.h @@ -6,11 +6,11 @@ #ifndef M_CORE_REWIND_H #define M_CORE_REWIND_H -#include "util/common.h" +#include CXX_GUARD_START -#include "util/vector.h" +#include DECLARE_VECTOR(mCoreRewindPatches, struct PatchFast); diff --git a/src/core/serialize.h b/include/mgba/core/serialize.h similarity index 97% rename from src/core/serialize.h rename to include/mgba/core/serialize.h index b901fbe40..266cab0ca 100644 --- a/src/core/serialize.h +++ b/include/mgba/core/serialize.h @@ -6,7 +6,7 @@ #ifndef M_SERIALIZE_H #define M_SERIALIZE_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/core/sync.h b/include/mgba/core/sync.h similarity index 94% rename from src/core/sync.h rename to include/mgba/core/sync.h index 19add7e76..1ca30335a 100644 --- a/src/core/sync.h +++ b/include/mgba/core/sync.h @@ -6,11 +6,11 @@ #ifndef M_CORE_SYNC_H #define M_CORE_SYNC_H -#include "util/common.h" +#include CXX_GUARD_START -#include "util/threading.h" +#include struct mCoreSync { int videoFramePending; diff --git a/src/core/thread.h b/include/mgba/core/thread.h similarity index 95% rename from src/core/thread.h rename to include/mgba/core/thread.h index 07ec8b9a0..b0a60ac80 100644 --- a/src/core/thread.h +++ b/include/mgba/core/thread.h @@ -6,14 +6,14 @@ #ifndef M_CORE_THREAD_H #define M_CORE_THREAD_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/log.h" -#include "core/rewind.h" -#include "core/sync.h" -#include "util/threading.h" +#include +#include +#include +#include struct mCoreThread; struct mCore; diff --git a/src/core/tile-cache.h b/include/mgba/core/tile-cache.h similarity index 98% rename from src/core/tile-cache.h rename to include/mgba/core/tile-cache.h index b1f780f55..0a71c690a 100644 --- a/src/core/tile-cache.h +++ b/include/mgba/core/tile-cache.h @@ -6,7 +6,7 @@ #ifndef M_TILE_CACHE_H #define M_TILE_CACHE_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/core/timing.h b/include/mgba/core/timing.h similarity index 97% rename from src/core/timing.h rename to include/mgba/core/timing.h index 815215dd8..19de59dc7 100644 --- a/src/core/timing.h +++ b/include/mgba/core/timing.h @@ -6,7 +6,7 @@ #ifndef M_CORE_TIMING #define M_CORE_TIMING -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/core/version.h b/include/mgba/core/version.h similarity index 100% rename from src/core/version.h rename to include/mgba/core/version.h diff --git a/src/gb/core.h b/include/mgba/gb/core.h similarity index 92% rename from src/gb/core.h rename to include/mgba/gb/core.h index 5839b6709..10b284803 100644 --- a/src/gb/core.h +++ b/include/mgba/gb/core.h @@ -6,7 +6,7 @@ #ifndef GB_CORE_H #define GB_CORE_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/gb/interface.h b/include/mgba/gb/interface.h similarity index 96% rename from src/gb/interface.h rename to include/mgba/gb/interface.h index 2764c2a9b..098a5e5dd 100644 --- a/src/gb/interface.h +++ b/include/mgba/gb/interface.h @@ -6,7 +6,7 @@ #ifndef GB_INTERFACE_H #define GB_INTERFACE_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/gba/core.h b/include/mgba/gba/core.h similarity index 92% rename from src/gba/core.h rename to include/mgba/gba/core.h index add75ede7..cb4c1a862 100644 --- a/src/gba/core.h +++ b/include/mgba/gba/core.h @@ -6,7 +6,7 @@ #ifndef GBA_CORE_H #define GBA_CORE_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/gba/interface.h b/include/mgba/gba/interface.h similarity index 94% rename from src/gba/interface.h rename to include/mgba/gba/interface.h index 2c9df6be3..3a5412645 100644 --- a/src/gba/interface.h +++ b/include/mgba/gba/interface.h @@ -6,11 +6,11 @@ #ifndef GBA_INTERFACE_H #define GBA_INTERFACE_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/interface.h" +#include enum GBASIOMode { SIO_NORMAL_8 = 0, diff --git a/src/arm/arm.h b/include/mgba/internal/arm/arm.h similarity index 98% rename from src/arm/arm.h rename to include/mgba/internal/arm/arm.h index c3c0eccfc..7bc1328bf 100644 --- a/src/arm/arm.h +++ b/include/mgba/internal/arm/arm.h @@ -6,11 +6,11 @@ #ifndef ARM_H #define ARM_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/cpu.h" +#include enum { ARM_SP = 13, diff --git a/src/arm/debugger/cli-debugger.h b/include/mgba/internal/arm/debugger/cli-debugger.h similarity index 93% rename from src/arm/debugger/cli-debugger.h rename to include/mgba/internal/arm/debugger/cli-debugger.h index c4e6bff6e..70f9b1885 100644 --- a/src/arm/debugger/cli-debugger.h +++ b/include/mgba/internal/arm/debugger/cli-debugger.h @@ -6,7 +6,7 @@ #ifndef ARM_CLI_DEBUGGER_H #define ARM_CLI_DEBUGGER_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/arm/debugger/debugger.h b/include/mgba/internal/arm/debugger/debugger.h similarity index 93% rename from src/arm/debugger/debugger.h rename to include/mgba/internal/arm/debugger/debugger.h index a12e30a58..d5a05e6fd 100644 --- a/src/arm/debugger/debugger.h +++ b/include/mgba/internal/arm/debugger/debugger.h @@ -6,13 +6,13 @@ #ifndef ARM_DEBUGGER_H #define ARM_DEBUGGER_H -#include "util/common.h" +#include CXX_GUARD_START -#include "debugger/debugger.h" +#include -#include "arm/arm.h" +#include struct ARMDebugBreakpoint { uint32_t address; diff --git a/src/arm/debugger/memory-debugger.h b/include/mgba/internal/arm/debugger/memory-debugger.h similarity index 94% rename from src/arm/debugger/memory-debugger.h rename to include/mgba/internal/arm/debugger/memory-debugger.h index b27dec8d8..1ec675992 100644 --- a/src/arm/debugger/memory-debugger.h +++ b/include/mgba/internal/arm/debugger/memory-debugger.h @@ -6,7 +6,7 @@ #ifndef MEMORY_DEBUGGER_H #define MEMORY_DEBUGGER_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/arm/decoder-inlines.h b/include/mgba/internal/arm/decoder-inlines.h similarity index 100% rename from src/arm/decoder-inlines.h rename to include/mgba/internal/arm/decoder-inlines.h diff --git a/src/arm/decoder.h b/include/mgba/internal/arm/decoder.h similarity index 98% rename from src/arm/decoder.h rename to include/mgba/internal/arm/decoder.h index eabd30272..4f6322b28 100644 --- a/src/arm/decoder.h +++ b/include/mgba/internal/arm/decoder.h @@ -6,11 +6,11 @@ #ifndef ARM_DECODER_H #define ARM_DECODER_H -#include "util/common.h" +#include CXX_GUARD_START -#include "arm.h" +#include // Bit 0: a register is involved with this operand // Bit 1: an immediate is invovled with this operand diff --git a/src/arm/emitter-arm.h b/include/mgba/internal/arm/emitter-arm.h similarity index 100% rename from src/arm/emitter-arm.h rename to include/mgba/internal/arm/emitter-arm.h diff --git a/src/arm/emitter-inlines.h b/include/mgba/internal/arm/emitter-inlines.h similarity index 100% rename from src/arm/emitter-inlines.h rename to include/mgba/internal/arm/emitter-inlines.h diff --git a/src/arm/emitter-thumb.h b/include/mgba/internal/arm/emitter-thumb.h similarity index 100% rename from src/arm/emitter-thumb.h rename to include/mgba/internal/arm/emitter-thumb.h diff --git a/src/arm/isa-arm.h b/include/mgba/internal/arm/isa-arm.h similarity index 94% rename from src/arm/isa-arm.h rename to include/mgba/internal/arm/isa-arm.h index 7f3063171..fb347cd89 100644 --- a/src/arm/isa-arm.h +++ b/include/mgba/internal/arm/isa-arm.h @@ -6,7 +6,7 @@ #ifndef ISA_ARM_H #define ISA_ARM_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/arm/isa-inlines.h b/include/mgba/internal/arm/isa-inlines.h similarity index 100% rename from src/arm/isa-inlines.h rename to include/mgba/internal/arm/isa-inlines.h diff --git a/src/arm/isa-thumb.h b/include/mgba/internal/arm/isa-thumb.h similarity index 93% rename from src/arm/isa-thumb.h rename to include/mgba/internal/arm/isa-thumb.h index 71ddd06ed..330a4faf8 100644 --- a/src/arm/isa-thumb.h +++ b/include/mgba/internal/arm/isa-thumb.h @@ -6,7 +6,7 @@ #ifndef ISA_THUMB_H #define ISA_THUMB_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/arm/macros.h b/include/mgba/internal/arm/macros.h similarity index 93% rename from src/arm/macros.h rename to include/mgba/internal/arm/macros.h index abde45bf1..4832f0546 100644 --- a/src/arm/macros.h +++ b/include/mgba/internal/arm/macros.h @@ -6,7 +6,7 @@ #ifndef MACROS_H #define MACROS_H -#include "util/common.h" +#include #define LOAD_64 LOAD_64LE #define LOAD_32 LOAD_32LE diff --git a/src/debugger/cli-debugger.h b/include/mgba/internal/debugger/cli-debugger.h similarity index 97% rename from src/debugger/cli-debugger.h rename to include/mgba/internal/debugger/cli-debugger.h index c82a8b493..2f86590ee 100644 --- a/src/debugger/cli-debugger.h +++ b/include/mgba/internal/debugger/cli-debugger.h @@ -6,11 +6,11 @@ #ifndef CLI_DEBUGGER_H #define CLI_DEBUGGER_H -#include "util/common.h" +#include CXX_GUARD_START -#include "debugger.h" +#include struct CLIDebugger; diff --git a/src/debugger/debugger.h b/include/mgba/internal/debugger/debugger.h similarity index 95% rename from src/debugger/debugger.h rename to include/mgba/internal/debugger/debugger.h index 858d76554..3cd228dc7 100644 --- a/src/debugger/debugger.h +++ b/include/mgba/internal/debugger/debugger.h @@ -6,13 +6,13 @@ #ifndef DEBUGGER_H #define DEBUGGER_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/cpu.h" -#include "core/log.h" -#include "util/vector.h" +#include +#include +#include mLOG_DECLARE_CATEGORY(DEBUGGER); diff --git a/src/debugger/gdb-stub.h b/include/mgba/internal/debugger/gdb-stub.h similarity index 90% rename from src/debugger/gdb-stub.h rename to include/mgba/internal/debugger/gdb-stub.h index 84b086a60..9e6be2239 100644 --- a/src/debugger/gdb-stub.h +++ b/include/mgba/internal/debugger/gdb-stub.h @@ -6,13 +6,13 @@ #ifndef GDB_STUB_H #define GDB_STUB_H -#include "util/common.h" +#include CXX_GUARD_START -#include "debugger/debugger.h" +#include -#include "util/socket.h" +#include #define GDB_STUB_MAX_LINE 1200 #define GDB_STUB_INTERVAL 32 diff --git a/src/debugger/parser.h b/include/mgba/internal/debugger/parser.h similarity index 94% rename from src/debugger/parser.h rename to include/mgba/internal/debugger/parser.h index 39ac6d262..c5ab01446 100644 --- a/src/debugger/parser.h +++ b/include/mgba/internal/debugger/parser.h @@ -6,11 +6,11 @@ #ifndef PARSER_H #define PARSER_H -#include "util/common.h" +#include CXX_GUARD_START -#include "debugger.h" +#include enum LexState { LEX_ERROR = -1, diff --git a/src/gb/audio.h b/include/mgba/internal/gb/audio.h similarity index 98% rename from src/gb/audio.h rename to include/mgba/internal/gb/audio.h index bd47a72e9..b1e86e299 100644 --- a/src/gb/audio.h +++ b/include/mgba/internal/gb/audio.h @@ -6,12 +6,11 @@ #ifndef GB_AUDIO_H #define GB_AUDIO_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/timing.h" -#include "third-party/blip_buf/blip_buf.h" +#include DECL_BITFIELD(GBAudioRegisterDuty, uint8_t); DECL_BITS(GBAudioRegisterDuty, Length, 0, 6); @@ -157,8 +156,8 @@ struct GBAudio { struct GBAudioWaveChannel ch3; struct GBAudioNoiseChannel ch4; - blip_t* left; - blip_t* right; + struct blip_t* left; + struct blip_t* right; int16_t lastLeft; int16_t lastRight; int clock; diff --git a/src/gb/cheats.h b/include/mgba/internal/gb/cheats.h similarity index 89% rename from src/gb/cheats.h rename to include/mgba/internal/gb/cheats.h index 5b2f7e3a0..0eb7d3b3c 100644 --- a/src/gb/cheats.h +++ b/include/mgba/internal/gb/cheats.h @@ -6,12 +6,12 @@ #ifndef GB_CHEATS_H #define GB_CHEATS_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/cheats.h" -#include "util/vector.h" +#include +#include enum GBCheatType { GB_CHEAT_AUTODETECT, diff --git a/src/gb/extra/cli.h b/include/mgba/internal/gb/extra/cli.h similarity index 86% rename from src/gb/extra/cli.h rename to include/mgba/internal/gb/extra/cli.h index 343ef1546..19c2c711b 100644 --- a/src/gb/extra/cli.h +++ b/include/mgba/internal/gb/extra/cli.h @@ -6,11 +6,11 @@ #ifndef GB_CLI_H #define GB_CLI_H -#include "util/common.h" +#include CXX_GUARD_START -#include "debugger/cli-debugger.h" +#include struct GBCLIDebugger { struct CLIDebuggerSystem d; diff --git a/src/gb/gb.h b/include/mgba/internal/gb/gb.h similarity index 90% rename from src/gb/gb.h rename to include/mgba/internal/gb/gb.h index 0ed6f99a0..d047f1c2c 100644 --- a/src/gb/gb.h +++ b/include/mgba/internal/gb/gb.h @@ -6,21 +6,19 @@ #ifndef GB_H #define GB_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/log.h" -#include "core/timing.h" +#include +#include +#include -#include "lr35902/lr35902.h" - -#include "gb/audio.h" -#include "gb/interface.h" -#include "gb/memory.h" -#include "gb/sio.h" -#include "gb/timer.h" -#include "gb/video.h" +#include +#include +#include +#include +#include extern const uint32_t DMG_LR35902_FREQUENCY; extern const uint32_t CGB_LR35902_FREQUENCY; @@ -45,6 +43,7 @@ enum GBIRQVector { GB_VECTOR_KEYPAD = 0x60, }; +struct LR35902Core; struct mCoreSync; struct mAVStream; struct mCoreCallbacks; diff --git a/src/gb/io.h b/include/mgba/internal/gb/io.h similarity index 97% rename from src/gb/io.h rename to include/mgba/internal/gb/io.h index 756157565..5ed4cb0fe 100644 --- a/src/gb/io.h +++ b/include/mgba/internal/gb/io.h @@ -6,11 +6,11 @@ #ifndef GB_IO_H #define GB_IO_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/log.h" +#include mLOG_DECLARE_CATEGORY(GB_IO); diff --git a/src/gb/mbc.h b/include/mgba/internal/gb/mbc.h similarity index 94% rename from src/gb/mbc.h rename to include/mgba/internal/gb/mbc.h index b38b53096..32496177f 100644 --- a/src/gb/mbc.h +++ b/include/mgba/internal/gb/mbc.h @@ -6,11 +6,11 @@ #ifndef GB_MBC_H #define GB_MBC_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/log.h" +#include mLOG_DECLARE_CATEGORY(GB_MBC); diff --git a/src/gb/memory.h b/include/mgba/internal/gb/memory.h similarity index 96% rename from src/gb/memory.h rename to include/mgba/internal/gb/memory.h index 1117bb4b5..45a3f0aed 100644 --- a/src/gb/memory.h +++ b/include/mgba/internal/gb/memory.h @@ -6,14 +6,13 @@ #ifndef GB_MEMORY_H #define GB_MEMORY_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/log.h" -#include "core/timing.h" -#include "gb/interface.h" -#include "lr35902/lr35902.h" +#include +#include +#include #include @@ -154,6 +153,7 @@ struct GBMemory { struct mRumble* rumble; }; +struct LR35902Core; void GBMemoryInit(struct GB* gb); void GBMemoryDeinit(struct GB* gb); diff --git a/src/gb/overrides.h b/include/mgba/internal/gb/overrides.h similarity index 92% rename from src/gb/overrides.h rename to include/mgba/internal/gb/overrides.h index 1779aea16..fd787163c 100644 --- a/src/gb/overrides.h +++ b/include/mgba/internal/gb/overrides.h @@ -6,11 +6,11 @@ #ifndef GB_OVERRIDES_H #define GB_OVERRIDES_H -#include "util/common.h" +#include CXX_GUARD_START -#include "gb/interface.h" +#include struct GBCartridgeOverride { int headerCrc32; diff --git a/src/gb/renderers/software.h b/include/mgba/internal/gb/renderers/software.h similarity index 85% rename from src/gb/renderers/software.h rename to include/mgba/internal/gb/renderers/software.h index 9f2b9e519..038c660b8 100644 --- a/src/gb/renderers/software.h +++ b/include/mgba/internal/gb/renderers/software.h @@ -6,13 +6,13 @@ #ifndef GB_RENDERER_SOFTWARE_H #define GB_RENDERER_SOFTWARE_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/core.h" -#include "gb/gb.h" -#include "gb/video.h" +#include +#include +#include struct GBVideoSoftwareRenderer { struct GBVideoRenderer d; diff --git a/src/gb/renderers/tile-cache.h b/include/mgba/internal/gb/renderers/tile-cache.h similarity index 94% rename from src/gb/renderers/tile-cache.h rename to include/mgba/internal/gb/renderers/tile-cache.h index 7a96ec866..1b739ca46 100644 --- a/src/gb/renderers/tile-cache.h +++ b/include/mgba/internal/gb/renderers/tile-cache.h @@ -6,7 +6,7 @@ #ifndef GB_TILE_CACHE_H #define GB_TILE_CACHE_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/gb/serialize.h b/include/mgba/internal/gb/serialize.h similarity index 99% rename from src/gb/serialize.h rename to include/mgba/internal/gb/serialize.h index 9819af85a..e370c997b 100644 --- a/src/gb/serialize.h +++ b/include/mgba/internal/gb/serialize.h @@ -6,12 +6,12 @@ #ifndef GB_SERIALIZE_H #define GB_SERIALIZE_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/core.h" -#include "gb/gb.h" +#include +#include extern const uint32_t GB_SAVESTATE_MAGIC; extern const uint32_t GB_SAVESTATE_VERSION; diff --git a/src/gb/sio.h b/include/mgba/internal/gb/sio.h similarity index 93% rename from src/gb/sio.h rename to include/mgba/internal/gb/sio.h index e101f9c3f..004cf16e8 100644 --- a/src/gb/sio.h +++ b/include/mgba/internal/gb/sio.h @@ -6,12 +6,12 @@ #ifndef GB_SIO_H #define GB_SIO_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/log.h" -#include "core/timing.h" +#include +#include #define MAX_GBS 2 diff --git a/src/gb/sio/lockstep.h b/include/mgba/internal/gb/sio/lockstep.h similarity index 88% rename from src/gb/sio/lockstep.h rename to include/mgba/internal/gb/sio/lockstep.h index 2b1b52815..25f6d9c74 100644 --- a/src/gb/sio/lockstep.h +++ b/include/mgba/internal/gb/sio/lockstep.h @@ -6,13 +6,13 @@ #ifndef GB_SIO_LOCKSTEP_H #define GB_SIO_LOCKSTEP_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/lockstep.h" -#include "core/timing.h" -#include "gb/sio.h" +#include +#include +#include struct GBSIOLockstep { struct mLockstep d; diff --git a/src/gb/timer.h b/include/mgba/internal/gb/timer.h similarity index 94% rename from src/gb/timer.h rename to include/mgba/internal/gb/timer.h index 0a6ebcea9..b81ff1c34 100644 --- a/src/gb/timer.h +++ b/include/mgba/internal/gb/timer.h @@ -6,11 +6,11 @@ #ifndef GB_TIMER_H #define GB_TIMER_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/timing.h" +#include DECL_BITFIELD(GBRegisterTAC, uint8_t); DECL_BITS(GBRegisterTAC, Clock, 0, 2); diff --git a/src/gb/video.h b/include/mgba/internal/gb/video.h similarity index 96% rename from src/gb/video.h rename to include/mgba/internal/gb/video.h index e9ff5b956..67bf96405 100644 --- a/src/gb/video.h +++ b/include/mgba/internal/gb/video.h @@ -6,14 +6,12 @@ #ifndef GB_VIDEO_H #define GB_VIDEO_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/interface.h" -#include "core/timing.h" -#include "gb/interface.h" -#include "gb/memory.h" +#include +#include enum { GB_VIDEO_HORIZONTAL_PIXELS = 160, @@ -55,7 +53,6 @@ union GBOAM { uint8_t raw[160]; }; -enum GBModel; struct mTileCache; struct GBVideoRenderer { void (*init)(struct GBVideoRenderer* renderer, enum GBModel model); diff --git a/src/gba/audio.h b/include/mgba/internal/gba/audio.h similarity index 96% rename from src/gba/audio.h rename to include/mgba/internal/gba/audio.h index 3a6d07348..10f5a7e65 100644 --- a/src/gba/audio.h +++ b/include/mgba/internal/gba/audio.h @@ -6,13 +6,13 @@ #ifndef GBA_AUDIO_H #define GBA_AUDIO_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/log.h" -#include "gb/audio.h" -#include "util/circle-buffer.h" +#include +#include +#include mLOG_DECLARE_CATEGORY(GBA_AUDIO); diff --git a/src/gba/bios.h b/include/mgba/internal/gba/bios.h similarity index 89% rename from src/gba/bios.h rename to include/mgba/internal/gba/bios.h index 7d2bed194..a89edfd68 100644 --- a/src/gba/bios.h +++ b/include/mgba/internal/gba/bios.h @@ -6,15 +6,15 @@ #ifndef GBA_BIOS_H #define GBA_BIOS_H -#include "util/common.h" +#include CXX_GUARD_START -#include "arm/arm.h" -#include "core/log.h" +#include mLOG_DECLARE_CATEGORY(GBA_BIOS); +struct ARMCore; void GBASwi16(struct ARMCore* cpu, int immediate); void GBASwi32(struct ARMCore* cpu, int immediate); diff --git a/src/gba/cheats.h b/include/mgba/internal/gba/cheats.h similarity index 97% rename from src/gba/cheats.h rename to include/mgba/internal/gba/cheats.h index 6dcd01f53..83912f660 100644 --- a/src/gba/cheats.h +++ b/include/mgba/internal/gba/cheats.h @@ -6,12 +6,12 @@ #ifndef GBA_CHEATS_H #define GBA_CHEATS_H -#include "util/common.h" +#include CXX_GUARD_START -#include "arm/arm.h" -#include "core/cheats.h" +#include +#include #define MAX_ROM_PATCHES 4 #define COMPLETE ((size_t) -1) diff --git a/src/gba/dma.h b/include/mgba/internal/gba/dma.h similarity index 96% rename from src/gba/dma.h rename to include/mgba/internal/gba/dma.h index 984980c87..fd86829af 100644 --- a/src/gba/dma.h +++ b/include/mgba/internal/gba/dma.h @@ -6,7 +6,7 @@ #ifndef GBA_DMA_H #define GBA_DMA_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/gba/extra/cli.h b/include/mgba/internal/gba/extra/cli.h similarity index 86% rename from src/gba/extra/cli.h rename to include/mgba/internal/gba/extra/cli.h index e77f8439d..2b2d407fe 100644 --- a/src/gba/extra/cli.h +++ b/include/mgba/internal/gba/extra/cli.h @@ -6,11 +6,11 @@ #ifndef GBA_CLI_H #define GBA_CLI_H -#include "util/common.h" +#include CXX_GUARD_START -#include "debugger/cli-debugger.h" +#include struct mCore; diff --git a/src/gba/gba.h b/include/mgba/internal/gba/gba.h similarity index 93% rename from src/gba/gba.h rename to include/mgba/internal/gba/gba.h index bcbdc544e..73171095b 100644 --- a/src/gba/gba.h +++ b/include/mgba/internal/gba/gba.h @@ -6,20 +6,18 @@ #ifndef GBA_H #define GBA_H -#include "util/common.h" +#include CXX_GUARD_START -#include "arm/arm.h" -#include "core/log.h" -#include "core/timing.h" +#include +#include -#include "gba/interface.h" -#include "gba/memory.h" -#include "gba/video.h" -#include "gba/audio.h" -#include "gba/sio.h" -#include "gba/timer.h" +#include +#include +#include +#include +#include #define GBA_ARM7TDMI_FREQUENCY 0x1000000U @@ -52,6 +50,7 @@ enum { SP_BASE_SUPERVISOR = 0x03007FE0 }; +struct ARMCore; struct GBA; struct Patch; struct VFile; diff --git a/src/gba/hardware.h b/include/mgba/internal/gba/hardware.h similarity index 96% rename from src/gba/hardware.h rename to include/mgba/internal/gba/hardware.h index 0329fbf5e..8aa98ba47 100644 --- a/src/gba/hardware.h +++ b/include/mgba/internal/gba/hardware.h @@ -6,14 +6,13 @@ #ifndef GBA_HARDWARE_H #define GBA_HARDWARE_H -#include "util/common.h" +#include CXX_GUARD_START -#include "arm/macros.h" -#include "core/log.h" -#include "core/timing.h" -#include "gba/interface.h" +#include +#include +#include #include diff --git a/src/gba/input.h b/include/mgba/internal/gba/input.h similarity index 91% rename from src/gba/input.h rename to include/mgba/internal/gba/input.h index cf2da1469..03cb8b5e0 100644 --- a/src/gba/input.h +++ b/include/mgba/internal/gba/input.h @@ -6,11 +6,11 @@ #ifndef GBA_INPUT_H #define GBA_INPUT_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/input.h" +#include extern const struct mInputPlatformInfo GBAInputInfo; diff --git a/src/gba/io.h b/include/mgba/internal/gba/io.h similarity index 98% rename from src/gba/io.h rename to include/mgba/internal/gba/io.h index b7e6aaddd..959babf05 100644 --- a/src/gba/io.h +++ b/include/mgba/internal/gba/io.h @@ -6,11 +6,11 @@ #ifndef GBA_IO_H #define GBA_IO_H -#include "util/common.h" +#include CXX_GUARD_START -#include "gba/gba.h" +#include enum GBAIORegisters { // Video @@ -163,6 +163,7 @@ mLOG_DECLARE_CATEGORY(GBA_IO); extern const char* const GBAIORegisterNames[]; +struct GBA; void GBAIOInit(struct GBA* gba); void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value); void GBAIOWrite8(struct GBA* gba, uint32_t address, uint8_t value); diff --git a/src/gba/memory.h b/include/mgba/internal/gba/memory.h similarity index 95% rename from src/gba/memory.h rename to include/mgba/internal/gba/memory.h index 047771764..9507f0e29 100644 --- a/src/gba/memory.h +++ b/include/mgba/internal/gba/memory.h @@ -6,16 +6,16 @@ #ifndef GBA_MEMORY_H #define GBA_MEMORY_H -#include "util/common.h" +#include CXX_GUARD_START -#include "arm/arm.h" -#include "core/timing.h" +#include -#include "gba/hardware.h" -#include "gba/savedata.h" -#include "gba/vfame.h" +#include +#include +#include +#include enum GBAMemoryRegion { REGION_BIOS = 0x0, @@ -148,6 +148,7 @@ struct GBAMemory { bool mirroring; }; +struct GBA; void GBAMemoryInit(struct GBA* gba); void GBAMemoryDeinit(struct GBA* gba); diff --git a/src/gba/overrides.h b/include/mgba/internal/gba/overrides.h similarity index 92% rename from src/gba/overrides.h rename to include/mgba/internal/gba/overrides.h index c86c0e728..4240fea2e 100644 --- a/src/gba/overrides.h +++ b/include/mgba/internal/gba/overrides.h @@ -6,11 +6,11 @@ #ifndef GBA_OVERRIDES_H #define GBA_OVERRIDES_H -#include "util/common.h" +#include CXX_GUARD_START -#include "gba/savedata.h" +#include #define IDLE_LOOP_NONE 0xFFFFFFFF diff --git a/src/gba/renderers/thread-proxy.h b/include/mgba/internal/gba/renderers/thread-proxy.h similarity index 87% rename from src/gba/renderers/thread-proxy.h rename to include/mgba/internal/gba/renderers/thread-proxy.h index 2914f203b..6fa07215a 100644 --- a/src/gba/renderers/thread-proxy.h +++ b/include/mgba/internal/gba/renderers/thread-proxy.h @@ -6,13 +6,13 @@ #ifndef VIDEO_THREAD_PROXY_H #define VIDEO_THREAD_PROXY_H -#include "util/common.h" +#include CXX_GUARD_START -#include "gba/video.h" -#include "util/threading.h" -#include "util/ring-fifo.h" +#include +#include +#include enum GBAVideoThreadProxyState { PROXY_THREAD_STOPPED = 0, diff --git a/src/gba/renderers/tile-cache.h b/include/mgba/internal/gba/renderers/tile-cache.h similarity index 94% rename from src/gba/renderers/tile-cache.h rename to include/mgba/internal/gba/renderers/tile-cache.h index 2afa25696..3e2143f35 100644 --- a/src/gba/renderers/tile-cache.h +++ b/include/mgba/internal/gba/renderers/tile-cache.h @@ -6,7 +6,7 @@ #ifndef GBA_TILE_CACHE_H #define GBA_TILE_CACHE_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/gba/renderers/video-software.h b/include/mgba/internal/gba/renderers/video-software.h similarity index 97% rename from src/gba/renderers/video-software.h rename to include/mgba/internal/gba/renderers/video-software.h index e292eb233..ba9db50f7 100644 --- a/src/gba/renderers/video-software.h +++ b/include/mgba/internal/gba/renderers/video-software.h @@ -6,12 +6,12 @@ #ifndef VIDEO_SOFTWARE_H #define VIDEO_SOFTWARE_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/core.h" -#include "gba/video.h" +#include +#include struct GBAVideoSoftwareSprite { struct GBAObj obj; diff --git a/src/gba/rr/mgm.h b/include/mgba/internal/gba/rr/mgm.h similarity index 96% rename from src/gba/rr/mgm.h rename to include/mgba/internal/gba/rr/mgm.h index f45351a7b..fd455a830 100644 --- a/src/gba/rr/mgm.h +++ b/include/mgba/internal/gba/rr/mgm.h @@ -6,11 +6,11 @@ #ifndef RR_MGM_H #define RR_MGM_H -#include "util/common.h" +#include CXX_GUARD_START -#include "gba/rr/rr.h" +#include struct GBA; struct VDir; diff --git a/src/gba/rr/rr.h b/include/mgba/internal/gba/rr/rr.h similarity index 94% rename from src/gba/rr/rr.h rename to include/mgba/internal/gba/rr/rr.h index dcc7ea782..b4fc2e627 100644 --- a/src/gba/rr/rr.h +++ b/include/mgba/internal/gba/rr/rr.h @@ -6,12 +6,12 @@ #ifndef GBA_RR_H #define GBA_RR_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/log.h" -#include "gba/serialize.h" +#include +#include struct VFile; diff --git a/src/gba/rr/vbm.h b/include/mgba/internal/gba/rr/vbm.h similarity index 89% rename from src/gba/rr/vbm.h rename to include/mgba/internal/gba/rr/vbm.h index e38f83261..66d19b76e 100644 --- a/src/gba/rr/vbm.h +++ b/include/mgba/internal/gba/rr/vbm.h @@ -6,11 +6,11 @@ #ifndef GBA_VBM_H #define GBA_VBM_H -#include "util/common.h" +#include CXX_GUARD_START -#include "gba/rr/rr.h" +#include struct GBAVBMContext { struct GBARRContext d; diff --git a/src/gba/savedata.h b/include/mgba/internal/gba/savedata.h similarity index 98% rename from src/gba/savedata.h rename to include/mgba/internal/gba/savedata.h index bd2c8fc97..2b0bbfe38 100644 --- a/src/gba/savedata.h +++ b/include/mgba/internal/gba/savedata.h @@ -6,11 +6,11 @@ #ifndef GBA_SAVEDATA_H #define GBA_SAVEDATA_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/log.h" +#include mLOG_DECLARE_CATEGORY(GBA_SAVE); diff --git a/src/gba/serialize.h b/include/mgba/internal/gba/serialize.h similarity index 98% rename from src/gba/serialize.h rename to include/mgba/internal/gba/serialize.h index 301eae0a9..fd2c191b0 100644 --- a/src/gba/serialize.h +++ b/include/mgba/internal/gba/serialize.h @@ -6,13 +6,13 @@ #ifndef GBA_SERIALIZE_H #define GBA_SERIALIZE_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/core.h" -#include "gba/gba.h" -#include "gb/serialize.h" +#include +#include +#include extern const uint32_t GBA_SAVESTATE_MAGIC; extern const uint32_t GBA_SAVESTATE_VERSION; diff --git a/src/gba/sharkport.h b/include/mgba/internal/gba/sharkport.h similarity index 94% rename from src/gba/sharkport.h rename to include/mgba/internal/gba/sharkport.h index 18bb0c64b..361d4eb44 100644 --- a/src/gba/sharkport.h +++ b/include/mgba/internal/gba/sharkport.h @@ -6,7 +6,7 @@ #ifndef GBA_SHARKPORT_H #define GBA_SHARKPORT_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/gba/sio.h b/include/mgba/internal/gba/sio.h similarity index 95% rename from src/gba/sio.h rename to include/mgba/internal/gba/sio.h index cdb0d50b7..d7b702edb 100644 --- a/src/gba/sio.h +++ b/include/mgba/internal/gba/sio.h @@ -6,12 +6,12 @@ #ifndef GBA_SIO_H #define GBA_SIO_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/log.h" -#include "gba/interface.h" +#include +#include #define MAX_GBAS 4 diff --git a/src/gba/sio/lockstep.h b/include/mgba/internal/gba/sio/lockstep.h similarity index 89% rename from src/gba/sio/lockstep.h rename to include/mgba/internal/gba/sio/lockstep.h index cecfbc733..13c181039 100644 --- a/src/gba/sio/lockstep.h +++ b/include/mgba/internal/gba/sio/lockstep.h @@ -6,13 +6,13 @@ #ifndef GBA_SIO_LOCKSTEP_H #define GBA_SIO_LOCKSTEP_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/lockstep.h" -#include "core/timing.h" -#include "gba/sio.h" +#include +#include +#include struct GBASIOLockstep { struct mLockstep d; diff --git a/src/gba/timer.h b/include/mgba/internal/gba/timer.h similarity index 93% rename from src/gba/timer.h rename to include/mgba/internal/gba/timer.h index 1edce1c9e..d031f3d4f 100644 --- a/src/gba/timer.h +++ b/include/mgba/internal/gba/timer.h @@ -6,11 +6,11 @@ #ifndef GBA_TIMER_H #define GBA_TIMER_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/timing.h" +#include DECL_BITFIELD(GBATimerFlags, uint32_t); DECL_BITS(GBATimerFlags, PrescaleBits, 0, 4); diff --git a/src/gba/vfame.h b/include/mgba/internal/gba/vfame.h similarity index 97% rename from src/gba/vfame.h rename to include/mgba/internal/gba/vfame.h index fa226efa3..eff24a039 100644 --- a/src/gba/vfame.h +++ b/include/mgba/internal/gba/vfame.h @@ -9,7 +9,7 @@ #ifndef GBA_VFAME_H #define GBA_VFAME_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/gba/video.h b/include/mgba/internal/gba/video.h similarity index 98% rename from src/gba/video.h rename to include/mgba/internal/gba/video.h index b5b1d810b..3a1aa14e8 100644 --- a/src/gba/video.h +++ b/include/mgba/internal/gba/video.h @@ -6,12 +6,12 @@ #ifndef GBA_VIDEO_H #define GBA_VIDEO_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/timing.h" -#include "gba/memory.h" +#include +#include mLOG_DECLARE_CATEGORY(GBA_VIDEO); diff --git a/src/lr35902/debugger/cli-debugger.h b/include/mgba/internal/lr35902/debugger/cli-debugger.h similarity index 93% rename from src/lr35902/debugger/cli-debugger.h rename to include/mgba/internal/lr35902/debugger/cli-debugger.h index a229f03cc..995f10649 100644 --- a/src/lr35902/debugger/cli-debugger.h +++ b/include/mgba/internal/lr35902/debugger/cli-debugger.h @@ -6,7 +6,7 @@ #ifndef LR35902_CLI_DEBUGGER_H #define LR35902_CLI_DEBUGGER_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/lr35902/debugger/debugger.h b/include/mgba/internal/lr35902/debugger/debugger.h similarity index 92% rename from src/lr35902/debugger/debugger.h rename to include/mgba/internal/lr35902/debugger/debugger.h index 9697f5fc5..06801d77b 100644 --- a/src/lr35902/debugger/debugger.h +++ b/include/mgba/internal/lr35902/debugger/debugger.h @@ -6,11 +6,11 @@ #ifndef LR35902_DEBUGGER_H #define LR35902_DEBUGGER_H -#include "util/common.h" +#include CXX_GUARD_START -#include "debugger/debugger.h" +#include struct LR35902DebugBreakpoint { uint16_t address; diff --git a/src/lr35902/emitter-lr35902.h b/include/mgba/internal/lr35902/emitter-lr35902.h similarity index 100% rename from src/lr35902/emitter-lr35902.h rename to include/mgba/internal/lr35902/emitter-lr35902.h diff --git a/src/lr35902/isa-lr35902.h b/include/mgba/internal/lr35902/isa-lr35902.h similarity index 94% rename from src/lr35902/isa-lr35902.h rename to include/mgba/internal/lr35902/isa-lr35902.h index 60e278f4e..151524a43 100644 --- a/src/lr35902/isa-lr35902.h +++ b/include/mgba/internal/lr35902/isa-lr35902.h @@ -6,7 +6,7 @@ #ifndef ISA_LR35902_H #define ISA_LR35902_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/lr35902/lr35902.h b/include/mgba/internal/lr35902/lr35902.h similarity index 96% rename from src/lr35902/lr35902.h rename to include/mgba/internal/lr35902/lr35902.h index f2c0492c7..59811cc8b 100644 --- a/src/lr35902/lr35902.h +++ b/include/mgba/internal/lr35902/lr35902.h @@ -6,12 +6,12 @@ #ifndef LR35902_H #define LR35902_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/cpu.h" -#include "lr35902/isa-lr35902.h" +#include +#include struct LR35902Core; diff --git a/src/arm/arm.c b/src/arm/arm.c index 9fc35de71..618f34750 100644 --- a/src/arm/arm.c +++ b/src/arm/arm.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "arm.h" +#include -#include "isa-arm.h" -#include "isa-inlines.h" -#include "isa-thumb.h" +#include +#include +#include static inline enum RegisterBank _ARMSelectBank(enum PrivilegeMode); diff --git a/src/arm/debugger/cli-debugger.c b/src/arm/debugger/cli-debugger.c index dbee4c538..87a1655c5 100644 --- a/src/arm/debugger/cli-debugger.c +++ b/src/arm/debugger/cli-debugger.c @@ -3,13 +3,13 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "cli-debugger.h" +#include -#include "arm/debugger/debugger.h" -#include "arm/debugger/memory-debugger.h" -#include "arm/decoder.h" -#include "core/core.h" -#include "debugger/cli-debugger.h" +#include +#include +#include +#include +#include static void _printStatus(struct CLIDebuggerSystem*); diff --git a/src/arm/debugger/debugger.c b/src/arm/debugger/debugger.c index ba9204726..76b474841 100644 --- a/src/arm/debugger/debugger.c +++ b/src/arm/debugger/debugger.c @@ -3,12 +3,12 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "debugger.h" +#include -#include "arm/arm.h" -#include "arm/isa-inlines.h" -#include "arm/debugger/memory-debugger.h" -#include "core/core.h" +#include +#include +#include +#include DEFINE_VECTOR(ARMDebugBreakpointList, struct ARMDebugBreakpoint); DEFINE_VECTOR(ARMDebugWatchpointList, struct ARMDebugWatchpoint); diff --git a/src/arm/debugger/memory-debugger.c b/src/arm/debugger/memory-debugger.c index 2844af5e6..faa8651f4 100644 --- a/src/arm/debugger/memory-debugger.c +++ b/src/arm/debugger/memory-debugger.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "memory-debugger.h" +#include -#include "arm/debugger/debugger.h" +#include -#include "util/math.h" +#include #include diff --git a/src/arm/decoder-arm.c b/src/arm/decoder-arm.c index 3b082a0d2..bfbf65365 100644 --- a/src/arm/decoder-arm.c +++ b/src/arm/decoder-arm.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "decoder.h" +#include -#include "decoder-inlines.h" -#include "emitter-arm.h" -#include "isa-inlines.h" +#include +#include +#include #define ADDR_MODE_1_SHIFT(OP) \ info->op3.reg = opcode & 0x0000000F; \ diff --git a/src/arm/decoder-thumb.c b/src/arm/decoder-thumb.c index 707324023..a53da00e9 100644 --- a/src/arm/decoder-thumb.c +++ b/src/arm/decoder-thumb.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "decoder.h" +#include -#include "decoder-inlines.h" -#include "emitter-thumb.h" -#include "isa-inlines.h" +#include +#include +#include #define DEFINE_THUMB_DECODER(NAME, MNEMONIC, BODY) \ static void _ThumbDecode ## NAME (uint16_t opcode, struct ARMInstructionInfo* info) { \ diff --git a/src/arm/decoder.c b/src/arm/decoder.c index 8e5ef3f8d..5411c20f3 100644 --- a/src/arm/decoder.c +++ b/src/arm/decoder.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "decoder.h" +#include -#include "decoder-inlines.h" +#include #define ADVANCE(AMOUNT) \ if (AMOUNT > blen) { \ diff --git a/src/arm/isa-arm.c b/src/arm/isa-arm.c index d1f7b7c29..85323a1a1 100644 --- a/src/arm/isa-arm.c +++ b/src/arm/isa-arm.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "isa-arm.h" +#include -#include "arm.h" -#include "emitter-arm.h" -#include "isa-inlines.h" +#include +#include +#include #define PSR_USER_MASK 0xF0000000 #define PSR_PRIV_MASK 0x000000CF diff --git a/src/arm/isa-thumb.c b/src/arm/isa-thumb.c index 7c587f618..54faf6ddc 100644 --- a/src/arm/isa-thumb.c +++ b/src/arm/isa-thumb.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "isa-thumb.h" +#include -#include "isa-inlines.h" -#include "emitter-thumb.h" +#include +#include // Instruction definitions // Beware pre-processor insanity diff --git a/src/core/cheats.c b/src/core/cheats.c index efcbf4aa0..fe6e59c99 100644 --- a/src/core/cheats.c +++ b/src/core/cheats.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "cheats.h" +#include -#include "core/core.h" -#include "util/string.h" -#include "util/vfs.h" +#include +#include +#include #define MAX_LINE_LENGTH 128 diff --git a/src/core/config.c b/src/core/config.c index d66baddb3..0a2d146b3 100644 --- a/src/core/config.c +++ b/src/core/config.c @@ -3,12 +3,12 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "config.h" +#include -#include "core/version.h" -#include "util/formatting.h" -#include "util/string.h" -#include "util/vfs.h" +#include +#include +#include +#include #include @@ -24,7 +24,7 @@ #endif #ifdef _3DS -#include "platform/3ds/3ds-vfs.h" +#include #endif #define SECTION_NAME_MAX 128 diff --git a/src/core/core.c b/src/core/core.c index 835a88c25..433c213b8 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -3,19 +3,20 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "core.h" +#include -#include "core/log.h" -#include "core/serialize.h" -#include "util/vfs.h" +#include +#include +#include #ifdef M_CORE_GB -#include "gb/core.h" -#include "gb/gb.h" +#include +// TODO: Fix layering violation +#include #endif #ifdef M_CORE_GBA -#include "gba/core.h" -#include "gba/gba.h" +#include +#include #endif static struct mCoreFilter { @@ -62,7 +63,7 @@ enum mPlatform mCoreIsCompatible(struct VFile* vf) { } #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 -#include "util/png-io.h" +#include #ifdef PSP2 #include diff --git a/src/core/directories.c b/src/core/directories.c index db4ec1b26..ca261dbd9 100644 --- a/src/core/directories.c +++ b/src/core/directories.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "directories.h" +#include -#include "core/config.h" -#include "util/vfs.h" +#include +#include #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 void mDirectorySetInit(struct mDirectorySet* dirs) { diff --git a/src/core/input.c b/src/core/input.c index 4614e3549..86145f176 100644 --- a/src/core/input.c +++ b/src/core/input.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "input.h" +#include -#include "util/configuration.h" -#include "util/table.h" +#include +#include #include diff --git a/src/core/interface.c b/src/core/interface.c index 272afd948..66b372800 100644 --- a/src/core/interface.c +++ b/src/core/interface.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "interface.h" +#include -#include "core/core.h" +#include #include static time_t _rtcGenericCallback(struct mRTCSource* source) { diff --git a/src/core/library.c b/src/core/library.c index 995772cf9..425405bac 100644 --- a/src/core/library.c +++ b/src/core/library.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "library.h" +#include -#include "util/vfs.h" +#include DEFINE_VECTOR(mLibraryListing, struct mLibraryEntry); diff --git a/src/core/lockstep.c b/src/core/lockstep.c index 28bc03355..40b1f1e2e 100644 --- a/src/core/lockstep.c +++ b/src/core/lockstep.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "lockstep.h" +#include void mLockstepInit(struct mLockstep* lockstep) { lockstep->attached = 0; diff --git a/src/core/log.c b/src/core/log.c index 125907e9a..65ec99924 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "log.h" +#include -#include "core/thread.h" +#include #define MAX_CATEGORY 64 diff --git a/src/core/rewind.c b/src/core/rewind.c index e48b2eb8b..56a59e47d 100644 --- a/src/core/rewind.c +++ b/src/core/rewind.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "rewind.h" +#include -#include "core/core.h" -#include "util/patch-fast.h" -#include "util/vfs.h" +#include +#include +#include DEFINE_VECTOR(mCoreRewindPatches, struct PatchFast); diff --git a/src/core/serialize.c b/src/core/serialize.c index 14a3795ac..f5b143fec 100644 --- a/src/core/serialize.c +++ b/src/core/serialize.c @@ -3,15 +3,15 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "serialize.h" +#include -#include "core/core.h" -#include "core/cheats.h" -#include "util/memory.h" -#include "util/vfs.h" +#include +#include +#include +#include #ifdef USE_PNG -#include "util/png-io.h" +#include #include #include #endif diff --git a/src/core/sync.c b/src/core/sync.c index 640628024..5fc5e72d9 100644 --- a/src/core/sync.c +++ b/src/core/sync.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "sync.h" +#include static void _changeVideoSync(struct mCoreSync* sync, bool frameOn) { // Make sure the video thread can process events while the GBA thread is paused diff --git a/src/core/test/core.c b/src/core/test/core.c index 12f67a900..3fcebaf31 100644 --- a/src/core/test/core.c +++ b/src/core/test/core.c @@ -5,8 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "util/test/suite.h" -#include "core/core.h" -#include "util/vfs.h" +#include +#include #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 M_TEST_DEFINE(findNullPath) { diff --git a/src/core/test/core.h b/src/core/test/core.h index f5cbd16a0..add2a4c02 100644 --- a/src/core/test/core.h +++ b/src/core/test/core.h @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef TEST_M_CORE_H #define TEST_M_CORE_H -#include "util/common.h" +#include int TestRunCore(void); diff --git a/src/core/thread.c b/src/core/thread.c index 4c7eb90eb..f3509071e 100644 --- a/src/core/thread.c +++ b/src/core/thread.c @@ -3,13 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "thread.h" +#include -#include "core/core.h" -#include "util/patch.h" -#include "util/vfs.h" - -#include "feature/commandline.h" +#include +#include +#include #include diff --git a/src/core/tile-cache.c b/src/core/tile-cache.c index 17572fe0b..85c2f7032 100644 --- a/src/core/tile-cache.c +++ b/src/core/tile-cache.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "tile-cache.h" +#include -#include "util/memory.h" +#include void mTileCacheInit(struct mTileCache* cache) { // TODO: Reconfigurable cache for space savings diff --git a/src/core/timing.c b/src/core/timing.c index 384d92617..d7e7653bd 100644 --- a/src/core/timing.c +++ b/src/core/timing.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "timing.h" +#include void mTimingInit(struct mTiming* timing, int32_t* relativeCycles, int32_t* nextEvent) { timing->root = NULL; diff --git a/src/core/version.c.in b/src/core/version.c.in index 98fcd6428..b8c87fb70 100644 --- a/src/core/version.c.in +++ b/src/core/version.c.in @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "core/version.h" +#include const char* const gitCommit = "${GIT_COMMIT}"; const char* const gitCommitShort = "${GIT_COMMIT_SHORT}"; diff --git a/src/debugger/cli-debugger.c b/src/debugger/cli-debugger.c index 8f5a7d6b6..d5b6dc535 100644 --- a/src/debugger/cli-debugger.c +++ b/src/debugger/cli-debugger.c @@ -3,12 +3,12 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "cli-debugger.h" +#include -#include "core/core.h" -#include "core/version.h" -#include "debugger/parser.h" -#include "util/string.h" +#include +#include +#include +#include #if !defined(NDEBUG) && !defined(_WIN32) #include diff --git a/src/debugger/debugger.c b/src/debugger/debugger.c index 6ddbc7dcb..0e7e3fc1a 100644 --- a/src/debugger/debugger.c +++ b/src/debugger/debugger.c @@ -3,14 +3,14 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "debugger.h" +#include -#include "core/core.h" +#include -#include "debugger/cli-debugger.h" +#include #ifdef USE_GDB_STUB -#include "debugger/gdb-stub.h" +#include #endif const uint32_t DEBUGGER_ID = 0xDEADBEEF; diff --git a/src/debugger/gdb-stub.c b/src/debugger/gdb-stub.c index 227418176..b497c24d7 100644 --- a/src/debugger/gdb-stub.c +++ b/src/debugger/gdb-stub.c @@ -3,12 +3,12 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "gdb-stub.h" +#include -#include "arm/debugger/debugger.h" -#include "arm/isa-inlines.h" -#include "core/core.h" -#include "gba/memory.h" +#include +#include +#include +#include #include diff --git a/src/debugger/parser.c b/src/debugger/parser.c index 4d3cfd6b2..a755af505 100644 --- a/src/debugger/parser.c +++ b/src/debugger/parser.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "parser.h" +#include -#include "util/string.h" +#include static struct LexVector* _lexOperator(struct LexVector* lv, char operator) { struct LexVector* lvNext = malloc(sizeof(struct LexVector)); diff --git a/src/feature/commandline.c b/src/feature/commandline.c index 9fc75bacb..ae9f72c18 100644 --- a/src/feature/commandline.c +++ b/src/feature/commandline.c @@ -5,13 +5,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "commandline.h" -#include "core/config.h" -#include "core/version.h" -#include "util/string.h" +#include +#include +#include #include #ifdef _MSC_VER -#include "platform/windows/getopt.h" +#include #else #include #endif diff --git a/src/feature/commandline.h b/src/feature/commandline.h index 0b672eb34..322c8e87b 100644 --- a/src/feature/commandline.h +++ b/src/feature/commandline.h @@ -6,11 +6,11 @@ #ifndef COMMAND_LINE_H #define COMMAND_LINE_H -#include "util/common.h" +#include CXX_GUARD_START -#include "debugger/debugger.h" +#include struct mArguments { char* fname; diff --git a/src/feature/editline/cli-el-backend.c b/src/feature/editline/cli-el-backend.c index ac0a935d4..530019b03 100644 --- a/src/feature/editline/cli-el-backend.c +++ b/src/feature/editline/cli-el-backend.c @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "cli-el-backend.h" -#include "core/version.h" +#include #include diff --git a/src/feature/editline/cli-el-backend.h b/src/feature/editline/cli-el-backend.h index 68fb32a1c..89ceec641 100644 --- a/src/feature/editline/cli-el-backend.h +++ b/src/feature/editline/cli-el-backend.h @@ -6,11 +6,11 @@ #ifndef CLI_EL_BACKEND_H #define CLI_EL_BACKEND_H -#include "util/common.h" +#include CXX_GUARD_START -#include "debugger/cli-debugger.h" +#include #include diff --git a/src/feature/ffmpeg/ffmpeg-encoder.c b/src/feature/ffmpeg/ffmpeg-encoder.c index ac239f650..a902d6abf 100644 --- a/src/feature/ffmpeg/ffmpeg-encoder.c +++ b/src/feature/ffmpeg/ffmpeg-encoder.c @@ -5,8 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ffmpeg-encoder.h" -#include "core/core.h" -#include "gba/video.h" +#include +#include #include #include diff --git a/src/feature/ffmpeg/ffmpeg-encoder.h b/src/feature/ffmpeg/ffmpeg-encoder.h index b8017769f..feeeddc77 100644 --- a/src/feature/ffmpeg/ffmpeg-encoder.h +++ b/src/feature/ffmpeg/ffmpeg-encoder.h @@ -6,11 +6,11 @@ #ifndef FFMPEG_ENCODER #define FFMPEG_ENCODER -#include "util/common.h" +#include CXX_GUARD_START -#include "gba/gba.h" +#include #include #include diff --git a/src/feature/gui/gui-config.c b/src/feature/gui/gui-config.c index 16f13a2f9..9d4e39fb2 100644 --- a/src/feature/gui/gui-config.c +++ b/src/feature/gui/gui-config.c @@ -5,13 +5,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "gui-config.h" -#include "core/config.h" -#include "core/core.h" +#include +#include #include "feature/gui/gui-runner.h" #include "feature/gui/remap.h" -#include "gba/gba.h" -#include "util/gui/file-select.h" -#include "util/gui/menu.h" +#include +#include +#include #ifndef GUI_MAX_INPUTS #define GUI_MAX_INPUTS 7 diff --git a/src/feature/gui/gui-config.h b/src/feature/gui/gui-config.h index 539bd109e..f869e1c46 100644 --- a/src/feature/gui/gui-config.h +++ b/src/feature/gui/gui-config.h @@ -6,7 +6,7 @@ #ifndef GUI_CONFIG_H #define GUI_CONFIG_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/feature/gui/gui-runner.c b/src/feature/gui/gui-runner.c index 2a0ee06a7..0fce5b791 100644 --- a/src/feature/gui/gui-runner.c +++ b/src/feature/gui/gui-runner.c @@ -5,18 +5,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "gui-runner.h" -#include "core/core.h" -#include "core/serialize.h" +#include +#include #include "feature/gui/gui-config.h" -#include "gba/gba.h" -#include "gba/input.h" -#include "gba/interface.h" -#include "util/gui/file-select.h" -#include "util/gui/font.h" -#include "util/gui/menu.h" -#include "util/memory.h" -#include "util/png-io.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef _3DS #include <3ds.h> diff --git a/src/feature/gui/gui-runner.h b/src/feature/gui/gui-runner.h index 1293b1e97..0a288951f 100644 --- a/src/feature/gui/gui-runner.h +++ b/src/feature/gui/gui-runner.h @@ -6,15 +6,15 @@ #ifndef GUI_RUNNER_H #define GUI_RUNNER_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/config.h" +#include #include "feature/gui/remap.h" -#include "gba/hardware.h" -#include "util/circle-buffer.h" -#include "util/gui.h" +#include +#include +#include enum mGUIInput { mGUI_INPUT_INCREASE_BRIGHTNESS = GUI_INPUT_USER_START, diff --git a/src/feature/gui/remap.c b/src/feature/gui/remap.c index 2db8517fa..b17560319 100644 --- a/src/feature/gui/remap.c +++ b/src/feature/gui/remap.c @@ -5,8 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "remap.h" -#include "util/gui.h" -#include "util/gui/menu.h" +#include +#include void mGUIRemapKeys(struct GUIParams* params, struct mInputMap* map, const struct GUIInputKeys* keys) { struct GUIMenu menu = { diff --git a/src/feature/gui/remap.h b/src/feature/gui/remap.h index de0cd6e8a..a604c3950 100644 --- a/src/feature/gui/remap.h +++ b/src/feature/gui/remap.h @@ -6,7 +6,7 @@ #ifndef GUI_REMAP_H #define GUI_REMAP_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/feature/imagemagick/imagemagick-gif-encoder.c b/src/feature/imagemagick/imagemagick-gif-encoder.c index ccd8ea426..faa44d9d9 100644 --- a/src/feature/imagemagick/imagemagick-gif-encoder.c +++ b/src/feature/imagemagick/imagemagick-gif-encoder.c @@ -5,9 +5,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "imagemagick-gif-encoder.h" -#include "gba/gba.h" -#include "gba/video.h" -#include "util/string.h" +#include +#include +#include static void _magickPostVideoFrame(struct mAVStream*, const color_t* pixels, size_t stride); static void _magickVideoDimensionsChanged(struct mAVStream*, unsigned width, unsigned height); diff --git a/src/feature/imagemagick/imagemagick-gif-encoder.h b/src/feature/imagemagick/imagemagick-gif-encoder.h index 366c8f6b7..13505e6db 100644 --- a/src/feature/imagemagick/imagemagick-gif-encoder.h +++ b/src/feature/imagemagick/imagemagick-gif-encoder.h @@ -6,11 +6,11 @@ #ifndef IMAGEMAGICK_GIF_ENCODER #define IMAGEMAGICK_GIF_ENCODER -#include "util/common.h" +#include CXX_GUARD_START -#include "core/interface.h" +#include #define MAGICKCORE_HDRI_ENABLE 0 #define MAGICKCORE_QUANTUM_DEPTH 8 diff --git a/src/gb/audio.c b/src/gb/audio.c index 14f501096..183927730 100644 --- a/src/gb/audio.c +++ b/src/gb/audio.c @@ -3,13 +3,14 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "audio.h" +#include -#include "core/interface.h" -#include "core/sync.h" -#include "gb/gb.h" -#include "gb/serialize.h" -#include "gb/io.h" +#include +#include +#include +#include +#include +#include #ifdef _3DS #define blip_add_delta blip_add_delta_fast diff --git a/src/gb/cheats.c b/src/gb/cheats.c index a29711c61..118ddde20 100644 --- a/src/gb/cheats.c +++ b/src/gb/cheats.c @@ -3,12 +3,12 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "cheats.h" +#include -#include "core/core.h" -#include "gb/gb.h" -#include "gb/memory.h" -#include "util/string.h" +#include +#include +#include +#include DEFINE_VECTOR(GBCheatPatchList, struct GBCheatPatch); diff --git a/src/gb/core.c b/src/gb/core.c index fabe88f8c..6380f9ff1 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -3,21 +3,22 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "core.h" +#include -#include "core/core.h" -#include "gb/cheats.h" -#include "gb/extra/cli.h" -#include "gb/gb.h" -#include "gb/mbc.h" -#include "gb/overrides.h" -#include "gb/renderers/software.h" -#include "gb/serialize.h" -#include "lr35902/debugger/debugger.h" -#include "util/crc32.h" -#include "util/memory.h" -#include "util/patch.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include struct GBCore { struct mCore d; diff --git a/src/gb/extra/cli.c b/src/gb/extra/cli.c index 0f8f7d945..78e10a1b6 100644 --- a/src/gb/extra/cli.c +++ b/src/gb/extra/cli.c @@ -3,14 +3,14 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "cli.h" +#include -#include "core/core.h" -#include "core/serialize.h" -#include "gb/gb.h" -#include "gb/io.h" -#include "gb/video.h" -#include "lr35902/debugger/cli-debugger.h" +#include +#include +#include +#include +#include +#include static void _GBCLIDebuggerInit(struct CLIDebuggerSystem*); static bool _GBCLIDebuggerCustom(struct CLIDebuggerSystem*); diff --git a/src/gb/gb.c b/src/gb/gb.c index 6a47ccf63..e53a7e579 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -3,18 +3,19 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "gb.h" +#include -#include "gb/io.h" -#include "gb/mbc.h" +#include +#include +#include -#include "core/core.h" -#include "core/cheats.h" -#include "util/crc32.h" -#include "util/memory.h" -#include "util/math.h" -#include "util/patch.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include +#include +#include #define CLEANUP_THRESHOLD 15 diff --git a/src/gb/io.c b/src/gb/io.c index 4a3d5e59d..82f3855ef 100644 --- a/src/gb/io.c +++ b/src/gb/io.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "io.h" +#include -#include "gb/gb.h" -#include "gb/sio.h" -#include "gb/serialize.h" +#include +#include +#include mLOG_DEFINE_CATEGORY(GB_IO, "GB I/O"); diff --git a/src/gb/mbc.c b/src/gb/mbc.c index 9357fcbe3..0ae353b05 100644 --- a/src/gb/mbc.c +++ b/src/gb/mbc.c @@ -3,11 +3,12 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "mbc.h" +#include -#include "gb/gb.h" -#include "gb/memory.h" -#include "util/vfs.h" +#include +#include +#include +#include mLOG_DEFINE_CATEGORY(GB_MBC, "GB MBC"); diff --git a/src/gb/memory.c b/src/gb/memory.c index 3b2656001..0334e136e 100644 --- a/src/gb/memory.c +++ b/src/gb/memory.c @@ -3,15 +3,16 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "memory.h" +#include -#include "core/interface.h" -#include "gb/gb.h" -#include "gb/io.h" -#include "gb/mbc.h" -#include "gb/serialize.h" +#include +#include +#include +#include +#include +#include -#include "util/memory.h" +#include mLOG_DEFINE_CATEGORY(GB_MEM, "GB Memory"); diff --git a/src/gb/overrides.c b/src/gb/overrides.c index 9e19b7d87..d86f08f5f 100644 --- a/src/gb/overrides.c +++ b/src/gb/overrides.c @@ -3,12 +3,12 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "overrides.h" +#include -#include "gb/gb.h" +#include -#include "util/configuration.h" -#include "util/crc32.h" +#include +#include static const struct GBCartridgeOverride _overrides[] = { // None yet diff --git a/src/gb/renderers/software.c b/src/gb/renderers/software.c index 1e6f914fc..61daa9f98 100644 --- a/src/gb/renderers/software.c +++ b/src/gb/renderers/software.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "software.h" +#include -#include "core/tile-cache.h" -#include "gb/io.h" -#include "util/memory.h" +#include +#include +#include static void GBVideoSoftwareRendererInit(struct GBVideoRenderer* renderer, enum GBModel model); static void GBVideoSoftwareRendererDeinit(struct GBVideoRenderer* renderer); diff --git a/src/gb/renderers/tile-cache.c b/src/gb/renderers/tile-cache.c index b10ee972d..4780649b8 100644 --- a/src/gb/renderers/tile-cache.c +++ b/src/gb/renderers/tile-cache.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "tile-cache.h" +#include -#include "core/tile-cache.h" -#include "gb/video.h" -#include "gb/renderers/tile-cache.h" +#include +#include +#include void GBVideoTileCacheInit(struct mTileCache* cache) { mTileCacheInit(cache); diff --git a/src/gb/serialize.c b/src/gb/serialize.c index abec007ac..61b4b5a09 100644 --- a/src/gb/serialize.c +++ b/src/gb/serialize.c @@ -3,10 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "serialize.h" +#include -#include "gb/io.h" -#include "gb/timer.h" +#include +#include +#include mLOG_DEFINE_CATEGORY(GB_STATE, "GB Savestate"); diff --git a/src/gb/sio.c b/src/gb/sio.c index f25cb3b96..944064752 100644 --- a/src/gb/sio.c +++ b/src/gb/sio.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "sio.h" +#include -#include "gb/gb.h" -#include "gb/io.h" -#include "gb/serialize.h" +#include +#include +#include mLOG_DEFINE_CATEGORY(GB_SIO, "GB Serial I/O"); diff --git a/src/gb/sio/lockstep.c b/src/gb/sio/lockstep.c index d52401a66..c60978ffe 100644 --- a/src/gb/sio/lockstep.c +++ b/src/gb/sio/lockstep.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "lockstep.h" +#include -#include "gb/gb.h" -#include "gb/io.h" +#include +#include #define LOCKSTEP_INCREMENT 512 diff --git a/src/gb/test/core.c b/src/gb/test/core.c index c5ed2fdfa..09f9ca25a 100644 --- a/src/gb/test/core.c +++ b/src/gb/test/core.c @@ -5,10 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "util/test/suite.h" -#include "core/core.h" -#include "gb/core.h" -#include "gb/gb.h" -#include "util/vfs.h" +#include +#include +#include +#include M_TEST_DEFINE(create) { struct mCore* core = GBCoreCreate(); diff --git a/src/gb/test/gb.h b/src/gb/test/gb.h index 2bb574f01..572a21466 100644 --- a/src/gb/test/gb.h +++ b/src/gb/test/gb.h @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef TEST_GB_H #define TEST_GB_H -#include "util/common.h" +#include int TestRunGB(void); diff --git a/src/gb/test/mbc.c b/src/gb/test/mbc.c index d4e94b401..a9448892b 100644 --- a/src/gb/test/mbc.c +++ b/src/gb/test/mbc.c @@ -5,11 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "util/test/suite.h" -#include "core/core.h" -#include "gb/core.h" -#include "gb/gb.h" -#include "gb/mbc.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include M_TEST_SUITE_SETUP(GBMBC) { struct VFile* vf = VFileMemChunk(NULL, 2048); diff --git a/src/gb/test/memory.c b/src/gb/test/memory.c index 35768916a..f4e0ee642 100644 --- a/src/gb/test/memory.c +++ b/src/gb/test/memory.c @@ -5,11 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "util/test/suite.h" -#include "core/core.h" -#include "gb/core.h" -#include "gb/gb.h" -#include "gb/mbc.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include M_TEST_SUITE_SETUP(GBMemory) { struct VFile* vf = VFileMemChunk(NULL, GB_SIZE_CART_BANK0 * 4); diff --git a/src/gb/test/rtc.c b/src/gb/test/rtc.c index 8e6010775..5ad393a64 100644 --- a/src/gb/test/rtc.c +++ b/src/gb/test/rtc.c @@ -5,11 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "util/test/suite.h" -#include "core/core.h" -#include "gb/core.h" -#include "gb/gb.h" -#include "gb/mbc.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include struct GBRTCTest { struct mRTCSource d; diff --git a/src/gb/timer.c b/src/gb/timer.c index 3426cafad..0cd2571a9 100644 --- a/src/gb/timer.c +++ b/src/gb/timer.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "timer.h" +#include -#include "gb/gb.h" -#include "gb/io.h" -#include "gb/serialize.h" +#include +#include +#include void _GBTimerIRQ(struct mTiming* timing, void* context, uint32_t cyclesLate) { UNUSED(timing); diff --git a/src/gb/video.c b/src/gb/video.c index 37e58b5a8..cfabfe4ce 100644 --- a/src/gb/video.c +++ b/src/gb/video.c @@ -3,16 +3,17 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "video.h" +#include -#include "core/sync.h" -#include "core/thread.h" -#include "core/tile-cache.h" -#include "gb/gb.h" -#include "gb/io.h" -#include "gb/serialize.h" +#include +#include +#include +#include +#include +#include +#include -#include "util/memory.h" +#include static void GBVideoDummyRendererInit(struct GBVideoRenderer* renderer, enum GBModel model); static void GBVideoDummyRendererDeinit(struct GBVideoRenderer* renderer); diff --git a/src/gba/audio.c b/src/gba/audio.c index 9f01889ed..52d99d883 100644 --- a/src/gba/audio.c +++ b/src/gba/audio.c @@ -3,14 +3,16 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "audio.h" +#include -#include "core/sync.h" -#include "gba/dma.h" -#include "gba/gba.h" -#include "gba/io.h" -#include "gba/serialize.h" -#include "gba/video.h" +#include +#include +#include +#include +#include +#include +#include +#include #ifdef _3DS #define blip_add_delta blip_add_delta_fast diff --git a/src/gba/bios.c b/src/gba/bios.c index a61cf88d8..83e43b302 100644 --- a/src/gba/bios.c +++ b/src/gba/bios.c @@ -3,13 +3,13 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "bios.h" +#include -#include "arm/isa-inlines.h" -#include "arm/macros.h" -#include "gba/gba.h" -#include "gba/io.h" -#include "gba/memory.h" +#include +#include +#include +#include +#include const uint32_t GBA_BIOS_CHECKSUM = 0xBAAE187F; const uint32_t GBA_DS_BIOS_CHECKSUM = 0xBAAE1880; diff --git a/src/gba/cheats.c b/src/gba/cheats.c index 8b5f5804b..2e1a30b54 100644 --- a/src/gba/cheats.c +++ b/src/gba/cheats.c @@ -3,13 +3,13 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "cheats.h" +#include -#include "core/core.h" +#include +#include +#include #include "gba/cheats/gameshark.h" #include "gba/cheats/parv3.h" -#include "gba/gba.h" -#include "util/string.h" #define MAX_LINE_LENGTH 128 diff --git a/src/gba/cheats/codebreaker.c b/src/gba/cheats/codebreaker.c index 5c7f6fb58..bca859b68 100644 --- a/src/gba/cheats/codebreaker.c +++ b/src/gba/cheats/codebreaker.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "gba/cheats.h" +#include -#include "gba/gba.h" -#include "gba/io.h" -#include "util/string.h" +#include +#include +#include static void _cbLoadByteswap(uint8_t* buffer, uint32_t op1, uint16_t op2) { buffer[0] = op1 >> 24; diff --git a/src/gba/cheats/gameshark.c b/src/gba/cheats/gameshark.c index 58dcb749c..1fc476aff 100644 --- a/src/gba/cheats/gameshark.c +++ b/src/gba/cheats/gameshark.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "gameshark.h" +#include #include "gba/cheats/parv3.h" -#include "gba/gba.h" -#include "util/string.h" +#include +#include const uint32_t GBACheatGameSharkSeeds[4] = { 0x09F4FBBD, 0x9681884A, 0x352027E9, 0xF3DEE5A7 }; diff --git a/src/gba/cheats/gameshark.h b/src/gba/cheats/gameshark.h index 86736f492..af4d10469 100644 --- a/src/gba/cheats/gameshark.h +++ b/src/gba/cheats/gameshark.h @@ -6,14 +6,13 @@ #ifndef GBA_CHEATS_GAMESHARK_H #define GBA_CHEATS_GAMESHARK_H -#include "util/common.h" +#include CXX_GUARD_START -#include "gba/cheats.h" - extern const uint32_t GBACheatGameSharkSeeds[4]; +struct GBACheatSet; void GBACheatDecryptGameShark(uint32_t* op1, uint32_t* op2, const uint32_t* seeds); void GBACheatReseedGameShark(uint32_t* seeds, uint16_t params, const uint8_t* t1, const uint8_t* t2); void GBACheatSetGameSharkVersion(struct GBACheatSet* cheats, int version); diff --git a/src/gba/cheats/parv3.c b/src/gba/cheats/parv3.c index 5cad2b342..ccd6c34b0 100644 --- a/src/gba/cheats/parv3.c +++ b/src/gba/cheats/parv3.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "parv3.h" +#include #include "gba/cheats/gameshark.h" -#include "gba/gba.h" -#include "util/string.h" +#include +#include const uint32_t GBACheatProActionReplaySeeds[4] = { 0x7AA9648F, 0x7FAE6994, 0xC0EFAAD5, 0x42712C57 }; diff --git a/src/gba/cheats/parv3.h b/src/gba/cheats/parv3.h index 2723d673f..814f9b1df 100644 --- a/src/gba/cheats/parv3.h +++ b/src/gba/cheats/parv3.h @@ -6,14 +6,13 @@ #ifndef GBA_CHEATS_PARV3_H #define GBA_CHEATS_PARV3_H -#include "util/common.h" +#include CXX_GUARD_START -#include "gba/cheats.h" - extern const uint32_t GBACheatProActionReplaySeeds[4]; +struct GBACheatSet; bool GBACheatAddProActionReplayRaw(struct GBACheatSet* cheats, uint32_t op1, uint32_t op2); int GBACheatProActionReplayProbability(uint32_t op1, uint32_t op2); diff --git a/src/gba/core.c b/src/gba/core.c index a3f5b4441..52b7be0d9 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -3,24 +3,24 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "core.h" +#include -#include "core/core.h" -#include "core/log.h" -#include "arm/debugger/debugger.h" -#include "gba/cheats.h" -#include "gba/gba.h" -#include "gba/extra/cli.h" -#include "gba/overrides.h" +#include +#include +#include +#include +#include +#include +#include #ifndef DISABLE_THREADING -#include "gba/renderers/thread-proxy.h" +#include #endif -#include "gba/renderers/video-software.h" -#include "gba/savedata.h" -#include "gba/serialize.h" -#include "util/memory.h" -#include "util/patch.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include +#include struct GBACore { struct mCore d; diff --git a/src/gba/dma.c b/src/gba/dma.c index 7560bdb2f..5c5499ebf 100644 --- a/src/gba/dma.c +++ b/src/gba/dma.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "dma.h" +#include -#include "gba/gba.h" -#include "gba/io.h" +#include +#include static void _dmaEvent(struct mTiming* timing, void* context, uint32_t cyclesLate); diff --git a/src/gba/extra/cli.c b/src/gba/extra/cli.c index ca16a9117..a9ad7841b 100644 --- a/src/gba/extra/cli.c +++ b/src/gba/extra/cli.c @@ -3,12 +3,14 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "cli.h" +#include -#include "arm/debugger/cli-debugger.h" -#include "core/serialize.h" -#include "gba/io.h" -#include "gba/serialize.h" +#include +#include +#include +#include +#include +#include static void _GBACLIDebuggerInit(struct CLIDebuggerSystem*); static bool _GBACLIDebuggerCustom(struct CLIDebuggerSystem*); diff --git a/src/gba/gba.c b/src/gba/gba.c index e1c379fc6..857552ed2 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -3,29 +3,23 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "gba.h" +#include -#include "core/thread.h" +#include +#include +#include -#include "arm/decoder.h" -#include "arm/debugger/debugger.h" -#include "arm/isa-inlines.h" +#include +#include +#include +#include +#include -#include "gba/bios.h" -#include "gba/cheats.h" -#include "gba/io.h" -#include "gba/overrides.h" -#include "gba/rr/rr.h" -#include "gba/serialize.h" -#include "gba/sio.h" -#include "gba/timer.h" -#include "gba/vfame.h" - -#include "util/crc32.h" -#include "util/memory.h" -#include "util/math.h" -#include "util/patch.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include mLOG_DEFINE_CATEGORY(GBA, "GBA"); mLOG_DEFINE_CATEGORY(GBA_DEBUG, "GBA Debug"); diff --git a/src/gba/hardware.c b/src/gba/hardware.c index a47339ba7..5c9032de4 100644 --- a/src/gba/hardware.c +++ b/src/gba/hardware.c @@ -3,12 +3,13 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "hardware.h" +#include -#include "gba/io.h" -#include "gba/serialize.h" -#include "util/formatting.h" -#include "util/hash.h" +#include +#include +#include +#include +#include mLOG_DEFINE_CATEGORY(GBA_HW, "GBA Pak Hardware"); diff --git a/src/gba/hle-bios.c b/src/gba/hle-bios.c index eff5e682f..be450acd4 100644 --- a/src/gba/hle-bios.c +++ b/src/gba/hle-bios.c @@ -1,6 +1,6 @@ #include "hle-bios.h" -#include "gba/memory.h" +#include const uint8_t hleBios[SIZE_BIOS] = { 0x06, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x0b, 0x00, 0x00, 0xea, diff --git a/src/gba/hle-bios.h b/src/gba/hle-bios.h index a696d7f6b..cc15e2f5c 100644 --- a/src/gba/hle-bios.h +++ b/src/gba/hle-bios.h @@ -6,7 +6,7 @@ #ifndef HLE_BIOS_H #define HLE_BIOS_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/gba/hle-bios.make b/src/gba/hle-bios.make index 20c2b50e3..1022c4c12 100644 --- a/src/gba/hle-bios.make +++ b/src/gba/hle-bios.make @@ -13,6 +13,6 @@ hle-bios.bin: hle-bios.o hle-bios.c: hle-bios.bin echo '#include "hle-bios.h"' > $@ echo >> $@ - echo '#include "gba/memory.h"' >> $@ + echo '#include ' >> $@ echo >> $@ xxd -i $< | sed -e 's/unsigned char hle_bios_bin\[\]/const uint8_t hleBios[SIZE_BIOS]/' | grep -v hle_bios_bin_len >> $@ diff --git a/src/gba/input.c b/src/gba/input.c index e21d0b774..c478e4a05 100644 --- a/src/gba/input.c +++ b/src/gba/input.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "input.h" +#include -#include "gba/interface.h" +#include const struct mInputPlatformInfo GBAInputInfo = { .platformName = "gba", diff --git a/src/gba/io.c b/src/gba/io.c index c705a3cc3..c788fb243 100644 --- a/src/gba/io.c +++ b/src/gba/io.c @@ -3,13 +3,13 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "io.h" +#include -#include "gba/dma.h" -#include "gba/rr/rr.h" -#include "gba/serialize.h" -#include "gba/sio.h" -#include "gba/video.h" +#include +#include +#include +#include +#include mLOG_DEFINE_CATEGORY(GBA_IO, "GBA I/O"); diff --git a/src/gba/memory.c b/src/gba/memory.c index 53ceeb3e9..674ba5a7d 100644 --- a/src/gba/memory.c +++ b/src/gba/memory.c @@ -3,17 +3,19 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "memory.h" +#include -#include "arm/decoder.h" -#include "gba/dma.h" -#include "gba/hardware.h" -#include "gba/io.h" -#include "gba/serialize.h" +#include +#include +#include +#include +#include +#include #include "gba/hle-bios.h" -#include "util/math.h" -#include "util/memory.h" -#include "util/vfs.h" + +#include +#include +#include #define IDLE_LOOP_THRESHOLD 10000 diff --git a/src/gba/overrides.c b/src/gba/overrides.c index c83f3d9c0..787690945 100644 --- a/src/gba/overrides.c +++ b/src/gba/overrides.c @@ -3,12 +3,12 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "overrides.h" +#include -#include "gba/gba.h" -#include "gba/hardware.h" +#include +#include -#include "util/configuration.h" +#include static const struct GBACartridgeOverride _overrides[] = { // Advance Wars diff --git a/src/gba/renderers/software-bg.c b/src/gba/renderers/software-bg.c index ef0c69413..f22a3a589 100644 --- a/src/gba/renderers/software-bg.c +++ b/src/gba/renderers/software-bg.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "software-private.h" +#include "gba/renderers/software-private.h" -#include "gba/gba.h" +#include #define MODE_2_COORD_OVERFLOW \ localX = x & (sizeAdjusted - 1); \ diff --git a/src/gba/renderers/software-mode0.c b/src/gba/renderers/software-mode0.c index 704ef3d61..74db03180 100644 --- a/src/gba/renderers/software-mode0.c +++ b/src/gba/renderers/software-mode0.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "software-private.h" +#include "gba/renderers/software-private.h" -#include "gba/gba.h" +#include #define BACKGROUND_TEXT_SELECT_CHARACTER \ localX = tileX * 8 + inX; \ diff --git a/src/gba/renderers/software-obj.c b/src/gba/renderers/software-obj.c index fccc108c0..f3ee2bd49 100644 --- a/src/gba/renderers/software-obj.c +++ b/src/gba/renderers/software-obj.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "software-private.h" +#include "gba/renderers/software-private.h" #define SPRITE_NORMAL_LOOP(DEPTH, TYPE) \ SPRITE_YBASE_ ## DEPTH(inY); \ diff --git a/src/gba/renderers/software-private.h b/src/gba/renderers/software-private.h index b387e78bc..582af7329 100644 --- a/src/gba/renderers/software-private.h +++ b/src/gba/renderers/software-private.h @@ -6,7 +6,8 @@ #ifndef SOFTWARE_PRIVATE_H #define SOFTWARE_PRIVATE_H -#include "video-software.h" +#include +#include #ifdef NDEBUG #define VIDEO_CHECKS false diff --git a/src/gba/renderers/thread-proxy.c b/src/gba/renderers/thread-proxy.c index 1221dec5c..15c8bba0e 100644 --- a/src/gba/renderers/thread-proxy.c +++ b/src/gba/renderers/thread-proxy.c @@ -3,13 +3,13 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "thread-proxy.h" +#include -#include "core/tile-cache.h" -#include "gba/io.h" -#include "gba/renderers/tile-cache.h" +#include +#include +#include -#include "util/memory.h" +#include #ifndef DISABLE_THREADING diff --git a/src/gba/renderers/tile-cache.c b/src/gba/renderers/tile-cache.c index e39e727ed..20e24849a 100644 --- a/src/gba/renderers/tile-cache.c +++ b/src/gba/renderers/tile-cache.c @@ -3,11 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "tile-cache.h" +#include -#include "core/tile-cache.h" -#include "gba/video.h" -#include "gba/renderers/tile-cache.h" +#include +#include void GBAVideoTileCacheInit(struct mTileCache* cache) { mTileCacheInit(cache); diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index 8b1fdd5d0..3e04be736 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -3,15 +3,14 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "software-private.h" +#include "gba/renderers/software-private.h" -#include "core/tile-cache.h" -#include "gba/gba.h" -#include "gba/io.h" -#include "gba/renderers/tile-cache.h" +#include +#include +#include -#include "util/arm-algo.h" -#include "util/memory.h" +#include +#include static void GBAVideoSoftwareRendererInit(struct GBAVideoRenderer* renderer); static void GBAVideoSoftwareRendererDeinit(struct GBAVideoRenderer* renderer); diff --git a/src/gba/rr/mgm.c b/src/gba/rr/mgm.c index c578c1b5e..d56e979bb 100644 --- a/src/gba/rr/mgm.c +++ b/src/gba/rr/mgm.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "mgm.h" +#include -#include "gba/gba.h" -#include "gba/serialize.h" -#include "util/vfs.h" +#include +#include +#include #define BINARY_EXT ".mgm" #define BINARY_MAGIC "GBAb" diff --git a/src/gba/rr/rr.c b/src/gba/rr/rr.c index f2af0a0d4..da6c48349 100644 --- a/src/gba/rr/rr.c +++ b/src/gba/rr/rr.c @@ -3,10 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "rr.h" +#include -#include "core/serialize.h" -#include "util/vfs.h" +#include +#include +#include mLOG_DEFINE_CATEGORY(GBA_RR, "GBA RR"); diff --git a/src/gba/rr/vbm.c b/src/gba/rr/vbm.c index c9ebca2e4..2845b74bc 100644 --- a/src/gba/rr/vbm.c +++ b/src/gba/rr/vbm.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "vbm.h" +#include -#include "gba/gba.h" -#include "gba/serialize.h" -#include "util/vfs.h" +#include +#include +#include #ifdef USE_ZLIB #include diff --git a/src/gba/savedata.c b/src/gba/savedata.c index 63666161a..f84246f2b 100644 --- a/src/gba/savedata.c +++ b/src/gba/savedata.c @@ -3,13 +3,14 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "savedata.h" +#include -#include "gba/gba.h" -#include "gba/serialize.h" +#include +#include +#include -#include "util/memory.h" -#include "util/vfs.h" +#include +#include #include #include diff --git a/src/gba/serialize.c b/src/gba/serialize.c index efa931212..77f7bc968 100644 --- a/src/gba/serialize.c +++ b/src/gba/serialize.c @@ -3,17 +3,14 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "serialize.h" +#include -#include "core/serialize.h" -#include "gba/audio.h" -#include "gba/cheats.h" -#include "gba/io.h" -#include "gba/rr/rr.h" -#include "gba/video.h" +#include +#include +#include -#include "util/memory.h" -#include "util/vfs.h" +#include +#include #include #ifdef _MSC_VER diff --git a/src/gba/sharkport.c b/src/gba/sharkport.c index 5284e57b1..4ada2360c 100644 --- a/src/gba/sharkport.c +++ b/src/gba/sharkport.c @@ -3,10 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "sharkport.h" +#include -#include "gba/gba.h" -#include "util/vfs.h" +#include +#include +#include static const char* const SHARKPORT_HEADER = "SharkPortSave"; diff --git a/src/gba/sio.c b/src/gba/sio.c index 1e191e93c..661d9d09b 100644 --- a/src/gba/sio.c +++ b/src/gba/sio.c @@ -3,9 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "sio.h" +#include -#include "gba/io.h" +#include +#include mLOG_DEFINE_CATEGORY(GBA_SIO, "GBA Serial I/O"); diff --git a/src/gba/sio/lockstep.c b/src/gba/sio/lockstep.c index 142222a7b..c196fc3fa 100644 --- a/src/gba/sio/lockstep.c +++ b/src/gba/sio/lockstep.c @@ -3,11 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "lockstep.h" +#include -#include "gba/gba.h" -#include "gba/io.h" -#include "gba/video.h" +#include +#include #define LOCKSTEP_INCREMENT 3000 diff --git a/src/gba/test/core.c b/src/gba/test/core.c index 5864f3d05..acb0165af 100644 --- a/src/gba/test/core.c +++ b/src/gba/test/core.c @@ -5,8 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "util/test/suite.h" -#include "core/core.h" -#include "gba/core.h" +#include +#include M_TEST_DEFINE(create) { struct mCore* core = GBACoreCreate(); diff --git a/src/gba/test/gba.h b/src/gba/test/gba.h index c769e5320..1e50b1d39 100644 --- a/src/gba/test/gba.h +++ b/src/gba/test/gba.h @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef TEST_GBA_H #define TEST_GBA_H -#include "util/common.h" +#include int TestRunGBA(void); diff --git a/src/gba/timer.c b/src/gba/timer.c index 3ae17f50c..49722ed4d 100644 --- a/src/gba/timer.c +++ b/src/gba/timer.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "timer.h" +#include -#include "gba/gba.h" -#include "gba/io.h" +#include +#include static void GBATimerUpdate(struct mTiming* timing, struct GBA* gba, int timerId, uint32_t cyclesLate) { struct GBATimer* timer = &gba->timers[timerId]; diff --git a/src/gba/vfame.c b/src/gba/vfame.c index ae8b44cca..9dc6def16 100644 --- a/src/gba/vfame.c +++ b/src/gba/vfame.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include -#include "vfame.h" -#include "gba/gba.h" -#include "gba/memory.h" +#include +#include static const uint8_t ADDRESS_REORDERING[4][16] = { { 15, 14, 9, 1, 8, 10, 7, 3, 5, 11, 4, 0, 13, 12, 2, 6 }, diff --git a/src/gba/video.c b/src/gba/video.c index d05151486..bfd4e5175 100644 --- a/src/gba/video.c +++ b/src/gba/video.c @@ -3,18 +3,17 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "video.h" +#include -#include "core/sync.h" -#include "core/tile-cache.h" -#include "gba/dma.h" -#include "gba/gba.h" -#include "gba/io.h" -#include "gba/renderers/tile-cache.h" -#include "gba/rr/rr.h" -#include "gba/serialize.h" +#include +#include +#include +#include +#include +#include +#include -#include "util/memory.h" +#include mLOG_DEFINE_CATEGORY(GBA_VIDEO, "GBA Video"); diff --git a/src/lr35902/debugger/cli-debugger.c b/src/lr35902/debugger/cli-debugger.c index 349578dbf..65d65b0b7 100644 --- a/src/lr35902/debugger/cli-debugger.c +++ b/src/lr35902/debugger/cli-debugger.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "cli-debugger.h" +#include -#include "core/core.h" -#include "debugger/cli-debugger.h" -#include "lr35902/lr35902.h" +#include +#include +#include static void _printStatus(struct CLIDebuggerSystem*); diff --git a/src/lr35902/debugger/debugger.c b/src/lr35902/debugger/debugger.c index 620650aec..a5f08a394 100644 --- a/src/lr35902/debugger/debugger.c +++ b/src/lr35902/debugger/debugger.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "debugger.h" +#include -#include "lr35902/lr35902.h" -#include "core/core.h" +#include +#include DEFINE_VECTOR(LR35902DebugBreakpointList, struct LR35902DebugBreakpoint); DEFINE_VECTOR(LR35902DebugWatchpointList, struct LR35902DebugWatchpoint); diff --git a/src/lr35902/isa-lr35902.c b/src/lr35902/isa-lr35902.c index d8f10211f..a625662c8 100644 --- a/src/lr35902/isa-lr35902.c +++ b/src/lr35902/isa-lr35902.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "isa-lr35902.h" +#include -#include "lr35902/emitter-lr35902.h" -#include "lr35902/lr35902.h" +#include +#include static inline uint16_t LR35902ReadHL(struct LR35902Core* cpu) { uint16_t hl; diff --git a/src/lr35902/lr35902.c b/src/lr35902/lr35902.c index 5b6255b2c..8d1f3f005 100644 --- a/src/lr35902/lr35902.c +++ b/src/lr35902/lr35902.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "lr35902.h" +#include -#include "isa-lr35902.h" +#include void LR35902Init(struct LR35902Core* cpu) { cpu->master->init(cpu, cpu->master); diff --git a/src/platform/3ds/3ds-memory.c b/src/platform/3ds/3ds-memory.c index e3417c828..c37e4637b 100644 --- a/src/platform/3ds/3ds-memory.c +++ b/src/platform/3ds/3ds-memory.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/memory.h" +#include #include <3ds.h> diff --git a/src/platform/3ds/3ds-vfs.c b/src/platform/3ds/3ds-vfs.c index 11e894c95..9de4b1ab3 100644 --- a/src/platform/3ds/3ds-vfs.c +++ b/src/platform/3ds/3ds-vfs.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "3ds-vfs.h" +#include #ifdef USE_VFS_3DS -#include "util/memory.h" -#include "util/string.h" +#include +#include struct VFile3DS { struct VFile d; diff --git a/src/platform/3ds/ctru-heap.c b/src/platform/3ds/ctru-heap.c index f1639687c..42608f8b9 100644 --- a/src/platform/3ds/ctru-heap.c +++ b/src/platform/3ds/ctru-heap.c @@ -28,7 +28,7 @@ #include <3ds/services/hid.h> #include <3ds/svc.h> -#include "util/common.h" +#include extern char* fake_heap_start; extern char* fake_heap_end; diff --git a/src/platform/3ds/gui-font.c b/src/platform/3ds/gui-font.c index 2b79e730d..3c1abc0a0 100644 --- a/src/platform/3ds/gui-font.c +++ b/src/platform/3ds/gui-font.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/gui/font.h" -#include "util/gui/font-metrics.h" -#include "util/png-io.h" -#include "util/vfs.h" +#include +#include +#include +#include #include "icons.h" #include "ctr-gpu.h" diff --git a/src/platform/3ds/main.c b/src/platform/3ds/main.c index 3042a67d8..0d17ba9fa 100644 --- a/src/platform/3ds/main.c +++ b/src/platform/3ds/main.c @@ -4,23 +4,24 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "core/core.h" +#include +#include #ifdef M_CORE_GBA -#include "gba/gba.h" -#include "gba/input.h" -#include "gba/video.h" +#include +#include +#include #endif #ifdef M_CORE_GB -#include "gb/gb.h" +#include #endif #include "feature/gui/gui-runner.h" -#include "util/gui.h" -#include "util/gui/file-select.h" -#include "util/gui/font.h" -#include "util/gui/menu.h" -#include "util/memory.h" +#include +#include +#include +#include +#include -#include "3ds-vfs.h" +#include #include "ctr-gpu.h" #include <3ds.h> diff --git a/src/platform/3ds/socket.c b/src/platform/3ds/socket.c index d15c6500b..6c380ec49 100644 --- a/src/platform/3ds/socket.c +++ b/src/platform/3ds/socket.c @@ -3,6 +3,6 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/socket.h" +#include u32* SOCUBuffer = NULL; diff --git a/src/platform/example/client-server/client.c b/src/platform/example/client-server/client.c index c80e54df0..86d8fdc6f 100644 --- a/src/platform/example/client-server/client.c +++ b/src/platform/example/client-server/client.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "core/core.h" -#include "core/version.h" -#include "util/socket.h" +#include +#include +#include #include diff --git a/src/platform/example/client-server/server.c b/src/platform/example/client-server/server.c index b1e05a81d..75af4edb1 100644 --- a/src/platform/example/client-server/server.c +++ b/src/platform/example/client-server/server.c @@ -1,7 +1,7 @@ // This source file is placed into the public domain. -#include "core/core.h" +#include #include "feature/commandline.h" -#include "util/socket.h" +#include #define DEFAULT_PORT 13721 diff --git a/src/platform/libretro/libretro.c b/src/platform/libretro/libretro.c index b290ee28b..1f7727f5b 100644 --- a/src/platform/libretro/libretro.c +++ b/src/platform/libretro/libretro.c @@ -5,24 +5,24 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "libretro.h" -#include "util/common.h" +#include -#include "core/core.h" -#include "core/version.h" +#include +#include +#include +#include #ifdef M_CORE_GB -#include "gb/core.h" -#include "gb/gb.h" +#include #endif #ifdef M_CORE_GBA -#include "gba/bios.h" -#include "gba/core.h" -#include "gba/cheats.h" -#include "gba/core.h" -#include "gba/serialize.h" +#include +#include +#include +#include #endif -#include "util/circle-buffer.h" -#include "util/memory.h" -#include "util/vfs.h" +#include +#include +#include #define SAMPLES 1024 #define RUMBLE_PWM 35 @@ -146,7 +146,7 @@ void retro_get_system_av_info(struct retro_system_av_info* info) { info->geometry.max_width = width; info->geometry.max_height = height; info->geometry.aspect_ratio = width / (double) height; - info->timing.fps = GBA_ARM7TDMI_FREQUENCY / (float) VIDEO_TOTAL_LENGTH; + info->timing.fps = core->frequency(core) / (float) core->frameCycles(core); info->timing.sample_rate = 32768; } @@ -443,14 +443,14 @@ void retro_unload_game(void) { } size_t retro_serialize_size(void) { - return sizeof(struct GBASerializedState); + return core->stateSize(core); } bool retro_serialize(void* data, size_t size) { if (size != retro_serialize_size()) { return false; } - GBASerialize(core->board, data); + core->saveState(core, data); return true; } @@ -458,7 +458,7 @@ bool retro_unserialize(const void* data, size_t size) { if (size != retro_serialize_size()) { return false; } - GBADeserialize(core->board, data); + core->loadState(core, data); return true; } diff --git a/src/platform/openemu/mGBAGameCore.m b/src/platform/openemu/mGBAGameCore.m index 91ef7b892..1ddf5482f 100644 --- a/src/platform/openemu/mGBAGameCore.m +++ b/src/platform/openemu/mGBAGameCore.m @@ -24,17 +24,18 @@ #import "mGBAGameCore.h" -#include "util/common.h" +#include -#include "core/serialize.h" -#include "core/core.h" -#include "gba/cheats.h" -#include "gba/core.h" -#include "gba/gba.h" -#include "gba/input.h" -#include "util/circle-buffer.h" -#include "util/memory.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #import #import "OEGBASystemResponderClient.h" @@ -129,8 +130,8 @@ - (void)setupEmulation { - blip_set_rates(core->getAudioChannel(core, 0), GBA_ARM7TDMI_FREQUENCY, 32768); - blip_set_rates(core->getAudioChannel(core, 1), GBA_ARM7TDMI_FREQUENCY, 32768); + blip_set_rates(core->getAudioChannel(core, 0), core->frequency(core), 32768); + blip_set_rates(core->getAudioChannel(core, 1), core->frequency(core), 32768); } #pragma mark - Video @@ -176,7 +177,7 @@ - (NSTimeInterval)frameInterval { - return GBA_ARM7TDMI_FREQUENCY / (double) VIDEO_TOTAL_LENGTH; + return core->frequency(core) / (double) core->frameCycles(core); } #pragma mark - Audio diff --git a/src/platform/opengl/gl.c b/src/platform/opengl/gl.c index 51bb64365..31bb101aa 100644 --- a/src/platform/opengl/gl.c +++ b/src/platform/opengl/gl.c @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "gl.h" -#include "util/math.h" +#include static const GLint _glVertices[] = { 0, 0, diff --git a/src/platform/opengl/gl.h b/src/platform/opengl/gl.h index b5cda4ce7..a6412e919 100644 --- a/src/platform/opengl/gl.h +++ b/src/platform/opengl/gl.h @@ -6,7 +6,7 @@ #ifndef GL_H #define GL_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/platform/opengl/gles2.c b/src/platform/opengl/gles2.c index 604384055..781217e57 100644 --- a/src/platform/opengl/gles2.c +++ b/src/platform/opengl/gles2.c @@ -5,11 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "gles2.h" -#include "core/log.h" -#include "util/configuration.h" -#include "util/formatting.h" -#include "util/vector.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include mLOG_DECLARE_CATEGORY(OPENGL); mLOG_DEFINE_CATEGORY(OPENGL, "OpenGL"); diff --git a/src/platform/opengl/gles2.h b/src/platform/opengl/gles2.h index 03cbaf0ae..f6d050bc9 100644 --- a/src/platform/opengl/gles2.h +++ b/src/platform/opengl/gles2.h @@ -6,7 +6,7 @@ #ifndef GLES2_H #define GLES2_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/platform/posix/memory.c b/src/platform/posix/memory.c index 47760275e..7892a5985 100644 --- a/src/platform/posix/memory.c +++ b/src/platform/posix/memory.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/memory.h" +#include #include diff --git a/src/platform/psp2/gui-font.c b/src/platform/psp2/gui-font.c index 37c94be7b..f0296d541 100644 --- a/src/platform/psp2/gui-font.c +++ b/src/platform/psp2/gui-font.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/gui/font.h" -#include "util/gui/font-metrics.h" -#include "util/string.h" +#include +#include +#include #include diff --git a/src/platform/psp2/main.c b/src/platform/psp2/main.c index c184c419d..95dabc13c 100644 --- a/src/platform/psp2/main.c +++ b/src/platform/psp2/main.c @@ -5,12 +5,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "psp2-context.h" -#include "gba/gba.h" +#include #include "feature/gui/gui-runner.h" -#include "util/gui.h" -#include "util/gui/font.h" -#include "util/gui/file-select.h" -#include "util/gui/menu.h" +#include +#include +#include +#include #include #include diff --git a/src/platform/psp2/psp2-common.h b/src/platform/psp2/psp2-common.h index 18e70067a..7f34d1d10 100644 --- a/src/platform/psp2/psp2-common.h +++ b/src/platform/psp2/psp2-common.h @@ -6,7 +6,7 @@ #ifndef PSP2_COMMON_H #define PSP2_COMMON_H -#include "util/common.h" +#include #define PSP2_HORIZONTAL_PIXELS 960 #define PSP2_VERTICAL_PIXELS 544 diff --git a/src/platform/psp2/psp2-context.c b/src/platform/psp2/psp2-context.c index 8b75af17c..f58ee6a1d 100644 --- a/src/platform/psp2/psp2-context.c +++ b/src/platform/psp2/psp2-context.c @@ -5,25 +5,25 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "psp2-context.h" -#include "core/core.h" +#include +#include #ifdef M_CORE_GBA -#include "gba/gba.h" +#include #endif #ifdef M_CORE_GB -#include "gb/gb.h" +#include #endif #include "feature/gui/gui-runner.h" -#include "gba/input.h" +#include -#include "util/memory.h" -#include "util/circle-buffer.h" -#include "util/ring-fifo.h" -#include "util/threading.h" -#include "util/vfs.h" -#include "platform/psp2/sce-vfs.h" -#include "third-party/blip_buf/blip_buf.h" +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/platform/psp2/psp2-context.h b/src/platform/psp2/psp2-context.h index 6702c39d7..28a403ba3 100644 --- a/src/platform/psp2/psp2-context.h +++ b/src/platform/psp2/psp2-context.h @@ -7,8 +7,8 @@ #define PSP2_CONTEXT_H #include "psp2-common.h" -#include "core/interface.h" -#include "util/gui.h" +#include +#include struct mGUIRunner; void mPSP2Setup(struct mGUIRunner* runner); diff --git a/src/platform/psp2/psp2-memory.c b/src/platform/psp2/psp2-memory.c index 1118ee901..7ff56318b 100644 --- a/src/platform/psp2/psp2-memory.c +++ b/src/platform/psp2/psp2-memory.c @@ -3,8 +3,8 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/memory.h" -#include "util/vector.h" +#include +#include #include #include diff --git a/src/platform/psp2/sce-vfs.c b/src/platform/psp2/sce-vfs.c index 4a1e1c559..4b6fdce52 100644 --- a/src/platform/psp2/sce-vfs.c +++ b/src/platform/psp2/sce-vfs.c @@ -3,12 +3,12 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "sce-vfs.h" +#include #include -#include "util/vfs.h" -#include "util/memory.h" +#include +#include struct VFileSce { struct VFile d; diff --git a/src/platform/python/_builder.h b/src/platform/python/_builder.h index 8d0cddbb3..58a214d93 100644 --- a/src/platform/python/_builder.h +++ b/src/platform/python/_builder.h @@ -27,23 +27,23 @@ void free(void*); #include "flags.h" -#include "core/core.h" -#include "core/tile-cache.h" +#include +#include #include "platform/python/vfs-py.h" #include "platform/python/log.h" #ifdef USE_PNG -#include "util/png-io.h" +#include #endif #ifdef M_CORE_GBA -#include "arm/arm.h" -#include "gba/gba.h" -#include "gba/input.h" -#include "gba/renderers/tile-cache.h" +#include +#include +#include +#include #endif #ifdef M_CORE_GB -#include "lr35902/lr35902.h" -#include "gb/gb.h" -#include "gba/input.h" -#include "gb/renderers/tile-cache.h" +#include +#include +#include +#include #endif diff --git a/src/platform/python/_builder.py b/src/platform/python/_builder.py index 4bf78ce53..94babdb55 100644 --- a/src/platform/python/_builder.py +++ b/src/platform/python/_builder.py @@ -7,29 +7,30 @@ import sys ffi = cffi.FFI() pydir = os.path.dirname(os.path.abspath(__file__)) srcdir = os.path.join(pydir, "..", "..") +incdir = os.path.join(pydir, "..", "..", "..", "include") bindir = os.environ.get("BINDIR", os.path.join(os.getcwd(), "..")) cpp = shlex.split(os.environ.get("CPP", "cc -E")) cppflags = shlex.split(os.environ.get("CPPFLAGS", "")) if __name__ == "__main__": cppflags.extend(sys.argv[1:]) -cppflags.extend(["-I" + srcdir, "-I" + bindir]) +cppflags.extend(["-I" + incdir, "-I" + srcdir, "-I" + bindir]) ffi.set_source("mgba._pylib", """ #include "flags.h" -#include "util/common.h" -#include "core/core.h" -#include "core/log.h" -#include "core/tile-cache.h" -#include "arm/arm.h" -#include "gba/gba.h" -#include "gba/input.h" -#include "gba/renderers/tile-cache.h" -#include "lr35902/lr35902.h" -#include "gb/gb.h" -#include "gb/renderers/tile-cache.h" -#include "util/png-io.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include struct VFile* VFileFromPython(void* fileobj); @@ -44,7 +45,7 @@ struct mLoggerPy { struct mLogger d; void* pyobj; }; -""", include_dirs=[srcdir], +""", include_dirs=[incdir, srcdir], extra_compile_args=cppflags, libraries=["mgba"], library_dirs=[bindir], diff --git a/src/platform/python/log.c b/src/platform/python/log.c index aeb77f69f..6066da4a0 100644 --- a/src/platform/python/log.c +++ b/src/platform/python/log.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "core/log.h" +#include struct mLoggerPy { struct mLogger d; @@ -24,4 +24,4 @@ struct mLogger* mLoggerPythonCreate(void* pyobj) { logger->d.log = _pyLogShim; logger->pyobj = pyobj; return &logger->d; -} \ No newline at end of file +} diff --git a/src/platform/python/log.h b/src/platform/python/log.h index 5ee1f7119..f29dba8bb 100644 --- a/src/platform/python/log.h +++ b/src/platform/python/log.h @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "core/log.h" +#include struct mLoggerPy { struct mLogger d; diff --git a/src/platform/python/vfs-py.c b/src/platform/python/vfs-py.c index 51b1f182b..f393832cd 100644 --- a/src/platform/python/vfs-py.c +++ b/src/platform/python/vfs-py.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/vfs.h" +#include struct VFilePy { struct VFile d; diff --git a/src/platform/python/vfs-py.h b/src/platform/python/vfs-py.h index 82a5ac0cf..2842d4812 100644 --- a/src/platform/python/vfs-py.h +++ b/src/platform/python/vfs-py.h @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/vfs.h" +#include struct VFilePy { struct VFile d; @@ -25,4 +25,4 @@ void _vfpTruncate(struct VFile* vf, size_t size); ssize_t _vfpSize(struct VFile* vf); bool _vfpSync(struct VFile* vf, const void* buffer, size_t size); -} \ No newline at end of file +} diff --git a/src/platform/qt/AboutScreen.cpp b/src/platform/qt/AboutScreen.cpp index 895eaec74..0dce32d2b 100644 --- a/src/platform/qt/AboutScreen.cpp +++ b/src/platform/qt/AboutScreen.cpp @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "AboutScreen.h" -#include "core/version.h" +#include #include #include diff --git a/src/platform/qt/ArchiveInspector.cpp b/src/platform/qt/ArchiveInspector.cpp index 11854ed95..3dfd38d0e 100644 --- a/src/platform/qt/ArchiveInspector.cpp +++ b/src/platform/qt/ArchiveInspector.cpp @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ArchiveInspector.h" -#include "util/vfs.h" +#include using namespace QGBA; diff --git a/src/platform/qt/AssetTile.cpp b/src/platform/qt/AssetTile.cpp index 7066a78bf..74dcdf961 100644 --- a/src/platform/qt/AssetTile.cpp +++ b/src/platform/qt/AssetTile.cpp @@ -9,12 +9,12 @@ #include -#include "core/interface.h" +#include #ifdef M_CORE_GBA -#include "gba/memory.h" +#include #endif #ifdef M_CORE_GB -#include "gb/memory.h" +#include #endif using namespace QGBA; diff --git a/src/platform/qt/AssetTile.h b/src/platform/qt/AssetTile.h index 59800405a..c3bf729f0 100644 --- a/src/platform/qt/AssetTile.h +++ b/src/platform/qt/AssetTile.h @@ -10,7 +10,7 @@ #include "ui_AssetTile.h" -#include "core/tile-cache.h" +#include namespace QGBA { diff --git a/src/platform/qt/AssetView.cpp b/src/platform/qt/AssetView.cpp index 21420ae25..cd95749b8 100644 --- a/src/platform/qt/AssetView.cpp +++ b/src/platform/qt/AssetView.cpp @@ -7,10 +7,6 @@ #include -#ifdef M_CORE_GBA -#include "gba/gba.h" -#endif - using namespace QGBA; AssetView::AssetView(GameController* controller, QWidget* parent) diff --git a/src/platform/qt/AudioDevice.cpp b/src/platform/qt/AudioDevice.cpp index 44d1139af..a74e67f50 100644 --- a/src/platform/qt/AudioDevice.cpp +++ b/src/platform/qt/AudioDevice.cpp @@ -7,9 +7,10 @@ #include "LogController.h" -#include "core/core.h" -#include "core/thread.h" -#include "gba/audio.h" +#include +#include +#include +#include using namespace QGBA; diff --git a/src/platform/qt/AudioProcessorQt.cpp b/src/platform/qt/AudioProcessorQt.cpp index ec9b1bdfb..1ff237b01 100644 --- a/src/platform/qt/AudioProcessorQt.cpp +++ b/src/platform/qt/AudioProcessorQt.cpp @@ -10,8 +10,8 @@ #include -#include "core/core.h" -#include "core/thread.h" +#include +#include using namespace QGBA; diff --git a/src/platform/qt/AudioProcessorSDL.cpp b/src/platform/qt/AudioProcessorSDL.cpp index d869f8836..0e8d50af6 100644 --- a/src/platform/qt/AudioProcessorSDL.cpp +++ b/src/platform/qt/AudioProcessorSDL.cpp @@ -7,7 +7,7 @@ #include "LogController.h" -#include "core/thread.h" +#include using namespace QGBA; diff --git a/src/platform/qt/CheatsModel.cpp b/src/platform/qt/CheatsModel.cpp index d822b305f..79041ecea 100644 --- a/src/platform/qt/CheatsModel.cpp +++ b/src/platform/qt/CheatsModel.cpp @@ -10,7 +10,8 @@ #include -#include "core/cheats.h" +#include +#include using namespace QGBA; diff --git a/src/platform/qt/CheatsView.cpp b/src/platform/qt/CheatsView.cpp index 41799530a..b3e912c55 100644 --- a/src/platform/qt/CheatsView.cpp +++ b/src/platform/qt/CheatsView.cpp @@ -11,12 +11,12 @@ #include #include -#include "core/cheats.h" +#include #ifdef M_CORE_GBA -#include "gba/cheats.h" +#include #endif #ifdef M_CORE_GB -#include "gb/cheats.h" +#include #endif using namespace QGBA; diff --git a/src/platform/qt/ConfigController.h b/src/platform/qt/ConfigController.h index 1953ccfbf..2ce8868fd 100644 --- a/src/platform/qt/ConfigController.h +++ b/src/platform/qt/ConfigController.h @@ -15,8 +15,8 @@ #include -#include "core/config.h" -#include "util/configuration.h" +#include +#include #include "feature/commandline.h" class QAction; diff --git a/src/platform/qt/DebuggerConsoleController.cpp b/src/platform/qt/DebuggerConsoleController.cpp index 0ac49fa0d..0752eb89e 100644 --- a/src/platform/qt/DebuggerConsoleController.cpp +++ b/src/platform/qt/DebuggerConsoleController.cpp @@ -9,7 +9,7 @@ #include -#include "debugger/cli-debugger.h" +#include using namespace QGBA; diff --git a/src/platform/qt/DebuggerConsoleController.h b/src/platform/qt/DebuggerConsoleController.h index bac31e20b..36e7903cb 100644 --- a/src/platform/qt/DebuggerConsoleController.h +++ b/src/platform/qt/DebuggerConsoleController.h @@ -12,7 +12,7 @@ #include #include -#include "debugger/cli-debugger.h" +#include namespace QGBA { diff --git a/src/platform/qt/Display.cpp b/src/platform/qt/Display.cpp index 81526be51..506afe76b 100644 --- a/src/platform/qt/Display.cpp +++ b/src/platform/qt/Display.cpp @@ -9,9 +9,9 @@ #include "DisplayQt.h" #ifdef M_CORE_GB -#include "gb/video.h" +#include #elif defined(M_CORE_GBA) -#include "gba/video.h" +#include #endif using namespace QGBA; diff --git a/src/platform/qt/Display.h b/src/platform/qt/Display.h index 66ce63110..a78810fe8 100644 --- a/src/platform/qt/Display.h +++ b/src/platform/qt/Display.h @@ -6,7 +6,7 @@ #ifndef QGBA_DISPLAY #define QGBA_DISPLAY -#include "util/common.h" +#include #include diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp index f59474428..4a1cfff87 100644 --- a/src/platform/qt/DisplayGL.cpp +++ b/src/platform/qt/DisplayGL.cpp @@ -8,8 +8,8 @@ #include #include -#include "core/core.h" -#include "core/thread.h" +#include +#include #ifdef BUILD_GL #include "platform/opengl/gl.h" #endif diff --git a/src/platform/qt/DisplayQt.cpp b/src/platform/qt/DisplayQt.cpp index 5dec87215..284347d58 100644 --- a/src/platform/qt/DisplayQt.cpp +++ b/src/platform/qt/DisplayQt.cpp @@ -7,8 +7,8 @@ #include -#include "core/core.h" -#include "core/thread.h" +#include +#include using namespace QGBA; diff --git a/src/platform/qt/GBAApp.cpp b/src/platform/qt/GBAApp.cpp index 284145535..ea42ed128 100644 --- a/src/platform/qt/GBAApp.cpp +++ b/src/platform/qt/GBAApp.cpp @@ -16,11 +16,14 @@ #include #include -#include "core/version.h" +#include +#include +#include +#include +#include +/* #include "feature/commandline.h" -#include "util/nointro.h" -#include "util/socket.h" - +*/ using namespace QGBA; static GBAApp* g_app = nullptr; diff --git a/src/platform/qt/GBAApp.h b/src/platform/qt/GBAApp.h index 988b55f11..a0e13a60e 100644 --- a/src/platform/qt/GBAApp.h +++ b/src/platform/qt/GBAApp.h @@ -14,8 +14,7 @@ struct NoIntroDB; -#include "core/log.h" -#include "gba/sio.h" +#include mLOG_DECLARE_CATEGORY(QT); diff --git a/src/platform/qt/GBAKeyEditor.h b/src/platform/qt/GBAKeyEditor.h index a2b1391fc..7274a6078 100644 --- a/src/platform/qt/GBAKeyEditor.h +++ b/src/platform/qt/GBAKeyEditor.h @@ -11,7 +11,7 @@ #include #include -#include "gba/input.h" +#include class QComboBox; class QTimer; diff --git a/src/platform/qt/GBAOverride.cpp b/src/platform/qt/GBAOverride.cpp index bd165454a..61a01b6d7 100644 --- a/src/platform/qt/GBAOverride.cpp +++ b/src/platform/qt/GBAOverride.cpp @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "GBAOverride.h" -#include "core/core.h" +#include using namespace QGBA; diff --git a/src/platform/qt/GBAOverride.h b/src/platform/qt/GBAOverride.h index 8f2042684..a668a0d57 100644 --- a/src/platform/qt/GBAOverride.h +++ b/src/platform/qt/GBAOverride.h @@ -8,7 +8,7 @@ #include "Override.h" -#include "gba/overrides.h" +#include namespace QGBA { diff --git a/src/platform/qt/GBOverride.cpp b/src/platform/qt/GBOverride.cpp index 6aa4fd205..e0ff2b4d8 100644 --- a/src/platform/qt/GBOverride.cpp +++ b/src/platform/qt/GBOverride.cpp @@ -5,9 +5,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "GBOverride.h" -#include "core/core.h" -#include "gb/gb.h" -#include "util/crc32.h" +#include +#include +#include using namespace QGBA; diff --git a/src/platform/qt/GBOverride.h b/src/platform/qt/GBOverride.h index 6d35618fc..7c52b497a 100644 --- a/src/platform/qt/GBOverride.h +++ b/src/platform/qt/GBOverride.h @@ -8,7 +8,7 @@ #include "Override.h" -#include "gb/overrides.h" +#include namespace QGBA { diff --git a/src/platform/qt/GDBController.h b/src/platform/qt/GDBController.h index aac3852b8..206c8a27e 100644 --- a/src/platform/qt/GDBController.h +++ b/src/platform/qt/GDBController.h @@ -10,7 +10,7 @@ #ifdef USE_GDB_STUB -#include "debugger/gdb-stub.h" +#include namespace QGBA { diff --git a/src/platform/qt/GIFView.cpp b/src/platform/qt/GIFView.cpp index 427bb9459..e72475150 100644 --- a/src/platform/qt/GIFView.cpp +++ b/src/platform/qt/GIFView.cpp @@ -12,6 +12,9 @@ #include +#include +#include + using namespace QGBA; GIFView::GIFView(QWidget* parent) diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index d31ffa1a3..a86fbf8ac 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -17,22 +17,23 @@ #include -#include "core/config.h" -#include "core/directories.h" -#include "core/serialize.h" -#include "core/tile-cache.h" +#include +#include +#include +#include #ifdef M_CORE_GBA -#include "gba/bios.h" -#include "gba/core.h" -#include "gba/gba.h" -#include "gba/renderers/tile-cache.h" -#include "gba/sharkport.h" +#include +#include +#include +#include +#include +#include #endif #ifdef M_CORE_GB -#include "gb/gb.h" -#include "gb/renderers/tile-cache.h" +#include +#include #endif -#include "util/vfs.h" +#include using namespace QGBA; using namespace std; diff --git a/src/platform/qt/GameController.h b/src/platform/qt/GameController.h index 30369c538..63383ac23 100644 --- a/src/platform/qt/GameController.h +++ b/src/platform/qt/GameController.h @@ -15,12 +15,10 @@ #include -#include "core/core.h" -#include "core/thread.h" -#include "gba/cheats.h" -#include "gba/hardware.h" -#include "gba/input.h" -#include "gba/overrides.h" +#include +#include +#include +#include #ifdef BUILD_SDL #include "platform/sdl/sdl-events.h" #endif diff --git a/src/platform/qt/GamepadAxisEvent.h b/src/platform/qt/GamepadAxisEvent.h index 6416041bd..68234ccdc 100644 --- a/src/platform/qt/GamepadAxisEvent.h +++ b/src/platform/qt/GamepadAxisEvent.h @@ -8,7 +8,7 @@ #include -#include "gba/input.h" +#include namespace QGBA { diff --git a/src/platform/qt/GamepadButtonEvent.h b/src/platform/qt/GamepadButtonEvent.h index 82419191e..b0751f4b6 100644 --- a/src/platform/qt/GamepadButtonEvent.h +++ b/src/platform/qt/GamepadButtonEvent.h @@ -8,7 +8,7 @@ #include -#include "gba/input.h" +#include namespace QGBA { diff --git a/src/platform/qt/IOViewer.cpp b/src/platform/qt/IOViewer.cpp index b7b9bdd50..b308de6a4 100644 --- a/src/platform/qt/IOViewer.cpp +++ b/src/platform/qt/IOViewer.cpp @@ -12,11 +12,13 @@ #include #include -#include "gba/io.h" +#include +#include + +struct ARMCore; using namespace QGBA; - QList IOViewer::s_registers; const QList& IOViewer::registerDescriptions() { diff --git a/src/platform/qt/InputController.cpp b/src/platform/qt/InputController.cpp index c8a86f1cb..eca5dfe97 100644 --- a/src/platform/qt/InputController.cpp +++ b/src/platform/qt/InputController.cpp @@ -14,8 +14,8 @@ #include #include -#include "core/interface.h" -#include "util/configuration.h" +#include +#include using namespace QGBA; diff --git a/src/platform/qt/InputController.h b/src/platform/qt/InputController.h index ce33b8b28..8dc5af196 100644 --- a/src/platform/qt/InputController.h +++ b/src/platform/qt/InputController.h @@ -14,7 +14,7 @@ class QTimer; -#include "gba/input.h" +#include #ifdef BUILD_SDL #include "platform/sdl/sdl-events.h" diff --git a/src/platform/qt/InputProfile.h b/src/platform/qt/InputProfile.h index d0d80e155..431bd4b4f 100644 --- a/src/platform/qt/InputProfile.h +++ b/src/platform/qt/InputProfile.h @@ -8,7 +8,7 @@ #include "GamepadAxisEvent.h" -#include "gba/interface.h" +#include namespace QGBA { diff --git a/src/platform/qt/LibraryModel.cpp b/src/platform/qt/LibraryModel.cpp index da085cf0a..9973af042 100644 --- a/src/platform/qt/LibraryModel.cpp +++ b/src/platform/qt/LibraryModel.cpp @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "LibraryModel.h" -#include "util/vfs.h" +#include using namespace QGBA; diff --git a/src/platform/qt/LibraryModel.h b/src/platform/qt/LibraryModel.h index d11cdaaf7..5f8999461 100644 --- a/src/platform/qt/LibraryModel.h +++ b/src/platform/qt/LibraryModel.h @@ -8,7 +8,7 @@ #include -#include "core/library.h" +#include struct VDir; diff --git a/src/platform/qt/LoadSaveState.cpp b/src/platform/qt/LoadSaveState.cpp index 64210ce75..122cb133e 100644 --- a/src/platform/qt/LoadSaveState.cpp +++ b/src/platform/qt/LoadSaveState.cpp @@ -14,11 +14,9 @@ #include #include -#include "core/serialize.h" -#ifdef M_CORE_GBA -#include "gba/serialize.h" -#endif -#include "util/memory.h" +#include +#include +#include using namespace QGBA; diff --git a/src/platform/qt/LogController.h b/src/platform/qt/LogController.h index b630f33e6..0a4be0159 100644 --- a/src/platform/qt/LogController.h +++ b/src/platform/qt/LogController.h @@ -11,8 +11,6 @@ #include #include -#include "gba/gba.h" - namespace QGBA { class LogController : public QObject { diff --git a/src/platform/qt/MemoryModel.cpp b/src/platform/qt/MemoryModel.cpp index 888e020d0..e7f4d126e 100644 --- a/src/platform/qt/MemoryModel.cpp +++ b/src/platform/qt/MemoryModel.cpp @@ -19,7 +19,8 @@ #include #include -#include "core/core.h" +#include +#include using namespace QGBA; diff --git a/src/platform/qt/MemoryModel.h b/src/platform/qt/MemoryModel.h index 1e0fbd645..a32bb8c36 100644 --- a/src/platform/qt/MemoryModel.h +++ b/src/platform/qt/MemoryModel.h @@ -13,7 +13,7 @@ #include #include -#include "util/text-codec.h" +#include struct mCore; diff --git a/src/platform/qt/MemoryView.cpp b/src/platform/qt/MemoryView.cpp index 9fdfb0704..20a6dce16 100644 --- a/src/platform/qt/MemoryView.cpp +++ b/src/platform/qt/MemoryView.cpp @@ -8,12 +8,12 @@ #include "GameController.h" -#include "core/core.h" +#include #ifdef M_CORE_GBA -#include "gba/memory.h" +#include #endif #ifdef M_CORE_GB -#include "gb/memory.h" +#include #endif using namespace QGBA; diff --git a/src/platform/qt/MessagePainter.cpp b/src/platform/qt/MessagePainter.cpp index 6cb9b7835..629ce4878 100644 --- a/src/platform/qt/MessagePainter.cpp +++ b/src/platform/qt/MessagePainter.cpp @@ -9,7 +9,7 @@ #include -#include "gba/video.h" +#include using namespace QGBA; diff --git a/src/platform/qt/MultiplayerController.cpp b/src/platform/qt/MultiplayerController.cpp index 850dd350e..dc5e54ebb 100644 --- a/src/platform/qt/MultiplayerController.cpp +++ b/src/platform/qt/MultiplayerController.cpp @@ -8,10 +8,10 @@ #include "GameController.h" #ifdef M_CORE_GBA -#include "gba/gba.h" +#include #endif #ifdef M_CORE_GB -#include "gb/gb.h" +#include #endif using namespace QGBA; diff --git a/src/platform/qt/MultiplayerController.h b/src/platform/qt/MultiplayerController.h index ca88757fe..42de75bcb 100644 --- a/src/platform/qt/MultiplayerController.h +++ b/src/platform/qt/MultiplayerController.h @@ -10,12 +10,12 @@ #include #include -#include "core/lockstep.h" +#include #ifdef M_CORE_GBA -#include "gba/sio/lockstep.h" +#include #endif #ifdef M_CORE_GB -#include "gb/sio/lockstep.h" +#include #endif namespace QGBA { diff --git a/src/platform/qt/ObjView.cpp b/src/platform/qt/ObjView.cpp index da6910c43..f2471226b 100644 --- a/src/platform/qt/ObjView.cpp +++ b/src/platform/qt/ObjView.cpp @@ -10,10 +10,10 @@ #include #include -#include "gba/gba.h" +#include #ifdef M_CORE_GB -#include "gb/gb.h" -#include "gb/io.h" +#include +#include #endif using namespace QGBA; diff --git a/src/platform/qt/ObjView.h b/src/platform/qt/ObjView.h index afa5f1c2a..725fabfd4 100644 --- a/src/platform/qt/ObjView.h +++ b/src/platform/qt/ObjView.h @@ -11,7 +11,7 @@ #include "ui_ObjView.h" -#include "core/tile-cache.h" +#include namespace QGBA { diff --git a/src/platform/qt/OverrideView.cpp b/src/platform/qt/OverrideView.cpp index d5875ebd0..ad0819616 100644 --- a/src/platform/qt/OverrideView.cpp +++ b/src/platform/qt/OverrideView.cpp @@ -12,12 +12,12 @@ #ifdef M_CORE_GBA #include "GBAOverride.h" -#include "gba/gba.h" +#include #endif #ifdef M_CORE_GB #include "GBOverride.h" -#include "gb/gb.h" +#include #endif using namespace QGBA; diff --git a/src/platform/qt/OverrideView.h b/src/platform/qt/OverrideView.h index aad6709ab..c7f3fad99 100644 --- a/src/platform/qt/OverrideView.h +++ b/src/platform/qt/OverrideView.h @@ -9,7 +9,7 @@ #include #ifdef M_CORE_GB -#include "gb/overrides.h" +#include #endif #include "ui_OverrideView.h" diff --git a/src/platform/qt/PaletteView.cpp b/src/platform/qt/PaletteView.cpp index 8f756bec1..af55bdd4b 100644 --- a/src/platform/qt/PaletteView.cpp +++ b/src/platform/qt/PaletteView.cpp @@ -12,15 +12,15 @@ #include #include -#include "core/core.h" -#include "util/export.h" -#ifdef M_CORE_GA -#include "gba/gba.h" +#include +#ifdef M_CORE_GBA +#include #endif #ifdef M_CORE_GB -#include "gb/gb.h" +#include #endif -#include "util/vfs.h" +#include +#include using namespace QGBA; diff --git a/src/platform/qt/ROMInfo.cpp b/src/platform/qt/ROMInfo.cpp index bdea67c43..d83b4cf2c 100644 --- a/src/platform/qt/ROMInfo.cpp +++ b/src/platform/qt/ROMInfo.cpp @@ -8,14 +8,14 @@ #include "GBAApp.h" #include "GameController.h" -#include "core/core.h" +#include #ifdef M_CORE_GB -#include "gb/gb.h" +#include #endif #ifdef M_CORE_GBA -#include "gba/gba.h" +#include #endif -#include "util/nointro.h" +#include using namespace QGBA; diff --git a/src/platform/qt/SensorView.cpp b/src/platform/qt/SensorView.cpp index 6305d801c..b0e86cc64 100644 --- a/src/platform/qt/SensorView.cpp +++ b/src/platform/qt/SensorView.cpp @@ -9,8 +9,8 @@ #include "GamepadAxisEvent.h" #include "InputController.h" -#include "core/core.h" -#include "gba/gba.h" +#include +#include using namespace QGBA; diff --git a/src/platform/qt/SettingsView.cpp b/src/platform/qt/SettingsView.cpp index ef11f79ba..d4625e13e 100644 --- a/src/platform/qt/SettingsView.cpp +++ b/src/platform/qt/SettingsView.cpp @@ -13,8 +13,8 @@ #include "InputController.h" #include "ShortcutView.h" -#include "core/serialize.h" -#include "gba/gba.h" +#include +#include using namespace QGBA; diff --git a/src/platform/qt/ShaderSelector.cpp b/src/platform/qt/ShaderSelector.cpp index b5f8feccd..928cef505 100644 --- a/src/platform/qt/ShaderSelector.cpp +++ b/src/platform/qt/ShaderSelector.cpp @@ -17,7 +17,8 @@ #include #include -#include "core/version.h" +#include +#include #include "platform/video-backend.h" #if !defined(_WIN32) || defined(USE_EPOXY) diff --git a/src/platform/qt/Swatch.cpp b/src/platform/qt/Swatch.cpp index 5ff1fc2b6..8c0e64212 100644 --- a/src/platform/qt/Swatch.cpp +++ b/src/platform/qt/Swatch.cpp @@ -8,7 +8,7 @@ #include #include -#include "core/interface.h" +#include using namespace QGBA; diff --git a/src/platform/qt/TileView.cpp b/src/platform/qt/TileView.cpp index c8b383741..eb4dbd18d 100644 --- a/src/platform/qt/TileView.cpp +++ b/src/platform/qt/TileView.cpp @@ -11,7 +11,7 @@ #include #ifdef M_CORE_GB -#include "gb/gb.h" +#include #endif using namespace QGBA; diff --git a/src/platform/qt/TileView.h b/src/platform/qt/TileView.h index aef5b526f..623d83a47 100644 --- a/src/platform/qt/TileView.h +++ b/src/platform/qt/TileView.h @@ -11,7 +11,7 @@ #include "ui_TileView.h" -#include "core/tile-cache.h" +#include namespace QGBA { diff --git a/src/platform/qt/VFileDevice.cpp b/src/platform/qt/VFileDevice.cpp index 3e15c9f62..04da09353 100644 --- a/src/platform/qt/VFileDevice.cpp +++ b/src/platform/qt/VFileDevice.cpp @@ -5,6 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "VFileDevice.h" +#include + using namespace QGBA; VFileDevice::VFileDevice(VFile* vf, QObject* parent) diff --git a/src/platform/qt/VFileDevice.h b/src/platform/qt/VFileDevice.h index 2cdd85d14..71baecd1a 100644 --- a/src/platform/qt/VFileDevice.h +++ b/src/platform/qt/VFileDevice.h @@ -8,7 +8,8 @@ #include -#include "util/vfs.h" +struct VDir; +struct VFile; namespace QGBA { diff --git a/src/platform/qt/VideoView.cpp b/src/platform/qt/VideoView.cpp index 0e8433af0..6a6523b6e 100644 --- a/src/platform/qt/VideoView.cpp +++ b/src/platform/qt/VideoView.cpp @@ -12,10 +12,6 @@ #include -#ifdef M_CORE_GB -#include "gb/video.h" -#endif - using namespace QGBA; QMap VideoView::s_acodecMap; diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index ca3ca0fae..9a2d594a6 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -42,13 +42,14 @@ #include "TileView.h" #include "VideoView.h" -#include "core/version.h" +#include #ifdef M_CORE_GB -#include "gb/gb.h" +#include +#include #endif #include "feature/commandline.h" -#include "util/nointro.h" -#include "util/vfs.h" +#include +#include using namespace QGBA; diff --git a/src/platform/qt/Window.h b/src/platform/qt/Window.h index 557b99a80..087977fb3 100644 --- a/src/platform/qt/Window.h +++ b/src/platform/qt/Window.h @@ -13,8 +13,7 @@ #include -#include "core/thread.h" -#include "gba/gba.h" +#include #include "InputController.h" #include "LoadSaveState.h" diff --git a/src/platform/sdl/gl-common.c b/src/platform/sdl/gl-common.c index 3e4f7add2..7ed9aa95b 100644 --- a/src/platform/sdl/gl-common.c +++ b/src/platform/sdl/gl-common.c @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "main.h" -#include "core/version.h" +#include void mSDLGLCommonSwap(struct VideoBackend* context) { struct mSDLRenderer* renderer = (struct mSDLRenderer*) context->user; diff --git a/src/platform/sdl/gl-common.h b/src/platform/sdl/gl-common.h index 4a22c1b34..b517dd436 100644 --- a/src/platform/sdl/gl-common.h +++ b/src/platform/sdl/gl-common.h @@ -6,7 +6,7 @@ #ifndef SDL_GL_COMMON_H #define SDL_GL_COMMON_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/platform/sdl/gl-sdl.c b/src/platform/sdl/gl-sdl.c index 0a34b7600..0ecf67ecd 100644 --- a/src/platform/sdl/gl-sdl.c +++ b/src/platform/sdl/gl-sdl.c @@ -7,8 +7,8 @@ #include "gl-common.h" -#include "core/core.h" -#include "core/thread.h" +#include +#include #include "platform/opengl/gl.h" static void _doViewport(int w, int h, struct VideoBackend* v) { diff --git a/src/platform/sdl/main.c b/src/platform/sdl/main.c index c6621ecf5..9bbabedbc 100644 --- a/src/platform/sdl/main.c +++ b/src/platform/sdl/main.c @@ -5,33 +5,23 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "main.h" -#include "debugger/cli-debugger.h" +#include #ifdef USE_GDB_STUB -#include "debugger/gdb-stub.h" +#include #endif #ifdef USE_EDITLINE #include "feature/editline/cli-el-backend.h" #endif -#include "core/core.h" -#include "core/config.h" -#include "core/input.h" -#include "core/thread.h" -#include "gba/input.h" -#ifdef M_CORE_GBA -#include "gba/core.h" -#include "gba/gba.h" -#include "gba/video.h" -#endif -#ifdef M_CORE_GB -#include "gb/core.h" -#include "gb/gb.h" -#include "gb/video.h" -#endif +#include +#include +#include +#include +#include + #include "feature/commandline.h" -#include "util/configuration.h" -#include "util/vfs.h" +#include #include diff --git a/src/platform/sdl/main.h b/src/platform/sdl/main.h index d8f34909b..0477692cb 100644 --- a/src/platform/sdl/main.h +++ b/src/platform/sdl/main.h @@ -6,18 +6,10 @@ #ifndef SDL_MAIN_H #define SDL_MAIN_H -#include "util/common.h" +#include CXX_GUARD_START -#ifdef M_CORE_GBA -#include "gba/renderers/video-software.h" -#endif - -#ifdef M_CORE_GB -#include "gb/renderers/software.h" -#endif - #include "sdl-audio.h" #include "sdl-events.h" diff --git a/src/platform/sdl/sdl-audio.c b/src/platform/sdl/sdl-audio.c index c731cfba7..369592140 100644 --- a/src/platform/sdl/sdl-audio.c +++ b/src/platform/sdl/sdl-audio.c @@ -5,11 +5,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "sdl-audio.h" -#include "core/core.h" -#include "core/thread.h" -#include "gba/gba.h" +#include +#include +#include +#include -#include "third-party/blip_buf/blip_buf.h" +#include #define BUFFER_SIZE (GBA_AUDIO_SAMPLES >> 2) diff --git a/src/platform/sdl/sdl-audio.h b/src/platform/sdl/sdl-audio.h index f7001cb61..dc21cb86c 100644 --- a/src/platform/sdl/sdl-audio.h +++ b/src/platform/sdl/sdl-audio.h @@ -6,11 +6,11 @@ #ifndef SDL_AUDIO_H #define SDL_AUDIO_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/log.h" +#include #include diff --git a/src/platform/sdl/sdl-events.c b/src/platform/sdl/sdl-events.c index 3da4c2a78..474265ce4 100644 --- a/src/platform/sdl/sdl-events.c +++ b/src/platform/sdl/sdl-events.c @@ -5,18 +5,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "sdl-events.h" -#include "core/input.h" -#include "core/serialize.h" -#include "core/thread.h" -#include "debugger/debugger.h" -#include "gba/input.h" -#include "gba/io.h" -#include "gba/rr/rr.h" -#include "gba/video.h" -#include "gba/renderers/video-software.h" -#include "util/configuration.h" -#include "util/formatting.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #if SDL_VERSION_ATLEAST(2, 0, 0) && defined(__APPLE__) #define GUI_MOD KMOD_GUI diff --git a/src/platform/sdl/sdl-events.h b/src/platform/sdl/sdl-events.h index eea7bb7ba..bebf02cea 100644 --- a/src/platform/sdl/sdl-events.h +++ b/src/platform/sdl/sdl-events.h @@ -6,14 +6,14 @@ #ifndef SDL_EVENTS_H #define SDL_EVENTS_H -#include "util/common.h" +#include CXX_GUARD_START -#include "core/interface.h" -#include "core/log.h" -#include "util/circle-buffer.h" -#include "util/vector.h" +#include +#include +#include +#include #include diff --git a/src/platform/test/fuzz-main.c b/src/platform/test/fuzz-main.c index b8009f82e..d40a15937 100644 --- a/src/platform/test/fuzz-main.c +++ b/src/platform/test/fuzz-main.c @@ -3,17 +3,19 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "core/cheats.h" -#include "core/config.h" -#include "core/core.h" -#include "core/serialize.h" -#include "gb/core.h" -#include "gba/gba.h" +#include +#include +#include +#include +#include +#include +#include +#include #include "feature/commandline.h" -#include "util/memory.h" -#include "util/string.h" -#include "util/vfs.h" +#include +#include +#include #include #include diff --git a/src/platform/test/perf-main.c b/src/platform/test/perf-main.c index 390c49402..03fe093ce 100644 --- a/src/platform/test/perf-main.c +++ b/src/platform/test/perf-main.c @@ -3,16 +3,18 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "core/config.h" -#include "core/serialize.h" -#include "gba/core.h" -#include "gba/gba.h" -#include "gba/renderers/video-software.h" +#include +#include +#include +#include +#include +#include +#include #include "feature/commandline.h" -#include "util/socket.h" -#include "util/string.h" -#include "util/vfs.h" +#include +#include +#include #ifdef _3DS #include <3ds.h> diff --git a/src/platform/test/tbl-fuzz-main.c b/src/platform/test/tbl-fuzz-main.c index bd7e2ff00..d1c39fbd2 100644 --- a/src/platform/test/tbl-fuzz-main.c +++ b/src/platform/test/tbl-fuzz-main.c @@ -3,8 +3,8 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/text-codec.h" -#include "util/vfs.h" +#include +#include int main(int argc, char** argv) { struct TextCodec codec; diff --git a/src/platform/video-backend.h b/src/platform/video-backend.h index 31d7a5301..79264c4e2 100644 --- a/src/platform/video-backend.h +++ b/src/platform/video-backend.h @@ -6,7 +6,7 @@ #ifndef VIDEO_BACKEND_H #define VIDEO_BACKEND_H -#include "util/common.h" +#include CXX_GUARD_START diff --git a/src/platform/wii/gui-font.c b/src/platform/wii/gui-font.c index 101ca383b..1a247c751 100644 --- a/src/platform/wii/gui-font.c +++ b/src/platform/wii/gui-font.c @@ -3,8 +3,8 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/gui/font.h" -#include "util/gui/font-metrics.h" +#include +#include #include "icons.h" #include "font.h" diff --git a/src/platform/wii/main.c b/src/platform/wii/main.c index bcc9c8251..29096042e 100644 --- a/src/platform/wii/main.c +++ b/src/platform/wii/main.c @@ -12,18 +12,19 @@ #include #include -#include "util/common.h" +#include -#include "core/core.h" +#include +#include #include "feature/gui/gui-runner.h" -#include "gba/audio.h" -#include "gba/gba.h" -#include "gba/input.h" -#include "util/gui.h" -#include "util/gui/file-select.h" -#include "util/gui/font.h" -#include "util/gui/menu.h" -#include "util/vfs.h" +#include +#include +#include +#include +#include +#include +#include +#include #define GCN1_INPUT 0x47434E31 #define GCN2_INPUT 0x47434E32 diff --git a/src/platform/wii/wii-memory.c b/src/platform/wii/wii-memory.c index e034bf760..419b58f9a 100644 --- a/src/platform/wii/wii-memory.c +++ b/src/platform/wii/wii-memory.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/memory.h" +#include void* anonymousMemoryMap(size_t size) { return malloc(size); diff --git a/src/platform/windows/vfs-w32.c b/src/platform/windows/vfs-w32.c index 565feee07..315429fae 100644 --- a/src/platform/windows/vfs-w32.c +++ b/src/platform/windows/vfs-w32.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/vfs.h" +#include -#include "util/string.h" +#include #include static bool _vdwClose(struct VDir* vd); diff --git a/src/third-party/blip_buf/blip_buf.c b/src/third-party/blip_buf/blip_buf.c index 362eede49..6bc7da8bd 100644 --- a/src/third-party/blip_buf/blip_buf.c +++ b/src/third-party/blip_buf/blip_buf.c @@ -1,6 +1,6 @@ /* blip_buf 1.1.0. http://www.slack.net/~ant/ */ -#include "blip_buf.h" +#include #include #include diff --git a/src/util/circle-buffer.c b/src/util/circle-buffer.c index 5220ced44..deb426473 100644 --- a/src/util/circle-buffer.c +++ b/src/util/circle-buffer.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "circle-buffer.h" +#include #ifndef NDEBUG static int _checkIntegrity(struct CircleBuffer* buffer) { diff --git a/src/util/configuration.c b/src/util/configuration.c index adae7f300..1021c5137 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "configuration.h" +#include -#include "util/formatting.h" -#include "util/string.h" -#include "util/vfs.h" +#include +#include +#include #include "third-party/inih/ini.h" diff --git a/src/util/crc32.c b/src/util/crc32.c index 77c1715f1..21a4354d4 100644 --- a/src/util/crc32.c +++ b/src/util/crc32.c @@ -40,9 +40,9 @@ * CRC32 code derived from work by Gary S. Brown. */ -#include "util/crc32.h" +#include -#include "util/vfs.h" +#include enum { BUFFER_SIZE = 1024 diff --git a/src/util/export.c b/src/util/export.c index 3e7145f7e..cb138ce5a 100644 --- a/src/util/export.c +++ b/src/util/export.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "export.h" +#include -#include "gba/video.h" -#include "util/vfs.h" +#include +#include bool exportPaletteRIFF(struct VFile* vf, size_t entries, const uint16_t* colors) { if (entries > 0xFFFF) { diff --git a/src/util/formatting.c b/src/util/formatting.c index e0f200ed6..ccd874622 100644 --- a/src/util/formatting.c +++ b/src/util/formatting.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "formatting.h" +#include #include #include diff --git a/src/util/gui.c b/src/util/gui.c index 5aed3d58b..ec37f99e5 100644 --- a/src/util/gui.c +++ b/src/util/gui.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "gui.h" +#include void GUIInit(struct GUIParams* params) { memset(params->inputHistory, 0, sizeof(params->inputHistory)); diff --git a/src/util/gui/file-select.c b/src/util/gui/file-select.c index 70bc91120..96bb632f2 100644 --- a/src/util/gui/file-select.c +++ b/src/util/gui/file-select.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "file-select.h" +#include -#include "util/gui/font.h" -#include "util/gui/menu.h" -#include "util/vfs.h" +#include +#include +#include #include diff --git a/src/util/gui/font-metrics.c b/src/util/gui/font-metrics.c index 3513fec70..0e965a3e6 100644 --- a/src/util/gui/font-metrics.c +++ b/src/util/gui/font-metrics.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/gui/font.h" +#include const struct GUIFontGlyphMetric defaultFontMetrics[128] = { { 0, 0, { 0, 0, 0, 0 }}, // 0x00 diff --git a/src/util/gui/font.c b/src/util/gui/font.c index 03965bf24..05ceffa92 100644 --- a/src/util/gui/font.c +++ b/src/util/gui/font.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/gui/font.h" +#include -#include "util/string.h" +#include unsigned GUIFontSpanWidth(const struct GUIFont* font, const char* text) { unsigned width = 0; diff --git a/src/util/gui/menu.c b/src/util/gui/menu.c index dcfdfdab7..6f8eb8327 100644 --- a/src/util/gui/menu.c +++ b/src/util/gui/menu.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "menu.h" +#include -#include "util/gui.h" -#include "util/gui/font.h" +#include +#include #ifdef _3DS #include <3ds.h> diff --git a/src/util/hash.c b/src/util/hash.c index 96e2ffb7f..9db508c13 100644 --- a/src/util/hash.c +++ b/src/util/hash.c @@ -1,7 +1,7 @@ // MurmurHash3 was written by Austin Appleby, and is placed in the public // domain. The author hereby disclaims copyright to this source code. -#include "hash.h" +#include #if defined(_MSC_VER) diff --git a/src/util/nointro.c b/src/util/nointro.c index fdf3008b3..bb5471572 100644 --- a/src/util/nointro.c +++ b/src/util/nointro.c @@ -3,12 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "nointro.h" +#include -#include "util/crc32.h" -#include "util/table.h" -#include "util/vector.h" -#include "util/vfs.h" +#include +#include +#include #define KEY_STACK_SIZE 8 diff --git a/src/util/patch-fast.c b/src/util/patch-fast.c index d2722792f..81b3aa45a 100644 --- a/src/util/patch-fast.c +++ b/src/util/patch-fast.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "patch-fast.h" +#include DEFINE_VECTOR(PatchFastExtents, struct PatchFastExtent); diff --git a/src/util/patch-ips.c b/src/util/patch-ips.c index 0249f9ce9..34b41658d 100644 --- a/src/util/patch-ips.c +++ b/src/util/patch-ips.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/patch-ips.h" +#include -#include "util/patch.h" -#include "util/vfs.h" +#include +#include static size_t _IPSOutputSize(struct Patch* patch, size_t inSize); static bool _IPSApplyPatch(struct Patch* patch, const void* in, size_t inSize, void* out, size_t outSize); diff --git a/src/util/patch-ups.c b/src/util/patch-ups.c index 80573387a..d58ee2216 100644 --- a/src/util/patch-ups.c +++ b/src/util/patch-ups.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/patch-ips.h" +#include -#include "util/crc32.h" -#include "util/patch.h" -#include "util/vfs.h" +#include +#include +#include enum { IN_CHECKSUM = -12, diff --git a/src/util/patch.c b/src/util/patch.c index d4e950e6c..b83c0d853 100644 --- a/src/util/patch.c +++ b/src/util/patch.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/patch.h" +#include -#include "util/patch-ips.h" -#include "util/patch-ups.h" +#include +#include bool loadPatch(struct VFile* vf, struct Patch* patch) { patch->vf = vf; diff --git a/src/util/png-io.c b/src/util/png-io.c index 09631dbe4..e3e17ff5e 100644 --- a/src/util/png-io.c +++ b/src/util/png-io.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/png-io.h" +#include #ifdef USE_PNG -#include "vfs.h" +#include static void _pngWrite(png_structp png, png_bytep buffer, png_size_t size) { struct VFile* vf = png_get_io_ptr(png); diff --git a/src/util/ring-fifo.c b/src/util/ring-fifo.c index 5cac3f2c4..167690c61 100644 --- a/src/util/ring-fifo.c +++ b/src/util/ring-fifo.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "ring-fifo.h" +#include -#include "util/memory.h" +#include void RingFIFOInit(struct RingFIFO* buffer, size_t capacity) { buffer->data = anonymousMemoryMap(capacity); diff --git a/src/util/string.c b/src/util/string.c index eb05768db..7e18a8547 100644 --- a/src/util/string.c +++ b/src/util/string.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/string.h" +#include #include diff --git a/src/util/table.c b/src/util/table.c index 3f4deb013..179d40a00 100644 --- a/src/util/table.c +++ b/src/util/table.c @@ -3,10 +3,10 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "table.h" +#include -#include "util/hash.h" -#include "util/string.h" +#include +#include #define LIST_INITIAL_SIZE 8 #define TABLE_INITIAL_SIZE 8 diff --git a/src/util/test/suite.h b/src/util/test/suite.h index f446e2cf6..dd947830d 100644 --- a/src/util/test/suite.h +++ b/src/util/test/suite.h @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef SUITE_H #define SUITE_H -#include "util/common.h" +#include #include #include diff --git a/src/util/test/text-codec.c b/src/util/test/text-codec.c index 75e382f8c..54c05703f 100644 --- a/src/util/test/text-codec.c +++ b/src/util/test/text-codec.c @@ -5,8 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "util/test/suite.h" -#include "util/text-codec.h" -#include "util/vfs.h" +#include +#include M_TEST_DEFINE(emptyCodec) { struct VFile* vf = VFileMemChunk(NULL, 0); diff --git a/src/util/test/util.h b/src/util/test/util.h index e5a374554..0a665b995 100644 --- a/src/util/test/util.h +++ b/src/util/test/util.h @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef TEST_UTIL_H #define TEST_UTIL_H -#include "util/common.h" +#include int TestRunUtil(void); diff --git a/src/util/test/vfs.c b/src/util/test/vfs.c index b011d5039..cc623d1b0 100644 --- a/src/util/test/vfs.c +++ b/src/util/test/vfs.c @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "util/test/suite.h" -#include "util/vfs.h" +#include #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 M_TEST_DEFINE(openNullPathR) { diff --git a/src/util/text-codec.c b/src/util/text-codec.c index 399016f59..173f2b36c 100644 --- a/src/util/text-codec.c +++ b/src/util/text-codec.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "text-codec.h" +#include -#include "util/string.h" -#include "util/table.h" -#include "util/vfs.h" +#include +#include +#include struct TextCodecNode { uint8_t* leaf; diff --git a/src/util/vfs.c b/src/util/vfs.c index 27932c717..82035ec1e 100644 --- a/src/util/vfs.c +++ b/src/util/vfs.c @@ -3,15 +3,15 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "vfs.h" +#include -#include "util/string.h" +#include #ifdef PSP2 -#include "platform/psp2/sce-vfs.h" +#include #endif #ifdef _3DS -#include "platform/3ds/3ds-vfs.h" +#include #endif struct VFile* VFileOpen(const char* path, int flags) { diff --git a/src/util/vfs/vfs-devlist.c b/src/util/vfs/vfs-devlist.c index 8f25feb17..667ffd193 100644 --- a/src/util/vfs/vfs-devlist.c +++ b/src/util/vfs/vfs-devlist.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/vfs.h" +#include #include diff --git a/src/util/vfs/vfs-dirent.c b/src/util/vfs/vfs-dirent.c index 7104af808..d124af355 100644 --- a/src/util/vfs/vfs-dirent.c +++ b/src/util/vfs/vfs-dirent.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/vfs.h" +#include -#include "util/string.h" +#include #include #include diff --git a/src/util/vfs/vfs-fd.c b/src/util/vfs/vfs-fd.c index 2b0f418c9..39b2164ee 100644 --- a/src/util/vfs/vfs-fd.c +++ b/src/util/vfs/vfs-fd.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/vfs.h" +#include #include #include diff --git a/src/util/vfs/vfs-file.c b/src/util/vfs/vfs-file.c index 57ab37efa..bfde30e93 100644 --- a/src/util/vfs/vfs-file.c +++ b/src/util/vfs/vfs-file.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/vfs.h" +#include -#include "util/memory.h" +#include #include #include diff --git a/src/util/vfs/vfs-lzma.c b/src/util/vfs/vfs-lzma.c index 359628abd..53bf5e619 100644 --- a/src/util/vfs/vfs-lzma.c +++ b/src/util/vfs/vfs-lzma.c @@ -3,11 +3,11 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/vfs.h" +#include #ifdef USE_LZMA -#include "util/string.h" +#include #include "third-party/lzma/7z.h" #include "third-party/lzma/7zAlloc.h" diff --git a/src/util/vfs/vfs-mem.c b/src/util/vfs/vfs-mem.c index 2d8798012..7264577cf 100644 --- a/src/util/vfs/vfs-mem.c +++ b/src/util/vfs/vfs-mem.c @@ -3,8 +3,8 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/vfs.h" -#include "util/memory.h" +#include +#include struct VFileMem { struct VFile d; diff --git a/src/util/vfs/vfs-zip.c b/src/util/vfs/vfs-zip.c index a0773ae8a..13220a303 100644 --- a/src/util/vfs/vfs-zip.c +++ b/src/util/vfs/vfs-zip.c @@ -3,9 +3,9 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/vfs.h" +#include -#include "util/string.h" +#include #ifdef USE_LIBZIP #include @@ -41,7 +41,7 @@ enum { #else #include "third-party/zlib/contrib/minizip/unzip.h" #endif -#include "util/memory.h" +#include struct VDirEntryZip { struct VDirEntry d; From 978349d7652ae68f6a1fddac4b074a5e059bb94e Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 30 Dec 2016 23:46:07 -0800 Subject: [PATCH 52/56] Windows: Fix build --- src/platform/windows/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/windows/memory.c b/src/platform/windows/memory.c index d2baddbb1..3c05b02d7 100644 --- a/src/platform/windows/memory.c +++ b/src/platform/windows/memory.c @@ -3,7 +3,7 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "util/memory.h" +#include #include From 2c52c55efc8404c5922acdc515288d660c3ea268 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 31 Dec 2016 01:29:03 -0800 Subject: [PATCH 53/56] Windows: Fix VDir unitialized variable --- src/platform/windows/vfs-w32.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/platform/windows/vfs-w32.c b/src/platform/windows/vfs-w32.c index 315429fae..398ec5ba4 100644 --- a/src/platform/windows/vfs-w32.c +++ b/src/platform/windows/vfs-w32.c @@ -63,6 +63,7 @@ struct VDir* VDirOpen(const char* path) { vd->vde.d.name = _vdweName; vd->vde.d.type = _vdweType; vd->vde.ffData = ffData; + vd->vde.utf8Name = NULL; return &vd->d; } From ae9feee1476438dd795c5ffba9138a74e07401f4 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 31 Dec 2016 01:56:26 -0800 Subject: [PATCH 54/56] All: Update CHANGES for 0.5.2 --- CHANGES | 81 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/CHANGES b/CHANGES index ca1415751..5e1cda320 100644 --- a/CHANGES +++ b/CHANGES @@ -7,44 +7,10 @@ Features: - Debugging console - Improved memory viewer Bugfixes: - - Libretro: Fix unterminated SET_INPUT_DESCRIPTORS - LR35902: Fix core never exiting with certain event patterns - GB Timer: Improve DIV reset behavior - - GBA Memory: Fix misaligned BIOS reads - - GBA BIOS: Fix MidiKey2Freq BIOS reads - - GBA BIOS: Fix invalid CpuSet not setting BIOS prefetch - - GB MBC: Fix SRAM dangling pointer with RTC games - - Windows: Fix Unicode directory handling - - Qt: Fix changing resolution of software renderer - - Qt: Fix setting overrides - - GBA Cheats: Fix GameShark ROM patches - - Qt: Fix cut off tiles and alignment issues in tile viewer - - GB MBC: Fix initializing MBC when no ROM is loaded - - VFS: Fix resizing memory chunks when not needed - - GB Memory: Fix patching ROM bank 0 - - GB: Fix audio not being deinitialized - - GBA Memory: Fix VCOUNT being writable - GBA Memory: Improve initial skipped BIOS state - - Qt: Only reset window dimensions when first shown - - GB Memory: Fix starting HDMAs during mode 0 - - Qt: Fix Qt Multimedia audio driver on big endian - - GBA: Fix IRQs firing after already being cleared - - All: Fix fullscreen config option being ignored - GBA BIOS: Implement BitUnPack - - GBA: Add savegame override for Crash Bandicoot 2 - - ARM7: PSR mode bits should not get sign extended - - GBA: Only unhalt CPU if appropriate bit is set in IE - - GBA Video: Fix out of bounds sprite transforms - - GB: Fix crash when masking savedata - - GB Audio: Fix serialization of channel 3 and NR52 properties - - GB: Properly initialize sramRealVf variable - - Qt: Fix Apply button for key and controller configurations - - GB Video: Initialize LCDC in renderer - - GBA I/O: Mask off WAITCNT bits that cannot be written - - GB Memory: Fix HDMA5 value after DMA completes - - GB Video: Hblank IRQs should mask LYC=LY IRQs - - GB Audio: Reset envelope timer when reseting sound channel - - Libretro: Fix disabling BIOS Misc: - SDL: Remove scancode key input - GBA Video: Clean up unused timers @@ -52,8 +18,6 @@ Misc: - GBA Video: Allow multiple handles into the same tile cache - VFS: Call msync when syncing mapped data - GBA Video, GB Video: Colors are now fully scaled - - PSP2: Improved controller rumble - - GB, GBA: Prevent loading null ROMs - VFS: Allow truncating memory chunk VFiles - Debugger: Modularize CLI debugger - Core: Clean up some thread state checks @@ -65,15 +29,56 @@ Misc: - 3DS, PSP2, Wii: Last directory loaded is saved - GB Audio: Simplify envelope code - GB Audio: Improve initial envelope samples - - GB Audio: Initialize wave RAM to GBC values - Debugger: Add functions for read- or write-only watchpoints - - GB Memory: Reset ROM bank when loading a ROM - GBA DMA: Refactor DMA out of memory.c - GBA DMA: Move DMAs to using absolute timing - All: Add C++ header guards - GBA I/O: Clear JOYSTAT RECV flag when reading JOY_RECV registers - GBA I/O: Set JOYSTAT TRANS flag when writing JOY_TRANS registers +0.5.2: (2016-12-31) +Bugfixes: + - All: Fix fullscreen config option being ignored + - ARM7: PSR mode bits should not get sign extended + - GB: Fix audio not being deinitialized + - GB: Fix crash when masking savedata + - GB: Properly initialize sramRealVf variable + - GB Audio: Fix serialization of channel 3 and NR52 properties + - GB Audio: Reset envelope timer when reseting sound channel + - GB MBC: Fix SRAM dangling pointer with RTC games + - GB MBC: Fix initializing MBC when no ROM is loaded + - GB Memory: Fix patching ROM bank 0 + - GB Memory: Fix starting HDMAs during mode 0 + - GB Memory: Fix HDMA5 value after DMA completes + - GB Video: Initialize LCDC in renderer + - GB Video: Hblank IRQs should mask LYC=LY IRQs + - GBA: Fix IRQs firing after already being cleared + - GBA: Only unhalt CPU if appropriate bit is set in IE + - GBA: Add savegame override for Crash Bandicoot 2 + - GBA BIOS: Fix MidiKey2Freq BIOS reads + - GBA BIOS: Fix invalid CpuSet not setting BIOS prefetch + - GBA Cheats: Fix GameShark ROM patches + - GBA I/O: Mask off WAITCNT bits that cannot be written + - GBA Memory: Fix misaligned BIOS reads + - GBA Memory: Fix VCOUNT being writable + - GBA Video: Fix out of bounds sprite transforms + - Libretro: Fix unterminated SET_INPUT_DESCRIPTORS + - Libretro: Fix disabling BIOS + - Libretro: Fix Game Boy savestates and audio + - Qt: Fix changing resolution of software renderer + - Qt: Fix setting overrides + - Qt: Fix cut off tiles and alignment issues in tile viewer + - Qt: Only reset window dimensions when first shown + - Qt: Fix Qt Multimedia audio driver on big endian + - Qt: Fix Apply button for key and controller configurations + - VFS: Fix resizing memory chunks when not needed + - Windows: Fix Unicode directory handling +Misc: + - GB, GBA: Prevent loading null ROMs + - GB Audio: Initialize wave RAM to GBC values + - GB Memory: Reset ROM bank when loading a ROM + - PSP2: Improved controller rumble + 0.5.1: (2016-10-05) Bugfixes: - Core: Fix importing save games as read-only From 180418a74f035dfd8b7bddb2a437b9ed9b528d3a Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 1 Jan 2017 14:46:58 -0800 Subject: [PATCH 55/56] ARM7: Fix MLA/*MULL/*MLAL timing --- CHANGES | 1 + src/arm/isa-arm.c | 43 ++++++++++++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/CHANGES b/CHANGES index 5e1cda320..461248c44 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,7 @@ Bugfixes: - GB Timer: Improve DIV reset behavior - GBA Memory: Improve initial skipped BIOS state - GBA BIOS: Implement BitUnPack + - ARM7: Fix MLA/*MULL/*MLAL timing Misc: - SDL: Remove scancode key input - GBA Video: Clean up unused timers diff --git a/src/arm/isa-arm.c b/src/arm/isa-arm.c index 85323a1a1..8533833bc 100644 --- a/src/arm/isa-arm.c +++ b/src/arm/isa-arm.c @@ -316,11 +316,10 @@ static inline void _immediate(struct ARMCore* cpu, uint32_t opcode) { #define DEFINE_MULTIPLY_INSTRUCTION_EX_ARM(NAME, BODY, S_BODY) \ DEFINE_INSTRUCTION_ARM(NAME, \ - int rd = (opcode >> 12) & 0xF; \ - int rdHi = (opcode >> 16) & 0xF; \ + int rd = (opcode >> 16) & 0xF; \ int rs = (opcode >> 8) & 0xF; \ int rm = opcode & 0xF; \ - if (rdHi == ARM_PC || rd == ARM_PC) { \ + if (rd == ARM_PC) { \ return; \ } \ ARM_WAIT_MUL(cpu->gprs[rs]); \ @@ -328,10 +327,28 @@ static inline void _immediate(struct ARMCore* cpu, uint32_t opcode) { S_BODY; \ currentCycles += cpu->memory.activeNonseqCycles32 - cpu->memory.activeSeqCycles32) +#define DEFINE_MULTIPLY_INSTRUCTION_2_EX_ARM(NAME, BODY, S_BODY, WAIT) \ + DEFINE_INSTRUCTION_ARM(NAME, \ + int rd = (opcode >> 12) & 0xF; \ + int rdHi = (opcode >> 16) & 0xF; \ + int rs = (opcode >> 8) & 0xF; \ + int rm = opcode & 0xF; \ + if (rdHi == ARM_PC || rd == ARM_PC) { \ + return; \ + } \ + currentCycles += cpu->memory.stall(cpu, WAIT); \ + BODY; \ + S_BODY; \ + currentCycles += cpu->memory.activeNonseqCycles32 - cpu->memory.activeSeqCycles32) + #define DEFINE_MULTIPLY_INSTRUCTION_ARM(NAME, BODY, S_BODY) \ DEFINE_MULTIPLY_INSTRUCTION_EX_ARM(NAME, BODY, ) \ DEFINE_MULTIPLY_INSTRUCTION_EX_ARM(NAME ## S, BODY, S_BODY) +#define DEFINE_MULTIPLY_INSTRUCTION_2_ARM(NAME, BODY, S_BODY, WAIT) \ + DEFINE_MULTIPLY_INSTRUCTION_2_EX_ARM(NAME, BODY, , WAIT) \ + DEFINE_MULTIPLY_INSTRUCTION_2_EX_ARM(NAME ## S, BODY, S_BODY, WAIT) + #define DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME, ADDRESS, WRITEBACK, BODY) \ DEFINE_INSTRUCTION_ARM(NAME, \ uint32_t address; \ @@ -485,36 +502,36 @@ DEFINE_ALU_INSTRUCTION_S_ONLY_ARM(TST, ARM_NEUTRAL_S(cpu->gprs[rn], cpu->shifter // Begin multiply definitions -DEFINE_MULTIPLY_INSTRUCTION_ARM(MLA, cpu->gprs[rdHi] = cpu->gprs[rm] * cpu->gprs[rs] + cpu->gprs[rd], ARM_NEUTRAL_S(, , cpu->gprs[rdHi])) -DEFINE_MULTIPLY_INSTRUCTION_ARM(MUL, cpu->gprs[rdHi] = cpu->gprs[rm] * cpu->gprs[rs], ARM_NEUTRAL_S(cpu->gprs[rm], cpu->gprs[rs], cpu->gprs[rdHi])) +DEFINE_MULTIPLY_INSTRUCTION_2_ARM(MLA, cpu->gprs[rdHi] = cpu->gprs[rm] * cpu->gprs[rs] + cpu->gprs[rd], ARM_NEUTRAL_S(, , cpu->gprs[rdHi]), 2) +DEFINE_MULTIPLY_INSTRUCTION_ARM(MUL, cpu->gprs[rd] = cpu->gprs[rm] * cpu->gprs[rs], ARM_NEUTRAL_S(cpu->gprs[rm], cpu->gprs[rs], cpu->gprs[rd])) -DEFINE_MULTIPLY_INSTRUCTION_ARM(SMLAL, +DEFINE_MULTIPLY_INSTRUCTION_2_ARM(SMLAL, int64_t d = ((int64_t) cpu->gprs[rm]) * ((int64_t) cpu->gprs[rs]); int32_t dm = cpu->gprs[rd]; int32_t dn = d; cpu->gprs[rd] = dm + dn; cpu->gprs[rdHi] = cpu->gprs[rdHi] + (d >> 32) + ARM_CARRY_FROM(dm, dn, cpu->gprs[rd]);, - ARM_NEUTRAL_HI_S(cpu->gprs[rd], cpu->gprs[rdHi])) + ARM_NEUTRAL_HI_S(cpu->gprs[rd], cpu->gprs[rdHi]), 3) -DEFINE_MULTIPLY_INSTRUCTION_ARM(SMULL, +DEFINE_MULTIPLY_INSTRUCTION_2_ARM(SMULL, int64_t d = ((int64_t) cpu->gprs[rm]) * ((int64_t) cpu->gprs[rs]); cpu->gprs[rd] = d; cpu->gprs[rdHi] = d >> 32;, - ARM_NEUTRAL_HI_S(cpu->gprs[rd], cpu->gprs[rdHi])) + ARM_NEUTRAL_HI_S(cpu->gprs[rd], cpu->gprs[rdHi]), 2) -DEFINE_MULTIPLY_INSTRUCTION_ARM(UMLAL, +DEFINE_MULTIPLY_INSTRUCTION_2_ARM(UMLAL, uint64_t d = ARM_UXT_64(cpu->gprs[rm]) * ARM_UXT_64(cpu->gprs[rs]); int32_t dm = cpu->gprs[rd]; int32_t dn = d; cpu->gprs[rd] = dm + dn; cpu->gprs[rdHi] = cpu->gprs[rdHi] + (d >> 32) + ARM_CARRY_FROM(dm, dn, cpu->gprs[rd]);, - ARM_NEUTRAL_HI_S(cpu->gprs[rd], cpu->gprs[rdHi])) + ARM_NEUTRAL_HI_S(cpu->gprs[rd], cpu->gprs[rdHi]), 3) -DEFINE_MULTIPLY_INSTRUCTION_ARM(UMULL, +DEFINE_MULTIPLY_INSTRUCTION_2_ARM(UMULL, uint64_t d = ARM_UXT_64(cpu->gprs[rm]) * ARM_UXT_64(cpu->gprs[rs]); cpu->gprs[rd] = d; cpu->gprs[rdHi] = d >> 32;, - ARM_NEUTRAL_HI_S(cpu->gprs[rd], cpu->gprs[rdHi])) + ARM_NEUTRAL_HI_S(cpu->gprs[rd], cpu->gprs[rdHi]), 2) // End multiply definitions From 3f61f68f22bd5545d4d65ad7f78b7426fe1e8c34 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 1 Jan 2017 22:04:04 -0800 Subject: [PATCH 56/56] GBA: Fix multiboot ROM loading --- CHANGES | 1 + src/gba/core.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGES b/CHANGES index 461248c44..261370424 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,7 @@ Bugfixes: - GBA Memory: Improve initial skipped BIOS state - GBA BIOS: Implement BitUnPack - ARM7: Fix MLA/*MULL/*MLAL timing + - GBA: Fix multiboot ROM loading Misc: - SDL: Remove scancode key input - GBA Video: Clean up unused timers diff --git a/src/gba/core.c b/src/gba/core.c index 52b7be0d9..397cdcb7d 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -198,6 +198,9 @@ static void _GBACoreSetAVStream(struct mCore* core, struct mAVStream* stream) { } static bool _GBACoreLoadROM(struct mCore* core, struct VFile* vf) { + if (GBAIsMB(vf)) { + return GBALoadMB(core->board, vf); + } return GBALoadROM(core->board, vf); }