bool cbm_crt_read_data(core_file* file, UINT8 *roml, UINT8 *romh) { offs_t roml_offset = 0; offs_t romh_offset = 0; core_fseek(file, CRT_HEADER_LENGTH, SEEK_SET); while (!core_feof(file)) { cbm_crt_chip chip; core_fread(file, &chip, CRT_CHIP_LENGTH); UINT16 address = pick_integer_be(chip.start_address, 0, 2); UINT16 size = pick_integer_be(chip.image_size, 0, 2); switch (address) { case 0x8000: core_fread(file, roml + roml_offset, size); roml_offset += size; break; case 0xa000: core_fread(file, romh + romh_offset, size); romh_offset += size; break; case 0xe000: core_fread(file, romh + romh_offset, size); romh_offset += size; break; } } return true; }
bool cbm_crt_read_header(core_file* file, size_t *roml_size, size_t *romh_size, int *exrom, int *game) { // read the header cbm_crt_header header; core_fread(file, &header, CRT_HEADER_LENGTH); if (memcmp(header.signature, CRT_SIGNATURE, 16) != 0) return false; UINT16 hardware = pick_integer_be(header.hardware, 0, 2); *exrom = header.exrom; *game = header.game; if (LOG) { logerror("Name: %s\n", header.name); logerror("Hardware: %04x\n", hardware); logerror("Slot device: %s\n", CRT_C64_SLOT_NAMES[hardware]); logerror("EXROM: %u\n", header.exrom); logerror("GAME: %u\n", header.game); } // determine ROM region lengths while (!core_feof(file)) { cbm_crt_chip chip; core_fread(file, &chip, CRT_CHIP_LENGTH); UINT16 address = pick_integer_be(chip.start_address, 0, 2); UINT16 size = pick_integer_be(chip.image_size, 0, 2); UINT16 type = pick_integer_be(chip.chip_type, 0, 2); if (LOG) { logerror("CHIP Address: %04x\n", address); logerror("CHIP Size: %04x\n", size); logerror("CHIP Type: %04x\n", type); } switch (address) { case 0x8000: *roml_size += size; break; case 0xa000: *romh_size += size; break; case 0xe000: *romh_size += size; break; default: logerror("Invalid CHIP loading address!\n"); break; } core_fseek(file, size, SEEK_CUR); } return true; }
bool emu_file::eof() { // load the ZIP file now if we haven't yet if (compressed_file_ready()) return 0; // return EOF if we can if (m_file != NULL) return core_feof(m_file); return 0; }
bool emu_file::eof() { // load the ZIP file now if we haven't yet if (m_zipfile != NULL && load_zipped_file() != FILERR_NONE) return 0; // return EOF if we can if (m_file != NULL) return core_feof(m_file); return 0; }
xml_data_node *xml_file_read(core_file *file, xml_parse_options *opts) { xml_parse_info parse_info; int done; /* set up the parser */ if (!expat_setup_parser(&parse_info, opts)) return NULL; /* loop through the file and parse it */ do { char tempbuf[TEMP_BUFFER_SIZE]; /* read as much as we can */ int bytes = core_fread(file, tempbuf, sizeof(tempbuf)); done = core_feof(file); /* parse the data */ if (XML_Parse(parse_info.parser, tempbuf, bytes, done) == XML_STATUS_ERROR) { if (opts != NULL && opts->error != NULL) { opts->error->error_message = XML_ErrorString(XML_GetErrorCode(parse_info.parser)); opts->error->error_line = XML_GetCurrentLineNumber(parse_info.parser); opts->error->error_column = XML_GetCurrentColumnNumber(parse_info.parser); } xml_file_free(parse_info.rootnode); XML_ParserFree(parse_info.parser); return NULL; } } while (!done); /* free the parser */ XML_ParserFree(parse_info.parser); /* return the root node */ return parse_info.rootnode; }