| 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 | inline void ReadTOC(CDUtility::TOC *read_target) |
| 36 | { |
| 37 | *read_target = disc_toc; |
| 38 | } |
| 39 | |
| 40 | virtual void HintReadSector(uint32 lba) = 0; |
| 41 | virtual bool ReadRawSector(uint8 *buf, uint32 lba) = 0; |
| 42 | |
| 43 | // Call for mode 1 or mode 2 form 1 only. |
| 44 | bool ValidateRawSector(uint8 *buf); |
| 45 | |
| 46 | // Utility/Wrapped functions |
| 47 | // Reads mode 1 and mode2 form 1 sectors(2048 bytes per sector returned) |
| 48 | // Will return the type(1, 2) of the first sector read to the buffer supplied, 0 on error |
| 49 | int ReadSector(uint8* pBuf, uint32 lba, uint32 nSectors); |
| 50 | |
| 51 | // Return true if operation succeeded or it was a NOP(either due to not being implemented, or the current status matches eject_status). |
| 52 | // Returns false on failure(usually drive error of some kind; not completely fatal, can try again). |
| 53 | virtual bool Eject(bool eject_status) = 0; |
| 54 | |
| 55 | inline bool IsPhysical(void) { return(is_phys_cache); } |
| 56 | |
| 57 | // For Mode 1, or Mode 2 Form 1. |
| 58 | // No reference counting or whatever is done, so if you destroy the CDIF object before you destroy the returned Stream, things will go BOOM. |
| 59 | Stream *MakeStream(uint32 lba, uint32 sector_count); |
| 60 | |
| 61 | protected: |
| 62 | bool UnrecoverableError; |
| 63 | bool is_phys_cache; |
| 64 | CDUtility::TOC disc_toc; |
| 65 | bool DiscEjected; |
| 66 | }; |
| 67 | |
| 68 | CDIF *CDIF_Open(const char *path, const bool is_device, bool image_memcache); |
| 69 | |
| 70 | #endif |