aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/dc/selector.cpp1
-rw-r--r--backends/dc/vmsave.cpp4
-rw-r--r--common/config-file.cpp13
-rw-r--r--common/engine.h12
-rw-r--r--common/file.cpp44
-rw-r--r--common/gameDetector.cpp9
-rw-r--r--common/gameDetector.h2
-rw-r--r--common/main.cpp4
-rw-r--r--common/rect.h (renamed from scumm/smush/rect.h)10
-rw-r--r--scumm/scumm.h23
-rw-r--r--scumm/scummvm.cpp6
-rw-r--r--scumm/smush/blitter.h5
-rw-r--r--scumm/smush/brenderer.cpp2
-rw-r--r--scumm/smush/channel.h1
-rw-r--r--scumm/smush/chunk.cpp2
-rw-r--r--scumm/smush/codec37.cpp2
-rw-r--r--scumm/smush/config.h2
-rw-r--r--scumm/smush/decoder.h4
-rw-r--r--scumm/smush/frenderer.cpp2
-rw-r--r--scumm/smush/frenderer.h2
-rw-r--r--scumm/smush/player.cpp3
-rw-r--r--scumm/smush/player.h2
-rw-r--r--scumm/smush/renderer.h4
-rw-r--r--scumm/smush/saud_channel.cpp1
-rw-r--r--scumm/smush/scumm_renderer.cpp1
-rw-r--r--scumm/string.cpp4
-rw-r--r--scumm/sys.cpp6
-rw-r--r--simon/simon.h3
28 files changed, 94 insertions, 80 deletions
diff --git a/backends/dc/selector.cpp b/backends/dc/selector.cpp
index 22cba5bbfc..0d643dd812 100644
--- a/backends/dc/selector.cpp
+++ b/backends/dc/selector.cpp
@@ -167,7 +167,6 @@ static void checkName(GameDetector *d, Game &game)
if(d->detectGame()) {
char *n = d->getGameName();
strcpy(game.text, n);
- free(n);
} else
strcpy(game.text, game.filename_base);
d->_exe_name = NULL;
diff --git a/backends/dc/vmsave.cpp b/backends/dc/vmsave.cpp
index 34bf2e40fa..ef3999ddb9 100644
--- a/backends/dc/vmsave.cpp
+++ b/backends/dc/vmsave.cpp
@@ -69,9 +69,7 @@ static vmsaveResult trySave(GameDetector *d, const char *data, int size,
memset(&header, 0, sizeof(header));
strncpy(header.shortdesc, "ScummVM savegame", 16);
- char *game_name = d->getGameName();
- strncpy(header.longdesc, game_name, 32);
- free(game_name);
+ strncpy(header.longdesc, d->getGameName(), 32);
strncpy(header.id, "ScummVM", 16);
icon.create_vmicon(iconbuffer);
header.numicons = 1;
diff --git a/common/config-file.cpp b/common/config-file.cpp
index b56630f5c5..17b9fb2b4f 100644
--- a/common/config-file.cpp
+++ b/common/config-file.cpp
@@ -30,6 +30,19 @@
#define xfree(p) {if (p) free(p);}
+#ifdef NEED_STRDUP
+char *strdup(const char *s) {
+ if (s) {
+ int len = strlen(s) + 1;
+ char *d = (char *)malloc(len);
+ if (d)
+ memcpy(d, s, len);
+ return d;
+ }
+ return NULL;
+}
+#endif /* NEED_STRDUP */
+
static char *ltrim(char *t)
{
diff --git a/common/engine.h b/common/engine.h
index 6241d70a7f..8ca47dd17e 100644
--- a/common/engine.h
+++ b/common/engine.h
@@ -56,5 +56,17 @@ public:
static Engine *createFromDetector(GameDetector *detector, OSystem *syst);
};
+#if defined(__GNUC__)
+void CDECL error(const char *s, ...) NORETURN;
+#else
+void CDECL NORETURN error(const char *s, ...);
+#endif
+
+void CDECL warning(const char *s, ...);
+
+void CDECL debug(int level, const char *s, ...);
+void checkHeap();
+
#endif
+
diff --git a/common/file.cpp b/common/file.cpp
index a5c1608210..faa09dde1e 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -21,19 +21,6 @@
#include "file.h"
-#ifdef NEED_STRDUP
-char *strdup(const char *s) {
- if (s) {
- int len = strlen(s) + 1;
- char *d = (char *)malloc(len);
- if (d)
- memcpy(d, s, len);
- return d;
- }
- return NULL;
-}
-#endif /* NEED_STRDUP */
-
File::File() {
_handle = NULL;
_readFailed = false;
@@ -45,28 +32,35 @@ File::~File() {
}
bool File::open(const char *filename, int mode, byte encbyte) {
- char * buf;
+ char buf[256], *ptr;
if (_handle) {
debug(2, "File %s already opened", filename);
return false;
}
clearReadFailed();
- buf = strdup(filename);
+ strcpy(buf, filename);
if (mode == 1) {
_handle = fopen(buf, "rb");
if (_handle == NULL) {
- _handle = fopen(strupr(buf), "rb");
- if (_handle == NULL) {
- _handle = fopen(strlwr(buf), "rb");
- }
- else {
- debug(2, "File %s not found", filename);
- return false;
- }
+ ptr = buf;
+ do
+ *ptr++ = toupper(*ptr);
+ while (*ptr);
+ _handle = fopen(buf, "rb");
}
- }
- else {
+ if (_handle == NULL) {
+ ptr = buf;
+ do
+ *ptr++ = tolower(*ptr);
+ while (*ptr);
+ _handle = fopen(buf, "rb");
+ }
+ if (_handle == NULL) {
+ debug(2, "File %s not found", filename);
+ return false;
+ }
+ } else {
warning("Only read mode supported!");
return false;
}
diff --git a/common/gameDetector.cpp b/common/gameDetector.cpp
index 581767c58d..237dbf663f 100644
--- a/common/gameDetector.cpp
+++ b/common/gameDetector.cpp
@@ -29,6 +29,9 @@
#include "common/config-file.h"
+extern uint16 _debugLevel;
+
+
#define CHECK_OPTION() if ((current_option != NULL) || (*s != '\0')) goto ShowHelpAndExit
#define HANDLE_OPTION() if ((*s == '\0') && (current_option == NULL)) goto ShowHelpAndExit; \
if ((*s != '\0') && (current_option != NULL)) goto ShowHelpAndExit; \
@@ -450,14 +453,14 @@ bool GameDetector::detectGame()
return true;
}
-char *GameDetector::getGameName()
+const char *GameDetector::getGameName()
{
if (_gameText == NULL) {
char buf[256];
sprintf(buf, "Unknown game: \"%s\"", _exe_name);
- return strdup(buf);
+ _gameText = strdup(buf);
}
- return strdup(_gameText);
+ return _gameText;
}
int GameDetector::detectMain(int argc, char **argv)
diff --git a/common/gameDetector.h b/common/gameDetector.h
index 4cbfa3453f..6393440863 100644
--- a/common/gameDetector.h
+++ b/common/gameDetector.h
@@ -31,7 +31,7 @@ public:
int detectMain(int argc, char **argv);
void parseCommandLine(int argc, char **argv);
bool detectGame(void);
- char *getGameName(void);
+ const char *getGameName(void);
bool _fullScreen;
byte _gameId;
diff --git a/common/main.cpp b/common/main.cpp
index 43fd2e4563..9a43a58212 100644
--- a/common/main.cpp
+++ b/common/main.cpp
@@ -130,12 +130,10 @@ int main(int argc, char *argv[])
OSystem *system = detector.createSystem();
{
- char *s = detector.getGameName();
OSystem::Property prop;
- prop.caption = s;
+ prop.caption = detector.getGameName();
system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
- free(s);
}
// Create the game engine
diff --git a/scumm/smush/rect.h b/common/rect.h
index d1f061136f..0dbc8ab6b6 100644
--- a/scumm/smush/rect.h
+++ b/common/rect.h
@@ -19,10 +19,12 @@
*
*/
-#ifndef SMUSH_RECT_H
-#define SMUSH_RECT_H
+#ifndef COMMON_RECT_H
+#define COMMON_RECT_H
-#include "config.h"
+#include "scummsys.h"
+
+namespace ScummVM {
/*! @brief simple class for handling both 2D position and size
@@ -97,4 +99,6 @@ public:
bool clip(Rect & r) const;
};
+}; // End of namespace ScummVM
+
#endif
diff --git a/scumm/scumm.h b/scumm/scumm.h
index ecb3e1f468..b0412d1ac4 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -208,7 +208,7 @@ struct CharsetRenderer {
byte *_charPtr;
int _width, _height;
int _offsX, _offsY;
- byte _bitMask, _revBitMask;
+ byte _bitMask;
int _bottom;
int _virtScreenHeight;
@@ -368,7 +368,7 @@ public:
/* Init functions, etc */
byte _fastMode;
- char *getGameName();
+ const char *getGameName();
/* video buffer */
byte *_videoBuffer;
@@ -835,8 +835,9 @@ public:
void unkScreenEffect3();
void unkScreenEffect4();
void unkScreenEffect5(int a);
- void transitionEffect(int a); // former unkScreenEffect7
- void dissolveEffect(int width, int height); // former unkScreenEffect5(0) and unkScreenEffect6
+ void transitionEffect(int a);
+ void dissolveEffect(int width, int height);
+ void scrollEffect(int dir);
void decompressBomp(byte *dst, byte *src, int w, int h);
uint _shakeFrame;
@@ -1397,20 +1398,8 @@ public:
Scumm_v7(GameDetector *detector, OSystem *syst) : Scumm(detector, syst) {}
};
-extern uint16 _debugLevel;
-
+// This is a constant lookup table of reverse bit masks
extern const byte revBitMask[8];
-//void blitToScreen(Scumm *s, byte *src, int x, int y, int w, int h);
-
-#if defined(__GNUC__)
-void CDECL error(const char *s, ...) NORETURN;
-#else
-void CDECL NORETURN error(const char *s, ...);
-#endif
-
-void CDECL warning(const char *s, ...);
-void CDECL debug(int level, const char *s, ...);
-void checkHeap();
/* Direction conversion functions (between old dir and new dir format) */
int newDirToOldDir(int dir);
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index 7352a7ae79..ef3a3c45f1 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -100,7 +100,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
_gui->init(this);
_newgui = new NewGui(this);
- _bundle = new Bundle(this);
+ _bundle = new Bundle();
_timer = new Timer(this);
_sound = new Sound(this);
@@ -1464,7 +1464,7 @@ void Scumm::launch()
_maxHeapThreshold = 450000;
_minHeapThreshold = 400000;
- /* Create a primary virtual screen */
+ // Create a primary virtual screen
_videoBuffer = (byte *)calloc(328*200, 1);
allocResTypeData(rtBuffer, MKID('NONE'), 10, "buffer", 0);
@@ -1514,8 +1514,6 @@ void Scumm::launch()
_sound->setupSound();
runScript(1, 0, 0, &_bootParam);
-
-// _scummTimer = 0;
}
void Scumm::go() {
diff --git a/scumm/smush/blitter.h b/scumm/smush/blitter.h
index 16c07f0296..a59644e777 100644
--- a/scumm/smush/blitter.h
+++ b/scumm/smush/blitter.h
@@ -34,7 +34,10 @@
# endif
#endif
-#include "rect.h"
+#include "common/rect.h"
+
+using ScummVM::Point;
+using ScummVM::Rect;
class Chunk;
/*! @brief class for handling blitting on a frame buffer
diff --git a/scumm/smush/brenderer.cpp b/scumm/smush/brenderer.cpp
index 64f97bb9c5..bba35fd3ad 100644
--- a/scumm/smush/brenderer.cpp
+++ b/scumm/smush/brenderer.cpp
@@ -22,6 +22,8 @@
#include <stdafx.h>
#include "brenderer.h"
+#include "common/engine.h" // for debug, warning, error
+
#include <assert.h>
void BaseRenderer::clean() {
diff --git a/scumm/smush/channel.h b/scumm/smush/channel.h
index af5a078540..112ca5f1e7 100644
--- a/scumm/smush/channel.h
+++ b/scumm/smush/channel.h
@@ -23,6 +23,7 @@
#define CHANNEL_H
#include "config.h"
+#include "common/engine.h" // for debug, warning, error
#ifdef DEBUG
# ifndef NO_DEBUG_CHANNEL
diff --git a/scumm/smush/chunk.cpp b/scumm/smush/chunk.cpp
index 76163ebec2..f665c4db36 100644
--- a/scumm/smush/chunk.cpp
+++ b/scumm/smush/chunk.cpp
@@ -22,6 +22,8 @@
#include <stdafx.h>
#include "chunk.h"
+#include "common/engine.h" // for debug, warning, error
+
#include <stdio.h> // for FILE, fopen, fclose, fseek and ftell
#include <string.h> // for memcpy
diff --git a/scumm/smush/codec37.cpp b/scumm/smush/codec37.cpp
index 16fe44a411..cc796ef48e 100644
--- a/scumm/smush/codec37.cpp
+++ b/scumm/smush/codec37.cpp
@@ -24,6 +24,8 @@
#include "chunk.h"
#include "blitter.h"
+#include "common/engine.h" // for debug, warning, error
+
#include <assert.h>
#include <string.h>
diff --git a/scumm/smush/config.h b/scumm/smush/config.h
index 112b166e4d..7ad1bcff23 100644
--- a/scumm/smush/config.h
+++ b/scumm/smush/config.h
@@ -23,7 +23,7 @@
#define SMUSH_CONFIG_H
#include <stdafx.h>
-#include <scumm.h>
+#include <scummsys.h>
#ifndef NDEBUG
#define DEBUG
diff --git a/scumm/smush/decoder.h b/scumm/smush/decoder.h
index cff839214d..8e4e9493f3 100644
--- a/scumm/smush/decoder.h
+++ b/scumm/smush/decoder.h
@@ -24,8 +24,10 @@
#include "config.h"
-#include "rect.h"
+#include "common/rect.h"
+using ScummVM::Point;
+using ScummVM::Rect;
class Blitter;
class Chunk;
diff --git a/scumm/smush/frenderer.cpp b/scumm/smush/frenderer.cpp
index 191235fb05..eb75a2bde4 100644
--- a/scumm/smush/frenderer.cpp
+++ b/scumm/smush/frenderer.cpp
@@ -21,9 +21,9 @@
#include <stdafx.h>
#include "common/util.h"
+#include "common/engine.h" // for debug, warning, error
#include "frenderer.h"
-#include "rect.h"
#include <assert.h>
#include <string.h>
diff --git a/scumm/smush/frenderer.h b/scumm/smush/frenderer.h
index 18d6bf5089..c0210ab4d7 100644
--- a/scumm/smush/frenderer.h
+++ b/scumm/smush/frenderer.h
@@ -35,7 +35,7 @@
#endif
#include "brenderer.h"
-#include "rect.h"
+#include "common/util.h"
#include "blitter.h"
/*! @brief ::renderer implementation specifically designed for font files.
diff --git a/scumm/smush/player.cpp b/scumm/smush/player.cpp
index cbe6aae69d..829d4d9437 100644
--- a/scumm/smush/player.cpp
+++ b/scumm/smush/player.cpp
@@ -21,6 +21,8 @@
#include <stdafx.h>
#include "common/util.h"
+#include "common/engine.h" // for debug, warning, error
+
#include "player.h"
#include "mixer.h"
@@ -28,7 +30,6 @@
#include "frenderer.h"
#include "channel.h"
#include "chunk_type.h"
-#include "rect.h"
#include "blitter.h"
#include <assert.h>
diff --git a/scumm/smush/player.h b/scumm/smush/player.h
index 79bc7f6874..f9decce7f0 100644
--- a/scumm/smush/player.h
+++ b/scumm/smush/player.h
@@ -24,7 +24,7 @@
#include "config.h"
-#include "rect.h"
+#include "common/util.h"
#include "chunk.h"
#include "palette.h"
#include "codec1.h"
diff --git a/scumm/smush/renderer.h b/scumm/smush/renderer.h
index 7f8fd7e730..f9ccc04ac1 100644
--- a/scumm/smush/renderer.h
+++ b/scumm/smush/renderer.h
@@ -25,8 +25,10 @@
#include "config.h"
#include "palette.h"
-#include "rect.h"
+#include "common/rect.h"
+using ScummVM::Point;
+using ScummVM::Rect;
class Mixer;
/*! @brief interface for general output (rendering)
diff --git a/scumm/smush/saud_channel.cpp b/scumm/smush/saud_channel.cpp
index c6a6aefd74..6eaa388ae7 100644
--- a/scumm/smush/saud_channel.cpp
+++ b/scumm/smush/saud_channel.cpp
@@ -20,6 +20,7 @@
*/
#include <stdafx.h>
+
#include "channel.h"
#include "chunk.h"
#include "chunk_type.h"
diff --git a/scumm/smush/scumm_renderer.cpp b/scumm/smush/scumm_renderer.cpp
index 3375d275d9..e652d5a370 100644
--- a/scumm/smush/scumm_renderer.cpp
+++ b/scumm/smush/scumm_renderer.cpp
@@ -25,6 +25,7 @@
#include "channel.h"
#include "mixer.h"
#include "sound/mixer.h"
+#include "scumm/scumm.h"
#include "scumm/sound.h"
class scumm_mixer : public Mixer {
diff --git a/scumm/string.cpp b/scumm/string.cpp
index 1c85f6a7c9..b955cf5dca 100644
--- a/scumm/string.cpp
+++ b/scumm/string.cpp
@@ -951,8 +951,6 @@ void CharsetRenderer::printChar(int chr)
_mask_ptr = _vm->getResourceAddress(rtBuffer, 9)
+ _drawTop * 40 + _left / 8 + _vm->_screenStartStrip;
- _revBitMask = revBitMask[_left & 7];
-
_virtScreenHeight = vs->height;
_charPtr += 4;
@@ -992,7 +990,7 @@ void CharsetRenderer::drawBits()
y = 0;
for (y = 0; y < _height && y + _drawTop < _virtScreenHeight;) {
- maskmask = _revBitMask;
+ maskmask = revBitMask[_left & 7];
maskpos = 0;
for (x = 0; x < _width; x++) {
diff --git a/scumm/sys.cpp b/scumm/sys.cpp
index e8619a331e..ff023e642f 100644
--- a/scumm/sys.cpp
+++ b/scumm/sys.cpp
@@ -167,12 +167,6 @@ bool Scumm::checkFixedDisk()
return true;
}
-
-#ifdef NEED_STRDUP
-char *strdup(const char *s);
-#endif /* NEED_STRDUP */
-
-
void *operator new(size_t size) {
return calloc(size, 1);
}
diff --git a/simon/simon.h b/simon/simon.h
index fce335b15a..829692e0f7 100644
--- a/simon/simon.h
+++ b/simon/simon.h
@@ -813,9 +813,6 @@ public:
};
-void NORETURN CDECL error(const char *errmsg, ...);
-void CDECL warning(const char *errmsg, ...);
-
void palette_fadeout(uint32 *pal_values, uint num);
#endif