diff --git a/src/dos/dos_mscdex.cpp b/src/dos/dos_mscdex.cpp index 2fa767d3..aac4c803 100644 --- a/src/dos/dos_mscdex.cpp +++ b/src/dos/dos_mscdex.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2007 The DOSBox Team + * Copyright (C) 2002-2008 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_mscdex.cpp,v 1.51 2007-12-30 08:21:35 qbix79 Exp $ */ +/* $Id: dos_mscdex.cpp,v 1.52 2008-02-06 21:56:32 c2woody Exp $ */ #include #include @@ -138,6 +138,7 @@ public: private: PhysPt GetDefaultBuffer (void); + PhysPt GetTempBuffer (void); Bit16u numDrives; @@ -161,8 +162,7 @@ public: Bit16u rootDriverHeaderSeg; }; -CMscdex::CMscdex(void) -{ +CMscdex::CMscdex(void) { numDrives = 0; rootDriverHeaderSeg = 0; defaultBufSeg = 0; @@ -171,12 +171,12 @@ CMscdex::CMscdex(void) for (Bit32u i=0; i=numDrives) return false; Bit16u drive = dinfo[subUnit].drive; - Bit16u error,seg,size = 128; + Bit16u error; bool success = false; - if (DOS_AllocateMemory(&seg,&size)) { - PhysPt ptoc = PhysMake(seg,0); - success = ReadVTOC(drive,0x00,ptoc,error); - if (success) { - MEM_StrCopy(ptoc+40,data,31); - data[31] = 0; - rtrim(data); - }; - DOS_FreeMemory(seg); - } else { LOG(LOG_MISC,LOG_ERROR)("MSCDEX buffer allocation failed."); }; + PhysPt ptoc = GetTempBuffer(); + success = ReadVTOC(drive,0x00,ptoc,error); + if (success) { + MEM_StrCopy(ptoc+40,data,31); + data[31] = 0; + rtrim(data); + }; + return success; }; -bool CMscdex::GetCopyrightName(Bit16u drive, PhysPt data) -{ - Bit16u error,seg,size = 128; +bool CMscdex::GetCopyrightName(Bit16u drive, PhysPt data) { + Bit16u error; bool success = false; - if (DOS_AllocateMemory(&seg,&size)) { - PhysPt ptoc = PhysMake(seg,0); - success = ReadVTOC(drive,0x00,ptoc,error); - if (success) { - MEM_BlockCopy(data,ptoc+702,37); - mem_writeb(data+37,0); - }; - DOS_FreeMemory(seg); - } else { LOG(LOG_MISC,LOG_ERROR)("MSCDEX buffer allocation failed."); }; + PhysPt ptoc = GetTempBuffer(); + success = ReadVTOC(drive,0x00,ptoc,error); + if (success) { + MEM_BlockCopy(data,ptoc+702,37); + mem_writeb(data+37,0); + }; return success; }; -bool CMscdex::GetAbstractName(Bit16u drive, PhysPt data) -{ - Bit16u error,seg,size = 128; +bool CMscdex::GetAbstractName(Bit16u drive, PhysPt data) { + Bit16u error; bool success = false; - if (DOS_AllocateMemory(&seg,&size)) { - PhysPt ptoc = PhysMake(seg,0); - success = ReadVTOC(drive,0x00,ptoc,error); - if (success) { - MEM_BlockCopy(data,ptoc+739,37); - mem_writeb(data+37,0); - }; - DOS_FreeMemory(seg); - } else { LOG(LOG_MISC,LOG_ERROR)("MSCDEX buffer allocation failed."); }; + PhysPt ptoc = GetTempBuffer(); + success = ReadVTOC(drive,0x00,ptoc,error); + if (success) { + MEM_BlockCopy(data,ptoc+739,37); + mem_writeb(data+37,0); + }; return success; }; -bool CMscdex::GetDocumentationName(Bit16u drive, PhysPt data) -{ - Bit16u error,seg,size = 128; +bool CMscdex::GetDocumentationName(Bit16u drive, PhysPt data) { + Bit16u error; bool success = false; - if (DOS_AllocateMemory(&seg,&size)) { - PhysPt ptoc = PhysMake(seg,0); - success = ReadVTOC(drive,0x00,ptoc,error); - if (success) { - MEM_BlockCopy(data,ptoc+776,37); - mem_writeb(data+37,0); - }; - DOS_FreeMemory(seg); - } else { LOG(LOG_MISC,LOG_ERROR)("MSCDEX buffer allocation failed."); }; + PhysPt ptoc = GetTempBuffer(); + success = ReadVTOC(drive,0x00,ptoc,error); + if (success) { + MEM_BlockCopy(data,ptoc+776,37); + mem_writeb(data+37,0); + }; return success; };