- variable bUseASPI must be a member of the cdrom object

- report WNASPI32.DLL version (some versions are not working properly)
- new variable isWindowsXP added (for future enhancements)
- PVR address in TOC for image files fixed (SF patch #977900 from Ben Lunt)
- converted tabs to spaces in modified sections
This commit is contained in:
Volker Ruppert 2004-08-22 16:23:35 +00:00
parent 0ae22a3daf
commit 2d695b4d74
2 changed files with 95 additions and 92 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cdrom.cc,v 1.69 2004-06-19 15:20:10 sshwarts Exp $
// $Id: cdrom.cc,v 1.70 2004-08-22 16:23:34 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -177,7 +177,8 @@ BOOL (*TranslateASPI32Address)(PDWORD,PDWORD);
DWORD (*GetASPI32DLLVersion)(void);
static BOOL bUseASPI = FALSE;
static OSVERSIONINFO osinfo;
static BOOL isWindowsXP;
static BOOL bHaveDev;
static UINT cdromCount = 0;
static HINSTANCE hASPI = NULL;
@ -468,11 +469,17 @@ cdrom_interface::cdrom_interface(char *dev)
path = strdup(dev);
}
using_file=0;
#ifdef WIN32
bUseASPI = FALSE;
osinfo.dwOSVersionInfoSize = sizeof(osinfo);
GetVersionEx(&osinfo);
isWindowsXP = (osinfo.dwMajorVersion >= 5) && (osinfo.dwMinorVersion >= 1);
#endif
}
void
cdrom_interface::init(void) {
BX_DEBUG(("Init $Id: cdrom.cc,v 1.69 2004-06-19 15:20:10 sshwarts Exp $"));
BX_DEBUG(("Init $Id: cdrom.cc,v 1.70 2004-08-22 16:23:34 vruppert Exp $"));
BX_INFO(("file = '%s'",path));
}
@ -499,12 +506,9 @@ cdrom_interface::insert_cdrom(char *dev)
BX_INFO (("load cdrom with path=%s", path));
#ifdef WIN32
char drive[256];
OSVERSIONINFO osi;
if ( (path[1] == ':') && (strlen(path) == 2) )
{
osi.dwOSVersionInfoSize = sizeof(osi);
GetVersionEx(&osi);
if(osi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
if(osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
// Use direct device access under windows NT/2k
// With all the backslashes it's hard to see, but to open D: drive
@ -522,7 +526,6 @@ cdrom_interface::insert_cdrom(char *dev)
{
strcpy(drive,path);
using_file = 1;
bUseASPI = FALSE;
BX_INFO (("Opening image file as a cd"));
}
if(bUseASPI) {
@ -533,13 +536,17 @@ cdrom_interface::insert_cdrom(char *dev)
SRB_GDEVBlock sd;
if (!hASPI) {
hASPI = LoadLibrary("WNASPI32.DLL");
}
if(hASPI) {
if (hASPI) {
SendASPI32Command = (DWORD(*)(LPSRB))GetProcAddress( hASPI, "SendASPI32Command" );
GetASPI32DLLVersion = (DWORD(*)(void))GetProcAddress( hASPI, "GetASPI32DLLVersion" );
GetASPI32SupportInfo = (DWORD(*)(void))GetProcAddress( hASPI, "GetASPI32SupportInfo" );
// BX_INFO(("Using first CDROM. Please upgrade your ASPI drivers to version 4.01 or later if you wish to specify a cdrom driver."));
d = GetASPI32DLLVersion();
BX_INFO(("WNASPI32.DLL version %d.%02d initialized", d & 0xff, (d >> 8) & 0xff));
} else {
BX_PANIC(("Could not load ASPI drivers, so cdrom access will fail"));
return false;
}
}
cdr = 0;
bHaveDev = FALSE;
d = GetASPI32SupportInfo();
@ -577,14 +584,9 @@ cdrom_interface::insert_cdrom(char *dev)
}
if(bHaveDev) break;
}
}
} else {
BX_PANIC(("Could not load ASPI drivers, so cdrom access will fail"));
}
fd=1;
} else {
BX_INFO(("Using direct access for CDROM"));
hFile=CreateFile((char *)&drive, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL);
if (hFile !=(void *)0xFFFFFFFF)
fd=1;
@ -760,7 +762,7 @@ cdrom_interface::read_toc(uint8* buf, int* length, bx_bool msf, int start_track)
buf[len++] = 0;
buf[len++] = 0;
buf[len++] = 0;
buf[len++] = 0; // logical sector 0
buf[len++] = 16; // logical sector 0
}
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cdrom.h,v 1.13 2003-08-19 00:37:03 cbothamy Exp $
// $Id: cdrom.h,v 1.14 2004-08-22 16:23:35 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -58,6 +58,7 @@ private:
int using_file;
#ifdef WIN32
BOOL bUseASPI;
HANDLE hFile;
int hid;
int tid;