Skip to content

Commit 36c10c3

Browse files
authored
show warning when using mirror/echo/kernel RAM (#987)
1 parent 1c79c93 commit 36c10c3

12 files changed

+46
-37
lines changed

src/RA_StringUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ class StringBuilder
311311
const auto nIndex = sFormat.find('.');
312312
if (nIndex != std::string::npos)
313313
{
314-
int nPrecision = std::stoi(sFormat.c_str() + nIndex + 1);
314+
const int nPrecision = std::stoi(sFormat.c_str() + nIndex + 1);
315315
oss.precision(nPrecision);
316316
oss << std::fixed;
317317
}
@@ -332,7 +332,7 @@ class StringBuilder
332332
{
333333
if (sFormat.front() == '.')
334334
{
335-
int nCharacters = std::stoi(&sFormat.at(1));
335+
const int nCharacters = std::stoi(&sFormat.at(1));
336336
AppendSubString(arg, nCharacters);
337337
}
338338
else

src/data/DataModelBase.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void DataModelBase::EndUpdate()
198198
{
199199
if (pChange.tNewValue != pChange.tOldValue)
200200
{
201-
IntModelProperty::ChangeArgs args{ *pChange.pProperty, pChange.tOldValue, pChange.tNewValue };
201+
const IntModelProperty::ChangeArgs args{ *pChange.pProperty, pChange.tOldValue, pChange.tNewValue };
202202
m_pEndUpdateChangeArgs = &args;
203203
OnValueChanged(args);
204204
}
@@ -208,7 +208,7 @@ void DataModelBase::EndUpdate()
208208
{
209209
if (pChange.tNewValue != pChange.tOldValue)
210210
{
211-
BoolModelProperty::ChangeArgs args{ *pChange.pProperty, pChange.tOldValue, pChange.tNewValue };
211+
const BoolModelProperty::ChangeArgs args{ *pChange.pProperty, pChange.tOldValue, pChange.tNewValue };
212212
m_pEndUpdateChangeArgs = &args;
213213
OnValueChanged(args);
214214
}
@@ -218,7 +218,7 @@ void DataModelBase::EndUpdate()
218218
{
219219
if (pChange.tNewValue != pChange.tOldValue)
220220
{
221-
StringModelProperty::ChangeArgs args{ *pChange.pProperty, pChange.tOldValue, pChange.tNewValue };
221+
const StringModelProperty::ChangeArgs args{ *pChange.pProperty, pChange.tOldValue, pChange.tNewValue };
222222
m_pEndUpdateChangeArgs = &args;
223223
OnValueChanged(args);
224224
}

src/data/ModelPropertyContainer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void ModelPropertyContainer::SetValue(const BoolModelProperty& pProperty, bool b
2626
m_mDebugValues.insert_or_assign(pProperty.GetPropertyName(), bValue ? L"true" : L"false");
2727
#endif
2828

29-
BoolModelProperty::ChangeArgs args{ pProperty, !bValue, bValue };
29+
const BoolModelProperty::ChangeArgs args{ pProperty, !bValue, bValue };
3030
OnValueChanged(args);
3131
}
3232

@@ -76,7 +76,7 @@ void ModelPropertyContainer::SetValue(const StringModelProperty& pProperty, cons
7676
m_mDebugValues.insert_or_assign(pProperty.GetPropertyName(), sValue);
7777
#endif
7878

79-
StringModelProperty::ChangeArgs args{ pProperty, *pOldValue, sValue };
79+
const StringModelProperty::ChangeArgs args{ pProperty, *pOldValue, sValue };
8080
OnValueChanged(args);
8181
}
8282

@@ -121,7 +121,7 @@ void ModelPropertyContainer::SetValue(const IntModelProperty& pProperty, int nVa
121121
m_mDebugValues.insert_or_assign(pProperty.GetPropertyName(), std::to_wstring(nValue));
122122
#endif
123123

124-
IntModelProperty::ChangeArgs args{ pProperty, nOldValue, nValue };
124+
const IntModelProperty::ChangeArgs args{ pProperty, nOldValue, nValue };
125125
OnValueChanged(args);
126126
}
127127

src/data/models/TriggerValidation.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,30 @@ bool TriggerValidation::Validate(const std::string& sTrigger, std::wstring& sErr
9999
sTriggerBuffer.resize(nSize);
100100
const auto* pTrigger = rc_parse_trigger(sTriggerBuffer.data(), sTrigger.c_str(), nullptr, 0);
101101

102-
unsigned nMaxAddress = ra::to_unsigned(-1);
102+
char sErrorBuffer[256] = "";
103+
int nResult = 1;
104+
103105
if (ra::services::ServiceLocator::Exists<ra::data::context::ConsoleContext>())
104106
{
105107
const auto& pConsoleContext = ra::services::ServiceLocator::Get<ra::data::context::ConsoleContext>();
106-
nMaxAddress = pConsoleContext.MaxAddress();
108+
unsigned nMaxAddress = pConsoleContext.MaxAddress();
107109

108-
// if console definition doesn't specify the max address, see how much was exposed by the emulator
109110
if (nMaxAddress == 0)
110111
{
112+
// if console definition doesn't specify the max address, see how much was exposed by the emulator
111113
const auto& pEmulatorContext = ra::services::ServiceLocator::Get<ra::data::context::EmulatorContext>();
112114
nMaxAddress = gsl::narrow_cast<unsigned>(pEmulatorContext.TotalMemorySize()) - 1;
115+
116+
nResult = rc_validate_trigger(pTrigger, sErrorBuffer, sizeof(sErrorBuffer), nMaxAddress);
117+
}
118+
else
119+
{
120+
// if console definition does specify a max address, call the console-specific validator for additional validation
121+
nResult = rc_validate_trigger_for_console(pTrigger, sErrorBuffer, sizeof(sErrorBuffer), ra::etoi(pConsoleContext.Id()));
113122
}
114123
}
115124

116-
char sErrorBuffer[256];
117-
if (rc_validate_trigger(pTrigger, sErrorBuffer, sizeof(sErrorBuffer), nMaxAddress))
125+
if (nResult)
118126
{
119127
if (nType == AssetType::Leaderboard)
120128
{

src/ui/drawing/gdi/GDIBitmapSurface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void GDIBitmapSurface::WriteText(int nX, int nY, int nFont, Color nColor, const
127127
SelectFont(hMemDC, m_pResourceRepository.GetHFont(nFont));
128128
SetTextColor(hMemDC, RGB(255, 255, 255));
129129
SetBkMode(hMemDC, TRANSPARENT);
130-
RECT rcRect{0, 0, szText.cx, szText.cy};
130+
const RECT rcRect{0, 0, szText.cx, szText.cy};
131131
TextOutW(hMemDC, 0, 0, sText.c_str(), gsl::narrow_cast<int>(sText.length()));
132132

133133
// copy the greyscale text to the forground using the grey value as the alpha for antialiasing

src/ui/drawing/gdi/ImageRepository.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,13 @@ static HRESULT CreateDIBFromBitmapSource(_In_ IWICBitmapSource* pToRenderBitmapS
342342
// Create a DIB section based on Bitmap Info
343343
// BITMAPINFO Struct must first be setup before a DIB can be created.
344344
// Note that the height is negative for top-down bitmaps
345-
BITMAPINFOHEADER info_header{sizeof(BITMAPINFOHEADER), // biSize
346-
to_signed(nWidth),
347-
-to_signed(nHeight),
348-
WORD{1}, // biPlanes
349-
WORD{32}, // biBitCount
350-
DWORD{BI_RGB}};
351-
BITMAPINFO bminfo{info_header};
345+
const BITMAPINFOHEADER info_header{sizeof(BITMAPINFOHEADER), // biSize
346+
to_signed(nWidth),
347+
-to_signed(nHeight),
348+
WORD{1}, // biPlanes
349+
WORD{32}, // biBitCount
350+
DWORD{BI_RGB}};
351+
const BITMAPINFO bminfo{info_header};
352352
void *pvImageBits = nullptr;
353353

354354
auto hWindow = GetActiveWindow();

src/ui/win32/DialogBase.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ INT_PTR CALLBACK DialogBase::DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPA
423423

424424
case WM_MOVE:
425425
{
426-
ra::ui::Position oPosition{ LOWORD(lParam), HIWORD(lParam) };
426+
const ra::ui::Position oPosition{ LOWORD(lParam), HIWORD(lParam) };
427427
OnMove(oPosition);
428428
return 0;
429429
}
@@ -443,7 +443,7 @@ INT_PTR CALLBACK DialogBase::DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPA
443443

444444
case WM_SIZE:
445445
{
446-
ra::ui::Size oSize{ LOWORD(lParam), HIWORD(lParam) };
446+
const ra::ui::Size oSize{ LOWORD(lParam), HIWORD(lParam) };
447447
OnSize(oSize);
448448
return 0;
449449
}
@@ -663,7 +663,7 @@ void DialogBase::UpdateAnchoredControls()
663663
auto* pBinding = FindControlBinding(hControl);
664664
if (pBinding)
665665
{
666-
ra::ui::Size pNewSize{ nWidth, nHeight };
666+
const ra::ui::Size pNewSize{ nWidth, nHeight };
667667
pBinding->OnSizeChanged(pNewSize);
668668
}
669669
}

src/ui/win32/bindings/MemoryViewerControlBinding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void MemoryViewerControlBinding::SetHWND(DialogBase& pDialog, HWND hControl)
113113
RECT rcRect;
114114
GetWindowRect(hControl, &rcRect);
115115

116-
ra::ui::Size szSize{ rcRect.right - rcRect.left, rcRect.bottom - rcRect.top };
116+
const ra::ui::Size szSize{ rcRect.right - rcRect.left, rcRect.bottom - rcRect.top };
117117
OnSizeChanged(szSize);
118118
}
119119

src/ui/win32/bindings/WindowBinding.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ void WindowBinding::OnSizeChanged(_UNUSED ra::ui::Size oSize)
256256
// oSize is the size of client area, we need the size of the window (including non-client area)
257257
RECT rcDialog;
258258
GetWindowRect(m_hWnd, &rcDialog);
259-
ra::ui::Size oDialogSize{ rcDialog.right - rcDialog.left, rcDialog.bottom - rcDialog.top };
259+
const ra::ui::Size oDialogSize{ rcDialog.right - rcDialog.left, rcDialog.bottom - rcDialog.top };
260260

261261
ra::services::ServiceLocator::GetMutable<ra::services::IConfiguration>().SetWindowSize(m_sSizeAndPositionKey, oDialogSize);
262262
}
@@ -275,7 +275,7 @@ void WindowBinding::OnPositionChanged(_UNUSED ra::ui::Position oPosition)
275275
// capture position relative to main window
276276
RECT rcMainWindow;
277277
GetWindowRect(g_RAMainWnd, &rcMainWindow);
278-
ra::ui::Position oRelativePosition{ rcDialog.left - rcMainWindow.left, rcDialog.top - rcMainWindow.top };
278+
const ra::ui::Position oRelativePosition{ rcDialog.left - rcMainWindow.left, rcDialog.top - rcMainWindow.top };
279279

280280
ra::services::ServiceLocator::GetMutable<ra::services::IConfiguration>().SetWindowPosition(m_sSizeAndPositionKey, oRelativePosition);
281281
}

tests/data/models/TriggerValidation_Tests.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,21 @@ TEST_CLASS(TriggerValidation_Tests)
131131
// basic checks for each side
132132
ra::data::context::mocks::MockConsoleContext mockConsoleContext(NES, L"NES");
133133
Assert::AreEqual(0xFFFFU, mockConsoleContext.MaxAddress());
134-
AssertValidation("0xH1234>0xH1235", L"");
135-
AssertValidation("0xH12345>0xH1235", L"Condition 1: Address 12345 out of range (max FFFF)");
136-
AssertValidation("0xH1234>0xH12345", L"Condition 1: Address 12345 out of range (max FFFF)");
134+
AssertValidation("0xH0234>0xH0235", L"");
135+
AssertValidation("0xH1234>0xH1235", L"Condition 1: Mirror RAM may not be exposed by emulator (address 1234)");
136+
AssertValidation("0xH12345>0xH0235", L"Condition 1: Address 12345 out of range (max FFFF)");
137+
AssertValidation("0xH0234>0xH12345", L"Condition 1: Address 12345 out of range (max FFFF)");
137138
AssertValidation("0xH12345>0xH12345", L"Condition 1: Address 12345 out of range (max FFFF)");
138-
AssertValidation("0xX1234>h12345", L"");
139+
AssertValidation("0xX0234>h12345", L"");
139140

140141
// edge cases
141142
AssertValidation("0xH0000>5", L"");
142143
AssertValidation("0xHFFFF>5", L"");
143144
AssertValidation("0xH10000>5", L"Condition 1: Address 10000 out of range (max FFFF)");
144145

145146
// AddAddress can use really big values for negative offsets, don't flag them.
146-
AssertValidation("I:0xX1234_0xHFFFFFF00>5", L"");
147-
AssertValidation("I:0xX1234_0xH1234>5_0xHFFFFFF00>5", L"Condition 3: Address FFFFFF00 out of range (max FFFF)");
147+
AssertValidation("I:0xX0234_0xHFFFFFF00>5", L"");
148+
AssertValidation("I:0xX0234_0xH0234>5_0xHFFFFFF00>5", L"Condition 3: Address FFFFFF00 out of range (max FFFF)");
148149
}
149150

150151
TEST_METHOD(TestAddressRangeArcade)

tests/services/SearchResults_Tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ TEST_CLASS(SearchResults_Tests)
14401440
Assert::AreEqual({ 3U }, results1.MatchingAddressCount());
14411441

14421442
// exclude doesn't do anything to unfiltered results
1443-
SearchResults::Result excludeResult{ 1U, 0U, MemSize::EightBit };
1443+
const SearchResults::Result excludeResult{ 1U, 0U, MemSize::EightBit };
14441444
results1.ExcludeResult(excludeResult);
14451445
Assert::AreEqual({ 3U }, results1.MatchingAddressCount());
14461446

@@ -1539,7 +1539,7 @@ TEST_CLASS(SearchResults_Tests)
15391539
Assert::AreEqual({ 2U }, results1.MatchingAddressCount());
15401540

15411541
// exclude doesn't do anything to unfiltered results
1542-
SearchResults::Result excludeResult{ 0U, 0U, MemSize::EightBit };
1542+
const SearchResults::Result excludeResult{ 0U, 0U, MemSize::EightBit };
15431543
results1.ExcludeResult(excludeResult);
15441544
Assert::AreEqual({ 2U }, results1.MatchingAddressCount());
15451545

@@ -2083,7 +2083,7 @@ TEST_CLASS(SearchResults_Tests)
20832083
Assert::AreEqual({ 3U }, results1.MatchingAddressCount());
20842084

20852085
// exclude doesn't do anything to unfiltered results
2086-
SearchResults::Result excludeResult{ 0U, 0U, MemSize::EightBit };
2086+
const SearchResults::Result excludeResult{ 0U, 0U, MemSize::EightBit };
20872087
results1.ExcludeResult(excludeResult);
20882088
Assert::AreEqual({ 3U }, results1.MatchingAddressCount());
20892089

0 commit comments

Comments
 (0)