ScummVM API documentation
misc.h
1
2/* ScummVM - Graphic Adventure Engine
3 *
4 * ScummVM is the legal property of its developers, whose names
5 * are too numerous to list here. Please refer to the COPYRIGHT
6 * file distributed with this source distribution.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef BAGEL_BOFLIB_MISC_H
24#define BAGEL_BOFLIB_MISC_H
25
26#include "bagel/boflib/stdinc.h"
27
28namespace Bagel {
29
30extern int mapWindowsPointSize(int pointSize);
31
35extern void timerStart();
36
41extern uint32 timerStop();
42
46extern uint32 getTimer();
47
52extern void bofSleep(uint32 milli);
53
54extern Fixed fixedDivide(Fixed Dividend, Fixed Divisor);
55extern Fixed fixedMultiply(Fixed Multiplicand, Fixed Multiplier);
56
57#define intToFixed(i) (Fixed)(((long)(i)) << 16)
58#define fixedToInt(f) (int)(((long)(f)) >> 16)
59
61//
62// Memory allocation routines (Should be put into their own MEMORY module)
63//
65
66
75extern void *bofMemAlloc(uint32 nSize, const char *pFile, int nLine, bool bClear);
76
81extern void bofMemFree(void *pBuf);
82
83#define bofAlloc(n) bofMemAlloc((n), __FILE__, __LINE__, false)
84#define bofCleanAlloc(n) bofMemAlloc((n), __FILE__, __LINE__, true)
85#define bofFree(p) bofMemFree((p))
86
87inline uint32 getFreePhysMem() {
88 return 999999;
89}
90
97void encrypt(void *pBuf, int32 lSize, const char *pszPassword = nullptr);
98#define decrypt encrypt
99#define Decrypt encrypt
100
101extern void encryptPartial(void *, int32, int32, const char *pPassword = nullptr);
102#define decryptPartial encryptPartial
103
109extern bool ProbableTrue(int nProbability);
110
111extern void ErrorLog(const char *logFile, const char *format, ...);
112
113extern int StrFreqMatch(const char *, const char *);
114extern bool StrCompare(const char *, const char *, unsigned int);
115extern int StrCharCount(const char *, char);
116extern char *StriStr(char *, const char *);
117extern void StrUprStr(char *, const char *);
118extern void StrCpyStripChar(char *, const char *, char);
119extern char *StrStripChar(char *, char);
120extern char *StrReplaceChar(char *, char, char);
121
122} // namespace Bagel
123
124#endif