fixed compilation on Mac OS X; some cleanup; moved header file scumm/smusH/rect.h to common/rect.h

svn-id: r4877
This commit is contained in:
Max Horn 2002-08-31 13:29:10 +00:00
parent 0c7771a706
commit a39711e256
28 changed files with 94 additions and 80 deletions

View file

@ -167,7 +167,6 @@ static void checkName(GameDetector *d, Game &game)
if(d->detectGame()) { if(d->detectGame()) {
char *n = d->getGameName(); char *n = d->getGameName();
strcpy(game.text, n); strcpy(game.text, n);
free(n);
} else } else
strcpy(game.text, game.filename_base); strcpy(game.text, game.filename_base);
d->_exe_name = NULL; d->_exe_name = NULL;

View file

@ -69,9 +69,7 @@ static vmsaveResult trySave(GameDetector *d, const char *data, int size,
memset(&header, 0, sizeof(header)); memset(&header, 0, sizeof(header));
strncpy(header.shortdesc, "ScummVM savegame", 16); strncpy(header.shortdesc, "ScummVM savegame", 16);
char *game_name = d->getGameName(); strncpy(header.longdesc, d->getGameName(), 32);
strncpy(header.longdesc, game_name, 32);
free(game_name);
strncpy(header.id, "ScummVM", 16); strncpy(header.id, "ScummVM", 16);
icon.create_vmicon(iconbuffer); icon.create_vmicon(iconbuffer);
header.numicons = 1; header.numicons = 1;

View file

@ -30,6 +30,19 @@
#define xfree(p) {if (p) free(p);} #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) static char *ltrim(char *t)
{ {

View file

@ -56,5 +56,17 @@ public:
static Engine *createFromDetector(GameDetector *detector, OSystem *syst); 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 #endif

View file

@ -21,19 +21,6 @@
#include "file.h" #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() { File::File() {
_handle = NULL; _handle = NULL;
_readFailed = false; _readFailed = false;
@ -45,28 +32,35 @@ File::~File() {
} }
bool File::open(const char *filename, int mode, byte encbyte) { bool File::open(const char *filename, int mode, byte encbyte) {
char * buf; char buf[256], *ptr;
if (_handle) { if (_handle) {
debug(2, "File %s already opened", filename); debug(2, "File %s already opened", filename);
return false; return false;
} }
clearReadFailed(); clearReadFailed();
buf = strdup(filename); strcpy(buf, filename);
if (mode == 1) { if (mode == 1) {
_handle = fopen(buf, "rb"); _handle = fopen(buf, "rb");
if (_handle == NULL) { if (_handle == NULL) {
_handle = fopen(strupr(buf), "rb"); ptr = buf;
if (_handle == NULL) { do
_handle = fopen(strlwr(buf), "rb"); *ptr++ = toupper(*ptr);
} while (*ptr);
else { _handle = fopen(buf, "rb");
debug(2, "File %s not found", filename);
return false;
}
} }
} if (_handle == NULL) {
else { 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!"); warning("Only read mode supported!");
return false; return false;
} }

View file

@ -29,6 +29,9 @@
#include "common/config-file.h" #include "common/config-file.h"
extern uint16 _debugLevel;
#define CHECK_OPTION() if ((current_option != NULL) || (*s != '\0')) goto ShowHelpAndExit #define CHECK_OPTION() if ((current_option != NULL) || (*s != '\0')) goto ShowHelpAndExit
#define HANDLE_OPTION() if ((*s == '\0') && (current_option == NULL)) goto ShowHelpAndExit; \ #define HANDLE_OPTION() if ((*s == '\0') && (current_option == NULL)) goto ShowHelpAndExit; \
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; return true;
} }
char *GameDetector::getGameName() const char *GameDetector::getGameName()
{ {
if (_gameText == NULL) { if (_gameText == NULL) {
char buf[256]; char buf[256];
sprintf(buf, "Unknown game: \"%s\"", _exe_name); 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) int GameDetector::detectMain(int argc, char **argv)

View file

@ -31,7 +31,7 @@ public:
int detectMain(int argc, char **argv); int detectMain(int argc, char **argv);
void parseCommandLine(int argc, char **argv); void parseCommandLine(int argc, char **argv);
bool detectGame(void); bool detectGame(void);
char *getGameName(void); const char *getGameName(void);
bool _fullScreen; bool _fullScreen;
byte _gameId; byte _gameId;

View file

@ -130,12 +130,10 @@ int main(int argc, char *argv[])
OSystem *system = detector.createSystem(); OSystem *system = detector.createSystem();
{ {
char *s = detector.getGameName();
OSystem::Property prop; OSystem::Property prop;
prop.caption = s; prop.caption = detector.getGameName();
system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop); system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
free(s);
} }
// Create the game engine // Create the game engine

View file

@ -19,10 +19,12 @@
* *
*/ */
#ifndef SMUSH_RECT_H #ifndef COMMON_RECT_H
#define SMUSH_RECT_H #define COMMON_RECT_H
#include "config.h" #include "scummsys.h"
namespace ScummVM {
/*! @brief simple class for handling both 2D position and size /*! @brief simple class for handling both 2D position and size
@ -97,4 +99,6 @@ public:
bool clip(Rect & r) const; bool clip(Rect & r) const;
}; };
}; // End of namespace ScummVM
#endif #endif

View file

@ -208,7 +208,7 @@ struct CharsetRenderer {
byte *_charPtr; byte *_charPtr;
int _width, _height; int _width, _height;
int _offsX, _offsY; int _offsX, _offsY;
byte _bitMask, _revBitMask; byte _bitMask;
int _bottom; int _bottom;
int _virtScreenHeight; int _virtScreenHeight;
@ -368,7 +368,7 @@ public:
/* Init functions, etc */ /* Init functions, etc */
byte _fastMode; byte _fastMode;
char *getGameName(); const char *getGameName();
/* video buffer */ /* video buffer */
byte *_videoBuffer; byte *_videoBuffer;
@ -835,8 +835,9 @@ public:
void unkScreenEffect3(); void unkScreenEffect3();
void unkScreenEffect4(); void unkScreenEffect4();
void unkScreenEffect5(int a); void unkScreenEffect5(int a);
void transitionEffect(int a); // former unkScreenEffect7 void transitionEffect(int a);
void dissolveEffect(int width, int height); // former unkScreenEffect5(0) and unkScreenEffect6 void dissolveEffect(int width, int height);
void scrollEffect(int dir);
void decompressBomp(byte *dst, byte *src, int w, int h); void decompressBomp(byte *dst, byte *src, int w, int h);
uint _shakeFrame; uint _shakeFrame;
@ -1397,20 +1398,8 @@ public:
Scumm_v7(GameDetector *detector, OSystem *syst) : Scumm(detector, syst) {} 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]; 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) */ /* Direction conversion functions (between old dir and new dir format) */
int newDirToOldDir(int dir); int newDirToOldDir(int dir);

View file

@ -100,7 +100,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
_gui->init(this); _gui->init(this);
_newgui = new NewGui(this); _newgui = new NewGui(this);
_bundle = new Bundle(this); _bundle = new Bundle();
_timer = new Timer(this); _timer = new Timer(this);
_sound = new Sound(this); _sound = new Sound(this);
@ -1464,7 +1464,7 @@ void Scumm::launch()
_maxHeapThreshold = 450000; _maxHeapThreshold = 450000;
_minHeapThreshold = 400000; _minHeapThreshold = 400000;
/* Create a primary virtual screen */ // Create a primary virtual screen
_videoBuffer = (byte *)calloc(328*200, 1); _videoBuffer = (byte *)calloc(328*200, 1);
allocResTypeData(rtBuffer, MKID('NONE'), 10, "buffer", 0); allocResTypeData(rtBuffer, MKID('NONE'), 10, "buffer", 0);
@ -1514,8 +1514,6 @@ void Scumm::launch()
_sound->setupSound(); _sound->setupSound();
runScript(1, 0, 0, &_bootParam); runScript(1, 0, 0, &_bootParam);
// _scummTimer = 0;
} }
void Scumm::go() { void Scumm::go() {

View file

@ -34,7 +34,10 @@
# endif # endif
#endif #endif
#include "rect.h" #include "common/rect.h"
using ScummVM::Point;
using ScummVM::Rect;
class Chunk; class Chunk;
/*! @brief class for handling blitting on a frame buffer /*! @brief class for handling blitting on a frame buffer

View file

@ -22,6 +22,8 @@
#include <stdafx.h> #include <stdafx.h>
#include "brenderer.h" #include "brenderer.h"
#include "common/engine.h" // for debug, warning, error
#include <assert.h> #include <assert.h>
void BaseRenderer::clean() { void BaseRenderer::clean() {

View file

@ -23,6 +23,7 @@
#define CHANNEL_H #define CHANNEL_H
#include "config.h" #include "config.h"
#include "common/engine.h" // for debug, warning, error
#ifdef DEBUG #ifdef DEBUG
# ifndef NO_DEBUG_CHANNEL # ifndef NO_DEBUG_CHANNEL

View file

@ -22,6 +22,8 @@
#include <stdafx.h> #include <stdafx.h>
#include "chunk.h" #include "chunk.h"
#include "common/engine.h" // for debug, warning, error
#include <stdio.h> // for FILE, fopen, fclose, fseek and ftell #include <stdio.h> // for FILE, fopen, fclose, fseek and ftell
#include <string.h> // for memcpy #include <string.h> // for memcpy

View file

@ -24,6 +24,8 @@
#include "chunk.h" #include "chunk.h"
#include "blitter.h" #include "blitter.h"
#include "common/engine.h" // for debug, warning, error
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>

View file

@ -23,7 +23,7 @@
#define SMUSH_CONFIG_H #define SMUSH_CONFIG_H
#include <stdafx.h> #include <stdafx.h>
#include <scumm.h> #include <scummsys.h>
#ifndef NDEBUG #ifndef NDEBUG
#define DEBUG #define DEBUG

View file

@ -24,8 +24,10 @@
#include "config.h" #include "config.h"
#include "rect.h" #include "common/rect.h"
using ScummVM::Point;
using ScummVM::Rect;
class Blitter; class Blitter;
class Chunk; class Chunk;

View file

@ -21,9 +21,9 @@
#include <stdafx.h> #include <stdafx.h>
#include "common/util.h" #include "common/util.h"
#include "common/engine.h" // for debug, warning, error
#include "frenderer.h" #include "frenderer.h"
#include "rect.h"
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>

View file

@ -35,7 +35,7 @@
#endif #endif
#include "brenderer.h" #include "brenderer.h"
#include "rect.h" #include "common/util.h"
#include "blitter.h" #include "blitter.h"
/*! @brief ::renderer implementation specifically designed for font files. /*! @brief ::renderer implementation specifically designed for font files.

View file

@ -21,6 +21,8 @@
#include <stdafx.h> #include <stdafx.h>
#include "common/util.h" #include "common/util.h"
#include "common/engine.h" // for debug, warning, error
#include "player.h" #include "player.h"
#include "mixer.h" #include "mixer.h"
@ -28,7 +30,6 @@
#include "frenderer.h" #include "frenderer.h"
#include "channel.h" #include "channel.h"
#include "chunk_type.h" #include "chunk_type.h"
#include "rect.h"
#include "blitter.h" #include "blitter.h"
#include <assert.h> #include <assert.h>

View file

@ -24,7 +24,7 @@
#include "config.h" #include "config.h"
#include "rect.h" #include "common/util.h"
#include "chunk.h" #include "chunk.h"
#include "palette.h" #include "palette.h"
#include "codec1.h" #include "codec1.h"

View file

@ -25,8 +25,10 @@
#include "config.h" #include "config.h"
#include "palette.h" #include "palette.h"
#include "rect.h" #include "common/rect.h"
using ScummVM::Point;
using ScummVM::Rect;
class Mixer; class Mixer;
/*! @brief interface for general output (rendering) /*! @brief interface for general output (rendering)

View file

@ -20,6 +20,7 @@
*/ */
#include <stdafx.h> #include <stdafx.h>
#include "channel.h" #include "channel.h"
#include "chunk.h" #include "chunk.h"
#include "chunk_type.h" #include "chunk_type.h"

View file

@ -25,6 +25,7 @@
#include "channel.h" #include "channel.h"
#include "mixer.h" #include "mixer.h"
#include "sound/mixer.h" #include "sound/mixer.h"
#include "scumm/scumm.h"
#include "scumm/sound.h" #include "scumm/sound.h"
class scumm_mixer : public Mixer { class scumm_mixer : public Mixer {

View file

@ -951,8 +951,6 @@ void CharsetRenderer::printChar(int chr)
_mask_ptr = _vm->getResourceAddress(rtBuffer, 9) _mask_ptr = _vm->getResourceAddress(rtBuffer, 9)
+ _drawTop * 40 + _left / 8 + _vm->_screenStartStrip; + _drawTop * 40 + _left / 8 + _vm->_screenStartStrip;
_revBitMask = revBitMask[_left & 7];
_virtScreenHeight = vs->height; _virtScreenHeight = vs->height;
_charPtr += 4; _charPtr += 4;
@ -992,7 +990,7 @@ void CharsetRenderer::drawBits()
y = 0; y = 0;
for (y = 0; y < _height && y + _drawTop < _virtScreenHeight;) { for (y = 0; y < _height && y + _drawTop < _virtScreenHeight;) {
maskmask = _revBitMask; maskmask = revBitMask[_left & 7];
maskpos = 0; maskpos = 0;
for (x = 0; x < _width; x++) { for (x = 0; x < _width; x++) {

View file

@ -167,12 +167,6 @@ bool Scumm::checkFixedDisk()
return true; return true;
} }
#ifdef NEED_STRDUP
char *strdup(const char *s);
#endif /* NEED_STRDUP */
void *operator new(size_t size) { void *operator new(size_t size) {
return calloc(size, 1); return calloc(size, 1);
} }

View file

@ -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); void palette_fadeout(uint32 *pal_values, uint num);
#endif #endif