@@ -82,7 +82,7 @@ const char *getAddressStringFromOffsets(int32_t slot, uint32_t maxOffset)
82
82
return " ???" ;
83
83
}
84
84
85
- // Make sure the address being read does not exceed 0x817FFFFF
85
+ // Make sure the address being read does not exceed 0x817FFFFF/0xC17FFFFF
86
86
Address = reinterpret_cast <uint32_t >(fixBaseAddress (
87
87
slot, reinterpret_cast <void *>(Address)));
88
88
@@ -107,7 +107,7 @@ const char *getValueString(int32_t slot)
107
107
return " ???" ;
108
108
}
109
109
110
- // Make sure the address being read does not exceed 0x817FFFFF
110
+ // Make sure the address being read does not exceed 0x817FFFFF/0xC17FFFFF
111
111
Address = reinterpret_cast <uint32_t >(fixBaseAddress (
112
112
slot, reinterpret_cast <void *>(Address)));
113
113
@@ -433,7 +433,7 @@ uint32_t adjustWatchValueControls(int32_t slot)
433
433
IncrementAmount = -1 ;
434
434
}
435
435
436
- adjustWatchTempValueAndBounds (slot, HighestDigit, IncrementAmount);
436
+ adjustWatchTempValueAndBounds (HighestDigit, IncrementAmount);
437
437
MemoryWatchAdjustableValueMenu.WaitFramesToPerformIncrement = 0 ;
438
438
return Button;
439
439
}
@@ -498,15 +498,15 @@ uint32_t adjustWatchValueControls(int32_t slot)
498
498
case DPADDOWN:
499
499
{
500
500
// Decrement the current value for the current slot
501
- adjustWatchTempValueAndBounds (slot, HighestDigit, -1 );
501
+ adjustWatchTempValueAndBounds (HighestDigit, -1 );
502
502
503
503
MenuVar.FrameCounter = 1 ;
504
504
return Button;
505
505
}
506
506
case DPADUP:
507
507
{
508
508
// Increment the current value for the current slot
509
- adjustWatchTempValueAndBounds (slot, HighestDigit, 1 );
509
+ adjustWatchTempValueAndBounds (HighestDigit, 1 );
510
510
511
511
MenuVar.FrameCounter = 1 ;
512
512
return Button;
@@ -522,14 +522,22 @@ uint32_t adjustWatchValueControls(int32_t slot)
522
522
case 0 :
523
523
{
524
524
// Modifying the address
525
- // Make sure the address being read does not exceed 0x817FFFFF
526
- MemoryWatch[slot].Address = reinterpret_cast <uint32_t >(
527
- fixBaseAddress (slot, reinterpret_cast <void *>(MenuVar.MenuSecondaryValueUnsigned )));
528
-
529
- MenuVar.MenuSelectionStates = 0 ;
525
+ // Make sure the address is valid
526
+ uint32_t tempMenuSecondaryValueUnsigned = MenuVar.MenuSecondaryValueUnsigned ;
527
+ if (checkIfPointerIsValid (reinterpret_cast <void *>(tempMenuSecondaryValueUnsigned)))
528
+ {
529
+ MemoryWatch[slot].Address = tempMenuSecondaryValueUnsigned;
530
+
531
+ MenuVar.MenuSelectionStates = 0 ;
530
532
531
- MenuVar.FrameCounter = 1 ;
532
- return Button;
533
+ MenuVar.FrameCounter = 1 ;
534
+ return Button;
535
+ }
536
+ else
537
+ {
538
+ // Tried to use an invalid address, so do nothing
539
+ return 0 ;
540
+ }
533
541
}
534
542
default :
535
543
{
@@ -584,7 +592,7 @@ uint32_t adjustWatchValueControls(int32_t slot)
584
592
}
585
593
}
586
594
587
- void adjustWatchTempValueAndBounds (int32_t slot, uint32_t highestDigit, int32_t valueChangedBy)
595
+ void adjustWatchTempValueAndBounds (uint32_t highestDigit, int32_t valueChangedBy)
588
596
{
589
597
for (uint32_t i = 0 ; i < (highestDigit - MenuVar.SecondaryMenuOption - 1 ); i++)
590
598
{
@@ -598,8 +606,8 @@ void adjustWatchTempValueAndBounds(int32_t slot, uint32_t highestDigit, int32_t
598
606
{
599
607
case MEMORY_WATCH_CHANGE_ADDRESS:
600
608
{
601
- uint32_t UpperBoundUnsigned;
602
- uint32_t LowerBoundUnsigned;
609
+ // uint32_t UpperBoundUnsigned;
610
+ // uint32_t LowerBoundUnsigned;
603
611
int32_t UpperBoundSigned;
604
612
int32_t LowerBoundSigned;
605
613
@@ -608,22 +616,7 @@ void adjustWatchTempValueAndBounds(int32_t slot, uint32_t highestDigit, int32_t
608
616
case 0 :
609
617
{
610
618
// Modifying the address
611
- // Make sure the upper bound does not exceed 0x817FFFFF
612
- UpperBoundUnsigned = reinterpret_cast <uint32_t >(
613
- fixBaseAddress (slot, reinterpret_cast <void *>(0x817FFFFF )));
614
-
615
- LowerBoundUnsigned = 0x80000000 ;
616
-
617
- if (tempMenuSecondaryValueUnsigned > UpperBoundUnsigned)
618
- {
619
- // Loop to the beginning
620
- MenuVar.MenuSecondaryValueUnsigned = LowerBoundUnsigned;
621
- }
622
- else if (tempMenuSecondaryValueUnsigned < LowerBoundUnsigned)
623
- {
624
- // Loop to the end
625
- MenuVar.MenuSecondaryValueUnsigned = UpperBoundUnsigned;
626
- }
619
+ // Nothing needs to be done for this
627
620
break ;
628
621
}
629
622
default :
@@ -690,9 +683,21 @@ void *fixBaseAddress(int32_t slot, void *address)
690
683
}
691
684
}
692
685
693
- // Make sure the address does not exceed 0x817FFFFF
686
+ // Make sure the address does not exceed 0x817FFFFF/0xC17FFFFF
694
687
uint32_t tempAddress = reinterpret_cast <uint32_t >(address);
695
- while ((tempAddress + CurrentTypeSize - 1 ) >= 0x81800000 )
688
+
689
+ // Arbitrary check for cached memory
690
+ uint32_t AddressCap;
691
+ if (tempAddress < 0x90000000 )
692
+ {
693
+ AddressCap = 0x81800000 ;
694
+ }
695
+ else
696
+ {
697
+ AddressCap = 0xC1800000 ;
698
+ }
699
+
700
+ while ((tempAddress + CurrentTypeSize - 1 ) >= AddressCap)
696
701
{
697
702
tempAddress--;
698
703
}
@@ -1271,13 +1276,9 @@ uint32_t memoryEditorButtonControls()
1271
1276
1272
1277
if (RowCheck)
1273
1278
{
1274
- // Only move down if there's at least one valid byte under the last row
1275
- if (checkIfPointerIsValid (CurrentAddress + EDITOR_MAX_NUM_BYTES_DISPLAYED))
1276
- {
1277
- // Move down one row
1278
- // Don't set CurrentEditorMenuOption, as it's already correct
1279
- MemoryEditor.CurrentAddress = CurrentAddress + EDITOR_BYTES_PER_ROW;
1280
- }
1279
+ // Move down one row
1280
+ // Don't set CurrentEditorMenuOption, as it's already correct
1281
+ MemoryEditor.CurrentAddress = CurrentAddress + EDITOR_BYTES_PER_ROW;
1281
1282
}
1282
1283
else
1283
1284
{
@@ -1340,13 +1341,9 @@ uint32_t memoryEditorButtonControls()
1340
1341
// Check to see if moving up goes to the previous row
1341
1342
if (CurrentEditorMenuOption < 0 )
1342
1343
{
1343
- // Only move up if there's at least one valid byte above the first row
1344
- if (checkIfPointerIsValid (CurrentAddress - 0x1 ))
1345
- {
1346
- // Move up one row
1347
- // Don't set CurrentEditorMenuOption, as it's already correct
1348
- MemoryEditor.CurrentAddress = CurrentAddress - EDITOR_BYTES_PER_ROW;
1349
- }
1344
+ // Move up one row
1345
+ // Don't set CurrentEditorMenuOption, as it's already correct
1346
+ MemoryEditor.CurrentAddress = CurrentAddress - EDITOR_BYTES_PER_ROW;
1350
1347
}
1351
1348
else
1352
1349
{
@@ -1450,6 +1447,14 @@ uint32_t memoryEditorButtonControls()
1450
1447
uint32_t Start = reinterpret_cast <uint32_t >(tempAddress);
1451
1448
uint32_t End = Start + NumBytesBeingEdited;
1452
1449
1450
+ // Arbitrary check for cached memory
1451
+ if (checkIfPointerIsValid (tempAddress) == PTR_UNCACHED)
1452
+ {
1453
+ // Only need to clear cached memory, so adjust the start and end to be in cached memory
1454
+ Start -= 0x40000000 ;
1455
+ End -= 0x40000000 ;
1456
+ }
1457
+
1453
1458
if (Start < 0x80000000 )
1454
1459
{
1455
1460
Start = 0x80000000 ;
0 commit comments