From: <ric...@us...> - 2011-05-15 15:33:17
|
Revision: 4005 http://desmume.svn.sourceforge.net/desmume/?rev=4005&view=rev Author: riccardom Date: 2011-05-15 15:33:10 +0000 (Sun, 15 May 2011) Log Message: ----------- NDS_LoadRom: Use gameInfo.romdata to store the rom for !WINDOWS This makes NDS_FreeROM() works properly and avoid to allocate the buffer for the ROM data twice. Thanks to Jan B?\195?\188cken for reporting the issue. Modified Paths: -------------- trunk/desmume/src/NDSSystem.cpp Modified: trunk/desmume/src/NDSSystem.cpp =================================================================== --- trunk/desmume/src/NDSSystem.cpp 2011-05-15 14:35:11 UTC (rev 4004) +++ trunk/desmume/src/NDSSystem.cpp 2011-05-15 15:33:10 UTC (rev 4005) @@ -543,7 +543,6 @@ ROMReader_struct *reader; void *file; u32 size; - u8 *data; char *noext; char buf[MAX_PATH]; @@ -593,21 +592,13 @@ if(MMU.CART_ROM != MMU.UNUSED_RAM) NDS_FreeROM(); - data = new u8[gameInfo.mask + 1]; - if (!data) - { - reader->DeInit(file); - free(noext); - return -1; - } - - ret = reader->Read(file, data, size); + ret = reader->Read(file, gameInfo.romdata, size); reader->DeInit(file); //decrypt if necessary.. //but this is untested and suspected to fail on big endian, so lets not support this on big endian #ifndef WORDS_BIGENDIAN - bool okRom = DecryptSecureArea(data,size); + bool okRom = DecryptSecureArea((u8 *)gameInfo.romdata, gameInfo.romsize); if(!okRom) { printf("Specified file is not a valid rom\n"); @@ -619,10 +610,10 @@ if (cheatSearch) cheatSearch->close(); MMU_unsetRom(); - NDS_SetROM(data, gameInfo.mask); + NDS_SetROM((u8*)gameInfo.romdata, gameInfo.mask); gameInfo.populate(); - gameInfo.crc = crc32(0,data,size); + gameInfo.crc = crc32(0,(u8*)gameInfo.romdata,gameInfo.romsize); INFO("\nROM crc: %08X\n", gameInfo.crc); INFO("ROM serial: %s\n", gameInfo.ROMserial); INFO("ROM internal name: %s\n\n", gameInfo.ROMname); @@ -630,7 +621,7 @@ //for homebrew, try auto-patching DLDI. should be benign if there is no DLDI or if it fails if(!memcmp(gameInfo.header.gameCode,"####",4)) - DLDI::tryPatch((void*)data, gameInfo.mask + 1); + DLDI::tryPatch((void*)gameInfo.romdata, gameInfo.mask + 1); NDS_Reset(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |