#include <kazzo_task.h>
#include "type.h"
#include "widget.h"
-#include "header.h"
+#include "romimage.h"
#include "memory_manage.h"
#include "reader_master.h"
#include "squirrel_wrap.h"
#include "flash_device.h"
-#include "progress.h"
#include "script_common.h"
#include "script_program.h"
t->command_change = false;
}
-/* printf("programming %s ROM area 0x%06x...\n", name, t->memory->offset);
- fflush(stdout);*/
return sq_suspendvm(v);
}
+
static void program_execute(const struct reader_handle *h, struct flash_memory_driver *t)
{
const long w = t->access->flash_program(
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->gauge.label, t->programming.offset);
- if(t->programming.count == 0){
- t->gauge.label_set(t->gauge.label, wgT("skip"));
- }
+
+ 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)
if(t->programming.length == 0){
if(t->programming.offset != 0 && compare == true){
if(program_compare(h, t) == false){
- log->append(log->object, wgT("%s memory compare error\n"), t->memory.name);
+ log->append(log->object, wgT("%s memory compare error, offset 0x%06x\n"), t->memory.name, t->programming.offset);
return false;
}
}
- 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))){
- c->log.append(c->log.object, wgT("%s open error\n"), c->script);
- 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
return ret;
}
-static void zendan(struct program_config *c)
+static bool zendan(struct program_config *c)
{
//script test run
{
if(script_execute(v, wgT("testrun"), c) == false){
qr_close(v);
- return;
+ return false;
}
qr_close(v);
assert(c->cpu.memory.size != 0);
if(c->cpu.programming.count % c->cpu.memory.size != 0){
c->log.append(c->log.object, wgT("logical error: cpu_programsize is not connected 0x%06x/0x%06x\n"), (int) c->cpu.programming.count, (int) c->cpu.memory.size);
- return;
+ return false;
}
if(c->ppu.memory.size != 0){
if(c->ppu.programming.count % c->ppu.memory.size != 0){
c->log.append(c->log.object, wgT("logical error: ppu_programsize is not connected 0x%06x/0x%06x\n"), (int) c->ppu.programming.count, (int) c->ppu.memory.size);
- return;
+ return false;
}
}
}
script_execute(v, wgT("program"), c);
qr_close(v);
}
+ return true;
}
static bool memory_image_init(const struct memory *from, struct flash_memory_driver *t, struct textcontrol *log)
return true;
}
-void script_program_execute(struct program_config *c)
+bool script_program_execute(struct program_config *c)
{
//rom image load
struct romimage rom;
if(nesfile_load(&c->log, c->target, &rom) == false){
c->log.append(c->log.object, wgT("ROM image open error"));
- return;
+ return false;
}
//variable init
c->mappernum = rom.mappernum;
c->cpu.memory.name = wgT("Program Flash");
if(memory_image_init(&rom.cpu_rom, &c->cpu, &c->log) == false){
nesbuffer_free(&rom, 0);
- return;
+ return false;
}
c->ppu.memory.name = wgT("Charcter Flash");
if(memory_image_init(&rom.ppu_rom, &c->ppu, &c->log) == false){
nesbuffer_free(&rom, 0);
- return;
+ return false;
}
//reader initalize
- c->handle = c->control->open(c->except);
+ c->handle = c->control->open(c->except, &c->log);
if(c->handle == NULL){
c->log.append(c->log.object, wgT("reader open error\n"));
nesbuffer_free(&rom, 0);
- return;
+ return false;
}
//program start, reader finalize
if(connection_check(c->handle, &c->log, c->cpu.access, c->ppu.access) == false){
nesbuffer_free(&rom, 0);
- return;
+ c->control->close(c->handle);
+ return false;
}
- zendan(c);
+ bool ret = zendan(c);
c->control->close(c->handle);
c->handle = NULL;
nesbuffer_free(&rom, 0);
+ return ret;
}