Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
intact committed Apr 9, 2017
2 parents a622b19 + abe2e61 commit 78d064f
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
5 changes: 5 additions & 0 deletions desmume/src/GPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5554,6 +5554,11 @@ void GPUEngineA::_RenderLine_DisplayCapture(const u16 l)
const size_t readLineIndexWithOffset = (this->_dispCapCnt.readOffset * 64) + l;
bool newCaptureLineNativeState = true;
u16 *renderedLineSrcA16 = NULL;

//we must block captures when the capture dest is not mapped to LCDC.
//mario kart does this (maybe due to a programming bug, but maybe emulation timing error) when spamming confirm key during course intro and through black transition
if(vramConfiguration.banks[vramWriteBlock].purpose != VramConfiguration::LCDC)
return;

//128-wide captures should write linearly into memory, with no gaps
//this is tested by hotel dusk
Expand Down
37 changes: 37 additions & 0 deletions desmume/src/commandline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
#include "commandline.h"
#include "types.h"
#include "movie.h"
#include "rtc.h"
#include "slot1.h"
#include "slot2.h"
#include "NDSSystem.h"
#include "utils/datetime.h"
#include "utils/xstring.h"
#include <compat/getopt.h>
//#include "frontend/modules/mGetOpt.h" //to test with this, make sure global `optind` is initialized to 1
Expand Down Expand Up @@ -74,6 +76,8 @@ CommandLine::CommandLine()
, language(1) //english by default
, disable_sound(0)
, disable_limiter(0)
, _rtc_day(-1)
, _rtc_hour(-1)
{
}

Expand Down Expand Up @@ -116,6 +120,8 @@ static const char* help_string = \
#endif
" --disable-sound Disables the sound output" ENDL
" --disable-limiter Disables the 60fps limiter" ENDL
" --rtc-day D Override RTC day, 0=Sunday, 6=Saturday" ENDL
" --rtc-hour H Override RTC hour, 0=midnight, 23=an hour before" ENDL
ENDL
"Arguments affecting overall emulation parameters (`sync settings`): " ENDL
#ifdef HAVE_JIT
Expand Down Expand Up @@ -206,6 +212,9 @@ ENDL
#define OPT_ARM9GDB 700
#define OPT_ARM7GDB 701

#define OPT_RTC_DAY 800
#define OPT_RTC_HOUR 801

#define OPT_ADVANSCENE 900

bool CommandLine::parse(int argc,char **argv)
Expand Down Expand Up @@ -237,6 +246,8 @@ bool CommandLine::parse(int argc,char **argv)
#endif
{ "disable-sound", no_argument, &disable_sound, 1},
{ "disable-limiter", no_argument, &disable_limiter, 1},
{ "rtc-day", required_argument, NULL, OPT_RTC_DAY},
{ "rtc-hour", required_argument, NULL, OPT_RTC_HOUR},

//sync settings
#ifdef HAVE_JIT
Expand Down Expand Up @@ -306,6 +317,10 @@ bool CommandLine::parse(int argc,char **argv)
case OPT_3D_TEXTURE_UPSCALE: texture_upscale = atoi(optarg); break;
case OPT_GPU_RESOLUTION_MULTIPLIER: gpu_resolution_multiplier = atoi(optarg); break;

//RTC settings
case OPT_RTC_DAY: _rtc_day = atoi(optarg); break;
case OPT_RTC_HOUR: _rtc_hour = atoi(optarg); break;

//sync settings
case OPT_JIT_SIZE: _jit_size = atoi(optarg); break;

Expand Down Expand Up @@ -497,6 +512,14 @@ bool CommandLine::validate()
printerror("Invalid jit block size [1..100]. set to 100\n");
}
#endif
if (_rtc_day < -1 || _rtc_day > 6) {
printerror("Invalid rtc day override, valid values are from 0 to 6");
return false;
}
if (_rtc_hour < -1 || _rtc_hour > 23) {
printerror("Invalid rtc day override, valid values are from 0 to 23");
return false;
}

return true;
}
Expand Down Expand Up @@ -548,5 +571,19 @@ void CommandLine::process_addonCommands()
slot1_Change(NDS_SLOT1_RETAIL_MCROM);
else if(slot1 == "RETAILDEBUG")
slot1_Change(NDS_SLOT1_RETAIL_DEBUG);

if (_rtc_day != -1 || _rtc_hour != -1) {
DateTime now = DateTime::get_Now();
int cur_day = now.get_DayOfWeek();
int cur_hour = now.get_Hour();
int cur_total = cur_day * 24 + cur_hour;
int day = (_rtc_day != -1 ? _rtc_day : cur_day);
int hour = (_rtc_hour != -1 ? _rtc_hour : cur_hour);
int total = day * 24 + hour;
int diff = total - cur_total;
if (diff < 0)
diff += 24 * 7;
rtcHourOverride = diff;
}
}

2 changes: 2 additions & 0 deletions desmume/src/commandline.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class CommandLine
char *_slot1_fat_dir;
char* _console_type;
char* _advanscene_import;
int _rtc_day;
int _rtc_hour;
};

#endif
4 changes: 2 additions & 2 deletions desmume/src/rtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#endif
#include "movie.h"

int rtcHourOverride = 0;

typedef struct
{
Expand Down Expand Up @@ -95,9 +96,8 @@ bool moviemode=false;

DateTime rtcGetTime(void)
{
DateTime tm;
if(movieMode == MOVIEMODE_INACTIVE) {
return DateTime::get_Now();
return DateTime::get_Now().AddHours(rtcHourOverride);
}
else {
//now, you might think it is silly to go through all these conniptions
Expand Down
2 changes: 2 additions & 0 deletions desmume/src/rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "types.h"
#include "utils/datetime.h"

extern int rtcHourOverride;

DateTime rtcGetTime(void);
void rtcGetTimeAsString(char *buffer);

Expand Down

0 comments on commit 78d064f

Please sign in to comment.