19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Lesser General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2.1 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Lesser General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Lesser General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free Software 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@libsdl.org 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h" 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef SDL_CDROM_OS2 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Functions for system-level CD-ROM audio control */ 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define INCL_MCIOS2 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <os2.h> 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <os2me.h> 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_cdrom.h" 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_syscdrom.h" 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Size of MCI result buffer (in bytes) */ 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define MCI_CMDRETBUFSIZE 128 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* The maximum number of CD-ROM drives we'll detect */ 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define MAX_DRIVES 16 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* A list of available CD-ROM drives */ 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic char *SDL_cdlist[MAX_DRIVES]; 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall//static dev_t SDL_cdmode[MAX_DRIVES]; 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* The system-dependent CD control functions */ 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic const char *SDL_SYS_CDName(int drive); 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDOpen(int drive); 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDGetTOC(SDL_CD *cdrom); 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position); 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length); 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDPause(SDL_CD *cdrom); 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDResume(SDL_CD *cdrom); 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDStop(SDL_CD *cdrom); 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDEject(SDL_CD *cdrom); 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void SDL_SYS_CDClose(SDL_CD *cdrom); 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* MCI Timing Functions */ 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define MCI_MMTIMEPERSECOND 3000 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define FRAMESFROMMM(mmtime) (((mmtime)*CD_FPS)/MCI_MMTIMEPERSECOND) 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Ready for MCI CDAudio Devices */ 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint SDL_SYS_CDInit(void) 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint i; /* generig counter */ 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_SYSINFO_PARMS msp; /* Structure to MCI SysInfo parameters */ 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallCHAR SysInfoRet[MCI_CMDRETBUFSIZE]; /* Buffer for MCI Command result */ 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Fill in our driver capabilities */ 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_CDcaps.Name = SDL_SYS_CDName; 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_CDcaps.Open = SDL_SYS_CDOpen; 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_CDcaps.Status = SDL_SYS_CDStatus; 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_CDcaps.Play = SDL_SYS_CDPlay; 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_CDcaps.Pause = SDL_SYS_CDPause; 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_CDcaps.Resume = SDL_SYS_CDResume; 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_CDcaps.Stop = SDL_SYS_CDStop; 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_CDcaps.Eject = SDL_SYS_CDEject; 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_CDcaps.Close = SDL_SYS_CDClose; 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Get the number of CD ROMs in the System */ 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Clean SysInfo structure */ 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_memset(&msp, 0x00, sizeof(MCI_SYSINFO_PARMS)); 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Prepare structure to Ask Numer of Audio CDs */ 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.pszReturn = (PSZ)&SysInfoRet; /* Return Structure */ 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulRetSize = MCI_CMDRETBUFSIZE; /* Size of ret struct */ 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_QUANTITY | MCI_WAIT, (PVOID)&msp, 0)) != MCIERR_SUCCESS) return(CD_ERROR); 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_numcds = atoi(SysInfoRet); 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (SDL_numcds > MAX_DRIVES) SDL_numcds = MAX_DRIVES; /* Limit maximum CD number */ 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Get and Add their system name to the SDL_cdlist */ 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.pszReturn = (PSZ)&SysInfoRet; /* Return Structure */ 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulRetSize = MCI_CMDRETBUFSIZE; /* Size of ret struct */ 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallfor (i=0; i<SDL_numcds; i++) 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall msp.ulNumber = i+1; 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mciSendCommand(0,MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT,&msp, 0); 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_cdlist[i] = SDL_strdup(SysInfoRet); 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_cdlist[i] == NULL ) 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory(); 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(-1); 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallreturn(0); 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Return CDAudio System Dependent Device Name - Ready for MCI*/ 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic const char *SDL_SYS_CDName(int drive) 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallreturn(SDL_cdlist[drive]); 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Open CDAudio Device - Ready for MCI */ 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDOpen(int drive) 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_OPEN_PARMS mop; 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_SET_PARMS msp; 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_GENERIC_PARMS mgp; 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Open the device */ 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmop.hwndCallback = (HWND)NULL; // None 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmop.usDeviceID = (USHORT)NULL; // Will be returned. 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmop.pszDeviceType = (PSZ)SDL_cdlist[drive]; // CDAudio Device 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(0,MCI_OPEN,MCI_WAIT,&mop, 0)) != MCIERR_SUCCESS) return(CD_ERROR); 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Set time format */ 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.hwndCallback = (HWND)NULL; // None 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulTimeFormat = MCI_FORMAT_MSF; // Minute : Second : Frame structure 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulSpeedFormat = (ULONG)NULL; // No change 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulAudio = (ULONG)NULL; // No Channel 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulLevel = (ULONG)NULL; // No Volume 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulOver = (ULONG)NULL; // No Delay 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulItem = (ULONG)NULL; // No item 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulValue = (ULONG)NULL; // No value for item flag 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(mop.usDeviceID,MCI_SET,MCI_WAIT | MCI_SET_TIME_FORMAT,&msp, 0)) == MCIERR_SUCCESS) return (mop.usDeviceID); 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Error setting time format? - Close opened device */ 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmgp.hwndCallback = (HWND)NULL; // None 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallmciSendCommand(mop.usDeviceID,MCI_CLOSE,MCI_WAIT,&mgp, 0); 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallreturn(CD_ERROR); 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Get CD Table Of Contents - Ready for MCI */ 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDGetTOC(SDL_CD *cdrom) 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_TOC_PARMS mtp; 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_STATUS_PARMS msp; 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_TOC_REC * mtr; 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallINT i; 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Correction because MCI cannot read TOC while CD is playing (it'll stop!) */ 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (cdrom->status == CD_PLAYING || cdrom->status == CD_PAUSED) return 0; 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Get Number of Tracks */ 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.hwndCallback = (HWND)NULL; /* None */ 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulReturn = (ULONG)NULL; /* We want this information */ 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulItem = MCI_STATUS_NUMBER_OF_TRACKS; 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulValue = (ULONG)NULL; /* No additional information */ 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) return(CD_ERROR); 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallcdrom->numtracks = msp.ulReturn; 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif ( cdrom->numtracks > SDL_MAX_TRACKS ) 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall cdrom->numtracks = SDL_MAX_TRACKS; 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Alocate space for TOC data */ 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmtr = (MCI_TOC_REC *)SDL_malloc(cdrom->numtracks*sizeof(MCI_TOC_REC)); 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif ( mtr == NULL ) 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory(); 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(-1); 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Get TOC from CD */ 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmtp.pBuf = mtr; 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmtp.ulBufSize = cdrom->numtracks*sizeof(MCI_TOC_REC); 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(cdrom->id,MCI_GETTOC,MCI_WAIT,&mtp, 0)) != MCIERR_SUCCESS) 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory(); 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(mtr); 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(CD_ERROR); 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Fill SDL Tracks Structure */ 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallfor (i=0; i<cdrom->numtracks; i++) 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set Track ID */ 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall cdrom->track[i].id = (mtr+i)->TrackNum; 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set Track Type */ 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall msp.hwndCallback = (HWND)NULL; /* None */ 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall msp.ulReturn = (ULONG)NULL; /* We want this information */ 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall msp.ulItem = MCI_CD_STATUS_TRACK_TYPE; 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall msp.ulValue = (ULONG)((mtr+i)->TrackNum); /* Track Number? */ 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_TRACK | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(mtr); 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return (CD_ERROR); 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (msp.ulReturn==MCI_CD_TRACK_AUDIO) cdrom->track[i].type = SDL_AUDIO_TRACK; 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else cdrom->track[i].type = SDL_DATA_TRACK; 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set Track Length - values from MCI are in MMTIMEs - 3000 MMTIME = 1 second */ 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall cdrom->track[i].length = FRAMESFROMMM((mtr+i)->ulEndAddr - (mtr+i)->ulStartAddr); 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set Track Offset */ 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall cdrom->track[i].offset = FRAMESFROMMM((mtr+i)->ulStartAddr); 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_free(mtr); 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallreturn(0); 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Get CD-ROM status - Ready for MCI */ 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position) 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallCDstatus status; 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_STATUS_PARMS msp; 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Get Status from MCI */ 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.hwndCallback = (HWND)NULL; /* None */ 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulReturn = (ULONG)NULL; /* We want this information */ 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulItem = MCI_STATUS_MODE; 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulValue = (ULONG)NULL; /* No additional information */ 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) status = CD_ERROR; 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallelse 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch(msp.ulReturn) 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case MCI_MODE_NOT_READY: 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall status = CD_TRAYEMPTY; 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case MCI_MODE_PAUSE: 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall status = CD_PAUSED; 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case MCI_MODE_PLAY: 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall status = CD_PLAYING; 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case MCI_MODE_STOP: 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall status = CD_STOPPED; 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* These cases should not occour */ 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case MCI_MODE_RECORD: 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case MCI_MODE_SEEK: 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default: 2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall status = CD_ERROR; 2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Determine position */ 2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (position != NULL) /* The SDL $&$&%# CDROM call sends NULL pointer here! */ 2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((status == CD_PLAYING) || (status == CD_PAUSED)) 2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Get Position */ 2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall msp.hwndCallback = (HWND)NULL; /* None */ 2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall msp.ulReturn = (ULONG)NULL; /* We want this information */ 2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall msp.ulItem = MCI_STATUS_POSITION; 2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall msp.ulValue = (ULONG)NULL; /* No additiona info */ 2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) != MCIERR_SUCCESS) return (CD_ERROR); 2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Convert from MSF (format selected in the Open process) to Frames (format that will be returned) */ 2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall *position = MSF_TO_FRAMES(MSF_MINUTE(msp.ulReturn),MSF_SECOND(msp.ulReturn),MSF_FRAME(msp.ulReturn)); 2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else *position = 0; 2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallreturn(status); 2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Start play - Ready for MCI */ 2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) 2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_GENERIC_PARMS mgp; 2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_STATUS_PARMS msp; 2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_PLAY_PARMS mpp; 2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallULONG min,sec,frm; 2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Start MSF */ 2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallFRAMES_TO_MSF(start, &min, &sec, &frm); 2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMSF_MINUTE(mpp.ulFrom) = min; 2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMSF_SECOND(mpp.ulFrom) = sec; 2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMSF_FRAME(mpp.ulFrom) = frm; 2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* End MSF */ 2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallFRAMES_TO_MSF(start+length, &min, &sec, &frm); 2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMSF_MINUTE(mpp.ulTo) = min; 2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMSF_SECOND(mpp.ulTo) = sec; 2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMSF_FRAME(mpp.ulTo) = frm; 2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef DEBUG_CDROM 2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", 2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0, 2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1); 2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Verifies if it is paused first... and if it is, unpause before stopping it. */ 2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.hwndCallback = (HWND)NULL; /* None */ 2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulReturn = (ULONG)NULL; /* We want this information */ 2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulItem = MCI_STATUS_MODE; 2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulValue = (ULONG)NULL; /* No additional information */ 2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) == MCIERR_SUCCESS) 2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (msp.ulReturn == MCI_MODE_PAUSE) 2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mgp.hwndCallback = (HWND)NULL; // None 2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mciSendCommand(cdrom->id,MCI_RESUME,0,&mgp, 0); 2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Now play it. */ 3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmpp.hwndCallback = (HWND)NULL; // We do not want the info. temp 3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(cdrom->id,MCI_PLAY,MCI_FROM | MCI_TO,&mpp, 0)) == MCIERR_SUCCESS) return 0; 3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallreturn (CD_ERROR); 3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Pause play - Ready for MCI */ 3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDPause(SDL_CD *cdrom) 3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_GENERIC_PARMS mgp; 3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmgp.hwndCallback = (HWND)NULL; // None 3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(cdrom->id,MCI_PAUSE,MCI_WAIT,&mgp, 0)) == MCIERR_SUCCESS) return 0; 3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallreturn(CD_ERROR); 3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Resume play - Ready for MCI */ 3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDResume(SDL_CD *cdrom) 3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_GENERIC_PARMS mgp; 3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmgp.hwndCallback = (HWND)NULL; // None 3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(cdrom->id,MCI_RESUME,MCI_WAIT,&mgp, 0)) == MCIERR_SUCCESS) return 0; 3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallreturn(CD_ERROR); 3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Stop play - Ready for MCI */ 3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDStop(SDL_CD *cdrom) 3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_GENERIC_PARMS mgp; 3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_STATUS_PARMS msp; 3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Verifies if it is paused first... and if it is, unpause before stopping it. */ 3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.hwndCallback = (HWND)NULL; /* None */ 3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulReturn = (ULONG)NULL; /* We want this information */ 3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulItem = MCI_STATUS_MODE; 3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulValue = (ULONG)NULL; /* No additional information */ 3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) == MCIERR_SUCCESS) 3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (msp.ulReturn == MCI_MODE_PAUSE) 3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mgp.hwndCallback = (HWND)NULL; // None 3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mciSendCommand(cdrom->id,MCI_RESUME,0,&mgp, 0); 3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Now stops the media */ 3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmgp.hwndCallback = (HWND)NULL; // None 3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(cdrom->id,MCI_STOP,MCI_WAIT,&mgp, 0)) == MCIERR_SUCCESS) return 0; 3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallreturn(CD_ERROR); 3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Eject the CD-ROM - Ready for MCI */ 3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int SDL_SYS_CDEject(SDL_CD *cdrom) 3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_SET_PARMS msp; 3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.hwndCallback = (HWND)NULL; // None 3589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulTimeFormat = (ULONG)NULL; // No change 3599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulSpeedFormat = (ULONG)NULL; // No change 3609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulAudio = (ULONG)NULL; // No Channel 3619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulLevel = (ULONG)NULL; // No Volume 3629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulOver = (ULONG)NULL; // No Delay 3639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulItem = (ULONG)NULL; // No item 3649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmsp.ulValue = (ULONG)NULL; // No value for item flag 3659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif (LOUSHORT(mciSendCommand(cdrom->id,MCI_SET,MCI_WAIT | MCI_SET_DOOR_OPEN,&msp, 0)) == MCIERR_SUCCESS) return 0; 3669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallreturn(CD_ERROR); 3679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Close the CD-ROM handle - Ready for MCI */ 3709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void SDL_SYS_CDClose(SDL_CD *cdrom) 3719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallMCI_GENERIC_PARMS mgp; 3739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallmgp.hwndCallback = (HWND)NULL; // None 3759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallmciSendCommand(cdrom->id,MCI_CLOSE,MCI_WAIT,&mgp, 0); 3769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Finalize CDROM Subsystem - Ready for MCI */ 3799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_SYS_CDQuit(void) 3809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint i; 3829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallif ( SDL_numcds > 0 ) 3849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; i<SDL_numcds; ++i ) 3869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(SDL_cdlist[i]); 3889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_numcds = 0; 3909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* SDL_CDROM_OS2 */ 394