1 |
using System; |
2 |
using System.Collections.Generic; |
3 |
using System.ComponentModel; |
4 |
using System.Data; |
5 |
using System.Drawing; |
6 |
using System.Text; |
7 |
using System.Windows.Forms; |
8 |
|
9 |
namespace RomCheater.Docking.MemorySearch |
10 |
{ |
11 |
public partial class PatchRangeAdder : Form |
12 |
{ |
13 |
SearchDataTypes DataType; |
14 |
bool Unsigned = false; |
15 |
int _pid = -1; |
16 |
public PatchRangeAdder(int pid) |
17 |
{ |
18 |
InitializeComponent(); |
19 |
_pid = pid; |
20 |
Unsigned = true; |
21 |
DataType = SearchDataTypes._8bits; |
22 |
txtStartAddress.Text = string.Format("0x{0:x8}", 0); |
23 |
txtEndAddress.Text = string.Format("0x{0:x8}", 0); |
24 |
this.AddedPatchValue = new List<ResultDataType>(); |
25 |
txtStartAddress.MaxLength = sizeof(uint) * 2 + 2; |
26 |
txtEndAddress.MaxLength = sizeof(uint) * 2 + 2; |
27 |
} |
28 |
|
29 |
private void PatchRangeAdder_Load(object sender, EventArgs e) |
30 |
{ |
31 |
foreach (int val in Enum.GetValues(typeof(SearchDataTypes))) |
32 |
{ |
33 |
comboDataBitSize.Items.Add(val); |
34 |
} |
35 |
comboDataBitSize.SelectedIndex = 0; |
36 |
comboDataBitSize.Text = comboDataBitSize.Items[comboDataBitSize.SelectedIndex].ToString(); |
37 |
txtStartAddress.ReadOnly = false; |
38 |
txtEndAddress.ReadOnly = false; |
39 |
txtStartAddress.Text = ""; |
40 |
txtEndAddress.Text = ""; |
41 |
} |
42 |
|
43 |
private void btnOK_Click(object sender, EventArgs e) |
44 |
{ |
45 |
uint StartAddress = txtStartAddress.ToUInt32(); |
46 |
uint EndAddress = txtEndAddress.ToUInt32(); |
47 |
uint BIT_SIZE = ((uint)DataType) / 8; |
48 |
|
49 |
//if (!(ramdumper.VTLB_VADDR_MIN <= StartAddress && StartAddress < ramdumper.VTLB_VADDR_MAX || ramdumper.VTLB_VADDR_MIN <= EndAddress && EndAddress < ramdumper.VTLB_VADDR_MAX)) |
50 |
//{ |
51 |
// MessageBox.Show(string.Format("EE Ram requires the Starting and End Address to be between: 0x{0:x8} and 0x{1:x8}", ramdumper.VTLB_VADDR_MIN, ramdumper.VTLB_VADDR_MAX), "Address Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); |
52 |
// txtStartAddress.Text = ""; |
53 |
// txtEndAddress.Text = ""; |
54 |
// return; |
55 |
//} |
56 |
|
57 |
|
58 |
//if (!(ramdumper.VTLB_VADDR_MIN <= StartAddress && StartAddress < ramdumper.VTLB_VADDR_MAX)) |
59 |
//{ |
60 |
// MessageBox.Show(string.Format("EE Ram requires the Starting Address to be between: 0x{0:x8} and 0x{1:x8}", ramdumper.VTLB_VADDR_MIN, ramdumper.VTLB_VADDR_MAX), "Address Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); |
61 |
// txtStartAddress.Text = ""; |
62 |
// return; |
63 |
//} |
64 |
|
65 |
|
66 |
//if (!(ramdumper.VTLB_VADDR_MIN <= EndAddress && EndAddress < ramdumper.VTLB_VADDR_MAX)) |
67 |
//{ |
68 |
// MessageBox.Show(string.Format("EE Ram requires the Ending Address to be between: 0x{0:x8} and 0x{1:x8}", ramdumper.VTLB_VADDR_MIN, ramdumper.VTLB_VADDR_MAX), "Address Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); |
69 |
// txtEndAddress.Text = ""; |
70 |
// return; |
71 |
//} |
72 |
|
73 |
for (uint i = StartAddress; i <= EndAddress; i += BIT_SIZE) |
74 |
{ |
75 |
|
76 |
ResultItemState _result_state = new ResultItemState(string.Format("0x{0:x8}", i), DataType, Unsigned, _pid); |
77 |
ResultDataType _result = _result_state; |
78 |
this.AddedPatchValue.Add(_result); |
79 |
} |
80 |
this.Close(); |
81 |
} |
82 |
|
83 |
private void btnCancel_Click(object sender, EventArgs e) |
84 |
{ |
85 |
this.Close(); |
86 |
} |
87 |
|
88 |
public bool WasAPatchAdded |
89 |
{ |
90 |
get { return (this.AddedPatchValue.Count > 0); } |
91 |
} |
92 |
private List<ResultDataType> _AddedPatchValue; |
93 |
public List<ResultDataType> AddedPatchValue |
94 |
{ |
95 |
get { return _AddedPatchValue; } |
96 |
private set { _AddedPatchValue = value; } |
97 |
} |
98 |
|
99 |
private void comboDataBitSize_SelectedIndexChanged(object sender, EventArgs e) |
100 |
{ |
101 |
int selected_index = comboDataBitSize.SelectedIndex; |
102 |
int bit_size = -1; |
103 |
|
104 |
bit_size = Convert.ToInt32(comboDataBitSize.Items[comboDataBitSize.SelectedIndex]); |
105 |
this.DataType = (SearchDataTypes)bit_size; |
106 |
} |
107 |
|
108 |
private void PatchRangeAdder_KeyDown(object sender, KeyEventArgs e) |
109 |
{ |
110 |
if (e.KeyCode == Keys.Enter) btnOK.PerformClick(); |
111 |
} |
112 |
} |
113 |
} |
114 |
|