Merge branch 'master' into medusa

This commit is contained in:
Jeffrey Pfau 2017-01-02 18:17:50 -08:00
commit 87caf0a6ac
411 changed files with 3751 additions and 1490 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
*.user*
*~
*.swp
*.pyc

85
CHANGES
View File

@ -7,43 +7,12 @@ 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
- ARM7: Fix MLA/*MULL/*MLAL timing
- GBA: Fix multiboot ROM loading
- SDL: Prevent crash on cores with no audio
- ARM7: Decode MCR/MRC
- ARM7: Clean up instruction decoding for future expandability
@ -54,8 +23,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
@ -67,11 +34,55 @@ 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:

View File

@ -29,6 +29,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)")
@ -53,7 +54,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)
@ -61,12 +63,12 @@ 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("DS board" FILES ${DS_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)
@ -153,6 +155,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)
@ -643,7 +648,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}
@ -777,6 +786,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})
@ -787,7 +801,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()
@ -861,6 +875,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}")

View File

@ -6,7 +6,9 @@
#ifndef CIRCLE_BUFFER_H
#define CIRCLE_BUFFER_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct CircleBuffer {
void* data;
@ -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

View File

@ -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 <ctype.h>
#include <fcntl.h>
#include <inttypes.h>
@ -46,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
@ -177,4 +189,6 @@ typedef intptr_t ssize_t;
#define ROR(I, ROTATE) ((((uint32_t) (I)) >> ROTATE) | ((uint32_t) (I) << ((-ROTATE) & 31)))
CXX_GUARD_END
#endif

View File

@ -6,7 +6,11 @@
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include "util/table.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#include <mgba-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

View File

@ -6,7 +6,9 @@
#ifndef CRC32_H
#define CRC32_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct VFile;
@ -14,4 +16,6 @@ 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

View File

@ -6,11 +6,15 @@
#ifndef EXPORT_H
#define EXPORT_H
#include "util/common.h"
#include <mgba-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

View File

@ -6,7 +6,9 @@
#ifndef FORMATTING_H
#define FORMATTING_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#include "locale.h"
@ -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

View File

@ -6,10 +6,13 @@
#ifndef GUI_H
#define GUI_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/input.h"
#include "util/vector.h"
CXX_GUARD_START
// TODO: Fix layering violation
#include <mgba/core/input.h>
#include <mgba-util/vector.h>
struct GUIFont;
@ -81,4 +84,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

View File

@ -6,10 +6,16 @@
#ifndef GUI_FILE_CHOOSER_H
#define GUI_FILE_CHOOSER_H
#include "util/gui.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#include <mgba-util/gui.h>
struct VFile;
bool GUISelectFile(struct GUIParams*, char* outPath, size_t outLen, bool (*filter)(struct VFile*));
CXX_GUARD_END
#endif

View File

@ -6,7 +6,7 @@
#ifndef DEFAULT_FONT_METRICS_H
#define DEFAULT_FONT_METRICS_H
#include "util/gui/font.h"
#include <mgba-util/gui/font.h>
extern struct GUIFontGlyphMetric defaultFontMetrics[];
extern struct GUIIconMetric defaultIconMetrics[];

View File

@ -6,7 +6,9 @@
#ifndef GUI_FONT_H
#define GUI_FONT_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct GUIFont;
struct GUIFont* GUIFontCreate(void);
@ -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

View File

@ -6,7 +6,11 @@
#ifndef GUI_MENU_H
#define GUI_MENU_H
#include "util/vector.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#include <mgba-util/vector.h>
struct GUIMenu;
struct GUIMenuItem {
@ -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

View File

@ -6,8 +6,12 @@
#ifndef HASH_H
#define HASH_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
uint32_t hash32(const void* key, int len, uint32_t seed);
CXX_GUARD_END
#endif

View File

@ -6,7 +6,9 @@
#ifndef UTIL_MATH_H
#define UTIL_MATH_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
static inline uint32_t popcount32(unsigned bits) {
bits = bits - ((bits >> 1) & 0x55555555);
@ -59,4 +61,6 @@ static inline uint32_t toPow2(uint32_t bits) {
return 1 << (32 - lz);
}
CXX_GUARD_END
#endif

View File

@ -6,9 +6,13 @@
#ifndef MEMORY_H
#define MEMORY_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
void* anonymousMemoryMap(size_t size);
void mappedMemoryFree(void* memory, size_t size);
CXX_GUARD_END
#endif

View File

@ -6,7 +6,9 @@
#ifndef NOINTRO_H
#define NOINTRO_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct NoIntroGame {
const char* name;
@ -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

View File

@ -6,7 +6,9 @@
#ifndef PATCH_H
#define PATCH_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct VFile;
@ -19,4 +21,6 @@ struct Patch {
bool loadPatch(struct VFile* vf, struct Patch* patch);
CXX_GUARD_END
#endif

View File

@ -6,10 +6,12 @@
#ifndef PATCH_FAST_H
#define PATCH_FAST_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "util/patch.h"
#include "util/vector.h"
CXX_GUARD_START
#include <mgba-util/patch.h>
#include <mgba-util/vector.h>
#define PATCH_FAST_EXTENT 256
@ -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

View File

@ -6,10 +6,14 @@
#ifndef PATCH_IPS_H
#define PATCH_IPS_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct Patch;
bool loadPatchIPS(struct Patch* patch);
CXX_GUARD_END
#endif

View File

@ -6,10 +6,14 @@
#ifndef PATCH_UPS_H
#define PATCH_UPS_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct Patch;
bool loadPatchUPS(struct Patch* patch);
CXX_GUARD_END
#endif

View File

@ -6,7 +6,7 @@
#ifndef N3DS_VFS_H
#define N3DS_VFS_H
#include "util/vfs.h"
#include <mgba-util/vfs.h>
#include <3ds.h>

View File

@ -6,7 +6,7 @@
#ifndef N3DS_THREADING_H
#define N3DS_THREADING_H
#include "util/common.h"
#include <mgba-util/common.h>
#include <3ds.h>
#include <malloc.h>

View File

@ -6,7 +6,9 @@
#ifndef POSIX_THREADING_H
#define POSIX_THREADING_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#include <pthread.h>
#include <sys/time.h>
@ -94,4 +96,6 @@ static inline int ThreadSetName(const char* name) {
#endif
}
CXX_GUARD_END
#endif

View File

@ -6,7 +6,7 @@
#ifndef WINDOWS_THREADING_H
#define WINDOWS_THREADING_H
#include "util/common.h"
#include <mgba-util/common.h>
#define _WIN32_WINNT 0x0600
#include <windows.h>

View File

@ -6,7 +6,9 @@
#ifndef PNG_IO_H
#define PNG_IO_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#ifdef USE_PNG
@ -37,4 +39,6 @@ void PNGReadClose(png_structp png, png_infop info, png_infop end);
#endif
CXX_GUARD_END
#endif

View File

@ -6,7 +6,9 @@
#ifndef RING_FIFO_H
#define RING_FIFO_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct RingFIFO {
void* data;
@ -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

View File

@ -6,7 +6,9 @@
#ifndef SOCKET_H
#define SOCKET_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#if defined(__cplusplus) && !defined(restrict)
#define restrict __restrict__
@ -316,4 +318,6 @@ static inline int SocketPoll(size_t nSockets, Socket* reads, Socket* writes, Soc
return result;
}
CXX_GUARD_END
#endif

View File

@ -6,7 +6,9 @@
#ifndef UTIL_STRING_H
#define UTIL_STRING_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#ifndef HAVE_STRNDUP
// This is sometimes a macro
@ -36,4 +38,6 @@ const char* hex4(const char* line, uint8_t* out);
void rtrim(char* string);
CXX_GUARD_END
#endif

View File

@ -6,7 +6,9 @@
#ifndef TABLE_H
#define TABLE_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct TableList;
@ -29,13 +31,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*);
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);
}
void HashTableInit(struct Table* table, size_t initialSize, void (deinitializer(void*)));
void HashTableDeinit(struct Table* table);
void* HashTableLookup(const struct Table*, const char* key);
void HashTableInsert(struct Table*, const char* key, void* value);
@ -46,4 +43,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

View File

@ -6,7 +6,9 @@
#ifndef TEXT_CODEC_H
#define TEXT_CODEC_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct TextCodecNode;
struct TextCodec {
@ -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

View File

@ -6,17 +6,19 @@
#ifndef THREADING_H
#define THREADING_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#ifndef DISABLE_THREADING
#ifdef USE_PTHREADS
#include "platform/posix/threading.h"
#include <mgba-util/platform/posix/threading.h>
#elif _WIN32
#include "platform/windows/threading.h"
#include <mgba-util/platform/windows/threading.h>
#elif PSP2
#include "platform/psp2/threading.h"
#include <mgba-util/platform/psp2/threading.h>
#elif _3DS
#include "platform/3ds/threading.h"
#include <mgba-util/platform/3ds/threading.h>
#else
#define DISABLE_THREADING
#endif
@ -85,4 +87,6 @@ static inline int ConditionWake(Condition* cond) {
}
#endif
CXX_GUARD_END
#endif

View File

@ -6,7 +6,9 @@
#ifndef VECTOR_H
#define VECTOR_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#define DECLARE_VECTOR(NAME, TYPE) \
struct NAME { \
@ -84,4 +86,6 @@
return member - (const TYPE*) vector->vector; \
} \
CXX_GUARD_END
#endif

View File

@ -6,7 +6,9 @@
#ifndef VFS_H
#define VFS_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#ifdef _WIN32
#include <io.h>
@ -65,12 +67,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 +84,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);
@ -97,4 +102,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

View File

@ -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* );

View File

@ -6,11 +6,13 @@
#ifndef CHEATS_H
#define CHEATS_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/cpu.h"
#include "core/log.h"
#include "util/vector.h"
CXX_GUARD_START
#include <mgba/core/cpu.h>
#include <mgba/core/log.h>
#include <mgba-util/vector.h>
#define MAX_ROM_PATCHES 4
@ -100,4 +102,6 @@ bool mCheatSaveFile(struct mCheatDevice*, struct VFile*);
void mCheatRefresh(struct mCheatDevice*, struct mCheatSet*);
CXX_GUARD_END
#endif

View File

@ -6,9 +6,11 @@
#ifndef M_CORE_CONFIG_H
#define M_CORE_CONFIG_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "util/configuration.h"
CXX_GUARD_START
#include <mgba-util/configuration.h>
struct mCoreConfig {
struct Configuration configTable;
@ -91,4 +93,6 @@ const struct Configuration* mCoreConfigGetOverridesConst(const struct mCoreConfi
void mCoreConfigFreeOpts(struct mCoreOptions* opts);
CXX_GUARD_END
#endif

View File

@ -6,18 +6,21 @@
#ifndef M_CORE_H
#define M_CORE_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/config.h"
CXX_GUARD_START
#include <mgba/core/config.h>
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
#include "core/directories.h"
#include <mgba/core/directories.h>
#endif
#ifndef MINIMAL_CORE
#include "core/input.h"
#include <mgba/core/input.h>
#endif
#include "core/interface.h"
#include <mgba/core/interface.h>
#ifdef USE_DEBUGGERS
#include "debugger/debugger.h"
// TODO: Fix layering violation
#include <mgba/internal/debugger/debugger.h>
#endif
enum mPlatform {
@ -162,4 +165,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

View File

@ -6,7 +6,9 @@
#ifndef M_CPU_H
#define M_CPU_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
enum mCPUComponentType {
CPU_COMPONENT_DEBUGGER,
@ -20,4 +22,6 @@ struct mCPUComponent {
void (*deinit)(struct mCPUComponent* component);
};
CXX_GUARD_END
#endif

View File

@ -6,7 +6,9 @@
#ifndef DIRECTORIES_H
#define DIRECTORIES_H
#include "util/common.h"
#include <mgba-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

View File

@ -6,7 +6,9 @@
#ifndef M_INPUT_H
#define M_INPUT_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct Configuration;
@ -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

View File

@ -6,7 +6,9 @@
#ifndef CORE_INTERFACE_H
#define CORE_INTERFACE_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct mCore;
@ -84,4 +86,6 @@ struct mRumble {
void (*setRumble)(struct mRumble*, int enable);
};
CXX_GUARD_END
#endif

View File

@ -6,10 +6,12 @@
#ifndef M_LIBRARY_H
#define M_LIBRARY_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/core.h"
#include "util/vector.h"
CXX_GUARD_START
#include <mgba/core/core.h>
#include <mgba-util/vector.h>
struct mLibraryEntry {
char* filename;
@ -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

View File

@ -0,0 +1,41 @@
/* 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 <mgba-util/common.h>
CXX_GUARD_START
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*);
CXX_GUARD_END
#endif

View File

@ -6,7 +6,9 @@
#ifndef M_LOG_H
#define M_LOG_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
enum mLogLevel {
mLOG_FATAL = 0x01,
@ -30,19 +32,7 @@ int mLogGenerateCategory(const char*);
const char* mLogCategoryName(int);
ATTRIBUTE_FORMAT(printf, 3, 4)
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);
}
void mLog(int category, enum mLogLevel level, const char* format, ...);
#define mLOG(CATEGORY, LEVEL, ...) mLog(_mLOG_CAT_ ## CATEGORY (), mLOG_ ## LEVEL, __VA_ARGS__)
@ -58,4 +48,6 @@ static inline void mLog(int category, enum mLogLevel level, const char* format,
mLOG_DECLARE_CATEGORY(STATUS)
CXX_GUARD_END
#endif

View File

@ -6,9 +6,11 @@
#ifndef M_CORE_REWIND_H
#define M_CORE_REWIND_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "util/vector.h"
CXX_GUARD_START
#include <mgba-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

View File

@ -6,7 +6,9 @@
#ifndef M_SERIALIZE_H
#define M_SERIALIZE_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
enum mStateExtdataTag {
EXTDATA_NONE = 0,
@ -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

View File

@ -6,9 +6,11 @@
#ifndef M_CORE_SYNC_H
#define M_CORE_SYNC_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "util/threading.h"
CXX_GUARD_START
#include <mgba-util/threading.h>
struct mCoreSync {
int videoFramePending;
@ -36,4 +38,6 @@ void mCoreSyncLockAudio(struct mCoreSync* sync);
void mCoreSyncUnlockAudio(struct mCoreSync* sync);
void mCoreSyncConsumeAudio(struct mCoreSync* sync);
CXX_GUARD_END
#endif

View File

@ -6,12 +6,14 @@
#ifndef M_CORE_THREAD_H
#define M_CORE_THREAD_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/log.h"
#include "core/rewind.h"
#include "core/sync.h"
#include "util/threading.h"
CXX_GUARD_START
#include <mgba/core/log.h>
#include <mgba/core/rewind.h>
#include <mgba/core/sync.h>
#include <mgba-util/threading.h>
struct mCoreThread;
struct mCore;
@ -97,4 +99,6 @@ void mCoreThreadSetRewinding(struct mCoreThread* threadContext, bool);
struct mCoreThread* mCoreThreadGet(void);
struct mLogger* mCoreThreadLogger(void);
CXX_GUARD_END
#endif

View File

@ -6,7 +6,9 @@
#ifndef M_TILE_CACHE_H
#define M_TILE_CACHE_H
#include "util/common.h"
#include <mgba-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

View File

@ -6,7 +6,9 @@
#ifndef M_CORE_TIMING
#define M_CORE_TIMING
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct mTiming;
struct mTimingEvent {
@ -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

View File

@ -6,7 +6,13 @@
#ifndef DS_CORE_H
#define DS_CORE_H
#include <mgba-util/common.h>
CXX_GUARD_START
struct mCore;
struct mCore* DSCoreCreate(void);
CXX_GUARD_END
#endif

View File

@ -6,7 +6,13 @@
#ifndef GB_CORE_H
#define GB_CORE_H
#include <mgba-util/common.h>
CXX_GUARD_START
struct mCore;
struct mCore* GBCoreCreate(void);
CXX_GUARD_END
#endif

View File

@ -6,7 +6,9 @@
#ifndef GB_INTERFACE_H
#define GB_INTERFACE_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
enum GBModel {
GB_MODEL_AUTODETECT = 0xFF,
@ -32,4 +34,6 @@ enum GBMemoryBankControllerType {
GB_MBC5_RUMBLE = 0x105
};
CXX_GUARD_END
#endif

View File

@ -6,7 +6,13 @@
#ifndef GBA_CORE_H
#define GBA_CORE_H
#include <mgba-util/common.h>
CXX_GUARD_START
struct mCore;
struct mCore* GBACoreCreate(void);
CXX_GUARD_END
#endif

View File

@ -6,9 +6,11 @@
#ifndef GBA_INTERFACE_H
#define GBA_INTERFACE_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/interface.h"
CXX_GUARD_START
#include <mgba/core/interface.h>
enum GBASIOMode {
SIO_NORMAL_8 = 0,
@ -42,4 +44,6 @@ struct GBASIODriver {
uint16_t (*writeRegister)(struct GBASIODriver* driver, uint32_t address, uint16_t value);
};
CXX_GUARD_END
#endif

View File

@ -6,9 +6,11 @@
#ifndef ARM_H
#define ARM_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/cpu.h"
CXX_GUARD_START
#include <mgba/core/cpu.h>
enum {
ARM_SP = 13,
@ -73,7 +75,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 +85,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;
@ -261,4 +263,6 @@ void ARMv5RunLoop(struct ARMCore* cpu);
int32_t ARMv5RunCycles(struct ARMCore* cpu, int32_t cycles);
void ARMRunFake(struct ARMCore* cpu, uint32_t opcode);
CXX_GUARD_END
#endif

View File

@ -6,9 +6,13 @@
#ifndef ARM_CLI_DEBUGGER_H
#define ARM_CLI_DEBUGGER_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct CLIDebuggerSystem;
void ARMCLIDebuggerCreate(struct CLIDebuggerSystem* debugger);
CXX_GUARD_END
#endif

View File

@ -3,7 +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 "debugger/debugger.h"
#ifndef ARM_DEBUGGER_H
#define ARM_DEBUGGER_H
#include <mgba-util/common.h>
CXX_GUARD_START
#include <mgba/internal/debugger/debugger.h>
#include <mgba/internal/arm/arm.h>
struct ARMDebugBreakpoint {
uint32_t address;
@ -40,3 +49,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

View File

@ -6,11 +6,15 @@
#ifndef MEMORY_DEBUGGER_H
#define MEMORY_DEBUGGER_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct ARMDebugger;
void ARMDebuggerInstallMemoryShim(struct ARMDebugger* debugger);
void ARMDebuggerRemoveMemoryShim(struct ARMDebugger* debugger);
CXX_GUARD_END
#endif

View File

@ -6,7 +6,11 @@
#ifndef ARM_DECODER_H
#define ARM_DECODER_H
#include "arm.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#include <mgba/internal/arm/arm.h>
// Bit 0: a register is involved with this operand
// Bit 1: an immediate is invovled with this operand
@ -234,4 +238,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

View File

@ -6,7 +6,9 @@
#ifndef ISA_ARM_H
#define ISA_ARM_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#define ARM_PREFETCH_CYCLES (1 + cpu->memory.activeSeqCycles32)
@ -16,4 +18,6 @@ typedef void (*ARMInstruction)(struct ARMCore*, uint32_t opcode);
extern const ARMInstruction _armv4Table[0x1000];
extern const ARMInstruction _armv5Table[0x1000];
CXX_GUARD_END
#endif

View File

@ -6,11 +6,15 @@
#ifndef ISA_THUMB_H
#define ISA_THUMB_H
#include "util/common.h"
#include <mgba-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

View File

@ -6,7 +6,7 @@
#ifndef MACROS_H
#define MACROS_H
#include "util/common.h"
#include <mgba-util/common.h>
#define LOAD_64 LOAD_64LE
#define LOAD_32 LOAD_32LE

View File

@ -6,9 +6,11 @@
#ifndef CLI_DEBUGGER_H
#define CLI_DEBUGGER_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "debugger.h"
CXX_GUARD_START
#include <mgba/internal/debugger/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

View File

@ -6,11 +6,13 @@
#ifndef DEBUGGER_H
#define DEBUGGER_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "arm/arm.h"
#include "core/log.h"
#include "util/vector.h"
CXX_GUARD_START
#include <mgba/core/cpu.h>
#include <mgba/core/log.h>
#include <mgba-util/vector.h>
mLOG_DECLARE_CATEGORY(DEBUGGER);
@ -35,7 +37,7 @@ enum mDebuggerState {
enum mWatchpointType {
WATCHPOINT_WRITE = 1,
WATCHPOINT_READ = 2,
WATCHPOINT_RW = WATCHPOINT_WRITE | WATCHPOINT_READ
WATCHPOINT_RW = 3
};
enum mBreakpointType {
@ -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

View File

@ -6,11 +6,13 @@
#ifndef GDB_STUB_H
#define GDB_STUB_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "debugger/debugger.h"
CXX_GUARD_START
#include "util/socket.h"
#include <mgba/internal/debugger/debugger.h>
#include <mgba-util/socket.h>
#define GDB_STUB_MAX_LINE 1200
#define GDB_STUB_INTERVAL 32
@ -47,4 +49,6 @@ void GDBStubShutdown(struct GDBStub*);
void GDBStubUpdate(struct GDBStub*);
CXX_GUARD_END
#endif

View File

@ -6,8 +6,11 @@
#ifndef PARSER_H
#define PARSER_H
#include "util/common.h"
#include "debugger.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#include <mgba/internal/debugger/debugger.h>
enum LexState {
LEX_ERROR = -1,
@ -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

View File

@ -6,9 +6,11 @@
#ifndef DS_BIOS_H
#define DS_BIOS_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/log.h"
CXX_GUARD_START
#include <mgba/core/log.h>
mLOG_DECLARE_CATEGORY(DS_BIOS);
@ -21,4 +23,6 @@ void DS9Swi32(struct ARMCore* cpu, int immediate);
extern const uint32_t DS7_BIOS_CHECKSUM;
extern const uint32_t DS9_BIOS_CHECKSUM;
CXX_GUARD_END
#endif

View File

@ -6,14 +6,16 @@
#ifndef DS_H
#define DS_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "arm/arm.h"
#include "core/log.h"
CXX_GUARD_START
#include "ds/memory.h"
#include "ds/timer.h"
#include "ds/video.h"
#include <mgba/internal/arm/arm.h>
#include <mgba/core/log.h>
#include <mgba/internal/ds/memory.h>
#include <mgba/internal/ds/timer.h>
#include <mgba/internal/ds/video.h>
extern const uint32_t DS_ARM946ES_FREQUENCY;
extern const uint32_t DS_ARM7TDMI_FREQUENCY;
@ -140,4 +142,6 @@ void DSWriteIME(struct ARMCore* cpu, uint16_t* io, uint16_t value);
void DSWriteIE(struct ARMCore* cpu, uint16_t* io, uint32_t value);
void DSRaiseIRQ(struct ARMCore* cpu, uint16_t* io, enum DSIRQ irq);
CXX_GUARD_END
#endif

View File

@ -6,7 +6,11 @@
#ifndef DS_CLI_H
#define DS_CLI_H
#include "debugger/cli-debugger.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#include <mgba/internal/debugger/cli-debugger.h>
struct mCore;
@ -21,4 +25,6 @@ struct DSCLIDebugger {
struct DSCLIDebugger* DSCLIDebuggerCreate(struct mCore*);
CXX_GUARD_END
#endif

View File

@ -6,9 +6,11 @@
#ifndef DS_IO_H
#define DS_IO_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/log.h"
CXX_GUARD_START
#include <mgba/core/log.h>
enum DS7IORegisters {
// Video
@ -339,4 +341,7 @@ void DS9IOWrite(struct DS* ds, uint32_t address, uint16_t value);
void DS9IOWrite8(struct DS* ds, uint32_t address, uint8_t value);
void DS9IOWrite32(struct DS* ds, uint32_t address, uint32_t value);
uint16_t DS9IORead(struct DS* ds, uint32_t address);
CXX_GUARD_END
#endif

View File

@ -6,11 +6,13 @@
#ifndef DS_MEMORY_H
#define DS_MEMORY_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "arm/arm.h"
#include "core/log.h"
#include "ds/io.h"
CXX_GUARD_START
#include <mgba/internal/arm/arm.h>
#include <mgba/core/log.h>
#include <mgba/internal/ds/io.h>
enum DSMemoryRegion {
DS7_REGION_BIOS = 0x0,

View File

@ -6,7 +6,9 @@
#ifndef DS_TIMER_H
#define DS_TIMER_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
DECL_BITFIELD(DSTimerFlags, uint32_t);
DECL_BITS(DSTimerFlags, PrescaleBits, 0, 4);
@ -31,4 +33,7 @@ void DSTimerWriteTMCNT_HI(struct DSTimer* timer, struct ARMCore* cpu, uint16_t*
struct DS;
int32_t DSTimersProcessEvents(struct DS* ds, int32_t cycles);
CXX_GUARD_END
#endif

View File

@ -6,9 +6,11 @@
#ifndef DS_VIDEO_H
#define DS_VIDEO_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/log.h"
CXX_GUARD_START
#include <mgba/core/log.h>
mLOG_DECLARE_CATEGORY(DS_VIDEO);
@ -48,4 +50,6 @@ void DSVideoInit(struct DSVideo* video);
void DSVideoReset(struct DSVideo* video);
void DSVideoDeinit(struct DSVideo* video);
CXX_GUARD_START
#endif

View File

@ -6,10 +6,11 @@
#ifndef GB_AUDIO_H
#define GB_AUDIO_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/timing.h"
#include "third-party/blip_buf/blip_buf.h"
CXX_GUARD_START
#include <mgba/core/timing.h>
DECL_BITFIELD(GBAudioRegisterDuty, uint8_t);
DECL_BITS(GBAudioRegisterDuty, Length, 0, 6);
@ -155,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;
@ -240,4 +241,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

View File

@ -6,10 +6,12 @@
#ifndef GB_CHEATS_H
#define GB_CHEATS_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/cheats.h"
#include "util/vector.h"
CXX_GUARD_START
#include <mgba/core/cheats.h>
#include <mgba-util/vector.h>
enum GBCheatType {
GB_CHEAT_AUTODETECT,
@ -36,4 +38,6 @@ struct GBCheatSet {
struct mCheatDevice* GBCheatDeviceCreate(void);
CXX_GUARD_END
#endif

View File

@ -6,7 +6,11 @@
#ifndef GB_CLI_H
#define GB_CLI_H
#include "debugger/cli-debugger.h"
#include <mgba-util/common.h>
CXX_GUARD_START
#include <mgba/internal/debugger/cli-debugger.h>
struct GBCLIDebugger {
struct CLIDebuggerSystem d;
@ -19,4 +23,6 @@ struct GBCLIDebugger {
struct CLIDebuggerSystem* GBCLIDebuggerCreate(struct mCore*);
CXX_GUARD_END
#endif

View File

@ -6,19 +6,19 @@
#ifndef GB_H
#define GB_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/log.h"
#include "core/timing.h"
CXX_GUARD_START
#include "lr35902/lr35902.h"
#include <mgba/core/cpu.h>
#include <mgba/core/log.h>
#include <mgba/core/timing.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 <mgba/internal/gb/audio.h>
#include <mgba/internal/gb/memory.h>
#include <mgba/internal/gb/sio.h>
#include <mgba/internal/gb/timer.h>
#include <mgba/internal/gb/video.h>
extern const uint32_t DMG_LR35902_FREQUENCY;
extern const uint32_t CGB_LR35902_FREQUENCY;
@ -43,6 +43,7 @@ enum GBIRQVector {
GB_VECTOR_KEYPAD = 0x60,
};
struct LR35902Core;
struct mCoreSync;
struct mAVStream;
struct mCoreCallbacks;
@ -79,6 +80,7 @@ struct GB {
struct mAVStream* stream;
bool cpuBlocked;
bool earlyExit;
struct mTimingEvent eiPending;
unsigned doubleSpeed;
};
@ -119,7 +121,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);
@ -140,4 +141,6 @@ void GBGetGameCode(const struct GB* gba, char* out);
void GBFrameEnded(struct GB* gb);
CXX_GUARD_END
#endif

View File

@ -6,9 +6,11 @@
#ifndef GB_IO_H
#define GB_IO_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/log.h"
CXX_GUARD_START
#include <mgba/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

View File

@ -6,9 +6,11 @@
#ifndef GB_MBC_H
#define GB_MBC_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/log.h"
CXX_GUARD_START
#include <mgba/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

View File

@ -6,12 +6,13 @@
#ifndef GB_MEMORY_H
#define GB_MEMORY_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/log.h"
#include "core/timing.h"
#include "gb/interface.h"
#include "lr35902/lr35902.h"
CXX_GUARD_START
#include <mgba/core/log.h>
#include <mgba/core/timing.h>
#include <mgba/gb/interface.h>
#include <time.h>
@ -152,6 +153,7 @@ struct GBMemory {
struct mRumble* rumble;
};
struct LR35902Core;
void GBMemoryInit(struct GB* gb);
void GBMemoryDeinit(struct GB* gb);
@ -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

View File

@ -6,9 +6,11 @@
#ifndef GB_OVERRIDES_H
#define GB_OVERRIDES_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "gb/interface.h"
CXX_GUARD_START
#include <mgba/gb/interface.h>
struct GBCartridgeOverride {
int headerCrc32;
@ -24,4 +26,6 @@ struct GB;
void GBOverrideApply(struct GB*, const struct GBCartridgeOverride*);
void GBOverrideApplyDefaults(struct GB*);
CXX_GUARD_END
#endif

View File

@ -6,11 +6,13 @@
#ifndef GB_RENDERER_SOFTWARE_H
#define GB_RENDERER_SOFTWARE_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/core.h"
#include "gb/gb.h"
#include "gb/video.h"
CXX_GUARD_START
#include <mgba/core/core.h>
#include <mgba/internal/gb/gb.h>
#include <mgba/internal/gb/video.h>
struct GBVideoSoftwareRenderer {
struct GBVideoRenderer d;
@ -36,4 +38,6 @@ struct GBVideoSoftwareRenderer {
void GBVideoSoftwareRendererCreate(struct GBVideoSoftwareRenderer*);
CXX_GUARD_END
#endif

View File

@ -6,7 +6,9 @@
#ifndef GB_TILE_CACHE_H
#define GB_TILE_CACHE_H
#include "util/common.h"
#include <mgba-util/common.h>
CXX_GUARD_START
struct GBVideo;
struct mTileCache;
@ -14,4 +16,6 @@ struct mTileCache;
void GBVideoTileCacheInit(struct mTileCache* cache);
void GBVideoTileCacheAssociate(struct mTileCache* cache, struct GBVideo* video);
CXX_GUARD_END
#endif

View File

@ -6,10 +6,12 @@
#ifndef GB_SERIALIZE_H
#define GB_SERIALIZE_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/core.h"
#include "gb/gb.h"
CXX_GUARD_START
#include <mgba/core/core.h>
#include <mgba/internal/gb/gb.h>
extern const uint32_t GB_SAVESTATE_MAGIC;
extern const uint32_t GB_SAVESTATE_VERSION;
@ -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

View File

@ -6,15 +6,26 @@
#ifndef GB_SIO_H
#define GB_SIO_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/timing.h"
CXX_GUARD_START
#include <mgba/core/log.h>
#include <mgba/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 +34,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 +51,10 @@ 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);
CXX_GUARD_END
#endif

View File

@ -0,0 +1,49 @@
/* 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 <mgba-util/common.h>
CXX_GUARD_START
#include <mgba/core/lockstep.h>
#include <mgba/core/timing.h>
#include <mgba/internal/gb/sio.h>
struct GBSIOLockstep {
struct mLockstep d;
struct GBSIOLockstepNode* players[MAX_GBS];
uint8_t pendingSB[MAX_GBS];
bool masterClaimed;
};
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*);
CXX_GUARD_END
#endif

View File

@ -6,9 +6,11 @@
#ifndef GB_TIMER_H
#define GB_TIMER_H
#include "util/common.h"
#include <mgba-util/common.h>
#include "core/timing.h"
CXX_GUARD_START
#include <mgba/core/timing.h>
DECL_BITFIELD(GBRegisterTAC, uint8_t);
DECL_BITS(GBRegisterTAC, Clock, 0, 2);
@ -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

Some files were not shown because too many files have changed in this diff Show More