int main(int argc, char **argv) { int64_t position = 0; int64_t insize; int64_t outsize; char *buffer = NULL; #ifdef LOGFIX /* set up the log */ int retcode = ERR_CODE; struct SetupList setup; retcode = zvm_setup(&setup); retcode = log_set(&setup); if(retcode) return retcode; #endif /* allocate buffer */ if((buffer = (char*) malloc(CHUNK_SIZE)) == NULL) LEAVE(buffer, -1); /* copy input channel to output channel */ while((insize = zvm_pread(InputChannel, buffer, CHUNK_SIZE, position)) > 0) { outsize = zvm_pwrite(OutputChannel, buffer, insize, position); fprintf(stderr, "read [%lld] bytes, written %lld bytes\n", insize, outsize); if(insize != outsize) LEAVE(buffer, -2); /* check if some bytes lost in action */ position += insize; fprintf(stderr, "position = %lld\n", position); } LEAVE(buffer, 0) return 0; /* not reachable */ }
void on_qso_cancel_clicked (GtkButton *button, gpointer user_data) { gtk_widget_hide(wqsoeditor); actlog = 0; log_set(0); display_status("nothing changed in log."); }
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 = &r->control; config.cpu.access = &r->cpu; config.ppu.access = &r->ppu; config.compare = false; switch(v[1][0]){ case wgT('F'): case wgT('X'): config.compare = true; break; } switch(c){ case 5: {//mode script target cpu_flash_device wgChar trans = wgT('f'); if(v[1][1] != wgT('\0')){ trans = v[1][1]; } if(program_rom_set(v[4], trans, &config.cpu.memory, &config.cpu.flash) == false){ return; } if(program_rom_set(wgT("dummy"), wgT('e'), &config.ppu.memory, &config.ppu.flash) == false){ assert(0); return; } }break; case 6: { //mode script target cpu_flash_device ppu_flash_device wgChar trans = wgT('f'); if(v[1][1] != wgT('\0')){ trans = v[1][1]; } if(program_rom_set(v[4], trans, &config.cpu.memory, &config.cpu.flash) == false){ return; } trans = wgT('f'); if(v[1][1] != wgT('\0') && v[1][2] != wgT('\0')){ trans = v[1][2]; } if(program_rom_set(v[5], trans, &config.ppu.memory, &config.ppu.flash) == false){ return; } }break; default: PUTS(wgT("mode script target cpu_flash_device ppu_flash_device")); return; } log_set(&config.log); cui_gauge_new(&config.cpu.gauge, wgT("Program Flash"), 2, -2); cui_gauge_new(&config.ppu.gauge, wgT("Charcter Flash"), 1, -1); config.except = except; script_program_execute(&config); cui_gauge_destory(&config.cpu.gauge); cui_gauge_destory(&config.ppu.gauge); }
void on_clear_logentry_activate(GtkMenuItem *menuitem, gpointer user_data) { if (actlog == 0) //only clear window { log_set(0); return; } else { log_delete_entry(actlog); log_shift_entries(actlog); actlog = 0; log_set(0); display_status("log entry cleared."); log_store(); } }
void on_qso_clear_clicked (GtkButton *button, gpointer user_data) { log_search(); if (actlog > 0) { log_delete_entry(actlog); log_shift_entries(actlog); actlog = 0; log_set(0); display_status("log entry cleared."); log_store(); } else { log_set(0); display_status("nothing changed in log."); } gtk_widget_hide(wqsoeditor); }
// at the moment unused void on_delete1_activate(GtkMenuItem *menuitem, gpointer user_data) { { log_delete_all(); lb.logsize = 0; log_list(); log_set(0); log_store(); } display_status("Why did you clear your log? Work them again!"); }
void on_archivate_activate(GtkMenuItem *menuitem, gpointer user_data) { { log_archivate(); log_delete_all(); log_list(); log_set(0); log_store(); } display_status("(log has been archivated on your demand.)"); }
void on_logentry_clear_clicked (GtkButton *button, gpointer user_data) { log_search(); gtk_widget_hide(Wsearchlogentr); if (actlog == 0) //only clear window { log_set(0); display_status("entry was not yet stored, only mask cleared."); return; } else { log_delete_entry(actlog); log_shift_entries(actlog); actlog = 0; log_set(0); display_status("log entry cleared."); log_store(); } }
void loglist_select(GtkCList *clist, gint row, gint column, GdkEventButton *event, gpointer user_data) { actlog = row + 1; log_set (actlog); gtk_widget_hide(wlistalllog); if (log_on == 0) { gtk_widget_show(wqsoeditor); } if (log_on == 0) { gtk_widget_show(wqsoeditor); } display_status("log entry loaded, You can edit it!"); }
void on_logentry_edit_clicked(GtkButton *button, gpointer user_data) { log_search(); gtk_widget_hide(Wsearchlogentr); if (actlog == 0) { return; } if (log_on == 0) { gtk_widget_show(wqsoeditor); } log_set(actlog); display_status("log entry loaded, You can edit it!"); }
static void crc32_display(int c, wgChar **v) { if(c <= 3){ PUTS(wgT("anago b [filename] [program ROM banksize]")); return; } struct romimage r; struct textcontrol log; log_set(&log); if(nesfile_load(&log, v[2], &r) == false){ return; } crc32_dump(wgT("Program ROM"), v[3], &r.cpu_rom); if(c == 5 && r.ppu_rom.size != 0){ crc32_dump(wgT("Charcter ROM"), v[4], &r.ppu_rom); } nesbuffer_free(&r, 0); }
static void vram_scan(int c, wgChar **v, const struct reader_driver *r) { const struct reader_handle *h; struct textcontrol log; if(c == 3){ PUTS(wgT("anago F [address] [data]...")); return; } log_set(&log); h = r->control.open(except, &log); if(c == 2){ PRINTF(wgT("%02x\n"), r->control.vram_connection(h)); }else{ const long address = STRTOUL(v[2], NULL, 0x10); int i; for(i = 3; i < c; i++){ const uint8_t d = STRTOUL(v[i], NULL, 0x10); r->cpu.memory_write(h, address, 1, &d); PRINTF(wgT("$%04x = 0x%02x->0x%02x\n"), (int) address, (int) d, r->control.vram_connection(h)); } } r->control.close(h); }
static void dump(int c, wgChar **v, const struct reader_driver *r) { struct dump_config config; if(c < 4){ PUTS(wgT("argument error")); return; } config.cpu.increase = INCREASE_AUTO; config.ppu.increase = 1; config.progress = true; switch(v[1][0]){ case wgT('d'): case wgT('z'): config.mode = MODE_ROM_DUMP; break; case wgT('D'): config.mode = MODE_ROM_DUMP; config.progress = false; break; case wgT('r'): case wgT('R'): config.mode = MODE_RAM_READ; break; case wgT('w'): case wgT('W'): config.mode = MODE_RAM_WRITE; break; } switch(v[1][1]){ case wgT('1'): config.cpu.increase = 1; break; case wgT('2'): config.cpu.increase = 2; break; case wgT('4'): config.cpu.increase = 4; break; } if(v[1][1] != wgT('\0')){ switch(v[1][2]){ case wgT('2'): config.ppu.increase = 2; break; case wgT('4'): config.ppu.increase = 4; break; } } config.script = v[2]; config.target = v[3]; config.control = &r->control; config.cpu.access = &r->cpu; config.ppu.access = &r->ppu; if(config.mode == MODE_ROM_DUMP){ cui_gauge_new(&config.cpu.gauge, wgT("Program ROM"), 2, -2); }else{ cui_gauge_new(&config.cpu.gauge, wgT("Work RAM"), 2, -2); } cui_gauge_new(&config.ppu.gauge, wgT("Charcter ROM"), 1, -1); config.except = except; config.mappernum = -1; config.battery = false; if(c == 5){ const wgChar *t = v[4]; if(*t == 'b' || *t == 'B'){ config.battery = true; t += 1; } if(*t != '\0'){ #ifdef _UNICODE config.mappernum = _wtoi(t); #else config.mappernum = atoi(t); #endif } } log_set(&config.log); if(config.mode == MODE_ROM_DUMP){ script_dump_execute(&config); }else{ script_workram_execute(&config); } cui_gauge_destory(&config.cpu.gauge); cui_gauge_destory(&config.ppu.gauge); }