-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanOut.cpp
135 lines (135 loc) · 3.14 KB
/
cleanOut.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "G.h"
void G::ShowOut( s16 no, u8 size )
{
out_LC->DeleteAllItems();
s8 col = out_LC->GetColumnCount();
for ( ; col >= 0; --col )
{ out_LC->DeleteColumn( col ); }
if ( IsBetween( no, 0, 255 ) )
{
xStr text, hexC;
wxListItem item, column;
wxFile oldDump, oldByte;
xStr oldDumpText, oldByteText;
xStr slash = gGetSlash();
xStr path = wxGetCwd() + slash + wxT( "ram" ) + slash;
s16 i = no;
s16 iCount = no - 5;
u32 j = 0u;
u32 jNext = 0u;
u32 jByte = 0u;
u32 jCount = readSize;
u32 k = 0u;
u8 out = 0u;
u8 outCount = 100u;
u8* old8 = new u8[ jCount ];
u16* old16 = reinterpret_cast< u16* >( old8 );
u32* old32 = reinterpret_cast< u32* >( old8 );
u64* old64 = reinterpret_cast< u64* >( old8 );
bool* theByte = new bool[ jCount ];
oldByteText.Printf( wxT( "byte%02i.bin" ), no );
oldByte.Open( path + oldByteText );
u64 address = 0u;
u64 nextByte = 0u;
wxFileOffset tmp = oldByte.Length();
if ( tmp >= 0 )
{
u64 byteCount = tmp;
u64 oldValue;
hexC.Printf( wxT( "%%0%ullX" ), size * 2u );
if
(
iCount < 0 ||
iCount > i
)
{
iCount = 0;
}
item.SetId( 0 );
item.SetText( wxT( "Address" ) );
out_LC->InsertColumn( 0, item );
for
(
col = 1;
i >= iCount;
--i, ++col
)
{
// Add Column
text.Printf( wxT( "Value %i" ), col );
item.SetColumn( col );
column.SetId( col );
column.SetText( text );
out_LC->InsertColumn( col, column );
// Open File
text.Printf( wxT( "dump%02u.bin" ), i );
oldDump.Open( path + text );
oldByte.Seek( 0u, wxFromStart );
nextByte = 0u;
out = 0u;
for
(
address = 0u, j = jCount;
( address < byteCount && out < outCount );
++address, ++j
)
{
if ( j == jCount )
{
jByte += jCount;
if ( jByte > byteCount )
{
jByte -= jCount;
jCount = byteCount - jByte;
jByte += jCount;
}
oldDump.Read( old8, jCount );
oldByte.Read( theByte, jCount );
j = 0u;
jNext = 0u;
k = 0u;
}
if ( j == jNext )
{
if ( theByte[ j ] )
{
switch ( size )
{
case 2u:
oldValue = old16[ k ];
break;
case 4u:
oldValue = old32[ k ];
break;
case 8u:
oldValue = old64[ k ];
break;
default:
oldValue = old8[ k ];
}
item.SetId( out );
if ( col == 1 )
{
text.Printf( hex64, address );
item.SetColumn( 0 );
item.SetText( text );
out_LC->InsertItem( item );
item.SetColumn( 1 );
}
text.Printf( hexC, oldValue );
item.SetText( text );
out_LC->SetItem( item );
++out;
}
jNext += size;
++k;
}
}
oldDump.Close();
}
oldByte.Close();
}
delete [] old8;
delete [] theByte;
}
}