From 5075e0cf6afb384fdc84600a44d261a31dcf6935 Mon Sep 17 00:00:00 2001 From: naruko Date: Sat, 6 Jun 2015 09:26:23 +0000 Subject: [PATCH] flash programming is supported git-svn-id: svn+ssh://svn.osdn.net/svnroot/unagi@419 24ea1065-a21e-4ca1-99c9-f5125deb0858 --- client/trunk/anago/Makefile.windows | 2 +- client/trunk/anago/anago_cui.c | 9 ++-- client/trunk/anago/anago_gui.cpp | 4 +- client/trunk/anago/bandai_fcg1.ad | 2 +- client/trunk/anago/namcot_19.ai | 12 +++-- client/trunk/anago/script_dump.c | 13 +++--- client/trunk/anago/squirrel_wrap.c | 2 +- .../trunk/anago/{sunsoft_fme.ad => sunsoft_fme.ag} | 54 +++++++++++----------- 8 files changed, 52 insertions(+), 46 deletions(-) rename client/trunk/anago/{sunsoft_fme.ad => sunsoft_fme.ag} (74%) diff --git a/client/trunk/anago/Makefile.windows b/client/trunk/anago/Makefile.windows index ebc3770..d28e211 100644 --- a/client/trunk/anago/Makefile.windows +++ b/client/trunk/anago/Makefile.windows @@ -1,7 +1,7 @@ APP_CUI = anago.exe APP_GUI = anago_wx.exe LIBUSB = ../libusb-win32-bin-1.2.6.0 -SQUIRREL = ../SQUIRREL224 +SQUIRREL = ../SQUIRREL225 KAZZO = ../../kazzo/include WX_CONFIG = /d/dev/wxWidgets/build_unicode_sound3/wx-config CPPFLAGS = -D_UNICODE diff --git a/client/trunk/anago/anago_cui.c b/client/trunk/anago/anago_cui.c index 2ead87b..81a6143 100644 --- a/client/trunk/anago/anago_cui.c +++ b/client/trunk/anago/anago_cui.c @@ -14,6 +14,7 @@ #include "script_dump.h" #include "flash_device.h" #include "script_program.h" +#include "crc32.h" #ifdef _UNICODE #define PUTS _putws @@ -249,14 +250,16 @@ static void vram_scan(int c, wgChar **v, const struct reader_driver *r) r->control.close(h); } -#include "crc32.h" static void crc32_dump(const wgChar *name, const wgChar *str, struct memory *m) { - const long banksize = STRTOUL(str, NULL, 0x10); + long banksize = STRTOUL(str, NULL, 0x10); if(banksize < 0x400 || (banksize & 0xff) != 0){ PUTS(wgT("banksize requires over 0x400")); return; } + if(banksize > m->size){ + banksize = m->size; + } int i, j; PRINTF(wgT("%s 0x%x byte\n"), name, m->size); for(i = 0, j = 0; i < m->size; i += banksize, j++){ @@ -291,7 +294,7 @@ static void usage(const wgChar *v) PUTS(wgT("fF- flash program with kazzo")); PUTS(wgT("r - workram read with kazzo")); PUTS(wgT("w - workram write with kazzo")); - PUTS(wgT("V - VRAM A10 scan")); + PUTS(wgT("v - VRAM A10 scan with kazzo")); PUTS(wgT("b - display each CRC32s by required size")); if(DEBUG == 1){ PUTS(wgT("z - ROM dump for test")); diff --git a/client/trunk/anago/anago_gui.cpp b/client/trunk/anago/anago_gui.cpp index a3f1064..3cf644e 100644 --- a/client/trunk/anago/anago_gui.cpp +++ b/client/trunk/anago/anago_gui.cpp @@ -1,4 +1,4 @@ -/////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////// // C++ code generated with wxFormBuilder (version Sep 8 2010) // http://www.wxformbuilder.org/ // @@ -54,7 +54,7 @@ panel_version::panel_version( wxWindow* parent, wxWindowID id, const wxPoint& po bSizer30->Add( m_version_title, 0, wxALL, 2 ); - m_version_copyright = new wxStaticText( this, wxID_ANY, wxT("(C) unagi development team 2010"), wxDefaultPosition, wxDefaultSize, 0 ); + m_version_copyright = new wxStaticText( this, wxID_ANY, wxT("(C) unagi development team 2010-2014"), wxDefaultPosition, wxDefaultSize, 0 ); m_version_copyright->Wrap( -1 ); bSizer30->Add( m_version_copyright, 0, wxALL, 2 ); diff --git a/client/trunk/anago/bandai_fcg1.ad b/client/trunk/anago/bandai_fcg1.ad index a8e6bc4..619239a 100644 --- a/client/trunk/anago/bandai_fcg1.ad +++ b/client/trunk/anago/bandai_fcg1.ad @@ -29,4 +29,4 @@ board <- { }; const register_offset = 0x6000; -dofile("fcg3.ai"); +dofile("lz93d50.ai"); diff --git a/client/trunk/anago/namcot_19.ai b/client/trunk/anago/namcot_19.ai index 07b5c69..f4a9a15 100644 --- a/client/trunk/anago/namcot_19.ai +++ b/client/trunk/anago/namcot_19.ai @@ -12,13 +12,15 @@ I have never seen labeled IC with '106'. */ function cpu_dump(d, pagesize, banksize) { - for(local i = 0; i < pagesize - 2; i += 2){ + for(local i = 0; i < pagesize - 1 ; i += 1){ cpu_write(d, 0xe000, i); - cpu_write(d, 0xe800, i | 1); - cpu_read(d, 0x8000, banksize * 2); + cpu_read(d, 0x8000, banksize); } - cpu_write(d, 0xf000, 0x3e); - cpu_read(d, 0xc000, banksize * 2); +/* +note: databus conficts on $c800-$dfff. ($c800-$dfff & $7fff) are internal RAM port.... +Unfortunately kazzo generates incomple read wave form. do not use $c800-$dfff. +*/ + cpu_read(d, 0xe000, banksize); } function ppu_dump(d, pagesize, banksize) diff --git a/client/trunk/anago/script_dump.c b/client/trunk/anago/script_dump.c index c81e9c8..d653f62 100644 --- a/client/trunk/anago/script_dump.c +++ b/client/trunk/anago/script_dump.c @@ -348,10 +348,11 @@ static SQInteger memory_size_set(HSQUIRRELVM v) r = qr_argument_get(v, 2, &d->cpu.memory.size, &d->ppu.memory.size); return r; } - +//sq_pushroottable(v); //push the root table(were the globals of the script will are stored) static bool script_execute(HSQUIRRELVM v, struct dump_config *d) { bool ret = true; +// sq_pushroottable(v); 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; @@ -403,6 +404,7 @@ bool script_dump_execute(struct dump_config *d) return false; } qr_close(v); + v = NULL; } d->handle = d->control->open(d->except, &d->log); @@ -410,13 +412,9 @@ bool script_dump_execute(struct dump_config *d) d->log.append(d->log.object, wgT("reader open error\n")); return false; } -/* 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; - }*/ + //d->log.append(d->log.object, wgT("haohao\n")); { - HSQUIRRELVM v = qr_open(&d->log); + volatile HSQUIRRELVM v = qr_open(&d->log); qr_function_register_global(v, wgT("memory_new"), memory_new); qr_function_register_global(v, wgT("nesfile_save"), nesfile_save); qr_function_register_global(v, wgT("cpu_write"), cpu_write); @@ -425,6 +423,7 @@ bool script_dump_execute(struct dump_config *d) qr_function_register_global(v, wgT("ppu_ramfind"), ppu_ramfind); script_execute(v, d); qr_close(v); + v = NULL; } d->control->close(d->handle); d->handle = NULL; diff --git a/client/trunk/anago/squirrel_wrap.c b/client/trunk/anago/squirrel_wrap.c index e94d400..eb59f74 100644 --- a/client/trunk/anago/squirrel_wrap.c +++ b/client/trunk/anago/squirrel_wrap.c @@ -42,9 +42,9 @@ HSQUIRRELVM qr_open(const struct textcontrol *p) sq_setprintfunc(v, print_other); } sq_pushroottable(v); - sqstd_seterrorhandlers(v); sqstd_register_iolib(v); sqstd_register_stringlib(v); + sqstd_seterrorhandlers(v); return v; } diff --git a/client/trunk/anago/sunsoft_fme.ad b/client/trunk/anago/sunsoft_fme.ag similarity index 74% rename from client/trunk/anago/sunsoft_fme.ad rename to client/trunk/anago/sunsoft_fme.ag index 48991c2..6f5b3e3 100644 --- a/client/trunk/anago/sunsoft_fme.ad +++ b/client/trunk/anago/sunsoft_fme.ag @@ -18,8 +18,8 @@ SUNSOFT-5A, SUNSOFT-5B, FME-7 $6000-$7fff 7:0 RAM data (if RAM is enabled) $8000-$9fff 3:0 memory register address $a000-$bfff 7:0 memory register data -$c000-$dfff 3:0 audio register address -$e000-$ffff 7:0 audio register data +$c000-$dfff 3:0 audio register address (SUNSOFT-5B only) +$e000-$ffff 7:0 audio register data (SUNSOFT-5B only) [CPU readmap] $6000-$7fff 7:0 Program ROM bank #0 or RAM @@ -39,7 +39,7 @@ adr bit assignments ------------------------- 0-7 7:0 Charcter ROM bank #0 to #7 8 7 RAM enable bit 0:disable 1:enable - 6 memory select at $6000-$7fff 0:ROM 1:RAM + 6 memory select on $6000-$7fff 0:ROM 1:RAM 4:0 CPU ROM page for bank #0 9-b 4:0 CPU ROM page for bank #1 to #3 c 1:0 PPU area VRAM control @@ -55,7 +55,7 @@ address 8, bit7:6 behave on FME-7 11 enabled RAM audio register -(not analysed yet) +(not analyzed yet) */ function sunsoft5_write(d, register_address, data) @@ -66,16 +66,16 @@ function sunsoft5_write(d, register_address, data) function cpu_dump(d, pagesize, banksize) { + local regaddress = 9 + local cpuaddress = 0x8000 /* - //dump ROM data via $6000-$7fff - for(local i = 0; i < pagesize; i++){ - sunsoft5_write(d, 8, i); - cpu_read(d, 0x6000, banksize); - } + //*debug* dump ROM data via $6000-$7fff + regaddress = 8 + cpuaddress = 0x6000 */ for(local i = 0; i < pagesize - 1; i++){ - sunsoft5_write(d, 9, i); - cpu_read(d, 0x8000, banksize); + sunsoft5_write(d, regaddress, i); + cpu_read(d, cpuaddress, banksize); } cpu_read(d, 0xe000, banksize); } @@ -103,28 +103,32 @@ CPU memory bank cpu address|rom address |page|task $8000-$9fff|0x02000-0x03fff|1 |write 0x2aaa $a000-$bfff|0x04000-0x05fff|2 |write 0x5555 -$c000-$dfff|n * 0x2000 |n |program area +$c000-$dfff|n * 0x2000 |n |programming area $e000-$ffff|0x3c000-0x3ffff|fix |program last page PPU memory bank ppu address |rom address |page|task -0x0000-0x03ff|0x02800-0x02fff|0x0a|write 0x2aaa -0x0400-0x07ff|0x05000-0x057ff|0x14|write 0x5555 -0x0800-0x0fff|未使用 -0x1000-0x1fff|n * 0x1000 |n |program area +0x0000-0x0fff|n * 0x1000 |n |programming area +0x1000-0x13ff|0x02800-0x02fff|0x0a|write 0x2aaa +0x1400-0x17ff|0x05000-0x057ff|0x15|write 0x5555 +0x1800-0x1fff|未使用 */ function program_initalize(d, cpu_banksize, ppu_banksize) { - sunsoft5_write(d, 8, 0x40); //disable W-RAM + sunsoft5_write(d, 8, 1 << 6); //disable W-RAM - cpu_command(d, 0x2aaa, 0xe000, cpu_banksize); - cpu_command(d, 0x5555, 0xe000, cpu_banksize); + cpu_command(d, 0x2aaa, 0xa000, cpu_banksize); + cpu_command(d, 0x5555, 0xc000, cpu_banksize); sunsoft5_write(d, 0xa,1); sunsoft5_write(d, 0xb,2); ppu_command(d, 0x2aaa, 0x1000, ppu_banksize); ppu_command(d, 0x5555, 0x1400, ppu_banksize); ppu_command(d, 0x0000, 0x1800, ppu_banksize); + //なぜかよくわからないが電源投入直後の erase に失敗する (2度は必ず成功する) +/* for(local j = 0; j < 0x80; j++){ + sunsoft5_write(d, j & 0x07, j); + }*/ sunsoft5_write(d, 4, 0x0a); sunsoft5_write(d, 5, 0x15); sunsoft5_write(d, 6, 0); @@ -133,23 +137,21 @@ function program_initalize(d, cpu_banksize, ppu_banksize) function cpu_transfer(d, start, end, cpu_banksize) { for(local i = start; i < end - 1; i += 1){ - sunsoft5_write(d, 0xb, 3); + sunsoft5_write(d, 9, i); cpu_program(d, 0x8000, cpu_banksize); } - cpu_program(d, 0xe000, cpu_banksize); + //$6000-$7fff への不正アクセスを避けるため $e000-$ffff は使用しない + sunsoft5_write(d, 9, 0xff & 0x1f); + cpu_program(d, 0x8000, cpu_banksize); } function ppu_transfer(d, start, end, ppu_banksize) { -/* local mul = 1; + local mul = 4 for(local i = start; i < end; i += mul){ for(local j = 0; j < mul; j++){ sunsoft5_write(d, j, i + j); } ppu_program(d, 0x0000, ppu_banksize * mul); - }*/ - for(local i = start; i < end; i += 1){ - sunsoft5_write(d, 4, i); - ppu_program(d, 0x1000, ppu_banksize); } } -- 2.11.0