int simon_snapshot_read_module(snapshot_t *s) { BYTE vmajor, vminor; snapshot_module_t *m; m = snapshot_module_open(s, SNAP_MODULE_NAME, &vmajor, &vminor); if (m == NULL) { return -1; } if ((vmajor != CART_DUMP_VER_MAJOR) || (vminor != CART_DUMP_VER_MINOR)) { snapshot_module_close(m); return -1; } if (0 || (SMR_BA(m, roml_banks, 0x2000) < 0) || (SMR_BA(m, romh_banks, 0x2000) < 0)) { snapshot_module_close(m); return -1; } snapshot_module_close(m); return simon_common_attach(); }
int simon_bin_attach(const char *filename, BYTE *rawcart) { if (util_file_load(filename, rawcart, 0x4000, UTIL_FILE_LOAD_SKIP_ADDRESS) < 0) { return -1; } return simon_common_attach(); }
int simon_crt_attach(FILE *fd, BYTE *rawcart) { crt_chip_header_t chip; int i; for (i = 0; i <= 1; i++) { if (crt_read_chip_header(&chip, fd)) { return -1; } if ((chip.start != 0x8000 && chip.start != 0xa000) || chip.size != 0x2000) { return -1; } if (crt_read_chip(rawcart, chip.start - 0x8000, &chip, fd)) { return -1; } } return simon_common_attach(); }
int simon_crt_attach(FILE *fd, BYTE *rawcart) { BYTE chipheader[0x10]; int i; for (i = 0; i <= 1; i++) { if (fread(chipheader, 0x10, 1, fd) < 1) { return -1; } if (chipheader[0xc] != 0x80 && chipheader[0xc] != 0xa0) { return -1; } if (fread(&rawcart[(chipheader[0xc] << 8) - 0x8000], 0x2000, 1, fd) < 1) { return -1; } } return simon_common_attach(); }
int simon_snapshot_read_module(snapshot_t *s) { BYTE vmajor, vminor; snapshot_module_t *m; m = snapshot_module_open(s, snap_module_name, &vmajor, &vminor); if (m == NULL) { return -1; } /* Do not accept versions higher than current */ if (vmajor > SNAP_MAJOR || vminor > SNAP_MINOR) { snapshot_set_error(SNAPSHOT_MODULE_HIGHER_VERSION); goto fail; } /* new in 0.1 */ if (SNAPVAL(vmajor, vminor, 0, 1)) { if (SMR_B_INT(m, &simon_a000) < 0) { goto fail; } } else { simon_a000 = 0; } if (0 || SMR_BA(m, roml_banks, 0x2000) < 0 || SMR_BA(m, romh_banks, 0x2000) < 0) { goto fail; } snapshot_module_close(m); return simon_common_attach(); fail: snapshot_module_close(m); return -1; }