From: naruko Date: Sat, 23 Oct 2010 22:48:55 +0000 (+0000) Subject: progress bar の更新頻度を定量化, front end -> script 実行形の構造体を統合 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d8797b6f07277cb596b1e08f9339dfaa6c19dbee;hp=14e35a50e9ade68863d6343001ff02f9093b8d95;p=unagi%2Fold-svn-converted.git progress bar の更新頻度を定量化, front end -> script 実行形の構造体を統合 git-svn-id: svn+ssh://svn.osdn.net/svnroot/unagi@372 24ea1065-a21e-4ca1-99c9-f5125deb0858 --- diff --git a/client/trunk/anago/Makefile.wx b/client/trunk/anago/Makefile.wx index 1c11221..bc3fc4c 100644 --- a/client/trunk/anago/Makefile.wx +++ b/client/trunk/anago/Makefile.wx @@ -24,11 +24,12 @@ all: $(TARGET) WX_CONFIG = /d/dev/wxWidgets/build_thread/wx-config CXXFLAGS = -I.. `$(WX_CONFIG) --cppflags` +#script_flash.o OBJ = anago_gui.o anago_frame.o -OBJ += header.o crc32.o file.o \ +OBJ += header.o crc32.o file.o widget.o \ script_flash.o script_dump.o script_common.o \ progress.o flash_device.o \ - reader_dummy.o reader_kazzo.o usb_device.o squirrel_wrap.o memory_manage.o + reader_kazzo.o usb_device.o squirrel_wrap.o memory_manage.o clean: rm -f $(OBJ) diff --git a/client/trunk/anago/anago_frame.cpp b/client/trunk/anago/anago_frame.cpp index bf2b06f..d2955d5 100644 --- a/client/trunk/anago/anago_frame.cpp +++ b/client/trunk/anago/anago_frame.cpp @@ -16,14 +16,28 @@ extern "C"{ #include "script_flash.h" } -static void value_set(void *gauge, int value) +//---- C++ -> C -> C++ wrapping functions ---- +static void value_set(void *gauge, void *label, int value) { wxGauge *g = static_cast(gauge); + wxStaticText *l = static_cast(label); + wxString str; + str.Printf(wxT("0x%06x/0x%06x"), value, g->GetRange()); + wxMutexGuiEnter(); g->SetValue(value); + l->SetLabel(str); wxMutexGuiLeave(); } +static void value_add(void *gauge, void *label, int value) +{ + wxGauge *g = static_cast(gauge); + value += g->GetValue(); + + value_set(gauge, label, value); +} + static void range_set(void *gauge, int value) { wxGauge *g = static_cast(gauge); @@ -55,19 +69,20 @@ void choice_append(void *choice, const char *str) c->Append(wxString(str)); } +//---- script execute thread ---- class anago_frame; class anago_dumper : public wxThread { private: anago_frame *m_frame; - struct config_dump m_config; + struct dump_config m_config; protected: virtual void *Entry(void); public: - anago_dumper(anago_frame *f, struct config_dump *d) : wxThread() + anago_dumper(anago_frame *f, struct dump_config *d) : wxThread() { m_frame = f; - memcpy(&m_config, d, sizeof(config_dump)); + memcpy(&m_config, d, sizeof(struct dump_config)); } }; @@ -75,17 +90,18 @@ class anago_programmer : public wxThread { private: anago_frame *m_frame; - struct config_flash m_config; + struct program_config m_config; protected: virtual void *Entry(void); public: - anago_programmer(anago_frame *f, struct config_flash *d) : wxThread() + anago_programmer(anago_frame *f, struct program_config *d) : wxThread() { m_frame = f; - memcpy(&m_config, d, sizeof(config_flash)); + memcpy(&m_config, d, sizeof(struct program_config)); } }; +//---- main frame class ---- class anago_frame : public frame_main { private: @@ -98,6 +114,7 @@ private: t->label_set = label_set; t->range_set = range_set; t->value_set = value_set; + t->value_add = value_add; } void script_choice_init(wxChoice *c, wxString filespec) { @@ -128,21 +145,30 @@ private: c->Append(wxString("x4")); c->Select(0); } + int dump_increase_get(wxChoice *c) + { + switch(c->GetSelection()){ + case 0: return 1; + case 1: return 2; + case 2: return 4; + } + return 1; + } void dump_execute(void) { - struct config_dump config; - config.gauge_cpu.bar = m_dump_cpu_gauge; - config.gauge_cpu.label = m_dump_cpu_label; - gauge_init(&config.gauge_cpu); + struct dump_config config; + config.cpu.gauge.bar = m_dump_cpu_gauge; + config.cpu.gauge.label = m_dump_cpu_value; + gauge_init(&config.cpu.gauge); - config.gauge_ppu.bar = m_dump_ppu_gauge; - config.gauge_ppu.label = m_dump_ppu_label; - gauge_init(&config.gauge_ppu); + config.ppu.gauge.bar = m_dump_ppu_gauge; + config.ppu.gauge.label = m_dump_ppu_value; + gauge_init(&config.ppu.gauge); config.log.object = m_log; config.log.append = text_append; - config.increase.cpu = 1; - config.increase.ppu = 1; + config.cpu.increase = dump_increase_get(m_dump_cpu_increase); + config.ppu.increase = dump_increase_get(m_dump_ppu_increase); config.progress = true; wxString str_script = m_dump_script_choice->GetStringSelection(); strncpy(config.script, str_script.fn_str(), DUMP_SCRIPT_STR_LENGTH); @@ -167,8 +193,11 @@ private: } strncpy(config.target, str_rom.fn_str(), DUMP_TARGET_STR_LENGTH); - config.reader = &DRIVER_KAZZO; - if(config.reader->open_or_close(READER_OPEN) == NG){ + config.control = &DRIVER_KAZZO.control; + config.cpu.access = &DRIVER_KAZZO.cpu; + config.ppu.access = &DRIVER_KAZZO.ppu; + config.control->open(&config.handle); + if(config.handle.handle == NULL){ *m_log << "reader open error\n"; return; } @@ -181,7 +210,7 @@ private: m_dump_cpu_increase->Disable(); m_dump_ppu_increase->Disable(); - config.reader->init(); + config.control->init(&config.handle); /* if(m_anago_thread != NULL){ //??? delete m_anago_thread; }*/ @@ -205,7 +234,7 @@ private: c->Append(wxString("empty")); c->Select(0); } - bool program_rom_set(const char *area, wxString device, int trans, struct memory *m, struct flash_device *f) + bool program_rom_set(wxString device, int trans, struct memory *m, struct flash_device *f) { m->offset = 0; if(flash_device_get(device, f) == false){ @@ -227,26 +256,20 @@ private: m->transtype = TRANSTYPE_EMPTY; break; } - if(m->size == 0){ - m->transtype = TRANSTYPE_EMPTY; - } - if(f->capacity < m->size){ - *m_log << area << "area ROM image size is larger than target device"; - return false; - } return true; } +#if 1 void program_execute(void) { - struct config_flash f; + struct program_config f; - f.gauge_cpu.bar = m_program_cpu_gauge; - f.gauge_cpu.label = m_program_cpu_label; - gauge_init(&f.gauge_cpu); + f.cpu.gauge.bar = m_program_cpu_gauge; + f.cpu.gauge.label = m_program_cpu_value; + gauge_init(&f.cpu.gauge); - f.gauge_ppu.bar = m_program_ppu_gauge; - f.gauge_ppu.label = m_program_ppu_label; - gauge_init(&f.gauge_ppu); + f.ppu.gauge.bar = m_program_ppu_gauge; + f.ppu.gauge.label = m_program_ppu_value; + gauge_init(&f.ppu.gauge); f.log.object = m_log; f.log.append = text_append; @@ -261,34 +284,34 @@ private: return; } strncpy(f.target, str_rom.fn_str(), PROGRAM_TARGET_STR_LENGTH); - f.compare = false; + f.compare = m_program_compare->GetValue(); f.testrun = false; -//あとで struct config_flash の構造を見直す +#if 0 // if(nesfile_load(__FUNCTION__, f.target, &f.rom) == false){ if(nesfile_load(__FUNCTION__, str_rom.fn_str(), &f.rom) == false){ *m_log << str_rom << " open error\n"; return; } +#endif if(program_rom_set( - "CPU", m_program_cpu_device->GetStringSelection(), + m_program_cpu_device->GetStringSelection(), m_program_cpu_padding->GetSelection(), - &f.rom.cpu_rom, &f.flash_cpu + &f.cpu.memory, &f.cpu.flash ) == false){ return; } if(program_rom_set( - "PPU", m_program_ppu_device->GetStringSelection(), + m_program_ppu_device->GetStringSelection(), m_program_ppu_padding->GetSelection(), - &f.rom.ppu_rom, &f.flash_ppu + &f.ppu.memory, &f.ppu.flash ) == false){ return; } - f.reader = &DRIVER_KAZZO; - if(f.reader->open_or_close(READER_OPEN) == NG){ - *m_log << "reader open error\n"; - return; - } + f.control = &DRIVER_KAZZO.control; + f.cpu.access = &DRIVER_KAZZO.cpu; + f.ppu.access = &DRIVER_KAZZO.ppu; + f.control->open(&f.handle); m_program_script_choice->Disable(); m_program_romimage_picker->Disable(); @@ -299,10 +322,7 @@ private: m_program_ppu_padding->Disable(); m_program_ppu_device->Disable(); m_program_compare->Disable(); - f.reader->init(); -/* if(m_anago_thread != NULL){ - delete m_anago_thread; - }*/ + m_anago_thread = new anago_programmer(this, &f); if(m_anago_thread->Create() != wxTHREAD_NO_ERROR){ *m_log << "thread creating error"; @@ -312,6 +332,7 @@ private: m_status = STATUS_PROGRAMMING; } } + protected: void dump_button_click(wxCommandEvent& event) { @@ -388,6 +409,8 @@ public: m_dump_romimage_picker->Enable(); m_dump_check_battery->Enable(); m_dump_check_forcemapper->Enable(); + m_dump_cpu_increase->Enable(); + m_dump_ppu_increase->Enable(); m_dump_button->SetLabel(wxString("&dump")); if(m_dump_check_forcemapper->GetValue() == true){ m_dump_text_forcemapper->Enable(); @@ -413,21 +436,19 @@ public: void *anago_dumper::Entry(void) { script_dump_execute(&m_config); - m_config.reader->open_or_close(READER_CLOSE); + m_config.control->close(&m_config.handle); + m_config.handle.handle = NULL; m_frame->DumpThreadFinish(); return NULL; } void *anago_programmer::Entry(void) { - script_flash_execute(&m_config); - m_config.reader->open_or_close(READER_CLOSE); - nesbuffer_free(&m_config.rom, 0); + script_program_execute(&m_config); m_frame->ProgramThreadFinish(); return NULL; } - class MyApp : public wxApp { private: diff --git a/client/trunk/anago/anago_gui.cpp b/client/trunk/anago/anago_gui.cpp index 1f070f2..9693ac6 100644 --- a/client/trunk/anago/anago_gui.cpp +++ b/client/trunk/anago/anago_gui.cpp @@ -12,6 +12,7 @@ frame_main::frame_main( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + this->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) ); wxBoxSizer* bSizer4; bSizer4 = new wxBoxSizer( wxVERTICAL ); @@ -45,47 +46,80 @@ frame_main::frame_main( wxWindow* parent, wxWindowID id, const wxString& title, bSizer9->Add( fgSizer1, 0, wxEXPAND, 5 ); + m_staticline1 = new wxStaticLine( m_panel_dump, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer9->Add( m_staticline1, 0, wxALL|wxEXPAND, 2 ); + wxBoxSizer* bSizer12; bSizer12 = new wxBoxSizer( wxHORIZONTAL ); - m_dump_cpu_label = new wxStaticText( m_panel_dump, wxID_ANY, wxT("CPU"), wxDefaultPosition, wxDefaultSize, 0 ); + m_dump_cpu_label = new wxStaticText( m_panel_dump, wxID_ANY, wxT("Program ROM"), wxDefaultPosition, wxDefaultSize, 0 ); m_dump_cpu_label->Wrap( -1 ); - m_dump_cpu_label->SetMinSize( wxSize( 150,-1 ) ); + m_dump_cpu_label->SetMinSize( wxSize( 80,-1 ) ); bSizer12->Add( m_dump_cpu_label, 0, wxALL, 5 ); + m_dump_cpu_gauge = new wxGauge( m_panel_dump, wxID_ANY, 100, wxDefaultPosition, wxSize( -1,12 ), wxGA_HORIZONTAL ); + bSizer12->Add( m_dump_cpu_gauge, 1, wxALL|wxALIGN_CENTER_VERTICAL, 0 ); + + bSizer9->Add( bSizer12, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer14; + bSizer14 = new wxBoxSizer( wxHORIZONTAL ); + wxArrayString m_dump_cpu_increaseChoices; m_dump_cpu_increase = new wxChoice( m_panel_dump, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_dump_cpu_increaseChoices, 0 ); m_dump_cpu_increase->SetSelection( 0 ); m_dump_cpu_increase->SetMinSize( wxSize( 60,-1 ) ); - bSizer12->Add( m_dump_cpu_increase, 0, wxALL, 5 ); + bSizer14->Add( m_dump_cpu_increase, 0, wxALL, 5 ); - bSizer9->Add( bSizer12, 1, wxEXPAND, 5 ); + m_dump_cpu_value = new wxStaticText( m_panel_dump, wxID_ANY, wxT("0x000000/0x000000"), wxDefaultPosition, wxDefaultSize, 0 ); + m_dump_cpu_value->Wrap( -1 ); + m_dump_cpu_value->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); + m_dump_cpu_value->SetMinSize( wxSize( 120,-1 ) ); - m_dump_cpu_gauge = new wxGauge( m_panel_dump, wxID_ANY, 100, wxDefaultPosition, wxSize( -1,12 ), wxGA_HORIZONTAL ); - bSizer9->Add( m_dump_cpu_gauge, 0, wxALL|wxEXPAND, 0 ); + bSizer14->Add( m_dump_cpu_value, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + bSizer9->Add( bSizer14, 1, wxALIGN_RIGHT, 5 ); + + m_staticline2 = new wxStaticLine( m_panel_dump, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer9->Add( m_staticline2, 0, wxEXPAND | wxALL, 2 ); wxBoxSizer* bSizer13; bSizer13 = new wxBoxSizer( wxHORIZONTAL ); - m_dump_ppu_label = new wxStaticText( m_panel_dump, wxID_ANY, wxT("PPU"), wxDefaultPosition, wxDefaultSize, 0 ); + m_dump_ppu_label = new wxStaticText( m_panel_dump, wxID_ANY, wxT("Charcter ROM"), wxDefaultPosition, wxDefaultSize, 0 ); m_dump_ppu_label->Wrap( -1 ); - m_dump_ppu_label->SetMinSize( wxSize( 150,-1 ) ); + m_dump_ppu_label->SetMinSize( wxSize( 80,-1 ) ); bSizer13->Add( m_dump_ppu_label, 0, wxALL, 5 ); + m_dump_ppu_gauge = new wxGauge( m_panel_dump, wxID_ANY, 100, wxDefaultPosition, wxSize( -1,12 ), wxGA_HORIZONTAL ); + bSizer13->Add( m_dump_ppu_gauge, 1, wxALL|wxALIGN_CENTER_VERTICAL, 0 ); + + bSizer9->Add( bSizer13, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer132; + bSizer132 = new wxBoxSizer( wxHORIZONTAL ); + wxArrayString m_dump_ppu_increaseChoices; m_dump_ppu_increase = new wxChoice( m_panel_dump, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_dump_ppu_increaseChoices, 0 ); m_dump_ppu_increase->SetSelection( 0 ); m_dump_ppu_increase->SetMinSize( wxSize( 60,-1 ) ); - bSizer13->Add( m_dump_ppu_increase, 0, wxALL, 5 ); + bSizer132->Add( m_dump_ppu_increase, 0, wxALL, 5 ); - bSizer9->Add( bSizer13, 1, wxEXPAND, 5 ); + m_dump_ppu_value = new wxStaticText( m_panel_dump, wxID_ANY, wxT("0x000000/0x000000"), wxDefaultPosition, wxDefaultSize, 0 ); + m_dump_ppu_value->Wrap( -1 ); + m_dump_ppu_value->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); + m_dump_ppu_value->SetMinSize( wxSize( 120,-1 ) ); - m_dump_ppu_gauge = new wxGauge( m_panel_dump, wxID_ANY, 100, wxDefaultPosition, wxSize( -1,12 ), wxGA_HORIZONTAL ); - bSizer9->Add( m_dump_ppu_gauge, 0, wxALL|wxEXPAND, 0 ); + bSizer132->Add( m_dump_ppu_value, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + bSizer9->Add( bSizer132, 1, wxALIGN_RIGHT, 5 ); + + m_staticline3 = new wxStaticLine( m_panel_dump, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer9->Add( m_staticline3, 0, wxEXPAND | wxALL, 2 ); wxBoxSizer* bSizer61; bSizer61 = new wxBoxSizer( wxHORIZONTAL ); @@ -110,7 +144,7 @@ frame_main::frame_main( wxWindow* parent, wxWindowID id, const wxString& title, m_panel_dump->SetSizer( bSizer9 ); m_panel_dump->Layout(); bSizer9->Fit( m_panel_dump ); - m_notebook3->AddPage( m_panel_dump, wxT("dump"), false ); + m_notebook3->AddPage( m_panel_dump, wxT("dump"), true ); m_panel_program = new wxPanel( m_notebook3, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer91; bSizer91 = new wxBoxSizer( wxVERTICAL ); @@ -130,89 +164,112 @@ frame_main::frame_main( wxWindow* parent, wxWindowID id, const wxString& title, m_program_script_choice->SetSelection( 0 ); fgSizer11->Add( m_program_script_choice, 0, wxALL|wxEXPAND, 5 ); - m_program_romimage_label = new wxStaticText( m_panel_program, wxID_ANY, wxT("&ROM image"), wxDefaultPosition, wxDefaultSize, 0 ); - m_program_romimage_label->Wrap( -1 ); - fgSizer11->Add( m_program_romimage_label, 0, wxALL, 5 ); + m_program_label = new wxStaticText( m_panel_program, wxID_ANY, wxT("&ROM image"), wxDefaultPosition, wxDefaultSize, 0 ); + m_program_label->Wrap( -1 ); + fgSizer11->Add( m_program_label, 0, wxALL, 5 ); m_program_romimage_picker = new wxFilePickerCtrl( m_panel_program, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.nes"), wxDefaultPosition, wxDefaultSize, wxFLP_DEFAULT_STYLE|wxFLP_FILE_MUST_EXIST ); fgSizer11->Add( m_program_romimage_picker, 0, wxALL|wxEXPAND, 5 ); bSizer91->Add( fgSizer11, 0, wxEXPAND, 5 ); + m_staticline11 = new wxStaticLine( m_panel_program, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer91->Add( m_staticline11, 0, wxALL|wxEXPAND, 2 ); + wxBoxSizer* bSizer121; bSizer121 = new wxBoxSizer( wxHORIZONTAL ); - m_program_cpu_label = new wxStaticText( m_panel_program, wxID_ANY, wxT("CPU"), wxDefaultPosition, wxDefaultSize, 0 ); + m_program_cpu_label = new wxStaticText( m_panel_program, wxID_ANY, wxT("Program flash"), wxDefaultPosition, wxDefaultSize, 0 ); m_program_cpu_label->Wrap( -1 ); - m_program_cpu_label->SetMinSize( wxSize( 150,-1 ) ); + m_program_cpu_label->SetMinSize( wxSize( 80,-1 ) ); bSizer121->Add( m_program_cpu_label, 0, wxALL, 5 ); - wxBoxSizer* bSizer31; - bSizer31 = new wxBoxSizer( wxHORIZONTAL ); + m_program_cpu_gauge = new wxGauge( m_panel_program, wxID_ANY, 100, wxDefaultPosition, wxSize( -1,12 ), wxGA_HORIZONTAL ); + bSizer121->Add( m_program_cpu_gauge, 1, wxALL|wxALIGN_CENTER_VERTICAL, 0 ); + + bSizer91->Add( bSizer121, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer141; + bSizer141 = new wxBoxSizer( wxHORIZONTAL ); wxArrayString m_program_cpu_deviceChoices; m_program_cpu_device = new wxChoice( m_panel_program, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_program_cpu_deviceChoices, 0 ); m_program_cpu_device->SetSelection( 0 ); - m_program_cpu_device->SetMinSize( wxSize( 80,-1 ) ); + m_program_cpu_device->SetMinSize( wxSize( 100,-1 ) ); - bSizer31->Add( m_program_cpu_device, 0, wxALL, 5 ); + bSizer141->Add( m_program_cpu_device, 0, wxALL, 5 ); wxArrayString m_program_cpu_paddingChoices; m_program_cpu_padding = new wxChoice( m_panel_program, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_program_cpu_paddingChoices, 0 ); m_program_cpu_padding->SetSelection( 0 ); m_program_cpu_padding->SetMinSize( wxSize( 60,-1 ) ); - bSizer31->Add( m_program_cpu_padding, 0, wxALL, 5 ); + bSizer141->Add( m_program_cpu_padding, 0, wxALL, 5 ); - bSizer121->Add( bSizer31, 1, wxEXPAND, 5 ); + m_program_cpu_value = new wxStaticText( m_panel_program, wxID_ANY, wxT("0x000000/0x000000"), wxDefaultPosition, wxDefaultSize, 0 ); + m_program_cpu_value->Wrap( -1 ); + m_program_cpu_value->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); + m_program_cpu_value->SetMinSize( wxSize( 120,-1 ) ); - bSizer91->Add( bSizer121, 1, wxEXPAND, 5 ); + bSizer141->Add( m_program_cpu_value, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_program_cpu_gauge = new wxGauge( m_panel_program, wxID_ANY, 100, wxDefaultPosition, wxSize( -1,12 ), wxGA_HORIZONTAL ); - bSizer91->Add( m_program_cpu_gauge, 0, wxALL|wxEXPAND, 0 ); + bSizer91->Add( bSizer141, 1, wxALIGN_RIGHT, 5 ); + + m_staticline21 = new wxStaticLine( m_panel_program, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer91->Add( m_staticline21, 0, wxEXPAND | wxALL, 2 ); wxBoxSizer* bSizer131; bSizer131 = new wxBoxSizer( wxHORIZONTAL ); - m_program_ppu_label = new wxStaticText( m_panel_program, wxID_ANY, wxT("PPU"), wxDefaultPosition, wxDefaultSize, 0 ); + m_program_ppu_label = new wxStaticText( m_panel_program, wxID_ANY, wxT("Charcter flash"), wxDefaultPosition, wxDefaultSize, 0 ); m_program_ppu_label->Wrap( -1 ); - m_program_ppu_label->SetMinSize( wxSize( 150,-1 ) ); + m_program_ppu_label->SetMinSize( wxSize( 80,-1 ) ); bSizer131->Add( m_program_ppu_label, 0, wxALL, 5 ); - wxBoxSizer* bSizer30; - bSizer30 = new wxBoxSizer( wxHORIZONTAL ); + m_program_ppu_gauge = new wxGauge( m_panel_program, wxID_ANY, 100, wxDefaultPosition, wxSize( -1,12 ), wxGA_HORIZONTAL ); + bSizer131->Add( m_program_ppu_gauge, 1, wxALL|wxALIGN_CENTER_VERTICAL, 0 ); + + bSizer91->Add( bSizer131, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer1321; + bSizer1321 = new wxBoxSizer( wxHORIZONTAL ); wxArrayString m_program_ppu_deviceChoices; - m_program_ppu_device = new wxChoice( m_panel_program, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), m_program_ppu_deviceChoices, 0 ); + m_program_ppu_device = new wxChoice( m_panel_program, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_program_ppu_deviceChoices, 0 ); m_program_ppu_device->SetSelection( 0 ); - m_program_ppu_device->SetMinSize( wxSize( 80,-1 ) ); + m_program_ppu_device->SetMinSize( wxSize( 100,-1 ) ); - bSizer30->Add( m_program_ppu_device, 0, wxALL, 5 ); + bSizer1321->Add( m_program_ppu_device, 0, wxALL, 5 ); wxArrayString m_program_ppu_paddingChoices; m_program_ppu_padding = new wxChoice( m_panel_program, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_program_ppu_paddingChoices, 0 ); m_program_ppu_padding->SetSelection( 0 ); m_program_ppu_padding->SetMinSize( wxSize( 60,-1 ) ); - bSizer30->Add( m_program_ppu_padding, 0, wxALL, 5 ); + bSizer1321->Add( m_program_ppu_padding, 0, wxALL, 5 ); - bSizer131->Add( bSizer30, 0, 0, 5 ); + m_program_ppu_value = new wxStaticText( m_panel_program, wxID_ANY, wxT("0x000000/0x000000"), wxDefaultPosition, wxDefaultSize, 0 ); + m_program_ppu_value->Wrap( -1 ); + m_program_ppu_value->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); + m_program_ppu_value->SetMinSize( wxSize( 120,-1 ) ); - bSizer91->Add( bSizer131, 1, wxALIGN_RIGHT|wxEXPAND, 5 ); + bSizer1321->Add( m_program_ppu_value, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_program_ppu_gauge = new wxGauge( m_panel_program, wxID_ANY, 100, wxDefaultPosition, wxSize( -1,12 ), wxGA_HORIZONTAL ); - bSizer91->Add( m_program_ppu_gauge, 0, wxALL|wxEXPAND, 0 ); + bSizer91->Add( bSizer1321, 1, wxALIGN_RIGHT, 5 ); + + m_staticline31 = new wxStaticLine( m_panel_program, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer91->Add( m_staticline31, 0, wxEXPAND | wxALL, 2 ); wxBoxSizer* bSizer611; bSizer611 = new wxBoxSizer( wxHORIZONTAL ); - m_program_compare = new wxCheckBox( m_panel_program, wxID_ANY, wxT("compare"), wxDefaultPosition, wxDefaultSize, 0 ); + m_program_compare = new wxCheckBox( m_panel_program, wxID_ANY, wxT("&compare"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer611->Add( m_program_compare, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_program_button = new wxButton( m_panel_program, wxID_ANY, wxT("&program"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer611->Add( m_program_button, 0, wxALL|wxALIGN_BOTTOM, 5 ); + bSizer611->Add( m_program_button, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); bSizer91->Add( bSizer611, 0, wxALIGN_RIGHT, 5 ); @@ -220,6 +277,17 @@ frame_main::frame_main( wxWindow* parent, wxWindowID id, const wxString& title, m_panel_program->Layout(); bSizer91->Fit( m_panel_program ); m_notebook3->AddPage( m_panel_program, wxT("program"), false ); + m_panel4 = new wxPanel( m_notebook3, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer30; + bSizer30 = new wxBoxSizer( wxVERTICAL ); + + m_bitmap1 = new wxStaticBitmap( m_panel4, wxID_ANY, wxBitmap( wxT("tubami.bmp"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer30->Add( m_bitmap1, 0, wxALL, 5 ); + + m_panel4->SetSizer( bSizer30 ); + m_panel4->Layout(); + bSizer30->Fit( m_panel4 ); + m_notebook3->AddPage( m_panel4, wxT("a page"), false ); bSizer4->Add( m_notebook3, 0, wxALL|wxEXPAND, 0 ); @@ -228,6 +296,8 @@ frame_main::frame_main( wxWindow* parent, wxWindowID id, const wxString& title, bSizer6 = new wxBoxSizer( wxVERTICAL ); m_log = new wxTextCtrl( m_panel_log, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); + m_log->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); + bSizer6->Add( m_log, 1, wxALL|wxEXPAND, 5 ); m_panel_log->SetSizer( bSizer6 ); diff --git a/client/trunk/anago/anago_gui.fbp b/client/trunk/anago/anago_gui.fbp index 1d25ad1..af93c51 100644 --- a/client/trunk/anago/anago_gui.fbp +++ b/client/trunk/anago/anago_gui.fbp @@ -30,7 +30,7 @@ impl_virtual - + ,90,90,-1,70,0 0 wxID_ANY @@ -142,7 +142,7 @@ dump - 0 + 1 @@ -440,6 +440,60 @@ + 2 + wxALL|wxEXPAND + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_staticline1 + protected + + + wxLI_HORIZONTAL + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxEXPAND 1 @@ -461,9 +515,9 @@ 0 wxID_ANY - CPU + Program ROM - 150,-1 + 80,-1 m_dump_cpu_label protected @@ -505,12 +559,11 @@ - 5 - wxALL - 0 - + 0 + wxALL|wxALIGN_CENTER_VERTICAL + 1 + - 1 1 @@ -519,23 +572,24 @@ 0 wxID_ANY - 60,-1 - m_dump_cpu_increase + + m_dump_cpu_gauge protected - 0 - + 100 + -1,12 + wxGA_HORIZONTAL wxFILTER_NONE wxDefaultValidator + - @@ -562,77 +616,22 @@ - - 0 - wxALL|wxEXPAND - 0 - - - - 1 - 1 - - - 0 - wxID_ANY - - - m_dump_cpu_gauge - protected - - 100 - -1,12 - wxGA_HORIZONTAL - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 5 - wxEXPAND + wxALIGN_RIGHT 1 - + - bSizer13 + bSizer14 wxHORIZONTAL none 5 wxALL 0 - + + 1 1 @@ -640,14 +639,13 @@ 0 wxID_ANY - PPU - 150,-1 - m_dump_ppu_label + 60,-1 + m_dump_cpu_increase protected + 0 - @@ -657,8 +655,8 @@ - -1 + @@ -685,25 +683,25 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL 0 - + - 1 1 - + ,90,90,-1,76,0 0 wxID_ANY + 0x000000/0x000000 - 60,-1 - m_dump_ppu_increase + 120,-1 + m_dump_cpu_value protected - 0 + @@ -713,8 +711,8 @@ + -1 - @@ -742,10 +740,10 @@ - 0 - wxALL|wxEXPAND + 2 + wxEXPAND | wxALL 0 - + 1 @@ -756,19 +754,17 @@ wxID_ANY - m_dump_ppu_gauge + m_staticline2 protected - 100 - -1,12 - wxGA_HORIZONTAL + + wxLI_HORIZONTAL wxFILTER_NONE wxDefaultValidator - @@ -797,22 +793,21 @@ - + 5 - wxALIGN_RIGHT - 0 - + wxEXPAND + 1 + - bSizer61 + bSizer13 wxHORIZONTAL none 5 - wxALL|wxALIGN_CENTER_VERTICAL + wxALL 0 - + - 0 1 1 @@ -820,10 +815,10 @@ 0 wxID_ANY - &battery + Charcter ROM - - m_dump_check_battery + 80,-1 + m_dump_ppu_label protected @@ -837,8 +832,8 @@ + -1 - @@ -864,12 +859,11 @@ - 5 + 0 wxALL|wxALIGN_CENTER_VERTICAL - 0 - + 1 + - 0 1 1 @@ -877,25 +871,25 @@ 0 wxID_ANY - &change mapper - m_dump_check_forcemapper + m_dump_ppu_gauge protected - - + 100 + -1,12 + wxGA_HORIZONTAL wxFILTER_NONE wxDefaultValidator + - mapper_change_check @@ -920,38 +914,49 @@ + + + + 5 + wxALIGN_RIGHT + 1 + + + bSizer132 + wxHORIZONTAL + none 5 - wxALL|wxALIGN_CENTER_VERTICAL + wxALL 0 - + + 1 - 0 + 1 0 wxID_ANY - 0 - 40,-1 - m_dump_text_forcemapper + 60,-1 + m_dump_ppu_increase protected + 0 - wxFILTER_NONE wxDefaultValidator - + @@ -973,10 +978,6 @@ - - - - @@ -984,20 +985,19 @@ 5 wxALL|wxALIGN_CENTER_VERTICAL 0 - + 1 - 0 1 - + ,90,90,-1,76,0 0 wxID_ANY - &dump + 0x000000/0x000000 - - m_dump_button + 120,-1 + m_dump_ppu_value protected @@ -1011,7 +1011,7 @@ - dump_button_click + -1 @@ -1039,48 +1039,344 @@ - - - - - - program - 0 - - - - 1 - 1 - - - 0 - wxID_ANY - - - m_panel_program - protected - - - - - - wxFILTER_NONE - wxDefaultValidator - - - - wxTAB_TRAVERSAL - - - - - - - - - - - + + 2 + wxEXPAND | wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_staticline3 + protected + + + wxLI_HORIZONTAL + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_RIGHT + 0 + + + bSizer61 + wxHORIZONTAL + none + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + &battery + + + m_dump_check_battery + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + + 0 + + 1 + 1 + + + 0 + wxID_ANY + &change mapper + + + m_dump_check_forcemapper + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + mapper_change_check + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + + + 1 + 0 + + + 0 + wxID_ANY + + 0 + 40,-1 + m_dump_text_forcemapper + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + + + 1 + 0 + 1 + + + 0 + wxID_ANY + &dump + + + m_dump_button + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + dump_button_click + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + program + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_panel_program + protected + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + wxTAB_TRAVERSAL + + + + + + + + + + + @@ -1093,33 +1389,448 @@ - + bSizer91 wxVERTICAL none 5 - wxEXPAND - 0 - - 2 - wxBOTH - 1 - - 0 + wxEXPAND + 0 + + 2 + wxBOTH + 1 + + 0 + + fgSizer11 + wxFLEX_GROWMODE_SPECIFIED + none + 2 + 0 + + 5 + wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + &script + + + m_program_script_label + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_program_script_choice + protected + + 0 + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + &ROM image + + + m_program_label + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + + Select a file + + m_program_romimage_picker + protected + + + wxFLP_DEFAULT_STYLE|wxFLP_FILE_MUST_EXIST + + + + wxFILTER_NONE + wxDefaultValidator + + + *.nes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + wxALL|wxEXPAND + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_staticline11 + protected + + + wxLI_HORIZONTAL + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer121 + wxHORIZONTAL + none + + 5 + wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + Program flash + + 80,-1 + m_program_cpu_label + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxALL|wxALIGN_CENTER_VERTICAL + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_program_cpu_gauge + protected + + 100 + -1,12 + wxGA_HORIZONTAL + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_RIGHT + 1 + - fgSizer11 - wxFLEX_GROWMODE_SPECIFIED + bSizer141 + wxHORIZONTAL none - 2 - 0 5 wxALL 0 - + + 1 1 @@ -1127,10 +1838,121 @@ 0 wxID_ANY - &script - - m_program_script_label + 100,-1 + m_program_cpu_device + protected + + 0 + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + + + 1 + 1 + + + 0 + wxID_ANY + + 60,-1 + m_program_cpu_padding + protected + + 0 + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + + + 1 + 1 + + ,90,90,-1,76,0 + 0 + wxID_ANY + 0x000000/0x000000 + + 120,-1 + m_program_cpu_value protected @@ -1170,13 +1992,77 @@ + + + + 2 + wxEXPAND | wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_staticline21 + protected + + + wxLI_HORIZONTAL + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer131 + wxHORIZONTAL + none 5 - wxALL|wxEXPAND + wxALL 0 - + - 1 1 @@ -1184,13 +2070,14 @@ 0 wxID_ANY + Charcter flash - - m_program_script_choice + 80,-1 + m_program_ppu_label protected - 0 + @@ -1200,8 +2087,8 @@ + -1 - @@ -1227,10 +2114,10 @@ - 5 - wxALL - 0 - + 0 + wxALL|wxALIGN_CENTER_VERTICAL + 1 + 1 @@ -1239,24 +2126,24 @@ 0 wxID_ANY - &ROM image - m_program_romimage_label + m_program_ppu_gauge protected - - + 100 + -1,12 + wxGA_HORIZONTAL wxFILTER_NONE wxDefaultValidator + - -1 @@ -1282,12 +2169,24 @@ + + + + 5 + wxALIGN_RIGHT + 1 + + + bSizer1321 + wxHORIZONTAL + none 5 - wxALL|wxEXPAND + wxALL 0 - + + 1 1 @@ -1296,28 +2195,25 @@ 0 wxID_ANY - Select a file - - m_program_romimage_picker + 100,-1 + m_program_ppu_device protected + 0 - wxFLP_DEFAULT_STYLE|wxFLP_FILE_MUST_EXIST wxFILTER_NONE wxDefaultValidator - - *.nes + - @@ -1340,23 +2236,13 @@ - - - - 5 - wxEXPAND - 1 - - - bSizer121 - wxHORIZONTAL - none 5 wxALL 0 - + + 1 1 @@ -1364,14 +2250,13 @@ 0 wxID_ANY - CPU - 150,-1 - m_program_cpu_label + 60,-1 + m_program_ppu_padding protected + 0 - @@ -1381,8 +2266,8 @@ - -1 + @@ -1409,197 +2294,7 @@ 5 - wxEXPAND - 1 - - - bSizer31 - wxHORIZONTAL - none - - 5 - wxALL - 0 - - - - - 1 - 1 - - - 0 - wxID_ANY - - 80,-1 - m_program_cpu_device - protected - - 0 - - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - - - 1 - 1 - - - 0 - wxID_ANY - - 60,-1 - m_program_cpu_padding - protected - - 0 - - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxALL|wxEXPAND - 0 - - - - 1 - 1 - - - 0 - wxID_ANY - - - m_program_cpu_gauge - protected - - 100 - -1,12 - wxGA_HORIZONTAL - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_RIGHT|wxEXPAND - 1 - - - bSizer131 - wxHORIZONTAL - none - - 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL 0 @@ -1607,13 +2302,13 @@ 1 1 - + ,90,90,-1,76,0 0 wxID_ANY - PPU + 0x000000/0x000000 - 150,-1 - m_program_ppu_label + 120,-1 + m_program_ppu_value protected @@ -1653,136 +2348,13 @@ - - 5 - - 0 - - - bSizer30 - wxHORIZONTAL - none - - 5 - wxALL - 0 - - - - - 1 - 1 - - - 0 - wxID_ANY - - 80,-1 - m_program_ppu_device - protected - - 0 - -1,-1 - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - - - 1 - 1 - - - 0 - wxID_ANY - - 60,-1 - m_program_ppu_padding - protected - - 0 - - - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - wxALL|wxEXPAND + 2 + wxEXPAND | wxALL 0 - + 1 @@ -1793,19 +2365,17 @@ wxID_ANY - m_program_ppu_gauge + m_staticline31 protected - 100 - -1,12 - wxGA_HORIZONTAL + + wxLI_HORIZONTAL wxFILTER_NONE wxDefaultValidator - @@ -1857,7 +2427,7 @@ 0 wxID_ANY - compare + &compare m_program_compare @@ -1902,7 +2472,7 @@ 5 - wxALL|wxALIGN_BOTTOM + wxALL|wxALIGN_CENTER_VERTICAL 0 @@ -1962,6 +2532,119 @@ + + + a page + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_panel4 + protected + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer30 + wxVERTICAL + none + + 5 + wxALL + 0 + + + tubami.bmp; Load From File + + 1 + 1 + + + 0 + wxID_ANY + + + m_bitmap1 + protected + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2030,7 +2713,7 @@ 1 1 - + ,90,90,-1,76,0 0 wxID_ANY diff --git a/client/trunk/anago/anago_gui.h b/client/trunk/anago/anago_gui.h index 6c1d2a8..9caf7ab 100644 --- a/client/trunk/anago/anago_gui.h +++ b/client/trunk/anago/anago_gui.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include #include #include @@ -45,12 +47,17 @@ class frame_main : public wxFrame wxChoice* m_dump_script_choice; wxStaticText* m_dump_romimage_label; wxFilePickerCtrl* m_dump_romimage_picker; + wxStaticLine* m_staticline1; wxStaticText* m_dump_cpu_label; - wxChoice* m_dump_cpu_increase; wxGauge* m_dump_cpu_gauge; + wxChoice* m_dump_cpu_increase; + wxStaticText* m_dump_cpu_value; + wxStaticLine* m_staticline2; wxStaticText* m_dump_ppu_label; - wxChoice* m_dump_ppu_increase; wxGauge* m_dump_ppu_gauge; + wxChoice* m_dump_ppu_increase; + wxStaticText* m_dump_ppu_value; + wxStaticLine* m_staticline3; wxCheckBox* m_dump_check_battery; wxCheckBox* m_dump_check_forcemapper; wxTextCtrl* m_dump_text_forcemapper; @@ -58,18 +65,25 @@ class frame_main : public wxFrame wxPanel* m_panel_program; wxStaticText* m_program_script_label; wxChoice* m_program_script_choice; - wxStaticText* m_program_romimage_label; + wxStaticText* m_program_label; wxFilePickerCtrl* m_program_romimage_picker; + wxStaticLine* m_staticline11; wxStaticText* m_program_cpu_label; + wxGauge* m_program_cpu_gauge; wxChoice* m_program_cpu_device; wxChoice* m_program_cpu_padding; - wxGauge* m_program_cpu_gauge; + wxStaticText* m_program_cpu_value; + wxStaticLine* m_staticline21; wxStaticText* m_program_ppu_label; + wxGauge* m_program_ppu_gauge; wxChoice* m_program_ppu_device; wxChoice* m_program_ppu_padding; - wxGauge* m_program_ppu_gauge; + wxStaticText* m_program_ppu_value; + wxStaticLine* m_staticline31; wxCheckBox* m_program_compare; wxButton* m_program_button; + wxPanel* m_panel4; + wxStaticBitmap* m_bitmap1; wxPanel* m_panel_log; wxTextCtrl* m_log; diff --git a/client/trunk/anago/script_dump.c b/client/trunk/anago/script_dump.c index 9ce3663..6920be1 100644 --- a/client/trunk/anago/script_dump.c +++ b/client/trunk/anago/script_dump.c @@ -14,20 +14,7 @@ #include "script_common.h" #include "script_dump.h" -struct dump_driver{ - const char *target; - struct memory_driver{ - struct memory memory; - long read_count; - void (*const write)(long address, long length, const uint8_t *data); - void (*const read)(long address, long length, u8 *data); - struct gauge *const gauge; - }cpu, ppu; - uint8_t (*const vram_connection)(void); - bool progress; - struct textcontrol *const log; -}; -static SQInteger write_memory(HSQUIRRELVM v, struct memory_driver *t) +static SQInteger write_memory(HSQUIRRELVM v, const struct reader_handle *h, struct dump_memory_driver *t) { long address, data; SQRESULT r = qr_argument_get(v, 2, &address, &data); @@ -35,17 +22,17 @@ static SQInteger write_memory(HSQUIRRELVM v, struct memory_driver *t) return r; } uint8_t d8 = (uint8_t) data; - t->write(address, 1, &d8); + t->access->memory_write(h, address, 1, &d8); return 0; } static SQInteger cpu_write(HSQUIRRELVM v) { - struct dump_driver *d; + struct dump_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - return write_memory(v, &d->cpu); + return write_memory(v, &d->handle, &d->cpu); } //¤³¤³¤Î printf ¤Ï debug ÍѤ˻Ĥ·¤Æ¤ª¤¯ @@ -81,54 +68,48 @@ static void buffer_show(struct memory *t, long length) fflush(stdout); } -static void progress_show(struct memory_driver *d, const char *area) -{ - char str[80]; - d->gauge->value_set(d->gauge->bar, d->memory.offset); - snprintf(str, 80, "%s 0x%06x/0x%06x", area, d->memory.offset, d->memory.size); - d->gauge->label_set(d->gauge->label, str); -} -static SQInteger read_memory(HSQUIRRELVM v, struct memory_driver *t, bool progress) +static SQInteger read_memory(HSQUIRRELVM v, const struct reader_handle *h, struct dump_memory_driver *t, bool progress) { long address, length; SQRESULT r = qr_argument_get(v, 2, &address, &length); if(SQ_FAILED(r)){ return r; } - t->read(address, length == 0 ? 1: length, t->memory.data + t->memory.offset); + t->access->memory_read(h, &t->gauge, address, length == 0 ? 1: length, t->memory.data + t->memory.offset); if((length != 0) && (progress == false)){ buffer_show(&t->memory, length); } t->memory.offset += length; + //progress_show(t); + return 0; } + static SQInteger cpu_read(HSQUIRRELVM v) { - struct dump_driver *d; + struct dump_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - r = read_memory(v, &d->cpu, d->progress); - progress_show(&d->cpu, "CPU"); + r = read_memory(v, &d->handle, &d->cpu, d->progress); return r; } static SQInteger ppu_read(HSQUIRRELVM v) { - struct dump_driver *d; + struct dump_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - r = read_memory(v, &d->ppu, d->progress); - progress_show(&d->ppu, "PPU"); + r = read_memory(v, &d->handle, &d->ppu, d->progress); return r; } static SQInteger ppu_ramfind(HSQUIRRELVM v) { - struct dump_driver *d; + struct dump_config *d; enum{ testsize = 8, testaddress = 1234 @@ -136,42 +117,43 @@ static SQInteger ppu_ramfind(HSQUIRRELVM v) static const uint8_t test_val[testsize] = {0xaa, 0x55, 0, 0xff, 0x46, 0x49, 0x07, 0x21}; static const uint8_t test_str[testsize] = "pputest"; uint8_t test_result[testsize]; - SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); + struct dump_memory_driver *p = &d->ppu; + if(SQ_FAILED(r)){ return r; } - d->ppu.write(testaddress, testsize, test_val); - d->ppu.read(testaddress, testsize, test_result); + p->access->memory_write(&d->handle, testaddress, testsize, test_val); + p->access->memory_read(&d->handle, &GAUGE_DUMMY, testaddress, testsize, test_result); if(memcmp(test_val, test_result, testsize) != 0){ sq_pushbool(v, SQFalse); return 1; } - d->ppu.write(testaddress, testsize, test_str); - d->ppu.read(testaddress, testsize, test_result); + p->access->memory_write(&d->handle, testaddress, testsize, test_str); + p->access->memory_read(&d->handle, &GAUGE_DUMMY, testaddress, testsize, test_result); if(memcmp(test_str, test_result, testsize) != 0){ sq_pushbool(v, SQFalse); return 1; } - d->ppu.memory.offset = 0; - d->ppu.memory.size = 0; + p->memory.offset = 0; + p->memory.size = 0; sq_pushbool(v, SQTrue); return 1; } -static void memory_new_init(struct memory_driver *d, const char *area) +static void memory_new_init(struct dump_memory_driver *d) { d->memory.offset = 0; d->memory.data = Malloc(d->memory.size); - d->gauge->value_set(d->gauge->bar, 0); - d->gauge->range_set(d->gauge->bar, d->memory.size); - d->gauge->label_set(d->gauge->label, area); + d->gauge.value_set(d->gauge.bar, d->gauge.label, 0); + d->gauge.range_set(d->gauge.bar, d->memory.size); +// d->gauge.label_set(d->gauge.label, d->memory.name); } //test »þ/1ÅÙÌܤΠcall ¤Ç»ÈÍÑ static SQInteger memory_new(HSQUIRRELVM v) { - struct dump_driver *d; + struct dump_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; @@ -188,15 +170,15 @@ static SQInteger memory_new(HSQUIRRELVM v) d->ppu.memory.data = Malloc(d->ppu.memory.size); d->cpu.gauge->value_set(0); d->ppu.gauge->range_set(d->ppu.gauge->object, d->ppu.memory.size);*/ - memory_new_init(&d->cpu, "CPU"); - memory_new_init(&d->ppu, "PPU"); + memory_new_init(&d->cpu); + memory_new_init(&d->ppu); return 0; } //dump »þ/2ÅÙÌܤΠcall ¤Ç nesfile_save ¤È¤·¤Æ»ÈÍÑ static SQInteger nesfile_save(HSQUIRRELVM v) { - struct dump_driver *d; + struct dump_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; @@ -212,14 +194,14 @@ static SQInteger nesfile_save(HSQUIRRELVM v) image.ppu_rom = d->ppu.memory; image.mirror = MIRROR_PROGRAMABLE; if(mirrorfind == 1){ - if(d->vram_connection() == 0x05){ + if(d->control->vram_connection(&d->handle) == 0x05){ image.mirror = MIRROR_VERTICAL; }else{ image.mirror = MIRROR_HORIZONAL; } } image.backupram = 0; - nesfile_create(d->log, &image, d->target); + nesfile_create(&d->log, &image, d->target); nesbuffer_free(&image, 0); //0 is MODE_xxx_xxxx d->cpu.memory.data = NULL; @@ -230,7 +212,7 @@ static SQInteger nesfile_save(HSQUIRRELVM v) //dump »þ/1ÅÙÌܤΠcall ¤Ç nesfile_save ¤È¤·¤Æ»ÈÍÑ static SQInteger length_check(HSQUIRRELVM v) { - struct dump_driver *d; + struct dump_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; @@ -243,14 +225,14 @@ static SQInteger length_check(HSQUIRRELVM v) char str[80]; if(cpu == false){ snprintf(str, 80, "cpu_romsize is not connected 0x%06x/0x%06x\n", (int) d->cpu.read_count, (int) d->cpu.memory.size); - d->log->append(d->log->object, str); + d->log.append(d->log.object, str); } if(d->ppu.memory.size != d->ppu.read_count){ ppu = false; } if(ppu == false){ snprintf(str, 80, "ppu_romsize is not connected 0x%06x/0x%06x\n", (int) d->ppu.read_count, (int) d->ppu.memory.size); - d->log->append(d->log->object, str); + d->log.append(d->log.object, str); } if(cpu == false || ppu == false){ r = sq_throwerror(v, "script logical error"); @@ -258,7 +240,7 @@ static SQInteger length_check(HSQUIRRELVM v) return r; } -static SQInteger read_count(HSQUIRRELVM v, struct textcontrol *l, struct memory_driver *t, const struct range *range_address, const struct range *range_length) +static SQInteger read_count(HSQUIRRELVM v, struct textcontrol *l, struct dump_memory_driver *t, const struct range *range_address, const struct range *range_length) { long address, length; SQRESULT r = qr_argument_get(v, 2, &address, &length); @@ -283,41 +265,41 @@ static SQInteger cpu_read_count(HSQUIRRELVM v) static const struct range range_address = {0x8000, 0x10000}; //length == 0 ¤Ï Âоݥ¢¥É¥ì¥¹¤ò¸Æ¤ó¤Ç¡¢¥Ð¥Ã¥Õ¥¡¤Ë¤¤¤ì¤Ê¤¤¡£mmc2, mmc4 ¤Ç»ÈÍѤ¹¤ë¡£ static const struct range range_length = {0x0000, 0x4000}; - struct dump_driver *d; + struct dump_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - return read_count(v, d->log, &d->cpu, &range_address, &range_length); + return read_count(v, &d->log, &d->cpu, &range_address, &range_length); } static SQInteger ppu_read_count(HSQUIRRELVM v) { static const struct range range_address = {0x0000, 0x2000}; static const struct range range_length = {0x0001, 0x2000}; - struct dump_driver *d; + struct dump_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - return read_count(v, d->log, &d->ppu, &range_address, &range_length); + return read_count(v, &d->log, &d->ppu, &range_address, &range_length); } -static bool script_execute(HSQUIRRELVM v, struct config_dump *c, struct dump_driver *d) +static bool script_execute(HSQUIRRELVM v, struct dump_config *d) { bool ret = true; if(SQ_FAILED(sqstd_dofile(v, _SC("dumpcore.nut"), SQFalse, SQTrue))){ - d->log->append(d->log->object, "dump core script error\n"); + d->log.append(d->log.object, "dump core script error\n"); ret = false; - }else if(SQ_FAILED(sqstd_dofile(v, _SC(c->script), SQFalse, SQTrue))){ + }else if(SQ_FAILED(sqstd_dofile(v, _SC(d->script), SQFalse, SQTrue))){ char str[80]; - snprintf(str, 80, "%s open error\n", c->script); - d->log->append(d->log->object, str); + snprintf(str, 80, "%s open error\n", d->script); + d->log.append(d->log.object, str); ret = false; }else{ SQRESULT r = qr_call( v, "dump", (SQUserPointer) d, true, - 3, c->mappernum, c->increase.cpu, c->increase.ppu + 3, d->mappernum, d->cpu.increase, d->ppu.increase ); if(SQ_FAILED(r)){ ret = false; @@ -329,42 +311,28 @@ static bool script_execute(HSQUIRRELVM v, struct config_dump *c, struct dump_dri } return ret; } -void script_dump_execute(struct config_dump *c) +void script_dump_execute(struct dump_config *d) { - struct dump_driver d = { - .cpu = { - .memory = { - .name = "program", - .size = 0, .offset = 0, - .attribute = MEMORY_ATTR_WRITE, - .transtype = TRANSTYPE_FULL, - .data = NULL - }, - .read_count = 0, - .write = c->reader->cpu_write_6502, - .read = c->reader->cpu_read, - .gauge = &c->gauge_cpu - }, - .ppu = { - .memory = { - .name = "charcter", - .size = 0, .offset = 0, - .attribute = MEMORY_ATTR_WRITE, - .transtype = TRANSTYPE_FULL, - .data = NULL - }, - .read_count = 0, - .write = c->reader->ppu_write, - .read = c->reader->ppu_read, - .gauge = &c->gauge_ppu - }, - .vram_connection = c->reader->vram_connection, - .target = c->target, - .progress = c->progress, - .log = &c->log - }; + struct dump_memory_driver *dd = &d->cpu; + dd->memory.name = "Program"; + dd->memory.size = 0; + dd->memory.offset = 0; + dd->memory.attribute = MEMORY_ATTR_WRITE; + dd->memory.transtype = TRANSTYPE_FULL; + dd->memory.data = NULL; + dd->read_count = 0; + + dd = &d->ppu; + dd->memory.name = "Charcter"; + dd->memory.size = 0; + dd->memory.offset = 0; + dd->memory.attribute = MEMORY_ATTR_WRITE; + dd->memory.transtype = TRANSTYPE_FULL; + dd->memory.data = NULL; + dd->read_count = 0; + { - HSQUIRRELVM v = qr_open(&c->log); + HSQUIRRELVM v = qr_open(&d->log); qr_function_register_global(v, "ppu_ramfind", script_nop); qr_function_register_global(v, "cpu_write", cpu_write_check); qr_function_register_global(v, "memory_new", memory_new); @@ -372,17 +340,17 @@ void script_dump_execute(struct config_dump *c) qr_function_register_global(v, "cpu_read", cpu_read_count); qr_function_register_global(v, "ppu_read", ppu_read_count); qr_function_register_global(v, "require", script_require); - if(script_execute(v, c, &d) == false){ + if(script_execute(v, d) == false){ qr_close(v); return; } qr_close(v); } - if(c->progress == true){ + if(d->progress == true){ progress_init(); } { - HSQUIRRELVM v = qr_open(&c->log); + HSQUIRRELVM v = qr_open(&d->log); qr_function_register_global(v, "memory_new", script_nop); qr_function_register_global(v, "nesfile_save", nesfile_save); qr_function_register_global(v, "cpu_write", cpu_write); @@ -390,7 +358,7 @@ void script_dump_execute(struct config_dump *c) qr_function_register_global(v, "ppu_read", ppu_read); qr_function_register_global(v, "ppu_ramfind", ppu_ramfind); qr_function_register_global(v, "require", script_require); - script_execute(v, c, &d); + script_execute(v, d); qr_close(v); } } diff --git a/client/trunk/anago/script_dump.h b/client/trunk/anago/script_dump.h index b496a18..9b7687f 100644 --- a/client/trunk/anago/script_dump.h +++ b/client/trunk/anago/script_dump.h @@ -4,16 +4,21 @@ enum{ DUMP_SCRIPT_STR_LENGTH = 20, DUMP_TARGET_STR_LENGTH = 50 }; -struct config_dump{ +struct dump_config{ char script[DUMP_SCRIPT_STR_LENGTH]; char target[DUMP_TARGET_STR_LENGTH]; - const struct reader_driver *reader; + struct reader_handle handle; + const struct reader_control *control; + struct dump_memory_driver{ + const struct reader_memory_access *access; + struct memory memory; + long read_count, increase; + struct gauge gauge; + }cpu, ppu; long mappernum; //struct romimage rom; - struct {long cpu, ppu;} increase; bool progress; - struct gauge gauge_cpu, gauge_ppu; struct textcontrol log; }; -void script_dump_execute(struct config_dump *c); +void script_dump_execute(struct dump_config *c); #endif diff --git a/client/trunk/anago/script_flash.c b/client/trunk/anago/script_flash.c index d45b074..7eb0c69 100644 --- a/client/trunk/anago/script_flash.c +++ b/client/trunk/anago/script_flash.c @@ -16,43 +16,16 @@ #include "script_common.h" #include "script_flash.h" -struct anago_driver{ - struct anago_flash_order{ - bool command_change; - struct{ - long address, length, count, offset; - }programming, compare; - long c000x, c2aaa, c5555; - struct memory *const memory; - struct flash_device *const device; - void (*const config)(long c000x, long c2aaa, long c5555, long unit, bool retry); - void (*const device_get)(uint8_t s[2]); - void (*const write)(long address, long length, const uint8_t *data); - void (*const read)(long address, long length, u8 *data); - void (*const erase)(long address, bool dowait); - long (*const program)(long address, long length, const u8 *data, bool dowait, bool skip); - struct gauge *const gauge; - }order_cpu, order_ppu; - void (*const flash_status)(uint8_t s[2]); - uint8_t (*const vram_connection)(void); - const enum vram_mirroring vram_mirroring; - bool compare, testrun; - struct textcontrol *const log; -}; - static SQInteger vram_mirrorfind(HSQUIRRELVM v) { - struct anago_driver *d; + struct flash_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - if((d->vram_connection() == 0x05) != (d->vram_mirroring == MIRROR_VERTICAL)){ - d->log->append(d->log->object, "warning: vram mirroring is inconnect"); - } return 0; } -static SQInteger command_set(HSQUIRRELVM v, struct anago_flash_order *t) +static SQInteger command_set(HSQUIRRELVM v, struct flash_memory_driver *t) { long command, address ,mask; SQRESULT r = qr_argument_get(v, 3, &command, &address, &mask); @@ -79,23 +52,23 @@ static SQInteger command_set(HSQUIRRELVM v, struct anago_flash_order *t) } static SQInteger cpu_command(HSQUIRRELVM v) { - struct anago_driver *d; + struct program_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - return command_set(v, &d->order_cpu); + return command_set(v, &d->cpu); } static SQInteger ppu_command(HSQUIRRELVM v) { - struct anago_driver *d; + struct program_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - return command_set(v, &d->order_ppu); + return command_set(v, &d->ppu); } -static SQInteger write_memory(HSQUIRRELVM v, struct anago_flash_order *t) +static SQInteger write_memory(HSQUIRRELVM v, const struct reader_handle *h, struct flash_memory_driver *t) { long address, data; SQRESULT r = qr_argument_get(v, 2, &address, &data); @@ -103,59 +76,60 @@ static SQInteger write_memory(HSQUIRRELVM v, struct anago_flash_order *t) return r; } uint8_t d8 = (uint8_t) data; - t->write(address, 1, &d8); + t->access->memory_write(h, address, 1, &d8); return 0; } static SQInteger cpu_write(HSQUIRRELVM v) { - struct anago_driver *d; + struct program_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - return write_memory(v, &d->order_cpu); + return write_memory(v, &d->handle, &d->cpu); } -static SQInteger erase_set(HSQUIRRELVM v, struct anago_flash_order *t, const char *region, struct textcontrol *log) +static SQInteger erase_set(HSQUIRRELVM v, const struct reader_handle *h, struct flash_memory_driver *t, struct textcontrol *log) { - t->config(t->c000x, t->c2aaa, t->c5555, t->device->pagesize, t->device->retry); + t->access->flash_config(h, t->c000x, t->c2aaa, t->c5555, t->flash.pagesize, t->flash.retry); t->command_change = false; - if(t->device->erase_require == true){ - char str[80]; - t->erase(t->c2aaa, false); - snprintf(str, 80, "erasing %s memory...\n", region); - log->append(log->object, str); + if(t->flash.erase_require == true){ + t->access->flash_erase(h, t->c2aaa, false); + t->gauge.label_set(t->gauge.label, "erasing..."); fflush(stdout); } return 0; } static SQInteger cpu_erase(HSQUIRRELVM v) { - struct anago_driver *d; + struct program_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - return erase_set(v, &d->order_cpu, "program", d->log); + return erase_set(v, &d->handle, &d->cpu, &d->log); } static SQInteger ppu_erase(HSQUIRRELVM v) { - struct anago_driver *d; + struct program_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - return erase_set(v, &d->order_ppu, "charcter", d->log); + return erase_set(v, &d->handle, &d->ppu, &d->log); } -static SQInteger program_regist(HSQUIRRELVM v, const char *name, struct anago_flash_order *t) +static SQInteger program_regist(HSQUIRRELVM v, const struct reader_handle *h, struct flash_memory_driver *t) { SQRESULT r = qr_argument_get(v, 2, &t->programming.address, &t->programming.length); if(SQ_FAILED(r)){ return r; } t->compare = t->programming; - t->compare.offset = t->memory->offset & (t->memory->size - 1); + t->compare.offset = t->memory.offset & (t->memory.size - 1); if(t->command_change == true){ - t->config(t->c000x, t->c2aaa, t->c5555, t->device->pagesize, t->device->retry); + t->access->flash_config( + h, t->c000x, t->c2aaa, t->c5555, + t->flash.pagesize, t->flash.retry + ); t->command_change = false; } @@ -163,26 +137,31 @@ static SQInteger program_regist(HSQUIRRELVM v, const char *name, struct anago_fl fflush(stdout);*/ return sq_suspendvm(v); } -static void program_execute(struct anago_flash_order *t) +static void program_execute(const struct reader_handle *h, struct flash_memory_driver *t) { - const long w = t->program(t->programming.address, t->programming.length, t->memory->data + t->memory->offset, false, t->device->erase_require); + const long w = t->access->flash_program( + h, &t->gauge, + t->programming.address, t->programming.length, + t->memory.data + t->memory.offset, false, + t->flash.erase_require + ); t->programming.address += w; t->programming.length -= w; - t->memory->offset += w; - t->memory->offset &= t->memory->size - 1; + t->memory.offset += w; + t->memory.offset &= t->memory.size - 1; t->programming.offset += w; } -static bool program_compare(struct anago_flash_order *t) +static bool program_compare(const struct reader_handle *h, struct flash_memory_driver *t) { uint8_t *comparea = Malloc(t->compare.length); bool ret = false; - if(t->device->erase_require == true){ + if(t->flash.erase_require == true){ memset(comparea, 0xff, t->compare.length); - int doread = memcmp(comparea, t->memory->data + t->compare.offset, t->compare.length); + int doread = memcmp(comparea, t->memory.data + t->compare.offset, t->compare.length); if(0){ memset(comparea, 0, t->compare.length); - doread &= memcmp(comparea, t->memory->data + t->compare.offset, t->compare.length); + doread &= memcmp(comparea, t->memory.data + t->compare.offset, t->compare.length); } if(doread == 0){ Free(comparea); @@ -190,8 +169,8 @@ static bool program_compare(struct anago_flash_order *t) } } - t->read(t->compare.address, t->compare.length, comparea); - if(memcmp(comparea, t->memory->data + t->compare.offset, t->compare.length) == 0){ + t->access->memory_read(h, &GAUGE_DUMMY, t->compare.address, t->compare.length, comparea); + if(memcmp(comparea, t->memory.data + t->compare.offset, t->compare.length) == 0){ ret = true; } Free(comparea); @@ -199,44 +178,44 @@ static bool program_compare(struct anago_flash_order *t) } static SQInteger cpu_program_memory(HSQUIRRELVM v) { - struct anago_driver *d; + struct program_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - return program_regist(v, "program", &d->order_cpu); + return program_regist(v, &d->handle, &d->cpu); } static SQInteger ppu_program_memory(HSQUIRRELVM v) { - struct anago_driver *d; + struct program_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - return program_regist(v, "charcter", &d->order_ppu); + return program_regist(v, &d->handle, &d->ppu); } -static long erase_timer_get(struct anago_flash_order *t) +static long erase_timer_get(const struct reader_handle *h, struct flash_memory_driver *t) { if( - (t->memory->transtype != TRANSTYPE_EMPTY) && - (t->device->erase_require == true) + (t->memory.transtype != TRANSTYPE_EMPTY) && + (t->flash.erase_require == true) ){ - return t->device->erase_wait; + return t->flash.erase_wait; }else{ return 0; } } static SQInteger erase_wait(HSQUIRRELVM v) { - struct anago_driver *d; + struct program_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } if(0){ - long timer_wait = erase_timer_get(&d->order_cpu); - long timer_ppu = erase_timer_get(&d->order_ppu); + long timer_wait = erase_timer_get(&d->handle, &d->cpu); + long timer_ppu = erase_timer_get(&d->handle, &d->ppu); if(timer_wait < timer_ppu){ timer_wait = timer_ppu; } @@ -245,41 +224,29 @@ static SQInteger erase_wait(HSQUIRRELVM v) uint8_t s[2]; do{ wait(2); - d->flash_status(s); + d->control->flash_status(&d->handle, s); //ËÜÍè¤Î°Õ¿Þ¤«¤é¤Ç¤Ï¤³¤³¤Î¾ò·ï¼°¤Ï && ¤Ç¤Ï¤Ê¤¯ || ¤À¤¬¡¢Àè¤Ë erase ¤¬½ª¤ï¤Ã¤¿¥Ç¥Ð¥¤¥¹¤¬Æ°¤«¤»¤ë¤Î¤Ç»Ä¤·¤Æ¤ª¤¯ }while((s[0] != KAZZO_TASK_FLASH_IDLE) && (s[1] != KAZZO_TASK_FLASH_IDLE)); } return 0; } -static void gauge_init(const char *area, struct anago_flash_order *t) +static void gauge_init(struct flash_memory_driver *t) { - t->gauge->range_set(t->gauge->bar, t->programming.count); - t->gauge->value_set(t->gauge->bar, t->programming.offset); + t->gauge.range_set(t->gauge.bar, t->programming.count); + t->gauge.value_set(t->gauge.bar, t->gauge.label, t->programming.offset); if(t->programming.count == 0){ - char str[20]; - snprintf(str, 20, "%s skip", area); - t->gauge->label_set(t->gauge->label, str); - } -} - -static void gauge_update(const char *area, struct anago_flash_order *t) -{ - if(t->programming.count != 0){ - char str[40]; - snprintf(str, 40, "%s 0x%06x/0x%06x", area, (int) t->programming.offset, (int) t->programming.count); - t->gauge->label_set(t->gauge->label, str); - t->gauge->value_set(t->gauge->bar, t->programming.offset); + t->gauge.label_set(t->gauge.label, "skip"); } } -static bool program_memoryarea(HSQUIRRELVM co, struct anago_flash_order *t, bool compare, const char *region, SQInteger *state, bool *console_update, struct textcontrol *log) +static bool program_memoryarea(HSQUIRRELVM co, const struct reader_handle *h, struct flash_memory_driver *t, bool compare, SQInteger *state, struct textcontrol *log) { if(t->programming.length == 0){ if(t->programming.offset != 0 && compare == true){ - if(program_compare(t) == false){ + if(program_compare(h, t) == false){ char str[80]; - snprintf(str, 80, "%s memory compare error\n", region); + snprintf(str, 80, "%s memory compare error\n", t->memory.name); log->append(log->object, str); return false; } @@ -288,8 +255,7 @@ static bool program_memoryarea(HSQUIRRELVM co, struct anago_flash_order *t, bool sq_wakeupvm(co, SQFalse, SQFalse, SQTrue/*, SQTrue*/); *state = sq_getvmstate(co); }else{ - program_execute(t); - *console_update = true; + program_execute(h, t); } return true; } @@ -299,7 +265,7 @@ static SQInteger program_main(HSQUIRRELVM v) if(sq_gettop(v) != (1 + 3)){ //roottable, userpointer, co_cpu, co_ppu return sq_throwerror(v, "argument number error"); } - struct anago_driver *d; + struct program_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; @@ -316,33 +282,32 @@ static SQInteger program_main(HSQUIRRELVM v) const long sleepms = d->compare == true ? 6 : 2; //W29C040 ¤Ç compare ¤ò¤¹¤ë¤È¡¢error ¤¬½Ð¤ë¤Î¤Ç½Ð¤Ê¤¤ÃͤËÄ´À° (¤ä¤Ã¤Ä¤±Âбþ) //progress_init(); - gauge_init("CPU", &d->order_cpu); - gauge_init("PPU", &d->order_ppu); + gauge_init(&d->cpu); + gauge_init(&d->ppu); while((state_cpu != SQ_VMSTATE_IDLE) || (state_ppu != SQ_VMSTATE_IDLE)){ uint8_t s[2]; - bool console_update = false; +// bool console_update = false; wait(sleepms); - d->flash_status(s); + d->control->flash_status(&d->handle, s); if(state_cpu != SQ_VMSTATE_IDLE && s[0] == KAZZO_TASK_FLASH_IDLE){ - if(program_memoryarea(co_cpu, &d->order_cpu, d->compare, "program", &state_cpu, &console_update, d->log) == false){ + if(program_memoryarea(co_cpu, &d->handle, &d->cpu, d->compare, &state_cpu, &d->log) == false){ return 0; } } if(state_ppu != SQ_VMSTATE_IDLE && s[1] == KAZZO_TASK_FLASH_IDLE){ - if(program_memoryarea(co_ppu, &d->order_ppu, d->compare, "charcter", &state_ppu, &console_update, d->log) == false){ + if(program_memoryarea(co_ppu, &d->handle, &d->ppu, d->compare, &state_ppu, &d->log) == false){ return 0; } } - if((console_update == true) && (d->testrun == false)){ - //progress_draw(d->order_cpu.programming.offset, d->order_cpu.programming.count, d->order_ppu.programming.offset, d->order_ppu.programming.count); +/* if((console_update == true) && (d->testrun == false)){ gauge_update("CPU", &d->order_cpu); gauge_update("PPU", &d->order_ppu); - } + }*/ } return 0; } -static SQInteger program_count(HSQUIRRELVM v, struct anago_flash_order *t, const struct range *range_address, const struct range *range_length, struct textcontrol *log) +static SQInteger program_count(HSQUIRRELVM v, struct flash_memory_driver *t, const struct range *range_address, const struct range *range_length, struct textcontrol *log) { SQRESULT r = qr_argument_get(v, 2, &t->programming.address, &t->programming.length); if(SQ_FAILED(r)){ @@ -365,44 +330,44 @@ static SQInteger cpu_program_count(HSQUIRRELVM v) { static const struct range range_address = {0x8000, 0x10000}; static const struct range range_length = {0x0100, 0x4000}; - struct anago_driver *d; + struct program_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - return program_count(v, &d->order_cpu, &range_address, &range_length, d->log); + return program_count(v, &d->cpu, &range_address, &range_length, &d->log); } static SQInteger ppu_program_count(HSQUIRRELVM v) { static const struct range range_address = {0x0000, 0x2000}; static const struct range range_length = {0x0100, 0x2000}; - struct anago_driver *d; + struct program_config *d; SQRESULT r = qr_userpointer_get(v, (SQUserPointer) &d); if(SQ_FAILED(r)){ return r; } - return program_count(v, &d->order_ppu, &range_address, &range_length, d->log); + return program_count(v, &d->ppu, &range_address, &range_length, &d->log); } -static bool script_execute(HSQUIRRELVM v, const char *function, struct config_flash *c, struct anago_driver *d) +static bool script_execute(HSQUIRRELVM v, const char *function, struct program_config *c) { bool ret = true; if(SQ_FAILED(sqstd_dofile(v, _SC("flashcore.nut"), SQFalse, SQTrue))){ - d->log->append(d->log->object, "flash core script error\n"); + c->log.append(c->log.object, "flash core script error\n"); ret = false; }else if(SQ_FAILED(sqstd_dofile(v, _SC(c->script), SQFalse, SQTrue))){ char str[80]; snprintf(str, 80, "%s open error\n", c->script); - d->log->append(d->log->object, str); + c->log.append(c->log.object, str); ret = false; }else{ SQRESULT r = qr_call( - v, function, (SQUserPointer) d, true, - 1 + 3 * 2, c->rom.mappernum, - d->order_cpu.memory->transtype, d->order_cpu.memory->size, d->order_cpu.device->capacity, - d->order_ppu.memory->transtype, d->order_ppu.memory->size, d->order_ppu.device->capacity + v, function, (SQUserPointer) c, true, + 1 + 3 * 2, c->mappernum, + c->cpu.memory.transtype, c->cpu.memory.size, c->cpu.flash.capacity, + c->ppu.memory.transtype, c->ppu.memory.size, c->cpu.flash.capacity ); if(SQ_FAILED(r)){ ret = false; @@ -411,46 +376,9 @@ static bool script_execute(HSQUIRRELVM v, const char *function, struct config_fl return ret; } -void script_flash_execute(struct config_flash *c) +static void zendan(struct program_config *c) { - struct anago_driver d = { - .order_cpu = { - .command_change = true, - .programming = { - .count = 0, .offset = 0 - }, - .device = &c->flash_cpu, - .memory = &c->rom.cpu_rom, - .config = c->reader->cpu_flash_config, - .device_get = c->reader->cpu_flash_device_get, - .write = c->reader->cpu_write_6502, - .read = c->reader->cpu_read, - .erase = c->reader->cpu_flash_erase, - .program = c->reader->cpu_flash_program, - .gauge = &c->gauge_cpu - }, - .order_ppu = { - .command_change = true, - .programming = { - .count = 0, .offset = 0 - }, - .device = &c->flash_ppu, - .memory = &c->rom.ppu_rom, - .config = c->reader->ppu_flash_config, - .device_get = c->reader->ppu_flash_device_get, - .write = c->reader->ppu_write, - .read = c->reader->ppu_read, - .erase = c->reader->ppu_flash_erase, - .program = c->reader->ppu_flash_program, - .gauge = &c->gauge_ppu - }, - .flash_status = c->reader->flash_status, - .vram_connection = c->reader->vram_connection, - .vram_mirroring = c->rom.mirror, - .compare = c->compare, - .testrun = c->testrun, - .log = &c->log - }; +//script test run { static const char *functionname[] = { "cpu_erase", "ppu_erase", @@ -469,28 +397,29 @@ void script_flash_execute(struct config_flash *c) qr_function_register_global(v, "ppu_command", ppu_command); qr_function_register_global(v, "vram_mirrorfind", vram_mirrorfind); - if(script_execute(v, "testrun", c, &d) == false){ + if(script_execute(v, "testrun", c) == false){ qr_close(v); return; } qr_close(v); - assert(d.order_cpu.memory->size != 0); + assert(c->cpu.memory.size != 0); char str[80]; - if(d.order_cpu.programming.count % d.order_cpu.memory->size != 0){ - snprintf(str, 80, "logical error: cpu_programsize is not connected 0x%06x/0x%06x\n", (int) d.order_cpu.programming.count, (int) d.order_cpu.memory->size); - d.log->append(d.log->object, str); + if(c->cpu.programming.count % c->cpu.memory.size != 0){ + snprintf(str, 80, "logical error: cpu_programsize is not connected 0x%06x/0x%06x\n", (int) c->cpu.programming.count, (int) c->cpu.memory.size); + c->log.append(c->log.object, str); return; } - if(d.order_ppu.memory->size != 0){ - if(d.order_ppu.programming.count % d.order_ppu.memory->size != 0){ - snprintf(str, 80, "logical error: ppu_programsize is not connected 0x%06x/0x%06x\n", (int) d.order_ppu.programming.count, (int) d.order_ppu.memory->size); - d.log->append(d.log->object, str); + if(c->ppu.memory.size != 0){ + if(c->ppu.programming.count % c->ppu.memory.size != 0){ + snprintf(str, 80, "logical error: ppu_programsize is not connected 0x%06x/0x%06x\n", (int) c->ppu.programming.count, (int) c->ppu.memory.size); + c->log.append(c->log.object, str); return; } } } - d.order_cpu.command_change = true; - d.order_ppu.command_change = true; +//script execute + c->cpu.command_change = true; + c->ppu.command_change = true; { HSQUIRRELVM v = qr_open(&c->log); qr_function_register_global(v, "cpu_write", cpu_write); @@ -503,7 +432,60 @@ void script_flash_execute(struct config_flash *c) qr_function_register_global(v, "program_main", program_main); qr_function_register_global(v, "erase_wait", erase_wait); qr_function_register_global(v, "vram_mirrorfind", script_nop); - script_execute(v, "program", c, &d); + script_execute(v, "program", c); qr_close(v); } } + +static bool memory_image_init(const struct memory *from, struct flash_memory_driver *t, struct textcontrol *log) +{ + t->memory.data = from->data; + t->memory.size = from->size; + t->memory.attribute = MEMORY_ATTR_READ; + t->command_change = true; + t->programming.count = 0; + t->programming.offset = 0; + if(t->memory.size == 0){ + t->memory.transtype = TRANSTYPE_EMPTY; + } + if(t->flash.capacity < from->size){ + log->append(log->object, t->memory.name); + + log->append(log->object, " image size is larger than target device"); + return false; + } + return true; +} + +void script_program_execute(struct program_config *c) +{ +//rom image load + struct romimage rom; + if(nesfile_load(__FUNCTION__, c->target, &rom) == false){ + c->log.append(c->log.object, "ROM image open error"); + return; + } +//variable init + c->mappernum = rom.mappernum; + c->cpu.memory.name = "Program Flash"; + if(memory_image_init(&rom.cpu_rom, &c->cpu, &c->log) == false){ + nesbuffer_free(&rom, 0); + return; + } + c->ppu.memory.name = "Charcter Flash"; + if(memory_image_init(&rom.ppu_rom, &c->ppu, &c->log) == false){ + nesbuffer_free(&rom, 0); + return; + } +//reader initalize + c->control->open(&c->handle); + if(c->handle.handle == NULL){ + c->log.append(c->log.object, "reader open error\n"); + }else{ +//program start, reader finalize + zendan(c); + c->control->close(&c->handle); + c->handle.handle = NULL; + } + nesbuffer_free(&rom, 0); +} diff --git a/client/trunk/anago/script_flash.h b/client/trunk/anago/script_flash.h index da64283..37dab8b 100644 --- a/client/trunk/anago/script_flash.h +++ b/client/trunk/anago/script_flash.h @@ -1,18 +1,28 @@ -#ifndef _SCRIPT_FLASH_H_ -#define _SCRIPT_FLASH_H_ +#ifndef _SCRIPT_PROGRAM_H_ +#define _SCRIPT_PROGRAM_H_ enum{ PROGRAM_SCRIPT_STR_LENGTH = 20, - PROGRAM_TARGET_STR_LENGTH = 50 + PROGRAM_TARGET_STR_LENGTH = 80 }; -struct config_flash{ +struct program_config{ char script[PROGRAM_SCRIPT_STR_LENGTH]; char target[PROGRAM_TARGET_STR_LENGTH]; - struct flash_device flash_cpu, flash_ppu; - const struct reader_driver *reader; - struct romimage rom; + struct reader_handle handle; + const struct reader_control *control; + struct flash_memory_driver{ + const struct reader_memory_access *access; + struct flash_device flash; + struct memory memory; + struct { + long address, length, count, offset; + }programming, compare; + bool command_change; + long c000x, c2aaa, c5555; + struct gauge gauge; + }cpu, ppu; + long mappernum; bool compare, testrun; - struct gauge gauge_cpu, gauge_ppu; struct textcontrol log; }; -void script_flash_execute(struct config_flash *c); +void script_program_execute(struct program_config *c); #endif diff --git a/client/trunk/header.c b/client/trunk/header.c index 4025240..1e306d7 100644 --- a/client/trunk/header.c +++ b/client/trunk/header.c @@ -11,6 +11,7 @@ iNES header/buffer control #include "file.h" #include "crc32.h" #include "config.h" +#include "widget.h" #include "header.h" enum{ @@ -46,8 +47,9 @@ void nesheader_set(const struct romimage *r, u8 *header) /* returnÃÍ: error count */ -static int mirroring_fix(struct memory *m, long min) +static int mirroring_fix(struct textcontrol *l, struct memory *m, long min) { + char str[80]; long mirror_size = m->size / 2; while(mirror_size >= min){ const u8 *halfbuf; @@ -56,7 +58,8 @@ static int mirroring_fix(struct memory *m, long min) if(memcmp(m->data, halfbuf, mirror_size) != 0){ const long ret = mirror_size * 2; if(m->size != ret){ - printf("mirroring %s rom fixed\n", m->name); + snprintf(str, 80, "mirroring %s rom fixed\n", m->name); + l->append(l->object, str); m->size = ret; } return 0; @@ -69,10 +72,11 @@ static int mirroring_fix(struct memory *m, long min) ffdata = Malloc(min); memset(ffdata, 0xff, min); if(memcmp(ffdata, m->data, min) == 0){ - printf("error: data is all 0xff\n"); + l->append(l->object, "error: data is all 0xff\n"); ret = 1; }else if(m->size != min){ - printf("mirroring %s rom fixed\n", m->name); + snprintf(str, 80, "mirroring %s rom fixed\n", m->name); + l->append(l->object, str); m->size = min; } Free(ffdata); @@ -81,33 +85,39 @@ static int mirroring_fix(struct memory *m, long min) } //hash ¤Ï sha1 ¤Ë¤·¤¿¤¤¤¬Â¾¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¤¢¤ï¤»¤Æ crc32 ¤Ë¤·¤È¤¯ -static void rominfo_print(const struct memory *m) +static void rominfo_print(struct textcontrol *l, const struct memory *m) { + char str[80]; if(m->size != 0){ const uint32_t crc = crc32_get(m->data, m->size); - printf("%s ROM: size 0x%06x, crc32 0x%08x\n", m->name, m->size, (const int) crc); + snprintf(str, 80, "%s ROM: size 0x%06x, crc32 0x%08x\n", m->name, m->size, (const int) crc); }else{ - printf("%s RAM\n", m->name); + snprintf(str, 80, "%s RAM\n", m->name); } + l->append(l->object, str); } -void nesfile_create(struct romimage *r, const char *romfilename) +void nesfile_create(struct textcontrol *l, struct romimage *r, const char *romfilename) { int error = 0; //RAM adapter bios size 0x2000 ¤ÏÊѹ¹¤·¤Ê¤¤ if(r->cpu_rom.size >= PROGRAM_ROM_MIN){ - error += mirroring_fix(&(r->cpu_rom), PROGRAM_ROM_MIN); + error += mirroring_fix(l, &(r->cpu_rom), PROGRAM_ROM_MIN); } if(r->ppu_rom.size != 0){ - error += mirroring_fix(&(r->ppu_rom), CHARCTER_ROM_MIN); + error += mirroring_fix(l, &(r->ppu_rom), CHARCTER_ROM_MIN); } if((DEBUG == 0) && (error != 0)){ return; } //½¤ÀµºÑ¤ß ROM ¾ðÊóɽ¼¨ - printf("mapper %d\n", (int) r->mappernum); - rominfo_print(&(r->cpu_rom)); - rominfo_print(&(r->ppu_rom)); + { + char str[80]; + snprintf(str, 80, "%s, mapper %d\n", romfilename, (int) r->mappernum); + l->append(l->object, str); + } + rominfo_print(l, &(r->cpu_rom)); + rominfo_print(l, &(r->ppu_rom)); FILE *f; u8 header[NES_HEADER_SIZE]; diff --git a/client/trunk/header.h b/client/trunk/header.h index d9f799b..a792fe0 100644 --- a/client/trunk/header.h +++ b/client/trunk/header.h @@ -3,6 +3,7 @@ #if ANAGO==0 #include "flashmemory.h" #endif + enum trastype{ TRANSTYPE_EMPTY, TRANSTYPE_TOP, @@ -60,7 +61,7 @@ enum{ void nesheader_set(const struct romimage *r, uint8_t *header); #endif bool nesbuffer_malloc(struct romimage *r, int mode); -void nesfile_create(struct romimage *r, const char *romfilename); +void nesfile_create(struct textcontrol *l, struct romimage *r, const char *romfilename); void nesbuffer_free(struct romimage *r, int mode); void backupram_create(const struct memory *r, const char *ramfilename); int memorysize_check(const long size, int region); diff --git a/client/trunk/reader_kazzo.c b/client/trunk/reader_kazzo.c index c64894a..6e72cef 100644 --- a/client/trunk/reader_kazzo.c +++ b/client/trunk/reader_kazzo.c @@ -8,8 +8,9 @@ #include "reader_master.h" #include "usb_device.h" #include "reader_kazzo.h" +#include "widget.h" -static usb_dev_handle *device_open(void) +static inline usb_dev_handle *device_open(void) { usb_dev_handle *handle = NULL; const unsigned char rawVid[2] = {USB_CFG_VENDOR_ID}; @@ -25,22 +26,17 @@ static usb_dev_handle *device_open(void) if(usbOpenDevice(&handle, vid, vendor, pid, product, NULL, NULL, NULL) == 0){ return handle; } - fprintf(stderr, "Could not find USB device \"%s\" with vid=0x%x pid=0x%x\n", product, vid, pid); return NULL; } -static usb_dev_handle *handle = NULL; -static int kazzo_open_close(enum reader_control oc) + +static void kazzo_open(struct reader_handle *h) { - switch(oc){ - case READER_OPEN: - handle = device_open(); - return handle == NULL ? NG : OK; - case READER_CLOSE: - usb_close(handle); - handle = NULL; - return OK; - } - return NG; + h->handle = device_open(); +} + +static void kazzo_close(struct reader_handle *h) +{ + usb_close(h->handle); } enum{ TIMEOUT = 4000 @@ -60,27 +56,35 @@ static void device_read(usb_dev_handle *handle, enum request r, enum index index exit(1); } } -static void read_main(const enum request r, enum index index, long address, long length, uint8_t *data) +static void read_main(const struct reader_handle *d, const struct gauge *g, const enum request r, enum index index, long address, long length, uint8_t *data) { const int packet = READ_PACKET_SIZE; while(length >= packet){ - device_read(handle, r, index, address, packet, data); + device_read( + (usb_dev_handle *) d->handle, + r, index, address, packet, data + ); data += packet; address += packet; length -= packet; + g->value_add(g->bar, g->label, packet); } if(length != 0){ - device_read(handle, r, index, address, length, data); + device_read( + (usb_dev_handle *) d->handle, + r, index, address, length, data + ); + g->value_add(g->bar, g->label, packet); } } -static void kazzo_cpu_read(long address, long length, uint8_t *data) +static void kazzo_cpu_read(const struct reader_handle *d, const struct gauge *g, long address, long length, uint8_t *data) { - read_main(REQUEST_CPU_READ, INDEX_IMPLIED, address, length, data); + read_main(d, g, REQUEST_CPU_READ, INDEX_IMPLIED, address, length, data); // read_main(REQUEST_CPU_READ_6502, address, length, data); } -static void kazzo_ppu_read(long address, long length, uint8_t *data) +static void kazzo_ppu_read(const struct reader_handle *d, const struct gauge *g, long address, long length, uint8_t *data) { - read_main(REQUEST_PPU_READ, INDEX_IMPLIED, address, length, data); + read_main(d, g, REQUEST_PPU_READ, INDEX_IMPLIED, address, length, data); } //-------- write sequence -------- /* @@ -109,33 +113,29 @@ static void device_write(usb_dev_handle *handle, enum request w, enum index inde Free(d); } -static void kazzo_init(void) +static void kazzo_init(const struct reader_handle *d) { - device_write(handle, REQUEST_PHI2_INIT, INDEX_IMPLIED, 0, 0, NULL); + device_write((usb_dev_handle *) d->handle, REQUEST_PHI2_INIT, INDEX_IMPLIED, 0, 0, NULL); } -static void write_memory(enum request r, long address, long length, const uint8_t *data) +static void write_memory(const struct reader_handle *d, enum request r, long address, long length, const uint8_t *data) { while(length != 0){ long l = length >= FLASH_PACKET_SIZE ? FLASH_PACKET_SIZE : length; - device_write(handle, r, INDEX_IMPLIED, address, l, data); + device_write((usb_dev_handle *) d->handle, r, INDEX_IMPLIED, address, l, data); address += l; data += l; length -= l; } } -static void kazzo_cpu_write_6502(long address, long length, const uint8_t *data) +static void kazzo_cpu_write_6502(const struct reader_handle *d, long address, long length, const uint8_t *data) { - write_memory(REQUEST_CPU_WRITE_6502, address, length, data); + write_memory(d, REQUEST_CPU_WRITE_6502, address, length, data); } -/*static void kazzo_cpu_write_flash(long address, long data) -{ - uint8_t d = (uint8_t) (data & 0xff); - device_write(handle, REQUEST_CPU_WRITE_FLASH, address, 1, &d); -}*/ -static void kazzo_ppu_write(long address, long length, const uint8_t *data) + +static void kazzo_ppu_write(const struct reader_handle *d, long address, long length, const uint8_t *data) { - write_memory(REQUEST_PPU_WRITE, address, length, data); + write_memory(d, REQUEST_PPU_WRITE, address, length, data); } static inline void pack_short_le(long l, uint8_t *t) @@ -143,7 +143,7 @@ static inline void pack_short_le(long l, uint8_t *t) t[0] = l & 0xff; t[1] = (l >> 8) & 0xff; } -static void flash_config(enum request r, enum index index, long c000x, long c2aaa, long c5555, long unit, bool retry) +static void flash_config(const struct reader_handle *d, enum request r, enum index index, long c000x, long c2aaa, long c5555, long unit, bool retry) { const int size = 2 * 4 + 1; uint8_t buf[size]; @@ -158,18 +158,18 @@ static void flash_config(enum request r, enum index index, long c000x, long c2aa pack_short_le(unit, t); t += sizeof(uint16_t); *t = retry == true ? 1 : 0; - device_write(handle, r, index, 0, size, buf); + device_write((usb_dev_handle *) d->handle, r, index, 0, size, buf); } -static void kazzo_cpu_flash_config(long c000x, long c2aaa, long c5555, long unit, bool retry) +static void kazzo_cpu_flash_config(const struct reader_handle *d, long c000x, long c2aaa, long c5555, long unit, bool retry) { - flash_config(REQUEST_FLASH_CONFIG_SET, INDEX_CPU, c000x, c2aaa, c5555, unit, retry); + flash_config(d, REQUEST_FLASH_CONFIG_SET, INDEX_CPU, c000x, c2aaa, c5555, unit, retry); } -static void kazzo_ppu_flash_config(long c000x, long c2aaa, long c5555, long unit, bool retry) +static void kazzo_ppu_flash_config(const struct reader_handle *d, long c000x, long c2aaa, long c5555, long unit, bool retry) { - flash_config(REQUEST_FLASH_CONFIG_SET, INDEX_PPU, c000x, c2aaa, c5555, unit, retry); + flash_config(d, REQUEST_FLASH_CONFIG_SET, INDEX_PPU, c000x, c2aaa, c5555, unit, retry); } -static inline void flash_execute(enum request p, enum request s, enum index index, long address, const uint8_t *data, int size, bool dowait, bool skip) +static inline void flash_execute(const struct reader_handle *d, enum request p, enum request s, enum index index, long address, const uint8_t *data, int size, bool dowait, bool skip) { uint8_t status; int filled = 1; @@ -184,22 +184,22 @@ static inline void flash_execute(enum request p, enum request s, enum index inde Free(filldata); } if(filled != 0){ - device_write(handle, p, index, address, size, data); + device_write((usb_dev_handle *) d->handle, p, index, address, size, data); } if(dowait == true){ do{ wait(10); - device_read(handle, s, index, 0, 1, &status); + device_read((usb_dev_handle *) d->handle, s, index, 0, 1, &status); }while(status != KAZZO_TASK_FLASH_IDLE); } } -static void kazzo_cpu_flash_erase(long address, bool dowait) +static void kazzo_cpu_flash_erase(const struct reader_handle *d, long address, bool dowait) { - flash_execute(REQUEST_FLASH_ERASE, REQUEST_FLASH_STATUS, INDEX_CPU, address, NULL, 0, dowait, false); + flash_execute(d, REQUEST_FLASH_ERASE, REQUEST_FLASH_STATUS, INDEX_CPU, address, NULL, 0, dowait, false); } -static void kazzo_ppu_flash_erase(long address, bool dowait) +static void kazzo_ppu_flash_erase(const struct reader_handle *d, long address, bool dowait) { - flash_execute(REQUEST_FLASH_ERASE, REQUEST_FLASH_STATUS, INDEX_PPU, address, NULL, 0, dowait, false); + flash_execute(d, REQUEST_FLASH_ERASE, REQUEST_FLASH_STATUS, INDEX_PPU, address, NULL, 0, dowait, false); } static void dump(const uint8_t *w, const uint8_t *r, long length) @@ -223,18 +223,19 @@ static void dump(const uint8_t *w, const uint8_t *r, long length) length -= 0x10; } } -static long flash_program(enum index index, long address, long length, const uint8_t *data, bool dowait, bool skip) +static long flash_program(const struct reader_handle *h, const struct gauge *g, enum index index, long address, long length, const uint8_t *data, bool dowait, bool skip) { enum request p = REQUEST_FLASH_PROGRAM; enum request s = REQUEST_FLASH_STATUS; if(dowait == false){ - flash_execute(p, s, index, address, data, FLASH_PACKET_SIZE, dowait, skip); + flash_execute(h, p, s, index, address, data, FLASH_PACKET_SIZE, dowait, skip); + g->value_add(g->bar, g->label, FLASH_PACKET_SIZE); return FLASH_PACKET_SIZE; } long count = 0; uint8_t *d = Malloc(FLASH_PACKET_SIZE); while(length >= FLASH_PACKET_SIZE){ - flash_execute(p, s, index, address, data, FLASH_PACKET_SIZE, dowait, skip); + flash_execute(h, p, s, index, address, data, FLASH_PACKET_SIZE, dowait, skip); if(0){ //device_read(handle, REQUEST_FLASH_BUFFER_GET, index, 0, FLASH_PACKET_SIZE, d); if(memcmp(d, data, FLASH_PACKET_SIZE) != 0){ @@ -242,6 +243,7 @@ static long flash_program(enum index index, long address, long length, const uin dump(data, d, FLASH_PACKET_SIZE); } } + g->value_add(g->bar, g->label, FLASH_PACKET_SIZE); address += FLASH_PACKET_SIZE; data += FLASH_PACKET_SIZE; count += FLASH_PACKET_SIZE; @@ -250,49 +252,53 @@ static long flash_program(enum index index, long address, long length, const uin Free(d); return count; } -static long kazzo_cpu_flash_program(long address, long length, const uint8_t *data, bool dowait, bool skip) +static long kazzo_cpu_flash_program(const struct reader_handle *d, const struct gauge *g, long address, long length, const uint8_t *data, bool dowait, bool skip) { - return flash_program(INDEX_CPU, address, length, data, dowait, skip); + return flash_program(d, g, INDEX_CPU, address, length, data, dowait, skip); } -static long kazzo_ppu_flash_program(long address, long length, const uint8_t *data, bool dowait, bool skip) +static long kazzo_ppu_flash_program(const struct reader_handle *d, const struct gauge *g, long address, long length, const uint8_t *data, bool dowait, bool skip) { - return flash_program(INDEX_PPU, address, length, data, dowait, skip); + return flash_program(d, g, INDEX_PPU, address, length, data, dowait, skip); } -static void kazzo_flash_status(uint8_t s[2]) +static void kazzo_flash_status(const struct reader_handle *d, uint8_t s[2]) { - read_main(REQUEST_FLASH_STATUS, INDEX_BOTH, 0, 2, s); + read_main(d, &GAUGE_DUMMY, REQUEST_FLASH_STATUS, INDEX_BOTH, 0, 2, s); } -static void kazzo_cpu_flash_device_get(uint8_t s[2]) +static void kazzo_cpu_flash_device_get(const struct reader_handle *d, uint8_t s[2]) { - read_main(REQUEST_FLASH_DEVICE, INDEX_CPU, 0, 2, s); + read_main(d, &GAUGE_DUMMY, REQUEST_FLASH_DEVICE, INDEX_CPU, 0, 2, s); } -static void kazzo_ppu_flash_device_get(uint8_t s[2]) +static void kazzo_ppu_flash_device_get(const struct reader_handle *d, uint8_t s[2]) { - read_main(REQUEST_FLASH_DEVICE, INDEX_PPU, 0, 2, s); + read_main(d, &GAUGE_DUMMY, REQUEST_FLASH_DEVICE, INDEX_PPU, 0, 2, s); } -static uint8_t kazzo_vram_connection(void) +static uint8_t kazzo_vram_connection(const struct reader_handle *d) { uint8_t s; - read_main(REQUEST_VRAM_CONNECTION, INDEX_IMPLIED, 0, 1, &s); + read_main(d, &GAUGE_DUMMY, REQUEST_VRAM_CONNECTION, INDEX_IMPLIED, 0, 1, &s); return s; } const struct reader_driver DRIVER_KAZZO = { - .name = "kazzo", - .open_or_close = kazzo_open_close, - .init = kazzo_init, - .cpu_read = kazzo_cpu_read, .ppu_read = kazzo_ppu_read, - .cpu_write_6502 = kazzo_cpu_write_6502, - .flash_support = true, - .ppu_write = kazzo_ppu_write, - .cpu_flash_config = kazzo_cpu_flash_config, - .cpu_flash_erase = kazzo_cpu_flash_erase, - .cpu_flash_program = kazzo_cpu_flash_program, - .cpu_flash_device_get = kazzo_cpu_flash_device_get, - .ppu_flash_config = kazzo_ppu_flash_config, - .ppu_flash_erase = kazzo_ppu_flash_erase, - .ppu_flash_program = kazzo_ppu_flash_program, - .ppu_flash_device_get = kazzo_ppu_flash_device_get, - .flash_status = kazzo_flash_status, - .vram_connection = kazzo_vram_connection + .cpu = { + .memory_read = kazzo_cpu_read, + .memory_write = kazzo_cpu_write_6502, + .flash_config = kazzo_cpu_flash_config, + .flash_erase = kazzo_cpu_flash_erase, + .flash_program = kazzo_cpu_flash_program, + .flash_device_get = kazzo_cpu_flash_device_get + }, .ppu = { + .memory_read = kazzo_ppu_read, + .memory_write = kazzo_ppu_write, + .flash_config = kazzo_ppu_flash_config, + .flash_erase = kazzo_ppu_flash_erase, + .flash_program = kazzo_ppu_flash_program, + .flash_device_get = kazzo_ppu_flash_device_get + }, .control = { + .name = "kazzo", + .open = kazzo_open, .close = kazzo_close, + .init = kazzo_init, + .flash_status = kazzo_flash_status, + .vram_connection = kazzo_vram_connection + } }; diff --git a/client/trunk/reader_master.h b/client/trunk/reader_master.h index 93da71b..44787a9 100644 --- a/client/trunk/reader_master.h +++ b/client/trunk/reader_master.h @@ -7,32 +7,36 @@ #include #endif -//C++ ¤Î Class ¤â¤É¤­¤ò C ¤Ç¼ÂÁõ¤·¤Æ¤¤¤ë´¶¤¬Áý¤·¤Æ¤­¤¿... -enum reader_control{ - READER_OPEN, READER_CLOSE +struct textcontrol; +struct gauge; +struct reader_handle{ + void *handle; + struct textcontrol *text; }; -struct reader_driver{ + +struct reader_memory_access{ + void (*memory_read)(const struct reader_handle *d, const struct gauge *g, long address, long length, uint8_t *data); + void (*memory_write)(const struct reader_handle *d, long address, long length, const uint8_t *data); + void (*flash_config)(const struct reader_handle *d, long c000x, long c2aaa, long c5555, long unit, bool retry); + void (*flash_erase)(const struct reader_handle *d, long address, bool wait); + long (*flash_program)(const struct reader_handle *d, const struct gauge *g, long address, long length, const uint8_t *data, bool wait, bool skip); + void (*flash_device_get)(const struct reader_handle *d, uint8_t s[2]); +}; +struct reader_control{ const char *name; - int (*open_or_close)(enum reader_control oc); - void (*init)(void); - void (*cpu_read)(long address, long length, uint8_t *data); - void (*cpu_write_6502)(long address, long length, const uint8_t *data); - void (*ppu_read)(long address, long length, uint8_t *data); - void (*ppu_write)(long address, long length, const uint8_t *data); - bool flash_support; - void (*cpu_flash_config)(long c000x, long c2aaa, long c5555, long unit, bool retry); - void (*cpu_flash_erase)(long address, bool wait); - long (*cpu_flash_program)(long address, long length, const uint8_t *data, bool wait, bool skip); - void (*cpu_flash_device_get)(uint8_t s[2]); - void (*ppu_flash_config)(long c000x, long c2aaa, long c5555, long unit, bool retry); - void (*ppu_flash_erase)(long address, bool wait); - long (*ppu_flash_program)(long address, long length, const uint8_t *data, bool wait, bool skip); - void (*ppu_flash_device_get)(uint8_t s[2]); - void (*flash_status)(uint8_t s[2]); - uint8_t (*vram_connection)(void); + void (*open)(struct reader_handle *h); + void (*close)(struct reader_handle *h); + void (*init)(const struct reader_handle *d); + void (*flash_status)(const struct reader_handle *d, uint8_t s[2]); + uint8_t (*vram_connection)(const struct reader_handle *d); +}; +struct reader_driver{ + const struct reader_control control; + const struct reader_memory_access cpu, ppu; }; -int paralellport_open_or_close(enum reader_control oc); -const struct reader_driver *reader_driver_get(const char *name); + +#if 0 +bool reader_driver_get(const char *name, struct reader_driver); enum{ ADDRESS_MASK_A0toA12 = 0x1fff, ADDRESS_MASK_A0toA14 = 0x7fff, @@ -42,7 +46,7 @@ enum{ M2_CONTROL_TRUE, M2_CONTROL_FALSE }; /* -static inline ¤Ï¶¦Í­¥Þ¥¯¥í°·¤¤ +static inline は共有マクロ扱い */ static inline int bit_set(int data, const int bit) { @@ -55,7 +59,7 @@ static inline int bit_clear(int data, const int bit) data &= ~(1 << bit); return data; } - +#endif static inline void wait(long msec) { if(msec == 0){