1
0
Fork 0

Removed HostPt in ReadSector

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1132
This commit is contained in:
Ulf Wohlers 2003-07-14 11:35:06 +00:00
parent b0780d0cb4
commit 640e059254
4 changed files with 33 additions and 13 deletions

View file

@ -5,6 +5,7 @@
#define MAX_ASPI_CDROM 5
#include <string.h>
#include "mem.h"
#include "SDL.h"
#define RAW_SECTOR_SIZE 2352
@ -40,7 +41,7 @@ public:
virtual bool PauseAudio (bool resume) = 0;
virtual bool StopAudio (void) = 0;
virtual bool ReadSectors (void* buffer, bool raw, unsigned long sector, unsigned long num) = 0;
virtual bool ReadSectors (PhysPt buffer, bool raw, unsigned long sector, unsigned long num) = 0;
virtual bool LoadUnloadMedia (bool unload) = 0;
};
@ -61,7 +62,7 @@ public:
bool PlayAudioSector (unsigned long start,unsigned long len);
bool PauseAudio (bool resume);
bool StopAudio (void);
bool ReadSectors (void* buffer, bool raw, unsigned long sector, unsigned long num) { return false; };
bool ReadSectors (PhysPt buffer, bool raw, unsigned long sector, unsigned long num) { return false; };
bool LoadUnloadMedia (bool unload);
private:
@ -86,7 +87,7 @@ public:
bool PlayAudioSector (unsigned long start,unsigned long len) { return true; };
bool PauseAudio (bool resume) { return true; };
bool StopAudio (void) { return true; };
bool ReadSectors (void* buffer, bool raw, unsigned long sector, unsigned long num) { return true; };
bool ReadSectors (PhysPt buffer, bool raw, unsigned long sector, unsigned long num) { return true; };
bool LoadUnloadMedia (bool unload) { return true; };
};
@ -117,7 +118,7 @@ public:
bool PauseAudio (bool resume);
bool StopAudio (void);
bool ReadSectors (void* buffer, bool raw, unsigned long sector, unsigned long num);
bool ReadSectors (PhysPt buffer, bool raw, unsigned long sector, unsigned long num);
bool LoadUnloadMedia (bool unload);
@ -164,7 +165,7 @@ public:
bool PauseAudio (bool resume);
bool StopAudio (void);
bool ReadSectors (void* buffer, bool raw, unsigned long sector, unsigned long num);
bool ReadSectors (PhysPt buffer, bool raw, unsigned long sector, unsigned long num);
bool LoadUnloadMedia (bool unload);

View file

@ -667,7 +667,7 @@ bool CDROM_Interface_Aspi::GetMediaTrayStatus(bool& mediaPresent, bool& mediaCha
return true;
};
bool CDROM_Interface_Aspi::ReadSectors(void* buffer, bool raw, unsigned long sector, unsigned long num)
bool CDROM_Interface_Aspi::ReadSectors(PhysPt buffer, bool raw, unsigned long sector, unsigned long num)
{
SRB_ExecSCSICmd s;DWORD dwStatus;
@ -675,6 +675,9 @@ bool CDROM_Interface_Aspi::ReadSectors(void* buffer, bool raw, unsigned long sec
memset(&s,0,sizeof(s));
Bitu buflen = raw?2352*num:2048*num;
Bit8u* bufdata = new Bit8u[buflen];
s.SRB_Cmd = SC_EXEC_SCSI_CMD;
s.SRB_HaId = haId;
s.SRB_Target = target;
@ -682,8 +685,8 @@ bool CDROM_Interface_Aspi::ReadSectors(void* buffer, bool raw, unsigned long sec
s.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY;
s.SRB_SenseLen = SENSE_LEN;
s.SRB_BufLen = raw?2352*num:2048*num;
s.SRB_BufPointer = (BYTE FAR*)buffer;
s.SRB_BufLen = buflen;
s.SRB_BufPointer = (BYTE FAR*)bufdata;
s.SRB_CDBLen = 12;
s.SRB_PostProc = (LPVOID)hEvent;
@ -705,6 +708,11 @@ bool CDROM_Interface_Aspi::ReadSectors(void* buffer, bool raw, unsigned long sec
CloseHandle(hEvent);
// Copy to PhysPt
MEM_BlockWrite(buffer,bufdata,buflen);
delete[] bufdata;
return (s.SRB_Status==SS_COMP);
};

View file

@ -140,6 +140,10 @@ bool CDROM_Interface_Ioctl::GetMediaTrayStatus(bool& mediaPresent, bool& mediaCh
mediaPresent = GetAudioTracks(track1, track2, leadOut),
trayOpen = !mediaPresent;
mediaChanged = (oldLeadOut.min!=leadOut.min) || (oldLeadOut.sec!=leadOut.sec) || (oldLeadOut.fr!=leadOut.fr);
if (mediaChanged) {
// Open new media
Close(); Open();
};
// Save old values
oldLeadOut.min = leadOut.min;
oldLeadOut.sec = leadOut.sec;
@ -207,17 +211,21 @@ bool CDROM_Interface_Ioctl::LoadUnloadMedia(bool unload)
return bStat>0;
};
bool CDROM_Interface_Ioctl::ReadSectors(void* buffer, bool raw, unsigned long sector, unsigned long num)
bool CDROM_Interface_Ioctl::ReadSectors(PhysPt buffer, bool raw, unsigned long sector, unsigned long num)
{
BOOL bStat;
DWORD byteCount = 0;
// Open();
Bitu buflen = raw ? num*RAW_SECTOR_SIZE : num*COOKED_SECTOR_SIZE;
Bit8u* bufdata = new Bit8u[buflen];
if (!raw) {
// Cooked
int success = 0;
DWORD newPos = SetFilePointer(hIOCTL, sector*COOKED_SECTOR_SIZE, 0, FILE_BEGIN);
if (newPos != 0xFFFFFFFF) success = ReadFile(hIOCTL, buffer, num*COOKED_SECTOR_SIZE, &byteCount, NULL);
if (newPos != 0xFFFFFFFF) success = ReadFile(hIOCTL, bufdata, buflen, &byteCount, NULL);
bStat = (success!=0);
} else {
// Raw
@ -227,9 +235,13 @@ bool CDROM_Interface_Ioctl::ReadSectors(void* buffer, bool raw, unsigned long se
in.SectorCount = num;
in.TrackMode = CDDA;
bStat = DeviceIoControl(hIOCTL,IOCTL_CDROM_RAW_READ, &in, sizeof(in),
buffer, num*RAW_SECTOR_SIZE, &byteCount,NULL);
bufdata, buflen, &byteCount,NULL);
}
// Close();
MEM_BlockWrite(buffer,bufdata,buflen);
delete[] bufdata;
return (byteCount!=num*RAW_SECTOR_SIZE) && (bStat>0);
}

View file

@ -504,8 +504,7 @@ bool CMscdex::GetUPC(Bit8u subUnit, Bit8u& attr, char* upc)
bool CMscdex::ReadSectors(Bit8u subUnit, bool raw, Bit32u sector, Bit16u num, PhysPt data)
{
if (subUnit>=numDrives) return false;
void* buffer = (void*)Phys2Host(data);
dinfo[subUnit].lastResult = cdrom[subUnit]->ReadSectors(buffer,raw,sector,num);
dinfo[subUnit].lastResult = cdrom[subUnit]->ReadSectors(data,raw,sector,num);
return dinfo[subUnit].lastResult;
};