2020-08-28 14:18:02 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// SCSI Target Emulator RaSCSI (*^..^*)
|
|
|
|
|
// for Raspberry Pi
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2001-2006 PI.(ytanaka@ipc-tokai.or.jp)
|
|
|
|
|
// Copyright (C) 2014-2020 GIMONS
|
2021-03-08 01:29:30 +00:00
|
|
|
|
// Copyright (C) akuker
|
2020-08-28 14:18:02 +00:00
|
|
|
|
//
|
2021-03-08 01:29:30 +00:00
|
|
|
|
// Licensed under the BSD 3-Clause License.
|
|
|
|
|
// See LICENSE file in the project root folder.
|
2020-08-28 14:18:02 +00:00
|
|
|
|
//
|
2021-03-08 01:29:30 +00:00
|
|
|
|
// [ SCSI Hard Disk for Apple Macintosh ]
|
2020-08-28 14:18:02 +00:00
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "os.h"
|
|
|
|
|
#include "disk.h"
|
|
|
|
|
#include "filepath.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Class precedence definition
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
class SCSICD;
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
//
|
|
|
|
|
// CD-ROM Track
|
|
|
|
|
//
|
|
|
|
|
//===========================================================================
|
|
|
|
|
class CDTrack
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
// Basic Functions
|
2021-03-08 01:29:30 +00:00
|
|
|
|
CDTrack(SCSICD *scsicd); // Constructor
|
|
|
|
|
virtual ~CDTrack(); // Destructor
|
2021-07-26 18:33:36 +00:00
|
|
|
|
BOOL Init(int track, DWORD first, DWORD last); // Initialization
|
2020-08-28 14:18:02 +00:00
|
|
|
|
|
|
|
|
|
// Properties
|
2021-07-26 18:33:36 +00:00
|
|
|
|
void SetPath(BOOL cdda, const Filepath& path); // Set the path
|
|
|
|
|
void GetPath(Filepath& path) const; // Get the path
|
|
|
|
|
void AddIndex(int index, DWORD lba); // Add index
|
|
|
|
|
DWORD GetFirst() const; // Get the start LBA
|
|
|
|
|
DWORD GetLast() const; // Get the last LBA
|
|
|
|
|
DWORD GetBlocks() const; // Get the number of blocks
|
|
|
|
|
int GetTrackNo() const; // Get the track number
|
|
|
|
|
BOOL IsValid(DWORD lba) const; // Is this a valid LBA?
|
|
|
|
|
BOOL IsAudio() const; // Is this an audio track?
|
2020-08-28 14:18:02 +00:00
|
|
|
|
|
|
|
|
|
private:
|
2021-03-08 01:29:30 +00:00
|
|
|
|
SCSICD *cdrom; // Parent device
|
|
|
|
|
BOOL valid; // Valid track
|
|
|
|
|
int track_no; // Track number
|
|
|
|
|
DWORD first_lba; // First LBA
|
|
|
|
|
DWORD last_lba; // Last LBA
|
|
|
|
|
BOOL audio; // Audio track flag
|
|
|
|
|
BOOL raw; // RAW data flag
|
|
|
|
|
Filepath imgpath; // Image file path
|
2020-08-28 14:18:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
//
|
|
|
|
|
// CD-DA Buffer
|
|
|
|
|
//
|
|
|
|
|
//===========================================================================
|
|
|
|
|
class CDDABuf
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
// Basic Functions
|
2021-03-08 01:29:30 +00:00
|
|
|
|
CDDABuf(); // Constructor
|
|
|
|
|
virtual ~CDDABuf(); // Destructor
|
|
|
|
|
#if 0
|
|
|
|
|
BOOL Init(); // Initialization
|
2021-07-26 18:33:36 +00:00
|
|
|
|
BOOL Load(const Filepath& path); // Load
|
|
|
|
|
BOOL Save(const Filepath& path); // Save
|
2020-08-28 14:18:02 +00:00
|
|
|
|
|
|
|
|
|
// API
|
2021-07-26 18:33:36 +00:00
|
|
|
|
void Clear(); // Clear the buffer
|
|
|
|
|
BOOL Open(Filepath& path); // File specification
|
|
|
|
|
BOOL GetBuf(DWORD *buffer, int frames); // Get the buffer
|
|
|
|
|
BOOL IsValid(); // Check if Valid
|
|
|
|
|
BOOL ReadReq(); // Read Request
|
|
|
|
|
BOOL IsEnd() const; // Finish check
|
2020-08-28 14:18:02 +00:00
|
|
|
|
|
|
|
|
|
private:
|
2021-03-08 01:29:30 +00:00
|
|
|
|
Filepath wavepath; // Wave path
|
|
|
|
|
BOOL valid; // Open result (is it valid?)
|
|
|
|
|
DWORD *buf; // Data buffer
|
|
|
|
|
DWORD read; // Read pointer
|
|
|
|
|
DWORD write; // Write pointer
|
|
|
|
|
DWORD num; // Valid number of data
|
|
|
|
|
DWORD rest; // Remaining file size
|
2020-08-28 14:18:02 +00:00
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
//
|
|
|
|
|
// SCSI CD-ROM
|
|
|
|
|
//
|
|
|
|
|
//===========================================================================
|
|
|
|
|
class SCSICD : public Disk
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
// Number of tracks
|
|
|
|
|
enum {
|
2021-03-08 01:29:30 +00:00
|
|
|
|
TrackMax = 96 // Maximum number of tracks
|
2020-08-28 14:18:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Basic Functions
|
2021-03-08 01:29:30 +00:00
|
|
|
|
SCSICD(); // Constructor
|
|
|
|
|
virtual ~SCSICD(); // Destructor
|
2021-08-08 15:08:58 +00:00
|
|
|
|
const char *Open(const Filepath& path, BOOL attn = TRUE); // Open
|
2020-08-28 14:18:02 +00:00
|
|
|
|
|
|
|
|
|
// commands
|
2021-07-26 18:33:36 +00:00
|
|
|
|
int Inquiry(const DWORD *cdb, BYTE *buf, DWORD major, DWORD minor); // INQUIRY command
|
|
|
|
|
int Read(const DWORD *cdb, BYTE *buf, DWORD block) override; // READ command
|
|
|
|
|
int ReadToc(const DWORD *cdb, BYTE *buf); // READ TOC command
|
|
|
|
|
BOOL PlayAudio(const DWORD *cdb); // PLAY AUDIO command
|
|
|
|
|
BOOL PlayAudioMSF(const DWORD *cdb); // PLAY AUDIO MSF command
|
|
|
|
|
BOOL PlayAudioTrack(const DWORD *cdb); // PLAY AUDIO TRACK command
|
2020-08-28 14:18:02 +00:00
|
|
|
|
|
|
|
|
|
// CD-DA
|
2021-07-26 18:33:36 +00:00
|
|
|
|
BOOL NextFrame(); // Frame notification
|
|
|
|
|
void GetBuf(DWORD *buffer, int samples, DWORD rate); // Get CD-DA buffer
|
2020-08-28 14:18:02 +00:00
|
|
|
|
|
|
|
|
|
// LBA-MSF変換
|
2021-07-26 18:33:36 +00:00
|
|
|
|
void LBAtoMSF(DWORD lba, BYTE *msf) const; // LBA→MSF conversion
|
|
|
|
|
DWORD MSFtoLBA(const BYTE *msf) const; // MSF→LBA conversion
|
2020-08-28 14:18:02 +00:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// Open
|
2021-07-26 18:33:36 +00:00
|
|
|
|
BOOL OpenCue(const Filepath& path); // Open(CUE)
|
|
|
|
|
BOOL OpenIso(const Filepath& path); // Open(ISO)
|
|
|
|
|
BOOL OpenPhysical(const Filepath& path); // Open(Physical)
|
2021-03-08 01:29:30 +00:00
|
|
|
|
BOOL rawfile; // RAW flag
|
2020-08-28 14:18:02 +00:00
|
|
|
|
|
|
|
|
|
// Track management
|
2021-07-26 18:33:36 +00:00
|
|
|
|
void ClearTrack(); // Clear the track
|
|
|
|
|
int SearchTrack(DWORD lba) const; // Track search
|
2021-03-08 01:29:30 +00:00
|
|
|
|
CDTrack* track[TrackMax]; // Track opbject references
|
|
|
|
|
int tracks; // Effective number of track objects
|
|
|
|
|
int dataindex; // Current data track
|
|
|
|
|
int audioindex; // Current audio track
|
|
|
|
|
|
|
|
|
|
int frame; // Frame number
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
CDDABuf da_buf; // CD-DA buffer
|
|
|
|
|
int da_num; // Number of CD-DA tracks
|
|
|
|
|
int da_cur; // CD-DA current track
|
|
|
|
|
int da_next; // CD-DA next track
|
|
|
|
|
BOOL da_req; // CD-DA data request
|
|
|
|
|
#endif
|
2020-08-28 14:18:02 +00:00
|
|
|
|
};
|