Skip to content

Commit

Permalink
Update to 0.11-dev (61791c9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryunam committed Apr 21, 2024
2 parents b256448 + 61791c9 commit 95a597c
Show file tree
Hide file tree
Showing 158 changed files with 4,670 additions and 1,885 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
CMakeCache.txt
CMakeFiles
CMakeSettings.json
CMakeUserPresets.json
compile_commands.json
/.cache
/.vscode
cmake_install.cmake
hle-bios.bin
version.c
Expand Down
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
0.11.0: (Future)
Features:
- New option to lock the maximum frame size
- Scripting: New `input` API for getting raw keyboard/mouse/controller state
- Scripting: New `storage` API for saving data for a script, e.g. settings
- Scripting: Debugger integration to allow for breakpoints and watchpoints
- New unlicensed GB mappers: NT (older types 1 and 2), Li Cheng, GGB-81
- Debugger: Add range watchpoints
Emulation fixes:
- GB Audio: Fix audio envelope timing resetting too often (fixes mgba.io/i/3164)
- GB I/O: Fix STAT writing IRQ trigger conditions (fixes mgba.io/i/2501)
- GB Serialize: Add missing Pocket Cam state to savestates
- GB Video: Implement DMG-style sprite ordering
- GBA: Unhandled bkpt should be treated as an undefined exception
- GBA GPIO: Fix tilt scale and orientation (fixes mgba.io/i/2703)
- GBA GPIO: Fix gyro read-out start (fixes mgba.io/i/3141)
- GBA I/O: Fix HALTCNT access behavior (fixes mgba.io/i/2309)
- GBA SIO: Fix MULTI mode SIOCNT bit 7 writes on secondary GBAs (fixes mgba.io/i/3110)
- GBA Video: Disable BG target 1 blending when OBJ blending (fixes mgba.io/i/2722)
Expand Down
42 changes: 20 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ if(NOT MSVC)
# TODO: Remove this once mScript KV pairs support const correctness
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=incompatible-pointer-types")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} -Woverloaded-virtual")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} -Woverloaded-virtual -Werror=reorder")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd4003 /wd4244 /wd4146 /wd4267 /Zc:preprocessor-")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd4003 /wd4244 /wd4146 /wd4267 /Zc:preprocessor-")
endif()

if(NOT LIBMGBA_ONLY)
set(USE_DEBUGGERS ON CACHE BOOL "Whether or not to enable the debugging infrastructure")
set(ENABLE_DEBUGGERS ON CACHE BOOL "Whether or not to enable the debugging infrastructure")
if (NOT WIN32)
set(USE_EDITLINE ON CACHE BOOL "Whether or not to enable the CLI-mode debugger")
endif()
set(USE_GDB_STUB ON CACHE BOOL "Whether or not to enable the GDB stub ARM debugger")
set(ENABLE_GDB_STUB ON CACHE BOOL "Whether or not to enable the GDB stub ARM debugger")
set(USE_FFMPEG ON CACHE BOOL "Whether or not to enable FFmpeg support")
set(USE_ZLIB ON CACHE BOOL "Whether or not to enable zlib support")
set(USE_MINIZIP ON CACHE BOOL "Whether or not to enable external minizip support")
Expand Down Expand Up @@ -217,13 +217,15 @@ endif()
# Platform support
if(WIN32)
set(WIN32_VERSION "${LIB_VERSION_MAJOR},${LIB_VERSION_MINOR},${LIB_VERSION_PATCH}")
add_definitions(-D_WIN32_WINNT=0x0600)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
if(MSVC)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
add_definitions(-D_UNICODE -DUNICODE)
else()
add_definitions(-D_GNU_SOURCE)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_compile_definitions(_FILE_OFFSET_BITS=64)
endif()
endif()
list(APPEND OS_LIB ws2_32 shlwapi)
list(APPEND CORE_VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-fd.c ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/windows/vfs-w32.c)
Expand Down Expand Up @@ -299,7 +301,7 @@ endif()

if(DEFINED 3DS OR DEFINED PSP2 OR DEFINED WII OR DEFINED SWITCH)
set(IS_EMBEDDED ON)
set(USE_DEBUGGERS OFF)
set(ENABLE_DEBUGGERS OFF)
set(USE_SQLITE3 OFF)
set(USE_DISCORD_RPC OFF)
set(USE_LIBZIP OFF CACHE BOOL "")
Expand All @@ -311,12 +313,12 @@ if(DEFINED SWITCH)
endif()

if(NOT M_CORE_GBA)
set(USE_GDB_STUB OFF)
set(ENABLE_GDB_STUB OFF)
endif()

if(NOT USE_DEBUGGERS)
if(NOT ENABLE_DEBUGGERS)
set(USE_EDITLINE OFF)
set(USE_GDB_STUB OFF)
set(ENABLE_GDB_STUB OFF)
endif()

if(WII)
Expand All @@ -343,18 +345,14 @@ find_function(popcount32)

find_function(futimens)
find_function(futimes)
find_function(localtime_r)

find_function(realpath)

if(ANDROID AND ANDROID_NDK_MAJOR GREATER 13)
find_function(localtime_r)
set(HAVE_STRTOF_L ON)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_function(localtime_r)
list(APPEND FUNCTION_DEFINES HAVE_STRTOF_L)
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
# The strtof_l on Linux not actually exposed nor actually strtof_l
set(HAVE_STRTOF_L OFF)
else()
find_function(localtime_r)
find_function(strtof_l)
endif()

Expand Down Expand Up @@ -491,7 +489,7 @@ if(NOT BUILD_GLES2 AND NOT BUILD_GLES3 AND NOT LIBMGBA_ONLY)
endif()

if(DISABLE_DEPS)
set(USE_GDB_STUB OFF)
set(ENABLE_GDB_STUB OFF)
set(USE_DISCORD_RPC OFF)
set(USE_JSON_C OFF)
set(USE_SQLITE3 OFF)
Expand Down Expand Up @@ -543,8 +541,8 @@ else()
set(DEBUGGER_LIB "")
endif()

if(USE_GDB_STUB)
list(APPEND FEATURES GDB_STUB)
if(ENABLE_GDB_STUB)
list(APPEND ENABLES GDB_STUB)
endif()
source_group("Debugger" FILES ${DEBUGGER_SRC})

Expand Down Expand Up @@ -853,10 +851,10 @@ if(M_CORE_GBA)
list(APPEND TEST_SRC ${ARM_TEST_SRC} ${GBA_TEST_SRC})
endif()

if(USE_DEBUGGERS)
if(ENABLE_DEBUGGERS)
list(APPEND FEATURE_SRC ${DEBUGGER_SRC})
list(APPEND TEST_SRC ${DEBUGGER_TEST_SRC})
list(APPEND FEATURES DEBUGGERS)
list(APPEND ENABLES DEBUGGERS)
endif()

if(ENABLE_SCRIPTING)
Expand Down Expand Up @@ -1314,11 +1312,11 @@ if(NOT QUIET AND NOT LIBMGBA_ONLY)
message(STATUS " Game Boy Advance: ${M_CORE_GBA}")
message(STATUS " Game Boy: ${M_CORE_GB}")
message(STATUS "Features:")
message(STATUS " Debuggers: ${USE_DEBUGGERS}")
message(STATUS " Debuggers: ${ENABLE_DEBUGGERS}")
if(NOT WIN32)
message(STATUS " CLI debugger: ${USE_EDITLINE}")
endif()
message(STATUS " GDB stub: ${USE_GDB_STUB}")
message(STATUS " GDB stub: ${ENABLE_GDB_STUB}")
message(STATUS " GIF/Video recording: ${USE_FFMPEG}")
message(STATUS " Screenshot/advanced savestate support: ${USE_PNG}")
message(STATUS " ZIP support: ${SUMMARY_ZIP}")
Expand Down
21 changes: 21 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": 3,
"configurePresets": [
{
"name": "clang",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
"name": "gcc",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions include/mgba-util/audio-buffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* Copyright (c) 2013-2024 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 M_AUDIO_BUFFER_H
#define M_AUDIO_BUFFER_H

#include <mgba-util/common.h>

CXX_GUARD_START

#include <mgba-util/circle-buffer.h>

struct mAudioBuffer {
struct mCircleBuffer data;
unsigned channels;
};

void mAudioBufferInit(struct mAudioBuffer* buffer, size_t capacity, unsigned channels);
void mAudioBufferDeinit(struct mAudioBuffer* buffer);

size_t mAudioBufferAvailable(const struct mAudioBuffer* buffer);
size_t mAudioBufferCapacity(const struct mAudioBuffer* buffer);

void mAudioBufferClear(struct mAudioBuffer* buffer);
int16_t mAudioBufferPeek(const struct mAudioBuffer* buffer, unsigned channel, size_t offset);
size_t mAudioBufferDump(const struct mAudioBuffer* buffer, int16_t* samples, size_t count, size_t offset);
size_t mAudioBufferRead(struct mAudioBuffer* buffer, int16_t* samples, size_t count);
size_t mAudioBufferWrite(struct mAudioBuffer* buffer, const int16_t* samples, size_t count);

CXX_GUARD_END

#endif
37 changes: 37 additions & 0 deletions include/mgba-util/audio-resampler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* Copyright (c) 2013-2024 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 M_AUDIO_RESAMPLER_H
#define M_AUDIO_RESAMPLER_H

#include <mgba-util/common.h>

CXX_GUARD_START

#include <mgba-util/interpolator.h>

struct mAudioBuffer;
struct mAudioResampler {
struct mAudioBuffer* source;
struct mAudioBuffer* destination;
double sourceRate;
double destRate;
double timestamp;
double lowWaterMark;
double highWaterMark;
struct mInterpolatorSinc interp;
bool consume;
};

void mAudioResamplerInit(struct mAudioResampler*);
void mAudioResamplerDeinit(struct mAudioResampler*);
void mAudioResamplerSetSource(struct mAudioResampler*, struct mAudioBuffer* source, double rate, bool consume);
void mAudioResamplerSetDestination(struct mAudioResampler*, struct mAudioBuffer* destination, double rate);
size_t mAudioResamplerProcess(struct mAudioResampler*);

CXX_GUARD_END

#endif

31 changes: 16 additions & 15 deletions include/mgba-util/circle-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,29 @@

CXX_GUARD_START

struct CircleBuffer {
struct mCircleBuffer {
void* data;
size_t capacity;
size_t size;
void* readPtr;
void* writePtr;
};

void CircleBufferInit(struct CircleBuffer* buffer, unsigned capacity);
void CircleBufferDeinit(struct CircleBuffer* buffer);
size_t CircleBufferSize(const struct CircleBuffer* buffer);
size_t CircleBufferCapacity(const struct CircleBuffer* buffer);
void CircleBufferClear(struct CircleBuffer* buffer);
int CircleBufferWrite8(struct CircleBuffer* buffer, int8_t value);
int CircleBufferWrite16(struct CircleBuffer* buffer, int16_t value);
int CircleBufferWrite32(struct CircleBuffer* buffer, int32_t value);
size_t CircleBufferWrite(struct CircleBuffer* buffer, const void* input, size_t length);
int CircleBufferRead8(struct CircleBuffer* buffer, int8_t* value);
int CircleBufferRead16(struct CircleBuffer* buffer, int16_t* value);
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);
void mCircleBufferInit(struct mCircleBuffer* buffer, unsigned capacity);
void mCircleBufferDeinit(struct mCircleBuffer* buffer);
size_t mCircleBufferSize(const struct mCircleBuffer* buffer);
size_t mCircleBufferCapacity(const struct mCircleBuffer* buffer);
void mCircleBufferClear(struct mCircleBuffer* buffer);
int mCircleBufferWrite8(struct mCircleBuffer* buffer, int8_t value);
int mCircleBufferWrite16(struct mCircleBuffer* buffer, int16_t value);
int mCircleBufferWrite32(struct mCircleBuffer* buffer, int32_t value);
size_t mCircleBufferWrite(struct mCircleBuffer* buffer, const void* input, size_t length);
size_t mCircleBufferWriteTruncate(struct mCircleBuffer* buffer, const void* input, size_t length);
int mCircleBufferRead8(struct mCircleBuffer* buffer, int8_t* value);
int mCircleBufferRead16(struct mCircleBuffer* buffer, int16_t* value);
int mCircleBufferRead32(struct mCircleBuffer* buffer, int32_t* value);
size_t mCircleBufferRead(struct mCircleBuffer* buffer, void* output, size_t length);
size_t mCircleBufferDump(const struct mCircleBuffer* buffer, void* output, size_t length, size_t offset);

CXX_GUARD_END

Expand Down
22 changes: 13 additions & 9 deletions include/mgba-util/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@
#define CXX_GUARD_END
#endif

#ifdef __MINGW32__
#define __USE_MINGW_ANSI_STDIO 1
#endif

CXX_GUARD_START

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
// Require Windows 7 or newer
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0601
#elif _WIN32_WINNT < 0x0601
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0601
#endif
// WinSock2 gets very angry if it's included too late
#include <winsock2.h>
#endif

#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
Expand All @@ -35,11 +44,6 @@ CXX_GUARD_START
#include <string.h>
#include <time.h>

#ifdef _WIN32
// WinSock2 gets very angry if it is included too late
#include <winsock2.h>
#endif

#if defined(_MSC_VER) || defined(__cplusplus)
#define restrict __restrict
#endif
Expand Down
1 change: 1 addition & 0 deletions include/mgba-util/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ void mPainterInit(struct mPainter*, struct mImage* backing);
void mPainterDrawRectangle(struct mPainter*, int x, int y, int width, int height);
void mPainterDrawLine(struct mPainter*, int x1, int y1, int x2, int y2);
void mPainterDrawCircle(struct mPainter*, int x, int y, int diameter);
void mPainterDrawMask(struct mPainter*, const struct mImage* mask, int x, int y);

uint32_t mColorConvert(uint32_t color, enum mColorFormat from, enum mColorFormat to);
uint32_t mImageColorConvert(uint32_t color, const struct mImage* from, enum mColorFormat to);
Expand Down
36 changes: 36 additions & 0 deletions include/mgba-util/interpolator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* Copyright (c) 2013-2024 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 M_INTERPOLATOR_H
#define M_INTERPOLATOR_H

#include <mgba-util/common.h>

CXX_GUARD_START

struct mInterpolationData {
int16_t (*at)(int index, const void* context);
void* context;
};

struct mInterpolator {
int16_t (*interpolate)(const struct mInterpolator* interp, const struct mInterpolationData* data, double time, double sampleStep);
};

struct mInterpolatorSinc {
struct mInterpolator d;

unsigned resolution;
unsigned width;
double* sincLut;
double* windowLut;
};

void mInterpolatorSincInit(struct mInterpolatorSinc* interp, unsigned resolution, unsigned width);
void mInterpolatorSincDeinit(struct mInterpolatorSinc* interp);

CXX_GUARD_END

#endif
2 changes: 0 additions & 2 deletions include/mgba-util/platform/windows/threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#include <mgba-util/common.h>

#define _WIN32_WINNT 0x0600
#include <windows.h>
#define THREAD_ENTRY DWORD WINAPI
typedef THREAD_ENTRY ThreadEntry(LPVOID);
#define THREAD_EXIT(RES) return RES
Expand Down
Loading

0 comments on commit 95a597c

Please sign in to comment.