2014-04-06 13:11:19 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
|
|
|
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
|
|
|
*
|
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-04-24 21:37:39 +00:00
|
|
|
#ifndef __CDVD_H__
|
|
|
|
#define __CDVD_H__
|
|
|
|
|
2016-02-26 11:05:50 +00:00
|
|
|
#define _WIN32_WINNT 0x0600
|
2016-10-22 17:53:21 +00:00
|
|
|
#define NOMINMAX
|
2010-04-24 21:37:39 +00:00
|
|
|
#include <windows.h>
|
2016-10-22 17:53:21 +00:00
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
2016-10-14 17:12:03 +00:00
|
|
|
#include <mutex>
|
2016-10-22 17:53:21 +00:00
|
|
|
#include <string>
|
2016-10-22 20:17:39 +00:00
|
|
|
#include <vector>
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
#define CDVDdefs
|
|
|
|
#include <PS2Edefs.h>
|
|
|
|
|
2016-09-19 23:40:45 +00:00
|
|
|
struct track
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2016-09-19 17:24:54 +00:00
|
|
|
u32 start_lba;
|
2016-09-19 23:40:45 +00:00
|
|
|
u8 type;
|
|
|
|
};
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-09-19 23:40:45 +00:00
|
|
|
extern u8 strack;
|
|
|
|
extern u8 etrack;
|
2010-04-24 21:37:39 +00:00
|
|
|
extern track tracks[100];
|
|
|
|
|
|
|
|
extern int curDiskType;
|
|
|
|
extern int curTrayStatus;
|
|
|
|
|
2016-10-22 20:17:39 +00:00
|
|
|
struct toc_entry
|
2016-09-19 17:24:54 +00:00
|
|
|
{
|
2016-10-22 20:17:39 +00:00
|
|
|
u32 lba;
|
|
|
|
u8 track;
|
|
|
|
u8 adr : 4;
|
|
|
|
u8 control : 4;
|
|
|
|
};
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-09-21 18:00:07 +00:00
|
|
|
class IOCtlSrc
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2016-10-22 17:53:21 +00:00
|
|
|
IOCtlSrc(const IOCtlSrc &) = delete;
|
|
|
|
IOCtlSrc &operator=(const IOCtlSrc &) = delete;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-10-22 17:53:21 +00:00
|
|
|
HANDLE m_device = INVALID_HANDLE_VALUE;
|
|
|
|
std::string m_filename;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-10-22 17:53:21 +00:00
|
|
|
s32 m_media_type = 0;
|
|
|
|
u32 m_sectors = 0;
|
|
|
|
u32 m_layer_break = 0;
|
2016-10-22 20:17:39 +00:00
|
|
|
std::vector<toc_entry> m_toc;
|
2016-10-14 17:12:03 +00:00
|
|
|
mutable std::mutex m_lock;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-10-22 17:53:21 +00:00
|
|
|
bool ReadDVDInfo();
|
|
|
|
bool ReadCDInfo();
|
2016-10-22 23:53:41 +00:00
|
|
|
bool Reopen();
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
public:
|
2016-10-22 17:53:21 +00:00
|
|
|
IOCtlSrc(const char *filename);
|
2016-09-21 18:00:07 +00:00
|
|
|
~IOCtlSrc();
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-10-22 23:53:41 +00:00
|
|
|
u32 GetSectorCount() const;
|
|
|
|
const std::vector<toc_entry> &ReadTOC() const;
|
2016-09-21 18:00:07 +00:00
|
|
|
s32 ReadSectors2048(u32 sector, u32 count, char *buffer);
|
|
|
|
s32 ReadSectors2352(u32 sector, u32 count, char *buffer);
|
2016-10-22 23:53:41 +00:00
|
|
|
u32 GetLayerBreakAddress() const;
|
|
|
|
s32 GetMediaType() const;
|
|
|
|
void SetSpindleSpeed(bool restore_defaults) const;
|
|
|
|
bool DiscReady();
|
2010-04-24 21:37:39 +00:00
|
|
|
};
|
|
|
|
|
2016-09-21 18:00:07 +00:00
|
|
|
extern IOCtlSrc *src;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
void configure();
|
|
|
|
|
|
|
|
extern char source_drive;
|
|
|
|
|
|
|
|
extern HINSTANCE hinst;
|
|
|
|
|
|
|
|
void ReadSettings();
|
|
|
|
void WriteSettings();
|
2016-09-19 17:24:54 +00:00
|
|
|
void CfgSetSettingsDir(const char *dir);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2014-07-15 21:06:49 +00:00
|
|
|
extern bool cdvd_is_open;
|
|
|
|
extern bool cdvdKeepAlive_is_open;
|
|
|
|
extern bool disc_has_changed;
|
|
|
|
extern bool weAreInNewDiskCB;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
extern void (*newDiscCB)();
|
|
|
|
|
|
|
|
s32 cdvdStartThread();
|
|
|
|
void cdvdStopThread();
|
|
|
|
s32 cdvdRequestSector(u32 sector, s32 mode);
|
|
|
|
s32 cdvdRequestComplete();
|
2016-09-19 17:24:54 +00:00
|
|
|
char *cdvdGetSector(s32 sector, s32 mode);
|
2010-04-24 21:37:39 +00:00
|
|
|
s32 cdvdDirectReadSector(s32 first, s32 mode, char *buffer);
|
|
|
|
s32 cdvdGetMediaType();
|
|
|
|
s32 cdvdRefreshData();
|
2016-10-22 20:17:39 +00:00
|
|
|
void cdvdParseTOC();
|
2010-04-24 21:37:39 +00:00
|
|
|
|
|
|
|
#endif /* __CDVD_H__ */
|