APP_CUI = anago.exe\r
APP_GUI = anago_wx.exe\r
LIBUSB = d:/dev/LibUSB-Win32\r
-SQUIRREL = ../SQUIRREL2\r
+SQUIRREL = ../SQUIRREL224\r
KAZZO = ../../kazzo/firmware\r
WX_CONFIG = /d/dev/wxWidgets/build_unicode_sound3/wx-config\r
CPPFLAGS = -D_UNICODE\r
ifeq ($(RELEASE),1)
CPPFLAGS += -O2 -DNDEBUG
else
- CPPFLAGS += -ggdb -O0
+ CPPFLAGS += -g -O0
endif
CPPFLAGS += -Wall -Werror -DDEBUG=1
CFLAGS = -I.. -I$(SQUIRREL)/include -I$(KAZZO)
reader_kazzo.o usb_device.o squirrel_wrap.o memory_manage.o \
script_program.o script_dump.o script_common.o flash_device.o
+ifeq ($(strip $(RELEASE)),)
+ OBJ_CORE += reader_dummy.o
+endif
ifneq ($(strip $(APP_CUI)),)
OBJ_CUI += $(OBJ_CORE)
OBJ_GUI += $(OBJ_CORE)
return true;
}
-static void program(int c, wgChar **v)
+static void program(int c, wgChar **v, const struct reader_driver *r)
{
struct program_config config;
config.cpu.memory.data = NULL;
config.ppu.memory.data = NULL;
config.script = v[2];
config.target = v[3];
- config.control = &DRIVER_KAZZO.control;
- config.cpu.access = &DRIVER_KAZZO.cpu;
- config.ppu.access = &DRIVER_KAZZO.ppu;
+ config.control = &r->control;
+ config.cpu.access = &r->cpu;
+ config.ppu.access = &r->ppu;
config.compare = false;
config.testrun = false;
switch(v[1][0]){
case 'a':
-// config.reader = &DRIVER_DUMMY;
config.testrun = true;
break;
case 'F':
cui_gauge_destory(&config.ppu.gauge);
}
-static void dump(int c, wgChar **v)
+static void dump(int c, wgChar **v, const struct reader_driver *r)
{
struct dump_config config;
if(c < 4){
}
config.script = v[2];
config.target = v[3];
- config.control = &DRIVER_KAZZO.control;
- config.cpu.access = &DRIVER_KAZZO.cpu;
- config.ppu.access = &DRIVER_KAZZO.ppu;
+ config.control = &r->control;
+ config.cpu.access = &r->cpu;
+ config.ppu.access = &r->ppu;
cui_gauge_new(&config.cpu.gauge, wgT("Program ROM"), 2, -2);
cui_gauge_new(&config.ppu.gauge, wgT("Charcter ROM"), 1, -1);
config.except = except;
PRINTF(wgT("%s [mode] [script] [target] ....\n"), v);
}
+#if DEBUG==1
+extern const struct reader_driver DRIVER_DUMMY;
+#endif
+
#ifdef WIN32
int main(int c, char **vv)
#else
{
mm_init();
if(c >= 2){
+ const struct reader_driver *r = &DRIVER_KAZZO;
#ifdef _UNICODE
int i;
wchar_t **v;
}
#endif
switch(v[1][0]){
- case wgT('a'): case wgT('f'): case wgT('F'):
- program(c, v);
+#if DEBUG==1
+ case wgT('x'):
+ r = &DRIVER_DUMMY;
+#endif
+ case wgT('f'): case wgT('F'):
+ program(c, v, r);
break;
+#if DEBUG==1
+ case wgT('z'):
+ r = &DRIVER_DUMMY;
+#endif
case wgT('d'): case wgT('D'):
- dump(c,v);
+ dump(c,v, r);
break;
default:
usage(v[0]);
#include "script_program.h"
void qr_version_print(const struct textcontrol *l);
}
+#if DEBUG==1
+extern const struct reader_driver DRIVER_DUMMY;
+#endif
#ifdef _UNICODE
#define STRNCPY wcsncpy
#else
wxGauge *g = static_cast<wxGauge *>(gauge);
wxStaticText *l = static_cast<wxStaticText *>(label);
wxString str;
- str.Printf(wxT("0x%06x/0x%06x"), value, g->GetRange());
+ if(g->GetRange() == 1){
+ str = wxT("skip ");
+ }else{
+ str.Printf(wxT("0x%06x/0x%06x"), value, g->GetRange());
+ }
wxMutexGuiEnter();
g->SetValue(value);
private:
wxThread *m_anago_thread;
const wxString m_config_file;
+ const struct reader_driver *m_reader;
wxString m_dump_sound_success, m_dump_sound_fail;
wxString m_program_sound_success, m_program_sound_fail;
enum{
STATUS_IDLE, STATUS_DUMPPING, STATUS_PROGRAMMING
}m_status;
+
void gauge_init(struct gauge *t)
{
t->label_set = label_set;
STRNCPY(t, str_rom.fn_str(), str_rom.Length() + 1);
}
- config.control = &DRIVER_KAZZO.control;
- config.cpu.access = &DRIVER_KAZZO.cpu;
- config.ppu.access = &DRIVER_KAZZO.ppu;
+ config.control = &m_reader->control;
+ config.cpu.access = &m_reader->cpu;
+ config.ppu.access = &m_reader->ppu;
m_dump_script_choice->Disable();
m_dump_romimage_picker->Disable();
return;
}
- f.control = &DRIVER_KAZZO.control;
- f.cpu.access = &DRIVER_KAZZO.cpu;
- f.ppu.access = &DRIVER_KAZZO.ppu;
+ f.control = &m_reader->control;
+ f.cpu.access = &m_reader->cpu;
+ f.ppu.access = &m_reader->ppu;
m_program_script_choice->Disable();
m_program_romimage_picker->Disable();
}
public:
/** Constructor */
- anago_frame( wxWindow* parent )
+ anago_frame(wxWindow* parent, const struct reader_driver *r)
: frame_main(parent),
#ifdef WIN32
m_config_file(wxGetCwd() + wxT("/anago.cfg"))
m_config_file(wxT(".anago"))
#endif
{
+ m_reader = r;
//form config load
{
wxFileConfig config(wxEmptyString, wxEmptyString, m_config_file);
// wxBitmap bitmap_okada(araki);
m_version_photo->SetBitmap(bitmap_okada);
m_version_photo->SetToolTip(tooltip);
+
+ if(DEBUG==1){
+ m_dump_romimage_picker->GetTextCtrl()->SetLabel(wxT("t.nes"));
+ }
}
void DumpThreadFinish(void)
{
m_dump_script_choice->Enable();
+ m_dump_script_choice->SetFocus();
m_dump_romimage_picker->Enable();
m_dump_check_battery->Enable();
m_dump_check_forcemapper->Enable();
void ProgramThreadFinish(void)
{
m_program_script_choice->Enable();
+ m_dump_script_choice->SetFocus();
m_program_romimage_picker->Enable();
m_program_compare->Enable();
m_program_button->SetLabel(wxT("&program"));
public:
bool OnInit()
{
- m_frame = new anago_frame(NULL);
+ if(DEBUG== 1 && this->argc >= 2){
+ m_frame = new anago_frame(NULL, &DRIVER_DUMMY);
+ }else{
+ m_frame = new anago_frame(NULL, &DRIVER_KAZZO);
+ }
m_frame->Show();
return true;
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );
- m_notebook3 = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
- m_panel_dump = new wxPanel( m_notebook3, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
+ m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
+ m_panel_dump = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer9;
bSizer9 = new wxBoxSizer( wxVERTICAL );
m_panel_dump->SetSizer( bSizer9 );
m_panel_dump->Layout();
bSizer9->Fit( m_panel_dump );
- m_notebook3->AddPage( m_panel_dump, wxT("dump"), true );
- m_panel_program = new wxPanel( m_notebook3, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
+ m_notebook->AddPage( m_panel_dump, wxT("dump"), true );
+ m_panel_program = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer91;
bSizer91 = new wxBoxSizer( wxVERTICAL );
m_panel_program->SetSizer( bSizer91 );
m_panel_program->Layout();
bSizer91->Fit( m_panel_program );
- m_notebook3->AddPage( m_panel_program, wxT("program"), false );
- m_panel_version = new wxPanel( m_notebook3, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
+ m_notebook->AddPage( m_panel_program, wxT("program"), false );
+ m_panel_version = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer30;
bSizer30 = new wxBoxSizer( wxVERTICAL );
m_panel_version->SetSizer( bSizer30 );
m_panel_version->Layout();
bSizer30->Fit( m_panel_version );
- m_notebook3->AddPage( m_panel_version, wxT("version"), false );
+ m_notebook->AddPage( m_panel_version, wxT("version"), false );
- bSizer4->Add( m_notebook3, 0, wxALL|wxEXPAND, 0 );
+ bSizer4->Add( m_notebook, 0, wxALL|wxEXPAND, 0 );
m_panel_log = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer6;
m_program_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frame_main::program_button_click ), NULL, this );
}
+
+rampanel::rampanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style )
+{
+ this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) );
+
+ wxBoxSizer* bSizer9;
+ bSizer9 = new wxBoxSizer( wxVERTICAL );
+
+ wxFlexGridSizer* fgSizer1;
+ fgSizer1 = new wxFlexGridSizer( 2, 2, 0, 0 );
+ fgSizer1->AddGrowableCol( 1 );
+ fgSizer1->SetFlexibleDirection( wxBOTH );
+ fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
+
+ m_script_label = new wxStaticText( this, wxID_ANY, wxT("&script"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_script_label->Wrap( -1 );
+ fgSizer1->Add( m_script_label, 0, wxALL, 5 );
+
+ wxArrayString m_script_choiceChoices;
+ m_script_choice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_script_choiceChoices, 0 );
+ m_script_choice->SetSelection( 0 );
+ fgSizer1->Add( m_script_choice, 0, wxALL|wxEXPAND, 5 );
+
+ m_ramimage_label = new wxStaticText( this, wxID_ANY, wxT("&RAM image"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_ramimage_label->Wrap( -1 );
+ fgSizer1->Add( m_ramimage_label, 0, wxALL, 5 );
+
+ m_ramimage_picker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.sav"), wxDefaultPosition, wxDefaultSize, wxFLP_DEFAULT_STYLE|wxFLP_OVERWRITE_PROMPT|wxFLP_SAVE|wxFLP_USE_TEXTCTRL );
+ fgSizer1->Add( m_ramimage_picker, 0, wxALL|wxEXPAND, 5 );
+
+ bSizer9->Add( fgSizer1, 0, wxEXPAND, 5 );
+
+ m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
+ bSizer9->Add( m_staticline1, 0, wxALL|wxEXPAND, 2 );
+
+ wxBoxSizer* bSizer12;
+ bSizer12 = new wxBoxSizer( wxHORIZONTAL );
+
+ m_cpu_label = new wxStaticText( this, wxID_ANY, wxT("Work RAM"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_cpu_label->Wrap( -1 );
+ m_cpu_label->SetMinSize( wxSize( 80,-1 ) );
+
+ bSizer12->Add( m_cpu_label, 0, wxALL, 5 );
+
+ m_cpu_gauge = new wxGauge( this, wxID_ANY, 100, wxDefaultPosition, wxSize( -1,12 ), wxGA_HORIZONTAL );
+ bSizer12->Add( m_cpu_gauge, 1, wxALL|wxALIGN_CENTER_VERTICAL, 0 );
+
+ bSizer9->Add( bSizer12, 1, wxEXPAND, 5 );
+
+ wxBoxSizer* bSizer14;
+ bSizer14 = new wxBoxSizer( wxHORIZONTAL );
+
+ wxArrayString m_cpu_increaseChoices;
+ m_cpu_increase = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_cpu_increaseChoices, 0 );
+ m_cpu_increase->SetSelection( 0 );
+ m_cpu_increase->SetMinSize( wxSize( 60,-1 ) );
+
+ bSizer14->Add( m_cpu_increase, 0, wxALL, 5 );
+
+ m_cpu_value = new wxStaticText( this, wxID_ANY, wxT("0x000000/0x000000"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_cpu_value->Wrap( -1 );
+ m_cpu_value->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) );
+
+ bSizer14->Add( m_cpu_value, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+
+ bSizer9->Add( bSizer14, 1, wxALIGN_RIGHT, 5 );
+
+ m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
+ bSizer9->Add( m_staticline3, 0, wxEXPAND | wxALL, 2 );
+
+ wxBoxSizer* bSizer61;
+ bSizer61 = new wxBoxSizer( wxHORIZONTAL );
+
+ m_button = new wxButton( this, wxID_ANY, wxT("&dump"), wxDefaultPosition, wxDefaultSize, 0 );
+ bSizer61->Add( m_button, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+
+ bSizer9->Add( bSizer61, 0, wxALIGN_RIGHT, 5 );
+
+ this->SetSizer( bSizer9 );
+ this->Layout();
+ bSizer9->Fit( this );
+
+ // Connect Events
+ m_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( rampanel::dump_button_click ), NULL, this );
+}
+
+rampanel::~rampanel()
+{
+ // Disconnect Events
+ m_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( rampanel::dump_button_click ), NULL, this );
+
+}
<property name="id">wxID_ANY</property>\r
<property name="maximum_size"></property>\r
<property name="minimum_size">-1,-1</property>\r
- <property name="name">m_notebook3</property>\r
+ <property name="name">m_notebook</property>\r
<property name="permission">protected</property>\r
<property name="pos"></property>\r
<property name="size"></property>\r
</object>\r
</object>\r
</object>\r
- <object class="notebookpage" expanded="1">\r
+ <object class="notebookpage" expanded="0">\r
<property name="bitmap"></property>\r
<property name="label">program</property>\r
<property name="select">0</property>\r
</object>\r
</object>\r
</object>\r
- <object class="notebookpage" expanded="1">\r
+ <object class="notebookpage" expanded="0">\r
<property name="bitmap">tubami.bmp; Load From File</property>\r
<property name="label">version</property>\r
<property name="select">0</property>\r
- <object class="wxPanel" expanded="1">\r
+ <object class="wxPanel" expanded="0">\r
<property name="bg"></property>\r
<property name="context_help"></property>\r
<property name="context_menu">1</property>\r
<event name="OnSetFocus"></event>\r
<event name="OnSize"></event>\r
<event name="OnUpdateUI"></event>\r
- <object class="wxBoxSizer" expanded="1">\r
+ <object class="wxBoxSizer" expanded="0">\r
<property name="minimum_size"></property>\r
<property name="name">bSizer30</property>\r
<property name="orient">wxVERTICAL</property>\r
<property name="permission">none</property>\r
- <object class="sizeritem" expanded="1">\r
+ <object class="sizeritem" expanded="0">\r
<property name="border">2</property>\r
<property name="flag">wxALL</property>\r
<property name="proportion">0</property>\r
- <object class="wxStaticText" expanded="1">\r
+ <object class="wxStaticText" expanded="0">\r
<property name="bg"></property>\r
<property name="context_help"></property>\r
<property name="context_menu">1</property>\r
<event name="OnUpdateUI"></event>\r
</object>\r
</object>\r
- <object class="sizeritem" expanded="1">\r
+ <object class="sizeritem" expanded="0">\r
<property name="border">2</property>\r
<property name="flag">wxALL</property>\r
<property name="proportion">0</property>\r
- <object class="wxStaticText" expanded="1">\r
+ <object class="wxStaticText" expanded="0">\r
<property name="bg"></property>\r
<property name="context_help"></property>\r
<property name="context_menu">1</property>\r
<event name="OnUpdateUI"></event>\r
</object>\r
</object>\r
- <object class="sizeritem" expanded="1">\r
+ <object class="sizeritem" expanded="0">\r
<property name="border">5</property>\r
<property name="flag">wxEXPAND</property>\r
<property name="proportion">1</property>\r
- <object class="wxBoxSizer" expanded="1">\r
+ <object class="wxBoxSizer" expanded="0">\r
<property name="minimum_size"></property>\r
<property name="name">bSizer16</property>\r
<property name="orient">wxHORIZONTAL</property>\r
</object>\r
</object>\r
</object>\r
- <object class="sizeritem" expanded="1">\r
+ <object class="sizeritem" expanded="0">\r
<property name="border">2</property>\r
<property name="flag">wxALL|wxEXPAND</property>\r
<property name="proportion">0</property>\r
- <object class="wxTextCtrl" expanded="1">\r
+ <object class="wxTextCtrl" expanded="0">\r
<property name="bg">wxSYS_COLOUR_ACTIVEBORDER</property>\r
<property name="context_help"></property>\r
<property name="context_menu">1</property>\r
</object>\r
</object>\r
</object>\r
+ <object class="notebookpage" expanded="1">\r
+ <property name="bitmap"></property>\r
+ <property name="label">a page</property>\r
+ <property name="select">0</property>\r
+ <object class="wxPanel" expanded="1">\r
+ <property name="bg"></property>\r
+ <property name="context_help"></property>\r
+ <property name="context_menu">1</property>\r
+ <property name="enabled">1</property>\r
+ <property name="fg"></property>\r
+ <property name="font"></property>\r
+ <property name="hidden">1</property>\r
+ <property name="id">wxID_ANY</property>\r
+ <property name="maximum_size"></property>\r
+ <property name="minimum_size"></property>\r
+ <property name="name">m_panel_wram</property>\r
+ <property name="permission">protected</property>\r
+ <property name="pos"></property>\r
+ <property name="size"></property>\r
+ <property name="subclass"></property>\r
+ <property name="tooltip"></property>\r
+ <property name="validator_data_type"></property>\r
+ <property name="validator_style">wxFILTER_NONE</property>\r
+ <property name="validator_type">wxDefaultValidator</property>\r
+ <property name="validator_variable"></property>\r
+ <property name="window_extra_style"></property>\r
+ <property name="window_name"></property>\r
+ <property name="window_style">wxTAB_TRAVERSAL</property>\r
+ <event name="OnChar"></event>\r
+ <event name="OnEnterWindow"></event>\r
+ <event name="OnEraseBackground"></event>\r
+ <event name="OnKeyDown"></event>\r
+ <event name="OnKeyUp"></event>\r
+ <event name="OnKillFocus"></event>\r
+ <event name="OnLeaveWindow"></event>\r
+ <event name="OnLeftDClick"></event>\r
+ <event name="OnLeftDown"></event>\r
+ <event name="OnLeftUp"></event>\r
+ <event name="OnMiddleDClick"></event>\r
+ <event name="OnMiddleDown"></event>\r
+ <event name="OnMiddleUp"></event>\r
+ <event name="OnMotion"></event>\r
+ <event name="OnMouseEvents"></event>\r
+ <event name="OnMouseWheel"></event>\r
+ <event name="OnPaint"></event>\r
+ <event name="OnRightDClick"></event>\r
+ <event name="OnRightDown"></event>\r
+ <event name="OnRightUp"></event>\r
+ <event name="OnSetFocus"></event>\r
+ <event name="OnSize"></event>\r
+ <event name="OnUpdateUI"></event>\r
+ </object>\r
+ </object>\r
</object>\r
</object>\r
- <object class="sizeritem" expanded="1">\r
+ <object class="sizeritem" expanded="0">\r
<property name="border">0</property>\r
<property name="flag">wxALL|wxEXPAND</property>\r
<property name="proportion">1</property>\r
- <object class="wxPanel" expanded="1">\r
+ <object class="wxPanel" expanded="0">\r
<property name="bg"></property>\r
<property name="context_help"></property>\r
<property name="context_menu">1</property>\r
<event name="OnSetFocus"></event>\r
<event name="OnSize"></event>\r
<event name="OnUpdateUI"></event>\r
- <object class="wxBoxSizer" expanded="1">\r
+ <object class="wxBoxSizer" expanded="0">\r
<property name="minimum_size"></property>\r
<property name="name">bSizer6</property>\r
<property name="orient">wxVERTICAL</property>\r
private:
protected:
- wxNotebook* m_notebook3;
+ wxNotebook* m_notebook;
wxPanel* m_panel_dump;
wxStaticText* m_dump_script_label;
wxChoice* m_dump_script_choice;
};
+///////////////////////////////////////////////////////////////////////////////
+/// Class rampanel
+///////////////////////////////////////////////////////////////////////////////
+class rampanel : public wxPanel
+{
+ private:
+
+ protected:
+ wxStaticText* m_script_label;
+ wxChoice* m_script_choice;
+ wxStaticText* m_ramimage_label;
+ wxFilePickerCtrl* m_ramimage_picker;
+ wxStaticLine* m_staticline1;
+ wxStaticText* m_cpu_label;
+ wxGauge* m_cpu_gauge;
+ wxChoice* m_cpu_increase;
+ wxStaticText* m_cpu_value;
+ wxStaticLine* m_staticline3;
+ wxButton* m_button;
+
+ // Virtual event handlers, overide them in your derived class
+ virtual void dump_button_click( wxCommandEvent& event ) { event.Skip(); }
+
+
+ public:
+
+ rampanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL );
+ ~rampanel();
+
+};
+
#endif //__anago_gui__
t->value = value;
if(t->range != 0){
draw(t);
+ }else{
+ PRINTF(wgT("%s skip"), t->name);
}
console_move(1);
}
-mega <- 0x20000;
-function dump(d, mappernum, increase_cpu, increase_ppu)
+function dump(d, script, mappernum, increase_cpu, increase_ppu)
{
+ const mega = 0x20000;
+ dofile(script);
local vram = board.vram_mirrorfind == true ? 1 : 0;
if(mappernum == -1){
mappernum = board.mappernum;
}
function testrun(
- d, mapper,
+ d, script, mapper,
cpu_trans, cpu_image_size, cpu_device_size,
ppu_trans, ppu_image_size, ppu_device_size
)
{
local trans_empty = 0;
+ dofile(script);
if((board.mappernum != mapper) && (mapper != 0)){
print("mapper number are not connected\n");
print("af:" + board.mappernum + " image:" + mapper + "\n");
}
function program(
- d, mapper,
+ d, script, mapper,
cpu_trans, cpu_image_size, cpu_device_size,
ppu_trans, ppu_image_size, ppu_device_size
)
{
local trans_empty = 0;
+ dofile(script);
if((board.mappernum != mapper) && (mapper != 0)){
return;
}
-#include <stdbool.h>
-#include <stdio.h>
#include <string.h>
+#include "type.h"
+#include "widget.h"
#include "reader_master.h"
-#include "reader_dummy.h"
+#include "memory_manage.h"
-static void dummy_init(void)
-{
-}
-static int dummy_open_close(enum reader_control oc)
-{
- return OK;
-}
-//---- cpu ----
-static void dummy_cpu_read(long address, long length, uint8_t *data)
+struct reader_handle{
+ void (*except)(const wgChar *str);
+};
+
+static const struct reader_handle *dummy_open(void (*except)(const wgChar *str))
{
- printf("%s %06x %04x\n", __FUNCTION__, (int) address, (int) length);
- memset(data, 0x55, length);
+ struct reader_handle *h;
+ h = Malloc(sizeof(struct reader_handle));
+ h->except = except;
+ return h;
}
-static void dummy_cpu_write_6502(long address, long length, const uint8_t *data)
+
+static void dummy_close(const struct reader_handle *h)
{
- printf("%s %04x %04x %02x\n", __FUNCTION__, (int) address, (int) length, (int) *data);
+ Free((void *) h);
}
-static void dummy_cpu_flash_config(long c000x, long c2aaa, long c5555, long unit, bool retry)
+
+/*static void throw(const struct reader_handle *h)
{
- printf("%s %04x %04x %04x %04x\n", __FUNCTION__, (int) c000x, (int) c2aaa, (int) c5555, (int) unit);
-}
-static long dummy_cpu_flash_program(long address, long length, const u8 *data, bool dowait, bool skip)
+#ifdef _UNICODE
+ size_t length = strlen(usb_strerror());
+ wchar_t *mm = Malloc(sizeof(wchar_t) * (length + 1));
+ mbstowcs(mm, usb_strerror(), length + 1);
+ h->except(mm);
+ Free(mm);
+#else
+ h->except(usb_strerror());
+#endif
+}*/
+
+static void dummy_read(const struct reader_handle *h, const struct gauge *g, long address, long length, uint8_t *data)
{
- int i = 0x10;
- printf("%s %06x\n", __FUNCTION__, (int) address);
- if(0){
- while(i != 0){
- printf("%02x ", *data);
- data++;
- i--;
- }
- printf("\n");
+ const int packet = 0x200;
+ while(length >= packet){
+ wait(10);
+ memset(data, 2, packet);
+ data += packet;
+ length -= packet;
+ g->value_add(g->bar, g->label, packet);
+ }
+ if(length != 0){
+ memset(data, 33, length);
+ g->value_add(g->bar, g->label, length);
}
- return 0x100;
}
-static void dummy_cpu_flash_erase(long address, bool dowait)
+static void dummy_init(const struct reader_handle *h)
{
- printf("%s %04x\n", __FUNCTION__, (int) address);
}
-//---- ppu ----
-static void dummy_ppu_read(long address, long length, u8 *data)
+static void dummy_write(const struct reader_handle *h, long address, long length, const uint8_t *data)
{
- printf("%s %06x %04x\n", __FUNCTION__, (int) address, (int) length);
- memset(data, 0x55, length);
+ Sleep(4);
}
-static void dummy_ppu_write(long address, long length, const uint8_t *data)
-{
- printf("%s %04x %04x %02x\n", __FUNCTION__, (int) address, (int) length, (int) *data);
-}
-static void dummy_ppu_flash_config(long c000x, long c2aaa, long c5555, long unit, bool retry)
+
+static void dummy_flash_config(const struct reader_handle *h, long c000x, long c2aaa, long c5555, long unit, bool retry)
{
- printf("%s %04x %04x %04x %04x\n", __FUNCTION__, (int) c000x, (int) c2aaa, (int) c5555, (int) unit);
}
-static long dummy_ppu_flash_program(long address, long length, const u8 *data, bool dowait, bool skip)
+
+static void dummy_flash_erase(const struct reader_handle *h, long address, bool dowait)
{
- int i = 0x10;
- printf("%s %06x\n", __FUNCTION__, (int) address);
- if(0){
- while(i != 0){
- printf("%02x ", *data);
- data++;
- i--;
- }
- printf("\n");
+ if(dowait == true){
+ wait(10);
}
- return 0x100;
}
-static void dummy_ppu_flash_erase(long address, bool dowait)
+static long dummy_flash_program(const struct reader_handle *h, const struct gauge *g, long address, long length, const uint8_t *data, bool dowait, bool skip)
{
- printf("%s %04x\n", __FUNCTION__, (int) address);
+ if(dowait == true){
+ wait(20);
+ }
+ g->value_add(g->bar, g->label, 0x200);
+ return 0x200;
}
-static void dummy_flash_status(uint8_t s[2])
+static void dummy_flash_status(const struct reader_handle *h, uint8_t s[2])
{
s[0] = 0;
s[1] = 0;
}
-static void dummy_flash_device_get(uint8_t s[2])
+
+static void dummy_flash_device_get(const struct reader_handle *h, uint8_t s[2])
{
- s[0] = 0x01;
- s[1] = 0xa4;
+ s[0] = 0;
+ s[1] = 0;
}
-static uint8_t dummy_vram_connection(void)
+
+static uint8_t dummy_vram_connection(const struct reader_handle *h)
{
- return 0x05;
+ return 0;
}
+
const struct reader_driver DRIVER_DUMMY = {
- .name = "tester",
- .open_or_close = dummy_open_close,
- .init = dummy_init,
- .cpu_read = dummy_cpu_read, .ppu_read = dummy_ppu_read,
- .cpu_write_6502 = dummy_cpu_write_6502,
- .flash_support = true,
- .ppu_write = dummy_ppu_write,
- .cpu_flash_config = dummy_cpu_flash_config,
- .cpu_flash_erase = dummy_cpu_flash_erase,
- .cpu_flash_program = dummy_cpu_flash_program,
- .cpu_flash_device_get = dummy_flash_device_get,
- .ppu_flash_config = dummy_ppu_flash_config,
- .ppu_flash_erase = dummy_ppu_flash_erase,
- .ppu_flash_program = dummy_ppu_flash_program,
- .ppu_flash_device_get = dummy_flash_device_get,
- .flash_status = dummy_flash_status,
- .vram_connection = dummy_vram_connection
+ .cpu = {
+ .memory_read = dummy_read,
+ .memory_write = dummy_write,
+ .flash_config = dummy_flash_config,
+ .flash_erase = dummy_flash_erase,
+ .flash_program = dummy_flash_program,
+ .flash_device_get = dummy_flash_device_get
+ }, .ppu = {
+ .memory_read = dummy_read,
+ .memory_write = dummy_write,
+ .flash_config = dummy_flash_config,
+ .flash_erase = dummy_flash_erase,
+ .flash_program = dummy_flash_program,
+ .flash_device_get = dummy_flash_device_get
+ }, .control = {
+ .name = wgT("dummy"),
+ .open = dummy_open, .close = dummy_close,
+ .init = dummy_init,
+ .flash_status = dummy_flash_status,
+ .vram_connection = dummy_vram_connection
+ }
};
d->memory.offset = 0;
d->memory.data = Malloc(d->memory.size);
d->gauge.range_set(d->gauge.bar, d->memory.size);
- if(d->memory.size == 0){
- d->gauge.label_set(d->gauge.label, wgT("skip"));
- }else{
- d->gauge.value_set(d->gauge.bar, d->gauge.label, 0);
- }
+ d->gauge.value_set(d->gauge.bar, d->gauge.label, 0);
}
//test »þ/1ÅÙÌܤΠcall ¤Ç»ÈÍÑ
static bool script_execute(HSQUIRRELVM v, struct dump_config *d)
{
bool ret = true;
- if(SQ_FAILED(sqstd_dofile(v, _SC("dumpcore.nut"), SQFalse, SQTrue))){
+ if(SQ_FAILED(sqstd_dofile(v, wgT("dumpcore.nut"), SQFalse, SQTrue))){
d->log.append(d->log.object, wgT("dump core script error\n"));
ret = false;
- }else if(SQ_FAILED(sqstd_dofile(v, d->script, SQFalse, SQTrue))){
+/* }else if(SQ_FAILED(sqstd_dofile(v, d->script, SQFalse, SQTrue))){
d->log.append(d->log.object, wgT("%s open error\n"), d->script);
- ret = false;
+ ret = false;*/
}else{
SQRESULT r = qr_call(
- v, wgT("dump"), (SQUserPointer) d, true,
+ v, wgT("dump"), (SQUserPointer) d, d->script,
3, d->mappernum, d->cpu.increase, d->ppu.increase
);
if(SQ_FAILED(r)){
}
d->control->init(d->handle);
if(connection_check(d->handle, &d->log, d->cpu.access, d->ppu.access) == false){
+ d->control->close(d->handle);
return false;
}
{
static void gauge_init(struct flash_memory_driver *t)
{
t->gauge.range_set(t->gauge.bar, t->programming.count);
- if(t->programming.count == 0){
- t->gauge.label_set(t->gauge.label, wgT("skip"));
- }else{
- t->gauge.value_set(t->gauge.bar, t->gauge.label, t->programming.offset);
- }
+
+ t->gauge.value_set(t->gauge.bar, t->gauge.label, 0);
}
static bool program_memoryarea(HSQUIRRELVM co, const struct reader_handle *h, struct flash_memory_driver *t, bool compare, SQInteger *state, struct textcontrol *log)
}
}
- sq_wakeupvm(co, SQFalse, SQFalse, SQTrue/*, SQTrue*/);
+ sq_wakeupvm(co, SQFalse, SQFalse, SQTrue, SQFalse);
*state = sq_getvmstate(co);
}else{
program_execute(h, t);
static bool script_execute(HSQUIRRELVM v, const wgChar *function, struct program_config *c)
{
bool ret = true;
- if(SQ_FAILED(sqstd_dofile(v, _SC("flashcore.nut"), SQFalse, SQTrue))){
+ if(SQ_FAILED(sqstd_dofile(v, _SC("programcore.nut"), SQFalse, SQTrue))){
c->log.append(c->log.object, wgT("flash core script error\n"));
ret = false;
- }else if(SQ_FAILED(sqstd_dofile(v, c->script, SQFalse, SQTrue))){
+/* }else if(SQ_FAILED(sqstd_dofile(v, c->script, SQFalse, SQTrue))){
c->log.append(c->log.object, wgT("%s open error\n"), c->script);
- ret = false;
+ ret = false;*/
}else{
SQRESULT r = qr_call(
- v, function, (SQUserPointer) c, true,
+ v, function, (SQUserPointer) c, c->script,
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
//program start, reader finalize
if(connection_check(c->handle, &c->log, c->cpu.access, c->ppu.access) == false){
nesbuffer_free(&rom, 0);
+ c->control->close(c->handle);
return false;
}
bool ret = zendan(c);
HSQUIRRELVM qr_open(const struct textcontrol *p)
{
HSQUIRRELVM v = sq_open(0x400);
- sqstd_seterrorhandlers(v);
- sqstd_register_iolib(v);
if(p == NULL){
sq_setprintfunc(v, print_stdout);
}else{
sq_setprintfunc(v, print_other);
}
sq_pushroottable(v);
+ sqstd_seterrorhandlers(v);
+ sqstd_register_iolib(v);
return v;
}
sq_pop(v, 1);
}
-SQRESULT qr_call(HSQUIRRELVM v, const SQChar *functionname, SQUserPointer up, bool settop, int argnum, ...)
+SQRESULT qr_call(HSQUIRRELVM v, const SQChar *functionname, SQUserPointer up, const SQChar *scriptfile, int argnum, ...)
{
SQRESULT r = SQ_ERROR;
SQInteger top = sq_gettop(v);
va_start(ap, argnum);
sq_pushroottable(v);
sq_pushuserpointer(v, up);
+ sq_pushstring(v, scriptfile, -1);
for(i = 0; i < argnum; i++){
sq_pushinteger(v, va_arg(ap, long));
}
- r = sq_call(v, 2 + argnum, SQFalse, SQTrue); //calls the function
- }
- if(settop == true){
- sq_settop(v, top); //restores the original stack size
+ r = sq_call(v, 3 + argnum, SQFalse, SQTrue); //calls the function
}
+ sq_settop(v, top); //restores the original stack size
return r;
}
struct textcontrol;
HSQUIRRELVM qr_open(struct textcontrol *p);
void qr_function_register_global(HSQUIRRELVM v, const wgChar *name, SQFUNCTION f);
-SQRESULT qr_call(HSQUIRRELVM v, const SQChar *functionname, SQUserPointer up, bool settop, int argnum, ...);
+SQRESULT qr_call(HSQUIRRELVM v, const SQChar *functionname, SQUserPointer up, const SQChar *scriptfile, int argnum, ...);
void qr_close(HSQUIRRELVM v);
SQRESULT qr_argument_get(HSQUIRRELVM v, SQInteger num, ...);
SQRESULT qr_userpointer_get(HSQUIRRELVM v, SQUserPointer *up);