ScummVM API documentation
memory.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef LASTEXPRESS_MEMORY_H
23#define LASTEXPRESS_MEMORY_H
24
25#include "common/scummsys.h"
26
27#include "lastexpress/lastexpress.h"
28
29namespace LastExpress {
30
31class LastExpressEngine;
32
33struct MemPage {
34 void *memPagePtr;
35 uint32 memPageSize;
36 int32 character;
37 char pageName[81];
38 bool allocatedFlag;
39
40 MemPage() {
41 memPagePtr = nullptr;
42 memPageSize = 0;
43 character = 0;
44 memset(pageName, 0, sizeof(pageName));
45 allocatedFlag = false;
46 }
47
48 void copyFrom(MemPage other) {
49 memPagePtr = other.memPagePtr;
50 memPageSize = other.memPageSize;
51 character = other.character;
52 memcpy(pageName, other.pageName, sizeof(pageName));
53 allocatedFlag = other.allocatedFlag;
54 }
55};
56
57enum MemoryFlags {
58 kMemoryFlagInit = 0x1,
59 kMemoryFlagFXFree = 0x2,
60 kMemoryFlagSeqFree = 0x4,
61};
62
64public:
67
68 void initMem();
69 void *allocMem(uint32 size, const char *name, int character);
70 void freeMem(void *data);
71 void releaseMemory();
72 void freeFX();
73 void lockFX();
74 void lockSeqMem(uint32 size);
75 void freeSeqMem();
76 Seq *copySeq(Seq *sequenceToCopy);
77
78private:
79 LastExpressEngine *_engine = nullptr;
80
81 int32 _nisSeqMemFlag = 0;
82 MemPage _memoryPages[128];
83 int _numAllocatedMemPages = 1;
84 int32 _nisSeqMemAvailForLocking = 0;
85};
86
87} // End of namespace LastExpress
88
89#endif // LASTEXPRESS_MEMORY_H
Definition: lastexpress.h:523
Definition: memory.h:63
Definition: archive.h:29
Definition: memory.h:33
Definition: lastexpress.h:212