Compare commits

...

2 Commits

Author SHA1 Message Date
Fabrice de Gans
5313f51e98 [Build] Move common/ files to their own target
This is the first step in moving the build to use multiple smaller
targets and have cleaner dependencies between targets. This should
lead to a faster build.

* Clean out many header definitions.
* Narrow down the scope of cmake dependencies.
2024-03-12 17:10:07 -07:00
Fabrice de Gans
1b707c3a20 [Build] Add toolchain-specific files
This moves most toolchain setup to their own specific filies and removes
a couple of unused cmake functions.
2024-03-12 13:14:23 -07:00
63 changed files with 660 additions and 1327 deletions

View File

@@ -6,6 +6,9 @@ endif()
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW) # use vars for options
endif()
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW) # use extraction timestamp for downloads, not archive timestamp
endif()
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
@@ -56,7 +59,7 @@ set(CMAKE_CXX_STANDARD 17)
project(VBA-M C CXX)
find_package(Git)
find_package(Git REQUIRED)
find_package(PkgConfig)
include(GNUInstallDirs)
@@ -145,8 +148,7 @@ if(MINGW)
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
endif()
find_package(Git)
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
include(GitTagVersion)
git_version(VERSION REVISION VERSION_RELEASE)
@@ -317,7 +319,6 @@ set(SDL2_TARGETS SDL2::SDL2 ${SDL2_LIBRARY_TEMP})
# set the standard libraries all ports use
set(
VBAMCORE_LIBS
vbamcore
fex
${SDL2_TARGETS}
${SFML_LIBRARIES}
@@ -449,270 +450,7 @@ if(ENABLE_NLS)
endif()
endif()
include(ProcessorCount)
ProcessorCount(num_cpus)
# Compiler stuff
include(SetCompilerLinkerFlags)
if(CMAKE_C_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT MSVC)
# TODO: This should also be done for clang-cl.
include(LLVMToolchain)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT MSVC)
unset(LTO_FLAGS)
if(ENABLE_LTO)
if(CMAKE_COMPILER_IS_GNUCXX)
if(num_cpus GREATER 1)
set(LTO_FLAGS -flto=${num_cpus} -ffat-lto-objects)
else()
set(LTO_FLAGS -flto -ffat-lto-objects)
endif()
else()
set(LTO_FLAGS -flto)
endif()
# check that LTO is not broken before enabling it
set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${LTO_FLAGS}")
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("int main(int argc, char** argv) { return 0; }" LTO_WORKS)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
if(NOT LTO_WORKS)
message(WARNING "LTO does not seem to be working on your system, if using clang make sure LLVMGold is installed")
unset(LTO_FLAGS)
set(ENABLE_LTO OFF)
endif()
endif()
unset(MY_C_OPT_FLAGS)
if(X86_32 OR X86_64)
set(MY_C_OPT_FLAGS -mfpmath=sse -msse2)
endif()
# common optimization flags
if(NOT (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3))
set(MY_C_OPT_FLAGS ${MY_C_OPT_FLAGS} -Ofast -fomit-frame-pointer ${LTO_FLAGS})
else()
# LTO and -fomit-frame-pointer generate broken binaries on Lion with XCode 4.2 tools
set(MY_C_OPT_FLAGS ${MY_C_OPT_FLAGS} -Ofast)
endif()
# Common flags.
set(MY_C_FLAGS -pipe -Wformat -Wformat-security)
include(CheckCXXCompilerFlag)
# Require and optimize for Core2 level support, tune for generic.
if(X86_64)
set(MY_C_FLAGS ${MY_C_FLAGS} -march=core2 -mtune=generic)
# Optimize for pentium-mmx and tune for generic for older XP builds.
elseif(X86_32)
set(MY_C_FLAGS ${MY_C_FLAGS} -march=pentium-mmx -mtune=generic)
endif()
# Check for -fopenmp=libomp on clang.
# if(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
# check_cxx_compiler_flag("-fopenmp=libomp" FOPENMP_LIBOMP_FLAG)
# if(FOPENMP_LIBOMP_FLAG)
# set(MY_C_FLAGS ${MY_C_FLAGS} -fopenmp=libomp)
# endif()
# endif()
# common debug flags
if(CMAKE_COMPILER_IS_GNUCXX)
set(MY_C_DBG_FLAGS -ggdb3 -Og -fno-omit-frame-pointer)
else()
set(MY_C_DBG_FLAGS -g -fno-omit-frame-pointer)
endif()
if(ENABLE_ASAN)
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
message(FATAL_ERROR "asan requires a debug build, set -DCMAKE_BUILD_TYPE=Debug")
endif()
string(TOLOWER ${ENABLE_ASAN} SANITIZER)
if(SANITIZER STREQUAL "on" OR SANITIZER STREQUAL "true")
set(SANITIZER address)
endif()
list(PREPEND CMAKE_REQUIRED_LIBRARIES -fsanitize=${SANITIZER})
check_cxx_compiler_flag("-fsanitize=${SANITIZER}" ASAN_SUPPORT_FLAG)
if(${ASAN_SUPPORT_FLAG})
list(PREPEND MY_C_DBG_FLAGS -fsanitize=${SANITIZER})
else()
message(FATAL_ERROR "asan not available to compiler.")
endif()
endif()
if(ENABLE_SSP AND CMAKE_BUILD_TYPE STREQUAL Debug)
if(WIN32)
set(SSP_STATIC ON)
endif()
find_package(SSP)
if(SSP_LIBRARY)
list(APPEND MY_C_FLAGS -D_FORTIFY_SOURCE=2)
list(APPEND MY_C_LINKER_FLAGS ${SSP_LIBRARY})
endif()
endif()
if(NOT (WIN32 OR X86_32)) # inline asm is not allowed with -fPIC
set(MY_C_FLAGS ${MY_C_FLAGS} -fPIC)
endif()
# check if ssp flags are supported for this version of gcc
if(CMAKE_COMPILER_IS_GNUCXX)
if(ENABLE_SSP)
check_cxx_compiler_flag(-fstack-protector-strong F_STACK_PROTECTOR_STRONG_FLAG)
if(F_STACK_PROTECTOR_STRONG_FLAG)
set(MY_C_FLAGS ${MY_C_FLAGS} -fstack-protector-strong)
check_cxx_compiler_flag("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_FLAG)
if(SSP_BUFFER_SIZE_FLAG)
# we do not add it to MY_C_FLAGS because this breaks things like CMAKE_REQUIRED_LIBRARIES
# which misinterpret compiler flags without leading dashes
add_compile_options(--param ssp-buffer-size=4)
endif()
endif()
endif()
set(MY_C_FLAGS ${MY_C_FLAGS} -fopenmp)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
unset(COMPILER_COLOR_DIAGNOSTICS)
check_cxx_compiler_flag(-fdiagnostics-color=always COMPILER_COLOR_DIAGNOSTICS)
if(COMPILER_COLOR_DIAGNOSTICS)
add_compile_options(-fdiagnostics-color=always)
else()
unset(COMPILER_COLOR_DIAGNOSTICS)
check_cxx_compiler_flag(-fdiagnostics-color COMPILER_COLOR_DIAGNOSTICS)
if(COMPILER_COLOR_DIAGNOSTICS)
add_compile_options(-fdiagnostics-color)
endif()
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
unset(COMPILER_COLOR_DIAGNOSTICS)
check_cxx_compiler_flag(-fcolor-diagnostics COMPILER_COLOR_DIAGNOSTICS)
if(COMPILER_COLOR_DIAGNOSTICS)
add_compile_options(-fcolor-diagnostics)
endif()
endif()
if(MINGW AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++)
endif()
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_DBG_FLAGS} -Wall -Wextra)
else()
set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_OPT_FLAGS} -Wno-error)
endif()
# for some reason this is necessary
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
set(MY_C_FLAGS -I/usr/local/include ${MY_C_FLAGS})
endif()
foreach(C_COMPILE_FLAG ${MY_C_FLAGS})
add_compile_options(${C_COMPILE_FLAG})
endforeach()
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-std=gnu++17 GNUPP17_FLAG)
if(NOT GNUPP17_FLAG)
message(FATAL_ERROR "Your compiler does not support -std=gnu++17.")
endif()
set(MY_CXX_FLAGS -std=gnu++17 -fexceptions)
foreach(ARG ${MY_CXX_FLAGS})
set(MY_CXX_FLAGS_STR "${MY_CXX_FLAGS_STR} ${ARG}")
endforeach()
# These must be set for C++ only, and we can't use generator expressions in
# ADD_COMPILE_OPTIONS because that's a cmake 3.3 feature and we need 2.8.12
# compat for Ubuntu 14.
string(REGEX REPLACE "<FLAGS>" "<FLAGS> ${MY_CXX_FLAGS_STR} " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
foreach(ARG ${MY_C_FLAGS})
set(MY_C_FLAGS_STR "${MY_C_FLAGS_STR} ${ARG}")
endforeach()
# need all flags for linking, because of -flto etc.
set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${MY_C_FLAGS_STR}")
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${MY_C_FLAGS_STR}")
# for the gcc -fstack-protector* flags we need libssp
# we also have to use the gcc- binutils for LTO to work
if(CMAKE_COMPILER_IS_GNUCXX)
if(ENABLE_LTO)
include(UseGCCBinUtilsWrappers)
endif()
set(MY_C_LINKER_FLAGS ${MY_C_LINKER_FLAGS} -Wl,-allow-multiple-definition)
if(CMAKE_PREFIX_PATH)
list(GET CMAKE_PREFIX_PATH 0 prefix_path_first)
set(MY_C_LINKER_FLAGS ${MY_C_LINKER_FLAGS} "-Wl,-rpath-link=${prefix_path_first}/lib")
endif()
endif()
# set linker flags
foreach(ARG ${MY_C_LINKER_FLAGS})
set(MY_C_LINKER_FLAGS_STR "${MY_C_LINKER_FLAGS_STR} ${ARG}")
endforeach()
set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${MY_C_LINKER_FLAGS_STR}")
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${MY_C_LINKER_FLAGS_STR}")
elseif(MSVC)
# first remove all warnings flags, otherwise there is a warning about overriding them
string(REGEX REPLACE "/[Ww][^ ]+" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
string(REGEX REPLACE "/[Ww][^ ]+" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
add_compiler_flags(/std:c++17 -D__STDC_LIMIT_MACROS /fp:fast /Oi)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:DEBUG>:Debug>" CACHE INTERNAL "")
if(CMAKE_BUILD_TYPE STREQUAL Debug)
add_compiler_flags(/ZI /W4 /Ob0 /Od /RTC1 /DDEBUG /EHsc)
else()
# Enable severe warnings for release builds, but suppress macro
# redefinition warnings.
add_compiler_flags(/W1 /wd4005 /DNDEBUG /EHsc)
if(CMAKE_BUILD_TYPE STREQUAL Release)
add_compiler_flags(/O2 /Ob3)
elseif(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
add_compiler_flags(/Zi /Ob1)
elseif(CMAKE_BUILD_TYPE STREQUAL MinSizeRel)
add_compiler_flags(/O1 /Ob1)
else()
message(FATAL_ERROR "Unknown CMAKE_BUILD_TYPE: '${CMAKE_BUILD_TYPE}'")
endif()
if(ENABLE_LTO)
add_compiler_flags(/GL)
add_linker_flags(/LTCG)
endif()
endif()
endif()
# Assembler flags
if(ASM_ENABLED)
string(REGEX REPLACE "<FLAGS>" "-I${CMAKE_SOURCE_DIR}/src/filters/hq/asm/ -O1 -w-orphan-labels" CMAKE_ASM_NASM_COMPILE_OBJECT ${CMAKE_ASM_NASM_COMPILE_OBJECT})
endif()
include(Toolchain)
if(APPLE)
add_definitions(-DMACHO)
@@ -728,45 +466,23 @@ if(NOT TRANSLATIONS_ONLY)
add_subdirectory(fex)
endif()
set(
SRC_MAIN
src/Util.cpp
src/common/dictionary.c
src/common/iniparser.c
src/common/Patch.cpp
src/common/memgzio.c
src/common/SoundSDL.cpp
)
add_subdirectory(src/common)
list(APPEND SRC_MAIN
src/Util.cpp)
list(APPEND HDR_MAIN
src/Util.h)
if(MSVC)
set(SRC_MAIN ${SRC_MAIN} "dependencies/msvc/getopt.c")
endif()
set(
HDR_MAIN
src/System.h
src/Util.h
src/common/array.h
src/common/dictionary.h
src/common/iniparser.h
src/common/memgzio.h
src/common/Port.h
src/common/sizes.h
src/common/SoundDriver.h
src/common/SoundSDL.h
)
if(MSVC)
set(HDR_MAIN ${HDR_MAIN} "dependencies/msvc/getopt.h")
endif()
if(ENABLE_FFMPEG)
set(SRC_MAIN ${SRC_MAIN} src/common/ffmpeg.cpp)
set(HDR_MAIN ${HDR_MAIN} src/common/ffmpeg.h)
list(APPEND SRC_MAIN
dependencies/msvc/getopt.c
)
list(APPEND HDR_MAIN
dependencies/msvc/getopt.h
)
endif()
if(ENABLE_NLS)
set(HDR_MAIN ${HDR_MAIN} src/NLS.h)
list(APPEND HDR_MAIN src/NLS.h)
endif()
set(
@@ -1029,6 +745,7 @@ if(NOT TRANSLATIONS_ONLY)
${HDR_STB_IMAGE}
)
add_dependencies(vbamcore generate)
target_link_libraries(vbamcore PUBLIC vbam-common)
target_include_directories(vbamcore PUBLIC ${SDL2_INCLUDE_DIRS})
endif()
@@ -1039,6 +756,7 @@ if((NOT TRANSLATIONS_ONLY) AND ENABLE_SDL)
${SRC_SDL}
${HDR_SDL}
)
target_link_libraries(vbam vbamcore)
if(WIN32)
set(WIN32_LIBRARIES wsock32 ws2_32 winmm version imm32)
@@ -1083,9 +801,7 @@ endif()
if(ENABLE_WX)
add_subdirectory(src/wx)
endif()
if(ENABLE_WX)
# Native Language Support
if(ENABLE_NLS)
add_subdirectory(po)

View File

@@ -87,14 +87,7 @@ function(get_git_head_revision _refspecvar _hashvar)
endfunction()
function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
@@ -136,14 +129,7 @@ function(git_get_exact_tag _var)
endfunction()
function(git_local_changes _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()

View File

@@ -3,8 +3,7 @@ function(git_version version revision version_release)
set(${revision} "" CACHE STRING "Latest Git Tag Revision" FORCE)
set(${version_release} 0 CACHE STRING "Is this a versioned release without revision" FORCE)
find_package(Git)
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
# get latest version from tag history
execute_process(COMMAND "${GIT_EXECUTABLE}" tag "--format=%(align:width=20)%(refname:short)%(end)%(if)%(*objectname)%(then)%(*objectname)%(else)%(objectname)%(end)" --sort=-v:refname OUTPUT_VARIABLE tags OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")

View File

@@ -1,44 +0,0 @@
function(use_llvm_toolchain)
if(CMAKE_C_COMPILER_ID STREQUAL Clang)
set(compiler "${CMAKE_C_COMPILER}")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(compiler "${CMAKE_CXX_COMPILER}")
else()
return()
endif()
foreach(tool ar ranlib ld nm objdump as)
execute_process(
COMMAND "${compiler}" -print-prog-name=llvm-${tool}
OUTPUT_VARIABLE prog_path
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# for FreeBSD
if(NOT prog_path MATCHES "^/")
get_filename_component(
abs_path ${prog_path} ABSOLUTE
BASE_DIR /usr/local/llvm-devel/bin
)
if(EXISTS ${abs_path})
set(prog_path ${abs_path})
endif()
endif()
if(prog_path MATCHES "^/")
if(tool STREQUAL ld)
set(tool linker)
elseif(tool STREQUAL as)
set(tool asm_compiler)
endif()
string(TOUPPER ${tool} utool)
set(CMAKE_${utool} "${prog_path}" PARENT_SCOPE)
set(CMAKE_${utool} "${prog_path}" CACHE FILEPATH "${tool}" FORCE)
endif()
endforeach()
endfunction()
use_llvm_toolchain()

View File

@@ -10,12 +10,6 @@ if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git")
message(FATAL_ERROR "releases can only be done from a git clone")
endif()
find_package(Git)
if(NOT GIT_FOUND)
message(FATAL_ERROR "git is required to make a release")
endif()
find_program(GPG_EXECUTABLE gpg)
if(NOT GPG_EXECUTABLE)

View File

@@ -1,11 +1,3 @@
if(POLICY CMP0012)
cmake_policy(SET CMP0012 NEW) # Saner if() behavior.
endif()
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW) # Use timestamps from archives.
endif()
if(NOT DEFINED VCPKG_TARGET_TRIPLET)
if(NOT WIN32)
return()
@@ -55,28 +47,6 @@ if(NOT DEFINED VCPKG_TARGET_TRIPLET)
message(STATUS "Inferred VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}")
endif()
function(vcpkg_seconds)
if(CMAKE_HOST_SYSTEM MATCHES Windows OR ((NOT DEFINED CMAKE_HOST_SYSTEM) AND WIN32))
execute_process(
COMMAND cmd /c echo %TIME:~0,8%
OUTPUT_VARIABLE time
)
else()
execute_process(
COMMAND date +%H:%M:%S
OUTPUT_VARIABLE time
)
endif()
string(SUBSTRING "${time}" 0 2 hours)
string(SUBSTRING "${time}" 3 2 minutes)
string(SUBSTRING "${time}" 6 2 secs)
math(EXPR seconds "(${hours} * 60 * 60) + (${minutes} * 60) + ${secs}")
set(seconds ${seconds} PARENT_SCOPE)
endfunction()
function(vcpkg_check_git_status git_status)
# The VS vcpkg component cannot be written to without elevation.
if(NOT git_status EQUAL 0 AND NOT VCPKG_ROOT MATCHES "^C:/Program Files/Microsoft Visual Studio/")

View File

@@ -1,44 +0,0 @@
include(VbamFunctions)
function(add_compiler_flags)
foreach(var RELEASE DEBUG RELWITHDEBINFO MINSIZEREL)
set("CMAKE_CXX_FLAGS_${var}" "" CACHE STRING "MUST BE UNSET" FORCE)
set("CMAKE_CXX_FLAGS_${var}" "" PARENT_SCOPE)
set("CMAKE_C_FLAGS_${var}" "" CACHE STRING "MUST BE UNSET" FORCE)
set("CMAKE_C_FLAGS_${var}" "" PARENT_SCOPE)
endforeach()
# Set C and CXX flags if not already set.
foreach(flag ${ARGV})
foreach(var CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
# Remove any duplicates first.
remove_dupes("${${var}}" "${var}")
string(FIND "${${var}}" "${flag}" found)
if(found EQUAL -1)
set("${var}" "${${var}} ${flag}" CACHE STRING "Compiler Flags" FORCE)
set("${var}" "${${var}} ${flag}" PARENT_SCOPE)
endif()
endforeach()
endforeach()
endfunction()
function(add_linker_flags)
# Set linker flags if not already set.
foreach(flag ${ARGV})
foreach(var EXE SHARED)
set(var "CMAKE_${var}_LINKER_FLAGS")
# Remove any duplicates first.
remove_dupes("${${var}}" "${var}")
string(FIND "${${var}}" "${flag}" found)
if(found EQUAL -1)
set("${var}" "${${var}} ${flag}" CACHE STRING "Linker Flags" FORCE)
set("${var}" "${${var}} ${flag}" PARENT_SCOPE)
endif()
endforeach()
endforeach()
endfunction()

View File

@@ -0,0 +1,216 @@
unset(LTO_FLAGS)
if(ENABLE_LTO)
if(CMAKE_COMPILER_IS_GNUCXX)
if(num_cpus GREATER 1)
set(LTO_FLAGS -flto=${num_cpus} -ffat-lto-objects)
else()
set(LTO_FLAGS -flto -ffat-lto-objects)
endif()
else()
set(LTO_FLAGS -flto)
endif()
# check that LTO is not broken before enabling it
set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${LTO_FLAGS}")
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("int main(int argc, char** argv) { return 0; }" LTO_WORKS)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
if(NOT LTO_WORKS)
message(WARNING "LTO does not seem to be working on your system, if using clang make sure LLVMGold is installed")
unset(LTO_FLAGS)
set(ENABLE_LTO OFF)
endif()
endif()
unset(MY_C_OPT_FLAGS)
if(X86_32 OR X86_64)
set(MY_C_OPT_FLAGS -mfpmath=sse -msse2)
endif()
# common optimization flags
if(NOT (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3))
set(MY_C_OPT_FLAGS ${MY_C_OPT_FLAGS} -Ofast -fomit-frame-pointer ${LTO_FLAGS})
else()
# LTO and -fomit-frame-pointer generate broken binaries on Lion with XCode 4.2 tools
set(MY_C_OPT_FLAGS ${MY_C_OPT_FLAGS} -Ofast)
endif()
# Common flags.
set(MY_C_FLAGS -pipe -Wno-unused-command-line-argument -Wformat -Wformat-security -feliminate-unused-debug-types)
include(CheckCXXCompilerFlag)
# Require and optimize for Core2 level support, tune for generic.
if(X86_64)
set(MY_C_FLAGS ${MY_C_FLAGS} -march=core2 -mtune=generic)
# Optimize for pentium-mmx and tune for generic for older XP builds.
elseif(X86_32)
set(MY_C_FLAGS ${MY_C_FLAGS} -march=pentium-mmx -mtune=generic)
endif()
# Check for -fopenmp=libomp on clang.
# if(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
# check_cxx_compiler_flag("-fopenmp=libomp" FOPENMP_LIBOMP_FLAG)
# if(FOPENMP_LIBOMP_FLAG)
# set(MY_C_FLAGS ${MY_C_FLAGS} -fopenmp=libomp)
# endif()
# endif()
# common debug flags
if(CMAKE_COMPILER_IS_GNUCXX)
set(MY_C_DBG_FLAGS -ggdb3 -Og -fno-omit-frame-pointer)
else()
set(MY_C_DBG_FLAGS -g -fno-omit-frame-pointer)
endif()
if(ENABLE_ASAN)
string(TOLOWER ${CMAKE_BUILD_TYPE} build)
if(NOT build STREQUAL "debug")
message(FATAL_ERROR "asan requires debug build, set -DCMAKE_BUILD_TYPE=Debug")
endif()
string(TOLOWER ${ENABLE_ASAN} SANITIZER)
if(SANITIZER STREQUAL "on" OR SANITIZER STREQUAL "true")
set(SANITIZER address)
endif()
list(PREPEND CMAKE_REQUIRED_LIBRARIES -fsanitize=${SANITIZER})
check_cxx_compiler_flag("-fsanitize=${SANITIZER}" ASAN_SUPPORT_FLAG)
if(${ASAN_SUPPORT_FLAG})
list(PREPEND MY_C_DBG_FLAGS -fsanitize=${SANITIZER})
else()
message(FATAL_ERROR "asan not available to compiler.")
endif()
endif()
if(ENABLE_SSP AND CMAKE_BUILD_TYPE STREQUAL Debug)
if(WIN32)
set(SSP_STATIC ON)
endif()
find_package(SSP)
if(SSP_LIBRARY)
list(APPEND MY_C_FLAGS -D_FORTIFY_SOURCE=2)
list(APPEND MY_C_LINKER_FLAGS ${SSP_LIBRARY})
endif()
endif()
if(NOT (WIN32 OR X86_32)) # inline asm is not allowed with -fPIC
set(MY_C_FLAGS ${MY_C_FLAGS} -fPIC)
endif()
# check if ssp flags are supported for this version of gcc
if(CMAKE_COMPILER_IS_GNUCXX)
if(ENABLE_SSP)
check_cxx_compiler_flag(-fstack-protector-strong F_STACK_PROTECTOR_STRONG_FLAG)
if(F_STACK_PROTECTOR_STRONG_FLAG)
set(MY_C_FLAGS ${MY_C_FLAGS} -fstack-protector-strong)
check_cxx_compiler_flag("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_FLAG)
if(SSP_BUFFER_SIZE_FLAG)
# we do not add it to MY_C_FLAGS because this breaks things like CMAKE_REQUIRED_LIBRARIES
# which misinterpret compiler flags without leading dashes
add_compile_options(--param ssp-buffer-size=4)
endif()
endif()
endif()
set(MY_C_FLAGS ${MY_C_FLAGS} -fopenmp)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
unset(COMPILER_COLOR_DIAGNOSTICS)
check_cxx_compiler_flag(-fdiagnostics-color=always COMPILER_COLOR_DIAGNOSTICS)
if(COMPILER_COLOR_DIAGNOSTICS)
add_compile_options(-fdiagnostics-color=always)
else()
unset(COMPILER_COLOR_DIAGNOSTICS)
check_cxx_compiler_flag(-fdiagnostics-color COMPILER_COLOR_DIAGNOSTICS)
if(COMPILER_COLOR_DIAGNOSTICS)
add_compile_options(-fdiagnostics-color)
endif()
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
unset(COMPILER_COLOR_DIAGNOSTICS)
check_cxx_compiler_flag(-fcolor-diagnostics COMPILER_COLOR_DIAGNOSTICS)
if(COMPILER_COLOR_DIAGNOSTICS)
add_compile_options(-fcolor-diagnostics)
endif()
endif()
if(MINGW)
set(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++)
endif()
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_DBG_FLAGS} -Wall -Wextra)
else()
set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_OPT_FLAGS} -Wno-error)
endif()
# for some reason this is necessary
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
set(MY_C_FLAGS -I/usr/local/include ${MY_C_FLAGS})
endif()
foreach(C_COMPILE_FLAG ${MY_C_FLAGS})
add_compile_options(${C_COMPILE_FLAG})
endforeach()
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-std=gnu++17 GNUPP17_FLAG)
if(NOT GNUPP17_FLAG)
message(FATAL_ERROR "Your compiler does not support -std=gnu++17.")
endif()
set(MY_CXX_FLAGS -std=gnu++17 -fexceptions)
foreach(ARG ${MY_CXX_FLAGS})
set(MY_CXX_FLAGS_STR "${MY_CXX_FLAGS_STR} ${ARG}")
endforeach()
# These must be set for C++ only, and we can't use generator expressions in
# ADD_COMPILE_OPTIONS because that's a cmake 3.3 feature and we need 2.8.12
# compat for Ubuntu 14.
string(REGEX REPLACE "<FLAGS>" "<FLAGS> ${MY_CXX_FLAGS_STR} " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
foreach(ARG ${MY_C_FLAGS})
set(MY_C_FLAGS_STR "${MY_C_FLAGS_STR} ${ARG}")
endforeach()
# need all flags for linking, because of -flto etc.
set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${MY_C_FLAGS_STR}")
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${MY_C_FLAGS_STR}")
# for the gcc -fstack-protector* flags we need libssp
# we also have to use the gcc- binutils for LTO to work
if(CMAKE_COMPILER_IS_GNUCXX)
if(ENABLE_LTO)
include(UseGCCBinUtilsWrappers)
endif()
set(MY_C_LINKER_FLAGS ${MY_C_LINKER_FLAGS} -Wl,-allow-multiple-definition)
if(CMAKE_PREFIX_PATH)
list(GET CMAKE_PREFIX_PATH 0 prefix_path_first)
set(MY_C_LINKER_FLAGS ${MY_C_LINKER_FLAGS} "-Wl,-rpath-link=${prefix_path_first}/lib")
endif()
endif()
# set linker flags
foreach(ARG ${MY_C_LINKER_FLAGS})
set(MY_C_LINKER_FLAGS_STR "${MY_C_LINKER_FLAGS_STR} ${ARG}")
endforeach()
set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${MY_C_LINKER_FLAGS_STR}")
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${MY_C_LINKER_FLAGS_STR}")

View File

@@ -0,0 +1,41 @@
if(CMAKE_C_COMPILER_ID STREQUAL Clang)
set(compiler "${CMAKE_C_COMPILER}")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(compiler "${CMAKE_CXX_COMPILER}")
else()
return()
endif()
foreach(tool ar ranlib ld nm objdump as)
execute_process(
COMMAND "${compiler}" -print-prog-name=llvm-${tool}
OUTPUT_VARIABLE prog_path
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# for FreeBSD
if(NOT prog_path MATCHES "^/")
get_filename_component(
abs_path ${prog_path} ABSOLUTE
BASE_DIR /usr/local/llvm-devel/bin
)
if(EXISTS ${abs_path})
set(prog_path ${abs_path})
endif()
endif()
if(prog_path MATCHES "^/")
if(tool STREQUAL ld)
set(tool linker)
elseif(tool STREQUAL as)
set(tool asm_compiler)
endif()
string(TOUPPER ${tool} utool)
set(CMAKE_${utool} "${prog_path}" PARENT_SCOPE)
set(CMAKE_${utool} "${prog_path}" CACHE FILEPATH "${tool}" FORCE)
endif()
endforeach()

View File

@@ -0,0 +1,63 @@
# this has to run after the toolchain is initialized so it can't be in
# Win32deps.cmake
if(MINGW)
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-include")
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
endif()
if(MINGW)
# Win32 deps submodule
set(git_checkout FALSE)
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(git_checkout TRUE)
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --remote --recursive
RESULT_VARIABLE git_status
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
endif()
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
if(NOT (git_checkout AND git_status EQUAL 0))
message(FATAL_ERROR "Please pull in git submodules, e.g.\nrun: git submodule update --init --remote --recursive")
endif()
endif()
endif()
# hack for ninja in msys2
if(WIN32 AND CMAKE_GENERATOR STREQUAL Ninja AND NOT "$ENV{MSYSTEM_PREFIX}" STREQUAL "")
set(MSYS ON)
endif()
if(MSYS AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
if($ENV{MSYSTEM} STREQUAL CLANG64)
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/x86_64-w64-mingw32")
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
elseif($ENV{MSYSTEM} STREQUAL CLANG32)
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/i686-w64-mingw32")
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
endif()
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" CACHE INTERNAL "prefix search path for find_XXXX" FORCE)
endif()
# link libgcc/libstdc++ statically on mingw
# and adjust link command when making a static binary
if(CMAKE_COMPILER_IS_GNUCXX AND VBAM_STATIC)
# some dists don't have a static libpthread
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread ")
if(WIN32)
add_custom_command(
TARGET visualboyadvance-m PRE_LINK
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/msys-link-static.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
else()
add_custom_command(
TARGET visualboyadvance-m PRE_LINK
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/link-static.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()
endif()

View File

@@ -0,0 +1,54 @@
if(X86_32)
set(ADDITIONAL_RELEASE_FLAGS "")
else()
if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC)
set(ADDITIONAL_RELEASE_FLAGS "/Ob3")
endif()
endif()
set(ADDITIONAL_FLAGS "")
if(ENABLE_LTO)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(ADDITIONAL_FLAGS "/GL")
set(ADDITIONAL_LINKER_FLAGS "/LTCG")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
string(APPEND ADDITIONAL_RELEASE_FLAGS " -flto -fuse-ld=lld -fsplit-lto-unit")
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC AND NOT CMAKE_GENERATOR MATCHES "Ninja")
string(APPEND ADDITIONAL_FLAGS " /MP")
endif()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:DEBUG>:Debug>" CACHE INTERNAL "")
set(PREPROCESSOR_FLAGS "/D_FORCENAMELESSUNION /DWIN32_LEAN_AND_MEAN /DWIN32 /D_WINDOWS /D__STDC_LIMIT_MACROS /D__STDC_CONSTANT_MACROS /D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_CXX_FLAGS "/nologo ${PREPROCESSOR_FLAGS} /GR /EHsc /W4 /std:c++17 ${ADDITIONAL_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS "/nologo ${PREPROCESSOR_FLAGS} /W4 /std:c11 ${ADDITIONAL_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_RC_FLAGS "-c65001 /DWIN32" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /DDEBUG /MTd /ZI /Ob0 /Od /RTC1" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /DDEBUG /MTd /ZI /Ob0 /Od /RTC1" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "/DNDEBUG /MT /O2 /Oi /Gy /Zi ${ADDITIONAL_RELEASE_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /MT /O2 /Oi /Gy /Zi ${ADDITIONAL_RELEASE_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/DNDEBUG /MT /O2 /Ob1 /Oi /Gy /Zi" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /MT /O2 /Ob1 /Oi /Gy /Zi" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_MINSIZEREL "/DNDEBUG /MT /O1 /Ob1 /Oi /Gy /Zi" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /MT /O1 /Ob1 /Oi /Gy /Zi" CACHE STRING "" FORCE)
foreach(link_var IN ITEMS EXE SHARED MODULE)
string(APPEND CMAKE_${link_var}_LINKER_FLAGS " ${ADDITIONAL_LINKER_FLAGS}")
set(CMAKE_${link_var}_LINKER_FLAGS "${CMAKE_${link_var}_LINKER_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_${link_var}_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF" CACHE STRING "" FORCE)
endforeach()
include_directories("${CMAKE_SOURCE_DIR}/dependencies/msvc")
if(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
# TODO: We should update the XAudio headers to build with clang-cl. See
# https://github.com/visualboyadvance-m/visualboyadvance-m/issues/1021
add_definitions(-DNO_XAUDIO2)
endif()
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ENABLE_LTO)

23
cmake/Toolchain.cmake Normal file
View File

@@ -0,0 +1,23 @@
# Compiler stuff
include(ProcessorCount)
ProcessorCount(num_cpus)
if(CMAKE_C_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT MSVC)
# TODO: This should also be done for clang-cl.
include(Toolchain-llvm)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT MSVC)
include(Toolchain-gcc-clang)
elseif(MSVC)
include(Toolchain-msvc)
elseif(MINGW)
include(Toolchain-mingw)
else()
message(FATAL_ERROR "Unsupported compiler")
endif()
# Assembler flags
if(ASM_ENABLED)
string(REGEX REPLACE "<FLAGS>" "-I${CMAKE_SOURCE_DIR}/src/filters/hq/asm/ -O1 -w-orphan-labels" CMAKE_ASM_NASM_COMPILE_OBJECT ${CMAKE_ASM_NASM_COMPILE_OBJECT})
endif()

View File

@@ -2,12 +2,6 @@
# Update version in appcast.xml to latest tag.
# Commit web-data.
find_package(Git)
if(NOT GIT_FOUND)
message(FATAL_ERROR "git is required to update the appcast")
endif()
function(update_appcast)
if(UPDATE_APPCAST STREQUAL UNDO)
file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/web-data)

View File

@@ -1,13 +1,7 @@
#ifndef SYSTEM_H
#define SYSTEM_H
#ifndef VBAM_SYSTEM_H_
#define VBAM_SYSTEM_H_
#include "common/Types.h"
#define winlog log
#ifdef __LIBRETRO__
#define utilOpenFile fopen
#endif
#include <cstdint>
class SoundDriver;
@@ -118,7 +112,9 @@ extern int systemVerbose;
extern int systemFrameSkip;
extern int systemSaveUpdateCounter;
extern int systemSpeed;
#define MAX_CHEATS 16384
#define SYSTEM_SAVE_UPDATED 30
#define SYSTEM_SAVE_NOT_UPDATED 0
#endif // SYSTEM_H
#endif // VBAM_SYSTEM_H_

View File

@@ -24,25 +24,22 @@ extern "C" {
extern "C" {
#include "stb_image_write.h"
}
extern "C" {
#include "common/memgzio.h"
}
#include "NLS.h"
#include "System.h"
#include "Util.h"
#include "common/Port.h"
#include "gba/Flash.h"
#include "gba/GBA.h"
#include "gba/gbafilter.h"
#include "gba/Globals.h"
#include "gba/RTC.h"
#include "fex/fex.h"
extern "C" {
#include "common/memgzio.h"
}
#include "gb/gbGlobals.h"
#include "gba/gbafilter.h"
#ifndef _MSC_VER
#define _stricmp strcasecmp
#endif // ! _MSC_VER

View File

@@ -1,8 +1,12 @@
#ifndef UTIL_H
#define UTIL_H
#ifndef VBAM_UTIL_H_
#define VBAM_UTIL_H_
#include <cstdint>
#include <string>
#include "System.h"
#ifndef __LIBRETRO__
#include <zlib.h>
#endif // __LIBRETRO__
#ifdef _WIN32
#define FILE_SEP '\\'
@@ -47,6 +51,9 @@ void utilUpdateSystemColorMaps(bool lcd = false);
bool utilFileExists(const char *filename);
#ifdef __LIBRETRO__
#define utilOpenFile fopen
void utilWriteIntMem(uint8_t *&data, int);
void utilWriteMem(uint8_t *&data, const void *in_data, unsigned size);
void utilWriteDataMem(uint8_t *&data, variable_desc *);
@@ -54,7 +61,9 @@ void utilWriteDataMem(uint8_t *&data, variable_desc *);
int utilReadIntMem(const uint8_t *&data);
void utilReadMem(void *buf, const uint8_t *&data, unsigned size);
void utilReadDataMem(const uint8_t *&data, variable_desc *);
#else
#else // !__LIBRETRO__
FILE* utilOpenFile(const char *filename, const char *mode);
gzFile utilAutoGzOpen(const char *file, const char *mode);
gzFile utilGzOpen(const char *file, const char *mode);
@@ -69,6 +78,7 @@ void utilReadData(gzFile, variable_desc *);
void utilReadDataSkip(gzFile, variable_desc *);
int utilReadInt(gzFile);
void utilWriteInt(gzFile, int);
#endif
#endif // UTIL_H
#endif // __LIBRETRO__
#endif // VBAM_UTIL_H_

38
src/common/CMakeLists.txt Normal file
View File

@@ -0,0 +1,38 @@
# The commmon library is a collection of source files used by the core emulator and multiple
# frontends.
if (TRANSLATIONS_ONLY)
return()
endif()
add_library(vbam-common STATIC
dictionary.c
iniparser.c
memgzio.c
Patch.cpp
SoundSDL.cpp
version.cpp
)
set_target_properties(vbam-common PROPERTIES PUBLIC_HEADER
array.h
dictionary.h
iniparser.h
memgzio.h
Patch.h
ringbuffer.h
sizes.h
SoundSDL.h
version_cpp.h
)
target_include_directories(vbam-common PUBLIC ${SDL2_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
target_link_libraries(vbam-common PUBLIC ${SDL2_LIBRARIES} ${ZLIB_LIBRARIES})
if (ENABLE_FFMPEG)
add_library(vbam-common-ffmpeg STATIC
ffmpeg.cpp
)
set_target_properties(vbam-common-ffmpeg PROPERTIES PUBLIC_HEADER
ffmpeg.h
)
target_include_directories(vbam-common-ffmpeg PUBLIC ${FFMPEG_INCLUDE_DIRS})
target_link_libraries(vbam-common PUBLIC ${FFMPEG_LIBRARIES} vbam-common-ffmpeg)
endif()

View File

@@ -7,6 +7,7 @@
#endif
#include "Patch.h"
#include "../Util.h"
#if defined(__FreeBSD__) || defined(__NetBSD__)
#include <sys/param.h>

View File

@@ -1,9 +1,8 @@
#ifndef PATCH_H
#define PATCH_H
#ifndef VBAM_COMMON_PATCH_H_
#define VBAM_COMMON_PATCH_H_
#include "../Util.h"
#include "Types.h"
#include <cstdint>
bool applyPatch(const char *patchname, uint8_t **rom, int *size);
#endif // PATCH_H
#endif // VBAM_COMMON_PATCH_H_

View File

@@ -1,7 +1,7 @@
#ifndef PORT_H
#define PORT_H
#ifndef VBAM_COMMON_PORT_H_
#define VBAM_COMMON_PORT_H_
#include "Types.h"
#include <cstdint>
#ifdef __PS3__
/* PlayStation3 */
@@ -60,4 +60,4 @@ static inline uint32_t swap32(uint32_t v)
#define WRITE32LE(x, v) *((uint32_t *)x) = (v)
#endif
#endif // PORT_H
#endif // VBAM_COMMON_PORT_H_

View File

@@ -15,10 +15,12 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "SoundSDL.h"
#include <cmath>
#include <iostream>
#include <SDL_events.h>
#include "SoundSDL.h"
#include "../System.h"
#include "../gba/Globals.h"
#include "../gba/Sound.h"

View File

@@ -1,28 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 2008 VBA-M development team
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_TYPES_H__
#define __VBA_TYPES_H__
#ifdef __LIBRETRO__
#include <stdint.h>
#else
#include <zlib.h>
#include "cstdint.h"
#endif
#endif // __VBA_TYPES_H__

View File

@@ -1,10 +0,0 @@
#ifndef CONTAINS_HPP_
#define CONTAINS_HPP_
template <class C, class V>
bool contains(const C& container, const V& val)
{
return (container.find(val) != container.end());
}
#endif /* CONTAINS_HPP_ */

View File

@@ -1,18 +0,0 @@
#ifndef CSTDINT_H
#define CSTDINT_H
#if defined(__has_include)
# if __has_include(<cstdint>)
# include <cstdint>
// necessary on Mac OS X Lion 10.7 or any clang <= 3.0
# elif __has_include(<tr1/cstdint>)
# include <tr1/cstdint>
# else
// throw error
# include <cstdint>
# endif
#else
# include <cstdint>
#endif
#endif // CSTDINT_H

View File

@@ -1,669 +0,0 @@
/*
Range
=====
Copyright (c) 2009-2011 Khaled Alshaya
Distributed under the Boost Software License, version 1.0
(See the license at: http://www.boost.org/license_1_0.txt).
*/
/*
Rationale
=========
In Python, there is a beautiful function called "range".
"range" allows the programmer to iterate over a range elegantly.
This concept is not as general as "for-loops" in C++,
but non the less, it expresses the intent of the programmer
clearer than the general "for-loops" in many cases.
Design
======
Range is made to be STL-like library. In fact, it is
built on top of the concepts of STL. The library is designed to
work with STL algorithms as well. Range is more flexible
than the Python "range", because:
Range is an "immutable ordered random access container"
Specifications
==============
Range satisfies the following requirements:
* Immutable.
* Random Access Container.
* Random Access Iterator Interface.
* Constant Time Complexity Operations.
Range models an ordered sequence of elements,
where a range is defined by:
[begin, end)
* begin: the first element in the range. (Inclusive)
* end : the last element in the range. (Exclusive)
* step : the distance between two consecutive elements in a range.
where each element in the range is defined by:
element = begin + step * i
* i: is the index of the element in range.
The following precondition must be met for the sequence
to be a valid range:
step != 0
&&
(
begin <= end && step > 0
||
begin >= end && step < 0
)
Portability
===========
Range Generator is written in standard C++ (C++98). It depends
-only- on the standard C++ library.
*/
#ifndef range_h__
#define range_h__
// using std::range
// using std::size_t from <cstddef>
// using std::ceil from <cmath>
#include <iterator>
#include <stdexcept>
#include <cstddef>
#include <cmath>
namespace Range
{
template <class IntegerType>
struct basic_range
{
struct const_iterator_impl
{
typedef IntegerType value_type;
typedef std::size_t size_type;
typedef IntegerType difference_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef
std::random_access_iterator_tag
iterator_category;
const_iterator_impl(): r(0), index(0)
{ }
const_iterator_impl(const const_iterator_impl& rhs)
: r(rhs.r), index(rhs.index)
{ }
const_iterator_impl(basic_range<IntegerType> const * p_range, size_type p_index)
:r(p_range), index(p_index)
{ }
const_iterator_impl& operator=(const const_iterator_impl& rhs)
{
r = rhs.r;
index = rhs.index;
return *this;
}
bool operator==(const const_iterator_impl& rhs) const
{
return *r == *(rhs.r) && index == rhs.index;
}
bool operator!=(const const_iterator_impl& rhs) const
{
return !(*this == rhs);
}
bool operator<(const const_iterator_impl& rhs) const
{
return index < rhs.index;
}
bool operator>(const const_iterator_impl& rhs) const
{
return index > rhs.index;
}
bool operator<=(const const_iterator_impl& rhs) const
{
return index <= rhs.index;
}
bool operator>=(const const_iterator_impl& rhs) const
{
return index >= rhs.index;
}
value_type operator*() const
{
return r->m_first_element + r->m_step*index;
}
// operator->
// is not implemented because the value_type is an integer type
// and primitive types in C++ don't define member functions.
const_iterator_impl& operator++()
{
++index;
return *this;
}
const_iterator_impl operator++(int)
{
const_iterator_impl temp = *this;
++index;
return temp;
}
const_iterator_impl& operator--()
{
--index;
return *this;
}
const_iterator_impl operator--(int)
{
const_iterator_impl temp = *this;
--index;
return temp;
}
const_iterator_impl& operator+=(difference_type increment)
{
index += increment;
return *this;
}
// operator+
// is friend operator but operator-
// is not, because we want to allow the following for "+":
// iterator+5
// 5+iterator
// For the "-" it is not correct to do so, because
// iterator-5 != 5-iterator
friend const_iterator_impl operator+
(const const_iterator_impl& lhs, difference_type increment)
{
const_iterator_impl sum;
sum.r = lhs.r;
sum.index = lhs.index + increment;
return sum;
}
const_iterator_impl& operator-=(difference_type decrement)
{
index -= decrement;
return *this;
}
const_iterator_impl operator-(difference_type decrement) const
{
const_iterator_impl shifted_iterator;
shifted_iterator.r = r;
shifted_iterator.index = index - decrement;
return shifted_iterator;
}
difference_type operator-(const const_iterator_impl& rhs) const
{
return index - rhs.index;
}
value_type operator[](difference_type offset) const
{
size_type new_index = index + offset;
return r->m_first_element + r->m_step*new_index;
}
private:
basic_range<IntegerType> const * r;
size_type index;
};
struct const_reverse_iterator_impl
{
typedef IntegerType value_type;
typedef std::size_t size_type;
typedef IntegerType difference_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef
std::random_access_iterator_tag
iterator_category;
const_reverse_iterator_impl(): r(0), index(0)
{ }
const_reverse_iterator_impl(const const_reverse_iterator_impl& rhs)
: r(rhs.r), index(rhs.index)
{ }
const_reverse_iterator_impl(basic_range<IntegerType> const * p_range, size_type p_index)
:r(p_range), index(p_index)
{ }
const_reverse_iterator_impl& operator=(const const_reverse_iterator_impl& rhs)
{
r = rhs.r;
index = rhs.index;
return *this;
}
bool operator==(const const_reverse_iterator_impl& rhs) const
{
return *r == *(rhs.r) && index == rhs.index;
}
bool operator!=(const const_reverse_iterator_impl& rhs) const
{
return !(*this == rhs);
}
bool operator<(const const_reverse_iterator_impl& rhs) const
{
return index < rhs.index;
}
bool operator>(const const_reverse_iterator_impl& rhs) const
{
return index > rhs.index;
}
bool operator<=(const const_reverse_iterator_impl& rhs) const
{
return index <= rhs.index;
}
bool operator>=(const const_reverse_iterator_impl& rhs) const
{
return index >= rhs.index;
}
value_type operator*() const
{
size_type reverse_index
= (r->m_element_count - 1) - index;
return r->m_first_element + r->m_step*reverse_index;
}
// operator->
// is not implemented because the value_type is integer type
// and primitive types in C++ don't define member functions.
const_reverse_iterator_impl& operator++()
{
++index;
return *this;
}
const_reverse_iterator_impl operator++(int)
{
const_reverse_iterator_impl temp = *this;
++index;
return temp;
}
const_reverse_iterator_impl& operator--()
{
--index;
return *this;
}
const_reverse_iterator_impl operator--(int)
{
const_reverse_iterator_impl temp = *this;
--index;
return temp;
}
const_reverse_iterator_impl& operator+=(difference_type increment)
{
index += increment;
return *this;
}
// operator+
// is friend operator but operator-
// is not, because we want to allow the following for "+":
// iterator+5
// 5+iterator
// For the "-" it is not correct to do so, because
// iterator-5 != 5-iterator
friend const_reverse_iterator_impl operator+
(const const_reverse_iterator_impl& lhs, difference_type increment)
{
const_reverse_iterator_impl sum;
sum.r = lhs.r;
sum.index = lhs.index + increment;
return sum;
}
const_reverse_iterator_impl& operator-=(difference_type decrement)
{
index -= decrement;
return *this;
}
const_reverse_iterator_impl operator-(difference_type decrement) const
{
const_reverse_iterator_impl shifted_iterator;
shifted_iterator.r = r;
shifted_iterator.index = index - decrement;
return shifted_iterator;
}
difference_type operator-(const const_reverse_iterator_impl& rhs) const
{
return index - rhs.index;
}
value_type operator[](difference_type offset) const
{
size_type new_reverse_index
= (r->m_element_count - 1) - (index + offset);
return r->m_first_element + r->m_step*new_reverse_index;
}
private:
basic_range<IntegerType> const * r;
size_type index;
};
typedef IntegerType value_type;
typedef const_iterator_impl iterator;
typedef const_iterator_impl const_iterator;
typedef const_reverse_iterator_impl reverse_iterator;
typedef const_reverse_iterator_impl const_reverse_iterator;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef value_type* pointer;
typedef IntegerType difference_type;
typedef std::size_t size_type;
// In the case of default construction,
// the range is considered as an empty range with no elements.
// step can be anything other than 0. 1 is
// an implementation convention, and it doesn't have
// a significance in this case because the range is empty.
basic_range(): m_first_element(0), m_element_count(0), m_step(1)
{ }
// first_element: is begin in specifications.
// last_element: is end in specifications.
basic_range(value_type first_element, value_type last_element, value_type step)
: m_first_element(first_element),
m_step(step)
{
// We need to count the number of elements.
// The only case where a range is invalid,
// when the step=0. It means that the range
// is infinite, because the number of elements
// in a range, is the length of that range
// divided by the difference between
// every two successive elements.
if(step == 0)
throw std::out_of_range("Invalid Range: step can't be equal to zero!");
if(first_element < last_element && step < 0)
throw std::out_of_range("Invalid Range: step can't be backward, while the range is forward!");
if(first_element > last_element && step > 0)
throw std::out_of_range("Invalid Range: step can't be forward, while the range is backward!");
m_element_count = (last_element-first_element)/step;
if( (last_element-first_element)%step != 0 )
++m_element_count;
}
// The following constructor, determines the step
// automatically. If the range is forward, then
// step will be one. If the range is backward,
// step will be minus one. If the begin is equal
// to end, then the step must not equal to zero
// and it is set to one as a convention.
basic_range(value_type first_element, value_type last_element)
: m_first_element(first_element)
{
if(last_element >= first_element) *this = basic_range<IntegerType>(first_element, last_element, 1);
else *this = basic_range<IntegerType>(first_element, last_element, -1);
}
// The following constructor is a shortcut
// if you want the first element as zero.
// the step is determined automatically, based
// on the last element. If the last element is
// positive, then step is one, but if it is negative
// then step is minus one.
basic_range<IntegerType>(value_type last_element)
: m_first_element(0)
{
if(last_element >= m_first_element) *this = basic_range<IntegerType>(m_first_element, last_element, 1);
else *this = basic_range<IntegerType>(m_first_element, last_element, -1);
}
basic_range<IntegerType>(const basic_range<IntegerType>& r)
: m_first_element(r.m_first_element),
m_element_count(r.m_element_count),
m_step(r.m_step)
{ }
basic_range<IntegerType>& operator=(const basic_range<IntegerType>& r)
{
m_first_element = r.m_first_element;
m_element_count = r.m_element_count;
m_step = r.m_step;
return *this;
}
bool operator==(const basic_range<IntegerType>& r) const
{
return m_first_element == r.m_first_element
&&
m_element_count == r.m_element_count
&&
m_step == r.m_step;
}
bool operator!=(const basic_range<IntegerType>& r) const
{
return !(*this == r);
}
// The following four functions enable the user to compare
// ranges using ( <, >, <=, >=).
// The comparison between two ranges is a simple lexicographical
// comparison(element by element). By convention, if two ranges
// R1, R2 where R1 has a smaller number of elements. Then if
// R1 contains more elements but all R1 elements are found in R2
// R1 is considered less than R2.
bool operator<(const basic_range<IntegerType>& r) const
{
// ********** This function needs refactoring.
if(m_element_count == 0 && r.m_element_count == 0)
return false;
if(m_element_count == 0 && r.m_element_count > 0)
return true;
if(m_element_count > 0 && r.m_element_count == 0)
return false;
// At this point, both has at least one element.
if(m_first_element < r.m_first_element)
return true;
if(m_first_element > r.m_first_element)
return false;
// At this point, the first element of both are equal.
if(m_element_count == 1 && r.m_element_count == 1)
return false;
if(m_element_count == 1 && r.m_element_count > 1)
return true;
if(m_element_count > 1 && r.m_element_count == 1)
return false;
// At this point, both have at least two elements with
// a similar first element. Note than the final answer
// in this case depends on the second element only, because
// we don't need to compare the elements further.
// Note that the second element is at (index == 1), because
// the first element is at (index == 0).
if(m_first_element+m_step*1 < r.m_first_element+r.m_step*1)
return true;
if(m_first_element+m_step*1 > r.m_first_element+r.m_step*1)
return false;
// if the first two elements of both ranges are equal, then
// they are co-linear ranges(because the step is constant).
// In that case, they comparison depends only on
// the size of the ranges by convention.
return m_element_count < r.m_element_count;
}
bool operator>(const basic_range<IntegerType>& r) const
{
// ********** This function needs refactoring.
if(m_element_count == 0 && r.m_element_count == 0)
return false;
if(m_element_count == 0 && r.m_element_count > 0)
return false;
if(m_element_count > 0 && r.m_element_count == 0)
return true;
// At this point, both has at least one element.
if(m_first_element < r.m_first_element)
return false;
if(m_first_element > r.m_first_element)
return true;
// At this point, the first element of both are equal.
if(m_element_count == 1 && r.m_element_count == 1)
return false;
if(m_element_count == 1 && r.m_element_count > 1)
return false;
if(m_element_count > 1 && r.m_element_count == 1)
return true;
// At this point, both have at least two elements with
// a similar first element. Note than the final answer
// in this case depends on the second element only, because
// we don't need to compare the elements further.
// Note that the second element is at (index == 1), because
// the first element is at (index == 0).
if(m_first_element+m_step*1 < r.m_first_element+r.m_step*1)
return false;
if(m_first_element+m_step*1 > r.m_first_element+r.m_step*1)
return true;
// if the first two elements of both ranges are equal, then
// they are co-linear ranges(because the step is constant).
// In that case, they comparison depends only on
// the size of the ranges by convention.
return m_element_count > r.m_element_count;
}
bool operator <=(const basic_range<IntegerType>& r) const
{
return !(*this > r);
}
bool operator >=(const basic_range<IntegerType>& r) const
{
return !(*this < r);
}
const_iterator begin() const
{
return const_iterator(this, 0);
}
const_iterator end() const
{
return const_iterator(this, m_element_count);
}
const_reverse_iterator rbegin() const
{
return const_reverse_iterator(this, 0);
}
const_reverse_iterator rend() const
{
return const_reverse_iterator(this, m_element_count);
}
size_type size() const
{
return m_element_count;
}
size_type max_size() const
{
// Because this is an immutable container,
// max_size() == size()
return m_element_count;
}
bool empty() const
{
return m_element_count == 0;
}
// exist() and find() are similar except that
// find() returns the index of the element.
iterator find(value_type element) const
{
value_type element_index = (element - m_first_element) / m_step;
bool in_range = element_index >= 0 && element_index < m_element_count &&
(element - m_first_element) % m_step == 0;
if(in_range)
return begin() + element_index;
return end();
}
bool exist(value_type element) const
{
return find(element) != end();
}
// In the standard, the operator[]
// should return a const reference.
// Because Range Generator doesn't store its elements
// internally, we return a copy of the value.
// In any case, this doesn't affect the semantics of the operator.
value_type operator[](size_type index) const
{
return m_first_element + m_step*index;
}
private:
// m_first_element: begin (see specifications).
// m_element_count: (end - begin) / step
value_type m_first_element, m_element_count, m_step;
};
// This is the default type of range!
typedef basic_range<int> range;
}
#endif // range_h__

View File

@@ -1,5 +1,11 @@
#ifndef GBCHEATS_H
#define GBCHEATS_H
#ifndef VBAM_GB_GBCHEATS_H_
#define VBAM_GB_GBCHEATS_H_
#include <cstdint>
#ifndef __LIBRETRO__
#include <zlib.h>
#endif // __LIBRETRO__
#include "../System.h"
@@ -42,4 +48,4 @@ extern int gbCheatNumber;
extern gbCheat gbCheatList[MAX_CHEATS];
extern bool gbCheatMap[0x10000];
#endif // GBCHEATS_H
#endif // VBAM_GB_GBCHEATS_H_

View File

@@ -1,6 +1,6 @@
#include <memory.h>
#include "../Util.h"
#include "../System.h"
#include "gbGlobals.h"
#include "gbSGB.h"

View File

@@ -1,5 +1,4 @@
#include <cstddef>
#include "../common/Types.h"
#include "gbGlobals.h"
uint8_t* gbMemoryMap[16];
@@ -30,4 +29,4 @@ bool gbCgbMode = false;
bool gbSgbMode = false;
bool gbColorOption = false;
uint8_t (*gbSerialFunction)(uint8_t) = NULL;
uint8_t (*gbSerialFunction)(uint8_t) = nullptr;

View File

@@ -1,7 +1,7 @@
#ifndef GBGLOBALS_H
#define GBGLOBALS_H
#ifndef VBAM_GB_GBGLOBALS_H_
#define VBAM_GB_GBGLOBALS_H_
#include "../common/Types.h"
#include <cstdint>
extern uint8_t* g_bios;
@@ -64,4 +64,4 @@ extern void gbDrawSprites(bool);
extern uint8_t (*gbSerialFunction)(uint8_t);
#endif // GBGLOBALS_H
#endif // VBAM_GB_GBGLOBALS_H_

View File

@@ -1,8 +1,8 @@
#ifndef GBMEMORY_H
#define GBMEMORY_H
#include "../common/Types.h"
#include <time.h>
#include <cstdint>
#include <ctime>
struct mapperMBC1 {
int mapperRAMEnable;

View File

@@ -1,5 +1,11 @@
#ifndef GBSGB_H
#define GBSGB_H
#ifndef VBAM_GB_GBSGB_H_
#define VBAM_GB_GBSGB_H_
#include <cstdint>
#ifndef __LIBRETRO__
#include <zlib.h>
#endif // __LIBRETRO__
void gbSgbInit();
void gbSgbShutdown();
@@ -24,4 +30,4 @@ extern int gbSgbPacketTimeout;
extern uint8_t gbSgbReadingController;
extern int gbSgbFourPlayers;
#endif // GBSGB_H
#endif // VBAM_GB_GBSGB_H_

View File

@@ -3,13 +3,13 @@
#include <cstring>
#include "../Util.h"
#include "../System.h"
#include "../apu/Effects_Buffer.h"
#include "../apu/Gb_Apu.h"
#include "../gba/Sound.h"
#include "gb.h"
#include "gbGlobals.h"
#include "../apu/Effects_Buffer.h"
#include "../apu/Gb_Apu.h"
extern long soundSampleRate; // current sound quality
gb_effects_config_t gb_effects_config = { false, 0.20f, 0.15f, false };

View File

@@ -1,7 +1,7 @@
#ifndef VBA_BKS_H
#define VBA_BKS_H
#ifndef VBAM_GBA_BREAKPOINTSTRUCTURES_H_
#define VBAM_GBA_BREAKPOINTSTRUCTURES_H_
#include "../common/Types.h"
#include <cstdint>
#define readWord(addr) \
((map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]) + ((map[(addr + 1) >> 24].address[(addr + 1) & map[(addr + 1) >> 24].mask]) << 8) + ((map[(addr + 2) >> 24].address[(addr + 2) & map[(addr + 2) >> 24].mask]) << 16) + ((map[(addr + 3) >> 24].address[(addr + 3) & map[(addr + 3) >> 24].mask]) << 24))
@@ -63,4 +63,5 @@ bool doBreak(struct ConditionalBreak* toTest);
// uint8_t printConditionalsFromAddress(uint32_t address);
// void printAllFlagConditionals(uint8_t flag, bool orMode);
// void printAllFlagConditionalsWithAddress(uint32_t address, uint8_t flag, bool orMode);
#endif
#endif // VBAM_GBA_BREAKPOINTSTRUCTURES_H_

View File

@@ -3,6 +3,10 @@
#include <cstdint>
#ifndef __LIBRETRO__
#include <zlib.h>
#endif // __LIBRETRO__
#include "../System.h"
struct CheatsData {

View File

@@ -1,8 +1,10 @@
#include "EEprom.h"
#include <cstring>
#include "../Util.h"
#include "../System.h"
#include "GBA.h"
#include <memory.h>
#include <string.h>
extern int cpuDmaCount;

View File

@@ -1,16 +1,20 @@
#ifndef EEPROM_H
#define EEPROM_H
#ifndef VBAM_GBA_EEPROM_H_
#define VBAM_GBA_EEPROM_H_
#include "../common/Types.h"
#include <cstdint>
#ifndef __LIBRETRO__
#include <zlib.h>
#endif // __LIBRETRO__
#ifdef __LIBRETRO__
extern void eepromSaveGame(uint8_t*& data);
extern void eepromReadGame(const uint8_t*& data);
#else // !__LIBRETRO__
#else // !__LIBRETRO__
extern void eepromSaveGame(gzFile _gzFile);
extern void eepromReadGame(gzFile _gzFile, int version);
extern void eepromReadGameSkip(gzFile _gzFile, int version);
#endif
#endif // __LIBRETRO__
extern uint8_t eepromData[0x2000];
extern int eepromRead(uint32_t address);
extern void eepromWrite(uint32_t address, uint8_t value);
@@ -25,4 +29,4 @@ extern int eepromSize;
#define EEPROM_READDATA2 3
#define EEPROM_WRITEDATA 4
#endif // EEPROM_H
#endif // VBAM_GBA_EEPROM_H_

View File

@@ -1,11 +1,12 @@
#include "Flash.h"
#include <cstdio>
#include <cstring>
#include "../Util.h"
#include "../System.h"
#include "GBA.h"
#include "Globals.h"
#include "Sram.h"
#include <memory.h>
#include <stdio.h>
#include <string.h>
#define FLASH_READ_ARRAY 0
#define FLASH_CMD_1 1

View File

@@ -1,7 +1,11 @@
#ifndef FLASH_H
#define FLASH_H
#ifndef VBAM_GBA_FLASH_H_
#define VBAM_GBA_FLASH_H_
#include "../common/Types.h"
#include <cstdint>
#ifndef __LIBRETRO__
#include <zlib.h>
#endif // __LIBRETRO__
#define FLASH_128K_SZ 0x20000
@@ -24,4 +28,4 @@ extern void flashInit();
extern int g_flashSize;
#endif // FLASH_H
#endif // VBAM_GBA_FLASH_H_

View File

@@ -1,9 +1,7 @@
#ifndef GBA_H
#define GBA_H
#ifndef VBAM_GBA_GBA_H_
#define VBAM_GBA_GBA_H_
#include "../common/Types.h"
#include "../System.h"
#include "../Util.h"
#include <cstdint>
const uint64_t TICKS_PER_SECOND = 16777216;
@@ -200,4 +198,4 @@ extern struct EmulatedSystem GBASystem;
#include "Flash.h"
#include "Globals.h"
#endif // GBA_H
#endif // VBAM_GBA_GBA_H_

View File

@@ -1,9 +1,9 @@
#ifndef GFX_H
#define GFX_H
#include "GBA.h"
#include "Globals.h"
#include "../System.h"
#include "../common/Port.h"
//#define SPRITE_DEBUG

View File

@@ -1,15 +1,14 @@
// This file was written by denopqrihg
// with major changes by tjm
#include "GBALink.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
// malloc.h does not seem to exist on Mac OS 10.7 and is an error on FreeBSD
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#include "../System.h"
#include "Globals.h"
#ifdef _MSC_VER
#define snprintf _snprintf

View File

@@ -1,9 +1,10 @@
#pragma once
#include "../common/Types.h"
#ifndef VBAM_GBA_GBASOCKCLIENT_H_
#define VBAM_GBA_GBASOCKCLIENT_H_
#include <SFML/Network.hpp>
#include <cstdint>
class GBASockClient {
public:
GBASockClient(sf::IpAddress _server_addr);
@@ -26,3 +27,5 @@ private:
int32_t clock_sync;
bool is_disconnected;
};
#endif // VBAM_GBA_GBASOCKCLIENT_H_

View File

@@ -1,5 +1,7 @@
#ifndef GBACPU_H
#define GBACPU_H
#ifndef VBAM_GBA_CPU_H_
#define VBAM_GBA_CPU_H_
#include "Globals.h"
extern int armExecute();
extern int thumbExecute();
@@ -234,4 +236,4 @@ inline void cpuMasterCodeCheck()
}
}
#endif // GBACPU_H
#endif // VBAM_GBA_CPU_H_

View File

@@ -2,16 +2,20 @@
#define GBAINLINE_H
#include <type_traits>
#include <cstdint>
#include "../System.h"
#include "../common/Port.h"
#include "Cheats.h"
#include "EEprom.h"
#include "Flash.h"
#include "GBALink.h"
#include "GBAcpu.h"
#include "Globals.h"
#include "RTC.h"
#include "Sound.h"
#include "agbprint.h"
#include "remote.h"
#include "stdint.h"
extern const uint32_t objTilesAddress[3];

View File

@@ -1,5 +1,11 @@
#ifndef RTC_H
#define RTC_H
#ifndef VBAM_GBA_RTC_H_
#define VBAM_GBA_RTC_H_
#include <cstdint>
#ifndef __LIBRETRO__
#include <zlib.h>
#endif // __LIBRETRO__
uint16_t rtcRead(uint32_t address);
void rtcUpdateTime(int ticks);
@@ -17,4 +23,4 @@ void rtcReadGame(gzFile gzFile);
void rtcSaveGame(gzFile gzFile);
#endif
#endif // RTC_H
#endif // VBAM_GBA_RTC_H_

View File

@@ -4,14 +4,14 @@
#include <cstring>
#include "../Util.h"
#include "../System.h"
#include "../apu/Gb_Apu.h"
#include "../apu/Multi_Buffer.h"
#include "../common/SoundDriver.h"
#include "../common/Port.h"
#include "GBA.h"
#include "Globals.h"
#include "../apu/Gb_Apu.h"
#include "../apu/Multi_Buffer.h"
#include "../common/SoundDriver.h"
#define NR10 0x60
#define NR11 0x62

View File

@@ -1,9 +1,13 @@
#ifndef SOUND_H
#define SOUND_H
#ifndef VBAM_GBA_SOUND_H_
#define VBAM_GBA_SOUND_H_
// Sound emulation setup/options and GBA sound emulation
#include "../System.h"
#include <cstdint>
#ifndef __LIBRETRO__
#include <zlib.h>
#endif // __LIBRETRO__
//// Setup/options (these affect GBA and GB sound)
@@ -88,4 +92,4 @@ class Multi_Buffer;
void flush_samples(Multi_Buffer* buffer);
#endif // SOUND_H
#endif // VBAM_GBA_SOUND_H_

View File

@@ -1,7 +1,8 @@
#include "Sram.h"
#include "../System.h"
#include "Flash.h"
#include "GBA.h"
#include "Globals.h"
uint8_t sramRead(uint32_t address)
{

View File

@@ -1,10 +1,10 @@
#ifndef SRAM_H
#define SRAM_H
#ifndef VBAM_GBA_SRAM_H_
#define VBAM_GBA_SRAM_H_
#include "../common/Types.h"
#include <cstdint>
uint8_t sramRead(uint32_t address);
void sramWrite(uint32_t address, uint8_t byte);
void sramDelayedWrite(uint32_t address, uint8_t byte);
#endif // SRAM_H
#endif // VBAM_GBA_SRAM_H_

View File

@@ -3,8 +3,10 @@
#include <string.h>
#include "../NLS.h"
#include "../System.h"
#include "../common/Port.h"
#include "GBA.h"
#include "Globals.h"
#include "elf.h"
#define elfReadMemory(addr) \

View File

@@ -1,12 +1,13 @@
#include <locale>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ereader.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "../Util.h"
#include "GBA.h"
#include "GBAinline.h"
#include "Globals.h"
#include "ereader.h"
char US_Ereader[19] = "CARDE READERPSAE01";
char JAP_Ereader[19] = "CARDE READERPEAJ01";

View File

@@ -1,3 +1,8 @@
#ifndef VBAM_GBA_EREADER_H_
#define VBAM_GBA_EREADER_H_
#include <cstdint>
extern unsigned char* DotCodeData;
extern char filebuffer[];
@@ -7,3 +12,5 @@ int LoadDotCodeData(int size, uint32_t* DCdata, unsigned long MEM1, unsigned lon
void EReaderWriteMemory(uint32_t address, uint32_t value);
void BIOS_EReader_ScanCard(int swi_num);
#endif // VBAM_GBA_EREADER_H_

View File

@@ -32,6 +32,7 @@
#include "BreakpointStructures.h"
#include "GBA.h"
#include "Globals.h"
#include "elf.h"
#include "remote.h"
#include <iomanip>

View File

@@ -1,35 +1,27 @@
// necessary to get portable strerror_r
#undef _GNU_SOURCE
#include <string.h>
#define _GNU_SOURCE 1
#include "ConfigManager.h"
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cerrno>
#include <sys/types.h>
#include <sys/stat.h>
extern "C" {
#include "../common/iniparser.h"
}
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <cmath>
#include <cerrno>
#include "../common/Patch.h"
#include "../gba/GBA.h"
#include "../gba/agbprint.h"
#include "../gba/Flash.h"
#include "../gba/Cheats.h"
#include "../gba/remote.h"
#include "../gba/RTC.h"
#include "../gba/Sound.h"
#include "../gb/gb.h"
#include "../gb/gbGlobals.h"
#include "../gb/gbCheats.h"
#include "../gb/gbSound.h"
#include "../Util.h"
#include "filters.h"
#ifndef _WIN32
#define GETCWD getcwd

View File

@@ -2,8 +2,6 @@
#define _CONFIGMANAGER_H
#pragma once
#include "../sdl/filters.h"
#include <stdio.h>
#ifndef __GNUC__
#define HAVE_DECL_GETOPT 0
@@ -18,6 +16,8 @@
#endif
#endif // ! __GNUC__
#include "../System.h"
extern const char *biosFileNameGB;
extern const char *biosFileNameGBA;
extern const char *biosFileNameGBC;

View File

@@ -54,9 +54,9 @@
#include "../gba/Cheats.h"
#include "../gba/Flash.h"
#include "../gba/GBA.h"
#include "../gba/Globals.h"
#include "../gba/RTC.h"
#include "../gba/Sound.h"
#include "../gba/agbprint.h"
#include "../common/SoundSDL.h"

View File

@@ -22,6 +22,7 @@
#include "../common/Port.h"
#include "../gba/GBA.h"
#include "../gba/Globals.h"
#include "../gba/elf.h"
#include "exprNode.h"

View File

@@ -16,11 +16,10 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef VBA_SDL_FILTERS_H
#define VBA_SDL_FILTERS_H
#ifndef VBAM_SDL_FILTERS_H_
#define VBAM_SDL_FILTERS_H_
#include "../common/Types.h"
#include "../System.h"
#include <cstdint>
//
// Screen filters
@@ -84,4 +83,4 @@ IFBFilterFunc initIFBFilter(const int f, const int colorDepth);
// Get the display name for an IFB filter
char* getIFBFilterName(const IFBFilter f);
#endif // VBA_SDL_FILTERS_H
#endif // VBAM_SDL_FILTERS_H_

View File

@@ -855,8 +855,6 @@ set(
# from external source with minor modifications
widgets/wx/checkedlistctrl.h
../common/version_cpp.h
../common/range.hpp
../common/contains.h
)
set(ALL_HDR_WX ${HDR_WX})
@@ -1019,6 +1017,7 @@ if(NOT TRANSLATIONS_ONLY)
target_link_libraries(
visualboyadvance-m
vbamcore
${wxWidgets_LIBRARIES}
${VBAM_LIBS}
)
@@ -1080,8 +1079,6 @@ if(NOT TRANSLATIONS_ONLY)
endif()
endif()
option(TRANSLATIONS_ONLY "Build only the translations.zip" OFF)
# Make the translations.zip
if(ENABLE_NLS)
add_custom_command(

View File

@@ -1,7 +1,5 @@
#include "background-input.h"
#include "../common/contains.h"
#define NO_ERROR (wxThread::ExitCode)0
#define ANY_ERROR (wxThread::ExitCode)1
@@ -113,8 +111,9 @@ int VKToWX(WXWORD vk, WXLPARAM lParam, wchar_t *uc)
int wxk;
// check the table first
if (contains(gs_specialKeys, vk)) {
wxk = gs_specialKeys[vk];
const auto iter = gs_specialKeys.find(vk);
if (iter != gs_specialKeys.end()) {
wxk = iter->second;
if (wxk < WXK_START) {
// Unicode code for this key is the same as its ASCII code.
if (uc) *uc = wxk;
@@ -459,8 +458,10 @@ int wxUnicodeCharXToWX(unsigned long keySym)
if ((keySym & 0xff000000) == 0x01000000)
return keySym & 0x00ffffff;
if (contains(x11KeySym, keySym))
return x11KeySym[keySym];
const auto iter = x11KeySym.find(keySym);
if (iter != x11KeySym.end()) {
return iter->second;
}
return WXK_NONE;
}

View File

@@ -10,6 +10,8 @@
// DirectSound8
#define DIRECTSOUND_VERSION 0x0800
#include <mmeapi.h>
#include <uuids.h>
#include <dsound.h>
extern bool soundBufferLow;

View File

@@ -2,8 +2,7 @@
// these are all the viewer dialogs except for the ones with graphical areas
// they can be instantiated multiple times
#include "../common/cstdint.h"
#include <cstdint>
#include <limits>
#include <wx/ffile.h>

View File

@@ -18,6 +18,7 @@
#include "wx/wxmisc.h"
#include "wxhead.h"
#include "../Util.h"
#include "../gb/gb.h"
#include "../gb/gbCheats.h"
#include "../gb/gbGlobals.h"