6 #include "anago_wxframe_main.h"
7 #include "reader_master.h"
8 //#include "reader_kazzo.h"
9 extern const struct reader_driver DRIVER_KAZZO;
11 #include "script_dump.h"
12 #include "flash_device.h"
15 static void value_set(void *gauge, int value)
17 wxGauge *g = static_cast<wxGauge *>(gauge);
21 static void range_set(void *gauge, int value)
23 wxGauge *g = static_cast<wxGauge *>(gauge);
30 static void text_append(void *log, const char *str)
32 wxTextCtrl *l = static_cast<wxTextCtrl *>(log);
36 static void label_set(void *label, const char *str)
38 wxStaticText *l = static_cast<wxStaticText *>(label);
42 static void choice_append(void *choice, const char *str)
44 wxChoice *c = static_cast<wxChoice *>(choice);
45 c->Append(wxString(str));
48 class anago_wxframe_main : public frame_main
52 MODE_DUMP, MODE_PROGRAM
54 void choise_script_init(wxString filespec)
56 wxDir dir(wxGetCwd());
59 m_choice_script->Clear();
60 if ( !dir.IsOpened() ){
63 bool cont = dir.GetFirst(&filename, filespec, wxDIR_FILES);
65 m_choice_script->Append(filename);
66 cont = dir.GetNext(&filename);
68 m_choice_script->Select(0);
70 void dump_form_init(void)
73 this->choise_script_init(wxString("*.ad"));
74 m_check_battery->Show();
75 m_check_forcemapper->Show();
76 m_text_forcemapper->Show();
77 m_button_execute->SetLabel(wxString("&Dump"));
78 m_choice_cpu_trans->Hide();
79 m_choice_cpu_device->Hide();
80 m_choice_ppu_trans->Hide();
81 m_choice_ppu_device->Hide();
83 void choise_trans_init(wxChoice *c)
86 c->Append(wxString("full"));
87 c->Append(wxString("empty"));
88 c->Append(wxString("top"));
89 c->Append(wxString("bottom"));
92 void program_form_init(void)
94 m_mode = MODE_PROGRAM;
95 this->choise_script_init(wxString("*.af"));
96 m_check_battery->Hide();
97 m_check_forcemapper->Hide();
98 m_text_forcemapper->Hide();
99 m_button_execute->SetLabel(wxString("&Program"));
100 m_choice_cpu_trans->Show();
101 m_choice_cpu_device->Show();
102 m_choice_ppu_trans->Show();
103 m_choice_ppu_device->Show();
105 void dump_execute(void)
107 struct config_dump config;
108 config.gauge_cpu.bar = m_gauge_cpu;
109 config.gauge_cpu.label = m_label_cpu;
110 config.gauge_cpu.label_set = label_set;
111 config.gauge_cpu.range_set = range_set;
112 config.gauge_cpu.value_set = value_set;
114 config.gauge_ppu.bar = m_gauge_ppu;
115 config.gauge_ppu.label = m_label_ppu;
116 config.gauge_ppu.label_set = label_set;
117 config.gauge_ppu.range_set = range_set;
118 config.gauge_ppu.value_set = value_set;
120 config.log.object = m_log;
121 config.log.append = text_append;
122 config.increase.cpu = 1;
123 config.increase.ppu = 1;
124 config.progress = true;
125 wxString str_script = m_choice_script->GetStringSelection();
126 config.script = str_script.fn_str();
130 config.mappernum = -1;
131 if(m_check_forcemapper->GetValue() == true){
132 str = m_text_forcemapper->GetValue();
133 if(str.ToLong(&config.mappernum) == false){
134 *m_log << "bad mapper number\n";
140 wxTextCtrl *text = m_picker_romimage->GetTextCtrl();
141 wxString str_rom = text->GetValue();
142 if(text->IsEmpty() == true){
143 *m_log << "Enter filename to ROM image\n";
146 config.target = str_rom.fn_str();
148 config.reader = &DRIVER_KAZZO;
149 if(config.reader->open_or_close(READER_OPEN) == NG){
150 *m_log << "reader open error\n";
153 m_choice_script->Disable();
154 m_picker_romimage->Disable();
155 m_check_battery->Disable();
156 m_check_forcemapper->Disable();
157 m_button_execute->Disable();
158 if(m_check_forcemapper->GetValue() == true){
159 m_text_forcemapper->Disable();
162 config.reader->init();
163 script_dump_execute(&config);
164 config.reader->open_or_close(READER_CLOSE);
166 m_choice_script->Enable();
167 m_picker_romimage->Enable();
168 m_check_battery->Enable();
169 m_check_forcemapper->Enable();
170 m_button_execute->Enable();
171 if(m_check_forcemapper->GetValue() == true){
172 m_text_forcemapper->Enable();
176 // Handlers for frame_main events.
177 void OnButtonClick( wxCommandEvent& event )
179 this->dump_execute();
182 void mapper_change_check(wxCommandEvent& event)
184 if(m_check_forcemapper->GetValue() == true){
185 m_text_forcemapper->Enable();
187 m_text_forcemapper->Disable();
192 anago_wxframe_main( wxWindow* parent ) : frame_main (parent)
194 //this->dump_form_init();
195 this->program_form_init();
196 this->choise_trans_init(m_choice_cpu_trans);
197 this->choise_trans_init(m_choice_ppu_trans);
199 struct flash_listup list;
200 list.obj_cpu = m_choice_cpu_device;
201 list.obj_ppu = m_choice_ppu_device;
202 list.append = choice_append;
203 flash_device_listup(&list);
204 m_choice_cpu_device->Select(0);
205 m_choice_ppu_device->Select(0);
212 class MyApp : public wxApp
215 anago_wxframe_main *m_frame;
219 m_frame = new anago_wxframe_main(NULL);