| 1 | #ifndef __MDFN_CDACCESS_IMAGE_H |
| 2 | #define __MDFN_CDACCESS_IMAGE_H |
| 3 | |
| 4 | #include <map> |
| 5 | |
| 6 | class Stream; |
| 7 | class AudioReader; |
| 8 | |
| 9 | struct CDRFILE_TRACK_INFO |
| 10 | { |
| 11 | int32 LBA; |
| 12 | |
| 13 | uint32 DIFormat; |
| 14 | uint8 subq_control; |
| 15 | |
| 16 | int32 pregap; |
| 17 | int32 pregap_dv; |
| 18 | |
| 19 | int32 postgap; |
| 20 | |
| 21 | int32 index[2]; |
| 22 | |
| 23 | int32 sectors; // Not including pregap sectors! |
| 24 | Stream *fp; |
| 25 | bool FirstFileInstance; |
| 26 | bool RawAudioMSBFirst; |
| 27 | long FileOffset; |
| 28 | unsigned int SubchannelMode; |
| 29 | |
| 30 | uint32 LastSamplePos; |
| 31 | |
| 32 | AudioReader *AReader; |
| 33 | }; |
| 34 | #if 0 |
| 35 | struct Medium_Chunk |
| 36 | { |
| 37 | int64 Offset; // Offset in [..TODO..] |
| 38 | uint32 DIFormat; |
| 39 | |
| 40 | FILE *fp; |
| 41 | bool FirstFileInstance; |
| 42 | bool RawAudioMSBFirst; |
| 43 | unsigned int SubchannelMode; |
| 44 | |
| 45 | uint32 LastSamplePos; |
| 46 | AudioReader *AReader; |
| 47 | }; |
| 48 | |
| 49 | struct CD_Chunk |
| 50 | { |
| 51 | int32 LBA; |
| 52 | int32 Track; |
| 53 | int32 Index; |
| 54 | bool DataType; |
| 55 | |
| 56 | Medium_Chunk Medium; |
| 57 | }; |
| 58 | |
| 59 | static std::vector<CD_Chunk> Chunks; |
| 60 | #endif |
| 61 | |
| 62 | class CDAccess_Image : public CDAccess |
| 63 | { |
| 64 | public: |
| 65 | |
| 66 | CDAccess_Image(const char *path, bool image_memcache); |
| 67 | virtual ~CDAccess_Image(); |
| 68 | |
| 69 | virtual void Read_Raw_Sector(uint8 *buf, int32 lba); |
| 70 | |
| 71 | virtual void Read_TOC(CDUtility::TOC *toc); |
| 72 | |
| 73 | virtual bool Is_Physical(void) throw(); |
| 74 | |
| 75 | virtual void Eject(bool eject_status); |
| 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 | |
| 85 | std::string base_dir; |
| 86 | |
| 87 | void ImageOpen(const char *path, bool image_memcache); |
| 88 | void Cleanup(void); |
| 89 | |
| 90 | // MakeSubPQ will OR the simulated P and Q subchannel data into SubPWBuf. |
| 91 | void MakeSubPQ(int32 lba, uint8 *SubPWBuf); |
| 92 | |
| 93 | 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); |
| 94 | uint32 GetSectorCount(CDRFILE_TRACK_INFO *track); |
| 95 | }; |
| 96 | |
| 97 | |
| 98 | #endif |