Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/psx/mednadisc/cdrom/cdromif.h
2 views
1
/* Mednafen - Multi-system Emulator
2
*
3
* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License as published by
5
* the Free Software Foundation; either version 2 of the License, or
6
* (at your option) any later version.
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*/
17
18
#ifndef __MDFN_CDROM_CDROMIF_H
19
#define __MDFN_CDROM_CDROMIF_H
20
21
#include "CDUtility.h"
22
#include "stream.h"
23
24
#include <queue>
25
26
typedef CDUtility::TOC CD_TOC;
27
28
class CDIF
29
{
30
public:
31
32
CDIF();
33
virtual ~CDIF();
34
35
static const int32 LBA_Read_Minimum = -150;
36
static const int32 LBA_Read_Maximum = 449849; // 100 * 75 * 60 - 150 - 1
37
38
inline void ReadTOC(CDUtility::TOC *read_target)
39
{
40
*read_target = disc_toc;
41
}
42
43
virtual void HintReadSector(int32 lba) = 0;
44
virtual bool ReadRawSector(uint8 *buf, int32 lba) = 0; // Reads 2352+96 bytes of data into buf.
45
virtual bool ReadRawSectorPWOnly(uint8* pwbuf, int32 lba, bool hint_fullread) = 0; // Reads 96 bytes(of raw subchannel PW data) into pwbuf.
46
47
// Call for mode 1 or mode 2 form 1 only.
48
bool ValidateRawSector(uint8 *buf);
49
50
// Utility/Wrapped functions
51
// Reads mode 1 and mode2 form 1 sectors(2048 bytes per sector returned)
52
// Will return the type(1, 2) of the first sector read to the buffer supplied, 0 on error
53
int ReadSector(uint8* buf, int32 lba, uint32 sector_count, bool suppress_uncorrectable_message = false);
54
55
// For Mode 1, or Mode 2 Form 1.
56
// No reference counting or whatever is done, so if you destroy the CDIF object before you destroy the returned Stream, things will go BOOM.
57
Stream *MakeStream(int32 lba, uint32 sector_count);
58
59
protected:
60
bool UnrecoverableError;
61
CDUtility::TOC disc_toc;
62
};
63
64
CDIF *CDIF_Open(const std::string& path, bool image_memcache);
65
66
#endif
67
68