static REG8 hdd_format(SXSIDEV sxsi, long pos) { FILEH fh; long r; UINT16 i; UINT8 work[256]; UINT size; UINT wsize; if (sxsi_prepare(sxsi) != SUCCESS) { return(0x60); } if ((pos < 0) || (pos >= sxsi->totals)) { return(0x40); } pos = pos * sxsi->size + sxsi->headersize; fh = (FILEH)sxsi->hdl; r = file_seek(fh, pos, FSEEK_SET); if (pos != r) { return(0xd0); } FillMemory(work, sizeof(work), 0xe5); for (i=0; i<sxsi->sectors; i++) { size = sxsi->size; while(size) { wsize = min(size, sizeof(work)); size -= wsize; CPU_REMCLOCK -= wsize; if (file_write(fh, work, wsize) != wsize) { return(0x70); } } } return(0x00); }
static REG8 hdd_write(SXSIDEV sxsi, long pos, const UINT8 *buf, UINT size) { FILEH fh; long r; UINT wsize; if (sxsi_prepare(sxsi) != SUCCESS) { return(0x60); } if ((pos < 0) || (pos >= sxsi->totals)) { return(0x40); } pos = pos * sxsi->size + sxsi->headersize; fh = (FILEH)sxsi->hdl; r = file_seek(fh, pos, FSEEK_SET); if (pos != r) { return(0xd0); } while(size) { wsize = min(size, sxsi->size); CPU_REMCLOCK -= wsize; if (file_write(fh, buf, wsize) != wsize) { return(0x70); } buf += wsize; size -= wsize; } return(0x00); }
// イメージファイル内全トラックセクタ長2448(2352+96)用 REG8 sec2448_read(SXSIDEV sxsi, long pos, UINT8 *buf, UINT size) { CDINFO cdinfo; FILEH fh; long fpos; UINT rsize; if (sxsi_prepare(sxsi) != SUCCESS) { return(0x60); } if ((pos < 0) || (pos >= sxsi->totals)) { return(0x40); } cdinfo = (CDINFO)sxsi->hdl; fh = cdinfo->fh; while(size) { fpos = (pos * 2448) + 16 + cdinfo->trk[0].start_offset; if (file_seek(fh, fpos, FSEEK_SET) != fpos) { return(0xd0); } rsize = min(size, 2048); CPU_REMCLOCK -= rsize; if (file_read(fh, buf, rsize) != rsize) { return(0xd0); } buf += rsize; size -= rsize; pos++; } return(0x00); }
static REG8 sec2048_read(SXSIDEV sxsi, long pos, UINT8 *buf, UINT size) { FILEH fh; UINT rsize; if (sxsi_prepare(sxsi) != SUCCESS) { return(0x60); } if ((pos < 0) || (pos >= sxsi->totals)) { return(0x40); } pos = pos * 2048; fh = ((CDINFO)sxsi->hdl)->fh; if (file_seek(fh, pos, FSEEK_SET) != pos) { return(0xd0); } while(size) { rsize = min(size, 2048); CPU_REMCLOCK -= rsize; if (file_read(fh, buf, rsize) != rsize) { return(0xd0); } buf += rsize; size -= rsize; } return(0x00); }
// イメージファイル内セクタ長混在用 // 非RAW(2048byte)+Audio(2352byte)等 REG8 sec_read(SXSIDEV sxsi, long pos, UINT8 *buf, UINT size) { CDINFO cdinfo; FILEH fh; long fpos; UINT rsize; UINT i; UINT32 secs; if (sxsi_prepare(sxsi) != SUCCESS) { return(0x60); } if ((pos < 0) || (pos >= sxsi->totals)) { return(0x40); } cdinfo = (CDINFO)sxsi->hdl; fh = cdinfo->fh; while (size) { fpos = 0; secs = 0; for (i = 0; i < cdinfo->trks; i++) { if (cdinfo->trk[i].str_sec <= pos && pos <= cdinfo->trk[i].end_sec) { fpos += (pos - secs) * cdinfo->trk[i].sector_size; if (cdinfo->trk[i].sector_size != 2048) { fpos += 16; } break; } fpos += cdinfo->trk[i].sectors * cdinfo->trk[i].sector_size; secs += cdinfo->trk[i].sectors; } fpos += cdinfo->trk[0].start_offset; if (file_seek(fh, fpos, FSEEK_SET) != fpos) { return(0xd0); } rsize = min(size, 2048); CPU_REMCLOCK -= rsize; if (file_read(fh, buf, rsize) != rsize) { return(0xd0); } buf += rsize; size -= rsize; pos++; } return(0x00); }
BRESULT sxsicd_readraw(SXSIDEV sxsi, long pos, void *buf) { CDINFO cdinfo; FILEH fh; long fpos; cdinfo = (CDINFO)sxsi->hdl; if (cdinfo->type != 2352) { return(FAILURE); } if (sxsi_prepare(sxsi) != SUCCESS) { return(FAILURE); } if ((pos < 0) || (pos >= sxsi->totals)) { return(FAILURE); } fh = ((CDINFO)sxsi->hdl)->fh; fpos = pos * 2352; if ((file_seek(fh, fpos, FSEEK_SET) != fpos) || (file_read(fh, buf, 2352) != 2352)) { return(FAILURE); } return(SUCCESS); }