Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/psx/mednadisc/cdrom/CDAccess_Image.h
2 views
1
#ifndef __MDFN_CDACCESS_IMAGE_H
2
#define __MDFN_CDACCESS_IMAGE_H
3
4
#include <map>
5
#include <array>
6
7
class Stream;
8
class CDAFReader;
9
10
struct CDRFILE_TRACK_INFO
11
{
12
int32 LBA;
13
14
uint32 DIFormat;
15
uint8 subq_control;
16
17
int32 pregap;
18
int32 pregap_dv;
19
20
int32 postgap;
21
22
int32 index[2];
23
24
int32 sectors; // Not including pregap sectors!
25
Stream *fp;
26
bool FirstFileInstance;
27
bool RawAudioMSBFirst;
28
long FileOffset;
29
unsigned int SubchannelMode;
30
31
uint32 LastSamplePos;
32
33
CDAFReader *AReader;
34
};
35
#if 0
36
struct Medium_Chunk
37
{
38
int64 Offset; // Offset in [..TODO..]
39
uint32 DIFormat;
40
41
FILE *fp;
42
bool FirstFileInstance;
43
bool RawAudioMSBFirst;
44
unsigned int SubchannelMode;
45
46
uint32 LastSamplePos;
47
AudioReader *AReader;
48
};
49
50
struct CD_Chunk
51
{
52
int32 LBA;
53
int32 Track;
54
int32 Index;
55
bool DataType;
56
57
Medium_Chunk Medium;
58
};
59
60
static std::vector<CD_Chunk> Chunks;
61
#endif
62
63
class CDAccess_Image : public CDAccess
64
{
65
public:
66
67
CDAccess_Image(const std::string& path, bool image_memcache);
68
virtual ~CDAccess_Image();
69
70
virtual void Read_Raw_Sector(uint8 *buf, int32 lba);
71
72
virtual bool Fast_Read_Raw_PW_TSRE(uint8* pwbuf, int32 lba) const noexcept;
73
74
virtual void Read_TOC(CDUtility::TOC *toc);
75
76
private:
77
78
int32 NumTracks;
79
int32 FirstTrack;
80
int32 LastTrack;
81
int32 total_sectors;
82
uint8 disc_type;
83
CDRFILE_TRACK_INFO Tracks[100]; // Track #0(HMM?) through 99
84
CDUtility::TOC toc;
85
86
std::map<uint32, std::array<uint8, 12>> SubQReplaceMap;
87
88
std::string base_dir;
89
90
void ImageOpen(const std::string& path, bool image_memcache);
91
void LoadSBI(const std::string& sbi_path);
92
void GenerateTOC(void);
93
void Cleanup(void);
94
95
// MakeSubPQ will OR the simulated P and Q subchannel data into SubPWBuf.
96
int32 MakeSubPQ(int32 lba, uint8 *SubPWBuf) const;
97
98
void ParseTOCFileLineInfo(CDRFILE_TRACK_INFO *track, const int tracknum, const std::string &filename, const char *binoffset, const char *msfoffset, const char *length, bool image_memcache, std::map<std::string, Stream*> &toc_streamcache);
99
uint32 GetSectorCount(CDRFILE_TRACK_INFO *track);
100
};
101
102
103
#endif
104
105