本文整理汇总了C++中snapshot_module_create函数的典型用法代码示例。如果您正苦于以下问题:C++ snapshot_module_create函数的具体用法?C++ snapshot_module_create怎么用?C++ snapshot_module_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了snapshot_module_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tape_snapshot_write_tapimage_module
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;
}
示例2: sid_snapshot_write_module_simple
static int sid_snapshot_write_module_simple(snapshot_t *s)
{
int sound, sid_engine;
snapshot_module_t *m;
m = snapshot_module_create(s, snap_module_name_simple, SNAP_MAJOR_SIMPLE,
SNAP_MINOR_SIMPLE);
if (m == NULL) {
return -1;
}
resources_get_int("Sound", &sound);
if (SMW_B(m, (BYTE)sound) < 0) {
snapshot_module_close(m);
return -1;
}
if (sound) {
resources_get_int("SidEngine", &sid_engine);
if (SMW_B(m, (BYTE)sid_engine) < 0) {
snapshot_module_close(m);
return -1;
}
/* FIXME: Only data for first SID stored. */
if (SMW_BA(m, sid_get_siddata(0), 32) < 0) {
snapshot_module_close(m);
return -1;
}
}
snapshot_module_close(m);
return 0;
}
示例3: mem_write_rom_snapshot_module
static int mem_write_rom_snapshot_module(snapshot_t *p, int save_roms)
{
snapshot_module_t *m;
if (!save_roms) {
return 0;
}
m = snapshot_module_create(p, SNAP_ROM_MODULE_NAME, VIC20MEM_DUMP_VER_MAJOR, VIC20MEM_DUMP_VER_MINOR);
if (m == NULL) {
return -1;
}
/* old cart system config bits. all zero = no roms */
SMW_B(m, 0x00);
/* save kernal */
SMW_BA(m, vic20memrom_kernal_rom, 0x2000);
/* save basic */
SMW_BA(m, vic20memrom_basic_rom, 0x2000);
SMW_BA(m, vic20memrom_chargen_rom, 0x1000);
snapshot_module_close(m);
return 0;
}
示例4: digimax_snapshot_write_module
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;
}
示例5: vic_fp_snapshot_write_module
int vic_fp_snapshot_write_module(snapshot_t *s)
{
snapshot_module_t *m;
m = snapshot_module_create(s, SNAP_MODULE_NAME,
VIC20CART_DUMP_VER_MAJOR,
VIC20CART_DUMP_VER_MINOR);
if (m == NULL) {
return -1;
}
if (0
|| (SMW_B(m, cart_bank_reg) < 0)
|| (SMW_B(m, cart_cfg_reg) < 0)
|| (SMW_BA(m, cart_ram, CART_RAM_SIZE) < 0)
|| (SMW_BA(m, cart_rom, CART_ROM_SIZE) < 0)) {
snapshot_module_close(m);
return -1;
}
snapshot_module_close(m);
if ((flash040core_snapshot_write_module(s, &flash_state, FLASH_SNAP_MODULE_NAME) < 0)) {
return -1;
}
return 0;
}
示例6: riotcore_snapshot_write_module
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;
}
示例7: myacia_snapshot_write_module
/*! \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;
}
示例8: finalexpansion_snapshot_write_module
int finalexpansion_snapshot_write_module(snapshot_t *s)
{
snapshot_module_t *m;
m = snapshot_module_create(s, SNAP_MODULE_NAME, VIC20CART_DUMP_VER_MAJOR, VIC20CART_DUMP_VER_MINOR);
if (m == NULL) {
return -1;
}
if (0
|| (SMW_B(m, register_a) < 0)
|| (SMW_B(m, register_b) < 0)
|| (SMW_B(m, lock_bit) < 0)
|| (SMW_BA(m, cart_ram, CART_RAM_SIZE) < 0)
|| (SMW_BA(m, flash_state.flash_data, CART_ROM_SIZE) < 0)) {
snapshot_module_close(m);
return -1;
}
snapshot_module_close(m);
if ((flash040core_snapshot_write_module(s, &flash_state, FLASH_SNAP_MODULE_NAME) < 0)) {
return -1;
}
return 0;
}
示例9: fdc_snapshot_write_module
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;
}
示例10: easyflash_snapshot_write_module
int easyflash_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)easyflash_jumper) < 0)
|| (SMW_B(m, easyflash_register_00) < 0)
|| (SMW_B(m, easyflash_register_02) < 0)
|| (SMW_BA(m, easyflash_ram, 256) < 0)
|| (SMW_BA(m, roml_banks, 0x80000) < 0)
|| (SMW_BA(m, romh_banks, 0x80000) < 0)) {
snapshot_module_close(m);
return -1;
}
snapshot_module_close(m);
if (0
|| (flash040core_snapshot_write_module(s, easyflash_state_low, FLASH_SNAP_MODULE_NAME) < 0)
|| (flash040core_snapshot_write_module(s, easyflash_state_high, FLASH_SNAP_MODULE_NAME) < 0)) {
return -1;
}
return 0;
}
示例11: drive_snapshot_write_image_module
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;
}
示例12: vic_snapshot_write_module
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;
}
示例13: ds1216e_write_snapshot
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);
}
示例14: drive_snapshot_write_p64image_module
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;
}
示例15: mem_write_rom_snapshot_module
static int mem_write_rom_snapshot_module(snapshot_t *s)
{
snapshot_module_t *m;
int trapfl;
/* Main memory module. */
m = snapshot_module_create(s, snap_rom_module_name,
SNAP_ROM_MAJOR, SNAP_ROM_MINOR);
if (m == NULL)
return -1;
/* disable traps before saving the ROM */
resources_get_int("VirtualDevices", &trapfl);
resources_set_int("VirtualDevices", 0);
if (0
|| SMW_BA(m, c128memrom_kernal_rom, C128_KERNAL_ROM_SIZE) < 0
|| SMW_BA(m, c128memrom_basic_rom, C128_BASIC_ROM_SIZE) < 0
|| SMW_BA(m, c128memrom_basic_rom + C128_BASIC_ROM_SIZE,
C128_EDITOR_ROM_SIZE) < 0
|| SMW_BA(m, mem_chargen_rom, C128_CHARGEN_ROM_SIZE) < 0)
goto fail;
/* FIXME: save cartridge ROM (& RAM?) areas:
first write out the configuration, i.e.
- type of cartridge (banking scheme type)
- state of cartridge (active/which bank, ...)
then the ROM/RAM arrays:
- cartridge ROM areas
- cartridge RAM areas
*/
/* enable traps again when necessary */
resources_set_int("VirtualDevices", trapfl);
if (snapshot_module_close(m) < 0)
goto fail;
return 0;
fail:
/* enable traps again when necessary */
resources_set_int("VirtualDevices", trapfl);
if (m != NULL)
snapshot_module_close(m);
return -1;
}