├── src
├── debug
│ ├── gdb_test
│ │ ├── .gitignore
│ │ └── Makefile
│ ├── GdbArch.h
│ ├── GdbProto.h
│ └── hexutil.h
├── sha1
│ ├── sha1.hpp
│ └── sha1.h
├── teakra
│ ├── src
│ │ ├── test_generator.h
│ │ ├── dsp1_reader
│ │ │ └── CMakeLists.txt
│ │ ├── coff_reader
│ │ │ └── CMakeLists.txt
│ │ ├── test_generator
│ │ │ ├── CMakeLists.txt
│ │ │ └── main.cpp
│ │ ├── makedsp1
│ │ │ ├── CMakeLists.txt
│ │ │ └── sha256.h
│ │ ├── mod_test_generator
│ │ │ ├── CMakeLists.txt
│ │ │ └── main.cpp
│ │ ├── step2_test_generator
│ │ │ ├── CMakeLists.txt
│ │ │ └── main.cpp
│ │ ├── crash.h
│ │ ├── parser.h
│ │ ├── processor.h
│ │ ├── disassembler_c.cpp
│ │ ├── bit.h
│ │ ├── mmio.h
│ │ ├── shared_memory.h
│ │ ├── cru.md
│ │ ├── test.h
│ │ ├── apbp.h
│ │ ├── processor.cpp
│ │ ├── common_types.h
│ │ ├── timer.h
│ │ ├── core_timing.h
│ │ ├── mmio.md
│ │ ├── ahbm.md
│ │ ├── test_verifier
│ │ │ └── CMakeLists.txt
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── processor_general.md
│ │ ├── matcher.h
│ │ ├── memory_interface.cpp
│ │ ├── memory_interface.h
│ │ └── sio.md
│ ├── externals
│ │ └── CMakeLists.txt
│ ├── include
│ │ └── teakra
│ │ │ ├── disassembler_c.h
│ │ │ └── disassembler.h
│ ├── appveyor.yml
│ ├── .gitignore
│ ├── .travis.yml
│ ├── CMakeModules
│ │ └── CreateDirectoryGroups.cmake
│ ├── LICENSE
│ └── README.md
├── frontend
│ ├── qt_sdl
│ │ ├── InputConfig
│ │ │ └── resources
│ │ │ │ ├── ds.qrc
│ │ │ │ └── LICENSE.md
│ │ ├── sem_timedwait.h
│ │ ├── PowerManagement
│ │ │ ├── resources
│ │ │ │ └── battery.qrc
│ │ │ └── PowerManagementDialog.h
│ │ ├── LAN_Socket.h
│ │ ├── AudioInOut.h
│ │ ├── CLI.h
│ │ ├── LAN_PCap.h
│ │ ├── main.h
│ │ ├── LocalMP.h
│ │ ├── Input.h
│ │ ├── ArchiveUtil.h
│ │ ├── main_shaders.h
│ │ ├── OSD_shaders.h
│ │ ├── MPSettingsDialog.h
│ │ ├── InterfaceSettingsDialog.h
│ │ ├── PathSettingsDialog.h
│ │ ├── DateTimeDialog.h
│ │ ├── WifiSettingsDialog.h
│ │ ├── QPathInput.h
│ │ ├── MPSettingsDialog.cpp
│ │ ├── SaveManager.h
│ │ ├── pcap
│ │ │ ├── vlan.h
│ │ │ ├── bluetooth.h
│ │ │ ├── ipnet.h
│ │ │ └── can_socketcan.h
│ │ ├── InterfaceSettingsDialog.cpp
│ │ ├── ROMInfoDialog.h
│ │ ├── AudioSettingsDialog.h
│ │ ├── EmuSettingsDialog.h
│ │ └── VideoSettingsDialog.h
│ ├── duckstation
│ │ ├── gl
│ │ │ ├── loader.h
│ │ │ ├── context_egl_x11.h
│ │ │ ├── context_egl_wayland.h
│ │ │ ├── x11_window.h
│ │ │ ├── context_agl.h
│ │ │ ├── context_glx.h
│ │ │ ├── context_egl.h
│ │ │ ├── context_wgl.h
│ │ │ ├── context_egl_x11.cpp
│ │ │ └── context.h
│ │ ├── duckstation_compat.h
│ │ ├── windows_headers.h
│ │ ├── window_info.h
│ │ └── scoped_guard.h
│ └── glad
│ │ └── glad_egl.c
├── PlatformOGL.h
├── tiny-AES-c
│ ├── aes.hpp
│ └── unlicense.txt
├── dolphin
│ ├── MathUtil.cpp
│ ├── Align.h
│ ├── ArmCommon.h
│ ├── x64Reg.h
│ ├── CPUDetect.h
│ ├── CommonFuncs.h
│ ├── CommonFuncs.cpp
│ └── x64ABI.h
├── ARMJIT_x64
│ ├── ARMJIT_Offsets.h
│ ├── ARMJIT_GenOffsets.cpp
│ └── ARMJIT_Linkage.S
├── version.h
├── fatfs
│ ├── 00readme.txt
│ └── LICENSE.txt
├── CRC32.h
├── MemRegion.h
├── ARMJIT_Compiler.h
├── ROMList.h
├── ARMInterpreter_Branch.h
├── OpenGLSupport.h
├── types.h
├── FATIO.h
├── AREngine.h
├── ARMInterpreter.h
├── MemConstants.h
├── DSi_SPI_TSC.h
├── ARCodeFile.h
├── Utils.h
├── WifiAP.h
├── FreeBIOS.h
├── CRC32.cpp
├── JitBlock.h
├── xxhash
│ └── xxhash.c
├── Utils.cpp
├── GPU_OpenGL.h
├── DMA_Timings.h
└── ARMInterpreter_LoadStore.h
├── res
├── melon.ico
├── melon.icns
├── icon
│ ├── melon_16x16.png
│ ├── melon_32x32.png
│ ├── melon_48x48.png
│ ├── melon_64x64.png
│ ├── melon_128x128.png
│ └── melon_256x256.png
├── melon.qrc
├── net.kuribo64.melonDS.desktop
├── xp.manifest.in
└── melon.rc.in
├── cmake
├── ECMFindModuleHelpersStub.cmake
├── FindVTune.cmake
├── overlay-triplets
│ ├── arm64-osx-11-release.cmake
│ └── x64-osx-1015-release.cmake
├── Toolchain-Homebrew-LLVM.cmake
├── Toolchain-cross-MinGW-w64-x86_64.cmake
└── FixInterfaceIncludes.cmake
├── freebios
├── drastic_bios_arm7.bin
├── drastic_bios_arm9.bin
├── Makefile
└── drastic_bios_readme.txt
├── .github
├── FUNDING.yml
└── workflows
│ ├── build-windows.yml
│ ├── build-ubuntu.yml
│ ├── build-ubuntu-aarch64.yml
│ └── build-appimage.yml
├── .gitignore
├── tools
└── msys-dist.sh
├── vcpkg.json
└── CMakePresets.json
/src/debug/gdb_test/.gitignore:
--------------------------------------------------------------------------------
1 | obj/
2 | test-gdb
3 |
--------------------------------------------------------------------------------
/res/melon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/melonDS-emu/melonDS-switch/HEAD/res/melon.ico
--------------------------------------------------------------------------------
/res/melon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/melonDS-emu/melonDS-switch/HEAD/res/melon.icns
--------------------------------------------------------------------------------
/cmake/ECMFindModuleHelpersStub.cmake:
--------------------------------------------------------------------------------
1 | include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpers.cmake)
2 |
--------------------------------------------------------------------------------
/res/icon/melon_16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/melonDS-emu/melonDS-switch/HEAD/res/icon/melon_16x16.png
--------------------------------------------------------------------------------
/res/icon/melon_32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/melonDS-emu/melonDS-switch/HEAD/res/icon/melon_32x32.png
--------------------------------------------------------------------------------
/res/icon/melon_48x48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/melonDS-emu/melonDS-switch/HEAD/res/icon/melon_48x48.png
--------------------------------------------------------------------------------
/res/icon/melon_64x64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/melonDS-emu/melonDS-switch/HEAD/res/icon/melon_64x64.png
--------------------------------------------------------------------------------
/res/icon/melon_128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/melonDS-emu/melonDS-switch/HEAD/res/icon/melon_128x128.png
--------------------------------------------------------------------------------
/res/icon/melon_256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/melonDS-emu/melonDS-switch/HEAD/res/icon/melon_256x256.png
--------------------------------------------------------------------------------
/freebios/drastic_bios_arm7.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/melonDS-emu/melonDS-switch/HEAD/freebios/drastic_bios_arm7.bin
--------------------------------------------------------------------------------
/freebios/drastic_bios_arm9.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/melonDS-emu/melonDS-switch/HEAD/freebios/drastic_bios_arm9.bin
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | patreon: Arisotura
2 | custom: ["https://paypal.me/Arisotura", "http://melonds.kuribo64.net/donate.php"]
3 |
--------------------------------------------------------------------------------
/src/sha1/sha1.hpp:
--------------------------------------------------------------------------------
1 | #ifndef SHA1_HPP
2 | #define SHA1_HPP
3 |
4 | extern "C"
5 | {
6 | #include "sha1.h"
7 | }
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/src/teakra/src/test_generator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace Teakra::Test {
4 | bool GenerateTestCasesToFile(const char* path);
5 | }
6 |
--------------------------------------------------------------------------------
/res/melon.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | icon/melon_256x256.png
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/InputConfig/resources/ds.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | ds_open.svg
4 | ds_back.svg
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/gl/loader.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Fix glad.h including windows.h
4 | #ifdef _WIN32
5 | #include "../windows_headers.h"
6 | #endif
7 |
8 | #include "../../glad/glad.h"
9 |
--------------------------------------------------------------------------------
/src/PlatformOGL.h:
--------------------------------------------------------------------------------
1 | #ifndef PLATFORMOGL_H
2 | #define PLATFORMOGL_H
3 |
4 | // if you don't wanna use glad for your platform
5 | // add your header here!
6 |
7 | #include "frontend/glad/glad.h"
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/sem_timedwait.h:
--------------------------------------------------------------------------------
1 | #ifndef __SEM_TIMEDWAIT_H
2 | #define __SEM_TIMEDWAIT_H
3 |
4 | #ifdef __APPLE__
5 | int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout);
6 | #endif
7 |
8 | #endif
9 |
--------------------------------------------------------------------------------
/src/teakra/externals/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (TEAKRA_BUILD_UNIT_TESTS)
2 | add_library(catch INTERFACE)
3 | target_include_directories(catch INTERFACE
4 | $)
5 | endif()
6 |
--------------------------------------------------------------------------------
/src/tiny-AES-c/aes.hpp:
--------------------------------------------------------------------------------
1 | #ifndef _AES_HPP_
2 | #define _AES_HPP_
3 |
4 | #ifndef __cplusplus
5 | #error Do not include the hpp header in a c project!
6 | #endif //__cplusplus
7 |
8 | extern "C" {
9 | #include "aes.h"
10 | }
11 |
12 | #endif //_AES_HPP_
13 |
--------------------------------------------------------------------------------
/cmake/FindVTune.cmake:
--------------------------------------------------------------------------------
1 |
2 | find_path(VTUNE_PATH "")
3 |
4 | set(VTUNE_INCLUDE_DIR "${VTUNE_PATH}/include")
5 |
6 | if (WIN32)
7 | set(VTUNE_LIBRARY "${VTUNE_PATH}/lib64/jitprofiling.lib")
8 | else()
9 | set(VTUNE_LIBRARY "${VTUNE_PATH}/lib64/jitprofiling.a")
10 | endif()
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | build*/
2 | bin
3 | obj
4 | *.depend
5 | *.layout
6 | *.o
7 | melon_grc.c
8 | melon_grc.h
9 | melon.rc
10 | cmake-build*
11 | cmake-build-debug
12 | compile_commands.json
13 | .idea
14 | .cache
15 |
16 | *.exe
17 |
18 | .DS_Store
19 |
20 | .vs
21 | .vscode
22 | CMakeFiles
23 | CMakeCache.txt
24 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/PowerManagement/resources/battery.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | dsi_batteryalmostempty.svg
4 | dsi_batterylow.svg
5 | dsi_battery2.svg
6 | dsi_battery3.svg
7 | dsi_batteryfull.svg
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/teakra/src/dsp1_reader/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include(CreateDirectoryGroups)
2 |
3 | add_executable(dsp1_reader
4 | main.cpp
5 | )
6 | create_target_directory_groups(dsp1_reader)
7 | target_link_libraries(dsp1_reader PRIVATE teakra)
8 | target_include_directories(dsp1_reader PRIVATE .)
9 | target_compile_options(dsp1_reader PRIVATE ${TEAKRA_CXX_FLAGS})
10 |
--------------------------------------------------------------------------------
/tools/msys-dist.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [[ ! -x melonDS.exe ]]; then
4 | echo "Run this script from the directory you built melonDS."
5 | exit 1
6 | fi
7 |
8 | mkdir -p dist
9 |
10 | for lib in $(ldd melonDS.exe | grep mingw | sed "s/.*=> //" | sed "s/(.*)//"); do
11 | cp "${lib}" dist
12 | done
13 |
14 | cp melonDS.exe dist
15 | windeployqt dist
16 |
--------------------------------------------------------------------------------
/res/net.kuribo64.melonDS.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Name=melonDS
3 | GenericName=Nintendo DS Emulator
4 | Comment=A fast and accurate Nintendo DS emulator.
5 | Exec=melonDS %f
6 | Type=Application
7 | Categories=Game;Emulator;
8 | Terminal=false
9 | Icon=net.kuribo64.melonDS
10 | MimeType=application/x-nintendo-ds-rom;
11 | Keywords=emulator;Nintendo;DS;NDS;Nintendo DS;
12 |
--------------------------------------------------------------------------------
/src/teakra/src/coff_reader/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include(CreateDirectoryGroups)
2 |
3 | add_executable(coff_reader
4 | coff.h
5 | main.cpp
6 | )
7 | create_target_directory_groups(coff_reader)
8 | target_link_libraries(coff_reader PRIVATE teakra)
9 | target_include_directories(coff_reader PRIVATE .)
10 | target_compile_options(coff_reader PRIVATE ${TEAKRA_CXX_FLAGS})
11 |
--------------------------------------------------------------------------------
/src/teakra/src/test_generator/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include(CreateDirectoryGroups)
2 |
3 | add_executable(test_generator
4 | main.cpp
5 | )
6 | create_target_directory_groups(test_generator)
7 | target_link_libraries(test_generator PRIVATE teakra)
8 | target_include_directories(test_generator PRIVATE .)
9 | target_compile_options(test_generator PRIVATE ${TEAKRA_CXX_FLAGS})
10 |
--------------------------------------------------------------------------------
/src/teakra/src/makedsp1/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include(CreateDirectoryGroups)
2 |
3 | add_executable(makedsp1
4 | main.cpp
5 | sha256.cpp
6 | sha256.h
7 | )
8 | create_target_directory_groups(makedsp1)
9 | target_link_libraries(makedsp1 PRIVATE teakra)
10 | target_include_directories(makedsp1 PRIVATE .)
11 | target_compile_options(makedsp1 PRIVATE ${TEAKRA_CXX_FLAGS})
12 |
--------------------------------------------------------------------------------
/src/dolphin/MathUtil.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Dolphin Emulator Project
2 | // Licensed under GPLv2+
3 | // Refer to the license.txt file included.
4 |
5 | #include "MathUtil.h"
6 |
7 | #include
8 |
9 | // Calculate sum of a float list
10 | float MathFloatVectorSum(const std::vector& Vec)
11 | {
12 | return std::accumulate(Vec.begin(), Vec.end(), 0.0f);
13 | }
14 |
--------------------------------------------------------------------------------
/src/teakra/include/teakra/disassembler_c.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | bool Teakra_Disasm_NeedExpansion(uint16_t opcode);
11 |
12 | size_t Teakra_Disasm_Do(char* dst, size_t dstlen,
13 | uint16_t opcode, uint16_t expansion /*= 0*/);
14 |
15 | #ifdef __cplusplus
16 | }
17 | #endif
18 |
--------------------------------------------------------------------------------
/src/teakra/src/mod_test_generator/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include(CreateDirectoryGroups)
2 |
3 | add_executable(mod_test_generator
4 | main.cpp
5 | )
6 | create_target_directory_groups(mod_test_generator)
7 | target_link_libraries(mod_test_generator PRIVATE teakra)
8 | target_include_directories(mod_test_generator PRIVATE .)
9 | target_compile_options(mod_test_generator PRIVATE ${TEAKRA_CXX_FLAGS})
10 |
--------------------------------------------------------------------------------
/src/teakra/src/step2_test_generator/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include(CreateDirectoryGroups)
2 |
3 | add_executable(step2_test_generator
4 | main.cpp
5 | )
6 | create_target_directory_groups(step2_test_generator)
7 | target_link_libraries(step2_test_generator PRIVATE teakra)
8 | target_include_directories(step2_test_generator PRIVATE .)
9 | target_compile_options(step2_test_generator PRIVATE ${TEAKRA_CXX_FLAGS})
10 |
--------------------------------------------------------------------------------
/src/teakra/src/test_generator/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "../test_generator.h"
3 |
4 | int main(int argc, char** argv) {
5 | if (argc < 2) {
6 | return -1;
7 | }
8 |
9 | if (!Teakra::Test::GenerateTestCasesToFile(argv[1])) {
10 | std::fprintf(stderr, "Unable to successfully generate all tests.\n");
11 | return -2;
12 | }
13 |
14 | return 0;
15 | }
16 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/duckstation_compat.h:
--------------------------------------------------------------------------------
1 | #ifndef DUCKSTATION_COMPAT_H
2 | #define DUCKSTATION_COMPAT_H
3 |
4 | #include "../types.h"
5 |
6 | #include
7 |
8 | #define ALWAYS_INLINE __attribute__((always_inline)) inline
9 |
10 | #define AssertMsg(cond, msg) assert(cond && msg)
11 | #define Assert(cond) assert(cond)
12 |
13 | #define Panic(msg) assert(false && msg)
14 |
15 | #define UnreachableCode() __builtin_unreachable()
16 |
17 | #endif
--------------------------------------------------------------------------------
/cmake/overlay-triplets/arm64-osx-11-release.cmake:
--------------------------------------------------------------------------------
1 | set(VCPKG_TARGET_ARCHITECTURE arm64)
2 | set(VCPKG_CRT_LINKAGE dynamic)
3 | set(VCPKG_LIBRARY_LINKAGE static)
4 |
5 | set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
6 | set(VCPKG_CMAKE_SYSTEM_VERSION 11.0)
7 | set(VCPKG_OSX_ARCHITECTURES arm64)
8 | set(VCPKG_BUILD_TYPE release)
9 | set(VCPKG_OSX_DEPLOYMENT_TARGET 11.0)
10 |
11 | set(VCPKG_C_FLAGS -mmacosx-version-min=11.0)
12 | set(VCPKG_CXX_FLAGS -mmacosx-version-min=11.0)
13 |
--------------------------------------------------------------------------------
/vcpkg.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": [
3 | "sdl2",
4 | "libarchive",
5 | "libslirp",
6 | "zstd",
7 | {
8 | "name": "qtbase",
9 | "default-features": false,
10 | "features": ["gui", "png", "thread", "widgets", "opengl", "zstd"]
11 | },
12 | {
13 | "name": "qtbase",
14 | "host": true,
15 | "default-features": false
16 | },
17 | {
18 | "name": "qtmultimedia",
19 | "default-features": false
20 | },
21 | "qtsvg"
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/cmake/overlay-triplets/x64-osx-1015-release.cmake:
--------------------------------------------------------------------------------
1 | set(VCPKG_TARGET_ARCHITECTURE x64)
2 | set(VCPKG_CRT_LINKAGE dynamic)
3 | set(VCPKG_LIBRARY_LINKAGE static)
4 |
5 | set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
6 | set(VCPKG_CMAKE_SYSTEM_VERSION 10.15)
7 | set(VCPKG_OSX_ARCHITECTURES x86_64)
8 | set(VCPKG_BUILD_TYPE release)
9 | set(VCPKG_OSX_DEPLOYMENT_TARGET 10.15)
10 |
11 | set(VCPKG_C_FLAGS -mmacosx-version-min=10.15)
12 | set(VCPKG_CXX_FLAGS -mmacosx-version-min=10.15)
13 |
--------------------------------------------------------------------------------
/src/teakra/src/crash.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | [[noreturn]] inline void Assert(const char* expression, const char* file, int line) {
6 | std::fprintf(stderr, "Assertion '%s' failed, file '%s' line '%d'.", expression, file, line);
7 | std::abort();
8 | }
9 |
10 | #define ASSERT(EXPRESSION) ((EXPRESSION) ? (void)0 : Assert(#EXPRESSION, __FILE__, __LINE__))
11 | #define UNREACHABLE() Assert("UNREACHABLE", __FILE__, __LINE__)
12 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/windows_headers.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef WIN32_LEAN_AND_MEAN
4 | #define WIN32_LEAN_AND_MEAN 1
5 | #endif
6 | #ifndef NOMINMAX
7 | #define NOMINMAX 1
8 | #endif
9 |
10 | // require vista+
11 | #ifdef _WIN32_WINNT
12 | #undef _WIN32_WINNT
13 | #endif
14 | #define _WIN32_WINNT _WIN32_WINNT_VISTA
15 |
16 | #include
17 |
18 | #if defined(CreateDirectory)
19 | #undef CreateDirectory
20 | #endif
21 | #if defined(CopyFile)
22 | #undef CopyFile
23 | #endif
24 | #if defined(DeleteFile)
25 | #undef DeleteFile
26 | #endif
27 |
--------------------------------------------------------------------------------
/src/sha1/sha1.h:
--------------------------------------------------------------------------------
1 | /* ================ sha1.h ================ */
2 | /*
3 | SHA-1 in C
4 | By Steve Reid
5 | 100% Public Domain
6 | */
7 |
8 | #include
9 |
10 | typedef struct {
11 | uint32_t state[5];
12 | uint32_t count[2];
13 | unsigned char buffer[64];
14 | } SHA1_CTX;
15 |
16 | void SHA1Transform(uint32_t state[5], const unsigned char* buffer);
17 | void SHA1Init(SHA1_CTX* context);
18 | void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
19 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
20 |
--------------------------------------------------------------------------------
/src/teakra/src/parser.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include "common_types.h"
6 |
7 | namespace Teakra {
8 |
9 | class Parser {
10 | public:
11 | virtual ~Parser() = default;
12 | struct Opcode {
13 | enum {
14 | Invalid,
15 | Valid,
16 | ValidWithExpansion,
17 | } status = Invalid;
18 | u16 opcode = 0;
19 | };
20 |
21 | virtual Opcode Parse(const std::vector& tokens) = 0;
22 | };
23 |
24 | std::unique_ptr GenerateParser();
25 |
26 | } // namespace Teakra
27 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/InputConfig/resources/LICENSE.md:
--------------------------------------------------------------------------------
1 | These vector images are modified from the [Nintendo DS Lite illustration on dimensions.com](https://www.dimensions.com/element/nintendo-ds-lite).
2 |
3 | These have been used with the permission of the copyright holders.
4 | > "We restrict the usage of our drawings and 3D models in commercial software, but as long as it's a free and open source community project, that would be approved. Any reference/backlink to Dimensions.com that could be provided in the developer notes and/or credits for the project would be sufficient for use."
5 |
6 | https://www.dimensions.com/legal
7 |
--------------------------------------------------------------------------------
/src/teakra/src/processor.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include "common_types.h"
5 | #include "core_timing.h"
6 |
7 | namespace Teakra {
8 |
9 | class MemoryInterface;
10 |
11 | class Processor {
12 | public:
13 | Processor(CoreTiming& core_timing, MemoryInterface& memory_interface);
14 | ~Processor();
15 | void Reset();
16 | void Run(unsigned cycles);
17 | void SignalInterrupt(u32 i);
18 | void SignalVectoredInterrupt(u32 address, bool context_switch);
19 |
20 | private:
21 | struct Impl;
22 | std::unique_ptr impl;
23 | };
24 |
25 | } // namespace Teakra
26 |
--------------------------------------------------------------------------------
/cmake/Toolchain-Homebrew-LLVM.cmake:
--------------------------------------------------------------------------------
1 | # Toolchain file for building with Homebrew's LLVM on macOS
2 | # This is useful on 10.14 where std::filesystem is not supported.
3 |
4 | set(CMAKE_C_COMPILER /usr/local/opt/llvm/bin/clang)
5 | set(CMAKE_CXX_COMPILER /usr/local/opt/llvm/bin/clang++)
6 |
7 | add_link_options(-L/usr/local/opt/llvm/lib)
8 |
9 | # LLVM in Homebrew is built with latest Xcode which has a newer linker than
10 | # what is bundled in the default install of Xcode Command Line Tools, so we
11 | # override it to prevent it passing flags not supported by the system's ld.
12 | add_link_options(-mlinker-version=450)
13 |
--------------------------------------------------------------------------------
/src/teakra/src/disassembler_c.cpp:
--------------------------------------------------------------------------------
1 | #include "teakra/disassembler.h"
2 | #include "teakra/disassembler_c.h"
3 |
4 | extern "C" {
5 | bool Teakra_Disasm_NeedExpansion(uint16_t opcode) {
6 | return Teakra::Disassembler::NeedExpansion(opcode);
7 | }
8 |
9 | size_t Teakra_Disasm_Do(char* dst, size_t dstlen,
10 | uint16_t opcode, uint16_t expansion /*= 0*/) {
11 | std::string r = Teakra::Disassembler::Do(opcode, expansion);
12 |
13 | if (dst) {
14 | size_t i = 0;
15 | for (; i < (dstlen-1) && i < r.length(); ++i) {
16 | dst[i] = r[i];
17 | }
18 | dst[dstlen-1] = '\0';
19 | }
20 |
21 | return r.length();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/dolphin/Align.h:
--------------------------------------------------------------------------------
1 | // This file is under the public domain.
2 |
3 | #pragma once
4 |
5 | #include
6 | #include
7 |
8 | namespace Common
9 | {
10 | template
11 | constexpr T AlignUp(T value, size_t size)
12 | {
13 | static_assert(std::is_unsigned(), "T must be an unsigned value.");
14 | return static_cast(value + (size - value % size) % size);
15 | }
16 |
17 | template
18 | constexpr T AlignDown(T value, size_t size)
19 | {
20 | static_assert(std::is_unsigned(), "T must be an unsigned value.");
21 | return static_cast(value - value % size);
22 | }
23 |
24 | } // namespace Common
25 |
--------------------------------------------------------------------------------
/freebios/Makefile:
--------------------------------------------------------------------------------
1 | TC_PREFIX = /home/exophase/pandora-dev
2 | PREFIX = $(TC_PREFIX)/arm-2011.03
3 | AS = $(PREFIX)/bin/arm-none-linux-gnueabi-gcc
4 | OBJCOPY = $(PREFIX)/bin/arm-none-linux-gnueabi-objcopy
5 |
6 | BIN_ARM7 = drastic_bios_arm7
7 | BIN_ARM9 = drastic_bios_arm9
8 |
9 | all:
10 | $(AS) bios_common.S -DBIOS_ARM7 -march=armv4 -c -Wa,-asl=$(BIN_ARM7).list -o $(BIN_ARM7).o
11 | $(AS) bios_common.S -DBIOS_ARM9 -march=armv5 -c -Wa,-asl=$(BIN_ARM9).list -o $(BIN_ARM9).o
12 | $(OBJCOPY) -O binary $(BIN_ARM7).o $(BIN_ARM7).bin
13 | $(OBJCOPY) -O binary $(BIN_ARM9).o $(BIN_ARM9).bin
14 |
15 | clean:
16 | rm -f $(BIN_ARM7).bin $(BIN_ARM7).o $(BIN_ARM9).bin $(BIN_ARM9).o
17 |
18 |
--------------------------------------------------------------------------------
/src/teakra/src/bit.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #ifdef _MSC_VER
6 | #include
7 | #endif
8 |
9 | namespace std20 {
10 |
11 | // A simple (and not very correct) implementation of C++20's std::log2p1
12 | template
13 | constexpr T log2p1(T x) noexcept {
14 | static_assert(std::is_integral_v && std::is_unsigned_v);
15 | if (x == 0)
16 | return 0;
17 | #ifdef _MSC_VER
18 | unsigned long index = 0;
19 | _BitScanReverse64(&index, x);
20 | return static_cast(index) + 1;
21 | #else
22 | return static_cast(std::numeric_limits::digits - __builtin_clzll(x));
23 | #endif
24 | }
25 |
26 | } // namespace std20
27 |
--------------------------------------------------------------------------------
/src/teakra/appveyor.yml:
--------------------------------------------------------------------------------
1 | # shallow clone
2 | clone_depth: 5
3 |
4 | environment:
5 | matrix:
6 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
7 | cmake_generator: "Visual Studio 15 2017 Win64"
8 |
9 | platform:
10 | - x64
11 |
12 | configuration:
13 | - Release
14 |
15 | install:
16 | - git submodule update --init --recursive
17 |
18 | before_build:
19 | - mkdir build
20 | - cd build
21 | - cmake .. -G "%cmake_generator%" -DTEAKRA_TEST_ASSETS_DIR="%USERPROFILE%\assets" -DTEAKRA_RUN_TESTS=ON
22 | - cd ..
23 |
24 | cache:
25 | - '%USERPROFILE%\assets'
26 |
27 | build:
28 | project: build/teakra.sln
29 | parallel: true
30 |
31 | test_script:
32 | - cd build && ctest -VV -C Release && cd ..
33 |
--------------------------------------------------------------------------------
/src/debug/gdb_test/Makefile:
--------------------------------------------------------------------------------
1 |
2 | default: all
3 |
4 | all: test-gdb
5 |
6 | CPPFLAGS += -Werror=implicit-function-declaration -Werror=int-conversion \
7 | -Werror=return-type -Werror=uninitialized \
8 | -I../ -I../../ -Og -g -Wall \
9 | -Wno-switch -Wno-pointer-sign
10 |
11 | obj/:
12 | @mkdir -vp "$@"
13 |
14 | test-gdb: obj/GdbProto.o obj/GdbStub.o obj/GdbCmds.o obj/main.o obj/CRC32.o
15 | $(CXX) $(CPPFLAGS) $(LDFLAGS) -o "$@" $^
16 |
17 | obj/Gdb%.o: ../Gdb%.cpp obj/
18 | $(CXX) $(CPPFLAGS) -c -o "$@" "$<"
19 |
20 | obj/main.o: main.cpp obj/
21 | $(CXX) $(CPPFLAGS) -c -o "$@" "$<"
22 |
23 | obj/CRC32.o: ../../CRC32.cpp obj/
24 | $(CXX) $(CPPFLAGS) -c -o "$@" "$<"
25 |
26 | clean:
27 | @$(RM) -rv obj/ test-gdb
28 |
29 |
--------------------------------------------------------------------------------
/src/teakra/src/mmio.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include "common_types.h"
5 | #include "icu.h"
6 |
7 | namespace Teakra {
8 |
9 | class MemoryInterfaceUnit;
10 | class Apbp;
11 | class Timer;
12 | class Dma;
13 | class Ahbm;
14 | class Btdmp;
15 |
16 | class MMIORegion {
17 | public:
18 | MMIORegion(MemoryInterfaceUnit& miu, ICU& icu, Apbp& apbp_from_cpu, Apbp& apbp_from_dsp,
19 | std::array& timer, Dma& dma, Ahbm& ahbm, std::array& btdmp);
20 | ~MMIORegion();
21 | u16 Read(u16 addr); // not const because it can be a FIFO register
22 | void Write(u16 addr, u16 value);
23 |
24 | private:
25 | class Impl;
26 | std::unique_ptr impl;
27 | };
28 |
29 | } // namespace Teakra
30 |
--------------------------------------------------------------------------------
/res/xp.manifest.in:
--------------------------------------------------------------------------------
1 |
2 |
5 |
10 | Project
11 |
12 |
13 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/teakra/.gitignore:
--------------------------------------------------------------------------------
1 | # Build directory
2 | [Bb]uild/
3 | cmake-build/
4 | doc-build/
5 |
6 | test/
7 |
8 | # Generated source files
9 | src/common/scm_rev.cpp
10 | .travis.descriptor.json
11 |
12 | # Project/editor files
13 | *.swp
14 | .idea/
15 | .vs/
16 | .vscode/
17 |
18 | # *nix related
19 | # Common convention for backup or temporary files
20 | *~
21 |
22 | # Visual Studio CMake settings
23 | CMakeSettings.json
24 |
25 | # OSX global filetypes
26 | # Created by Finder or Spotlight in directories for various OS functionality (indexing, etc)
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 | .Spotlight-V100
31 | .Trashes
32 |
33 | # Windows global filetypes
34 | Thumbs.db
35 |
36 | teakra.out
37 | teakra.out.*
38 |
39 | # cmake and ctest temporary files
40 | /Testing
41 |
--------------------------------------------------------------------------------
/src/teakra/src/shared_memory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include "common_types.h"
5 |
6 | namespace Teakra {
7 | struct SharedMemory {
8 | u16 ReadWord(u32 word_address) const {
9 | return read_external16(word_address << 1);
10 | }
11 | void WriteWord(u32 word_address, u16 value) {
12 | write_external16(word_address << 1, value);
13 | }
14 |
15 | void SetExternalMemoryCallback(
16 | std::function read16, std::function write16) {
17 |
18 | read_external16 = std::move(read16);
19 | write_external16 = std::move(write16);
20 | }
21 |
22 | std::function read_external16;
23 | std::function write_external16;
24 | };
25 | } // namespace Teakra
26 |
--------------------------------------------------------------------------------
/src/debug/GdbArch.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef GDBARCH_H_
3 | #define GDBARCH_H_
4 |
5 | namespace Gdb
6 | {
7 |
8 | using namespace melonDS;
9 | enum class Register : int
10 | {
11 | r0,
12 | r1,
13 | r2,
14 | r3,
15 | r4,
16 | r5,
17 | r6,
18 | r7,
19 | r8,
20 | r9,
21 | r10,
22 | r11,
23 | r12,
24 | sp,
25 | lr,
26 | pc,
27 |
28 | cpsr,
29 | sp_usr,
30 | lr_usr,
31 |
32 | r8_fiq,
33 | r9_fiq,
34 | r10_fiq,
35 | r11_fiq,
36 | r12_fiq,
37 |
38 | sp_fiq,
39 | lr_fiq,
40 | sp_irq,
41 | lr_irq,
42 | sp_svc,
43 | lr_svc,
44 | sp_abt,
45 | lr_abt,
46 | sp_und,
47 | lr_und,
48 |
49 | spsr_fiq,
50 | spsr_irq,
51 | spsr_svc,
52 | spsr_abt,
53 | spsr_und,
54 |
55 | COUNT
56 | };
57 |
58 | constexpr int GDB_ARCH_N_REG = (int)Register::COUNT;
59 |
60 | }
61 |
62 | #endif
63 |
64 |
--------------------------------------------------------------------------------
/src/teakra/include/teakra/disassembler.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | namespace Teakra::Disassembler {
10 |
11 | struct ArArpSettings {
12 | std::array ar;
13 | std::array arp;
14 | };
15 |
16 | bool NeedExpansion(std::uint16_t opcode);
17 | bool NeedExpansion(std::uint16_t opcode);
18 | std::vector GetTokenList(std::uint16_t opcode, std::uint16_t expansion = 0,
19 | std::optional ar_arp = std::nullopt);
20 | std::string Do(std::uint16_t opcode, std::uint16_t expansion = 0,
21 | std::optional ar_arp = std::nullopt);
22 |
23 | } // namespace Teakra::Disassembler
24 |
--------------------------------------------------------------------------------
/src/teakra/.travis.yml:
--------------------------------------------------------------------------------
1 | language: cpp
2 |
3 | matrix:
4 | include:
5 | - env: NAME="Linux Build"
6 | os: linux
7 | dist: xenial
8 | sudo: false
9 | cache:
10 | directories:
11 | - $HOME/assets
12 | addons:
13 | apt:
14 | sources:
15 | - ubuntu-toolchain-r-test
16 | packages:
17 | - gcc-7
18 | - g++-7
19 | script: ./.travis/linux-build.sh
20 | - env: NAME="macOS Build"
21 | os: osx
22 | sudo: false
23 | osx_image: xcode10
24 | cache:
25 | directories:
26 | - $HOME/assets
27 | script: ./.travis/macos-build.sh
28 | - env: NAME="Windows Build"
29 | os: windows
30 | cache:
31 | directories:
32 | - $HOME/assets
33 | script: ./.travis/windows-build.sh
34 |
--------------------------------------------------------------------------------
/src/teakra/src/cru.md:
--------------------------------------------------------------------------------
1 | # CRU
2 |
3 | ## MMIO Layout
4 |
5 | ```
6 | (N = 0..14)
7 | +-----------#---+---+---+---#---+---+---+---#---+---+---+---#---+---+---+---#
8 | |+0x0140+N*4| OFFSET_L |
9 | +-----------#---+---+---+---#---+---+---+---#---+---+---+---#---+---+---+---#
10 | |+0x0142+N*4| | | ? |
11 | +-----------#---+---+---+---#---+---+---+---#---+---+---+---#---+---+---+---#
12 | |+0x017C | OFFSET_L |
13 | +-----------#---+---+---+---#---+---+---+---#---+---+---+---#---+---+---+---#
14 | |+0x017E | | | | ? |
15 | +-----------#---+---+---+---#---+---+---+---#---+---+---+---#---+---+---+---#
16 |
17 | OFFSET_L, OFFSET_H: address of the program to replace
18 | ```
19 |
--------------------------------------------------------------------------------
/src/ARMJIT_x64/ARMJIT_Offsets.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2022 melonDS team, RSDuck
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #define ARM_CPSR_offset 0x64
20 | #define ARM_Cycles_offset 0xc
21 | #define ARM_StopExecution_offset 0x10
22 |
--------------------------------------------------------------------------------
/src/debug/GdbProto.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef GDBPROTO_H_
3 | #define GDBPROTO_H_
4 |
5 | #include
6 | #include
7 |
8 | #include "GdbStub.h" /* class GdbStub */
9 |
10 |
11 | #define MOCKTEST 0
12 |
13 |
14 | namespace Gdb {
15 |
16 | using namespace melonDS;
17 | constexpr int GDBPROTO_BUFFER_CAPACITY = 1024+128;
18 |
19 | extern u8 Cmdbuf[GDBPROTO_BUFFER_CAPACITY];
20 | extern ssize_t Cmdlen;
21 |
22 | namespace Proto {
23 |
24 | extern u8 PacketBuf[GDBPROTO_BUFFER_CAPACITY];
25 | extern u8 RespBuf[GDBPROTO_BUFFER_CAPACITY+5];
26 |
27 | Gdb::ReadResult MsgRecv(int connfd, u8 cmd_dest[/*static GDBPROTO_BUFFER_CAPACITY*/]);
28 |
29 | int SendAck(int connfd);
30 | int SendNak(int connfd);
31 |
32 | int Resp(int connfd, const u8* data1, size_t len1, const u8* data2, size_t len2, bool noack);
33 |
34 | int WaitAckBlocking(int connfd, u8* ackp, int to_ms);
35 |
36 | }
37 |
38 | }
39 |
40 | #endif
41 |
42 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/gl/context_egl_x11.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "context_egl.h"
3 | #include "x11_window.h"
4 |
5 | namespace GL {
6 |
7 | class ContextEGLX11 final : public ContextEGL
8 | {
9 | public:
10 | ContextEGLX11(const WindowInfo& wi);
11 | ~ContextEGLX11() override;
12 |
13 | static std::unique_ptr Create(const WindowInfo& wi, const Version* versions_to_try,
14 | size_t num_versions_to_try);
15 |
16 | std::unique_ptr CreateSharedContext(const WindowInfo& wi) override;
17 | void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
18 |
19 | protected:
20 | EGLNativeWindowType GetNativeWindow(EGLConfig config) override;
21 |
22 | private:
23 | ALWAYS_INLINE Display* GetDisplay() const { return static_cast(m_wi.display_connection); }
24 |
25 | X11Window m_window;
26 | };
27 |
28 | } // namespace GL
29 |
--------------------------------------------------------------------------------
/src/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef VERSION_H
20 | #define VERSION_H
21 |
22 | #define MELONDS_URL "https://melonds.kuribo64.net/"
23 |
24 | #endif // VERSION_H
25 |
26 |
--------------------------------------------------------------------------------
/src/fatfs/00readme.txt:
--------------------------------------------------------------------------------
1 | FatFs Module Source Files R0.14b
2 |
3 |
4 | FILES
5 |
6 | 00readme.txt This file.
7 | 00history.txt Revision history.
8 | ff.c FatFs module.
9 | ffconf.h Configuration file of FatFs module.
10 | ff.h Common include file for FatFs and application module.
11 | diskio.h Common include file for FatFs and disk I/O module.
12 | diskio.c An example of glue function to attach existing disk I/O module to FatFs.
13 | ffunicode.c Optional Unicode utility functions.
14 | ffsystem.c An example of optional O/S related functions.
15 |
16 |
17 | Low level disk I/O module is not included in this archive because the FatFs
18 | module is only a generic file system layer and it does not depend on any specific
19 | storage device. You need to provide a low level disk I/O module written to
20 | control the storage device that attached to the target system.
21 |
22 |
--------------------------------------------------------------------------------
/src/teakra/CMakeModules/CreateDirectoryGroups.cmake:
--------------------------------------------------------------------------------
1 | # This function should be passed a name of an existing target. It will automatically generate
2 | # file groups following the directory hierarchy, so that the layout of the files in IDEs matches the
3 | # one in the filesystem.
4 | function(create_target_directory_groups target_name)
5 | # Place any files that aren't in the source list in a separate group so that they don't get in
6 | # the way.
7 | source_group("Other Files" REGULAR_EXPRESSION ".")
8 |
9 | get_target_property(target_sources "${target_name}" SOURCES)
10 |
11 | foreach(file_name IN LISTS target_sources)
12 | get_filename_component(dir_name "${file_name}" PATH)
13 | # Group names use '\' as a separator even though the entire rest of CMake uses '/'...
14 | string(REPLACE "/" "\\" group_name "${dir_name}")
15 | source_group("${group_name}" FILES "${file_name}")
16 | endforeach()
17 | endfunction()
18 |
--------------------------------------------------------------------------------
/src/dolphin/ArmCommon.h:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Dolphin Emulator Project
2 | // Licensed under GPLv2+
3 | // Refer to the license.txt file included.
4 |
5 | #include "../types.h"
6 |
7 | enum CCFlags
8 | {
9 | CC_EQ = 0, // Equal
10 | CC_NEQ, // Not equal
11 | CC_CS, // Carry Set
12 | CC_CC, // Carry Clear
13 | CC_MI, // Minus (Negative)
14 | CC_PL, // Plus
15 | CC_VS, // Overflow
16 | CC_VC, // No Overflow
17 | CC_HI, // Unsigned higher
18 | CC_LS, // Unsigned lower or same
19 | CC_GE, // Signed greater than or equal
20 | CC_LT, // Signed less than
21 | CC_GT, // Signed greater than
22 | CC_LE, // Signed less than or equal
23 | CC_AL, // Always (unconditional) 14
24 | CC_HS = CC_CS, // Alias of CC_CS Unsigned higher or same
25 | CC_LO = CC_CC, // Alias of CC_CC Unsigned lower
26 | };
27 | const melonDS::u32 NO_COND = 0xE0000000;
28 |
--------------------------------------------------------------------------------
/src/CRC32.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef CRC32_H
20 | #define CRC32_H
21 |
22 | #include
23 |
24 | #include "types.h"
25 |
26 | namespace melonDS
27 | {
28 | u32 CRC32(const u8* data, int len, u32 start=0);
29 | }
30 |
31 | #endif // CRC32_H
32 |
--------------------------------------------------------------------------------
/cmake/Toolchain-cross-MinGW-w64-x86_64.cmake:
--------------------------------------------------------------------------------
1 | # https://cmake.org/Wiki/CMake_Cross_Compiling
2 |
3 | # the name of the target operating system
4 | SET(CMAKE_SYSTEM_NAME Windows)
5 |
6 | SET(COMPILER_PREFIX "x86_64-w64-mingw32")
7 |
8 | # which compilers to use for C and C++
9 | find_program(CMAKE_C_COMPILER NAMES ${COMPILER_PREFIX}-gcc)
10 | find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++)
11 | find_program(CMAKE_RC_COMPILER NAMES ${COMPILER_PREFIX}-windres)
12 |
13 | # pkg-config
14 | find_program(PKG_CONFIG_EXECUTABLE NAMES ${COMPILER_PREFIX}-pkg-config)
15 |
16 | # here is the target environment located
17 | SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX}/sys-root/mingw)
18 |
19 | # adjust the default behaviour of the FIND_XXX() commands:
20 | # search headers and libraries in the target environment, search
21 | # programs in the host environment
22 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
23 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
24 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
25 |
--------------------------------------------------------------------------------
/src/teakra/src/test.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #ifndef COMMON_TYPE_3DS
7 | #include "common_types.h"
8 | #endif
9 |
10 | constexpr u16 TestSpaceX = 0x6400;
11 | constexpr u16 TestSpaceY = 0xCC00;
12 | constexpr u16 TestSpaceSize = 0x0200;
13 |
14 | struct State {
15 | std::array a, b;
16 | std::array p;
17 | std::array r;
18 | std::array x, y;
19 | u16 stepi0, stepj0, mixp, sv, repc, lc;
20 | u16 cfgi, cfgj;
21 | u16 stt0, stt1, stt2;
22 | u16 mod0, mod1, mod2;
23 | std::array ar;
24 | std::array arp;
25 |
26 | std::array test_space_x;
27 | std::array test_space_y;
28 | };
29 |
30 | static_assert(std::is_trivially_copyable_v);
31 |
32 | struct TestCase {
33 | State before, after;
34 | u16 opcode, expand;
35 | };
36 |
37 | static_assert(sizeof(TestCase) == 4312);
38 | static_assert(std::is_trivially_copyable_v);
39 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/window_info.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "../types.h"
3 |
4 | // Contains the information required to create a graphics context in a window.
5 | struct WindowInfo
6 | {
7 | enum class Type
8 | {
9 | Surfaceless,
10 | Win32,
11 | X11,
12 | Wayland,
13 | MacOS,
14 | Android,
15 | Display,
16 | };
17 |
18 | enum class SurfaceFormat
19 | {
20 | None,
21 | Auto,
22 | RGB8,
23 | RGBA8,
24 | RGB565,
25 | Count
26 | };
27 |
28 | Type type = Type::Surfaceless;
29 | void* display_connection = nullptr;
30 | void* window_handle = nullptr;
31 | melonDS::u32 surface_width = 0;
32 | melonDS::u32 surface_height = 0;
33 | float surface_refresh_rate = 0.0f;
34 | float surface_scale = 1.0f;
35 | SurfaceFormat surface_format = SurfaceFormat::RGB8;
36 |
37 | // Needed for macOS.
38 | #ifdef __APPLE__
39 | void* surface_handle = nullptr;
40 | #endif
41 |
42 | static bool QueryRefreshRateForWindow(const WindowInfo& wi, float* refresh_rate);
43 | };
44 |
--------------------------------------------------------------------------------
/src/teakra/src/apbp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include "common_types.h"
6 |
7 | namespace Teakra {
8 | class Apbp {
9 | public:
10 | Apbp();
11 | ~Apbp();
12 |
13 | void Reset();
14 |
15 | void SendData(unsigned channel, u16 data);
16 | u16 RecvData(unsigned channel);
17 | u16 PeekData(unsigned channel) const;
18 | bool IsDataReady(unsigned channel) const;
19 | u16 GetDisableInterrupt(unsigned channel) const;
20 | void SetDisableInterrupt(unsigned channel, u16 v);
21 | void SetDataHandler(unsigned channel, std::function handler);
22 |
23 | void SetSemaphore(u16 bits);
24 | void ClearSemaphore(u16 bits);
25 | u16 GetSemaphore() const;
26 | void MaskSemaphore(u16 bits);
27 | u16 GetSemaphoreMask() const;
28 | void SetSemaphoreHandler(std::function handler);
29 |
30 | bool IsSemaphoreSignaled() const;
31 |
32 | private:
33 | class Impl;
34 | std::unique_ptr impl;
35 | };
36 | } // namespace Teakra
37 |
--------------------------------------------------------------------------------
/src/MemRegion.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef MELONDS_MEMREGION_H
20 | #define MELONDS_MEMREGION_H
21 |
22 | #include "types.h"
23 |
24 | // this file exists to break #include cycle loops
25 | namespace melonDS
26 | {
27 | struct MemRegion
28 | {
29 | u8* Mem;
30 | u32 Mask;
31 | };
32 | }
33 | #endif //MELONDS_MEMREGION_H
34 |
--------------------------------------------------------------------------------
/src/frontend/glad/glad_egl.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | EGL loader generated by glad 0.1.36 on Thu Sep 15 11:06:51 2022.
4 |
5 | Language/Generator: C/C++
6 | Specification: egl
7 | APIs: egl=1.5
8 | Profile: -
9 | Extensions:
10 |
11 | Loader: True
12 | Local files: True
13 | Omit khrplatform: False
14 | Reproducible: False
15 |
16 | Commandline:
17 | --api="egl=1.5" --generator="c" --spec="egl" --local-files --extensions=""
18 | Online:
19 | https://glad.dav1d.de/#language=c&specification=egl&loader=on&api=egl%3D1.5
20 | */
21 |
22 | #include
23 | #include
24 | #include
25 | #include "glad_egl.h"
26 |
27 | int gladLoadEGL(void) {
28 | return gladLoadEGLLoader((GLADloadproc)eglGetProcAddress);
29 | }
30 |
31 | static int find_extensionsEGL(void) {
32 | return 1;
33 | }
34 |
35 | static void find_coreEGL(void) {
36 | }
37 |
38 | int gladLoadEGLLoader(GLADloadproc load) {
39 | (void) load;
40 | find_coreEGL();
41 |
42 | if (!find_extensionsEGL()) return 0;
43 | return 1;
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/src/teakra/src/processor.cpp:
--------------------------------------------------------------------------------
1 | #include "interpreter.h"
2 | #include "processor.h"
3 | #include "register.h"
4 |
5 | namespace Teakra {
6 |
7 | struct Processor::Impl {
8 | Impl(CoreTiming& core_timing, MemoryInterface& memory_interface)
9 | : core_timing(core_timing), interpreter(core_timing, regs, memory_interface) {}
10 | CoreTiming& core_timing;
11 | RegisterState regs;
12 | Interpreter interpreter;
13 | };
14 |
15 | Processor::Processor(CoreTiming& core_timing, MemoryInterface& memory_interface)
16 | : impl(new Impl(core_timing, memory_interface)) {}
17 | Processor::~Processor() = default;
18 |
19 | void Processor::Reset() {
20 | impl->regs = RegisterState();
21 | }
22 |
23 | void Processor::Run(unsigned cycles) {
24 | impl->interpreter.Run(cycles);
25 | }
26 |
27 | void Processor::SignalInterrupt(u32 i) {
28 | impl->interpreter.SignalInterrupt(i);
29 | }
30 | void Processor::SignalVectoredInterrupt(u32 address, bool context_switch) {
31 | impl->interpreter.SignalVectoredInterrupt(address, context_switch);
32 | }
33 |
34 | } // namespace Teakra
35 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/LAN_Socket.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef LAN_SOCKET_H
20 | #define LAN_SOCKET_H
21 |
22 | #include "types.h"
23 |
24 | namespace LAN_Socket
25 | {
26 | using namespace melonDS;
27 |
28 | //
29 |
30 |
31 | bool Init();
32 | void DeInit();
33 |
34 | int SendPacket(u8* data, int len);
35 | int RecvPacket(u8* data);
36 |
37 | }
38 |
39 | #endif // LAN_SOCKET_H
40 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/scoped_guard.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | /// ScopedGuard provides an object which runs a function (usually a lambda) when
6 | /// it goes out of scope. This can be useful for releasing resources or handles
7 | /// which do not normally have C++ types to automatically release.
8 | template
9 | class ScopedGuard final
10 | {
11 | public:
12 | ALWAYS_INLINE ScopedGuard(T&& func) : m_func(std::forward(func)) {}
13 | ALWAYS_INLINE ScopedGuard(ScopedGuard&& other) : m_func(std::move(other.m_func)) { other.m_func = nullptr; }
14 | ALWAYS_INLINE ~ScopedGuard() { Invoke(); }
15 |
16 | ScopedGuard(const ScopedGuard&) = delete;
17 | void operator=(const ScopedGuard&) = delete;
18 |
19 | /// Prevents the function from being invoked when we go out of scope.
20 | ALWAYS_INLINE void Cancel() { m_func.reset(); }
21 |
22 | /// Explicitly fires the function.
23 | ALWAYS_INLINE void Invoke()
24 | {
25 | if (!m_func.has_value())
26 | return;
27 |
28 | m_func.value()();
29 | m_func.reset();
30 | }
31 |
32 | private:
33 | std::optional m_func;
34 | };
35 |
--------------------------------------------------------------------------------
/src/teakra/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Weiyi Wang
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/ARMJIT_Compiler.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2022 melonDS team, RSDuck
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef ARMJIT_COMPILER_H
20 | #define ARMJIT_COMPILER_H
21 |
22 | #ifdef JIT_ENABLED
23 |
24 | #if defined(__x86_64__)
25 | #include "ARMJIT_x64/ARMJIT_Compiler.h"
26 | #elif defined(__aarch64__)
27 | #include "ARMJIT_A64/ARMJIT_Compiler.h"
28 | #else
29 | #error "The current target platform doesn't have a JIT backend"
30 | #endif
31 |
32 | #endif
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/res/melon.rc.in:
--------------------------------------------------------------------------------
1 | #define VOS_NT_WINDOWS32 0x00040004L
2 | #define VFT_APP 0x00000001L
3 |
4 | //this will set your .exe icon
5 | 100 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "${CMAKE_SOURCE_DIR}/res/melon.ico"
6 |
7 | //include version information in .exe, modify these values to match your needs
8 | 1 VERSIONINFO
9 | FILEVERSION ${melonDS_VERSION_MAJOR},${melonDS_VERSION_MINOR},${melonDS_VERSION_PATCH},0
10 | PRODUCTVERSION ${melonDS_VERSION_MAJOR},${melonDS_VERSION_MINOR},${melonDS_VERSION_PATCH},0
11 | FILETYPE VFT_APP
12 | {
13 | BLOCK "StringFileInfo"
14 | {
15 | BLOCK "040904E4"
16 | {
17 | VALUE "CompanyName", "Melon Factory of Kuribo64"
18 | VALUE "FileVersion", "${melonDS_VERSION}"
19 | VALUE "FileDescription", "melonDS emulator"
20 | VALUE "InternalName", "SDnolem"
21 | VALUE "LegalCopyright", "2016-2023 melonDS team"
22 | VALUE "LegalTrademarks", ""
23 | VALUE "OriginalFilename", "melonDS.exe"
24 | VALUE "ProductName", "melonDS"
25 | VALUE "ProductVersion", "${melonDS_VERSION}"
26 | }
27 | }
28 | BLOCK "VarFileInfo"
29 | {
30 | VALUE "Translation", 0x0409, 1252 //language codes
31 | }
32 | }
33 |
34 | 1 24 "xp.manifest"
35 |
--------------------------------------------------------------------------------
/.github/workflows/build-windows.yml:
--------------------------------------------------------------------------------
1 | name: Windows
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 | branches:
9 | - master
10 |
11 | env:
12 | BUILD_TYPE: Release
13 |
14 | jobs:
15 | build:
16 |
17 | runs-on: windows-latest
18 |
19 | defaults:
20 | run:
21 | shell: msys2 {0}
22 | steps:
23 | - uses: actions/checkout@v1
24 | - uses: msys2/setup-msys2@v2
25 | with:
26 | msystem: MINGW64
27 | update: true
28 |
29 | - name: Install dependencies
30 | run: pacman -Sq --noconfirm git pkgconf mingw-w64-x86_64-{cmake,SDL2,qt5-static,libslirp,libarchive,toolchain}
31 |
32 | - name: Configure
33 | working-directory: ${{runner.workspace}}
34 | run: cmake -B build $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_STATIC=ON -DCMAKE_PREFIX_PATH=C:/tools/msys64/mingw64/qt5-static
35 |
36 | - name: Make
37 | working-directory: ${{runner.workspace}}/build
38 | run: cmake --build .
39 |
40 | - uses: actions/upload-artifact@v1
41 | with:
42 | name: melonDS-windows-x86_64
43 | path: ${{runner.workspace}}\build\melonDS.exe
44 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/gl/context_egl_wayland.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "context_egl.h"
3 | #include
4 |
5 | namespace GL {
6 |
7 | class ContextEGLWayland final : public ContextEGL
8 | {
9 | public:
10 | ContextEGLWayland(const WindowInfo& wi);
11 | ~ContextEGLWayland() override;
12 |
13 | static std::unique_ptr Create(const WindowInfo& wi, const Version* versions_to_try,
14 | size_t num_versions_to_try);
15 |
16 | std::unique_ptr CreateSharedContext(const WindowInfo& wi) override;
17 | void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
18 |
19 | protected:
20 | EGLNativeWindowType GetNativeWindow(EGLConfig config) override;
21 |
22 | private:
23 | bool LoadModule();
24 |
25 | wl_egl_window* m_wl_window = nullptr;
26 |
27 | void* m_wl_module = nullptr;
28 | wl_egl_window* (*m_wl_egl_window_create)(struct wl_surface* surface, int width, int height);
29 | void (*m_wl_egl_window_destroy)(struct wl_egl_window* egl_window);
30 | void (*m_wl_egl_window_resize)(struct wl_egl_window* egl_window, int width, int height, int dx, int dy);
31 | };
32 |
33 | } // namespace GL
34 |
--------------------------------------------------------------------------------
/src/ROMList.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef ROMLIST_H
20 | #define ROMLIST_H
21 |
22 | #include
23 |
24 | #include "types.h"
25 |
26 | namespace melonDS
27 | {
28 | struct ROMListEntry
29 | {
30 | u32 GameCode;
31 | u32 ROMSize;
32 | u32 SaveMemType;
33 | };
34 |
35 |
36 | extern const ROMListEntry ROMList[];
37 |
38 | /// The number of elements in \c ROMList.
39 | extern const size_t ROMListEntryCount;
40 |
41 | }
42 | #endif // ROMLIST_H
43 |
--------------------------------------------------------------------------------
/cmake/FixInterfaceIncludes.cmake:
--------------------------------------------------------------------------------
1 | # The entire codebase quite reasonably does things like #include or
2 | # CMake apparently doesn't think you should be doing this, so just includes $PREFIX/include/packagename for a given
3 | # package as include directories when using `target_link_libraries` with an imported target, this hacky function fixes
4 | # that up so includes can keep working as they always did but we can still use fancy imported targets.
5 | # This is stupid.
6 |
7 | function(fix_interface_includes)
8 | foreach (target ${ARGN})
9 | set(NEW_DIRS)
10 | get_target_property(DIRS "${target}" INTERFACE_INCLUDE_DIRECTORIES)
11 |
12 | if (NOT DIRS)
13 | continue()
14 | endif()
15 |
16 | foreach (DIR ${DIRS})
17 | get_filename_component(PARENT_DIR "${DIR}" DIRECTORY)
18 |
19 | if (PARENT_DIR MATCHES "include$")
20 | list(APPEND NEW_DIRS "${PARENT_DIR}")
21 | endif()
22 | endforeach()
23 |
24 | list(APPEND DIRS ${NEW_DIRS})
25 | set_target_properties("${target}" PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${DIRS}")
26 | endforeach()
27 | endfunction()
28 |
29 |
--------------------------------------------------------------------------------
/src/ARMJIT_x64/ARMJIT_GenOffsets.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2022 melonDS team, RSDuck
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #include "../ARM.h"
20 | using namespace melonDS;
21 | int main(int argc, char* argv[])
22 | {
23 | FILE* f = fopen("ARMJIT_Offsets.h", "w");
24 | #define writeOffset(field) \
25 | fprintf(f, "#define ARM_" #field "_offset 0x%x\n", offsetof(ARM, field))
26 |
27 | writeOffset(CPSR);
28 | writeOffset(Cycles);
29 | writeOffset(StopExecution);
30 |
31 | fclose(f);
32 | return 0;
33 | }
--------------------------------------------------------------------------------
/src/teakra/src/common_types.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | using u8 = std::uint8_t;
6 | using u16 = std::uint16_t;
7 | using u32 = std::uint32_t;
8 | using u64 = std::uint64_t;
9 |
10 | using s8 = std::int8_t;
11 | using s16 = std::int16_t;
12 | using s32 = std::int32_t;
13 | using s64 = std::int64_t;
14 |
15 | template
16 | constexpr unsigned BitSize() {
17 | return sizeof(T) * 8; // yeah I know I shouldn't use 8 here.
18 | }
19 |
20 | template
21 | constexpr T SignExtend(const T value, unsigned bit_count) {
22 | const T mask = static_cast(1ULL << bit_count) - 1;
23 | const bool sign_bit = ((value >> (bit_count - 1)) & 1) != 0;
24 | if (sign_bit) {
25 | return value | ~mask;
26 | }
27 | return value & mask;
28 | }
29 |
30 | template
31 | constexpr T SignExtend(const T value) {
32 | static_assert(bit_count <= BitSize(), "bit_count larger than bitsize of T");
33 | return SignExtend(value, bit_count);
34 | }
35 |
36 | inline constexpr u16 BitReverse(u16 value) {
37 | u16 result = 0;
38 | for (u32 i = 0; i < 16; ++i) {
39 | result |= ((value >> i) & 1) << (15 - i);
40 | }
41 | return result;
42 | }
43 |
--------------------------------------------------------------------------------
/src/teakra/src/timer.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include "common_types.h"
6 | #include "core_timing.h"
7 |
8 | namespace Teakra {
9 |
10 | class Timer : public CoreTiming::Callbacks {
11 | public:
12 | Timer(CoreTiming& core_timing);
13 |
14 | enum class CountMode : u16 {
15 | Single = 0,
16 | AutoRestart = 1,
17 | FreeRunning = 2,
18 | EventCount = 3,
19 | };
20 |
21 | void Reset();
22 |
23 | void Restart();
24 | void Tick() override;
25 | void TickEvent();
26 | u64 GetMaxSkip() const override;
27 | void Skip(u64 ticks) override;
28 |
29 | u16 update_mmio = 0;
30 | u16 pause = 0;
31 | CountMode count_mode = CountMode::Single;
32 | u16 scale = 0;
33 |
34 | u16 start_high = 0;
35 | u16 start_low = 0;
36 | u32 counter = 0;
37 | u16 counter_high = 0;
38 | u16 counter_low = 0;
39 |
40 | void SetInterruptHandler(std::function handler) {
41 | interrupt_handler = std::move(handler);
42 | }
43 |
44 | private:
45 | std::function interrupt_handler;
46 |
47 | void UpdateMMIO();
48 |
49 | class TimerTimingCallbacks;
50 | };
51 |
52 | } // namespace Teakra
53 |
--------------------------------------------------------------------------------
/.github/workflows/build-ubuntu.yml:
--------------------------------------------------------------------------------
1 | name: Ubuntu
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 | branches:
9 | - master
10 |
11 | jobs:
12 | build:
13 | name: x86_64
14 |
15 | runs-on: ubuntu-20.04
16 |
17 | steps:
18 | - uses: actions/checkout@v1
19 | - name: Install dependencies
20 | run: |
21 | sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list
22 | sudo apt update
23 | sudo apt install cmake extra-cmake-modules libcurl4-gnutls-dev libpcap0.8-dev libsdl2-dev qt5-default qtbase5-private-dev qtmultimedia5-dev libslirp0 libslirp-dev libarchive-dev zstd libzstd-dev --allow-downgrades
24 | - name: Create build environment
25 | run: mkdir ${{runner.workspace}}/build
26 | - name: Configure
27 | working-directory: ${{runner.workspace}}/build
28 | run: cmake $GITHUB_WORKSPACE
29 | - name: Make
30 | working-directory: ${{runner.workspace}}/build
31 | run: |
32 | make -j$(nproc --all)
33 | mkdir dist
34 | cp melonDS dist
35 | - uses: actions/upload-artifact@v1
36 | with:
37 | name: melonDS-ubuntu-x86_64
38 | path: ${{runner.workspace}}/build/dist
39 |
--------------------------------------------------------------------------------
/src/ARMInterpreter_Branch.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef ARMINTERPRETER_BRANCH_H
20 | #define ARMINTERPRETER_BRANCH_H
21 |
22 | namespace melonDS
23 | {
24 | namespace ARMInterpreter
25 | {
26 |
27 | void A_B(ARM* cpu);
28 | void A_BL(ARM* cpu);
29 | void A_BX(ARM* cpu);
30 | void A_BLX_REG(ARM* cpu);
31 |
32 | void T_BCOND(ARM* cpu);
33 | void T_BX(ARM* cpu);
34 | void T_BLX_REG(ARM* cpu);
35 | void T_B(ARM* cpu);
36 | void T_BL_LONG_1(ARM* cpu);
37 | void T_BL_LONG_2(ARM* cpu);
38 |
39 | }
40 |
41 | }
42 | #endif
43 |
--------------------------------------------------------------------------------
/src/OpenGLSupport.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef OPENGLSUPPORT_H
20 | #define OPENGLSUPPORT_H
21 |
22 | #include
23 | #include
24 |
25 | #include "Platform.h"
26 | #include "PlatformOGL.h"
27 |
28 | namespace melonDS::OpenGL
29 | {
30 |
31 | bool BuildShaderProgram(const char* vs, const char* fs, GLuint* ids, const char* name);
32 | bool LinkShaderProgram(GLuint* ids);
33 | void DeleteShaderProgram(GLuint* ids);
34 | void UseShaderProgram(GLuint* ids);
35 |
36 | }
37 |
38 | #endif // OPENGLSUPPORT_H
39 |
--------------------------------------------------------------------------------
/src/types.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef TYPES_H
20 | #define TYPES_H
21 |
22 | #include
23 | #include
24 |
25 | namespace melonDS
26 | {
27 | typedef uint8_t u8;
28 | typedef uint16_t u16;
29 | typedef uint32_t u32;
30 | typedef uint64_t u64;
31 | typedef int8_t s8;
32 | typedef int16_t s16;
33 | typedef int32_t s32;
34 | typedef int64_t s64;
35 |
36 | template
37 | using array2d = std::array, A>;
38 | }
39 | #endif // TYPES_H
40 |
--------------------------------------------------------------------------------
/src/FATIO.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 |
20 | #ifndef FATIO_H
21 | #define FATIO_H
22 |
23 | #include
24 | #include "fatfs/ff.h"
25 |
26 | // extra additions for interfacing with melonDS
27 | namespace melonDS
28 | {
29 | using ff_disk_read_cb = std::function;
30 | using ff_disk_write_cb = std::function;
31 |
32 | void ff_disk_open(const ff_disk_read_cb& readcb, const ff_disk_write_cb& writecb, LBA_t seccnt);
33 | void ff_disk_close();
34 | }
35 |
36 | #endif // FATIO_H
37 |
--------------------------------------------------------------------------------
/src/teakra/src/core_timing.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include "common_types.h"
8 |
9 | namespace Teakra {
10 |
11 | class CoreTiming {
12 | public:
13 | class Callbacks {
14 | public:
15 | virtual ~Callbacks() = default;
16 | virtual void Tick() = 0;
17 | virtual u64 GetMaxSkip() const = 0;
18 | virtual void Skip(u64) = 0;
19 | static constexpr u64 Infinity = std::numeric_limits::max();
20 | };
21 |
22 | void Tick() {
23 | for (const auto& callbacks : registered_callbacks) {
24 | callbacks->Tick();
25 | }
26 | }
27 |
28 | u64 Skip(u64 maximum) {
29 | u64 ticks = maximum;
30 | for (const auto& callbacks : registered_callbacks) {
31 | ticks = std::min(ticks, callbacks->GetMaxSkip());
32 | }
33 | for (const auto& callbacks : registered_callbacks) {
34 | callbacks->Skip(ticks);
35 | }
36 | return ticks;
37 | }
38 |
39 | void RegisterCallbacks(Callbacks* callbacks) {
40 | registered_callbacks.push_back(std::move(callbacks));
41 | }
42 |
43 | private:
44 | std::vector registered_callbacks;
45 | };
46 | } // namespace Teakra
47 |
--------------------------------------------------------------------------------
/src/tiny-AES-c/unlicense.txt:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
25 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/gl/x11_window.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "../duckstation_compat.h"
3 | #include
4 | #include
5 |
6 | namespace GL {
7 | using namespace melonDS;
8 | class X11Window
9 | {
10 | public:
11 | X11Window();
12 | ~X11Window();
13 |
14 | ALWAYS_INLINE Window GetWindow() const { return m_window; }
15 | ALWAYS_INLINE u32 GetWidth() const { return m_width; }
16 | ALWAYS_INLINE u32 GetHeight() const { return m_height; }
17 |
18 | bool Create(Display* display, Window parent_window, const XVisualInfo* vi);
19 | void Destroy();
20 |
21 | // Setting a width/height of 0 will use parent dimensions.
22 | void Resize(u32 width = 0, u32 height = 0);
23 |
24 | private:
25 | Display* m_display = nullptr;
26 | Window m_parent_window = {};
27 | Window m_window = {};
28 | Colormap m_colormap = {};
29 | u32 m_width = 0;
30 | u32 m_height = 0;
31 | };
32 |
33 | // Helper class for managing X errors
34 | class X11InhibitErrors
35 | {
36 | public:
37 | X11InhibitErrors();
38 | ~X11InhibitErrors();
39 |
40 | ALWAYS_INLINE bool HadError() const { return m_had_error; }
41 |
42 | private:
43 | static int ErrorHandler(Display* display, XErrorEvent* ee);
44 |
45 | XErrorHandler m_old_handler = {};
46 | bool m_had_error = false;
47 | };
48 |
49 | } // namespace GL
50 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/AudioInOut.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef AUDIO_INOUT_H
20 | #define AUDIO_INOUT_H
21 |
22 | #include "types.h"
23 |
24 | #include
25 |
26 | class EmuThread;
27 | namespace melonDS
28 | {
29 | class NDS;
30 | }
31 | namespace AudioInOut
32 | {
33 |
34 | void Init(EmuThread* thread);
35 | void DeInit();
36 |
37 | void MicProcess(melonDS::NDS& nds);
38 | void AudioMute(QMainWindow* mainWindow);
39 |
40 | void AudioSync(melonDS::NDS& nds);
41 |
42 | void UpdateSettings(melonDS::NDS& nds);
43 |
44 | void Enable();
45 | void Disable();
46 |
47 | }
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/src/teakra/src/makedsp1/sha256.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | * Filename: sha256.h
3 | * Author: Brad Conte (brad AT bradconte.com)
4 | * Copyright:
5 | * Disclaimer: This code is presented "as is" without any guarantees.
6 | * Details: Defines the API for the corresponding SHA1 implementation.
7 | *********************************************************************/
8 |
9 | #ifndef SHA256_H
10 | #define SHA256_H
11 |
12 | /*************************** HEADER FILES ***************************/
13 | #include
14 |
15 | /****************************** MACROS ******************************/
16 | #define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest
17 |
18 | /**************************** DATA TYPES ****************************/
19 | typedef unsigned char BYTE; // 8-bit byte
20 | typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
21 |
22 | typedef struct {
23 | BYTE data[64];
24 | WORD datalen;
25 | unsigned long long bitlen;
26 | WORD state[8];
27 | } SHA256_CTX;
28 |
29 | /*********************** FUNCTION DECLARATIONS **********************/
30 | void sha256_init(SHA256_CTX* ctx);
31 | void sha256_update(SHA256_CTX* ctx, const BYTE data[], size_t len);
32 | void sha256_final(SHA256_CTX* ctx, BYTE hash[]);
33 |
34 | #endif // SHA256_H
35 |
--------------------------------------------------------------------------------
/src/teakra/src/mmio.md:
--------------------------------------------------------------------------------
1 | # MMIO
2 |
3 | The core processor communicates with peripherals (and indirectly external hardware such as CPU) via MMIO. The MMIO region occupies 0x0800-word region in the 16-bit address space, initially starting at 0x8000. The location of MMIO region can be configured in MIU (...yes, via MMIO). MMIO registers usually use even addresses only, which seems to be a hardware optimization as there is a register in MIU that enables forcing this rule. Each peripheral corresponds to a sub-region in MMIO, listed below. The detail of registers are in their corresponding peripheral documents. The register addresses in these documents are offsets to the start of the MMIO region.
4 |
5 | - `+0x0000` ?
6 | - `+0x0004` JAM
7 | - `+0x0010` GLUE
8 | - `+0x0020` [Timer](timer.md)
9 | - `+0x0050` [SIO](sio.md), Serial IO
10 | - `+0x0060` [OCEM](ocem.md), On-chip Emulation Module
11 | - `+0x0080` [PMU](pmu.md), Power Management Unit
12 | - `+0x00C0` [APBP](apbp.md), Advanced Peripheral Bus Port?
13 | - `+0x00E0` [AHBM](ahbm.md), Advanced High Performance Bus Master
14 | - `+0x0100` [MIU](miu.md), Memory Interface Unit
15 | - `+0x0140` [CRU](cru.md), Code Replacement Unit
16 | - `+0x0180` [DMA](dma.md), Direct Memory Access
17 | - `+0x0200` [ICU](icu.md), Interrupt Control Unit
18 | - `+0x0280` [BTDMP](btdmp.md), Buffered Time Division Multiplexing Port
19 |
--------------------------------------------------------------------------------
/src/AREngine.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef ARENGINE_H
20 | #define ARENGINE_H
21 |
22 | #include "ARCodeFile.h"
23 |
24 | namespace melonDS
25 | {
26 | class NDS;
27 | class AREngine
28 | {
29 | public:
30 | AREngine(melonDS::NDS& nds);
31 |
32 | ARCodeFile* GetCodeFile() { return CodeFile; }
33 | void SetCodeFile(ARCodeFile* file) { CodeFile = file; }
34 |
35 | void RunCheats();
36 | void RunCheat(const ARCode& arcode);
37 | private:
38 | melonDS::NDS& NDS;
39 | ARCodeFile* CodeFile; // AR code file - frontend is responsible for managing this
40 | };
41 |
42 | }
43 | #endif // ARENGINE_H
44 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/CLI.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2021-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef CLI_H
20 | #define CLI_H
21 |
22 | #include
23 | #include
24 |
25 | #include
26 |
27 | namespace CLI {
28 |
29 | struct CommandLineOptions
30 | {
31 | QStringList errorsToDisplay = {};
32 |
33 | std::optional dsRomPath;
34 | std::optional dsRomArchivePath;
35 | std::optional gbaRomPath;
36 | std::optional gbaRomArchivePath;
37 | bool fullscreen;
38 | bool boot;
39 | };
40 |
41 | extern CommandLineOptions* ManageArgs(QApplication& melon);
42 |
43 | }
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/src/ARMInterpreter.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef ARMINTERPRETER_H
20 | #define ARMINTERPRETER_H
21 |
22 | #include "types.h"
23 | #include "ARM.h"
24 |
25 | namespace melonDS
26 | {
27 | namespace ARMInterpreter
28 | {
29 |
30 | extern void (*ARMInstrTable[4096])(ARM* cpu);
31 | extern void (*THUMBInstrTable[1024])(ARM* cpu);
32 |
33 | void A_MSR_IMM(ARM* cpu);
34 | void A_MSR_REG(ARM* cpu);
35 | void A_MRS(ARM* cpu);
36 | void A_MCR(ARM* cpu);
37 | void A_MRC(ARM* cpu);
38 | void A_SVC(ARM* cpu);
39 |
40 | void T_SVC(ARM* cpu);
41 |
42 | void A_BLX_IMM(ARM* cpu); // I'm a special one look at me
43 |
44 | }
45 |
46 | }
47 | #endif // ARMINTERPRETER_H
48 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/LAN_PCap.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef LAN_PCAP_H
20 | #define LAN_PCAP_H
21 |
22 | #include "types.h"
23 |
24 | namespace LAN_PCap
25 | {
26 |
27 | using namespace melonDS;
28 | struct AdapterData
29 | {
30 | char DeviceName[128];
31 | char FriendlyName[128];
32 | char Description[128];
33 |
34 | u8 MAC[6];
35 | u8 IP_v4[4];
36 |
37 | void* Internal;
38 | };
39 |
40 |
41 | extern AdapterData* Adapters;
42 | extern int NumAdapters;
43 |
44 |
45 | bool Init(bool open_adapter);
46 | void DeInit();
47 |
48 | int SendPacket(u8* data, int len);
49 | int RecvPacket(u8* data);
50 |
51 | }
52 |
53 | #endif // LAN_PCAP_H
54 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/main.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef MAIN_H
20 | #define MAIN_H
21 |
22 | #include "glad/glad.h"
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 | #include "Window.h"
35 | #include "EmuThread.h"
36 | #include "FrontendUtil.h"
37 |
38 | class MelonApplication : public QApplication
39 | {
40 | Q_OBJECT
41 |
42 | public:
43 | MelonApplication(int &argc, char** argv);
44 | bool event(QEvent* event) override;
45 | };
46 |
47 | #endif // MAIN_H
48 |
--------------------------------------------------------------------------------
/src/MemConstants.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef MELONDS_MEMCONSTANTS_H
20 | #define MELONDS_MEMCONSTANTS_H
21 |
22 | #include "types.h"
23 |
24 | namespace melonDS
25 | {
26 | constexpr u32 MainRAMMaxSize = 0x1000000;
27 | constexpr u32 SharedWRAMSize = 0x8000;
28 | constexpr u32 ARM7WRAMSize = 0x10000;
29 | constexpr u32 NWRAMSize = 0x40000;
30 | constexpr u32 ARM9BIOSSize = 0x1000;
31 | constexpr u32 ARM7BIOSSize = 0x4000;
32 | constexpr u32 DSiBIOSSize = 0x10000;
33 | constexpr u32 ITCMPhysicalSize = 0x8000;
34 | constexpr u32 DTCMPhysicalSize = 0x4000;
35 | constexpr u32 ARM7BIOSCRC32 = 0x1280f0d5;
36 | constexpr u32 ARM9BIOSCRC32 = 0x2ab23573;
37 | }
38 |
39 | #endif // MELONDS_MEMCONSTANTS_H
--------------------------------------------------------------------------------
/src/dolphin/x64Reg.h:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Dolphin Emulator Project
2 | // Licensed under GPLv2+
3 | // Refer to the license_dolphin.txt file included.
4 |
5 | #pragma once
6 |
7 | namespace Gen
8 | {
9 | enum X64Reg
10 | {
11 | EAX = 0,
12 | EBX = 3,
13 | ECX = 1,
14 | EDX = 2,
15 | ESI = 6,
16 | EDI = 7,
17 | EBP = 5,
18 | ESP = 4,
19 |
20 | RAX = 0,
21 | RBX = 3,
22 | RCX = 1,
23 | RDX = 2,
24 | RSI = 6,
25 | RDI = 7,
26 | RBP = 5,
27 | RSP = 4,
28 | R8 = 8,
29 | R9 = 9,
30 | R10 = 10,
31 | R11 = 11,
32 | R12 = 12,
33 | R13 = 13,
34 | R14 = 14,
35 | R15 = 15,
36 |
37 | AL = 0,
38 | BL = 3,
39 | CL = 1,
40 | DL = 2,
41 | SIL = 6,
42 | DIL = 7,
43 | BPL = 5,
44 | SPL = 4,
45 | AH = 0x104,
46 | BH = 0x107,
47 | CH = 0x105,
48 | DH = 0x106,
49 |
50 | AX = 0,
51 | BX = 3,
52 | CX = 1,
53 | DX = 2,
54 | SI = 6,
55 | DI = 7,
56 | BP = 5,
57 | SP = 4,
58 |
59 | XMM0 = 0,
60 | XMM1,
61 | XMM2,
62 | XMM3,
63 | XMM4,
64 | XMM5,
65 | XMM6,
66 | XMM7,
67 | XMM8,
68 | XMM9,
69 | XMM10,
70 | XMM11,
71 | XMM12,
72 | XMM13,
73 | XMM14,
74 | XMM15,
75 |
76 | YMM0 = 0,
77 | YMM1,
78 | YMM2,
79 | YMM3,
80 | YMM4,
81 | YMM5,
82 | YMM6,
83 | YMM7,
84 | YMM8,
85 | YMM9,
86 | YMM10,
87 | YMM11,
88 | YMM12,
89 | YMM13,
90 | YMM14,
91 | YMM15,
92 |
93 | INVALID_REG = 0xFFFFFFFF
94 | };
95 |
96 | } // namespace Gen
97 |
--------------------------------------------------------------------------------
/src/teakra/src/ahbm.md:
--------------------------------------------------------------------------------
1 | # AHBM
2 |
3 | ## MMIO Layout
4 |
5 | ```
6 | Status register
7 | +-----------#---+---+---+---#---+---+---+---#---+---+---+---#---+---+---+---#
8 | |+0x00E0 | | | | | | | | | | | | | |RNE| | |
9 | +-----------#---+---+---+---#---+---+---+---#---+---+---+---#---+---+---+---#
10 | Applications wait for all bits to be 0 before connecting AHBM to DMA
11 | RNE: 1 when the burst queue is not empty
12 |
13 | Channel config (N = 0, 1, 2)
14 | +-----------#---+---+---+---#---+---+---+---#---+---+---+---#---+---+---+---#
15 | |+0x00E2+N*6| - | | | | | | - | TYPE | | BURST | R |
16 | +-----------#---+---+---+---#---+---+---+---#---+---+---+---#---+---+---+---#
17 | |+0x00E4+N*6| - | E | W | | | | | | | | |
18 | +-----------#---+---+---+---#---+---+---+---#---+---+---+---#---+---+---+---#
19 | |+0x00E6+N*6| - | D7| D6| D5| D4| D3| D2| D1| D0|
20 | +-----------#---+---+---+---#---+---+---+---#---+---+---+---#---+---+---+---#
21 | R: Applications set this to 1 if BURST is non-zero
22 | BURST: burst type
23 | - 0: x1
24 | - 1: x4
25 | - 2: x8
26 | - 3: ?
27 | TYPE: data type
28 | - 0: 8 bit
29 | - 1: 16 bit
30 | - 2: 32 bit
31 | - 3: ?
32 | W: Transfer direction
33 | - 0: read from external memory
34 | - 1: write to external memory
35 | E: Applications always set this.
36 | D0..D7: Connects to DMA channel 0..7 if set to one
37 | ```
38 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/LocalMP.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef LOCALMP_H
20 | #define LOCALMP_H
21 |
22 | #include "types.h"
23 |
24 | namespace LocalMP
25 | {
26 |
27 | using namespace melonDS;
28 | bool Init();
29 | void DeInit();
30 |
31 | void SetRecvTimeout(int timeout);
32 |
33 | void Begin();
34 | void End();
35 |
36 | int SendPacket(u8* data, int len, u64 timestamp);
37 | int RecvPacket(u8* data, u64* timestamp);
38 | int SendCmd(u8* data, int len, u64 timestamp);
39 | int SendReply(u8* data, int len, u64 timestamp, u16 aid);
40 | int SendAck(u8* data, int len, u64 timestamp);
41 | int RecvHostPacket(u8* data, u64* timestamp);
42 | u16 RecvReplies(u8* data, u64 timestamp, u16 aidmask);
43 |
44 | }
45 |
46 | #endif // LOCALMP_H
47 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/Input.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef INPUT_H
20 | #define INPUT_H
21 |
22 | #include
23 |
24 | #include "types.h"
25 |
26 | namespace Input
27 | {
28 |
29 | using namespace melonDS;
30 | extern int JoystickID;
31 | extern SDL_Joystick* Joystick;
32 |
33 | extern u32 InputMask;
34 |
35 | void Init();
36 |
37 | // set joystickID before calling openJoystick()
38 | void OpenJoystick();
39 | void CloseJoystick();
40 |
41 | void KeyPress(QKeyEvent* event);
42 | void KeyRelease(QKeyEvent* event);
43 |
44 | void Process();
45 |
46 | bool HotkeyDown(int id);
47 | bool HotkeyPressed(int id);
48 | bool HotkeyReleased(int id);
49 |
50 | bool IsRightModKey(QKeyEvent* event);
51 |
52 | }
53 |
54 | #endif // INPUT_H
55 |
--------------------------------------------------------------------------------
/src/teakra/src/test_verifier/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include(CreateDirectoryGroups)
2 |
3 | add_executable(test_verifier
4 | main.cpp
5 | )
6 | create_target_directory_groups(test_verifier)
7 | target_link_libraries(test_verifier PRIVATE teakra)
8 | target_include_directories(test_verifier PRIVATE .)
9 | target_compile_options(test_verifier PRIVATE ${TEAKRA_CXX_FLAGS})
10 |
11 |
12 | # Test related stuff
13 | set(ASSET_SHA256SUM "baffcd4f805a7480d969401792443a34aa39f813b4f0ae49c6365f1d1f3ce120")
14 | if(TEAKRA_RUN_TESTS)
15 | message(STATUS "Will run Teakra accuracy tests")
16 | # download fixtures if there is none
17 | if(NOT EXISTS "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result")
18 | message(STATUS "Downloading required samples...")
19 | file(DOWNLOAD
20 | "https://liushuyu.b-cdn.net/teaklite2_tests_result_20181208"
21 | "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result"
22 | EXPECTED_HASH SHA256=${ASSET_SHA256SUM}
23 | SHOW_PROGRESS
24 | )
25 | else()
26 | # check if provided fixtures are good
27 | file(SHA256 "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result" ASSET_CHECKSUM)
28 | if(ASSET_SHA256SUM STREQUAL ASSET_CHECKSUM)
29 | message(STATUS "Unit test sample looks good.")
30 | else()
31 | message(FATAL_ERROR "Unit test sample broken. Please remove the file and re-run CMake.")
32 | endif()
33 | endif()
34 |
35 | add_test(NAME tests COMMAND test_verifier "${TEAKRA_TEST_ASSETS_DIR}/teaklite2_tests_result")
36 | endif(TEAKRA_RUN_TESTS)
37 |
--------------------------------------------------------------------------------
/src/teakra/src/step2_test_generator/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "../test.h"
4 |
5 | int main(int argc, char** argv) {
6 | if (argc < 2) {
7 | std::fprintf(stderr, "A file path argument must be specified. Exiting...\n");
8 | return -1;
9 | }
10 |
11 | std::unique_ptr f{std::fopen(argv[1], "wb"), std::fclose};
12 | if (!f) {
13 | std::fprintf(stderr, "Unable to open file %s. Exiting...\n", argv[1]);
14 | return -2;
15 | }
16 |
17 | TestCase test_case{};
18 | u16 r0base = 0x4839;
19 | test_case.opcode = 0xDFE9; // modr r0+arps0
20 | test_case.expand = 0;
21 | test_case.before.mod2 = 1; // enable mod for r0;
22 |
23 | for (u16 legacy = 0; legacy < 2; ++legacy) {
24 | test_case.before.mod1 = legacy << 13;
25 | for (u16 step = 4; step < 8; ++step) {
26 | test_case.before.arp[0] = step;
27 | for (u16 mod = 0; mod < 0x200; ++mod) {
28 | test_case.before.cfgi = mod << 7;
29 | for (u16 r = 0; r < 0x20; ++r) {
30 | test_case.before.r[0] = r + r0base;
31 | if (std::fwrite(&test_case, sizeof(test_case), 1, f.get()) == 0) {
32 | std::fprintf(stderr, "Unable to completely write test case. Exiting...\n");
33 | return -3;
34 | }
35 | }
36 | }
37 | }
38 | }
39 |
40 | return 0;
41 | }
42 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/ArchiveUtil.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef ARCHIVEUTIL_H
20 | #define ARCHIVEUTIL_H
21 |
22 | #include
23 |
24 | #include
25 | #include
26 |
27 | #include
28 | #include
29 |
30 | #include
31 | #include
32 |
33 | #include "types.h"
34 |
35 | namespace Archive
36 | {
37 |
38 | using namespace melonDS;
39 | QVector ListArchive(QString path);
40 | s32 ExtractFileFromArchive(QString path, QString wantedFile, std::unique_ptr& filedata, u32* filesize);
41 | //QVector ExtractFileFromArchive(QString path, QString wantedFile, QByteArray *romBuffer);
42 | //u32 ExtractFileFromArchive(const char* path, const char* wantedFile, u8 **romdata);
43 |
44 | }
45 |
46 | #endif // ARCHIVEUTIL_H
47 |
--------------------------------------------------------------------------------
/src/DSi_SPI_TSC.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef DSI_SPI_TSC
20 | #define DSI_SPI_TSC
21 |
22 | #include "types.h"
23 | #include "Savestate.h"
24 | #include "SPI.h"
25 |
26 | namespace melonDS
27 | {
28 | class DSi;
29 | class DSi_TSC : public TSC
30 | {
31 | public:
32 | DSi_TSC(melonDS::DSi& dsi);
33 | ~DSi_TSC() override;
34 |
35 | void Reset() override;
36 |
37 | void DoSavestate(Savestate* file) override;
38 |
39 | // 00=DS-mode 01=normal
40 | void SetMode(u8 mode);
41 |
42 | void SetTouchCoords(u16 x, u16 y) override;
43 | void MicInputFrame(const s16* data, int samples) override;
44 |
45 | void Write(u8 val) override;
46 | void Release() override;
47 |
48 | private:
49 | u8 Index;
50 | u8 Bank;
51 |
52 | u8 Bank3Regs[0x80];
53 | u8 TSCMode;
54 | };
55 |
56 | }
57 | #endif // DSI_SPI_TSC
58 |
--------------------------------------------------------------------------------
/src/ARCodeFile.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef ARCODEFILE_H
20 | #define ARCODEFILE_H
21 |
22 | #include
23 | #include
24 | #include
25 | #include "types.h"
26 |
27 | namespace melonDS
28 | {
29 | struct ARCode
30 | {
31 | std::string Name;
32 | bool Enabled;
33 | std::vector Code;
34 | };
35 |
36 | typedef std::list ARCodeList;
37 |
38 | struct ARCodeCat
39 | {
40 | std::string Name;
41 | ARCodeList Codes;
42 | };
43 |
44 | typedef std::list ARCodeCatList;
45 |
46 |
47 | class ARCodeFile
48 | {
49 | public:
50 | ARCodeFile(const std::string& filename);
51 | ~ARCodeFile();
52 |
53 | bool Error;
54 |
55 | bool Load();
56 | bool Save();
57 |
58 | ARCodeCatList Categories;
59 |
60 | private:
61 | std::string Filename;
62 | };
63 |
64 | }
65 | #endif // ARCODEFILE_H
66 |
--------------------------------------------------------------------------------
/src/teakra/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include(CreateDirectoryGroups)
2 |
3 | add_library(teakra
4 | ../include/teakra/disassembler.h
5 | ../include/teakra/teakra.h
6 | ahbm.cpp
7 | ahbm.h
8 | apbp.cpp
9 | apbp.h
10 | bit.h
11 | btdmp.cpp
12 | btdmp.h
13 | common_types.h
14 | crash.h
15 | decoder.h
16 | disassembler.cpp
17 | dma.cpp
18 | dma.h
19 | timer.cpp
20 | timer.h
21 | icu.h
22 | interpreter.h
23 | matcher.h
24 | memory_interface.cpp
25 | memory_interface.h
26 | mmio.cpp
27 | mmio.h
28 | operand.h
29 | parser.cpp
30 | processor.cpp
31 | processor.h
32 | register.h
33 | shared_memory.h
34 | teakra.cpp
35 | test.h
36 | test_generator.cpp
37 | test_generator.h
38 | )
39 |
40 | create_target_directory_groups(teakra)
41 |
42 | target_link_libraries(teakra PRIVATE Threads::Threads)
43 | target_include_directories(teakra
44 | PUBLIC ../include
45 | PRIVATE .)
46 | target_compile_options(teakra PRIVATE ${TEAKRA_CXX_FLAGS})
47 |
48 | add_library(teakra_c
49 | ../include/teakra/disassembler_c.h
50 | ../include/teakra/teakra_c.h
51 | disassembler_c.cpp
52 | teakra_c.cpp
53 | )
54 | target_link_libraries(teakra_c PRIVATE teakra)
55 |
56 | if (TEAKRA_BUILD_TOOLS)
57 | add_subdirectory(coff_reader)
58 | add_subdirectory(dsp1_reader)
59 | add_subdirectory(test_generator)
60 | add_subdirectory(test_verifier)
61 | add_subdirectory(mod_test_generator)
62 | add_subdirectory(step2_test_generator)
63 | add_subdirectory(makedsp1)
64 | endif()
65 |
--------------------------------------------------------------------------------
/src/Utils.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef MELONDS_UTILS_H
20 | #define MELONDS_UTILS_H
21 |
22 | #include
23 | #include "types.h"
24 | #include
25 |
26 | namespace melonDS
27 | {
28 | /// Ensures that the given array is a power of 2 in length.
29 | ///
30 | /// @return If \c len is a power of 2, returns \c data and \c len unchanged
31 | /// without copying anything.
32 | /// If \c data is \c nullptr, returns {nullptr, 0}.
33 | /// Otherwise, return a copy of \c data with zero-padding to the next power of 2.
34 | /// @post \c data is \c nullptr, even if it doesn't need to be copied.
35 | std::pair, u32> PadToPowerOf2(std::unique_ptr&& data, u32 len) noexcept;
36 |
37 | std::pair, u32> PadToPowerOf2(const u8* data, u32 len) noexcept;
38 |
39 | std::unique_ptr CopyToUnique(const u8* data, u32 len) noexcept;
40 |
41 | }
42 |
43 | #endif // MELONDS_UTILS_H
44 |
--------------------------------------------------------------------------------
/src/debug/hexutil.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef HEXUTIL_GDB_H_
3 | #define HEXUTIL_GDB_H_
4 |
5 | #ifdef __cplusplus
6 | extern "C"
7 | {
8 | #endif
9 |
10 | #include
11 |
12 | namespace melonDS
13 | {
14 | inline static uint8_t hex2nyb(uint8_t v)
15 | {
16 | if (v >= '0' && v <= '9') return v - '0';
17 | else if (v >= 'A' && v <= 'F') return v - 'A' + 0xa;
18 | else if (v >= 'a' && v <= 'f') return v - 'a' + 0xa;
19 | else
20 | {
21 | __builtin_trap();
22 | return 0xcc;
23 | }
24 | }
25 | inline static uint8_t nyb2hex(uint8_t v)
26 | {
27 | v &= 0xf;
28 | if (v >= 0xa) return v - 0xa + 'a';
29 | else return v - 0x0 + '0';
30 | }
31 |
32 | inline static void hexfmt8(uint8_t* dst, uint8_t v)
33 | {
34 | dst[0] = nyb2hex(v>>4);
35 | dst[1] = nyb2hex(v>>0);
36 | }
37 | inline static uint8_t unhex8(const uint8_t* src)
38 | {
39 | return (hex2nyb(src[0]) << 4) | hex2nyb(src[1]);
40 | }
41 |
42 | inline static void hexfmt16(uint8_t* dst, uint16_t v)
43 | {
44 | dst[0] = nyb2hex(v>> 4);
45 | dst[1] = nyb2hex(v>> 0);
46 | dst[2] = nyb2hex(v>>12);
47 | dst[3] = nyb2hex(v>> 8);
48 | }
49 | inline static uint16_t unhex16(const uint8_t* src)
50 | {
51 | return unhex8(&src[0*2]) | ((uint16_t)unhex8(&src[1*2]) << 8);
52 | }
53 |
54 | inline static void hexfmt32(uint8_t* dst, uint32_t v)
55 | {
56 | for (size_t i = 0; i < 4; ++i, v >>= 8)
57 | {
58 | dst[2*i+0] = nyb2hex(v>>4);
59 | dst[2*i+1] = nyb2hex(v>>0);
60 | }
61 | }
62 | inline static uint32_t unhex32(const uint8_t* src)
63 | {
64 | uint32_t v = 0;
65 | for (size_t i = 0; i < 4; ++i)
66 | {
67 | v |= (uint32_t)unhex8(&src[i*2]) << (i*8);
68 | }
69 | return v;
70 | }
71 |
72 | #ifdef __cplusplus
73 | }
74 | #endif
75 |
76 | }
77 | #endif
78 |
79 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/main_shaders.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef MAIN_SHADERS_H
20 | #define MAIN_SHADERS_H
21 |
22 | const char* kScreenVS = R"(#version 140
23 |
24 | uniform vec2 uScreenSize;
25 | uniform mat2x3 uTransform;
26 |
27 | in vec2 vPosition;
28 | in vec2 vTexcoord;
29 |
30 | smooth out vec2 fTexcoord;
31 |
32 | void main()
33 | {
34 | vec4 fpos;
35 |
36 | fpos.xy = vec3(vPosition, 1.0) * uTransform;
37 |
38 | fpos.xy = ((fpos.xy * 2.0) / uScreenSize) - 1.0;
39 | fpos.y *= -1;
40 | fpos.z = 0.0;
41 | fpos.w = 1.0;
42 |
43 | gl_Position = fpos;
44 | fTexcoord = vTexcoord;
45 | }
46 | )";
47 |
48 | const char* kScreenFS = R"(#version 140
49 |
50 | uniform sampler2D ScreenTex;
51 |
52 | smooth in vec2 fTexcoord;
53 |
54 | out vec4 oColor;
55 |
56 | void main()
57 | {
58 | vec4 pixel = texture(ScreenTex, fTexcoord);
59 |
60 | oColor = vec4(pixel.bgr, 1.0);
61 | }
62 | )";
63 |
64 | #endif // MAIN_SHADERS_H
65 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/gl/context_agl.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "context.h"
3 | #include "loader.h"
4 |
5 | #if defined(__APPLE__) && defined(__OBJC__)
6 | #import
7 | #else
8 | struct NSOpenGLContext;
9 | struct NSOpenGLPixelFormat;
10 | struct NSView;
11 | #define __bridge
12 | #endif
13 |
14 | namespace GL {
15 |
16 | using namespace melonDS;
17 | class ContextAGL final : public Context
18 | {
19 | public:
20 | ContextAGL(const WindowInfo& wi);
21 | ~ContextAGL() override;
22 |
23 | static std::unique_ptr Create(const WindowInfo& wi, const Version* versions_to_try,
24 | size_t num_versions_to_try);
25 |
26 | void* GetProcAddress(const char* name) override;
27 | bool ChangeSurface(const WindowInfo& new_wi) override;
28 | void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
29 | bool SwapBuffers() override;
30 | bool MakeCurrent() override;
31 | bool DoneCurrent() override;
32 | bool SetSwapInterval(s32 interval) override;
33 | std::unique_ptr CreateSharedContext(const WindowInfo& wi) override;
34 |
35 | private:
36 | ALWAYS_INLINE NSView* GetView() const { return static_cast((__bridge NSView*)m_wi.window_handle); }
37 |
38 | bool Initialize(const Version* versions_to_try, size_t num_versions_to_try);
39 | bool CreateContext(NSOpenGLContext* share_context, int profile, bool make_current);
40 | void BindContextToView();
41 |
42 | // returns true if dimensions have changed
43 | bool UpdateDimensions();
44 |
45 | NSOpenGLContext* m_context = nullptr;
46 | NSOpenGLPixelFormat* m_pixel_format = nullptr;
47 | void* m_opengl_module_handle = nullptr;
48 | };
49 |
50 | } // namespace GL
51 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/gl/context_glx.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "context.h"
3 | #include "../../glad/glad_glx.h"
4 | #include "x11_window.h"
5 |
6 | namespace GL {
7 |
8 | class ContextGLX final : public Context
9 | {
10 | public:
11 | ContextGLX(const WindowInfo& wi);
12 | ~ContextGLX() override;
13 |
14 | static std::unique_ptr Create(const WindowInfo& wi, const Version* versions_to_try,
15 | size_t num_versions_to_try);
16 |
17 | void* GetProcAddress(const char* name) override;
18 | bool ChangeSurface(const WindowInfo& new_wi) override;
19 | void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
20 | bool SwapBuffers() override;
21 | bool MakeCurrent() override;
22 | bool DoneCurrent() override;
23 | bool SetSwapInterval(s32 interval) override;
24 | std::unique_ptr CreateSharedContext(const WindowInfo& wi) override;
25 |
26 | private:
27 | ALWAYS_INLINE Display* GetDisplay() const { return static_cast(m_wi.display_connection); }
28 | ALWAYS_INLINE GLXDrawable GetDrawable() const { return static_cast(m_window.GetWindow()); }
29 |
30 | bool Initialize(const Version* versions_to_try, size_t num_versions_to_try);
31 | bool CreateWindow(int screen);
32 | bool CreateAnyContext(GLXContext share_context, bool make_current);
33 | bool CreateVersionContext(const Version& version, GLXContext share_context, bool make_current);
34 |
35 | GLXContext m_context = nullptr;
36 | GLXFBConfig m_fb_config = {};
37 | XVisualInfo* m_vi = nullptr;
38 | X11Window m_window;
39 |
40 | // GLAD releases its reference to libGL.so, so we need to maintain our own.
41 | void* m_libGL_handle = nullptr;
42 | };
43 |
44 | } // namespace GL
45 |
--------------------------------------------------------------------------------
/src/WifiAP.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef WIFIAP_H
20 | #define WIFIAP_H
21 |
22 | #include "types.h"
23 |
24 | namespace melonDS
25 | {
26 | class Wifi;
27 |
28 | class WifiAP
29 | {
30 | public:
31 | WifiAP(Wifi* client);
32 | ~WifiAP();
33 | void Reset();
34 |
35 | static const char* APName;
36 | static const u8 APMac[6];
37 |
38 | void MSTimer();
39 |
40 | // packet format: 12-byte TX header + original 802.11 frame
41 | int SendPacket(const u8* data, int len);
42 | int RecvPacket(u8* data);
43 |
44 | private:
45 | Wifi* Client;
46 |
47 | u64 USCounter;
48 |
49 | u16 SeqNo;
50 |
51 | bool BeaconDue;
52 |
53 | u8 PacketBuffer[2048];
54 | int PacketLen;
55 | int RXNum;
56 |
57 | u8 LANBuffer[2048];
58 |
59 | // this is a lazy AP, we only keep track of one client
60 | // 0=disconnected 1=authenticated 2=associated
61 | int ClientStatus;
62 |
63 | int HandleManagementFrame(const u8* data, int len);
64 | };
65 |
66 | }
67 | #endif
68 |
--------------------------------------------------------------------------------
/.github/workflows/build-ubuntu-aarch64.yml:
--------------------------------------------------------------------------------
1 | name: Ubuntu
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 | branches:
9 | - master
10 |
11 | env:
12 | BUILD_TYPE: Release
13 |
14 | jobs:
15 | build:
16 | name: aarch64
17 | runs-on: ubuntu-20.04
18 | container: ubuntu:20.04
19 |
20 | steps:
21 | - name: Prepare system
22 | shell: bash
23 | run: |
24 | apt update
25 | apt -y full-upgrade
26 | apt -y install git
27 | - name: Check out source
28 | uses: actions/checkout@v1
29 | - name: Install dependencies
30 | shell: bash
31 | run: |
32 | dpkg --add-architecture arm64
33 | sh -c "sed \"s|^deb \([a-z\.:/]*\) \([a-z\-]*\) \(.*\)$|deb [arch=amd64] \1 \2 \3\ndeb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports \2 \3|\" /etc/apt/sources.list > /etc/apt/sources.list.new"
34 | rm /etc/apt/sources.list
35 | mv /etc/apt/sources.list{.new,}
36 | apt update
37 | DEBIAN_FRONTEND=noninteractive apt install -y {gcc-10,g++-10,pkg-config}-aarch64-linux-gnu {libsdl2,qtbase5,qtbase5-private,qtmultimedia5,libslirp,libarchive,libzstd}-dev:arm64 zstd:arm64 cmake extra-cmake-modules dpkg-dev
38 | - name: Configure
39 | shell: bash
40 | run: |
41 | CC=aarch64-linux-gnu-gcc-10 CXX=aarch64-linux-gnu-g++-10 cmake -DPKG_CONFIG_EXECUTABLE=/usr/bin/aarch64-linux-gnu-pkg-config $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -B build
42 | - name: Make
43 | shell: bash
44 | run: |
45 | cmake --build build -j$(nproc --all)
46 | mkdir dist
47 | cp build/melonDS dist
48 | - uses: actions/upload-artifact@v1
49 | with:
50 | name: melonDS-ubuntu-aarch64
51 | path: dist
52 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/OSD_shaders.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef OSD_SHADERS_H
20 | #define OSD_SHADERS_H
21 |
22 | const char* kScreenVS_OSD = R"(#version 140
23 |
24 | uniform vec2 uScreenSize;
25 |
26 | uniform ivec2 uOSDPos;
27 | uniform ivec2 uOSDSize;
28 | uniform float uScaleFactor;
29 |
30 | in vec2 vPosition;
31 |
32 | smooth out vec2 fTexcoord;
33 |
34 | void main()
35 | {
36 | vec4 fpos;
37 |
38 | vec2 osdpos = (vPosition * vec2(uOSDSize * uScaleFactor));
39 | fTexcoord = osdpos;
40 | osdpos += uOSDPos;
41 |
42 | fpos.xy = ((osdpos * 2.0) / uScreenSize * uScaleFactor) - 1.0;
43 | fpos.y *= -1;
44 | fpos.z = 0.0;
45 | fpos.w = 1.0;
46 |
47 | gl_Position = fpos;
48 | }
49 | )";
50 |
51 | const char* kScreenFS_OSD = R"(#version 140
52 |
53 | uniform sampler2D OSDTex;
54 |
55 | smooth in vec2 fTexcoord;
56 |
57 | out vec4 oColor;
58 |
59 | void main()
60 | {
61 | vec4 pixel = texelFetch(OSDTex, ivec2(fTexcoord), 0);
62 | oColor = pixel.bgra;
63 | }
64 | )";
65 |
66 | #endif // OSD_SHADERS_H
67 |
--------------------------------------------------------------------------------
/src/FreeBIOS.h:
--------------------------------------------------------------------------------
1 | /* Custom NDS ARM7/ARM9 BIOS replacement
2 | Copyright (c) 2013, Gilead Kutnick
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1) Redistributions of source code must retain the above copyright notice,
9 | this list of conditions and the following disclaimer.
10 | 2) Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 | POSSIBILITY OF SUCH DAMAGE.
25 | */
26 |
27 |
28 | #ifndef FREEBIOS_H
29 | #define FREEBIOS_H
30 |
31 | #include
32 | #include "MemConstants.h"
33 |
34 | namespace melonDS
35 | {
36 | extern std::array bios_arm7_bin;
37 | extern std::array bios_arm9_bin;
38 | }
39 |
40 | #endif // FREEBIOS_H
41 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/gl/context_egl.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "context.h"
3 | #include "../../glad/glad_egl.h"
4 |
5 | namespace GL {
6 |
7 | class ContextEGL : public Context
8 | {
9 | public:
10 | ContextEGL(const WindowInfo& wi);
11 | ~ContextEGL() override;
12 |
13 | static std::unique_ptr Create(const WindowInfo& wi, const Version* versions_to_try,
14 | size_t num_versions_to_try);
15 |
16 | void* GetProcAddress(const char* name) override;
17 | virtual bool ChangeSurface(const WindowInfo& new_wi) override;
18 | virtual void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
19 | bool SwapBuffers() override;
20 | bool MakeCurrent() override;
21 | bool DoneCurrent() override;
22 | bool SetSwapInterval(s32 interval) override;
23 | virtual std::unique_ptr CreateSharedContext(const WindowInfo& wi) override;
24 |
25 | protected:
26 | virtual bool SetDisplay();
27 | virtual EGLNativeWindowType GetNativeWindow(EGLConfig config);
28 |
29 | bool Initialize(const Version* versions_to_try, size_t num_versions_to_try);
30 | bool CreateDisplay();
31 | bool CreateContext(const Version& version, EGLContext share_context);
32 | bool CreateContextAndSurface(const Version& version, EGLContext share_context, bool make_current);
33 | bool CreateSurface();
34 | bool CreatePBufferSurface();
35 | bool CheckConfigSurfaceFormat(EGLConfig config, WindowInfo::SurfaceFormat format) const;
36 | void DestroyContext();
37 | void DestroySurface();
38 |
39 | EGLDisplay m_display = EGL_NO_DISPLAY;
40 | EGLSurface m_surface = EGL_NO_SURFACE;
41 | EGLContext m_context = EGL_NO_CONTEXT;
42 |
43 | EGLConfig m_config = {};
44 |
45 | bool m_supports_surfaceless = false;
46 | };
47 |
48 | } // namespace GL
49 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/gl/context_wgl.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "../windows_headers.h"
3 |
4 | #include "context.h"
5 | #include "../../glad/glad_wgl.h"
6 | #include "loader.h"
7 | #include
8 |
9 | namespace GL {
10 |
11 | class ContextWGL final : public Context
12 | {
13 | public:
14 | ContextWGL(const WindowInfo& wi);
15 | ~ContextWGL() override;
16 |
17 | static std::unique_ptr Create(const WindowInfo& wi, const Version* versions_to_try,
18 | size_t num_versions_to_try);
19 |
20 | void* GetProcAddress(const char* name) override;
21 | bool ChangeSurface(const WindowInfo& new_wi) override;
22 | void ResizeSurface(u32 new_surface_width = 0, u32 new_surface_height = 0) override;
23 | bool SwapBuffers() override;
24 | bool MakeCurrent() override;
25 | bool DoneCurrent() override;
26 | bool SetSwapInterval(s32 interval) override;
27 | std::unique_ptr CreateSharedContext(const WindowInfo& wi) override;
28 |
29 | private:
30 | ALWAYS_INLINE HWND GetHWND() const { return static_cast(m_wi.window_handle); }
31 |
32 | HDC GetDCAndSetPixelFormat(HWND hwnd);
33 |
34 | bool Initialize(const Version* versions_to_try, size_t num_versions_to_try);
35 | bool InitializeDC();
36 | void ReleaseDC();
37 | bool CreatePBuffer();
38 | bool CreateAnyContext(HGLRC share_context, bool make_current);
39 | bool CreateVersionContext(const Version& version, HGLRC share_context, bool make_current);
40 |
41 | HDC m_dc = {};
42 | HGLRC m_rc = {};
43 |
44 | // Can't change pixel format once it's set for a RC.
45 | std::optional m_pixel_format;
46 |
47 | // Dummy window for creating a PBuffer off when we're surfaceless.
48 | HWND m_dummy_window = {};
49 | HDC m_dummy_dc = {};
50 | HPBUFFERARB m_pbuffer = {};
51 | };
52 |
53 | } // namespace GL
--------------------------------------------------------------------------------
/src/teakra/src/README.md:
--------------------------------------------------------------------------------
1 | ## Content
2 |
3 | - main library
4 | - [processor related](processor_general.md)
5 | - operand: defines basic operand types used in instructions
6 | - matcher and decoder: decodes binary instructions into opcodes and operands
7 | - disassembler: translate binary instructions to (pseudo-)assembly.
8 | - parser: translate (pseudo-)assembly to binary instructions
9 | - interpreter: executes instructions
10 | - [register](register.md): defines all register states in the processor
11 | - processor: wrapper of interpreter and register as a processor emulator
12 | - test_generator: generates test cases information for the instruction set
13 | - peripherals
14 | - [AHBM](ahbm.md): interface for accessing external memory (DSi/3DS main memory)
15 | - [APBP](apbp.md): interface for communication with CPU (ARM in DSi/3DS)
16 | - [BTDMP](btdmp.md): audio input/output ports
17 | - [DMA](dma.md): engine for transferring large data between DSP memory and external memory
18 | - [ICU](icu.md): interrupt controller unit
19 | - [timer](timer.md)
20 | - [MMIO](mmio.md): I/O ports for all peripherals
21 | - shared_memory: the DSP working memory
22 | - [memory_interface](miu.md): the memory space exposed to the processor and related control
23 | - Tools
24 | - coff_reader: disassembles and parses symbols COFF files leaked by some DSi applications
25 | - dsp1_reader: disassembles DSP1 files, DSP binary for 3DS applications
26 | - makedsp1: assembles DSP1 files
27 | - test_generator: generate random test cases for processor instructions.
28 | - mod_test_generator & step2_test_generator: similar to test_generator, but dedicated for mod/step2 related instructions
29 | - test_verifier: verify test cases on the interpreter against the result generated from 3DS
30 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/MPSettingsDialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef MPSETTINGSDIALOG_H
20 | #define MPSETTINGSDIALOG_H
21 |
22 | #include
23 | #include
24 |
25 | namespace Ui { class MPSettingsDialog; }
26 | class MPSettingsDialog;
27 |
28 | class MPSettingsDialog : public QDialog
29 | {
30 | Q_OBJECT
31 |
32 | public:
33 | explicit MPSettingsDialog(QWidget* parent);
34 | ~MPSettingsDialog();
35 |
36 | static MPSettingsDialog* currentDlg;
37 | static MPSettingsDialog* openDlg(QWidget* parent)
38 | {
39 | if (currentDlg)
40 | {
41 | currentDlg->activateWindow();
42 | return currentDlg;
43 | }
44 |
45 | currentDlg = new MPSettingsDialog(parent);
46 | currentDlg->open();
47 | return currentDlg;
48 | }
49 | static void closeDlg()
50 | {
51 | currentDlg = nullptr;
52 | }
53 |
54 | private slots:
55 | void done(int r);
56 |
57 | //
58 |
59 | private:
60 | Ui::MPSettingsDialog* ui;
61 |
62 | QButtonGroup* grpAudioMode;
63 | };
64 |
65 | #endif // MPSETTINGSDIALOG_H
66 |
--------------------------------------------------------------------------------
/src/dolphin/CPUDetect.h:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Dolphin Emulator Project
2 | // Licensed under GPLv2+
3 | // Refer to the license_dolphin.txt file included.
4 |
5 | // Detect the CPU, so we'll know which optimizations to use
6 | #pragma once
7 |
8 | #include
9 |
10 | enum class CPUVendor
11 | {
12 | Intel,
13 | AMD,
14 | ARM,
15 | Other,
16 | };
17 |
18 | struct CPUInfo
19 | {
20 | CPUVendor vendor = CPUVendor::Intel;
21 |
22 | char cpu_string[0x41] = {};
23 | char brand_string[0x21] = {};
24 | bool OS64bit = false;
25 | bool CPU64bit = false;
26 | bool Mode64bit = false;
27 |
28 | bool HTT = false;
29 | int num_cores = 0;
30 | int logical_cpu_count = 0;
31 |
32 | bool bSSE = false;
33 | bool bSSE2 = false;
34 | bool bSSE3 = false;
35 | bool bSSSE3 = false;
36 | bool bPOPCNT = false;
37 | bool bSSE4_1 = false;
38 | bool bSSE4_2 = false;
39 | bool bLZCNT = false;
40 | bool bSSE4A = false;
41 | bool bAVX = false;
42 | bool bAVX2 = false;
43 | bool bBMI1 = false;
44 | bool bBMI2 = false;
45 | bool bFMA = false;
46 | bool bFMA4 = false;
47 | bool bAES = false;
48 | // FXSAVE/FXRSTOR
49 | bool bFXSR = false;
50 | bool bMOVBE = false;
51 | // This flag indicates that the hardware supports some mode
52 | // in which denormal inputs _and_ outputs are automatically set to (signed) zero.
53 | bool bFlushToZero = false;
54 | bool bLAHFSAHF64 = false;
55 | bool bLongMode = false;
56 | bool bAtom = false;
57 |
58 | // ARMv8 specific
59 | bool bFP = false;
60 | bool bASIMD = false;
61 | bool bCRC32 = false;
62 | bool bSHA1 = false;
63 | bool bSHA2 = false;
64 |
65 | // Call Detect()
66 | explicit CPUInfo();
67 |
68 | // Turn the CPU info into a string we can show
69 | std::string Summarize();
70 |
71 | private:
72 | // Detects the various CPU features
73 | void Detect();
74 | };
75 |
76 | extern CPUInfo cpu_info;
77 |
--------------------------------------------------------------------------------
/src/dolphin/CommonFuncs.h:
--------------------------------------------------------------------------------
1 | // Copyright 2009 Dolphin Emulator Project
2 | // Licensed under GPLv2+
3 | // Refer to the license_dolphin.txt file included.
4 |
5 | #pragma once
6 |
7 | #include
8 | #include
9 | #include "../types.h"
10 |
11 | // Will fail to compile on a non-array:
12 | template
13 | constexpr size_t ArraySize(T (&arr)[N])
14 | {
15 | return N;
16 | }
17 |
18 | #ifndef _WIN32
19 |
20 | // go to debugger mode
21 | #define Crash() \
22 | { \
23 | __builtin_trap(); \
24 | }
25 |
26 | #else // WIN32
27 | // Function Cross-Compatibility
28 | #define strcasecmp _stricmp
29 | #define strncasecmp _strnicmp
30 | #define unlink _unlink
31 | #define vscprintf _vscprintf
32 |
33 | // 64 bit offsets for Windows
34 | #define fseeko _fseeki64
35 | #define ftello _ftelli64
36 | #define atoll _atoi64
37 | #define stat _stat64
38 | #define fstat _fstat64
39 | #define fileno _fileno
40 |
41 | extern "C" {
42 | __declspec(dllimport) void __stdcall DebugBreak(void);
43 | }
44 | #define Crash() \
45 | { \
46 | DebugBreak(); \
47 | }
48 | #endif // WIN32 ndef
49 |
50 | // Wrapper function to get last strerror(errno) string.
51 | // This function might change the error code.
52 | std::string LastStrerrorString();
53 |
54 | #ifdef _WIN32
55 | // Wrapper function to get GetLastError() string.
56 | // This function might change the error code.
57 | std::string GetLastErrorString();
58 | #endif
59 |
--------------------------------------------------------------------------------
/freebios/drastic_bios_readme.txt:
--------------------------------------------------------------------------------
1 | Custom NDS ARM7/ARM9 BIOS replacement
2 | Copyright (c) 2013, Gilead Kutnick
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1) Redistributions of source code must retain the above copyright notice,
9 | this list of conditions and the following disclaimer.
10 | 2) Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 | POSSIBILITY OF SUCH DAMAGE.
25 |
26 | -- Info --
27 |
28 | This archive contains source code and assembly for a custom BIOS replacement
29 | for the Nintendo DS system. This code is in no way affiliated with Nintendo
30 | and is not derived from Nintendo's BIOS implementation but has been implemented
31 | using publically available documentation.
32 |
33 | It can be assembled using the included Makefile along with a proper ARM gcc
34 | toolchain. Change the first four lines to point to the proper toolchain of your
35 | choice.
36 |
37 |
--------------------------------------------------------------------------------
/src/CRC32.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #include "CRC32.h"
20 |
21 | // http://www.codeproject.com/KB/recipes/crc32_large.aspx
22 |
23 | namespace melonDS
24 | {
25 | constexpr u32 _reflect(u32 refl, char ch)
26 | {
27 | u32 value = 0;
28 |
29 | for(int i = 1; i < (ch + 1); i++)
30 | {
31 | if (refl & 1)
32 | value |= 1 << (ch - i);
33 | refl >>= 1;
34 | }
35 |
36 | return value;
37 | }
38 |
39 | constexpr auto GetCRC32Table()
40 | {
41 | std::array Crc32Table { 0 };
42 | u32 polynomial = 0x04C11DB7;
43 |
44 | for (int i = 0; i < 0x100; i++)
45 | {
46 | Crc32Table[i] = _reflect(i, 8) << 24;
47 |
48 | for (int j = 0; j < 8; j++)
49 | Crc32Table[i] = (Crc32Table[i] << 1) ^ (Crc32Table[i] & (1 << 31) ? polynomial : 0);
50 |
51 | Crc32Table[i] = _reflect(Crc32Table[i], 32);
52 | }
53 | return Crc32Table;
54 | }
55 |
56 | u32 CRC32(const u8 *data, int len, u32 start)
57 | {
58 | auto Crc32Table = GetCRC32Table();
59 |
60 | u32 crc = start ^ 0xFFFFFFFF;
61 |
62 | while (len--)
63 | crc = (crc >> 8) ^ Crc32Table[(crc & 0xFF) ^ *data++];
64 |
65 | return (crc ^ 0xFFFFFFFF);
66 | }
67 |
68 | }
--------------------------------------------------------------------------------
/src/JitBlock.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef MELONDS_JITBLOCK_H
20 | #define MELONDS_JITBLOCK_H
21 |
22 | #include "types.h"
23 | #include "TinyVector.h"
24 |
25 | namespace melonDS
26 | {
27 | typedef void (*JitBlockEntry)();
28 |
29 | class JitBlock
30 | {
31 | public:
32 | JitBlock(u32 num, u32 literalHash, u32 numAddresses, u32 numLiterals)
33 | {
34 | Num = num;
35 | NumAddresses = numAddresses;
36 | NumLiterals = numLiterals;
37 | Data.SetLength(numAddresses * 2 + numLiterals);
38 | }
39 |
40 | u32 StartAddr;
41 | u32 StartAddrLocal;
42 | u32 InstrHash, LiteralHash;
43 | u8 Num;
44 | u16 NumAddresses;
45 | u16 NumLiterals;
46 |
47 | JitBlockEntry EntryPoint;
48 |
49 | const u32* AddressRanges() const { return &Data[0]; }
50 | u32* AddressRanges() { return &Data[0]; }
51 | const u32* AddressMasks() const { return &Data[NumAddresses]; }
52 | u32* AddressMasks() { return &Data[NumAddresses]; }
53 | const u32* Literals() const { return &Data[NumAddresses * 2]; }
54 | u32* Literals() { return &Data[NumAddresses * 2]; }
55 |
56 | private:
57 | TinyVector Data;
58 | };
59 | }
60 |
61 | #endif //MELONDS_JITBLOCK_H
62 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/InterfaceSettingsDialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef INTERFACESETTINGSDIALOG_H
20 | #define INTERFACESETTINGSDIALOG_H
21 |
22 | #include
23 |
24 | namespace Ui { class InterfaceSettingsDialog; }
25 | class InterfaceSettingsDialog;
26 |
27 | class InterfaceSettingsDialog : public QDialog
28 | {
29 | Q_OBJECT
30 |
31 | public:
32 | explicit InterfaceSettingsDialog(QWidget* parent);
33 | ~InterfaceSettingsDialog();
34 |
35 | static InterfaceSettingsDialog* currentDlg;
36 | static InterfaceSettingsDialog* openDlg(QWidget* parent)
37 | {
38 | if (currentDlg)
39 | {
40 | currentDlg->activateWindow();
41 | return currentDlg;
42 | }
43 |
44 | currentDlg = new InterfaceSettingsDialog(parent);
45 | currentDlg->open();
46 | return currentDlg;
47 | }
48 | static void closeDlg()
49 | {
50 | currentDlg = nullptr;
51 | }
52 |
53 | signals:
54 | void updateMouseTimer();
55 |
56 | private slots:
57 | void done(int r);
58 |
59 | void on_cbMouseHide_clicked();
60 |
61 | private:
62 | Ui::InterfaceSettingsDialog* ui;
63 | };
64 |
65 | #endif // INTERFACESETTINGSDIALOG_H
66 |
--------------------------------------------------------------------------------
/src/teakra/src/processor_general.md:
--------------------------------------------------------------------------------
1 | ## Features of the Architecture
2 |
3 | Most things in the processor is 16-bit. There is no 8-bit byte, and the smallest addressable memory unit is 16-bit. Many registers and data buses are also 16-bit. Exceptions are 40-bit accumulators, 33-bit multiplication results and 18-bit program counter. From now on, we call 16-bit "a word".
4 |
5 | Teak separate instruction and data address space. The instruction address is (18 + 4)-bit long, where 18 being the lower bits directly addressable by the program counter, and 4 being the higher bits specified by the `prpage` register. i.e. the program memory can be 16 pages with each page up to 0x40000 words. However, DSi/3DS seem to only support half of one program page (0x20000 words), and the register `prpage` is always 0. The data address is 16-bit long, meaning the data memory space contains 0x10000 words. However, DSi/3DS provides 0x20000-words long data memory to DSP. Accessing the larger space of data memory is achieved by memory bank switching. See [memory interface](miu.md) for details
6 |
7 | Although the program/data memory is viewed as arrays of 16-bit words from the Teak processor with no byte-order concept, it can be also accessed from the CPU (ARM) side and viewed as byte arrays. It appears that the 16-bit words is little-endian when represented in byte arrays.
8 |
9 | Each instruction is either one word or two words. The encoding of the instruction set is very messy. See [decoder](decoder.md) for details.
10 |
11 | The clock rate of the processor is unclear. Disassembly of 3DS DSP binary shows that it is likely about 134MHz (134,060,000 being the number used in the code). This also matches claimed sample rate from 3dbrew (32728Hz ≈ 134MHz / 4100, where 4100 is also a number for configuring audio output timer found in disassembly). Most instructions can complete in a single clock cycle, except for double-word instructions, multiple data read/write instructions and flow control instructions.
12 |
--------------------------------------------------------------------------------
/src/fatfs/LICENSE.txt:
--------------------------------------------------------------------------------
1 | FatFs License
2 |
3 | FatFs has being developped as a personal project of the author, ChaN. It is free from the code anyone else wrote at current release. Following code block shows a copy of the FatFs license document that heading the source files.
4 |
5 | /*----------------------------------------------------------------------------/
6 | / FatFs - Generic FAT Filesystem Module Rx.xx /
7 | /-----------------------------------------------------------------------------/
8 | /
9 | / Copyright (C) 20xx, ChaN, all right reserved.
10 | /
11 | / FatFs module is an open source software. Redistribution and use of FatFs in
12 | / source and binary forms, with or without modification, are permitted provided
13 | / that the following condition is met:
14 | /
15 | / 1. Redistributions of source code must retain the above copyright notice,
16 | / this condition and the following disclaimer.
17 | /
18 | / This software is provided by the copyright holder and contributors "AS IS"
19 | / and any warranties related to this software are DISCLAIMED.
20 | / The copyright owner or contributors be NOT LIABLE for any damages caused
21 | / by use of this software.
22 | /----------------------------------------------------------------------------*/
23 |
24 | Therefore FatFs license is one of the BSD-style licenses, but there is a significant feature. FatFs is mainly intended for embedded systems. In order to extend the usability for commercial products, the redistributions of FatFs in binary form, such as embedded code, binary library and any forms without source code, do not need to include about FatFs in the documentations. This is equivalent to the 1-clause BSD license. Of course FatFs is compatible with the most of open source software licenses include GNU GPL. When you redistribute the FatFs source code with changes or create a fork, the license can also be changed to GNU GPL, BSD-style license or any open source software license that not conflict with FatFs license.
25 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/PathSettingsDialog.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright 2016-2023 melonDS team
4 |
5 | This file is part of melonDS.
6 |
7 | melonDS is free software: you can redistribute it and/or modify it under
8 | the terms of the GNU General Public License as published by the Free
9 | Software Foundation, either version 3 of the License, or (at your option)
10 | any later version.
11 |
12 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License along
17 | with melonDS. If not, see http://www.gnu.org/licenses/.
18 | */
19 |
20 | #ifndef PATHSETTINGSDIALOG_H
21 | #define PATHSETTINGSDIALOG_H
22 |
23 | #include
24 |
25 | namespace Ui { class PathSettingsDialog; }
26 | class PathSettingsDialog;
27 |
28 | class PathSettingsDialog : public QDialog
29 | {
30 | Q_OBJECT
31 |
32 | public:
33 | explicit PathSettingsDialog(QWidget* parent);
34 | ~PathSettingsDialog();
35 |
36 | static PathSettingsDialog* currentDlg;
37 | static PathSettingsDialog* openDlg(QWidget* parent)
38 | {
39 | if (currentDlg)
40 | {
41 | currentDlg->activateWindow();
42 | return currentDlg;
43 | }
44 |
45 | currentDlg = new PathSettingsDialog(parent);
46 | currentDlg->open();
47 | return currentDlg;
48 | }
49 | static void closeDlg()
50 | {
51 | currentDlg = nullptr;
52 | }
53 |
54 | static bool needsReset;
55 |
56 | private slots:
57 | void done(int r);
58 |
59 | void on_btnSaveFileBrowse_clicked();
60 | void on_btnSavestateBrowse_clicked();
61 | void on_btnCheatFileBrowse_clicked();
62 |
63 | private:
64 | Ui::PathSettingsDialog* ui;
65 | };
66 |
67 | #endif // PATHSETTINGSDIALOG_H
68 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/DateTimeDialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef DATETIMEDIALOG_H
20 | #define DATETIMEDIALOG_H
21 |
22 | #include
23 | #include
24 | #include
25 |
26 | namespace Ui {class DateTimeDialog; }
27 | class DateTimeDialog;
28 |
29 | class DateTimeDialog : public QDialog
30 | {
31 | Q_OBJECT
32 |
33 | public:
34 | explicit DateTimeDialog(QWidget* parent);
35 | ~DateTimeDialog();
36 |
37 | static DateTimeDialog* currentDlg;
38 | static DateTimeDialog* openDlg(QWidget* parent)
39 | {
40 | if (currentDlg)
41 | {
42 | currentDlg->activateWindow();
43 | return currentDlg;
44 | }
45 |
46 | currentDlg = new DateTimeDialog(parent);
47 | currentDlg->open();
48 | return currentDlg;
49 | }
50 | static void closeDlg()
51 | {
52 | currentDlg = nullptr;
53 | }
54 |
55 | protected:
56 | void timerEvent(QTimerEvent* event) override;
57 |
58 | private slots:
59 | void done(int r);
60 |
61 | void on_chkChangeTime_clicked(bool checked);
62 | void on_chkResetTime_clicked(bool checked);
63 |
64 | private:
65 | Ui::DateTimeDialog* ui;
66 |
67 | QDateTime customTime;
68 | };
69 |
70 | #endif // DATETIMEDIALOG_H
71 |
--------------------------------------------------------------------------------
/src/xxhash/xxhash.c:
--------------------------------------------------------------------------------
1 | /*
2 | * xxHash - Extremely Fast Hash algorithm
3 | * Copyright (C) 2012-2020 Yann Collet
4 | *
5 | * BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are
9 | * met:
10 | *
11 | * * Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * * Redistributions in binary form must reproduce the above
14 | * copyright notice, this list of conditions and the following disclaimer
15 | * in the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * You can contact the author at:
31 | * - xxHash homepage: https://www.xxhash.com
32 | * - xxHash source repository: https://github.com/Cyan4973/xxHash
33 | */
34 |
35 |
36 | /*
37 | * xxhash.c instantiates functions defined in xxhash.h
38 | */
39 |
40 | #define XXH_STATIC_LINKING_ONLY /* access advanced declarations */
41 | #define XXH_IMPLEMENTATION /* access definitions */
42 |
43 | #include "xxhash.h"
44 |
--------------------------------------------------------------------------------
/src/dolphin/CommonFuncs.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2009 Dolphin Emulator Project
2 | // Licensed under GPLv2+
3 | // Refer to the license_dolphin.txt file included.
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #include "CommonFuncs.h"
11 |
12 | #ifdef _WIN32
13 | #include
14 | #define strerror_r(err, buf, len) strerror_s(buf, len, err)
15 | #endif
16 |
17 | constexpr size_t BUFFER_SIZE = 256;
18 |
19 | // Wrapper function to get last strerror(errno) string.
20 | // This function might change the error code.
21 | std::string LastStrerrorString()
22 | {
23 | char error_message[BUFFER_SIZE];
24 |
25 | // There are two variants of strerror_r. The XSI version stores the message to the passed-in
26 | // buffer and returns an int (0 on success). The GNU version returns a pointer to the message,
27 | // which might have been stored in the passed-in buffer or might be a static string.
28 |
29 | // We check defines in order to figure out variant is in use, and we store the returned value
30 | // to a variable so that we'll get a compile-time check that our assumption was correct.
31 |
32 | #if (defined(__GLIBC__) || __ANDROID_API__ >= 23) && \
33 | (_GNU_SOURCE || (_POSIX_C_SOURCE < 200112L && _XOPEN_SOURCE < 600))
34 | const char* str = strerror_r(errno, error_message, BUFFER_SIZE);
35 | return std::string(str);
36 | #else
37 | int error_code = strerror_r(errno, error_message, BUFFER_SIZE);
38 | return error_code == 0 ? std::string(error_message) : "";
39 | #endif
40 | }
41 |
42 | #ifdef _WIN32
43 | // Wrapper function to get GetLastError() string.
44 | // This function might change the error code.
45 | std::string GetLastErrorString()
46 | {
47 | char error_message[BUFFER_SIZE];
48 |
49 | FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(),
50 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), error_message, BUFFER_SIZE, nullptr);
51 | return std::string(error_message);
52 | }
53 | #endif
54 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/WifiSettingsDialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef WIFISETTINGSDIALOG_H
20 | #define WIFISETTINGSDIALOG_H
21 |
22 | #include
23 |
24 | namespace Ui { class WifiSettingsDialog; }
25 | class WifiSettingsDialog;
26 |
27 | class WifiSettingsDialog : public QDialog
28 | {
29 | Q_OBJECT
30 |
31 | public:
32 | explicit WifiSettingsDialog(QWidget* parent);
33 | ~WifiSettingsDialog();
34 |
35 | static WifiSettingsDialog* currentDlg;
36 | static WifiSettingsDialog* openDlg(QWidget* parent)
37 | {
38 | if (currentDlg)
39 | {
40 | currentDlg->activateWindow();
41 | return currentDlg;
42 | }
43 |
44 | currentDlg = new WifiSettingsDialog(parent);
45 | currentDlg->open();
46 | return currentDlg;
47 | }
48 | static void closeDlg()
49 | {
50 | currentDlg = nullptr;
51 | }
52 |
53 | static bool needsReset;
54 |
55 | private slots:
56 | void done(int r);
57 |
58 | void on_rbDirectMode_clicked();
59 | void on_rbIndirectMode_clicked();
60 | void on_cbxDirectAdapter_currentIndexChanged(int sel);
61 |
62 | private:
63 | Ui::WifiSettingsDialog* ui;
64 |
65 | bool haspcap;
66 |
67 | void updateAdapterControls();
68 | };
69 |
70 | #endif // WIFISETTINGSDIALOG_H
71 |
--------------------------------------------------------------------------------
/src/Utils.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #include "Utils.h"
20 |
21 | #include
22 |
23 | namespace melonDS
24 | {
25 | std::pair, u32> PadToPowerOf2(std::unique_ptr&& data, u32 len) noexcept
26 | {
27 | if (data == nullptr || len == 0)
28 | return {nullptr, 0};
29 |
30 | if ((len & (len - 1)) == 0)
31 | return {std::move(data), len};
32 |
33 | u32 newlen = 1;
34 | while (newlen < len)
35 | newlen <<= 1;
36 |
37 | auto newdata = std::make_unique(newlen);
38 | memcpy(newdata.get(), data.get(), len);
39 | data = nullptr;
40 | return {std::move(newdata), newlen};
41 | }
42 |
43 | std::pair, u32> PadToPowerOf2(const u8* data, u32 len) noexcept
44 | {
45 | if (len == 0)
46 | return {nullptr, 0};
47 |
48 | u32 newlen = 1;
49 | while (newlen < len)
50 | newlen <<= 1;
51 |
52 | auto newdata = std::make_unique(newlen);
53 | memcpy(newdata.get(), data, len);
54 | return {std::move(newdata), newlen};
55 | }
56 |
57 | std::unique_ptr CopyToUnique(const u8* data, u32 len) noexcept
58 | {
59 | if (data == nullptr || len == 0)
60 | return nullptr;
61 |
62 | auto newdata = std::make_unique(len);
63 | memcpy(newdata.get(), data, len);
64 | return newdata;
65 | }
66 | }
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/QPathInput.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef QPATHINPUT_H
20 | #define QPATHINPUT_H
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | class QPathInput : public QLineEdit
28 | {
29 | Q_OBJECT
30 |
31 | public:
32 | QPathInput(QWidget* parent = nullptr) : QLineEdit(parent)
33 | {
34 | setAcceptDrops(true);
35 | }
36 |
37 | ~QPathInput()
38 | {
39 | }
40 |
41 | protected:
42 | void dragEnterEvent(QDragEnterEvent* event) override
43 | {
44 | if (!event->mimeData()->hasUrls()) return QLineEdit::dragEnterEvent(event);
45 |
46 | QList urls = event->mimeData()->urls();
47 | if (urls.count() > 1) return QLineEdit::dragEnterEvent(event);
48 |
49 | QString filename = urls.at(0).toLocalFile();
50 |
51 | event->acceptProposedAction();
52 | }
53 |
54 | void dropEvent(QDropEvent* event) override
55 | {
56 | if (!event->mimeData()->hasUrls()) return QLineEdit::dropEvent(event);
57 |
58 | QList urls = event->mimeData()->urls();
59 | if (urls.count() > 1) return QLineEdit::dropEvent(event);
60 |
61 | QString filename = urls.at(0).toLocalFile();
62 | setText(filename);
63 | }
64 | };
65 |
66 | #endif // QPATHINPUT_H
67 |
--------------------------------------------------------------------------------
/src/teakra/src/matcher.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include "common_types.h"
7 | #include "crash.h"
8 |
9 | struct Rejector {
10 | u16 mask;
11 | u16 unexpected;
12 | bool Rejects(u16 instruction) const {
13 | return (instruction & mask) == unexpected;
14 | }
15 | };
16 |
17 | template
18 | class Matcher {
19 | public:
20 | using visitor_type = Visitor;
21 | using handler_return_type = typename Visitor::instruction_return_type;
22 | using handler_function = std::function;
23 |
24 | Matcher(const char* const name, u16 mask, u16 expected, bool expanded, handler_function func)
25 | : name{name}, mask{mask}, expected{expected}, expanded{expanded}, fn{std::move(func)} {}
26 |
27 | static Matcher AllMatcher(handler_function func) {
28 | return Matcher("*", 0, 0, false, std::move(func));
29 | }
30 |
31 | const char* GetName() const {
32 | return name;
33 | }
34 |
35 | bool NeedExpansion() const {
36 | return expanded;
37 | }
38 |
39 | bool Matches(u16 instruction) const {
40 | return (instruction & mask) == expected &&
41 | std::none_of(rejectors.begin(), rejectors.end(),
42 | [instruction](const Rejector& rejector) {
43 | return rejector.Rejects(instruction);
44 | });
45 | }
46 |
47 | Matcher Except(Rejector rejector) const {
48 | Matcher new_matcher(*this);
49 | new_matcher.rejectors.push_back(rejector);
50 | return new_matcher;
51 | }
52 |
53 | handler_return_type call(Visitor& v, u16 instruction, u16 instruction_expansion = 0) const {
54 | ASSERT(Matches(instruction));
55 | return fn(v, instruction, instruction_expansion);
56 | }
57 |
58 | private:
59 | const char* name;
60 | u16 mask;
61 | u16 expected;
62 | bool expanded;
63 | handler_function fn;
64 | std::vector rejectors;
65 | };
66 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/MPSettingsDialog.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #include
20 | #include
21 |
22 | #include "types.h"
23 | #include "Platform.h"
24 | #include "Config.h"
25 |
26 | #include "LAN_Socket.h"
27 | #include "LAN_PCap.h"
28 | #include "Wifi.h"
29 |
30 | #include "MPSettingsDialog.h"
31 | #include "ui_MPSettingsDialog.h"
32 |
33 |
34 | MPSettingsDialog* MPSettingsDialog::currentDlg = nullptr;
35 |
36 | extern bool RunningSomething;
37 |
38 |
39 | MPSettingsDialog::MPSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MPSettingsDialog)
40 | {
41 | ui->setupUi(this);
42 | setAttribute(Qt::WA_DeleteOnClose);
43 |
44 | grpAudioMode = new QButtonGroup(this);
45 | grpAudioMode->addButton(ui->rbAudioAll, 0);
46 | grpAudioMode->addButton(ui->rbAudioOneOnly, 1);
47 | grpAudioMode->addButton(ui->rbAudioActiveOnly, 2);
48 | grpAudioMode->button(Config::MPAudioMode)->setChecked(true);
49 |
50 | ui->sbReceiveTimeout->setValue(Config::MPRecvTimeout);
51 | }
52 |
53 | MPSettingsDialog::~MPSettingsDialog()
54 | {
55 | delete ui;
56 | }
57 |
58 | void MPSettingsDialog::done(int r)
59 | {
60 | if (r == QDialog::Accepted)
61 | {
62 | Config::MPAudioMode = grpAudioMode->checkedId();
63 | Config::MPRecvTimeout = ui->sbReceiveTimeout->value();
64 |
65 | Config::Save();
66 | }
67 |
68 | QDialog::done(r);
69 |
70 | closeDlg();
71 | }
72 |
73 | //
74 |
--------------------------------------------------------------------------------
/src/dolphin/x64ABI.h:
--------------------------------------------------------------------------------
1 | // Copyright 2008 Dolphin Emulator Project
2 | // Licensed under GPLv2+
3 | // Refer to the license_dolphin.txt file included.
4 |
5 | #pragma once
6 |
7 | #include "BitSet.h"
8 | #include "x64Reg.h"
9 |
10 | // x64 ABI:s, and helpers to help follow them when JIT-ing code.
11 | // All convensions return values in EAX (+ possibly EDX).
12 |
13 | // Windows 64-bit
14 | // * 4-reg "fastcall" variant, very new-skool stack handling
15 | // * Callee moves stack pointer, to make room for shadow regs for the biggest function _it itself
16 | // calls_
17 | // * Parameters passed in RCX, RDX, ... further parameters are MOVed into the allocated stack space.
18 | // Scratch: RAX RCX RDX R8 R9 R10 R11
19 | // Callee-save: RBX RSI RDI RBP R12 R13 R14 R15
20 | // Parameters: RCX RDX R8 R9, further MOV-ed
21 |
22 | // Linux 64-bit
23 | // * 6-reg "fastcall" variant, old skool stack handling (parameters are pushed)
24 | // Scratch: RAX RCX RDX RSI RDI R8 R9 R10 R11
25 | // Callee-save: RBX RBP R12 R13 R14 R15
26 | // Parameters: RDI RSI RDX RCX R8 R9
27 |
28 | #define ABI_ALL_FPRS BitSet32(0xffff0000)
29 | #define ABI_ALL_GPRS BitSet32(0x0000ffff)
30 |
31 | #ifdef _WIN32 // 64-bit Windows - the really exotic calling convention
32 |
33 | #define ABI_PARAM1 RCX
34 | #define ABI_PARAM2 RDX
35 | #define ABI_PARAM3 R8
36 | #define ABI_PARAM4 R9
37 |
38 | // xmm0-xmm15 use the upper 16 bits in the functions that push/pop registers.
39 | #define ABI_ALL_CALLER_SAVED \
40 | (BitSet32{RAX, RCX, RDX, R8, R9, R10, R11, XMM0 + 16, XMM1 + 16, XMM2 + 16, XMM3 + 16, \
41 | XMM4 + 16, XMM5 + 16})
42 | #else // 64-bit Unix / OS X
43 |
44 | #define ABI_PARAM1 RDI
45 | #define ABI_PARAM2 RSI
46 | #define ABI_PARAM3 RDX
47 | #define ABI_PARAM4 RCX
48 | #define ABI_PARAM5 R8
49 | #define ABI_PARAM6 R9
50 |
51 | // FIXME: avoid pushing all 16 XMM registers when possible? most functions we call probably
52 | // don't actually clobber them.
53 | #define ABI_ALL_CALLER_SAVED (BitSet32{RAX, RCX, RDX, RDI, RSI, R8, R9, R10, R11} | ABI_ALL_FPRS)
54 | #endif // WIN32
55 |
56 | #define ABI_ALL_CALLEE_SAVED (~ABI_ALL_CALLER_SAVED)
57 |
58 | #define ABI_RETURN RAX
59 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/SaveManager.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #ifndef SAVEMANAGER_H
20 | #define SAVEMANAGER_H
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | #include "types.h"
31 |
32 | class SaveManager : public QThread
33 | {
34 | Q_OBJECT
35 | void run() override;
36 |
37 | public:
38 | SaveManager(const std::string& path);
39 | ~SaveManager();
40 |
41 | std::string GetPath();
42 | void SetPath(const std::string& path, bool reload);
43 |
44 | void RequestFlush(const melonDS::u8* savedata, melonDS::u32 savelen, melonDS::u32 writeoffset, melonDS::u32 writelen);
45 | void CheckFlush();
46 |
47 | bool NeedsFlush();
48 | void FlushSecondaryBuffer(melonDS::u8* dst = nullptr, melonDS::u32 dstLength = 0);
49 |
50 | private:
51 | std::string Path;
52 |
53 | std::atomic_bool Running;
54 |
55 | std::unique_ptr Buffer;
56 | melonDS::u32 Length;
57 | bool FlushRequested;
58 |
59 | QMutex* SecondaryBufferLock;
60 | std::unique_ptr SecondaryBuffer;
61 | melonDS::u32 SecondaryBufferLength;
62 |
63 | time_t TimeAtLastFlushRequest;
64 |
65 | // We keep versions in case the user closes the application before
66 | // a flush cycle is finished.
67 | melonDS::u32 PreviousFlushVersion;
68 | melonDS::u32 FlushVersion;
69 | };
70 |
71 | #endif // SAVEMANAGER_H
72 |
--------------------------------------------------------------------------------
/src/frontend/qt_sdl/pcap/vlan.h:
--------------------------------------------------------------------------------
1 | /*-
2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 | * The Regents of the University of California. All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. All advertising materials mentioning features or use of this software
14 | * must display the following acknowledgement:
15 | * This product includes software developed by the University of
16 | * California, Berkeley and its contributors.
17 | * 4. Neither the name of the University nor the names of its contributors
18 | * may be used to endorse or promote products derived from this software
19 | * without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 | * SUCH DAMAGE.
32 | */
33 |
34 | #ifndef lib_pcap_vlan_h
35 | #define lib_pcap_vlan_h
36 |
37 | #include
38 |
39 | struct vlan_tag {
40 | uint16_t vlan_tpid; /* ETH_P_8021Q */
41 | uint16_t vlan_tci; /* VLAN TCI */
42 | };
43 |
44 | #define VLAN_TAG_LEN 4
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/.github/workflows/build-appimage.yml:
--------------------------------------------------------------------------------
1 | name: AppImage
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 | branches:
9 | - master
10 |
11 | jobs:
12 | build:
13 |
14 | runs-on: ubuntu-20.04
15 |
16 | steps:
17 | - uses: actions/checkout@v1
18 | - name: Install dependencies
19 | run: |
20 | sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list
21 | sudo apt update
22 | sudo apt install cmake extra-cmake-modules libcurl4-gnutls-dev libpcap0.8-dev libsdl2-dev libqt5multimedia5-plugins qt5-default qtbase5-private-dev qtmultimedia5-dev libslirp0 libslirp-dev libarchive-dev zstd libzstd-dev --allow-downgrades
23 | - name: Create build environment
24 | run: mkdir ${{runner.workspace}}/build
25 | - name: Configure
26 | working-directory: ${{runner.workspace}}/build
27 | run: cmake $GITHUB_WORKSPACE
28 | - name: Make
29 | working-directory: ${{runner.workspace}}/build
30 | run: |
31 | make -j$(nproc --all)
32 | - name: Prepare AppDir for AppImage
33 | working-directory: ${{runner.workspace}}/build
34 | run: |
35 | make install DESTDIR=AppDir
36 | mv ./AppDir/usr/local/bin ./AppDir/usr/bin
37 | mv ./AppDir/usr/local/share ./AppDir/usr/share
38 | rm -rf ./AppDir/usr/local
39 | - name: Prepare necessary Tools for building the AppImage
40 | working-directory: ${{runner.workspace}}/build
41 | run: |
42 | wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
43 | wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
44 | chmod a+x linuxdeploy-x86_64.AppImage
45 | chmod a+x linuxdeploy-plugin-qt-x86_64.AppImage
46 | - name: Build the AppImage
47 | working-directory: ${{runner.workspace}}/build
48 | run: |
49 | ./linuxdeploy-x86_64.AppImage --appdir AppDir --plugin qt --output appimage
50 | mkdir dist
51 | cp ./melonDS*.AppImage ./dist
52 | - uses: actions/upload-artifact@v1
53 | with:
54 | name: melonDS-appimage-x86_64
55 | path: ${{runner.workspace}}/build/dist
56 |
--------------------------------------------------------------------------------
/src/frontend/duckstation/gl/context_egl_x11.cpp:
--------------------------------------------------------------------------------
1 | #include "context_egl_x11.h"
2 | #include "../log.h"
3 | Log_SetChannel(GL::ContextEGLX11);
4 |
5 | namespace GL {
6 | ContextEGLX11::ContextEGLX11(const WindowInfo& wi) : ContextEGL(wi) {}
7 | ContextEGLX11::~ContextEGLX11() = default;
8 |
9 | std::unique_ptr ContextEGLX11::Create(const WindowInfo& wi, const Version* versions_to_try,
10 | size_t num_versions_to_try)
11 | {
12 | std::unique_ptr context = std::make_unique(wi);
13 | if (!context->Initialize(versions_to_try, num_versions_to_try))
14 | return nullptr;
15 |
16 | return context;
17 | }
18 |
19 | std::unique_ptr ContextEGLX11::CreateSharedContext(const WindowInfo& wi)
20 | {
21 | std::unique_ptr context = std::make_unique(wi);
22 | context->m_display = m_display;
23 |
24 | if (!context->CreateContextAndSurface(m_version, m_context, false))
25 | return nullptr;
26 |
27 | return context;
28 | }
29 |
30 | void ContextEGLX11::ResizeSurface(u32 new_surface_width, u32 new_surface_height)
31 | {
32 | m_window.Resize();
33 | ContextEGL::ResizeSurface(new_surface_width, new_surface_height);
34 | }
35 |
36 | EGLNativeWindowType ContextEGLX11::GetNativeWindow(EGLConfig config)
37 | {
38 | X11InhibitErrors ei;
39 |
40 | EGLint native_visual_id = 0;
41 | if (!eglGetConfigAttrib(m_display, m_config, EGL_NATIVE_VISUAL_ID, &native_visual_id))
42 | {
43 | Log_ErrorPrintf("Failed to get X11 visual ID");
44 | return false;
45 | }
46 |
47 | XVisualInfo vi_query = {};
48 | vi_query.visualid = native_visual_id;
49 |
50 | int num_vis;
51 | XVisualInfo* vi = XGetVisualInfo(static_cast(m_wi.display_connection), VisualIDMask, &vi_query, &num_vis);
52 | if (num_vis <= 0 || !vi)
53 | {
54 | Log_ErrorPrintf("Failed to query visual from X11");
55 | return false;
56 | }
57 |
58 | m_window.Destroy();
59 | if (!m_window.Create(GetDisplay(), static_cast(reinterpret_cast(m_wi.window_handle)), vi))
60 | {
61 | Log_ErrorPrintf("Faild to create X11 child window");
62 | XFree(vi);
63 | return false;
64 | }
65 |
66 | XFree(vi);
67 | return static_cast(m_window.GetWindow());
68 | }
69 | } // namespace GL
70 |
--------------------------------------------------------------------------------
/src/GPU_OpenGL.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2016-2023 melonDS team
3 |
4 | This file is part of melonDS.
5 |
6 | melonDS is free software: you can redistribute it and/or modify it under
7 | the terms of the GNU General Public License as published by the Free
8 | Software Foundation, either version 3 of the License, or (at your option)
9 | any later version.
10 |
11 | melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License along
16 | with melonDS. If not, see http://www.gnu.org/licenses/.
17 | */
18 |
19 | #pragma once
20 |
21 | #include "OpenGLSupport.h"
22 |
23 | #include
24 | #include
25 |
26 | namespace melonDS
27 | {
28 | class GPU;
29 | struct RenderSettings;
30 | class GLRenderer;
31 | class GLCompositor
32 | {
33 | public:
34 | static std::optional New() noexcept;
35 | GLCompositor(const GLCompositor&) = delete;
36 | GLCompositor& operator=(const GLCompositor&) = delete;
37 | GLCompositor(GLCompositor&&) noexcept;
38 | GLCompositor& operator=(GLCompositor&&) noexcept;
39 | ~GLCompositor();
40 |
41 | void SetScaleFactor(int scale) noexcept;
42 | [[nodiscard]] int GetScaleFactor() const noexcept { return Scale; }
43 |
44 | void Stop(const GPU& gpu) noexcept;
45 | void RenderFrame(const GPU& gpu, GLRenderer& renderer) noexcept;
46 | void BindOutputTexture(int buf);
47 | private:
48 | GLCompositor(std::array CompShader) noexcept;
49 | int Scale = 0;
50 | int ScreenH = 0, ScreenW = 0;
51 |
52 | std::array CompShader {};
53 | GLuint CompScaleLoc = 0;
54 | GLuint Comp3DXPosLoc = 0;
55 |
56 | GLuint CompVertexBufferID = 0;
57 | GLuint CompVertexArrayID = 0;
58 |
59 | struct CompVertex
60 | {
61 | std::array Position {};
62 | std::array Texcoord {};
63 | };
64 | std::array CompVertices {};
65 |
66 | GLuint CompScreenInputTex = 0;
67 | std::array