aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2014-12-14 22:23:02 +0100
committerEugene Sandulenko2015-12-15 00:05:02 +0100
commitdfa0a1ef0b23e0343ddf98c545cdae2a51d85c77 (patch)
tree8696ea518d62976e1ea21640005fc0cc2f373951 /engines
parentbbddd32d38a03544ddab6e36e6853ddc128d0254 (diff)
downloadscummvm-rg350-dfa0a1ef0b23e0343ddf98c545cdae2a51d85c77.tar.gz
scummvm-rg350-dfa0a1ef0b23e0343ddf98c545cdae2a51d85c77.tar.bz2
scummvm-rg350-dfa0a1ef0b23e0343ddf98c545cdae2a51d85c77.zip
LAB: Implement openFile(), first gfx output!
Diffstat (limited to 'engines')
-rw-r--r--engines/lab/labfile.cpp89
1 files changed, 12 insertions, 77 deletions
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 90db66fcbb..adef2f07d4 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -222,97 +222,32 @@ bool allocFile(void **Ptr, uint32 Size, const char *fileName) {
/* Reads a file into memory. */
/*****************************************************************************/
byte **openFile(const char *name) {
- warning("STUB: openFile");
+ byte *buf;
- return NULL;
-#if 0
- char *tempbuffer, *Buffer;
- int32 Size, Left;
- int FPtr, ReadSize, myread;
-
- ReadSoFar = 0L;
- ReadIsError = false;
- ReadIsDone = false;
-
- if ((buffer == NULL) || (name == NULL)) {
- ReadIsError = true;
- ReadIsDone = true;
- return NULL;
- }
+ Common::File file;
- Size = sizeOfFile(name);
+ file.open(translateFileName(name));
+ if (!file.isOpen()) {
+ warning("Cannot open file %s", translateFileName(name));
- if (!Size || (Size > ((int32) buffersize))) {
ReadIsError = true;
ReadIsDone = true;
return NULL;
}
- if (allocFile((void **) &Buffer, Size, name)) { /* Get place in Buffer */
- *startoffile = Buffer; /* If the file is buffered */
+ uint32 size = file.size();
- ReadSoFar = Size;
- ReadIsError = false;
- ReadIsDone = true;
+ buf = (byte *)malloc(size);
- return startoffile;
+ if (!buf) {
+ error("Unable to allocate %d bytes file file %s", size, name);
}
-#if defined(WIN32)
-#if defined(DEMODATA)
- {
- FILE *fh = fopen("c:\\depot\\labyrinth\\demodata.log", "a+w");
- fprintf(fh, "%s\n", name);
- fclose(fh);
- }
-#endif
-
- FPtr = open(translateFileName(name), O_RDONLY | O_BINARY);
-#else
- FPtr = open(translateFileName(name), O_RDONLY);
-#endif
-
- if (FPtr != -1) {
- Left = Size;
- tempbuffer = Buffer;
- *startoffile = Buffer;
-
- while (Left) {
- fileCheckMusic(Left);
-
- if (Left > MAXREADSIZE)
- ReadSize = MAXREADSIZE;
- else
- ReadSize = (int) Left;
-
- if (!(myread = read(FPtr, tempbuffer, ReadSize + DMABUGSIZE))) {
- ReadIsError = false;
- ReadIsDone = true;
-
- close(FPtr);
- return NULL;
- }
+ *startoffile = buf;
- /* Not necessary for IBM version
- if ((ReadSize == MAXREADSIZE) && DMABUGSIZE)
- Seek(FPtr, -DMABUGSIZE, (int32) OFFSET_CURRENT);
- */
+ file.read(buf, size);
- ReadSoFar += ReadSize;
- tempbuffer += ReadSize;
- Left -= ReadSize;
- }
-
- ReadIsDone = true;
- close(FPtr);
- return startoffile;
- } else {
- ReadIsError = false;
- ReadIsDone = true;
-
- return NULL;
- }
-#endif
+ return startoffile;
}