-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathExportFrm.cpp
More file actions
181 lines (157 loc) · 6.77 KB
/
ExportFrm.cpp
File metadata and controls
181 lines (157 loc) · 6.77 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "ExportFrm.h"
#include "MainFrm.h"
#include "HexFrm.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TExportForm *ExportForm;
//---------------------------------------------------------------------------
__fastcall TExportForm::TExportForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TExportForm::FormShow(TObject *Sender)
{
char OutputStr[1024];
ReverseOutputsCheckbox->Checked = MainForm->ReverseOutputs;
ReverseWithinOutColCheckbox->Checked = MainForm->ReverseWithinOutCol;
OutputBitOrderEdit->Text = MainForm->OutputBitOrderArrayToStr( OutputStr, sizeof(OutputStr) );
ROMLayoutRadioGroup->ItemIndex = MainForm->ROM_Layout;
}
//---------------------------------------------------------------------------
void __fastcall TExportForm::FormClose(TObject *Sender,
TCloseAction &Action)
{
MainForm->ReverseOutputs = ReverseOutputsCheckbox->Checked;
MainForm->ReverseWithinOutCol = ReverseWithinOutColCheckbox->Checked;
MainForm->ROM_Layout = (rom_layout_type)ROMLayoutRadioGroup->ItemIndex;
MainForm->Endianness = ExportForm->EndianRadioGroup->ItemIndex;
if( ROMLayoutRadioGroup->ItemIndex < 2 )
EnableAdditionalOptions();
else
DisableAdditionalOptions();
if( MainForm->ExportBin() > 0 ) // ByteData[] has been changed
HexForm->UpdateBin( MainForm->ByteData, MainForm->ByteDataLen );
}
//---------------------------------------------------------------------------
void __fastcall TExportForm::FormCloseQuery(TObject *Sender,
bool &CanClose)
{
int i,n;
char OutputStr[1024];
CanClose = true;
if( MainForm->OutputBitOrderStrToArray( OutputBitOrderEdit->Text.c_str() ) < 1 )
{
for( i=0; i<MainForm->NumOutputs; i++ )
MainForm->OutputOrder[i] = i;
OutputBitOrderEdit->Text = MainForm->OutputBitOrderArrayToStr( OutputStr, sizeof(OutputStr) );
return;
}
// check if MainForm->OutputOrder[] is sane, if not popup dialog and offer to go back to edit it
for( i=0; i<MainForm->NumOutputs; i++ )
{
if( MainForm->OutputOrder[i] >= MainForm->NumOutputs )
break;
for( n=0; n<MainForm->NumOutputs; n++ )
{
if( MainForm->OutputOrder[n] == i )
break;
}
if( n >= MainForm->NumOutputs )
break;
}
if( i < MainForm->NumOutputs )
{
if( Application->MessageBoxA( AnsiString(AnsiString("The Output bit order is not correct!\n\nThe Output bits include the range 0 .. ")+AnsiString( MainForm->NumOutputs-1 )+AnsiString("\n\nDo you want to continue even though the exported data will be invalid?") ).c_str(), "WARNING", MB_YESNO ) != IDYES )
CanClose = false;
}
}
//---------------------------------------------------------------------------
void __fastcall TExportForm::ReverseOutputsCheckboxClick(TObject *Sender)
{
MainForm->ReverseOutputs = ReverseOutputsCheckbox->Checked;
if( MainForm->ExportBin() > 0 ) // ByteData[] has been changed
HexForm->UpdateBin( MainForm->ByteData, MainForm->ByteDataLen );
}
//---------------------------------------------------------------------------
void __fastcall TExportForm::ReverseWithinOutColCheckboxClick(
TObject *Sender)
{
MainForm->ReverseWithinOutCol = ReverseWithinOutColCheckbox->Checked;
if( MainForm->ExportBin() > 0 ) // ByteData[] has been changed
HexForm->UpdateBin( MainForm->ByteData, MainForm->ByteDataLen );
}
//---------------------------------------------------------------------------
void __fastcall TExportForm::OutputBitOrderEditExit(TObject *Sender)
{
int i,n;
MainForm->OutputBitOrderStrToArray( OutputBitOrderEdit->Text.c_str() );
// check if MainForm->OutputOrder[] is sane
for( i=0; i<MainForm->NumOutputs; i++ )
{
if( MainForm->OutputOrder[i] >= MainForm->NumOutputs )
break;
for( n=0; n<MainForm->NumOutputs; n++ )
{
if( MainForm->OutputOrder[n] == i )
break;
}
if( n >= MainForm->NumOutputs )
break;
}
if( i < MainForm->NumOutputs )
{
if( Application->MessageBoxA( AnsiString(AnsiString("The Output bit order is not correct!\n\nThe Output bits include the range 0 .. ")+AnsiString( MainForm->NumOutputs-1 )+AnsiString("\n\nDo you want to continue even though the exported data will be invalid?") ).c_str(), "WARNING", MB_YESNO ) != IDYES )
return;
}
if( MainForm->ExportBin() > 0 ) // ByteData[] has been changed
HexForm->UpdateBin( MainForm->ByteData, MainForm->ByteDataLen );
}
//---------------------------------------------------------------------------
void __fastcall TExportForm::OutputBitOrderEditKeyPress(TObject *Sender,
char &Key)
{
if( Key == '\r' )
{
OutputBitOrderEditExit(Sender);
}
}
//---------------------------------------------------------------------------
void __fastcall TExportForm::ROMLayoutRadioGroupClick(TObject *Sender)
{
MainForm->ROM_Layout = (rom_layout_type)ROMLayoutRadioGroup->ItemIndex;
if( ROMLayoutRadioGroup->ItemIndex < 2 )
EnableAdditionalOptions();
else
DisableAdditionalOptions();
if( MainForm->ExportBin() > 0 ) // ByteData[] has been changed
HexForm->UpdateBin( MainForm->ByteData, MainForm->ByteDataLen );
}
//---------------------------------------------------------------------------
void __fastcall TExportForm::DisableAdditionalOptions(void)
{
ReverseOutputsCheckbox->Enabled = false;
ReverseWithinOutColCheckbox->Enabled = false;
OutputBitOrderEdit->Enabled = false;
OutputBitOrderLabel->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TExportForm::EnableAdditionalOptions(void)
{
ReverseOutputsCheckbox->Enabled = true;
ReverseWithinOutColCheckbox->Enabled = true;
OutputBitOrderEdit->Enabled = true;
OutputBitOrderLabel->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TExportForm::EndianRadioGroupClick(TObject *Sender)
{
MainForm->Endianness = ExportForm->EndianRadioGroup->ItemIndex;
if( MainForm->ExportBin() > 0 ) // ByteData[] has been changed
HexForm->UpdateBin( MainForm->ByteData, MainForm->ByteDataLen );
}
//---------------------------------------------------------------------------