int riotcore_snapshot_write_module(riot_context_t *riot_context, snapshot_t *p) { snapshot_module_t *m; m = snapshot_module_create(p, riot_context->myname, RIOT_DUMP_VER_MAJOR, RIOT_DUMP_VER_MINOR); if (m == NULL) return -1; update_timer(riot_context); SMW_B(m, riot_context->riot_io[0]); SMW_B(m, riot_context->riot_io[1]); SMW_B(m, riot_context->riot_io[2]); SMW_B(m, riot_context->riot_io[3]); SMW_B(m, riot_context->r_edgectrl); SMW_B(m, (BYTE)(riot_context->r_irqfl | (riot_context->r_irqline ? 1 : 0))); SMW_B(m, (BYTE)(riot_context->r_N - (*(riot_context->clk_ptr) - riot_context->r_write_clk) / riot_context->r_divider)); SMW_W(m, (WORD)(riot_context->r_divider)); SMW_W(m, (BYTE)((*(riot_context->clk_ptr) - riot_context->r_write_clk) % riot_context->r_divider)); SMW_B(m, (BYTE)(riot_context->r_irqen ? 1 : 0)); snapshot_module_close(m); return 0; }
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 viacore_snapshot_write_module(via_context_t *via_context, snapshot_t *s) { snapshot_module_t *m; if (via_context->tai && (via_context->tai <= *(via_context->clk_ptr))) viacore_intt1(*(via_context->clk_ptr) - via_context->tai, (void *)via_context); if (via_context->tbi && (via_context->tbi <= *(via_context->clk_ptr))) viacore_intt2(*(via_context->clk_ptr) - via_context->tbi, (void *)via_context); m = snapshot_module_create(s, via_context->my_module_name, VIA_DUMP_VER_MAJOR, VIA_DUMP_VER_MINOR); if (m == NULL) return -1; SMW_B(m, via_context->via[VIA_PRA]); SMW_B(m, via_context->via[VIA_DDRA]); SMW_B(m, via_context->via[VIA_PRB]); SMW_B(m, via_context->via[VIA_DDRB]); SMW_W(m, (WORD)(via_context->tal)); SMW_W(m, (WORD)myviata(via_context)); SMW_B(m, via_context->via[VIA_T2LL]); SMW_W(m, (WORD)myviatb(via_context)); SMW_B(m, (BYTE)((via_context->tai ? 0x80 : 0) | (via_context->tbi ? 0x40 : 0))); SMW_B(m, via_context->via[VIA_SR]); SMW_B(m, via_context->via[VIA_ACR]); SMW_B(m, via_context->via[VIA_PCR]); SMW_B(m, (BYTE)(via_context->ifr)); SMW_B(m, (BYTE)(via_context->ier)); /* FIXME! */ SMW_B(m, (BYTE)((((via_context->pb7 ^ via_context->pb7x) | via_context->pb7o) ? 0x80 : 0))); SMW_B(m, 0); /* SRHBITS */ SMW_B(m, (BYTE)((via_context->ca2_state ? 0x80 : 0) | (via_context->cb2_state ? 0x40 : 0))); SMW_B(m, via_context->ila); SMW_B(m, via_context->ilb); snapshot_module_close(m); return 0; }
static int drive_snapshot_write_image_module(snapshot_t *s, unsigned int dnr) { char snap_module_name[10]; snapshot_module_t *m; BYTE sector_data[0x100]; WORD word; disk_addr_t dadr; int rc; drive_t *drive; drive = drive_context[dnr]->drive; if (drive->image == NULL) { sprintf(snap_module_name, "NOIMAGE%i", dnr); } else { sprintf(snap_module_name, "IMAGE%i", dnr); } m = snapshot_module_create(s, snap_module_name, IMAGE_SNAP_MAJOR, IMAGE_SNAP_MINOR); if (m == NULL) { return -1; } if (drive->image == NULL) { if (snapshot_module_close(m) < 0) { return -1; } return 0; } word = drive->image->type; SMW_W(m, word); /* we use the return code to step through the tracks. So we do not need any geometry info. */ for (dadr.track = 1;; dadr.track++) { rc = 0; for (dadr.sector = 0;; dadr.sector++) { rc = disk_image_read_sector(drive->image, sector_data, &dadr); if (rc == 0) { SMW_BA(m, sector_data, 0x100); } else { break; } } if (dadr.sector == 0) { break; } } if (snapshot_module_close(m) < 0) { return -1; } return 0; }
void ciat_save_snapshot(ciat_t *cia_state, CLOCK cclk, snapshot_module_t *m, int ver) { /* ciat_print_state(state); */ if (ver >= 0x100) { /* major 1, minor >= 1 */ /* cnt & latch are saved from cia module already */ SMW_W(m, ((WORD)(cia_state->state))); } }
int sidcart_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_W(m, (WORD)sidcart_address) < 0 || SMW_B(m, (BYTE)sidcart_clock) < 0) { snapshot_module_close(m); return -1; } snapshot_module_close(m); return sid_snapshot_write_module(s); }
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 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 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; }
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 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 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; if (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 /* NewSpriteDmaMask */ || SMW_B(m, ted.raster.sprite_status->new_dma_msk) < 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, (BYTE)ted.regs[i]) < 0) goto fail; if (0 /* SpriteDmaMask */ || SMW_B(m, (BYTE)ted.raster.sprite_status->dma_msk) < 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; for (i = 0; i < 8; i++) { if (0 /* SpriteXMemPtr */ || SMW_B(m, (BYTE)ted.raster.sprite_status->sprites[i].memptr) < 0 /* SpriteXMemPtrInc */ || SMW_B(m, (BYTE)ted.raster.sprite_status->sprites[i].memptr_inc) < 0 /* SpriteXExpFlipFlop */ || SMW_B(m, (BYTE)ted.raster.sprite_status->sprites[i].exp_flag) < 0 ) goto fail; } if (0 /* FetchEventTick */ || SMW_DW(m, ted.fetch_clk - maincpu_clk) < 0 ) goto fail; return snapshot_module_close(m); fail: if (m != NULL) snapshot_module_close(m); return -1; }