Skip to content

Commit

Permalink
Fix #104
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseTG committed Oct 31, 2023
1 parent e3bd2df commit c476f76
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmake/FetchDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function(fetch_dependency name default_url default_tag)
FetchContent_GetProperties(${name})
endfunction()

fetch_dependency("melonDS" "https://github.com/melonDS-emu/melonDS.git" "master")
fetch_dependency("melonDS" "https://github.com/melonDS-emu/melonDS.git" "b8963b0")
fetch_dependency("libretro-common" "https://github.com/libretro/libretro-common.git" "01c6122")
fetch_dependency("embed-binaries" "https://github.com/andoalon/embed-binaries.git" "21f28ca")
fetch_dependency(glm "https://github.com/g-truc/glm.git" "47585fd")
Expand Down
14 changes: 14 additions & 0 deletions src/libretro/libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <SPU.h>
#include <ARM.h>
#include <fmt/format.h>
#include <RTC.h>

#include "cheats.hpp"
#include "config.hpp"
Expand Down Expand Up @@ -491,6 +492,16 @@ static void melonds::render_audio() {
retro::audio_sample_batch(audio_buffer, read);
}

static void SetConsoleTime() noexcept {
ZoneScopedN(TracyFunction);
time_t now = time(nullptr);
tm tm;
struct tm* tmPtr = localtime(&now);
memcpy(&tm, tmPtr, sizeof(tm)); // Reduce the odds of race conditions in case some other thread uses this
RTC::SetDateTime(tm.tm_year, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
// tm.tm_mon is 0-indexed, but RTC::SetDateTime expects 1-indexed
}

namespace NDS {
extern bool Running;
}
Expand Down Expand Up @@ -648,6 +659,7 @@ PUBLIC_SYMBOL void retro_reset(void) {
NDS::Reset();
}

SetConsoleTime();
if (NDSCart::Cart && !NDSCart::Cart->GetHeader().IsDSiWare()) {
melonds::set_up_direct_boot(nds_info.value());
}
Expand Down Expand Up @@ -840,6 +852,8 @@ static void melonds::load_games_deferred(
NDS::Reset();
}

SetConsoleTime();

if (nds_info && NDSCart::Cart && !NDSCart::Cart->GetHeader().IsDSiWare()) {
set_up_direct_boot(*nds_info);
}
Expand Down
6 changes: 6 additions & 0 deletions src/libretro/platform/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "../format.hpp"
#include "retro/scaler.hpp"
#include "sram.hpp"
#include "tracy.hpp"

constexpr unsigned DSI_CAMERA_WIDTH = 640;
constexpr unsigned DSI_CAMERA_HEIGHT = 480;
Expand Down Expand Up @@ -209,6 +210,11 @@ void Platform::Sleep(u64 usecs) {
sleep_impl(usecs);
}

void Platform::WriteDateTime(int year, int month, int day, int hour, int minute, int second) {
ZoneScopedN(TracyFunction);
retro::debug("Platform::WriteDateTime({}, {}, {}, {}, {}, {})", year, month, day, hour, minute, second);
}

void Platform::Camera_Start(int num) {
if (_camera.start) {
if (_camera.start()) {
Expand Down

0 comments on commit c476f76

Please sign in to comment.