/*! \brief Write the snapshot module for the ACIA \param p Pointer to the snapshot data \return 0 on success, -1 on error \remark Is it sensible to put the ACIA into a snapshot? It is unlikely the "other side" of the connection will be able to handle this case if a transfer was under way, anyway. \todo FIXME!!! Error check. \todo FIXME!!! If no connection, emulate carrier lost or so. */ int myacia_snapshot_write_module(snapshot_t *p) { snapshot_module_t *m; m = snapshot_module_create(p, module_name, (BYTE)ACIA_DUMP_VER_MAJOR, (BYTE)ACIA_DUMP_VER_MINOR); if (m == NULL) { return -1; } SMW_B(m, acia.txdata); SMW_B(m, acia.rxdata); SMW_B(m, (BYTE)(acia_get_status() | (acia.irq ? ACIA_SR_BITS_IRQ : 0))); SMW_B(m, acia.cmd); SMW_B(m, acia.ctrl); SMW_B(m, (BYTE)(acia.in_tx)); if (acia.alarm_active_tx) { SMW_DW(m, (acia.alarm_clk_tx - myclk)); } else { SMW_DW(m, 0); } /* new with VICE 2.0.9 */ if (acia.alarm_active_rx) { SMW_DW(m, (acia.alarm_clk_rx - myclk)); } else { SMW_DW(m, 0); } snapshot_module_close(m); return 0; }
int interrupt_write_sc_snapshot(interrupt_cpu_status_t *cs, snapshot_module_t *m) { if (SMW_DW(m, cs->irq_delay_cycles) < 0 || SMW_DW(m, cs->nmi_delay_cycles) < 0) { return -1; } return 0; }
int interrupt_write_new_snapshot(interrupt_cpu_status_t *cs, snapshot_module_t *m) { if (SMW_DW(m, cs->nirq) < 0 || SMW_DW(m, cs->nnmi) < 0 || SMW_DW(m, cs->global_pending_int) < 0) { return -1; } return 0; }
int interrupt_write_snapshot(interrupt_cpu_status_t *cs, snapshot_module_t *m) { /* FIXME: could we avoid some of this info? */ if (SMW_DW(m, cs->irq_clk) < 0 || SMW_DW(m, cs->nmi_clk) < 0 || SMW_DW(m, (DWORD)cs->num_last_stolen_cycles) < 0 || SMW_DW(m, cs->last_stolen_cycles_clk) < 0) return -1; return 0; }
static int tape_snapshot_write_tapimage_module(snapshot_t *s) { snapshot_module_t *m; FILE *ftap; long pos, tap_size; BYTE buffer[256]; int i; m = snapshot_module_create(s, "TAPIMAGE", TAPIMAGE_SNAP_MAJOR, TAPIMAGE_SNAP_MINOR); if (m == NULL) return -1; /* get the file descriptor */ ftap = ((tap_t*)tape_image_dev1->data)->fd; if (!ftap) { log_error(tape_snapshot_log, "Cannot open tapfile for reading"); return -1; } /* remeber current position */ pos = ftell(ftap); /* move to end and get size of file */ if (fseek(ftap, 0, SEEK_END) != 0) { log_error(tape_snapshot_log, "Cannot move to end of tapfile"); return -1; } tap_size = ftell(ftap); if (SMW_DW(m, tap_size)) { fseek(ftap, pos, SEEK_SET); log_error(tape_snapshot_log, "Cannot write size of tap image"); } /* move to beginning */ if (fseek(ftap, 0, SEEK_SET) != 0) { log_error(tape_snapshot_log, "Cannot move to beginning of tapfile"); return -1; } /* read every BYTE and write to snapshot module */ while (tap_size > 0) { i = fread(buffer, 1, 256, ftap); if (SMW_BA(m, buffer, i) < 0) { log_error(tape_snapshot_log, "Cannot write tap image"); fseek(ftap, pos, SEEK_SET); return -1; } tap_size -= i; } /* restore position */ fseek(ftap, pos, SEEK_SET); if (snapshot_module_close(m) < 0) return -1; return 0; }
int fdc_snapshot_write_module(snapshot_t *p, int fnum) { snapshot_module_t *m; char *name; if (fdc[fnum].fdc_state == FDC_UNUSED) { return 0; } name = lib_msprintf("FDC%i", fnum); m = snapshot_module_create(p, name, FDC_DUMP_VER_MAJOR, FDC_DUMP_VER_MINOR); lib_free(name); if (m == NULL) return -1; SMW_B(m, (BYTE)(fdc[fnum].fdc_state)); /* clk till next invocation */ SMW_DW(m, (DWORD)(fdc[fnum].alarm_clk - drive_clk[fnum])); /* number of drives - so far 1 only */ SMW_B(m, 1); /* last accessed track/sector */ SMW_B(m, ((BYTE)(fdc[fnum].last_track))); SMW_B(m, ((BYTE)(fdc[fnum].last_sector))); snapshot_module_close(m); return 0; }
int digimax_snapshot_write_module(snapshot_t *s) { snapshot_module_t *m; m = snapshot_module_create(s, SNAP_MODULE_NAME, CART_DUMP_VER_MAJOR, CART_DUMP_VER_MINOR); if (m == NULL) { return -1; } if (0 || (SMW_DW(m, (DWORD)digimax_address) < 0) /* FIXME: implement userport part in userport_digimax.c */ #if 0 || (SMW_B(m, digimax_userport_address) < 0) || (SMW_B(m, digimax_userport_direction_A) < 0) || (SMW_B(m, digimax_userport_direction_B) < 0) #endif || (SMW_BA(m, digimax_sound_data, 4) < 0) || (SMW_B(m, snd.voice0) < 0) || (SMW_B(m, snd.voice1) < 0) || (SMW_B(m, snd.voice2) < 0) || (SMW_B(m, snd.voice3) < 0)) { snapshot_module_close(m); return -1; } snapshot_module_close(m); return 0; }
static int drive_snapshot_write_gcrimage_module(snapshot_t *s, unsigned int dnr) { char snap_module_name[10]; snapshot_module_t *m; BYTE *data; unsigned int i; drive_t *drive; DWORD num_half_tracks, track_size; drive = drive_context[dnr]->drive; sprintf(snap_module_name, "GCRIMAGE%i", dnr); m = snapshot_module_create(s, snap_module_name, GCRIMAGE_SNAP_MAJOR, GCRIMAGE_SNAP_MINOR); if (m == NULL) { return -1; } num_half_tracks = MAX_TRACKS_1571 * 2; /* Write general data */ if (SMW_DW(m, num_half_tracks) < 0) { snapshot_module_close(m); return -1; } /* Write half track data */ for (i = 0; i < num_half_tracks; i++) { data = drive->gcr->tracks[i].data; track_size = data ? drive->gcr->tracks[i].size : 0; if (0 || SMW_DW(m, (DWORD)track_size) < 0 || (track_size && SMW_BA(m, data, track_size) < 0) ) { break; } } if (snapshot_module_close(m) < 0 || (i != num_half_tracks)) { return -1; } return 0; }
static int dtlbasic_write_snapshot(struct snapshot_s *s, int write_image) { snapshot_module_t *m; m = snapshot_module_create(s, snap_module_name, SNAP_MAJOR, SNAP_MINOR); if (m == NULL) { return -1; } if (0 || SMW_DW(m, (DWORD)dtlbasic_counter) < 0 || SMW_DW(m, (DWORD)write_status) < 0 || SMW_DW(m, (DWORD)sense_status) < 0 || SMW_DW(m, (DWORD)dtlbasic_state) < 0) { snapshot_module_close(m); return -1; } return snapshot_module_close(m); }
int actionreplay2_snapshot_write_module(snapshot_t *s) { snapshot_module_t *m; m = snapshot_module_create(s, SNAP_MODULE_NAME, CART_DUMP_VER_MAJOR, CART_DUMP_VER_MINOR); if (m == NULL) { return -1; } if (0 || (SMW_B(m, (BYTE)ar_enabled) < 0) || (SMW_DW(m, (DWORD)ar_cap_enable) < 0) || (SMW_DW(m, (DWORD)ar_cap_disable) < 0) || (SMW_BA(m, roml_banks, 0x4000) < 0)) { snapshot_module_close(m); return -1; } snapshot_module_close(m); return 0; }
int maincpu_snapshot_write_module(snapshot_t *s) { snapshot_module_t *m; m = snapshot_module_create(s, snap_module_name, ((BYTE)SNAP_MAJOR), ((BYTE)SNAP_MINOR)); if (m == NULL) { return -1; } if (0 || SMW_DW(m, maincpu_clk) < 0 || SMW_B(m, MOS6510_REGS_GET_A(&maincpu_regs)) < 0 || SMW_B(m, MOS6510_REGS_GET_X(&maincpu_regs)) < 0 || SMW_B(m, MOS6510_REGS_GET_Y(&maincpu_regs)) < 0 || SMW_B(m, MOS6510_REGS_GET_SP(&maincpu_regs)) < 0 || SMW_W(m, (WORD)MOS6510_REGS_GET_PC(&maincpu_regs)) < 0 || SMW_B(m, (BYTE)MOS6510_REGS_GET_STATUS(&maincpu_regs)) < 0 || SMW_DW(m, (DWORD)last_opcode_info) < 0) { goto fail; } if (interrupt_write_snapshot(maincpu_int_status, m) < 0) { goto fail; } if (interrupt_write_new_snapshot(maincpu_int_status, m) < 0) { goto fail; } return snapshot_module_close(m); fail: if (m != NULL) { snapshot_module_close(m); } return -1; }
int interrupt_write_new_snapshot(interrupt_cpu_status_t *cs, snapshot_module_t *m) { /* unsigned int i; */ if (SMW_DW(m, cs->nirq) < 0 || SMW_DW(m, cs->nnmi) < 0 || SMW_DW(m, cs->global_pending_int) < 0) return -1; /* if (SMW_DW(m, cs->num_dma_per_opcode) < 0) return -1; for (i = 0; i < cs->num_dma_per_opcode; i++) { if (SMW_DW(m, cs->dma_start_clk[i]) < 0) return -1; if (SMW_DW(m, cs->num_cycles_left[i]) < 0) return -1; } */ return 0; }
static int drive_snapshot_write_p64image_module(snapshot_t *s, unsigned int dnr) { char snap_module_name[10]; snapshot_module_t *m; drive_t *drive; TP64MemoryStream P64MemoryStreamInstance; PP64Image P64Image; drive = drive_context[dnr]->drive; sprintf(snap_module_name, "P64IMAGE%i", dnr); m = snapshot_module_create(s, snap_module_name, GCRIMAGE_SNAP_MAJOR, GCRIMAGE_SNAP_MINOR); if (m == NULL) { return -1; } P64Image = (void*)drive->p64; if (P64Image == NULL) { if (m != NULL) { snapshot_module_close(m); } return -1; } P64MemoryStreamCreate(&P64MemoryStreamInstance); P64MemoryStreamClear(&P64MemoryStreamInstance); if (!P64ImageWriteToStream(P64Image, &P64MemoryStreamInstance)) { P64MemoryStreamDestroy(&P64MemoryStreamInstance); return -1; } if (SMW_DW(m, P64MemoryStreamInstance.Size) < 0 || SMW_BA(m, P64MemoryStreamInstance.Data, P64MemoryStreamInstance.Size) < 0) { if (m != NULL) { snapshot_module_close(m); } P64MemoryStreamDestroy(&P64MemoryStreamInstance); return -1; } P64MemoryStreamDestroy(&P64MemoryStreamInstance); if (snapshot_module_close(m) < 0) { return -1; } return 0; }
int cbm2_c500_snapshot_write_module(snapshot_t *p) { snapshot_module_t *m; m = snapshot_module_create(p, module_name, C500DATA_DUMP_VER_MAJOR, C500DATA_DUMP_VER_MINOR); if (m == NULL) return -1; SMW_DW(m, c500_powerline_clk - maincpu_clk); snapshot_module_close(m); return 0; }
int ds1216e_write_snapshot(rtc_ds1216e_t *context, snapshot_t *s) { DWORD latch_lo = 0; DWORD latch_hi = 0; DWORD offset_lo = 0; DWORD offset_hi = 0; DWORD old_offset_lo = 0; DWORD old_offset_hi = 0; snapshot_module_t *m; /* time_t can be either 32bit or 64bit, so we save as 64bit */ #if (SIZE_OF_TIME_T == 8) latch_hi = (DWORD)(context->latch >> 32); latch_lo = (DWORD)(context->latch & 0xffffffff); offset_hi = (DWORD)(context->offset >> 32); offset_lo = (DWORD)(context->offset & 0xffffffff); old_offset_hi = (DWORD)(context->old_offset >> 32); old_offset_lo = (DWORD)(context->old_offset & 0xffffffff); #else latch_lo = (DWORD)context->latch; offset_lo = (DWORD)context->offset; old_offset_lo = (DWORD)context->old_offset; #endif m = snapshot_module_create(s, snap_module_name, SNAP_MAJOR, SNAP_MINOR); if (m == NULL) { return -1; } if (0 || SMW_B(m, (BYTE)context->reset) < 0 || SMW_B(m, (BYTE)context->inactive) < 0 || SMW_B(m, (BYTE)context->hours12) < 0 || SMW_B(m, (BYTE)context->pattern_pos) < 0 || SMW_B(m, (BYTE)context->pattern_ignore) < 0 || SMW_B(m, (BYTE)context->output) < 0 || SMW_B(m, (BYTE)context->output_pos) < 0 || SMW_DW(m, latch_hi) < 0 || SMW_DW(m, latch_lo) < 0 || SMW_DW(m, offset_hi) < 0 || SMW_DW(m, offset_lo) < 0 || SMW_DW(m, old_offset_hi) < 0 || SMW_DW(m, old_offset_lo) < 0 || SMW_BA(m, context->clock_regs, DS1216E_REG_SIZE) < 0 || SMW_BA(m, context->old_clock_regs, DS1216E_REG_SIZE) < 0 || SMW_BA(m, context->clock_regs_changed, DS1216E_REG_SIZE) < 0 || SMW_STR(m, context->device) < 0) { snapshot_module_close(m); return -1; } return snapshot_module_close(m); }
static int paperclip64_write_snapshot(struct snapshot_s *s, int port) { snapshot_module_t *m; m = snapshot_module_create(s, snap_module_name, SNAP_MAJOR, SNAP_MINOR); if (m == NULL) { return -1; } if (0 || SMW_DW(m, (DWORD)counter) < 0 || SMW_B(m, command) < 0) { snapshot_module_close(m); return -1; } return snapshot_module_close(m); }
int vic20cart_snapshot_write_module(snapshot_t *s) { snapshot_module_t *m; int ret = 0; m = snapshot_module_create(s, SNAP_MODULE_NAME, VIC20CART_DUMP_VER_MAJOR, VIC20CART_DUMP_VER_MINOR); if (m == NULL) { return -1; } if (SMW_DW(m, (DWORD)vic20cart_type) < 0) { snapshot_module_close(m); return -1; } snapshot_module_close(m); switch (vic20cart_type) { case CARTRIDGE_VIC20_GENERIC: ret = generic_snapshot_write_module(s); break; case CARTRIDGE_VIC20_FP: ret = vic_fp_snapshot_write_module(s); break; case CARTRIDGE_VIC20_MEGACART: ret = megacart_snapshot_write_module(s); break; case CARTRIDGE_VIC20_FINAL_EXPANSION: ret = finalexpansion_snapshot_write_module(s); break; case CARTRIDGE_NONE: default: break; } return ret; }
int epyxfastload_snapshot_write_module(snapshot_t *s) { snapshot_module_t *m; m = snapshot_module_create(s, SNAP_MODULE_NAME, CART_DUMP_VER_MAJOR, CART_DUMP_VER_MINOR); if (m == NULL) { return -1; } if (0 || (SMW_DW(m, epyxrom_alarm_time) < 0) || (SMW_BA(m, roml_banks, 0x2000) < 0)) { snapshot_module_close(m); return -1; } snapshot_module_close(m); return 0; }
int ds12c887rtc_snapshot_write_module(snapshot_t *s) { snapshot_module_t *m; m = snapshot_module_create(s, SNAP_MODULE_NAME, CART_DUMP_VER_MAJOR, CART_DUMP_VER_MINOR); if (m == NULL) { return -1; } /* FIXME: Implement the RTC snapshot part */ if (0 || (SMW_DW(m, (DWORD)ds12c887rtc_base_address) < 0)) { snapshot_module_close(m); return -1; } snapshot_module_close(m); return 0; }
int rtc72421_write_snapshot(rtc_72421_t *context, snapshot_t *s) { DWORD latch_lo = 0; DWORD latch_hi = 0; DWORD offset_lo = 0; DWORD offset_hi = 0; DWORD old_offset_lo = 0; DWORD old_offset_hi = 0; snapshot_module_t *m; /* time_t can be either 32bit or 64bit, so we save as 64bit */ #if (SIZE_OF_TIME_T == 8) latch_hi = (DWORD)(context->latch >> 32); latch_lo = (DWORD)(context->latch & 0xffffffff); offset_hi = (DWORD)(context->offset >> 32); offset_lo = (DWORD)(context->offset & 0xffffffff); old_offset_hi = (DWORD)(context->old_offset >> 32); old_offset_lo = (DWORD)(context->old_offset & 0xffffffff); #else latch_lo = (DWORD)context->latch; offset_lo = (DWORD)context->offset; old_offset_lo = (DWORD)context->old_offset; #endif m = snapshot_module_create(s, snap_module_name, SNAP_MAJOR, SNAP_MINOR); if (m == NULL) { return -1; } if (0 || SMW_B(m, (BYTE)context->stop) < 0 || SMW_B(m, (BYTE)context->hour24) < 0 || SMW_DW(m, latch_hi) < 0 || SMW_DW(m, latch_lo) < 0 || SMW_DW(m, offset_hi) < 0 || SMW_DW(m, offset_lo) < 0 || SMW_DW(m, old_offset_hi) < 0 || SMW_DW(m, old_offset_lo) < 0 || SMW_STR(m, context->device) < 0) { snapshot_module_close(m); return -1; } return snapshot_module_close(m); }
int ramcart_snapshot_write_module(snapshot_t *s) { snapshot_module_t *m; m = snapshot_module_create(s, snap_module_name, SNAP_MAJOR, SNAP_MINOR); if (m == NULL) { return -1; } if (0 || (SMW_B(m, (uint8_t)ramcart_enabled) < 0) || (SMW_B(m, (uint8_t)ramcart_readonly) < 0) || (SMW_DW(m, (uint32_t)ramcart_size) < 0) || (SMW_B(m, (uint8_t)ramcart_size_kb) < 0) || (SMW_BA(m, ramcart, 2) < 0) || (SMW_BA(m, ramcart_ram, ramcart_size) < 0)) { snapshot_module_close(m); return -1; } return snapshot_module_close(m); }
static int tapelog_write_snapshot(struct snapshot_s *s, int write_image) { snapshot_module_t *m; m = snapshot_module_create(s, snap_module_name, SNAP_MAJOR, SNAP_MINOR); if (m == NULL) { return -1; } if (0 || SMW_B(m, tapelog_motor_out) < 0 || SMW_B(m, tapelog_motor_in) < 0 || SMW_B(m, tapelog_sense_in) < 0 || SMW_B(m, tapelog_sense_out) < 0 || SMW_B(m, tapelog_write_out) < 0 || SMW_B(m, tapelog_write_in) < 0 || SMW_B(m, tapelog_read_out) < 0 || SMW_DW(m, (DWORD)tapelog_read_in) < 0) { snapshot_module_close(m); return -1; } return snapshot_module_close(m); }
int vic_snapshot_write_module(snapshot_t *s) { int i; snapshot_module_t *m; m = snapshot_module_create(s, snap_module_name, SNAP_MAJOR, SNAP_MINOR); if (m == NULL) { return -1; } if (SMW_B(m, (BYTE)VIC_RASTER_CYCLE(maincpu_clk)) < 0 || SMW_W(m, (WORD)VIC_RASTER_Y(maincpu_clk)) < 0) { goto fail; } if (0 || (SMW_W(m, (WORD)vic.area) < 0) || (SMW_W(m, (WORD)vic.fetch_state) < 0) || (SMW_DW(m, (DWORD)vic.raster_line) < 0) || (SMW_DW(m, (DWORD)vic.text_cols) < 0) || (SMW_DW(m, (DWORD)vic.text_lines) < 0) || (SMW_DW(m, (DWORD)vic.pending_text_cols) < 0) || (SMW_DW(m, (DWORD)vic.line_was_blank) < 0) || (SMW_DW(m, (DWORD)vic.memptr) < 0) || (SMW_DW(m, (DWORD)vic.memptr_inc) < 0) || (SMW_DW(m, (DWORD)vic.row_counter) < 0) || (SMW_DW(m, (DWORD)vic.buf_offset) < 0) || SMW_B(m, (BYTE)vic.light_pen.state) < 0 || SMW_B(m, (BYTE)vic.light_pen.triggered) < 0 || SMW_DW(m, (DWORD)vic.light_pen.x) < 0 || SMW_DW(m, (DWORD)vic.light_pen.y) < 0 || SMW_DW(m, (DWORD)vic.light_pen.x_extra_bits) < 0 || SMW_DW(m, (DWORD)vic.light_pen.trigger_cycle) < 0 || (SMW_B(m, vic.vbuf) < 0)) { goto fail; } /* Color RAM. */ if (SMW_BA(m, mem_ram + 0x9400, 0x400) < 0) { goto fail; } for (i = 0; i < 0x10; i++) { if (SMW_B(m, (BYTE)vic.regs[i]) < 0) { goto fail; } } return snapshot_module_close(m); fail: if (m != NULL) snapshot_module_close(m); return -1; }
int sfx_soundexpander_snapshot_write_module(snapshot_t *s) { FM_OPL *chip = (sfx_soundexpander_chip == 3526) ? YM3526_chip : YM3812_chip; snapshot_module_t *m; int x, y; m = snapshot_module_create(s, SNAP_MODULE_NAME, CART_DUMP_VER_MAJOR, CART_DUMP_VER_MINOR); if (m == NULL) { return -1; } if (0 || (SMW_DW(m, (DWORD)sfx_soundexpander_chip) < 0) || (SMW_B(m, (BYTE)snd.command) < 0)) { snapshot_module_close(m); return -1; } for (x = 0; x < 9; x++) { for (y = 0; y < 2; y++) { if (0 || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].ar) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].dr) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].rr) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].KSR) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].ksl) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].ksr) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].mul) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].Cnt) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].Incr) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].FB) < 0) || (SMW_DW(m, (DWORD)connect1_is_output0(chip->P_CH[x].SLOT[y].connect1)) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].op1_out[0]) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].op1_out[1]) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].CON) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].eg_type) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].state) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].TL) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].TLL) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].volume) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].sl) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].eg_sh_ar) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].eg_sel_ar) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].eg_sh_dr) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].eg_sel_dr) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].eg_sh_rr) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].eg_sel_rr) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].key) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].SLOT[y].AMmask) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].SLOT[y].vib) < 0) || (SMW_W(m, (WORD)chip->P_CH[x].SLOT[y].wavetable) < 0)) { snapshot_module_close(m); return -1; } } if (0 || (SMW_DW(m, (DWORD)chip->P_CH[x].block_fnum) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].fc) < 0) || (SMW_DW(m, (DWORD)chip->P_CH[x].ksl_base) < 0) || (SMW_B(m, (BYTE)chip->P_CH[x].kcode) < 0)) { snapshot_module_close(m); return -1; } } if (0 || (SMW_DW(m, (DWORD)chip->eg_cnt) < 0) || (SMW_DW(m, (DWORD)chip->eg_timer) < 0) || (SMW_DW(m, (DWORD)chip->eg_timer_add) < 0) || (SMW_DW(m, (DWORD)chip->eg_timer_overflow) < 0) || (SMW_B(m, (BYTE)chip->rhythm) < 0)) { snapshot_module_close(m); return -1; } for (x = 0; x < 1024; x++) { if (0 || (SMW_DW(m, (DWORD)chip->fn_tab[x]) < 0)) { snapshot_module_close(m); return -1; } } if (0 || (SMW_B(m, (BYTE)chip->lfo_am_depth) < 0) || (SMW_B(m, (BYTE)chip->lfo_pm_depth_range) < 0) || (SMW_DW(m, (DWORD)chip->lfo_am_cnt) < 0) || (SMW_DW(m, (DWORD)chip->lfo_am_inc) < 0) || (SMW_DW(m, (DWORD)chip->lfo_pm_cnt) < 0) || (SMW_DW(m, (DWORD)chip->lfo_pm_inc) < 0) || (SMW_DW(m, (DWORD)chip->noise_rng) < 0) || (SMW_DW(m, (DWORD)chip->noise_p) < 0) || (SMW_DW(m, (DWORD)chip->noise_f) < 0) || (SMW_B(m, (BYTE)chip->wavesel) < 0) || (SMW_DW(m, (DWORD)chip->T[0]) < 0) || (SMW_DW(m, (DWORD)chip->T[1]) < 0) || (SMW_B(m, (BYTE)chip->st[0]) < 0) || (SMW_B(m, (BYTE)chip->st[1]) < 0) || (SMW_B(m, (BYTE)chip->type) < 0) || (SMW_B(m, (BYTE)chip->address) < 0) || (SMW_B(m, (BYTE)chip->status) < 0) || (SMW_B(m, (BYTE)chip->statusmask) < 0) || (SMW_B(m, (BYTE)chip->mode) < 0) || (SMW_DW(m, (DWORD)chip->clock) < 0) || (SMW_DW(m, (DWORD)chip->rate) < 0) || (SMW_DB(m, (double)chip->freqbase) < 0)) { snapshot_module_close(m); return -1; } snapshot_module_close(m); return 0; }
int drive_snapshot_write_module(snapshot_t *s, int save_disks, int save_roms) { int i; char snap_module_name[] = "DRIVE"; snapshot_module_t *m; DWORD rotation_table_ptr[DRIVE_NUM]; BYTE GCR_image[4], P64_image[4]; int drive_true_emulation; int sync_factor; drive_t *drive; resources_get_int("DriveTrueEmulation", &drive_true_emulation); if (vdrive_snapshot_module_write(s, drive_true_emulation ? 10 : 8) < 0) { return -1; } if (!drive_true_emulation) { return 0; } drive_gcr_data_writeback_all(); rotation_table_get(rotation_table_ptr); for (i = 0; i < 2; i++) { drive = drive_context[i]->drive; GCR_image[i] = (drive->GCR_image_loaded == 0 || !save_disks) ? 0 : 1; P64_image[i] = (drive->P64_image_loaded == 0 || !save_disks) ? 0 : 1; } m = snapshot_module_create(s, snap_module_name, DRIVE_SNAP_MAJOR, DRIVE_SNAP_MINOR); if (m == NULL) { return -1; } resources_get_int("MachineVideoStandard", &sync_factor); if (SMW_DW(m, (DWORD)sync_factor) < 0) { if (m != NULL) { snapshot_module_close(m); } return -1; } /* TODO: NUM_DRIVES drives instead of 2 */ for (i = 0; i < 2; i++) { drive = drive_context[i]->drive; if (0 || SMW_DW(m, (DWORD)(drive->attach_clk)) < 0 || SMW_B(m, (BYTE)(drive->byte_ready_level)) < 0 || SMW_B(m, (BYTE)(drive->clock_frequency)) < 0 || SMW_W(m, (WORD)(drive->current_half_track + (drive->side * DRIVE_HALFTRACKS_1571))) < 0 || SMW_DW(m, (DWORD)(drive->detach_clk)) < 0 || SMW_B(m, (BYTE)0) < 0 || SMW_B(m, (BYTE)0) < 0 || SMW_B(m, (BYTE)(drive->extend_image_policy)) < 0 || SMW_DW(m, (DWORD)(drive->GCR_head_offset)) < 0 || SMW_B(m, (BYTE)(drive->GCR_read)) < 0 || SMW_B(m, (BYTE)(drive->GCR_write_value)) < 0 || SMW_B(m, (BYTE)(drive->idling_method)) < 0 || SMW_B(m, (BYTE)(drive->parallel_cable)) < 0 || SMW_B(m, (BYTE)(drive->read_only)) < 0 || SMW_DW(m, (DWORD)(rotation_table_ptr[i])) < 0 || SMW_DW(m, (DWORD)(drive->type)) < 0 /* rotation */ || SMW_DW(m, (DWORD)(drive->snap_accum)) < 0 || SMW_DW(m, (DWORD)(drive->snap_rotation_last_clk)) < 0 || SMW_DW(m, (DWORD)(drive->snap_bit_counter)) < 0 || SMW_DW(m, (DWORD)(drive->snap_zero_count)) < 0 || SMW_W(m, (WORD)(drive->snap_last_read_data)) < 0 || SMW_B(m, (BYTE)(drive->snap_last_write_data)) < 0 || SMW_DW(m, (BYTE)(drive->snap_seed)) < 0 || SMW_DW(m, (DWORD)(drive->snap_speed_zone)) < 0 || SMW_DW(m, (DWORD)(drive->snap_ue7_dcba)) < 0 || SMW_DW(m, (DWORD)(drive->snap_ue7_counter)) < 0 || SMW_DW(m, (DWORD)(drive->snap_uf4_counter)) < 0 || SMW_DW(m, (DWORD)(drive->snap_fr_randcount)) < 0 || SMW_DW(m, (DWORD)(drive->snap_filter_counter)) < 0 || SMW_DW(m, (DWORD)(drive->snap_filter_state)) < 0 || SMW_DW(m, (DWORD)(drive->snap_filter_last_state)) < 0 || SMW_DW(m, (DWORD)(drive->snap_write_flux)) < 0 || SMW_DW(m, (DWORD)(drive->snap_PulseHeadPosition)) < 0 || SMW_DW(m, (DWORD)(drive->snap_xorShift32)) < 0 || SMW_DW(m, (DWORD)(drive->snap_so_delay)) < 0 || SMW_DW(m, (DWORD)(drive->snap_cycle_index)) < 0 || SMW_DW(m, (DWORD)(drive->snap_ref_advance)) < 0 || SMW_DW(m, (DWORD)(drive->snap_req_ref_cycles)) < 0 ) { if (m != NULL) { snapshot_module_close(m); } return -1; } } /* new snapshot members */ for (i = 0; i < 2; i++) { drive = drive_context[i]->drive; if (0 || SMW_DW(m, (DWORD)(drive->attach_detach_clk)) < 0 ) { if (m != NULL) { snapshot_module_close(m); } return -1; } } for (i = 0; i < 2; i++) { drive = drive_context[i]->drive; if (0 || SMW_B(m, (BYTE)(drive->byte_ready_edge)) < 0 || SMW_B(m, (BYTE)(drive->byte_ready_active)) < 0 ) { if (m != NULL) { snapshot_module_close(m); } return -1; } } if (snapshot_module_close(m) < 0) { return -1; } for (i = 0; i < 2; i++) { drive = drive_context[i]->drive; if (drive->enable) { if (drive->type == DRIVE_TYPE_2000 || drive->type == DRIVE_TYPE_4000) { if (drivecpu65c02_snapshot_write_module(drive_context[i], s) < 0) { return -1; } } else { if (drivecpu_snapshot_write_module(drive_context[i], s) < 0) { return -1; } } if (machine_drive_snapshot_write(drive_context[i], s) < 0) { return -1; } } } if (save_disks) { if (GCR_image[0] > 0) { if (drive_snapshot_write_gcrimage_module(s, 0) < 0) { return -1; } } else if (P64_image[0] > 0) { if (drive_snapshot_write_p64image_module(s, 0) < 0) { return -1; } } else { if (drive_snapshot_write_image_module(s, 0) < 0) { return -1; } } if (GCR_image[1] > 0) { if (drive_snapshot_write_gcrimage_module(s, 1) < 0) { return -1; } } else if (P64_image[1] > 0) { if (drive_snapshot_write_p64image_module(s, 1) < 0) { return -1; } } else { if (drive_snapshot_write_image_module(s, 1) < 0) { return -1; } } } for (i = 0; i < 2; i++) { drive = drive_context[i]->drive; if (save_roms && drive->enable) { if (driverom_snapshot_write(s, drive) < 0) { return -1; } } } return 0; }
int drivecpu_snapshot_write_module(drive_context_t *drv, snapshot_t *s) { snapshot_module_t *m; drivecpu_context_t *cpu; cpu = drv->cpu; m = snapshot_module_create(s, drv->cpu->snap_module_name, ((BYTE)(SNAP_MAJOR)), ((BYTE)(SNAP_MINOR))); if (m == NULL) { return -1; } if (0 || SMW_DW(m, (DWORD) *(drv->clk_ptr)) < 0 || SMW_B(m, (BYTE)MOS6510_REGS_GET_A(&(cpu->cpu_regs))) < 0 || SMW_B(m, (BYTE)MOS6510_REGS_GET_X(&(cpu->cpu_regs))) < 0 || SMW_B(m, (BYTE)MOS6510_REGS_GET_Y(&(cpu->cpu_regs))) < 0 || SMW_B(m, (BYTE)MOS6510_REGS_GET_SP(&(cpu->cpu_regs))) < 0 || SMW_W(m, (WORD)MOS6510_REGS_GET_PC(&(cpu->cpu_regs))) < 0 || SMW_B(m, (BYTE)MOS6510_REGS_GET_STATUS(&(cpu->cpu_regs))) < 0 || SMW_DW(m, (DWORD)(cpu->last_opcode_info)) < 0 || SMW_DW(m, (DWORD)(cpu->last_clk)) < 0 || SMW_DW(m, (DWORD)(cpu->cycle_accum)) < 0 || SMW_DW(m, (DWORD)(cpu->last_exc_cycles)) < 0 || SMW_DW(m, (DWORD)(cpu->stop_clk)) < 0 ) { goto fail; } if (interrupt_write_snapshot(cpu->int_status, m) < 0) { goto fail; } if (drv->drive->type == DRIVE_TYPE_1540 || drv->drive->type == DRIVE_TYPE_1541 || drv->drive->type == DRIVE_TYPE_1541II || drv->drive->type == DRIVE_TYPE_1551 || drv->drive->type == DRIVE_TYPE_1570 || drv->drive->type == DRIVE_TYPE_1571 || drv->drive->type == DRIVE_TYPE_1571CR || drv->drive->type == DRIVE_TYPE_2031) { if (SMW_BA(m, drv->drive->drive_ram, 0x800) < 0) { goto fail; } } if (drv->drive->type == DRIVE_TYPE_1581 || drv->drive->type == DRIVE_TYPE_2000 || drv->drive->type == DRIVE_TYPE_4000) { if (SMW_BA(m, drv->drive->drive_ram, 0x2000) < 0) { goto fail; } } if (drive_check_old(drv->drive->type)) { if (SMW_BA(m, drv->drive->drive_ram, 0x1100) < 0) { goto fail; } } if (interrupt_write_new_snapshot(cpu->int_status, m) < 0) { goto fail; } return snapshot_module_close(m); fail: if (m != NULL) { snapshot_module_close(m); } return -1; }
int vic20cart_snapshot_write_module(snapshot_t *s) { snapshot_module_t *m; BYTE i; BYTE number_of_carts = 0; int cart_ids[VIC20CART_DUMP_MAX_CARTS]; int last_cart = 0; export_list_t *e = export_query_list(NULL); memset(cart_ids, 0, sizeof(cart_ids)); while (e != NULL) { if (number_of_carts == VIC20CART_DUMP_MAX_CARTS) { DBG(("CART snapshot save: active carts > max (%i)\n", number_of_carts)); return -1; } if (last_cart != (int)e->device->cartid) { last_cart = e->device->cartid; cart_ids[number_of_carts++] = last_cart; } e = e->next; } m = snapshot_module_create(s, SNAP_MODULE_NAME, VIC20CART_DUMP_VER_MAJOR, VIC20CART_DUMP_VER_MINOR); if (m == NULL) { return -1; } if (SMW_DW(m, (DWORD)vic20cart_type) < 0) { goto fail; } if (SMW_B(m, number_of_carts) < 0) { goto fail; } /* Not much to do if no carts present */ if (number_of_carts == 0) { return snapshot_module_close(m); } /* Save cart IDs */ for (i = 0; i < number_of_carts; i++) { if (SMW_DW(m, (DWORD)cart_ids[i]) < 0) { goto fail; } } snapshot_module_close(m); /* Save individual cart data */ for (i = 0; i < number_of_carts; i++) { switch (cart_ids[i]) { case CARTRIDGE_VIC20_FINAL_EXPANSION: if (finalexpansion_snapshot_write_module(s) < 0) { return -1; } break; case CARTRIDGE_VIC20_IO2_RAM: if (ioramcart_io2_snapshot_write_module(s) < 0) { return -1; } break; case CARTRIDGE_VIC20_IO3_RAM: if (ioramcart_io3_snapshot_write_module(s) < 0) { return -1; } break; case CARTRIDGE_VIC20_MEGACART: if (megacart_snapshot_write_module(s) < 0) { return -1; } break; case CARTRIDGE_VIC20_UM: if (vic_um_snapshot_write_module(s) < 0) { return -1; } break; case CARTRIDGE_VIC20_IEEE488: if (vic20_ieee488_snapshot_write_module(s) < 0) { return -1; } break; #ifdef HAVE_MIDI case CARTRIDGE_MIDI_MAPLIN: if (vic20_midi_snapshot_write_module(s) < 0) { return -1; } break; #endif case CARTRIDGE_VIC20_SIDCART: if (sidcart_snapshot_write_module(s) < 0) { return -1; } break; case CARTRIDGE_VIC20_FP: if (vic_fp_snapshot_write_module(s) < 0) { return -1; } break; case CARTRIDGE_ACIA: if (aciacart_snapshot_write_module(s) < 0) { return -1; } break; case CARTRIDGE_DIGIMAX: if (digimax_snapshot_write_module(s) < 0) { return -1; } break; case CARTRIDGE_DS12C887RTC: if (ds12c887rtc_snapshot_write_module(s) < 0) { return -1; } break; case CARTRIDGE_GEORAM: if (georam_write_snapshot_module(s) < 0) { return -1; } break; case CARTRIDGE_SFX_SOUND_EXPANDER: if (sfx_soundexpander_snapshot_write_module(s) < 0) { return -1; } break; case CARTRIDGE_SFX_SOUND_SAMPLER: if (sfx_soundsampler_snapshot_write_module(s) < 0) { return -1; } break; #ifdef HAVE_TFE case CARTRIDGE_TFE: if (tfe_snapshot_write_module(s) < 0) { return -1; } break; #endif } } if (vic20cart_type == CARTRIDGE_VIC20_GENERIC) { if (generic_snapshot_write_module(s) < 0) { return -1; } } return 0; fail: snapshot_module_close(m); return -1; }
int tape_snapshot_write_module(snapshot_t *s, int save_image) { char snap_module_name[] = "TAPE"; snapshot_module_t *m; tap_t *tap; t64_t *t64; if (tape_image_dev1 == NULL || tape_image_dev1->name == NULL) return 0; if (save_image) { switch (tape_image_dev1->type) { case TAPE_TYPE_T64: if (tape_snapshot_write_t64image_module(s) < 0) return -1; break; case TAPE_TYPE_TAP: if (tape_snapshot_write_tapimage_module(s) < 0) return -1; break; default: break; } } m = snapshot_module_create(s, snap_module_name, TAPE_SNAP_MAJOR, TAPE_SNAP_MINOR); if (m == NULL) return -1; if (0 || SMW_B(m, (BYTE)tape_image_dev1->read_only) < 0 || SMW_B(m, (BYTE)tape_image_dev1->type) < 0) { snapshot_module_close(m); return -1; } switch (tape_image_dev1->type) { case TAPE_TYPE_T64: t64 = (t64_t*)tape_image_dev1->data; break; case TAPE_TYPE_TAP: tap = (tap_t*)tape_image_dev1->data; if (tap == NULL || SMW_DW(m, tap->size) < 0 || SMW_B(m, tap->version) < 0 || SMW_B(m, tap->system) < 0 || SMW_DW(m, tap->current_file_seek_position) < 0 || SMW_DW(m, tap->offset) < 0 || SMW_DW(m, tap->cycle_counter) < 0 || SMW_DW(m, tap->cycle_counter_total) < 0 || SMW_DW(m, tap->counter) < 0 || SMW_DW(m, tap->mode) < 0 || SMW_DW(m, tap->read_only) < 0 || SMW_DW(m, tap->has_changed) < 0) { snapshot_module_close(m); return -1; } break; default: break; } if (snapshot_module_close(m) < 0) return -1; if (datasette_write_snapshot(s) < 0) return -1; return 0; }
int vicii_snapshot_write_module(snapshot_t *s) { int i; snapshot_module_t *m; BYTE color_ram[0x400]; /* FIXME: Dispatch all events? */ m = snapshot_module_create (s, snap_module_name, SNAP_MAJOR, SNAP_MINOR); if (m == NULL) { return -1; } mem_color_ram_to_snapshot(color_ram); if (0 /* AllowBadLines */ || SMW_B(m, (BYTE)vicii.allow_bad_lines) < 0 /* BadLine */ || SMW_B(m, (BYTE)vicii.bad_line) < 0 /* Blank */ || SMW_B(m, (BYTE)vicii.raster.blank_enabled) < 0 /* ColorBuf */ || SMW_BA(m, vicii.cbuf, 40) < 0 /* ColorRam */ || SMW_BA(m, color_ram, 1024) < 0 /* IdleState */ || SMW_B(m, (BYTE)vicii.idle_state) < 0 /* LPTrigger */ || SMW_B(m, (BYTE)vicii.light_pen.triggered) < 0 /* LPX */ || SMW_B(m, (BYTE)vicii.light_pen.x) < 0 /* LPY */ || SMW_B(m, (BYTE)vicii.light_pen.y) < 0 /* MatrixBuf */ || SMW_BA(m, vicii.vbuf, 40) < 0 /* NewSpriteDmaMask */ || SMW_B(m, vicii.raster.sprite_status->new_dma_msk) < 0 /* RamBase */ || SMW_DW(m, (DWORD)(vicii.ram_base_phi1 - mem_ram)) < 0 /* RasterCycle */ || SMW_B(m, (BYTE)(VICII_RASTER_CYCLE(maincpu_clk))) < 0 /* RasterLine */ || SMW_W(m, (WORD)(VICII_RASTER_Y(maincpu_clk))) < 0) { goto fail; } for (i = 0; i < 0x40; i++) { /* Registers */ if (SMW_B(m, vicii.regs[i]) < 0) { goto fail; } } if (0 /* SbCollMask */ || SMW_B(m, (BYTE)vicii.sprite_background_collisions) < 0 /* SpriteDmaMask */ || SMW_B(m, (BYTE)vicii.raster.sprite_status->dma_msk) < 0 /* SsCollMask */ || SMW_B(m, (BYTE)vicii.sprite_sprite_collisions) < 0 /* VBank */ || SMW_W(m, (WORD)vicii.vbank_phi1) < 0 /* Vc */ || SMW_W(m, (WORD)vicii.mem_counter) < 0 /* VcInc */ || SMW_B(m, (BYTE)vicii.mem_counter_inc) < 0 /* VcBase */ || SMW_W(m, (WORD)vicii.memptr) < 0 /* VideoInt */ || SMW_B(m, (BYTE)vicii.irq_status) < 0) { goto fail; } for (i = 0; i < 8; i++) { if (0 /* SpriteXMemPtr */ || SMW_B(m, (BYTE)vicii.raster.sprite_status->sprites[i].memptr) < 0 /* SpriteXMemPtrInc */ || SMW_B(m, (BYTE)vicii.raster.sprite_status->sprites[i].memptr_inc) < 0 /* SpriteXExpFlipFlop */ || SMW_B(m, (BYTE)vicii.raster.sprite_status->sprites[i].exp_flag) < 0) { goto fail; } } if (0 /* FetchEventTick */ || SMW_DW(m, vicii.fetch_clk - maincpu_clk) < 0 /* FetchEventType */ || SMW_B(m, (BYTE)vicii.fetch_idx) < 0) { goto fail; } /* Added in version 1.1 of the snapshot module */ /* using "ram_base-ram" is F***ing bullshit - what when external memory is not mapped anywhere in ram[]? We should rather use some more generic configuration info. But as we use it above in V1.0... :-( AF 16jan2001 */ if (0 /* RamBase */ || SMW_DW(m, (DWORD)(vicii.ram_base_phi2 - mem_ram)) < 0 /* VBank */ || SMW_W(m, (WORD)vicii.vbank_phi2) < 0) { goto fail; } return snapshot_module_close(m); fail: if (m != NULL) { snapshot_module_close(m); } return -1; }
int ted_snapshot_write_module(snapshot_t *s) { int i; snapshot_module_t *m; /* FIXME: Dispatch all events? */ m = snapshot_module_create (s, snap_module_name, SNAP_MAJOR, SNAP_MINOR); if (m == NULL) { return -1; } DBG(("TED write snapshot at clock: %d cycle: %d tedline: %d rasterline: %d\n", maincpu_clk, TED_RASTER_CYCLE(maincpu_clk), TED_RASTER_Y(maincpu_clk), ted.raster.current_line)); if (0 || SMW_DW(m, ted.last_emulate_line_clk) < 0 /* AllowBadLines */ || SMW_B(m, (BYTE)ted.allow_bad_lines) < 0 /* BadLine */ || SMW_B(m, (BYTE)ted.bad_line) < 0 /* Blank */ || SMW_B(m, (BYTE)ted.raster.blank_enabled) < 0 /* ColorBuf */ || SMW_BA(m, ted.cbuf, 40) < 0 /* IdleState */ || SMW_B(m, (BYTE)ted.idle_state) < 0 /* MatrixBuf */ || SMW_BA(m, ted.vbuf, 40) < 0 /* RasterCycle */ || SMW_B(m, (BYTE)TED_RASTER_CYCLE(maincpu_clk)) < 0 /* RasterLine */ || SMW_W(m, (WORD)(TED_RASTER_Y(maincpu_clk))) < 0 ) { goto fail; } for (i = 0; i < 0x40; i++) { /* Registers */ if (SMW_B(m, ted.regs[i]) < 0) { goto fail; } } if (0 || SMW_DW(m, (DWORD)ted.ted_raster_counter) < 0 /* Vc */ || SMW_W(m, (WORD)ted.mem_counter) < 0 /* VcInc */ || SMW_B(m, (BYTE)ted.mem_counter_inc) < 0 /* VcBase */ || SMW_W(m, (WORD)ted.memptr) < 0 /* VideoInt */ || SMW_B(m, (BYTE)ted.irq_status) < 0 ) { goto fail; } if (0 /* FetchEventTick */ || SMW_DW(m, ted.fetch_clk - maincpu_clk) < 0 ) { goto fail; } DBG(("TED snapshot written.\n")); return snapshot_module_close(m); fail: if (m != NULL) { snapshot_module_close(m); } DBG(("error writing TED snapshot.\n")); return -1; }