Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6f39652
Update InputConfigDialog.h
PanMenel Dec 18, 2025
fc2b34d
This should work I guess
PanMenel Dec 18, 2025
fcf6a8f
Gówno fix usuwający feature
PanMenel Dec 18, 2025
5dcc694
fix gówno fixa i guess
PanMenel Dec 18, 2025
29a92d3
Epic update, i hope it works XD
PanMenel Dec 18, 2025
1dc324a
fix better buildu
PanMenel Dec 18, 2025
e4a2672
fix fixa XD
PanMenel Dec 18, 2025
bfb988b
i am so fucking stupid fix
PanMenel Dec 18, 2025
814ad81
Update README.md
PanMenel Dec 18, 2025
d03f875
Update README.md
PanMenel Dec 18, 2025
baf8bfa
Update README.md
PanMenel Dec 18, 2025
1690b03
Cosmetic changes to ReadMe
PanMenel Dec 18, 2025
e37fa68
my stupid ass added button traping users
PanMenel Dec 18, 2025
14805c1
fix because unused code
PanMenel Dec 18, 2025
1a76845
even stupider case for a fix
PanMenel Dec 18, 2025
0c04ac3
more unused code
PanMenel Dec 19, 2025
e389058
revert on readme
PanMenel Dec 19, 2025
8bdda09
Reworked EmuInstanceInput.cpp to not touch existing code and made it …
PanMenel Dec 19, 2025
f93c230
if function shift to look more clean
PanMenel Dec 19, 2025
3b75b1e
Full Rewrite to fit more into melonds code
PanMenel Dec 19, 2025
3e19c52
Update Config.h
PanMenel Dec 19, 2025
c55230e
Update Config.cpp
PanMenel Dec 19, 2025
71ddddc
Update EmuSettingsDialog.cpp
PanMenel Dec 19, 2025
ec2c4e9
First batch of changes. could be wrong
PanMenel Dec 29, 2025
ee8b670
added new files and batch2
PanMenel Dec 30, 2025
a81d479
RA files
PanMenel Dec 30, 2025
1dbec57
RA frontend files
PanMenel Dec 30, 2025
e9a0211
Rcheevos files
PanMenel Dec 30, 2025
b5dd626
Rcheevos v2
PanMenel Dec 30, 2025
921c74e
rcheevos v3
PanMenel Dec 30, 2025
9469e46
rcheevos v4
PanMenel Dec 30, 2025
7281d90
somehow - snuck in
PanMenel Dec 30, 2025
759e403
Merge branch 'melonDS-emu:master' into Retro-Achievements-Implementation
PanMenel Dec 30, 2025
4112671
core fixes and changes
PanMenel Jan 5, 2026
1789c3c
changes to frontend nr.1
PanMenel Jan 5, 2026
8c7c3c9
Some cleanup
PanMenel Jan 6, 2026
4e60f9e
forgor .ui
PanMenel Jan 6, 2026
c025f97
Toast Manager fixes to fix compiling
PanMenel Jan 6, 2026
738a8ca
now toast should be good i guess
PanMenel Jan 6, 2026
0ec40be
More cleaning up
PanMenel Jan 6, 2026
785e00b
EVEN MORE CLEANING UP
PanMenel Jan 6, 2026
15be17b
Merge branch 'melonDS-emu:master' into Retro-Achievements-Implementation
PanMenel Jan 6, 2026
2d951aa
mainly revert changes from my other fork
PanMenel Jan 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,65 @@ if (ENABLE_JIT_PROFILING)
target_link_libraries(core PRIVATE "${VTUNE_LIBRARY}")
endif()

# --- RetroAchievements ---
option(ENABLE_RETROACHIEVEMENTS "Enable RetroAchievements support" OFF)

if (ENABLE_RETROACHIEVEMENTS)
message(STATUS "RetroAchievements: ENABLED")

if (WIN32)
target_compile_definitions(core PUBLIC RETROACHIEVEMENTS_ENABLED HAVE_CURL CURL_STATICLIB)

set(CURL_DEPENDENCY_NAMES
curl nghttp2 nghttp3 ngtcp2 ssh2 psl ssl crypto brotlidec
brotlicommon brotlienc zstd idn2 unistring iconv z
)

set(CURL_FOUND_LIBS "")
foreach(LIB_NAME ${CURL_DEPENDENCY_NAMES})
find_library(LIB_PATH_${LIB_NAME} NAMES ${LIB_NAME} REQUIRED)
if(LIB_PATH_${LIB_NAME})
list(APPEND CURL_FOUND_LIBS ${LIB_PATH_${LIB_NAME}})
endif()
endforeach()

find_library(LIB_NGTCP2_CRYPTO NAMES ngtcp2_crypto_ossl ngtcp2_crypto_openssl)
if(LIB_NGTCP2_CRYPTO)
list(INSERT CURL_FOUND_LIBS 4 ${LIB_NGTCP2_CRYPTO})
endif()

target_link_libraries(core PRIVATE
${CURL_FOUND_LIBS}
ws2_32 wldap32 crypt32 normaliz advapi32 secur32 bcrypt
)
else()
find_package(CURL REQUIRED)
target_compile_definitions(core PUBLIC RETROACHIEVEMENTS_ENABLED HAVE_CURL)
target_link_libraries(core PRIVATE ${CURL_LIBRARIES})
target_include_directories(core PRIVATE ${CURL_INCLUDE_DIRS})
endif()

target_include_directories(core PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/RetroAchievements"
"${CMAKE_CURRENT_SOURCE_DIR}"
)

target_sources(core PRIVATE
RetroAchievements/RAClient.cpp
RetroAchievements/RAClient.h
)

file(GLOB_RECURSE RCH_ALL "${CMAKE_CURRENT_SOURCE_DIR}/rcheevos/src/*.c")
list(FILTER RCH_ALL EXCLUDE REGEX "rc_libretro.c|rc_client_external.c|rhash/aes.c")
target_sources(core PRIVATE ${RCH_ALL})
target_include_directories(core PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/rcheevos/include"
"${CMAKE_CURRENT_SOURCE_DIR}/rcheevos/src"
)
else()
message(STATUS "RetroAchievements: DISABLED (default)")
endif()

#if(CMAKE_BUILD_TYPE MATCHES "Debug")
# set(
# CMAKE_C_FLAGS
Expand Down
28 changes: 28 additions & 0 deletions src/NDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
#include "DSi_DSP.h"
#include "ARMJIT.h"
#include "ARMJIT_Memory.h"
#include <string>

#ifdef RETROACHIEVEMENTS_ENABLED
#include "RetroAchievements/RAClient.h"
#endif

namespace melonDS
{
Expand Down Expand Up @@ -543,6 +548,9 @@ void NDS::Reset()
SPI.Reset();
RTC.Reset();
Wifi.Reset();
memset(MainRAM, 0, MainRAMMask + 1);
Copy link
Contributor

@asiekierka asiekierka Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the memset() done here? It is already done in SetupDirectBoot, which makes sense as that path skips BIOS/firmware, and I'm not sure if the console RAM is actually zero on cold boot on real hardware. Did you verify this or do you have a source for this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did implement this because I got a random achievement on starting a new game without fully restarting the emulator. I didn't really verify it, but it requires further testing if needed.

memset(SharedWRAM, 0, 0x8000);
memset(ARM7WRAM, 0, 0x10000);
}

void NDS::Start()
Expand Down Expand Up @@ -776,6 +784,16 @@ void NDS::SetNDSCart(std::unique_ptr<NDSCart::CartCommon>&& cart)
// The existing cart will always be ejected;
// if cart is null, then that's equivalent to ejecting a cart
// without inserting a new one.
#ifdef RETROACHIEVEMENTS_ENABLED
if (ra) {
auto cart = NDSCartSlot.GetCart();
if (cart) {
const char* h = cart->GetRAHash();
if (h && h[0])
ra->SetPendingGameHash(h);
}
}
#endif
}

void NDS::SetNDSSave(const u8* savedata, u32 savelen)
Expand Down Expand Up @@ -922,6 +940,11 @@ void NDS::RunSystemSleep(u64 timestamp)
template <CPUExecuteMode cpuMode>
u32 NDS::RunFrame()
{
#ifdef RETROACHIEVEMENTS_ENABLED
if (ra) {
ra->DoFrame();
}
#endif
Current = this;

FrameStartTimestamp = SysTimestamp;
Expand Down Expand Up @@ -1597,6 +1620,11 @@ void NDS::MonitorARM9Jump(u32 addr)
{
Log(LogLevel::Info, "Game is now booting\n");
RunningGame = true;
#ifdef RETROACHIEVEMENTS_ENABLED
if (ra) {
ra->AttachNDS(this);
}
#endif
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/NDS.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
#include "DMA.h"
#include "FreeBIOS.h"

#ifdef RETROACHIEVEMENTS_ENABLED
#include "RetroAchievements/RAClient.h"
#endif
// when touching the main loop/timing code, pls test a lot of shit
// with this enabled, to make sure it doesn't desync
//#define DEBUG_CHECK_DESYNC
Expand Down Expand Up @@ -248,6 +251,11 @@ class NDS
#endif

public: // TODO: Encapsulate the rest of these members
#ifdef RETROACHIEVEMENTS_ENABLED
RAContext* ra = nullptr;
void SetRAContext(RAContext* ctx) noexcept { ra = ctx; }
bool IsGameRunning() const { return RunningGame; }
#endif
void* UserData;

int ConsoleType;
Expand Down
24 changes: 24 additions & 0 deletions src/NDSCart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
#include "FATStorage.h"
#include "Utils.h"

#ifdef RETROACHIEVEMENTS_ENABLED
#include "RetroAchievements/RAClient.h"
#include <rc_hash.h>
#endif

namespace melonDS
{
using Platform::Log;
Expand Down Expand Up @@ -202,6 +207,25 @@ CartCommon::CartCommon(std::unique_ptr<u8[]>&& rom, u32 len, u32 chipid, bool ba
CartType(type),
UserData(userdata)
{
#ifdef RETROACHIEVEMENTS_ENABLED
if (ROM && ROMLength > 0)
{
const bool ok = rc_hash_generate_from_buffer(
this->ra_hash,
RC_CONSOLE_NINTENDO_DS,
ROM.get(),
ROMLength
);

if (ok)
{
if (ra)
{
ra->SetPendingGameHash(this->ra_hash);
}
}
}
#endif
memcpy(&Header, ROM.get(), sizeof(Header));
IsDSi = Header.IsDSi() && !badDSiDump;
DSiBase = Header.DSiRegionStart << 19;
Expand Down
9 changes: 9 additions & 0 deletions src/NDSCart.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include "FATStorage.h"
#include "ROMList.h"

#ifdef RETROACHIEVEMENTS_ENABLED
#include "RetroAchievements/RAClient.h"
#endif

namespace melonDS
{
class NDS;
Expand Down Expand Up @@ -76,6 +80,11 @@ struct NDSCartArgs
class CartCommon
{
public:
#ifdef RETROACHIEVEMENTS_ENABLED
RAContext* ra = nullptr;
const char* GetRAHash() const { return ra_hash; }
char ra_hash[33] = {0};
#endif
CartCommon(const u8* rom, u32 len, u32 chipid, bool badDSiDump, ROMListEntry romparams, CartType type, void* userdata);
CartCommon(std::unique_ptr<u8[]>&& rom, u32 len, u32 chipid, bool badDSiDump, ROMListEntry romparams, CartType type, void* userdata);
virtual ~CartCommon();
Expand Down
Loading