aboutsummaryrefslogtreecommitdiff
path: root/engines/lab/storage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/lab/storage.cpp')
-rw-r--r--engines/lab/storage.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/engines/lab/storage.cpp b/engines/lab/storage.cpp
new file mode 100644
index 0000000000..0d21b937c9
--- /dev/null
+++ b/engines/lab/storage.cpp
@@ -0,0 +1,89 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+
+namespace Lab {
+
+/*****************************************************************************/
+/* Allocates a chunk of memory. */
+/*****************************************************************************/
+bool allocate(void **Ptr, uint32 Size) {
+ (*Ptr) = malloc(Size);
+
+ if (*Ptr)
+ memset(*Ptr, 0, (size_t) Size);
+
+ return (*Ptr != NULL);
+}
+
+
+
+
+/*****************************************************************************/
+/* Allocates a piece of chip memory. */
+/*****************************************************************************/
+bool allocatechip(void **Ptr, uint32 Size) {
+ return allocate(Ptr, Size);
+}
+
+/*****************************************************************************/
+/* Allocates a chunk of dos memory. */
+/*****************************************************************************/
+bool allocatedos(void **Ptr, uint32 Size) {
+#if defined(DOSCODE)
+ static union REGS regs;
+
+ regs.x.eax = 0x100;
+ regs.x.ebx = (Size >> 4);
+ int386(0x31, &regs, &regs);
+
+ if (regs.x.cflag) {
+ *Ptr = NULL;
+ return false;
+ }
+
+ *Ptr = (char *)((regs.x.eax & 0xFFFF) << 4);
+ return (*Ptr != NULL);
+#else
+ *Ptr = malloc(Size);
+ return (*Ptr != NULL);
+#endif
+}
+
+/*****************************************************************************/
+/* Deallocates a piece of memory. */
+/*****************************************************************************/
+void deallocate(void *Ptr, uint32 Size) {
+ if (Ptr)
+ free(Ptr);
+}
+
+} // End of namespace Lab