UINT32 hard_disk_write(struct hard_disk_file *file, UINT32 lbasector, UINT32 numsectors, const void *buffer) { UINT32 hunknum = lbasector / file->hunksectors; UINT32 sectoroffs = lbasector % file->hunksectors; /* for now, just break down multisector writes into single sectors */ if (numsectors > 1) { UINT32 total = 0; while (numsectors--) { if (hard_disk_write(file, lbasector++, 1, (const UINT8 *)buffer + total * file->info.sectorbytes)) total++; else break; } return total; } /* if we haven't cached this hunk, read it now */ if (file->cachehunk != hunknum) { if (!chd_read(file->chd, hunknum, 1, file->cache)) return 0; file->cachehunk = hunknum; } /* copy in the requested data */ memcpy(&file->cache[sectoroffs * file->info.sectorbytes], buffer, file->info.sectorbytes); /* write it back out */ if (chd_write(file->chd, hunknum, 1, file->cache)) return 1; return 0; }
UINT32 hard_disk_read(struct hard_disk_file *file, UINT32 lbasector, UINT32 numsectors, void *buffer) { UINT32 hunknum = lbasector / file->hunksectors; UINT32 sectoroffs = lbasector % file->hunksectors; /* for now, just break down multisector reads into single sectors */ if (numsectors > 1) { UINT32 total = 0; while (numsectors--) { if (hard_disk_read(file, lbasector++, 1, (UINT8 *)buffer + total * file->info.sectorbytes)) total++; else break; } return total; } // printf("HDD: rd lba %x\n", lbasector); /* if we haven't cached this hunk, read it now */ if (file->cachehunk != hunknum) { if (!chd_read(file->chd, hunknum, 1, file->cache)) return 0; file->cachehunk = hunknum; } /* copy out the requested sector */ memcpy(buffer, &file->cache[sectoroffs * file->info.sectorbytes], file->info.sectorbytes); return 1; }
static int read_chd(void *file, int frame, bitmap_yuy16 &bitmap, INT16 *lsound, INT16 *rsound, int *samples) { av_codec_decompress_config avconfig; int interlace_factor = chdinterlaced ? 2 : 1; bitmap_yuy16 fakebitmap; UINT32 numsamples; chd_error chderr; int fieldnum; /* loop over fields */ *samples = 0; for (fieldnum = 0; fieldnum < interlace_factor; fieldnum++) { /* make a fake bitmap for this field */ avconfig.video.wrap(&bitmap.pix16(fieldnum), bitmap.width(), bitmap.height() / interlace_factor, bitmap.rowpixels() * interlace_factor); /* configure the codec */ avconfig.maxsamples = 48000; avconfig.actsamples = &numsamples; avconfig.audio[0] = &lsound[*samples]; avconfig.audio[1] = &rsound[*samples]; /* configure the decompressor for this frame */ chd_codec_config((chd_file *)file, AV_CODEC_DECOMPRESS_CONFIG, &avconfig); /* read the frame */ chderr = chd_read((chd_file *)file, frame * interlace_factor + fieldnum, NULL); if (chderr != CHDERR_NONE) return FALSE; /* account for samples read */ *samples += numsamples; } return TRUE; }
virtual void Read(u32 FAD,u8* dst,SectorFormat* sector_type,u8* subcode,SubcodeFormat* subcode_type) { u32 fad_offs=FAD-StartFAD; u32 hunk=(fad_offs)/disc->sph + StartHunk; if (disc->old_hunk!=hunk) { chd_read(disc->chd,hunk,disc->hunk_mem); //CHDERR_NONE } u32 hunk_ofs=fad_offs%disc->sph; memcpy(dst,disc->hunk_mem+hunk_ofs*(2352+96),2352); *sector_type=SECFMT_2352; //While space is reserved for it, the images contain no actual subcodes //memcpy(subcode,disc->hunk_mem+hunk_ofs*(2352+96)+2352,96); *subcode_type=SUBFMT_NONE; }
UINT32 hard_disk_read(hard_disk_file *file, UINT32 lbasector, void *buffer) { UINT32 hunknum = lbasector / file->hunksectors; UINT32 sectoroffs = lbasector % file->hunksectors; /* if we haven't cached this hunk, read it now */ if (file->cachehunk != hunknum) { chd_error err = chd_read(file->chd, hunknum, file->cache); if (err != CHDERR_NONE) return 0; file->cachehunk = hunknum; } /* copy out the requested sector */ memcpy(buffer, &file->cache[sectoroffs * file->info.sectorbytes], file->info.sectorbytes); return 1; }
UINT32 hard_disk_write(hard_disk_file *file, UINT32 lbasector, const void *buffer) { UINT32 hunknum = lbasector / file->hunksectors; UINT32 sectoroffs = lbasector % file->hunksectors; chd_error err; /* if we haven't cached this hunk, read it now */ if (file->cachehunk != hunknum) { err = chd_read(file->chd, hunknum, file->cache); if (err != CHDERR_NONE) return 0; file->cachehunk = hunknum; } /* copy in the requested data */ memcpy(&file->cache[sectoroffs * file->info.sectorbytes], buffer, file->info.sectorbytes); /* write it back out */ err = chd_write(file->chd, hunknum, file->cache); return (err == CHDERR_NONE) ? 1 : 0; }