diff options
author | Bertrand Augereau | 2011-12-04 18:29:34 +0100 |
---|---|---|
committer | Bertrand Augereau | 2011-12-04 18:29:34 +0100 |
commit | a201e1af336ae75f37fcb5216d2166d084bb0d0a (patch) | |
tree | c20f88d6ef10392891dfd4e51cb1b8bacaf3f765 /engines | |
parent | 87ac82db27e10317370b3a7637cf094f4e1492b9 (diff) | |
download | scummvm-rg350-a201e1af336ae75f37fcb5216d2166d084bb0d0a.tar.gz scummvm-rg350-a201e1af336ae75f37fcb5216d2166d084bb0d0a.tar.bz2 scummvm-rg350-a201e1af336ae75f37fcb5216d2166d084bb0d0a.zip |
DREAMWEB: 'standardLoadCPP' to load game data in malloc'ed buffers
Diffstat (limited to 'engines')
-rw-r--r-- | engines/dreamweb/stubs.cpp | 24 | ||||
-rw-r--r-- | engines/dreamweb/stubs.h | 1 |
2 files changed, 14 insertions, 11 deletions
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index f67547c934..efaa62c478 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -760,6 +760,17 @@ uint16 DreamGenContext::standardLoad(const char *fileName, uint16 *outSizeInByte return result; } +void *DreamGenContext::standardLoadCPP(const char *fileName, uint16 *outSizeInBytes) { + uint16 sizeInBytes; + uint16 seg = standardLoad(fileName, &sizeInBytes); + void *buffer = malloc(sizeInBytes); + memcpy(buffer, getSegment(seg).ptr(0, 0), sizeInBytes); + deallocateMem(seg); + if (outSizeInBytes) + *outSizeInBytes = sizeInBytes; + return buffer; +} + void DreamGenContext::standardLoad() { ax = standardLoad((const char *)cs.ptr(dx, 0), NULL); } @@ -2468,18 +2479,9 @@ void DreamGenContext::loadRoomsSample() { void DreamGenContext::readSetData() { data.word(kCharset1) = standardLoad("DREAMWEB.C00"); - uint16 icons1SizeInBytes; - uint16 tempIcons1 = standardLoad("DREAMWEB.G00", &icons1SizeInBytes); - void *icons1Buffer = malloc(icons1SizeInBytes); - memcpy(icons1Buffer, getSegment(tempIcons1).ptr(0, 0), icons1SizeInBytes); - deallocateMem(tempIcons1); + void *icons1Buffer = standardLoadCPP("DREAMWEB.G00"); engine->setIcons1(icons1Buffer); - - uint16 icons2SizeInBytes; - uint16 tempIcons2 = standardLoad("DREAMWEB.G01", &icons2SizeInBytes); - void *icons2Buffer = malloc(icons2SizeInBytes); - memcpy(icons2Buffer, getSegment(tempIcons2).ptr(0, 0), icons2SizeInBytes); - deallocateMem(tempIcons2); + void *icons2Buffer = standardLoadCPP("DREAMWEB.G01"); engine->setIcons2(icons2Buffer); data.word(kMainsprites) = standardLoad("DREAMWEB.S00"); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 83e375d625..dc777811bf 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -33,6 +33,7 @@ void clearWork(); void standardLoad(); uint16 standardLoad(const char *fileName, uint16 *outSizeInBytes = NULL); // Returns a segment handle which needs to be freed with deallocatemem for symmetry + void *standardLoadCPP(const char *fileName, uint16 *outSizeInBytes = NULL); // And this one should be 'free'd void loadIntoTemp(); void loadIntoTemp2(); void loadIntoTemp3(); |