aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorPaweł Kołodziejski2002-08-30 07:24:45 +0000
committerPaweł Kołodziejski2002-08-30 07:24:45 +0000
commita1fa514b5a1309e9e83b5b49a8f387c14ff8d27c (patch)
treec9bb6302ffa44c72dbaf9196416f56f1e5d28ace /scumm
parent9b34985faa10f46990d9e3dd72d1ac6188660759 (diff)
downloadscummvm-rg350-a1fa514b5a1309e9e83b5b49a8f387c14ff8d27c.tar.gz
scummvm-rg350-a1fa514b5a1309e9e83b5b49a8f387c14ff8d27c.tar.bz2
scummvm-rg350-a1fa514b5a1309e9e83b5b49a8f387c14ff8d27c.zip
some cleanup
svn-id: r4870
Diffstat (limited to 'scumm')
-rw-r--r--scumm/smush/blitter.cpp58
-rw-r--r--scumm/smush/blitter.h32
-rw-r--r--scumm/smush/brenderer.cpp2
-rw-r--r--scumm/smush/brenderer.h30
-rw-r--r--scumm/smush/channel.h112
-rw-r--r--scumm/smush/chunk.cpp86
-rw-r--r--scumm/smush/chunk.h62
-rw-r--r--scumm/smush/codec1.cpp19
-rw-r--r--scumm/smush/codec37.cpp88
-rw-r--r--scumm/smush/codec37.h32
-rw-r--r--scumm/smush/codec44.cpp8
-rw-r--r--scumm/smush/codec47.cpp14
-rw-r--r--scumm/smush/color.cpp6
-rw-r--r--scumm/smush/color.h4
-rw-r--r--scumm/smush/frenderer.cpp79
-rw-r--r--scumm/smush/frenderer.h30
-rw-r--r--scumm/smush/imuse_channel.cpp89
-rw-r--r--scumm/smush/mixer.h2
-rw-r--r--scumm/smush/palette.h8
-rw-r--r--scumm/smush/player.cpp146
-rw-r--r--scumm/smush/player.h20
-rw-r--r--scumm/smush/rect.h39
-rw-r--r--scumm/smush/renderer.h6
-rw-r--r--scumm/smush/saud_channel.cpp66
-rw-r--r--scumm/smush/scumm_renderer.cpp28
-rw-r--r--scumm/smush/scumm_renderer.h6
26 files changed, 537 insertions, 535 deletions
diff --git a/scumm/smush/blitter.cpp b/scumm/smush/blitter.cpp
index d760919869..38116dbbf5 100644
--- a/scumm/smush/blitter.cpp
+++ b/scumm/smush/blitter.cpp
@@ -27,7 +27,7 @@
#include <assert.h>
#include <string.h> // for memcpy
-Blitter::Blitter(char * ptr, const Point & dstsize, const Rect & src) :
+Blitter::Blitter(byte * ptr, const Point & dstsize, const Rect & src) :
_ptr(ptr),
_clip(dstsize),
_src(src),
@@ -53,7 +53,7 @@ Blitter::~Blitter() {
#endif
}
-void Blitter::advance(int x, int y) {
+void Blitter::advance(int32 x, int32 y) {
if(y != 0) {
_cur.set(_src.left() + x, _cur.getY() + y);
} else {
@@ -66,11 +66,11 @@ void Blitter::advance(int x, int y) {
_outside = ! _src.isInside(_cur);
}
-void Blitter::advanceBlock(int x, int y) {
- advance(x*4, y*4);
+void Blitter::advanceBlock(int32 x, int32 y) {
+ advance(x * 4, y * 4);
}
-void Blitter::put(char data) {
+void Blitter::put(byte data) {
if(!_outside) {
*_offset = data;
advance();
@@ -80,7 +80,7 @@ void Blitter::put(char data) {
#endif
}
-void Blitter::put(char data, unsigned int len) {
+void Blitter::put(byte data, uint32 len) {
while(len) {
if(_outside) {
#ifdef DEBUG_CLIPPER
@@ -88,14 +88,14 @@ void Blitter::put(char data, unsigned int len) {
#endif
break;
}
- int l = MIN((int)len, MIN(_clip.getX() - _cur.getX(), _src.right() - _cur.getX()));
+ int32 l = MIN((int32)len, MIN(_clip.getX() - _cur.getX(), _src.right() - _cur.getX()));
len -= l;
memset(_offset, data, l);
advance(l);
}
}
-void Blitter::blit(char * ptr, unsigned int len) {
+void Blitter::blit(byte * ptr, uint32 len) {
while(len) {
if(_outside) {
#ifdef DEBUG_CLIPPER
@@ -103,7 +103,7 @@ void Blitter::blit(char * ptr, unsigned int len) {
#endif
break;
}
- int l = MIN((int)len, MIN(_clip.getX() - _cur.getX(), _src.right() - _cur.getX()));
+ int32 l = MIN((int32)len, MIN(_clip.getX() - _cur.getX(), _src.right() - _cur.getX()));
len -= l;
memcpy(_offset, ptr, l);
ptr += l;
@@ -111,7 +111,7 @@ void Blitter::blit(char * ptr, unsigned int len) {
}
}
-void Blitter::blit(Chunk & src, unsigned int len) {
+void Blitter::blit(Chunk & src, uint32 len) {
while(len) {
if(_outside) {
#ifdef DEBUG_CLIPPER
@@ -119,18 +119,18 @@ void Blitter::blit(Chunk & src, unsigned int len) {
#endif
break;
}
- int l = MIN((int)len, MIN(_clip.getX() -_cur.getX(), _src.right() - _cur.getX()));
+ int32 l = MIN((int32)len, MIN(_clip.getX() -_cur.getX(), _src.right() - _cur.getX()));
len -= l;
src.read(_offset, l);
advance(l);
}
}
-void Blitter::putBlock(unsigned int data) {
+void Blitter::putBlock(uint32 data) {
if(_cur.getX() + 3 < _src.right() && _cur.getY() + 3 < _src.bottom()) { // This is clipping
assert((_clip.getX() & 3) == 0);
- unsigned int * dst = (unsigned int *)_offset;
- int line_size = _clip.getX() >> 2;
+ uint32 * dst = (uint32 *)_offset;
+ int32 line_size = _clip.getX() >> 2;
data = TO_LE_32(data);
*dst = data; dst += line_size;
@@ -146,11 +146,11 @@ void Blitter::putBlock(unsigned int data) {
advanceBlock();
}
-void Blitter::putBlock(unsigned int d1, unsigned int d2, unsigned int d3, unsigned int d4) {
+void Blitter::putBlock(uint32 d1, uint32 d2, uint32 d3, uint32 d4) {
if(_cur.getX() + 3 < _src.right() && _cur.getY() + 3 < _src.bottom()) { // This is clipping
assert((_clip.getX() & 3) == 0);
- unsigned int * dst = (unsigned int *)_offset;
- int line_size = _clip.getX() >> 2;
+ uint32 * dst = (uint32 *)_offset;
+ int32 line_size = _clip.getX() >> 2;
*dst = TO_LE_32(d4); dst += line_size;
*dst = TO_LE_32(d3); dst += line_size;
@@ -165,12 +165,12 @@ void Blitter::putBlock(unsigned int d1, unsigned int d2, unsigned int d3, unsign
advanceBlock();
}
-void Blitter::putBlock(unsigned char * data) {
+void Blitter::putBlock(byte * data) {
if(_cur.getX() + 3 < _src.right() && _cur.getY() + 3 < _src.bottom()) { // This is clipping
assert((_clip.getX() & 3) == 0);
- unsigned int * dst = (unsigned int *)_offset;
- int line_size = _clip.getX() >> 2;
- unsigned int * src = (unsigned int *)data;
+ uint32 * dst = (uint32 *)_offset;
+ int32 line_size = _clip.getX() >> 2;
+ uint32 * src = (uint32 *)data;
*dst = TO_LE_32(*src++); dst += line_size;
*dst = TO_LE_32(*src++); dst += line_size;
*dst = TO_LE_32(*src++); dst += line_size;
@@ -186,8 +186,8 @@ void Blitter::putBlock(unsigned char * data) {
void Blitter::putBlock(Chunk & src) {
if(_cur.getX() + 3 < _src.right() && _cur.getY() + 3 < _src.bottom()) { // This is clipping
assert((_clip.getX() & 3) == 0);
- unsigned int * dst = (unsigned int *)_offset;
- int line_size = _clip.getX() >> 2;
+ uint32 * dst = (uint32 *)_offset;
+ int32 line_size = _clip.getX() >> 2;
*dst = TO_LE_32(src.getDword()); dst += line_size;
*dst = TO_LE_32(src.getDword()); dst += line_size;
*dst = TO_LE_32(src.getDword()); dst += line_size;
@@ -200,16 +200,16 @@ void Blitter::putBlock(Chunk & src) {
advanceBlock();
}
-void Blitter::blockCopy(int offset) {
+void Blitter::blockCopy(int32 offset) {
if(_cur.getX() + 3 < _src.right() && _cur.getY() + 3 < _src.bottom()) {// This is clipping
- char * dst = _offset;
- *((unsigned int *)dst) = *((unsigned int *)(dst + offset));
+ byte * dst = _offset;
+ *((uint32 *)dst) = *((uint32 *)(dst + offset));
dst += _clip.getX();
- *((unsigned int *)dst) = *((unsigned int *)(dst + offset));
+ *((uint32 *)dst) = *((uint32 *)(dst + offset));
dst += _clip.getX();
- *((unsigned int *)dst) = *((unsigned int *)(dst + offset));
+ *((uint32 *)dst) = *((uint32 *)(dst + offset));
dst += _clip.getX();
- *((unsigned int *)dst) = *((unsigned int *)(dst + offset));
+ *((uint32 *)dst) = *((uint32 *)(dst + offset));
#ifdef DEBUG_CLIPPER
} else {
_clippedBlock ++;
diff --git a/scumm/smush/blitter.h b/scumm/smush/blitter.h
index 2590af0ac4..16c07f0296 100644
--- a/scumm/smush/blitter.h
+++ b/scumm/smush/blitter.h
@@ -1,4 +1,4 @@
-/* ScummVM - Scumm Interpreter
+/* ScummVM - Scumm int32erpreter
* Copyright (C) 2001/2002 The ScummVM project
*
* This program is free software; you can redistribute it and/or
@@ -44,15 +44,15 @@ class Chunk;
*/
class Blitter {
private:
- char * _ptr; //!< This is the pointer to the start of the frame buffer
- char * _offset; //!< This is the current pointer in the frame buffer
+ byte * _ptr; //!< This is the pointer to the start of the frame buffer
+ byte * _offset; //!< This is the current pointer in the frame buffer
Point _clip; //!< This is the size of the frame buffer (width/height)
Rect _src; //!< This is the size and position of the destination rectangle
Point _cur; //!< This is the current position in the destination rectangle
bool _outside; //!< flag that is set to \c true when the blitter reach the end of the destination rectangle
#ifdef DEBUG_CLIPPER
- int _clipped;
- int _clippedBlock;
+ int32 _clipped;
+ int32 _clippedBlock;
#endif
public:
/*! @brief constructor
@@ -61,19 +61,19 @@ public:
@param dstsize the size of the frame buffer
@param src the rectangle to blit to
*/
- Blitter(char * buffer, const Point & dstsize, const Rect & src);
+ Blitter(byte * buffer, const Point & dstsize, const Rect & src);
virtual ~Blitter();
- void blit(char *, unsigned int); //!< This method allows to blit directly some data from a buffer
- void blit(Chunk &, unsigned int); //!< This method allows to blit directly some data from a Chunk
- void put(char); //!< This method allows to blit one byte
- void put(char, unsigned int); //!< This method allows to blit one byte several times
- void advance(int = 1, int = 0); //!< This method allows to advance the current position in the blitter
- void advanceBlock(int = 1, int = 0); //!< This method allows to advance the current position in the blitter in terms of blocks
- void putBlock(unsigned int); //!< This method allows to blit one block from an int value repeated 4 time
+ void blit(byte *, uint32); //!< This method allows to blit directly some data from a buffer
+ void blit(Chunk &, uint32); //!< This method allows to blit directly some data from a Chunk
+ void put(byte); //!< This method allows to blit one byte
+ void put(byte, uint32); //!< This method allows to blit one byte several times
+ void advance(int32 = 1, int32 = 0); //!< This method allows to advance the current position in the blitter
+ void advanceBlock(int32 = 1, int32 = 0); //!< This method allows to advance the current position in the blitter in terms of blocks
+ void putBlock(uint32); //!< This method allows to blit one block from an int32 value repeated 4 time
void putBlock(Chunk &); //!< This method allows to blit one block directly read from a Chunk
- void putBlock(unsigned char *); //!< This method allows to blit one block directly from a buffer
- void putBlock(unsigned int, unsigned int, unsigned int, unsigned int); //!< This method allows to blit one block from a 4 int value
- void blockCopy(int); //!< This method allows to copy one block from another separated by the given offset
+ void putBlock(byte *); //!< This method allows to blit one block directly from a buffer
+ void putBlock(uint32, uint32, uint32, uint32); //!< This method allows to blit one block from a 4 int32 value
+ void blockCopy(int32); //!< This method allows to copy one block from another separated by the given offset
};
#endif
diff --git a/scumm/smush/brenderer.cpp b/scumm/smush/brenderer.cpp
index 1efa8be5b0..64f97bb9c5 100644
--- a/scumm/smush/brenderer.cpp
+++ b/scumm/smush/brenderer.cpp
@@ -54,7 +54,7 @@ bool BaseRenderer::initFrame(const Point & p) {
return true;
}
-char * BaseRenderer::lockFrame(int frame) {
+char * BaseRenderer::lockFrame(int32 frame) {
_frame = frame;
if(!_data) error("no allocated image buffer in lock_frame");
return _data;
diff --git a/scumm/smush/brenderer.h b/scumm/smush/brenderer.h
index e45b3e13eb..434c18b8a0 100644
--- a/scumm/smush/brenderer.h
+++ b/scumm/smush/brenderer.h
@@ -1,4 +1,4 @@
-/* ScummVM - Scumm Interpreter
+/* ScummVM - Scumm int32erpreter
* Copyright (C) 2001/2002 The ScummVM project
*
* This program is free software; you can redistribute it and/or
@@ -36,34 +36,34 @@ class BaseRenderer : public Renderer {
private:
Palette _pal; //!< The current palette
char * _data; //!< The current frame buffer
- int _frame; //!< The current frame number
- int _nbframes; //!< The number of frames in the animation
- int _width; //!< The current frame's width
- int _height; //!< The current frame's height
+ int32 _frame; //!< The current frame number
+ int32 _nbframes; //!< The number of frames in the animation
+ int32 _width; //!< The current frame's width
+ int32 _height; //!< The current frame's height
const char * _fname; //!< The filename of the animation being played
protected:
- virtual void save(int frame = -1) = 0;
+ virtual void save(int32 frame = -1) = 0;
protected:
const char * getFilename() const { return _fname; }; //!< accessor for animation filename
- int getNbframes() const { return _nbframes; }; //!< accessor for number of frames
- int getWidth() const { return _width; }; //!< accessor for current width
- int getHeight() const { return _height; }; //!< accessor for current height
+ int32 getNbframes() const { return _nbframes; }; //!< accessor for number of frames
+ int32 getWidth() const { return _width; }; //!< accessor for current width
+ int32 getHeight() const { return _height; }; //!< accessor for current height
const Palette & pal() const { return _pal; }; //!< accessor for current palette
const char * data() const { return _data; }; //!< accessor for current frame buffer
void clean(); //!< memory cleanup (deletes frame buffer)
- void setFrame(int f) { _frame = f; }; //!< allows to change the frame number
+ void setFrame(int32 f) { _frame = f; }; //!< allows to change the frame number
public:
- int getFrame() const { return _frame; }; //!< accessor for current frame number
+ int32 getFrame() const { return _frame; }; //!< accessor for current frame number
BaseRenderer();
virtual ~BaseRenderer();
virtual bool initFrame(const Point & size);
- virtual char * lockFrame(int frame);
+ virtual char * lockFrame(int32 frame);
virtual bool unlockFrame();
virtual bool flipFrame();
virtual bool setPalette(const Palette & pal);
- virtual bool startDecode(const char * fname, int version, int nbframes) { _fname = fname; _nbframes = nbframes; return true; }
+ virtual bool startDecode(const char * fname, int32 version, int32 nbframes) { _fname = fname; _nbframes = nbframes; return true; }
virtual Mixer * getMixer() { return 0; };
virtual bool prematureClose() { return false; };
};
@@ -75,11 +75,11 @@ public:
*/
class NullRenderer : public BaseRenderer {
protected:
- void save(int frame = -1) {};
+ void save(int32 frame = -1) {};
public:
NullRenderer() {};
virtual ~NullRenderer() {};
- bool wait(int ms) { return true; };
+ bool wait(int32 ms) { return true; };
};
#endif
diff --git a/scumm/smush/channel.h b/scumm/smush/channel.h
index 09a006356f..af5a078540 100644
--- a/scumm/smush/channel.h
+++ b/scumm/smush/channel.h
@@ -1,4 +1,4 @@
-/* ScummVM - Scumm Interpreter
+/* ScummVM - Scumm int32erpreter
* Copyright (C) 2001/2002 The ScummVM project
*
* This program is free software; you can redistribute it and/or
@@ -37,69 +37,69 @@
class Chunk;
class ContChunk;
-/*! @brief interface for a sound channel (a track)
+/*! @brief int32erface for a sound channel (a track)
- This is the interface for sound channels.
+ This is the int32erface for sound channels.
*/
class _Channel {
public:
virtual ~_Channel() {};
// called by the smush_player
- virtual bool appendData(Chunk & b, int size) = 0;
- virtual bool setParameters(int, int, int, int) = 0;
- virtual bool checkParameters(int, int, int, int, int) = 0;
+ virtual bool appendData(Chunk & b, int32 size) = 0;
+ virtual bool setParameters(int32, int32, int32, int32) = 0;
+ virtual bool checkParameters(int32, int32, int32, int32, int32) = 0;
// called by the mixer
virtual bool isTerminated() const = 0;
- virtual int availableSoundData() const = 0;
- virtual void getSoundData(short * sound_buffer, int size) = 0; // size is in sample
- virtual void getSoundData(char * sound_buffer, int size) = 0;
- virtual bool getParameters(int &rate, bool &stereo, bool &is_16bit) = 0;
- virtual int getTrackIdentifier() const = 0;
+ virtual int32 availableSoundData() const = 0;
+ virtual void getSoundData(int16 * sound_buffer, int32 size) = 0; // size is in sample
+ virtual void getSoundData(int8 * sound_buffer, int32 size) = 0;
+ virtual bool getParameters(int32 &rate, bool &stereo, bool &is_16bit) = 0;
+ virtual int32 getTrackIdentifier() const = 0;
};
class SaudChannel : public _Channel {
private:
- int _track; //!< The track identifier
- int _nbframes; //!< number of frames of the track (unused)
- int _dataSize; //!< the size of the sound buffer
- int _frequency; //!< the frequency target of the track (always 22050)
+ int32 _track; //!< The track identifier
+ int32 _nbframes; //!< number of frames of the track (unused)
+ int32 _dataSize; //!< the size of the sound buffer
+ int32 _frequency; //!< the frequency target of the track (always 22050)
bool _inData; //!< are we processing data ?
bool _markReached; //!< set to \c true when the SMRK tag is reached
- int _flags; //!< current flags of the track (unused)
- int _volume; //!< the current track volume
- int _balance; //!< the current track balance
- int _index; //!< the current PSAD index (for coherency checking)
- short _voltable[2][256]; //!< the precalculated volume table (stereo 16 bits)
- unsigned char * _tbuffer; //!< data temporary buffer
- int _tbufferSize; //!< temporary buffer size
- unsigned char * _sbuffer; //!< sound buffer
- int _sbufferSize; //!< sound buffer size
+ int32 _flags; //!< current flags of the track (unused)
+ int32 _volume; //!< the current track volume
+ int32 _balance; //!< the current track balance
+ int32 _index; //!< the current PSAD index (for coherency checking)
+ int16 _voltable[2][256]; //!< the precalculated volume table (stereo 16 bits)
+ byte * _tbuffer; //!< data temporary buffer
+ int32 _tbufferSize; //!< temporary buffer size
+ byte * _sbuffer; //!< sound buffer
+ int32 _sbufferSize; //!< sound buffer size
protected:
void handleStrk(Chunk & c);
void handleSmrk(Chunk & c);
void handleShdr(Chunk & c);
- bool handleSubTags(int & offset);
+ bool handleSubTags(int32 & offset);
bool processBuffer();
void recalcVolumeTable();
public:
- SaudChannel(int track, int freq);
+ SaudChannel(int32 track, int32 freq);
virtual ~SaudChannel();
bool isTerminated() const;
- bool setParameters(int duration, int flags, int vol1, int vol2);
- bool checkParameters(int index, int duration, int flags, int vol1, int vol2);
- bool appendData(Chunk & b, int size);
- int availableSoundData() const;
- void getSoundData(short * sound_buffer, int size);
- void getSoundData(char * sound_buffer, int size) { error("16bit request for SAUD channel should never happen"); };
- bool getParameters(int &rate, bool &stereo, bool &is_16bit) {
+ bool setParameters(int32 duration, int32 flags, int32 vol1, int32 vol2);
+ bool checkParameters(int32 index, int32 duration, int32 flags, int32 vol1, int32 vol2);
+ bool appendData(Chunk & b, int32 size);
+ int32 availableSoundData() const;
+ void getSoundData(int16 * sound_buffer, int32 size);
+ void getSoundData(int8 * sound_buffer, int32 size) { error("16bit request for SAUD channel should never happen"); };
+ bool getParameters(int32 &rate, bool &stereo, bool &is_16bit) {
rate = _frequency;
stereo = true;
is_16bit = true;
return true;
};
- virtual int getTrackIdentifier() const { return _track; };
+ virtual int32 getTrackIdentifier() const { return _track; };
};
/*! @brief class for a IACT sound ::channel (a The Dig track)
@@ -110,22 +110,22 @@ public:
*/
class ImuseChannel : public _Channel {
private:
- int _track; //!< the track number
- unsigned char * _tbuffer; //!< data temporary buffer
- int _tbufferSize; //!< temporary buffer size
- unsigned char * _sbuffer; //!< sound buffer
- int _sbufferSize; //!< sound buffer size
- int _srbufferSize;
- int _frequency; //!< the target frequency of the ::mixer
- int _dataSize; //!< remaining size of sound data in the iMUS buffer
+ int32 _track; //!< the track number
+ byte * _tbuffer; //!< data temporary buffer
+ int32 _tbufferSize; //!< temporary buffer size
+ byte * _sbuffer; //!< sound buffer
+ int32 _sbufferSize; //!< sound buffer size
+ int32 _srbufferSize;
+ int32 _frequency; //!< the target frequency of the ::mixer
+ int32 _dataSize; //!< remaining size of sound data in the iMUS buffer
bool _inData;
- int _bitsize; //!< the bitsize of the original data
- int _rate; //!< the sampling rate of the original data
- int _channels; //!< the number of channels of the original data
+ int32 _bitsize; //!< the bitsize of the original data
+ int32 _rate; //!< the sampling rate of the original data
+ int32 _channels; //!< the number of channels of the original data
protected:
- int decode(int size, int &ret);
+ int32 decode(int32 size, int32 &ret);
void decode();
bool processBuffer();
bool handleMap(Chunk &);
@@ -133,25 +133,25 @@ protected:
bool handleText(Chunk &);
bool handleRegion(Chunk &);
bool handleStop(Chunk &);
- bool handleSubTags(int & offset);
+ bool handleSubTags(int32 & offset);
public:
- ImuseChannel(int track, int freq);
+ ImuseChannel(int32 track, int32 freq);
virtual ~ImuseChannel();
bool isTerminated() const;
- bool setParameters(int nbframes, int size, int unk1, int unk2);
- bool checkParameters(int index, int nbframes, int size, int unk1, int unk2);
- bool appendData(Chunk & b, int size);
- int availableSoundData() const;
- void getSoundData(short * sound_buffer, int size);
- void getSoundData(char * sound_buffer, int size);
- bool getParameters(int &rate, bool &stereo, bool &is_16bit) {
+ bool setParameters(int32 nbframes, int32 size, int32 unk1, int32 unk2);
+ bool checkParameters(int32 index, int32 nbframes, int32 size, int32 unk1, int32 unk2);
+ bool appendData(Chunk & b, int32 size);
+ int32 availableSoundData() const;
+ void getSoundData(int16 * sound_buffer, int32 size);
+ void getSoundData(int8 * sound_buffer, int32 size);
+ bool getParameters(int32 &rate, bool &stereo, bool &is_16bit) {
rate = _frequency;
stereo = (_channels == 2);
is_16bit = (_bitsize > 8);
return true;
};
- virtual int getTrackIdentifier() const { return _track; };
+ virtual int32 getTrackIdentifier() const { return _track; };
};
#endif
diff --git a/scumm/smush/chunk.cpp b/scumm/smush/chunk.cpp
index c620c9d5d4..76163ebec2 100644
--- a/scumm/smush/chunk.cpp
+++ b/scumm/smush/chunk.cpp
@@ -1,4 +1,4 @@
-/* ScummVM - Scumm Interpreter
+/* ScummVM - Scumm int32erpreter
* Copyright (C) 2001/2002 The ScummVM project
*
* This program is free software; you can redistribute it and/or
@@ -32,8 +32,8 @@
class FilePtr {
char * _filename;
FILE * _ifs;
- int _refcount;
- int _curPos;
+ int32 _refcount;
+ int32 _curPos;
public:
FilePtr(const char * fname) : _refcount(1), _curPos(0) {
debug(9, "FilePtr created for %s", fname);
@@ -46,17 +46,17 @@ public:
free(_filename);
fclose(_ifs);
}
- int tell() {
+ int32 tell() {
return _curPos;
}
- bool seek(int pos) {
+ bool seek(int32 pos) {
if(pos != _curPos) {
fseek(_ifs, pos, SEEK_SET);
_curPos = pos;
}
return true;
}
- bool read(void * ptr, int size) {
+ bool read(void * ptr, int32 size) {
fread(ptr, size, 1, _ifs);
_curPos += size;
return true;
@@ -101,7 +101,7 @@ Chunk::type FileChunk::getType() const {
return _type;
}
-unsigned int FileChunk::getSize() const {
+uint32 FileChunk::getSize() const {
return _size;
}
@@ -110,7 +110,7 @@ Chunk * FileChunk::subBlock() {
ptr->_data = _data;
_data->incRef();
_data->seek(_offset + _curPos);
- unsigned int temp;
+ uint32 temp;
_data->read(&temp, 4);
ptr->_type = TO_BE_32(temp);
_data->read(&temp, 4);
@@ -125,22 +125,22 @@ bool FileChunk::eof() const {
return _curPos >= _size;
}
-unsigned int FileChunk::tell() const {
+uint32 FileChunk::tell() const {
return _curPos;
}
-bool FileChunk::seek(int delta, seek_type dir) {
+bool FileChunk::seek(int32 delta, seek_type dir) {
switch(dir) {
case seek_cur:
_curPos += delta;
break;
case seek_start:
if(delta < 0) error("invalid seek request");
- _curPos = (unsigned int)delta;
+ _curPos = (uint32)delta;
break;
case seek_end:
if(delta > 0 || (_size + delta) < 0) error("invalid seek request");
- _curPos = (unsigned int)(_size + delta);
+ _curPos = (uint32)(_size + delta);
break;
}
if(_curPos > _size) {
@@ -149,7 +149,7 @@ bool FileChunk::seek(int delta, seek_type dir) {
return true;
}
-bool FileChunk::read(void * buffer, unsigned int size) {
+bool FileChunk::read(void * buffer, uint32 size) {
if(size <= 0 || (_curPos + size) > _size) error("invalid buffer read request");
_data->seek(_offset + _curPos);
_data->read(buffer, size);
@@ -166,43 +166,43 @@ int8 FileChunk::getChar() {
return buffer;
}
-unsigned char FileChunk::getByte() {
+byte FileChunk::getByte() {
if(_curPos >= _size) error("invalid byte read request");
_data->seek(_offset + _curPos);
- unsigned char buffer;
+ byte buffer;
_data->read(&buffer, sizeof(buffer));
_curPos+= sizeof(buffer);
return buffer;
}
-short FileChunk::getShort() {
- unsigned short buffer = getWord();
- return *((short*)&buffer);
+int16 FileChunk::getShort() {
+ int16 buffer = getWord();
+ return *((int16*)&buffer);
}
-unsigned short FileChunk::getWord() {
+uint16 FileChunk::getWord() {
if(_curPos >= _size - 1) error("invalid word read request");
_data->seek(_offset + _curPos);
- unsigned short buffer;
+ uint16 buffer;
_data->read(&buffer, sizeof(buffer));
_curPos+= sizeof(buffer);
return TO_LE_16(buffer);
}
-unsigned int FileChunk::getDword() {
+uint32 FileChunk::getDword() {
if(_curPos >= _size - 3) error("invalid dword read request");
_data->seek(_offset + _curPos);
- unsigned int buffer;
+ uint32 buffer;
_data->read(&buffer, sizeof(buffer));
_curPos+= sizeof(buffer);
return TO_LE_32(buffer);
}
-ContChunk::ContChunk(char * data) {
- if(data == 0) error("Chunk() called with NULL pointer");
+ContChunk::ContChunk(byte * data) {
+ if(data == 0) error("Chunk() called with NULL point32er");
_type = (Chunk::type)READ_BE_UINT32(data);
- _size = READ_BE_UINT32(data+4);
- _data = data + sizeof(Chunk::type) + sizeof(unsigned int);
+ _size = READ_BE_UINT32(data + 4);
+ _data = data + sizeof(Chunk::type) + sizeof(uint32);
_curPos = 0;
}
@@ -210,13 +210,13 @@ Chunk::type ContChunk::getType() const {
return _type;
}
-unsigned int ContChunk::getSize() const {
+uint32 ContChunk::getSize() const {
return _size;
}
Chunk * ContChunk::subBlock() {
ContChunk * ptr = new ContChunk(_data + _curPos);
- seek(sizeof(Chunk::type) + sizeof(unsigned int) + ptr->getSize());
+ seek(sizeof(Chunk::type) + sizeof(uint32) + ptr->getSize());
return ptr;
}
@@ -224,22 +224,22 @@ bool ContChunk::eof() const {
return _curPos >= _size;
}
-unsigned int ContChunk::tell() const {
+uint32 ContChunk::tell() const {
return _curPos;
}
-bool ContChunk::seek(int delta, seek_type dir) {
+bool ContChunk::seek(int32 delta, seek_type dir) {
switch(dir) {
case seek_cur:
_curPos += delta;
break;
case seek_start:
if(delta < 0) error("invalid seek request");
- _curPos = (unsigned int)delta;
+ _curPos = (uint32)delta;
break;
case seek_end:
if(delta > 0 || (_size + delta) < 0) error("invalid seek request");
- _curPos = (unsigned int)(_size + delta);
+ _curPos = (uint32)(_size + delta);
break;
}
if(_curPos > _size) {
@@ -248,7 +248,7 @@ bool ContChunk::seek(int delta, seek_type dir) {
return true;
}
-bool ContChunk::read(void * buffer, unsigned int size) {
+bool ContChunk::read(void * buffer, uint32 size) {
if(size <= 0 || (_curPos + size) > _size) error("invalid buffer read request");
memcpy(buffer, _data + _curPos, size);
_curPos += size;
@@ -260,29 +260,29 @@ int8 ContChunk::getChar() {
return _data[_curPos++];
}
-unsigned char ContChunk::getByte() {
+byte ContChunk::getByte() {
if(_curPos >= _size) error("invalid byte read request");
- unsigned char * ptr = (unsigned char *)(_data + _curPos);
+ byte * ptr = (byte *)(_data + _curPos);
_curPos += 1;
return *ptr;
}
-short ContChunk::getShort() {
- if(_curPos >= _size - 1) error("invalid short read request");
- unsigned short buffer = getWord();
- return *((short*)&buffer);
+int16 ContChunk::getShort() {
+ if(_curPos >= _size - 1) error("invalid int16 read request");
+ int16 buffer = getWord();
+ return *((int16*)&buffer);
}
-unsigned short ContChunk::getWord() {
+uint16 ContChunk::getWord() {
if(_curPos >= _size - 1) error("invalid word read request");
- unsigned short * ptr = (unsigned short *)(_data + _curPos);
+ uint16 * ptr = (uint16 *)(_data + _curPos);
_curPos += 2;
return READ_LE_UINT16(ptr);
}
-unsigned int ContChunk::getDword() {
+uint32 ContChunk::getDword() {
if(_curPos >= _size - 3) error("invalid dword read request");
- unsigned int * ptr = (unsigned int *)(_data + _curPos);
+ uint32 * ptr = (uint32 *)(_data + _curPos);
_curPos += 4;
return READ_LE_UINT32(ptr);
}
diff --git a/scumm/smush/chunk.h b/scumm/smush/chunk.h
index 84dba0ca10..893ede35f8 100644
--- a/scumm/smush/chunk.h
+++ b/scumm/smush/chunk.h
@@ -34,7 +34,7 @@ class Chunk {
public:
enum seek_type { seek_start, seek_end, seek_cur };
virtual ~Chunk() {};
- typedef unsigned int type; //!< type of a Chunk (i.e. The first 4byte field of the Chunk structure).
+ typedef uint32 type; //!< type of a Chunk (i.e. The first 4byte field of the Chunk structure).
/*! @brief convert a type to a string
Utility function that convert a type to a string.
@@ -46,17 +46,17 @@ public:
static const char * ChunkString(type t);
virtual type getType() const = 0; //!< return the type of the Chunk
- virtual unsigned int getSize() const = 0; //!< return the size of the Chunk
+ virtual uint32 getSize() const = 0; //!< return the size of the Chunk
virtual Chunk * subBlock() = 0; //!< extract a subChunk from the current read position
virtual bool eof() const = 0; //!< is the Chunk completely read ?
- virtual unsigned int tell() const = 0; //!< get the Chunk current read position
- virtual bool seek(int delta, seek_type dir = seek_cur) = 0; //!< move the current read position inside the Chunk
- virtual bool read(void * buffer, unsigned int size) = 0; //!< read some data for the current read position
+ virtual uint32 tell() const = 0; //!< get the Chunk current read position
+ virtual bool seek(int32 delta, seek_type dir = seek_cur) = 0; //!< move the current read position inside the Chunk
+ virtual bool read(void * buffer, uint32 size) = 0; //!< read some data for the current read position
virtual int8 getChar() = 0; //!< extract the character at the current read position
- virtual unsigned char getByte() = 0; //!< extract the byte at the current read position
- virtual short getShort() = 0; //!< extract the short at the current read position
- virtual unsigned short getWord() = 0; //!< extract the word at the current read position
- virtual unsigned int getDword()= 0; //!< extract the dword at the current read position
+ virtual byte getByte() = 0; //!< extract the byte at the current read position
+ virtual int16 getShort() = 0; //!< extract the short at the current read position
+ virtual uint16 getWord() = 0; //!< extract the word at the current read position
+ virtual uint32 getDword()= 0; //!< extract the dword at the current read position
};
class FilePtr;
@@ -70,26 +70,26 @@ class FileChunk : public Chunk {
private:
FilePtr * _data;
type _type;
- unsigned int _size;
- unsigned int _offset;
- unsigned int _curPos;
+ uint32 _size;
+ uint32 _offset;
+ uint32 _curPos;
protected:
FileChunk();
public:
FileChunk(const char * fname);
virtual ~FileChunk();
type getType() const;
- unsigned int getSize() const;
+ uint32 getSize() const;
Chunk * subBlock();
bool eof() const;
- unsigned int tell() const;
- bool seek(int delta, seek_type dir = seek_cur);
- bool read(void * buffer, unsigned int size);
+ uint32 tell() const;
+ bool seek(int32 delta, seek_type dir = seek_cur);
+ bool read(void * buffer, uint32 size);
int8 getChar();
- unsigned char getByte();
+ byte getByte();
short getShort();
- unsigned short getWord();
- unsigned int getDword();
+ uint16 getWord();
+ uint32 getDword();
};
/*! @brief memory based ::Chunk
@@ -98,24 +98,24 @@ public:
*/
class ContChunk : public Chunk {
private:
- char * _data;
+ byte * _data;
Chunk::type _type;
- unsigned int _size;
- unsigned int _curPos;
+ uint32 _size;
+ uint32 _curPos;
public:
- ContChunk(char * data);
+ ContChunk(byte * data);
Chunk::type getType() const;
- unsigned int getSize() const;
+ uint32 getSize() const;
Chunk * subBlock();
bool eof() const;
- unsigned int tell() const;
- bool seek(int delta, seek_type dir = seek_cur);
- bool read(void * buffer, unsigned int size);
+ uint32 tell() const;
+ bool seek(int32 delta, seek_type dir = seek_cur);
+ bool read(void * buffer, uint32 size);
int8 getChar();
- unsigned char getByte();
- short getShort();
- unsigned short getWord();
- unsigned int getDword();
+ byte getByte();
+ int16 getShort();
+ uint16 getWord();
+ uint32 getDword();
};
#endif
diff --git a/scumm/smush/codec1.cpp b/scumm/smush/codec1.cpp
index 857428d595..14327af931 100644
--- a/scumm/smush/codec1.cpp
+++ b/scumm/smush/codec1.cpp
@@ -28,10 +28,10 @@ Codec1Decoder::~Codec1Decoder() {
}
bool Codec1Decoder::decode(Blitter & dst, Chunk & src) {
- int val;
- int size_line;
- int code, length;
- int h, height = getRect().height();
+ byte val;
+ int32 size_line;
+ int32 code, length;
+ int32 h, height = getRect().height();
for(h = 0; h < height; h++) {
size_line = src.getWord(); // size of compressed line !
@@ -48,8 +48,10 @@ bool Codec1Decoder::decode(Blitter & dst, Chunk & src) {
if(code & 1) {
val = src.getByte();
size_line --;
- if(val) dst.put(val, length);
- else dst.advance(length);
+ if(val)
+ dst.put(val, length);
+ else
+ dst.advance(length);
#ifdef DEBUG_CODEC1
debug(7, "codec1 : blitting %d times %d", length, val);
#endif
@@ -60,7 +62,8 @@ bool Codec1Decoder::decode(Blitter & dst, Chunk & src) {
#endif
while(length--) {
val = src.getByte();
- if(val) dst.put(val);
+ if(val)
+ dst.put(val);
else dst.advance();
}
}
@@ -68,7 +71,7 @@ bool Codec1Decoder::decode(Blitter & dst, Chunk & src) {
}
#ifdef DEBUG_CODEC1
if(!src.eof()) {
- int len = src.getSize() - src.tell();
+ int32 len = src.getSize() - src.tell();
debug(7, "codec1: remaining length after decode == %d", len);
}
#endif
diff --git a/scumm/smush/codec37.cpp b/scumm/smush/codec37.cpp
index bb59606c34..16fe44a411 100644
--- a/scumm/smush/codec37.cpp
+++ b/scumm/smush/codec37.cpp
@@ -25,7 +25,7 @@
#include "blitter.h"
#include <assert.h>
-#include <string.h> // for memset
+#include <string.h>
bool Codec37Decoder::initSize(const Point & p, const Rect & r) {
if(r.width() != getRect().width() && r.height() != getRect().height()) {
@@ -37,13 +37,13 @@ bool Codec37Decoder::initSize(const Point & p, const Rect & r) {
return false;
Decoder::initSize(p, r);
clean();
- int frame_size = getRect().width() * getRect().height();
+ int32 frame_size = getRect().width() * getRect().height();
_deltaSize = frame_size * 2 + DELTA_ADD * 4;
- _deltaBuf = new unsigned char[_deltaSize];
+ _deltaBuf = new byte[_deltaSize];
if(_deltaBuf == 0) error("unable to allocate decoder buffer");
_deltaBufs[0] = _deltaBuf + DELTA_ADD;
_deltaBufs[1] = _deltaBuf + frame_size + DELTA_ADD * 3;
- _offsetTable = new short[255];
+ _offsetTable = new int16[255];
if(_offsetTable == 0) error("unable to allocate decoder offset table");
_tableLastPitch = -1;
_tableLastIndex = -1;
@@ -84,8 +84,8 @@ Codec37Decoder::~Codec37Decoder() {
clean();
}
-void Codec37Decoder::maketable(int pitch, int index) {
- static const signed char maketable_bytes[] = {
+void Codec37Decoder::maketable(int32 pitch, int32 index) {
+ static const int8 maketable_bytes[] = {
0, 0, 1, 0, 2, 0, 3, 0, 5, 0, 8, 0, 13, 0, 21, 0,
-1, 0, -2, 0, -3, 0, -5, 0, -8, 0, -13, 0, -17, 0, -21, 0,
0, 1, 1, 1, 2, 1, 3, 1, 5, 1, 8, 1, 13, 1, 21, 1,
@@ -192,22 +192,22 @@ void Codec37Decoder::maketable(int pitch, int index) {
_tableLastPitch = pitch;
_tableLastIndex = index;
index *= 255;
- assert(index + 254 < (int)(sizeof(maketable_bytes) / 2));
+ assert(index + 254 < (int32)(sizeof(maketable_bytes) / 2));
- for (int i = 0; i < 255; i++) {
- int j = (i + index) << 1; // * 2
+ for (int32 i = 0; i < 255; i++) {
+ int32 j = (i + index) << 1; // * 2
_offsetTable[i] = maketable_bytes[j + 1] * pitch + maketable_bytes[j];
}
}
-void Codec37Decoder::proc1(Blitter & dst, Chunk & src, int next_offs, int bw, int bh, int size) {
- unsigned char * decoded = new unsigned char[size];
- int w = 0;
+void Codec37Decoder::proc1(Blitter & dst, Chunk & src, int32 next_offs, int32 bw, int32 bh, int32 size) {
+ byte * decoded = new byte[size];
+ int32 w = 0;
while(!src.eof()) {
- int code = src.getByte();
- int length = (code >> 1) + 1;
+ int32 code = src.getByte();
+ int32 length = (code >> 1) + 1;
if (code & 1) {
- unsigned char val = src.getByte();
+ byte val = src.getByte();
while(length--)
decoded[w++] = val;
} else {
@@ -219,7 +219,7 @@ void Codec37Decoder::proc1(Blitter & dst, Chunk & src, int next_offs, int bw, in
assert(w == size);
w = 0;
// Now we have our stream ready...
- for(int i = 0; i < size; i++) {
+ for(int32 i = 0; i < size; i++) {
if(decoded[i] == 0xFF) {
dst.putBlock(decoded + i + 1);
i += 16;
@@ -234,14 +234,14 @@ void Codec37Decoder::proc1(Blitter & dst, Chunk & src, int next_offs, int bw, in
delete []decoded;
}
-void Codec37Decoder::proc2(Blitter & dst, Chunk & src, int size) { // This is codec1 like...
+void Codec37Decoder::proc2(Blitter & dst, Chunk & src, int32 size) { // This is codec1 like...
#ifdef DEBUG_CODEC37_PROC2
- int decoded_size = 0;
- int coded_size = 0;
+ int32 decoded_size = 0;
+ int32 coded_size = 0;
#endif
do {
- int code = src.getByte();
- int length = (code >> 1) + 1;
+ int32 code = src.getByte();
+ int32 length = (code >> 1) + 1;
size -= length;
#ifdef DEBUG_CODEC37_PROC2
decoded_size += length;
@@ -258,11 +258,11 @@ void Codec37Decoder::proc2(Blitter & dst, Chunk & src, int size) { // This is co
} while (size);
}
-void Codec37Decoder::proc3WithFDFE(Blitter & dst, Chunk & src, int next_offs, int bw, int bh) {
+void Codec37Decoder::proc3WithFDFE(Blitter & dst, Chunk & src, int32 next_offs, int32 bw, int32 bh) {
do {
- int i = bw;
+ int32 i = bw;
do {
- int code = src.getByte();
+ int32 code = src.getByte();
if (code == 0xFD) {
#ifdef USE_COLOR_CODE_FOR_BLOCK
dst.putBlock(expand(1));
@@ -293,11 +293,11 @@ void Codec37Decoder::proc3WithFDFE(Blitter & dst, Chunk & src, int next_offs, in
} while (--bh);
}
-void Codec37Decoder::proc3WithoutFDFE(Blitter & dst, Chunk & src, int next_offs, int bw, int bh) {
+void Codec37Decoder::proc3WithoutFDFE(Blitter & dst, Chunk & src, int32 next_offs, int32 bw, int32 bh) {
do {
- int i = bw;
+ int32 i = bw;
do {
- int code = src.getByte();
+ int32 code = src.getByte();
if (code == 0xFF) {
#ifdef USE_COLOR_CODE_FOR_BLOCK
dst.putBlock(expand(5));
@@ -316,11 +316,11 @@ void Codec37Decoder::proc3WithoutFDFE(Blitter & dst, Chunk & src, int next_offs,
} while (--bh);
}
-void Codec37Decoder::proc4(Blitter & dst, Chunk & src, int next_offs, int bw, int bh) {
+void Codec37Decoder::proc4(Blitter & dst, Chunk & src, int32 next_offs, int32 bw, int32 bh) {
do {
- int i = bw;
+ int32 i = bw;
do {
- int code = src.getByte();
+ int32 code = src.getByte();
if (code == 0xFD) {
#ifdef USE_COLOR_CODE_FOR_BLOCK
dst.putBlock(expand(7));
@@ -340,8 +340,8 @@ void Codec37Decoder::proc4(Blitter & dst, Chunk & src, int next_offs, int bw, in
dst.putBlock(src);
#endif
} else if (code == 0x00) {
- int length = src.getByte() + 1;
- for (int l = 0; l < length; l++) {
+ int32 length = src.getByte() + 1;
+ for (int32 l = 0; l < length; l++) {
#ifdef USE_COLOR_CODE_FOR_BLOCK
dst.putBlock(expand(10));
#else
@@ -369,24 +369,24 @@ void Codec37Decoder::proc4(Blitter & dst, Chunk & src, int next_offs, int bw, in
}
bool Codec37Decoder::decode(Blitter & dst, Chunk & src) {
- int width = getRect().width();
- int height = getRect().height();
- int bw = (width + 3) >> 2, bh = (height + 3) >> 2;
- int pitch = bw << 2;
+ int32 width = getRect().width();
+ int32 height = getRect().height();
+ int32 bw = (width + 3) >> 2, bh = (height + 3) >> 2;
+ int32 pitch = bw << 2;
#ifdef DEBUG_CODEC37
debug(7, "codec37::decode() : width == %d : height == %d : pitch == %d : _prevSeqNb == %d",
width, height, pitch, _prevSeqNb);
#endif
- int code = src.getByte(); // 0 -> 1 (1)
- int index = src.getByte(); // 1 -> 2 (1)
- unsigned short seq_nb = src.getWord(); // 2 -> 4 (2)
- unsigned int decoded_size = src.getDword(); // 4 -> 8 (4)
+ int32 code = src.getByte(); // 0 -> 1 (1)
+ int32 index = src.getByte(); // 1 -> 2 (1)
+ uint16 seq_nb = src.getWord(); // 2 -> 4 (2)
+ uint32 decoded_size = src.getDword(); // 4 -> 8 (4)
#ifdef DEBUG_CODEC37
- unsigned int coded_size = src.getDword(); // 8 -> 12 (4)
+ uint32 coded_size = src.getDword(); // 8 -> 12 (4)
#else
src.seek(4);
#endif
- unsigned int mask_flag = src.getDword(); // 12 -> 16 (4)
+ uint32 mask_flag = src.getDword(); // 12 -> 16 (4)
#ifdef DEBUG_CODEC37
debug(7, "codec37::decode() : code == %d : index == %d : seq_nb == %d : decoded_size == %d : coded_size == %d : mask_flag == %d",
code, index, seq_nb, decoded_size, coded_size, mask_flag);
@@ -396,7 +396,7 @@ bool Codec37Decoder::decode(Blitter & dst, Chunk & src) {
assert(seq_nb && _prevSeqNb + 1 == seq_nb);
if (seq_nb & 1 || !(mask_flag & 1)) _curtable ^= 1;
}
- Blitter blit((char *)_deltaBufs[_curtable], Point(width, height), Rect(0, 0, width, height));
+ Blitter blit((byte *)_deltaBufs[_curtable], Point(width, height), Rect(0, 0, width, height));
switch(code) {
case 0:
memset(_deltaBuf, 0, _deltaBufs[_curtable] - _deltaBuf);
@@ -426,7 +426,7 @@ bool Codec37Decoder::decode(Blitter & dst, Chunk & src) {
#endif
break;
}
- dst.blit((char*)_deltaBufs[_curtable], width * height);
+ dst.blit((byte *)_deltaBufs[_curtable], width * height);
_prevSeqNb = seq_nb;
return true;
}
diff --git a/scumm/smush/codec37.h b/scumm/smush/codec37.h
index a60d80a268..548615b80e 100644
--- a/scumm/smush/codec37.h
+++ b/scumm/smush/codec37.h
@@ -54,14 +54,14 @@
class Codec37Decoder : public Decoder {
private:
- int _deltaSize;
- unsigned char * _deltaBufs[2];
- unsigned char * _deltaBuf;
- short * _offsetTable;
- int _curtable;
- unsigned short _prevSeqNb;
- int _tableLastPitch;
- int _tableLastIndex;
+ int32 _deltaSize;
+ byte * _deltaBufs[2];
+ byte * _deltaBuf;
+ int16 * _offsetTable;
+ int32 _curtable;
+ uint16 _prevSeqNb;
+ int32 _tableLastPitch;
+ int32 _tableLastIndex;
public:
bool initSize(const Point &, const Rect &);
@@ -69,16 +69,16 @@ public:
void clean();
virtual ~Codec37Decoder();
protected:
- static inline unsigned int expand(unsigned char b) {
- unsigned int r = b | (b << 8);
+ static inline uint32 expand(byte b) {
+ uint32 r = b | (b << 8);
return r | (r << 16);
}
- void maketable(int, int);
- void proc1(Blitter &, Chunk &, int, int, int, int);
- void proc2(Blitter &, Chunk &, int);
- void proc3WithFDFE(Blitter &, Chunk &, int, int, int);
- void proc3WithoutFDFE(Blitter &, Chunk &, int, int, int);
- void proc4(Blitter &, Chunk &, int, int, int);
+ void maketable(int32, int32);
+ void proc1(Blitter &, Chunk &, int32, int32, int32, int32);
+ void proc2(Blitter &, Chunk &, int32);
+ void proc3WithFDFE(Blitter &, Chunk &, int32, int32, int32);
+ void proc3WithoutFDFE(Blitter &, Chunk &, int32, int32, int32);
+ void proc4(Blitter &, Chunk &, int32, int32, int32);
public:
bool decode(Blitter &, Chunk &);
};
diff --git a/scumm/smush/codec44.cpp b/scumm/smush/codec44.cpp
index be3ff533bb..5e8ee1c081 100644
--- a/scumm/smush/codec44.cpp
+++ b/scumm/smush/codec44.cpp
@@ -25,10 +25,10 @@
#include "blitter.h"
bool Codec44Decoder::decode(Blitter & dst, Chunk & src) {
- int size_line;
- int num;
- int w, width = getRect().width() + 1;
- int h, height = getRect().height() + 1;
+ int32 size_line;
+ int32 num;
+ int32 w, width = getRect().width() + 1;
+ int32 h, height = getRect().height() + 1;
bool zero;
#ifdef DEBUG_CODEC44
debug(7, "codec44 : %dx%d", width, height);
diff --git a/scumm/smush/codec47.cpp b/scumm/smush/codec47.cpp
index 16f2145ec9..f1ae149e26 100644
--- a/scumm/smush/codec47.cpp
+++ b/scumm/smush/codec47.cpp
@@ -28,18 +28,18 @@ DumpDecoder::~DumpDecoder() {
}
bool DumpDecoder::decode(Blitter & dst, Chunk & src) {
- int i = 0;
- int seq = src.getWord();
- int codec = src.getByte();
- int flags = src.getByte();
- int unknown[22];
+ int32 i = 0;
+ int32 seq = src.getWord();
+ int32 codec = src.getByte();
+ int32 flags = src.getByte();
+ int32 unknown[22];
for(i = 0; i < 0; i++) {
unknown[i] = src.getByte();
}
if(codec == 5 || codec == 1) {
do {
- int code = src.getByte();
- int length = (code >> 1) + 1;
+ int32 code = src.getByte();
+ int32 length = (code >> 1) + 1;
if (code & 1)
dst.put(src.getChar(), length);
else
diff --git a/scumm/smush/color.cpp b/scumm/smush/color.cpp
index 54a06df3e1..f56dafed5f 100644
--- a/scumm/smush/color.cpp
+++ b/scumm/smush/color.cpp
@@ -22,12 +22,12 @@
#include <stdafx.h>
#include "color.h"
-#define UPDATE_COLOR(c, inc) (((int)((c)) << 7) + (c) + (inc)) >> 7
+#define UPDATE_COLOR(c, inc) (((int32)((c)) << 7) + (c) + (inc)) >> 7
#define CHECK_BOUNDS(c) (((c) > 255) ? 255 : (((c) < 0) ? 0 : (c)))
-void Color::delta(short * ptr) {
+void Color::delta(int16 * ptr) {
// This is a very specific method for XPALs.
- int t;
+ int16 t;
t = UPDATE_COLOR(_r, ptr[0]);
_r = CHECK_BOUNDS(t);
t = UPDATE_COLOR(_g, ptr[1]);
diff --git a/scumm/smush/color.h b/scumm/smush/color.h
index e0afefaf01..275b9cade4 100644
--- a/scumm/smush/color.h
+++ b/scumm/smush/color.h
@@ -30,7 +30,7 @@
*/
class Color {
public:
- typedef unsigned char value_type; //!< The type of the Chunk components.
+ typedef byte value_type; //!< The type of the Chunk components.
private:
value_type _r; //!< The red component.
value_type _g; //!< The green component.
@@ -49,7 +49,7 @@ public:
@param ptr pointer to a table of 3 shorts that contain delta values to use.
*/
- void delta(short * ptr);
+ void delta(int16 * ptr);
};
#endif
diff --git a/scumm/smush/frenderer.cpp b/scumm/smush/frenderer.cpp
index 92044b056a..a45cd2344c 100644
--- a/scumm/smush/frenderer.cpp
+++ b/scumm/smush/frenderer.cpp
@@ -26,18 +26,21 @@
#include "rect.h"
#include <assert.h>
-#include <string.h> // for memcpy, strcat, strdup
+#include <string.h>
-FontRenderer::FontRenderer(bool use_original_colors) : _nbChars(0), _color(-1), _original(use_original_colors) {
+FontRenderer::FontRenderer(bool use_original_colors) :
+ _nbChars(0),
+ _color(-1),
+ _original(use_original_colors) {
}
FontRenderer::~FontRenderer() {
- for(int i = 0; i < _nbChars; i++) {
+ for(int32 i = 0; i < _nbChars; i++) {
if(_chars[i].chr) delete []_chars[i].chr;
}
}
-void FontRenderer::save(int frame) {
+void FontRenderer::save(int32 frame) {
_chars[_nbChars].width = getWidth();
_chars[_nbChars].height = getHeight();
int size = getWidth() * getHeight();
@@ -46,20 +49,20 @@ void FontRenderer::save(int frame) {
_nbChars++;
}
-int FontRenderer::charWidth(int v) const {
+int32 FontRenderer::charWidth(int32 v) const {
if(v < 0) v = 256 + v;
if(v < 0 || v >= _nbChars) error("invalid character in FontRenderer::charWidth : %d (%d)", v, _nbChars);
return _chars[v].width;
}
-int FontRenderer::charHeight(int v) const {
+int32 FontRenderer::charHeight(int32 v) const {
if(v < 0) v = 256 + v;
if(v < 0 || v >= _nbChars) error("invalid character in FontRenderer::charHeight : %d (%d)", v, _nbChars);
return _chars[v].height;
}
-int FontRenderer::stringWidth(const char * str) const {
- int ret = 0;
+int32 FontRenderer::stringWidth(const char * str) const {
+ int32 ret = 0;
while(*str) {
ret += charWidth(*str++);
@@ -68,36 +71,36 @@ int FontRenderer::stringWidth(const char * str) const {
return ret;
}
-int FontRenderer::stringHeight(const char * str) const {
- int ret = 0;
+int32 FontRenderer::stringHeight(const char * str) const {
+ int32 ret = 0;
- for(int i = 0; str[i] != 0; i++) {
- int h = charHeight(str[i]);
+ for(int32 i = 0; str[i] != 0; i++) {
+ int32 h = charHeight(str[i]);
ret = MAX(ret, h);
}
return ret;
}
-int FontRenderer::drawChar(char * buffer, const Point & size, int x, int y, int chr) const {
- int w = _chars[chr].width;
- int h = _chars[chr].height;
+int32 FontRenderer::drawChar(char * buffer, const Point & size, int32 x, int32 y, int32 chr) const {
+ int32 w = _chars[chr].width;
+ int32 h = _chars[chr].height;
char * src = _chars[chr].chr;
char * dst = buffer + size.getX() * y + x;
if(_original) {
- for(int j = 0; j < h; j++) {
- for(int i = 0; i < w; i++) {
- int value = *src++;
+ for(int32 j = 0; j < h; j++) {
+ for(int32 i = 0; i < w; i++) {
+ char value = *src++;
if(value) dst[i] = value;
}
dst += size.getX();
}
} else {
- int color = (_color != -1) ? _color : 1;
- for(int j = 0; j < h; j++) {
- for(int i = 0; i < w; i++) {
- int value = *src++;
+ char color = (_color != -1) ? _color : 1;
+ for(int32 j = 0; j < h; j++) {
+ for(int32 i = 0; i < w; i++) {
+ char value = *src++;
if(value == 1) {
dst[i] = color;
} else if(value) {
@@ -112,7 +115,7 @@ int FontRenderer::drawChar(char * buffer, const Point & size, int x, int y, int
static char * * split(const char * str, char sep) {
char * * ret = new char *[32];
- int n = 0;
+ int32 n = 0;
const char * i = str, * j = strchr(i, sep);
while(j != NULL) {
@@ -131,12 +134,12 @@ static char * * split(const char * str, char sep) {
return ret;
}
-void FontRenderer::drawSubstring(const unsigned char * str, char * buffer, const Point & size, int x, int y) const {
- for(int i = 0; str[i] != 0; i++)
+void FontRenderer::drawSubstring(const byte * str, char * buffer, const Point & size, int32 x, int32 y) const {
+ for(int32 i = 0; str[i] != 0; i++)
x += drawChar(buffer, size, x, y, str[i]);
}
-bool FontRenderer::drawStringAbsolute(const char * str, char * buffer, const Point & size, int x, int y) const {
+bool FontRenderer::drawStringAbsolute(const char * str, char * buffer, const Point & size, int32 x, int32 y) const {
debug(9, "FontRenderer::drawStringAbsolute(%s, %d, %d)", str, x, y);
while(str) {
char line[256];
@@ -149,42 +152,42 @@ bool FontRenderer::drawStringAbsolute(const char * str, char * buffer, const Poi
strcpy(line, str);
str = 0;
}
- drawSubstring((const unsigned char *)line, buffer, size, x, y);
+ drawSubstring((const byte *)line, buffer, size, x, y);
y += stringHeight(line);
}
return true;
}
-bool FontRenderer::drawStringCentered(const char * str, char * buffer, const Point & size, int y, int xmin, int width, int offset) const {
+bool FontRenderer::drawStringCentered(const char * str, char * buffer, const Point & size, int32 y, int32 xmin, int32 width, int32 offset) const {
debug(9, "FontRenderer::drawStringCentered(%s, %d, %d)", str, xmin, y);
assert(strchr(str, '\n') == 0);
char * * words = split(str, ' ');
- int nb_sub = 0;
+ int32 nb_sub = 0;
while(words[nb_sub]) nb_sub++;
- int * sizes = new int[nb_sub];
- int i = 0, max_width = 0, height = 0, nb_subs = 0;
+ int32 * sizes = new int32[nb_sub];
+ int32 i = 0, max_width = 0, height = 0, nb_subs = 0;
for(i = 0; i < nb_sub; i++)
sizes[i] = stringWidth(words[i]);
char * * substrings = new char *[nb_sub];
- int * substr_widths = new int[nb_sub];
- int space_width = charWidth(' ');
+ int32 * substr_widths = new int32[nb_sub];
+ int32 space_width = charWidth(' ');
i = 0;
while(i < nb_sub) {
- int substr_width = sizes[i];
+ int32 substr_width = sizes[i];
char * substr = new char[1000];
strcpy(substr, words[i]);
- int j = i + 1;
+ int32 j = i + 1;
while(j < nb_sub && (substr_width + space_width + sizes[j]) < width) {
substr_width += sizes[j++] + space_width;
}
- for(int k = i + 1; k < j; k++) {
+ for(int32 k = i + 1; k < j; k++) {
strcat(substr, " ");
strcat(substr, words[k]);
}
@@ -219,8 +222,8 @@ bool FontRenderer::drawStringCentered(const char * str, char * buffer, const Poi
}
for(i = 0; i < nb_subs; i++) {
- int substr_width = substr_widths[i];
- drawSubstring((const unsigned char *)substrings[i], buffer, size, x - substr_width / 2, y);
+ int32 substr_width = substr_widths[i];
+ drawSubstring((const byte *)substrings[i], buffer, size, x - substr_width / 2, y);
y += stringHeight(substrings[i]);
delete []substrings[i];
}
diff --git a/scumm/smush/frenderer.h b/scumm/smush/frenderer.h
index 115106b963..18d6bf5089 100644
--- a/scumm/smush/frenderer.h
+++ b/scumm/smush/frenderer.h
@@ -50,12 +50,12 @@
*/
class FontRenderer : public BaseRenderer {
private:
- int _nbChars; //!< The number of frames in the font
- int _color; //!< A color parameter used for font printing.
+ int32 _nbChars; //!< The number of frames in the font
+ int32 _color; //!< A color parameter used for font printing.
bool _original; //!< flag for color selection
struct {
- int width;
- int height;
+ int32 width;
+ int32 height;
char * chr;
} _chars[256]; //!< array that contains the size of the different frames (i.e. characters) of the font.
public:
@@ -65,37 +65,37 @@ public:
*/
FontRenderer(bool use_original_colors = false);
virtual ~FontRenderer();
- virtual bool wait(int ms) { return true; };
+ virtual bool wait(int32 ms) { return true; };
protected:
- virtual void save(int frame = -1);
+ virtual void save(int32 frame = -1);
/*! @brief get the width of a character.
@param c the character we want the width from.
@return the width of the character
*/
- int charWidth(int c) const;
+ int32 charWidth(int32 c) const;
/*! @brief get the width of a string.
@param str the string we want the width from.
@return the complete width of the string
*/
- int stringWidth(const char * str) const;
+ int32 stringWidth(const char * str) const;
/*! @brief get the height of a character.
@param c the character we want the height from.
@return the height of the character
*/
- int charHeight(int c) const;
+ int32 charHeight(int32 c) const;
/*! @brief get the height of a string.
@param str the string we want the height from.
@return the complete height of the string
*/
- int stringHeight(const char * str) const;
+ int32 stringHeight(const char * str) const;
/*! @brief draw a character in the given frame buffer.
@param buffer the frame buffer to draw into.
@@ -108,7 +108,7 @@ protected:
@return the width of the character
*/
- int drawChar(char * buffer, const Point & size, int x, int y, int c) const;
+ int32 drawChar(char * buffer, const Point & size, int32 x, int32 y, int32 c) const;
/*! @brief draw a string in the given frame buffer.
@param str the string to draw.
@@ -119,7 +119,7 @@ protected:
@bug This method does not clip. This is not really a bug, as it should always be correctly called, but some asserts would be welcome.
*/
- void drawSubstring(const unsigned char * str, char * buffer, const Point & size, int x, int y) const;
+ void drawSubstring(const byte * str, char * buffer, const Point & size, int32 x, int32 y) const;
public:
/*! @brief change the programmable color of the font.
@@ -127,7 +127,7 @@ public:
@return \c true if everything went fine, \c false otherwise
*/
- bool setColor(int c) { _color = c; return true; }
+ bool setColor(int32 c) { _color = c; return true; }
/*! @brief draw a centered and possibly using multiple lines string.
This method performs calculation of the string size before choosing where to draw it.
@@ -147,7 +147,7 @@ public:
@return \c true if everything went fine, \c false otherwise
*/
- bool drawStringCentered(const char * str, char * buffer, const Point & size, int y, int xmin, int width, int offset) const;
+ bool drawStringCentered(const char * str, char * buffer, const Point & size, int32 y, int32 xmin, int32 width, int32 offset) const;
/*! @brief draw a string at an absolute position.
@param str the string to draw.
@@ -158,7 +158,7 @@ public:
@return \c true if everything went fine, \c false otherwise
*/
- bool drawStringAbsolute(const char * str, char * buffer, const Point & size, int x, int y) const;
+ bool drawStringAbsolute(const char * str, char * buffer, const Point & size, int32 x, int32 y) const;
};
diff --git a/scumm/smush/imuse_channel.cpp b/scumm/smush/imuse_channel.cpp
index ea969c9428..a4152a5a5c 100644
--- a/scumm/smush/imuse_channel.cpp
+++ b/scumm/smush/imuse_channel.cpp
@@ -25,9 +25,9 @@
#include "chunk_type.h"
#include <assert.h>
-#include <string.h> // for memcpy.h
+#include <string.h>
-ImuseChannel::ImuseChannel(int track, int freq) :
+ImuseChannel::ImuseChannel(int32 track, int32 freq) :
_track(track),
_tbuffer(0),
_tbufferSize(0),
@@ -52,32 +52,32 @@ bool ImuseChannel::isTerminated() const {
return (_dataSize <= 0 && _sbuffer == 0);
}
-bool ImuseChannel::setParameters(int nbframes, int size, int unk1, int unk2) {
+bool ImuseChannel::setParameters(int32 nbframes, int32 size, int32 unk1, int32 unk2) {
return true;
}
-bool ImuseChannel::checkParameters(int index, int nbframes, int size, int unk1, int unk2) {
+bool ImuseChannel::checkParameters(int32 index, int32 nbframes, int32 size, int32 unk1, int32 unk2) {
return true;
}
-bool ImuseChannel::appendData(Chunk & b, int size) {
+bool ImuseChannel::appendData(Chunk & b, int32 size) {
if(_dataSize == -1) { // First call
assert(size > 8);
Chunk::type imus_type = b.getDword(); imus_type = SWAP_BYTES(imus_type);
- unsigned int imus_size = b.getDword(); imus_size = SWAP_BYTES(imus_size);
+ uint32 imus_size = b.getDword(); imus_size = SWAP_BYTES(imus_size);
if(imus_type != TYPE_iMUS) error("Invalid Chunk for imuse_channel");
size -= 8;
_tbufferSize = size;
assert(_tbufferSize);
- _tbuffer = new unsigned char[_tbufferSize];
+ _tbuffer = new byte[_tbufferSize];
if(!_tbuffer) error("imuse_channel failed to allocate memory");
b.read(_tbuffer, size);
_dataSize = -2; // even if _in_data does not get set, this won't be called again
} else {
if(_tbuffer) { // remaining from last call
- unsigned char * old = _tbuffer;
- int new_size = size + _tbufferSize;
- _tbuffer = new unsigned char[new_size];
+ byte * old = _tbuffer;
+ int32 new_size = size + _tbufferSize;
+ _tbuffer = new byte[new_size];
if(!_tbuffer) error("imuse_channel failed to allocate memory");
memcpy(_tbuffer, old, _tbufferSize);
delete []old;
@@ -85,7 +85,7 @@ bool ImuseChannel::appendData(Chunk & b, int size) {
_tbufferSize += size;
} else {
_tbufferSize = size;
- _tbuffer = new unsigned char[_tbufferSize];
+ _tbuffer = new byte[_tbufferSize];
if(!_tbuffer) error("imuse_channel failed to allocate memory");
b.read(_tbuffer, size);
}
@@ -95,7 +95,7 @@ bool ImuseChannel::appendData(Chunk & b, int size) {
bool ImuseChannel::handleFormat(Chunk & src) {
if(src.getSize() != 20) error("invalid size for FRMT Chunk");
- unsigned imuse_start = src.getDword();
+ uint32 imuse_start = src.getDword();
imuse_start = SWAP_BYTES(imuse_start);
src.seek(4);
_bitsize = src.getDword();
@@ -152,16 +152,16 @@ void ImuseChannel::decode() {
_srbufferSize -= remaining_size;
assert(_inData);
if(_tbuffer == 0) {
- _tbuffer = new unsigned char[remaining_size];
+ _tbuffer = new byte[remaining_size];
memcpy(_tbuffer, _sbuffer + _sbufferSize - remaining_size, remaining_size);
_tbufferSize = remaining_size;
_sbufferSize -= remaining_size;
} else {
warning("impossible ! : %p, %d, %d, %p(%d), %p(%d, %d)",
this, _dataSize, _inData, _tbuffer, _tbufferSize, _sbuffer, _sbufferSize, _srbufferSize);
- unsigned char * old = _tbuffer;
+ byte * old = _tbuffer;
int new_size = remaining_size + _tbufferSize;
- _tbuffer = new unsigned char[new_size];
+ _tbuffer = new byte[new_size];
if(!_tbuffer) error("imuse_channel failed to allocate memory");
memcpy(_tbuffer, old, _tbufferSize);
delete []old;
@@ -172,7 +172,7 @@ void ImuseChannel::decode() {
int loop_size = _sbufferSize / 3;
int new_size = loop_size * 2;
short * keep, * decoded;
- keep = decoded = new short[new_size];
+ keep = decoded = new int16[new_size];
assert(keep);
unsigned char * source = _sbuffer;
while(loop_size--) {
@@ -180,25 +180,25 @@ void ImuseChannel::decode() {
int v2 = *source++;
int v3 = *source++;
int value = (((v2 & 0x0f) << 12) | (v1 << 4)) - 0x8000;
- *decoded++ = (short)value;
+ *decoded++ = (int16)value;
value = (((v2 & 0xf0) << 8) | (v3 << 4)) - 0x8000;
- *decoded++ = (short)value;
+ *decoded++ = (int16)value;
}
delete []_sbuffer;
- _sbuffer = (unsigned char*)keep;
- _sbufferSize = new_size * sizeof(short);
+ _sbuffer = (byte *)keep;
+ _sbufferSize = new_size * sizeof(int16);
}
-bool ImuseChannel::handleSubTags(int & offset) {
+bool ImuseChannel::handleSubTags(int32 & offset) {
if(_tbufferSize - offset >= 8) {
Chunk::type type = READ_BE_UINT32(_tbuffer + offset);
- unsigned int size = READ_BE_UINT32(_tbuffer + offset + 4);
- unsigned int available_size = _tbufferSize - offset;
+ uint32 size = READ_BE_UINT32(_tbuffer + offset + 4);
+ uint32 available_size = _tbufferSize - offset;
switch(type) {
case TYPE_MAP_:
_inData = false;
if(available_size >= (size + 8)) {
- ContChunk c((char*)_tbuffer + offset);
+ ContChunk c((byte *)_tbuffer + offset);
handleMap(c);
}
break;
@@ -208,8 +208,10 @@ bool ImuseChannel::handleSubTags(int & offset) {
offset += 8;
{
int reqsize = 1;
- if(_channels == 2) reqsize *= 2;
- if(_bitsize == 16) reqsize *= 2;
+ if(_channels == 2)
+ reqsize *= 2;
+ if(_bitsize == 16)
+ reqsize *= 2;
else if(_bitsize == 12) {
if(reqsize > 1)
reqsize = reqsize * 3 / 2;
@@ -239,14 +241,14 @@ bool ImuseChannel::processBuffer() {
if(_inData) {
if(_dataSize < _tbufferSize) {
- int offset= _dataSize;
+ int32 offset= _dataSize;
while(handleSubTags(offset));
_sbufferSize = _dataSize;
_sbuffer = _tbuffer;
if(offset < _tbufferSize) { // there is still some unprocessed data
- int new_size = _tbufferSize - offset;
- _tbuffer = new unsigned char[new_size];
- if(!_tbuffer) error("imuse_channel failed to allocate memory");
+ int32 new_size = _tbufferSize - offset;
+ _tbuffer = new byte[new_size];
+ if(!_tbuffer) error("imuse_channel failed to allocate memory");
memcpy(_tbuffer, _sbuffer + offset, new_size);
_tbufferSize = new_size;
} else {
@@ -266,24 +268,23 @@ bool ImuseChannel::processBuffer() {
_tbuffer = 0;
}
} else {
- int offset = 0;
+ int32 offset = 0;
while(handleSubTags(offset));
if(_inData) {
- //~ unsigned char * old = _tbuffer;
_sbufferSize = _tbufferSize - offset;
assert(_sbufferSize);
- _sbuffer = new unsigned char[_sbufferSize];
- if(!_sbuffer) error("imuse_channel failed to allocate memory");
+ _sbuffer = new byte[_sbufferSize];
+ if(!_sbuffer) error("imuse_channel failed to allocate memory");
memcpy(_sbuffer, _tbuffer + offset, _sbufferSize);
delete []_tbuffer;
_tbuffer = 0;
_tbufferSize = 0;
} else {
if(offset) { // maybe I should assert() this to avoid a lock...
- unsigned char * old = _tbuffer;
- int new_size = _tbufferSize - offset;
- _tbuffer = new unsigned char[new_size];
- if(!_tbuffer) error("imuse_channel failed to allocate memory");
+ byte * old = _tbuffer;
+ int32 new_size = _tbufferSize - offset;
+ _tbuffer = new byte[new_size];
+ if(!_tbuffer) error("imuse_channel failed to allocate memory");
memcpy(_tbuffer, old + offset, new_size);
_tbufferSize = new_size;
delete []old;
@@ -295,17 +296,17 @@ bool ImuseChannel::processBuffer() {
return true;
}
-int ImuseChannel::availableSoundData(void) const {
- int ret = _sbufferSize;
+int32 ImuseChannel::availableSoundData(void) const {
+ int32 ret = _sbufferSize;
if(_channels == 2) ret /= 2;
if(_bitsize > 8) ret /= 2;
return ret;
}
-void ImuseChannel::getSoundData(short * snd, int size) {
+void ImuseChannel::getSoundData(int16 * snd, int32 size) {
if(_dataSize <= 0 || _bitsize <= 8) error("invalid call to imuse_channel::read_sound_data()");
if(_channels == 2) size *= 2;
- for(int i = 0; i < size; i++)
+ for(int32 i = 0; i < size; i++)
snd[i] = READ_BE_UINT16(_sbuffer + 2 * i);
delete []_sbuffer;
assert(_sbufferSize == 2 * size);
@@ -314,10 +315,10 @@ void ImuseChannel::getSoundData(short * snd, int size) {
_dataSize -= _srbufferSize;
}
-void ImuseChannel::getSoundData(char * snd, int size) {
+void ImuseChannel::getSoundData(int8 * snd, int32 size) {
if(_dataSize <= 0 || _bitsize > 8) error("invalid call to imuse_channel::read_sound_data()");
if(_channels == 2) size *= 2;
- for(int i = 0; i < size; i++)
+ for(int32 i = 0; i < size; i++)
snd[i] = _sbuffer[i];
delete []_sbuffer;
_sbuffer = 0;
diff --git a/scumm/smush/mixer.h b/scumm/smush/mixer.h
index 21408d2fb9..58ad841fe1 100644
--- a/scumm/smush/mixer.h
+++ b/scumm/smush/mixer.h
@@ -49,7 +49,7 @@ class Mixer {
public:
virtual ~Mixer() {};
virtual bool init() = 0;
- virtual _Channel * findChannel(int track) = 0;
+ virtual _Channel * findChannel(int32 track) = 0;
virtual bool addChannel(_Channel * c) = 0;
virtual bool handleFrame() = 0;
virtual bool stop() = 0;
diff --git a/scumm/smush/palette.h b/scumm/smush/palette.h
index 6ffb08cf78..1a017a63f0 100644
--- a/scumm/smush/palette.h
+++ b/scumm/smush/palette.h
@@ -35,19 +35,19 @@ private:
Color _colors[256];
public:
Palette() {}
- Palette(unsigned char *ptr)
+ Palette(byte *ptr)
{
- for(int i = 0; i < 256; i++) {
+ for(int32 i = 0; i < 256; i++) {
_colors[i] = Color(ptr[3 * i + 0], ptr[3 * i + 1], ptr[3 * i + 2]);
}
}
- const Color & operator[](int a) const
+ const Color & operator[](int32 a) const
{
assert(a >= 0 && a < 256);
return _colors[a];
}
- Color & operator[](int a)
+ Color & operator[](int32 a)
{
assert(a >= 0 && a < 256);
return _colors[a];
diff --git a/scumm/smush/player.cpp b/scumm/smush/player.cpp
index e13344f194..aeac41f055 100644
--- a/scumm/smush/player.cpp
+++ b/scumm/smush/player.cpp
@@ -32,10 +32,10 @@
#include "blitter.h"
#include <assert.h>
-#include <stdlib.h> // for atoi
-#include <stdio.h> // for FILE, fopen, fclose, fread, fseek, ftell
-#include <string.h> // for strchr, strrchr
-#include <ctype.h> // for isdigit
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
const int WAIT = 100;
@@ -47,21 +47,21 @@ const int WAIT = 100;
@bug some of The Dig strings are not completely parsed (in titles)
*/
-const int MAX_STRINGS = 200;
+const int32 MAX_STRINGS = 200;
class StringResource {
private:
struct {
- int id;
+ int32 id;
char * string;
} _strings[MAX_STRINGS];
- int _nbStrings;
- int _lastId;
+ int32 _nbStrings;
+ int32 _lastId;
char * _lastString;
public:
StringResource() : _nbStrings(0), _lastId(-1) {};
~StringResource() {
- for(int i = 0; i < _nbStrings; i++) {
+ for(int32 i = 0; i < _nbStrings; i++) {
delete []_strings[i].string;
}
}
@@ -72,7 +72,7 @@ public:
@return \c true if the parsing went fine, \c false otherwise
*/
- bool init(char * buffer, int length) {
+ bool init(char * buffer, int32 length) {
debug(9, "parsing string resources...");
char * def_start = strchr(buffer, '#');
while(def_start != NULL) {
@@ -87,11 +87,13 @@ public:
char idstring[32];
memcpy(idstring, id_start, id_end - id_start);
idstring[id_end - id_start] = 0;
- int id = atoi(idstring);
- //~ assert(id != LONG_MIN && id != 0 && id != LONG_MAX);
+ int32 id = atoi(idstring);
char * data_start = def_end;
- while(*data_start == '\n' || *data_start == '\r') data_start++;
+
+ while(*data_start == '\n' || *data_start == '\r')
+ data_start++;
char * data_end = data_start;
+
while(1) {
if(data_end[-2] == '\r' && data_end[1] == '\n' && data_end[-1] == '\n' && data_end[0] == '\r')
break;
@@ -101,6 +103,7 @@ public:
break;
}
}
+
data_end -= 2;
assert(data_end > data_start);
char * value = new char[data_end - data_start + 1];
@@ -109,6 +112,7 @@ public:
value[data_end - data_start] = 0;
char * line_start = value;
char * line_end;
+
while ((line_end = strchr(line_start, '\n'))) {
line_start = line_end+1;
if (line_start[0] == '/' && line_start[1] == '/') {
@@ -136,7 +140,7 @@ public:
@return the corresponding string.
*/
- const char * get(int id) {
+ const char * get(int32 id) {
if(id == _lastId) return _lastString;
for(int i = 0; i < _nbStrings; i++)
{
@@ -175,7 +179,7 @@ void SmushPlayer::hide(const char * p) {
else if(strcmp(p, "voices") == 0)
_voices = false;
else {
- int id = atoi(p);
+ int32 id = atoi(p);
if(id < 0 || id > 36) error("invalid parameter to hide");
_skips[id] = false;
}
@@ -221,7 +225,7 @@ void SmushPlayer::clean() {
if(_fr[3]) delete _fr[3];
}
-void SmushPlayer::checkBlock(const Chunk & b, Chunk::type type_expected, unsigned int min_size) {
+void SmushPlayer::checkBlock(const Chunk & b, Chunk::type type_expected, uint32 min_size) {
if(type_expected != b.getType()) {
error("Chunk type is different from expected : %d != %d", b.getType(), type_expected);
}
@@ -230,13 +234,13 @@ void SmushPlayer::checkBlock(const Chunk & b, Chunk::type type_expected, unsigne
}
}
-void SmushPlayer::handleSoundBuffer(int track_id, int index, int max_frames, int flags, int vol, int bal, Chunk & b, int size) {
+void SmushPlayer::handleSoundBuffer(int32 track_id, int32 index, int32 max_frames, int32 flags, int32 vol, int32 bal, Chunk & b, int32 size) {
debug(6, "smush_player::handleSoundBuffer(%d)", track_id);
if(!_voices && (flags & 128) == 128) return;
if(!_bgmusic && (flags & 64) == 64) return;
_Channel * c = _mixer->findChannel(track_id);
if(c == 0) {
- c = new SaudChannel(track_id, _soundFrequency);
+ c = new SaudChannel(track_id, _soundFrequency);
_mixer->addChannel(c);
}
if(index == 0)
@@ -250,24 +254,24 @@ void SmushPlayer::handleSoundFrame(Chunk & b) {
checkBlock(b, TYPE_PSAD);
debug(6, "SmushPlayer::handleSoundFrame()");
if(!_outputSound) return;
- int track_id = b.getWord();
- int index = b.getWord();
- int max_frames = b.getWord();
- int flags = b.getWord();
- int vol = b.getByte();
- int bal = b.getChar();
+ int32 track_id = b.getWord();
+ int32 index = b.getWord();
+ int32 max_frames = b.getWord();
+ int32 flags = b.getWord();
+ int32 vol = b.getByte();
+ int32 bal = b.getChar();
#ifdef DEBUG
if(index == 0) {
debug(5, "track_id == %d, max_frames == %d, %d, %d, %d", track_id, max_frames, flags, vol, bal);
}
#endif
- int size = b.getSize() - 10;
+ int32 size = b.getSize() - 10;
handleSoundBuffer(track_id, index, max_frames, flags, vol, bal, b, size);
}
void SmushPlayer::handleSkip(Chunk & b) {
checkBlock(b, TYPE_SKIP, 4);
- int code = b.getDword();
+ int32 code = b.getDword();
debug(6, "SmushPlayer::handleSkip(%d)", code);
if(code >= 0 && code < 37)
_skipNext = _skips[code];
@@ -285,7 +289,7 @@ void SmushPlayer::handleFetch(Chunk & b) {
debug(6, "SmushPlayer::handleFetch()");
}
-void SmushPlayer::handleImuseBuffer(int track_id, int index, int nbframes, int size, int unk1, int unk2, Chunk & b, int bsize) {
+void SmushPlayer::handleImuseBuffer(int32 track_id, int32 index, int32 nbframes, int32 size, int32 unk1, int32 unk2, Chunk & b, int32 bsize) {
_Channel * c = _mixer->findChannel(track_id);
if(c == 0) {
c = new ImuseChannel(track_id, _soundFrequency);
@@ -298,14 +302,14 @@ void SmushPlayer::handleImuseBuffer(int track_id, int index, int nbframes, int s
c->appendData(b, bsize);
}
-void SmushPlayer::handleImuseAction8(Chunk & b, int flags, int unknown, int track_id) {
+void SmushPlayer::handleImuseAction8(Chunk & b, int32 flags, int32 unknown, int32 track_id) {
assert(flags == 46 && unknown == 0);
- int unknown2 = b.getWord();
+ int32 unknown2 = b.getWord();
track_id |= unknown2 << 16;
- int index = b.getWord();
- int nbframes = b.getWord();
- int size = b.getDword();
- int bsize = b.getSize() - 18;
+ int32 index = b.getWord();
+ int32 nbframes = b.getWord();
+ int32 size = b.getDword();
+ int32 bsize = b.getSize() - 18;
handleImuseBuffer(track_id, index, nbframes, size, unknown, unknown2, b, bsize);
}
@@ -313,10 +317,10 @@ void SmushPlayer::handleImuseAction(Chunk & b) {
checkBlock(b, TYPE_IACT, 8);
debug(6, "SmushPlayer::handleImuseAction()");
if(!_outputSound) return;
- int code = b.getWord();
- int flags = b.getWord();
- int unknown = b.getShort();
- int track_id = b.getWord();
+ int32 code = b.getWord();
+ int32 flags = b.getWord();
+ int32 unknown = b.getShort();
+ int32 track_id = b.getWord();
#ifdef DEBUG
debug(5, "handleImuseAction(%d, %d, %d, %d)", code, flags, unknown, track_id);
#endif
@@ -334,42 +338,36 @@ void SmushPlayer::handleImuseAction(Chunk & b) {
void SmushPlayer::handleTextResource(Chunk & b) {
checkBlock(b, TYPE_TRES, 18);
- int pos_x = b.getShort();
- int pos_y = b.getShort();
- int flags = b.getShort();
- int left = b.getShort();
- int top = b.getShort();
- int width = b.getShort();
- int height = b.getShort();
- int unk2 = b.getWord();
- int string_id = b.getWord();
+ int32 pos_x = b.getShort();
+ int32 pos_y = b.getShort();
+ int32 flags = b.getShort();
+ int32 left = b.getShort();
+ int32 top = b.getShort();
+ int32 width = b.getShort();
+ int32 height = b.getShort();
+ int32 unk2 = b.getWord();
+ int32 string_id = b.getWord();
debug(6, "SmushPlayer::handleTextResource(%d)", string_id);
if(!_strings) return;
// if subtitles disabled and bit 3 is set, then do not draw
- if((!_subtitles) && ((flags & 8) == 8)) return;
+ if((!_subtitles) && ((flags & 8) == 8))
+ return;
const char * str = _strings->get(string_id);
FontRenderer * fr = _fr[0];
- int color = 15;
+ int32 color = 15;
while(*str == '/') str++; // For Full Throttle text resources
while(str[0] == '^') {
switch(str[1]) {
case 'f':
{
-#if 0
- // This cause trouble if the next character is a digit.
- int id = atoi(str+2);
-#else
- // assume ASCII like character set...
int id = str[3] - '0';
-#endif
str += 4;
fr = _fr[id];
} break;
case 'c':
{
- //~ int id = atoi(str+2);
color = str[4] - '0' + 10 *(str[3] - '0');
str += 5;
} break;
@@ -388,7 +386,7 @@ void SmushPlayer::handleTextResource(Chunk & b) {
}
void SmushPlayer::readPalette(Palette & out, Chunk & in) {
- unsigned char buffer[768];
+ byte buffer[768];
in.read(buffer, 768);
out = Palette(buffer);
}
@@ -397,20 +395,20 @@ void SmushPlayer::handleDeltaPalette(Chunk & b) {
checkBlock(b, TYPE_XPAL);
debug(6, "SmushPlayer::handleDeltaPalette()");
if(b.getSize() == 768 * 3 + 4) {
- int unk1, num;
+ int32 unk1, num;
unk1 = b.getWord();
num = b.getWord();
- for(int i = 0; i < 768; i++) {
+ for(int32 i = 0; i < 768; i++) {
_deltaPal[i] = b.getWord();
}
readPalette(_pal, b);
updatePalette();
} else if(b.getSize() == 6) {
- int unk1, num, unk2;
+ int32 unk1, num, unk2;
unk1 = b.getWord();
num = b.getWord();
unk2 = b.getWord();
- for(int i = 0; i < 256; i++) {
+ for(int32 i = 0; i < 256; i++) {
_pal[i].delta(_deltaPal + 3 * i);
}
updatePalette();
@@ -428,7 +426,7 @@ void SmushPlayer::handleNewPalette(Chunk & b) {
void SmushPlayer::decodeCodec(Chunk & b, const Rect & r, Decoder & codec) {
assert(_curBuffer);
- Blitter blit(_curBuffer, _frameSize, r);
+ Blitter blit((byte*)_curBuffer, _frameSize, r);
codec.decode(blit, b);
}
@@ -469,12 +467,12 @@ void SmushPlayer::handleFrameObject(Chunk & b) {
}
int codec = b.getWord();
debug(6, "SmushPlayer::handleFrameObject(%d)", codec);
- unsigned short left = b.getWord();
- unsigned short top = b.getWord();
- unsigned short width = b.getWord();
- unsigned short height = b.getWord();
+ uint16 left = b.getWord();
+ uint16 top = b.getWord();
+ uint16 width = b.getWord();
+ uint16 height = b.getWord();
Rect r(left, top, left + width, top + height);
- unsigned short data[2];
+ uint16 data[2];
data[1] = b.getWord();
data[0] = b.getWord();
#ifdef DEBUG
@@ -504,7 +502,7 @@ void SmushPlayer::handleFrameObject(Chunk & b) {
decodeCodec(b, r, _codec44);
break;
default:
- error("Invalid codec for frame object : %d", (int)codec);
+ error("Invalid codec for frame object : %d", (int32)codec);
}
}
@@ -570,7 +568,7 @@ void SmushPlayer::handleAnimHeader(Chunk & b) {
debug(6, "SmushPlayer::handleAnimHeader()");
_version = b.getWord();
_nbframes = b.getWord();
- int unknown = b.getWord();
+ int32 unknown = b.getWord();
#ifdef DEBUG
debug(5, "SMUSH HEADER : version == %d, nbframes == %d, unknown == %d", _version, _nbframes, unknown);
#else
@@ -584,11 +582,11 @@ void SmushPlayer::handleAnimHeader(Chunk & b) {
}
if(_version == 2) {
_secondaryVersion = b.getDword();
- int unknown2 = b.getDword();
+ int32 unknown2 = b.getDword();
_soundFrequency = b.getDword();
#ifdef DEBUG
debug(5, "SMUSH HEADER : secondary version == %d, unknown2 == %d, sound frequency == %d", _secondaryVersion, unknown2, _soundFrequency);
- int i = 0, c;
+ int32 i = 0, c;
while(!b.eof()) {
c = b.getByte();
if(c) debug(9, "SMUSH HEADER : remaining bytes : %d == %d", i, c);
@@ -621,7 +619,7 @@ static StringResource * getStrings(const char * file, bool is_encoded) {
is = fopen(file, "rb");
if(is == NULL) return 0;
fseek(is, 0, SEEK_END);
- int length = ftell(is);
+ int32 length = ftell(is);
fseek(is, 0, SEEK_SET);
char * filebuffer = new char [length + 1];
assert(filebuffer);
@@ -629,7 +627,7 @@ static StringResource * getStrings(const char * file, bool is_encoded) {
filebuffer[length] = 0;
fclose(is);
if(is_encoded) {
- static const int ETRS_HEADER_LENGTH = 16;
+ static const int32 ETRS_HEADER_LENGTH = 16;
assert(length > ETRS_HEADER_LENGTH);
Chunk::type type = READ_BE_UINT32(filebuffer);
if(type != TYPE_ETRS) {
@@ -638,7 +636,7 @@ static StringResource * getStrings(const char * file, bool is_encoded) {
}
char * old = filebuffer;
filebuffer = new char[length - ETRS_HEADER_LENGTH];
- for(int i = ETRS_HEADER_LENGTH; i < length; i++)
+ for(int32 i = ETRS_HEADER_LENGTH; i < length; i++)
filebuffer[i - ETRS_HEADER_LENGTH] = old[i] ^ 0xCC;
delete []old;
length -= ETRS_HEADER_LENGTH;
@@ -737,7 +735,7 @@ bool SmushPlayer::play(const char * file) {
strcpy(file, directory); strcat(file, "titlfnt.nut");
_fr[2] = loadFont(file, true);
} else {
- for(int i = 0; i < 4; i++) {
+ for(int32 i = 0; i < 4; i++) {
char file[260];
sprintf(file, "%s/font%d.nut",directory, i);
_fr[i] = loadFont(file, i != 0);
diff --git a/scumm/smush/player.h b/scumm/smush/player.h
index 6cd6395f2e..79bc7f6874 100644
--- a/scumm/smush/player.h
+++ b/scumm/smush/player.h
@@ -44,13 +44,13 @@ class StringResource;
class SmushPlayer {
private:
char * _fname; //!< the name of the animation file being played
- int _version; //!< the version of the animation file being played
- int _secondaryVersion; //!< the secondary version number of the animation file being played
- int _soundFrequency; //!< the sound frequency of the animation file being played
- int _nbframes; //!< the number of frames in the animation file
+ int32 _version; //!< the version of the animation file being played
+ int32 _secondaryVersion; //!< the secondary version number of the animation file being played
+ int32 _soundFrequency; //!< the sound frequency of the animation file being played
+ int32 _nbframes; //!< the number of frames in the animation file
Mixer * _mixer; //!< the sound mixer
Palette _pal; //!< the current palette
- short _deltaPal[768]; //!< the delta palette information set by an xpal
+ int16 _deltaPal[768]; //!< the delta palette information set by an xpal
Renderer * _renderer; //!< pointer to the ::renderer
StringResource * _strings; //!< pointer to the string resources associated with the animation
FontRenderer * _fr[4]; //!< pointers to the fonts for the animation
@@ -59,7 +59,7 @@ private:
Codec44Decoder _codec44; //!< the ::decoder for codec 21 and 44
DumpDecoder _codecd; //!< the ::decoder for codec 21 and 44
Point _frameSize; //!< the current frame size of the animation
- int _frame; //!< the current frame number of the animation
+ int32 _frame; //!< the current frame number of the animation
bool _outputSound; //!< should we handle sound ?
bool _wait; //!< should we synchronise the player ?
bool _alreadyInit; //!< has the player already been initialized for the current frame
@@ -80,18 +80,18 @@ public:
protected:
bool readString(const char * file, bool &);
void clean();
- void checkBlock(const Chunk &, Chunk::type, unsigned int = 0);
+ void checkBlock(const Chunk &, Chunk::type, uint32 = 0);
void handleAnimHeader(Chunk &);
void handleFrame(Chunk &);
void handleNewPalette(Chunk &);
void handleFrameObject(Chunk &);
- void handleSoundBuffer(int, int, int, int, int, int, Chunk &, int);
- void handleImuseBuffer(int, int, int, int, int, int, Chunk &, int);
+ void handleSoundBuffer(int32, int32, int32, int32, int32, int32, Chunk &, int32);
+ void handleImuseBuffer(int32, int32, int32, int32, int32, int32, Chunk &, int32);
void handleSoundFrame(Chunk &);
void handleSkip(Chunk &);
void handleStore(Chunk &);
void handleFetch(Chunk &);
- void handleImuseAction8(Chunk &, int flags, int unknown, int track_id);
+ void handleImuseAction8(Chunk &, int32 flags, int32 unknown, int32 track_id);
void handleImuseAction(Chunk &);
void handleTextResource(Chunk &);
void handleDeltaPalette(Chunk &);
diff --git a/scumm/smush/rect.h b/scumm/smush/rect.h
index e02d6858be..d1f061136f 100644
--- a/scumm/smush/rect.h
+++ b/scumm/smush/rect.h
@@ -31,24 +31,24 @@
class Point {
friend class Rect;
private:
- int _x; //!< The horizontal part of the point
- int _y; //!< The vertical part of the point
+ int32 _x; //!< The horizontal part of the point
+ int32 _y; //!< The vertical part of the point
public:
Point() : _x(0), _y(0) {};
Point(const Point & p) : _x(p._x), _y(p._y) {};
- explicit Point(int x, int y) : _x(x), _y(y) {};
+ explicit Point(int32 x, int32 y) : _x(x), _y(y) {};
Point & operator=(const Point & p) { _x = p._x; _y = p._y; return *this; };
bool operator==(const Point & p) const { return _x == p._x && _y == p._y; };
- const int & getX() const { return _x; };
- const int & getY() const { return _y; };
- int & getX() { return _x; };
- int & getY() { return _y; };
+ const int32 & getX() const { return _x; };
+ const int32 & getY() const { return _y; };
+ int32 & getX() { return _x; };
+ int32 & getY() { return _y; };
Point operator+(const Point & p) const { return Point(_x + p._x, _y+p._y); };
Point operator-(const Point & p) const { return Point(_x - p._x, _y-p._y); };
Point & operator+=(const Point & p) { _x += p._x; _y += p._y; return *this; };
Point & operator-=(const Point & p) { _x -= p._x; _y -= p._y; return *this; };
bool isOrigin() const { return _x == 0 && _y == 0; };
- void set(int x, int y) { _x = x; _y = y; }
+ void set(int32 x, int32 y) { _x = x; _y = y; }
};
/*! @brief simple class for handling a rectangular zone.
@@ -62,15 +62,15 @@ private:
Point _bottomRight; //!< The point at the bottom right of the rectangle
public:
Rect() : _topLeft(0, 0), _bottomRight(0,0) {}
- Rect(int x, int y) : _topLeft(0, 0), _bottomRight(x, y) {}
- Rect(int x1, int y1, int x2, int y2) : _topLeft(x1, y1), _bottomRight(x2, y2) {}
+ Rect(int32 x, int32 y) : _topLeft(0, 0), _bottomRight(x, y) {}
+ Rect(int32 x1, int32 y1, int32 x2, int32 y2) : _topLeft(x1, y1), _bottomRight(x2, y2) {}
Point size() const { return (_bottomRight - _topLeft); };
- int width() const { return size()._x; }
- int height() const { return size()._y; }
- int left() const { return _topLeft._x; }
- int right() const { return _bottomRight._x; }
- int top() const { return _topLeft._y; }
- int bottom() const { return _bottomRight._y; }
+ int32 width() const { return size()._x; }
+ int32 height() const { return size()._y; }
+ int32 left() const { return _topLeft._x; }
+ int32 right() const { return _bottomRight._x; }
+ int32 top() const { return _topLeft._y; }
+ int32 bottom() const { return _bottomRight._y; }
const Point & topLeft() const { return _topLeft; }
const Point & bottomRight() const { return _bottomRight; }
@@ -81,8 +81,7 @@ public:
@return true if the given position is inside the rectangle, false otherwise
*/
- bool isInside(int x, int y) const
- {
+ bool isInside(int32 x, int32 y) const {
return (_topLeft._x <= x) && (_bottomRight._x > x) && (_topLeft._y <= y) && (_bottomRight._y > y);
}
/*! @brief check if given point is inside the rectangle
@@ -91,12 +90,10 @@ public:
@return true if the given point is inside the rectangle, false otherwise
*/
- bool isInside(const Point & p) const
- {
+ bool isInside(const Point & p) const {
return (_topLeft._x <= p._x) && (_bottomRight._x > p._x) && (_topLeft._y <= p._y) && (_bottomRight._y > p._y);
}
-
bool clip(Rect & r) const;
};
diff --git a/scumm/smush/renderer.h b/scumm/smush/renderer.h
index 89b18ca76e..7f8fd7e730 100644
--- a/scumm/smush/renderer.h
+++ b/scumm/smush/renderer.h
@@ -48,7 +48,7 @@ public:
@return true if initialisation was ok, false otherwise
*/
- virtual bool startDecode(const char * fname, int version, int nbframes) = 0;
+ virtual bool startDecode(const char * fname, int32 version, int32 nbframes) = 0;
/*! @brief start of animation output
This is called by the animation player when the frame size is changing.
@@ -75,7 +75,7 @@ public:
@return a pointer to the frame buffer to output data to.
*/
- virtual char * lockFrame(int frame) = 0;
+ virtual char * lockFrame(int32 frame) = 0;
/*! @brief unlock a frame buffer
This is called by the animation player when a frame has been decoded.
@@ -98,7 +98,7 @@ public:
@return true if everything went fine, false otherwise
*/
- virtual bool wait(int ms) = 0;
+ virtual bool wait(int32 ms) = 0;
/*! @brief does the renderer want a premature end of the animation ?
This is called by the animation player after each frame.
diff --git a/scumm/smush/saud_channel.cpp b/scumm/smush/saud_channel.cpp
index 6601f5a209..c6a6aefd74 100644
--- a/scumm/smush/saud_channel.cpp
+++ b/scumm/smush/saud_channel.cpp
@@ -25,10 +25,10 @@
#include "chunk_type.h"
#include <assert.h>
-#include <string.h> // for memcpy.h
+#include <string.h>
void SaudChannel::handleStrk(Chunk & b) {
- int size = b.getSize();
+ int32 size = b.getSize();
if(size != 14 && size != 10) {
error("STRK has a invalid size : %d", size);
}
@@ -39,21 +39,21 @@ void SaudChannel::handleSmrk(Chunk & b) {
}
void SaudChannel::handleShdr(Chunk & b) {
- int size = b.getSize();
+ int32 size = b.getSize();
if(size != 4) warning("SMRK has a invalid size : %d", size);
}
-bool SaudChannel::handleSubTags(int & offset) {
+bool SaudChannel::handleSubTags(int32 & offset) {
if(_tbufferSize - offset >= 8) {
Chunk::type type = READ_BE_UINT32(_tbuffer + offset);
- unsigned int size = READ_BE_UINT32(_tbuffer + offset + 4);
- unsigned int available_size = _tbufferSize - offset;
+ uint32 size = READ_BE_UINT32(_tbuffer + offset + 4);
+ uint32 available_size = _tbufferSize - offset;
switch(type) {
case TYPE_STRK:
_inData = false;
if(available_size >= (size + 8)) {
- ContChunk c((char*)_tbuffer + offset);
+ ContChunk c((byte *)_tbuffer + offset);
handleStrk(c);
}
else
@@ -62,7 +62,7 @@ bool SaudChannel::handleSubTags(int & offset) {
case TYPE_SMRK:
_inData = false;
if(available_size >= (size + 8)) {
- ContChunk c((char*)_tbuffer + offset);
+ ContChunk c((byte *)_tbuffer + offset);
handleSmrk(c);
}
else
@@ -71,7 +71,7 @@ bool SaudChannel::handleSubTags(int & offset) {
case TYPE_SHDR:
_inData = false;
if(available_size >= (size + 8)) {
- ContChunk c((char*)_tbuffer + offset);
+ ContChunk c((byte *)_tbuffer + offset);
handleShdr(c);
}
else
@@ -106,13 +106,13 @@ bool SaudChannel::processBuffer() {
if(_inData) {
if(_dataSize < _tbufferSize) {
// I can't assume that the channel is finished after data is received... (this assumption failed in realride.san)
- int offset= _dataSize;
+ int32 offset = _dataSize;
while(handleSubTags(offset));
_sbufferSize = _dataSize;
_sbuffer = _tbuffer;
if(offset < _tbufferSize) { // there is still some unprocessed data
int new_size = _tbufferSize - offset;
- _tbuffer = new unsigned char[new_size];
+ _tbuffer = new byte[new_size];
if(!_tbuffer) error("SaudChannel failed to allocate memory");
memcpy(_tbuffer, _sbuffer + offset, new_size);
_tbufferSize = new_size;
@@ -133,12 +133,12 @@ bool SaudChannel::processBuffer() {
_tbuffer = 0;
}
} else {
- int offset = 0;
+ int32 offset = 0;
while(handleSubTags(offset));
if(_inData) {
_sbufferSize = _tbufferSize - offset;
assert(_sbufferSize);
- _sbuffer = new unsigned char[_sbufferSize];
+ _sbuffer = new byte[_sbufferSize];
if(!_sbuffer) error("saud_channel failed to allocate memory");
memcpy(_sbuffer, _tbuffer + offset, _sbufferSize);
delete []_tbuffer;
@@ -147,8 +147,8 @@ bool SaudChannel::processBuffer() {
} else {
if(offset) { // maybe I should assert() this to avoid a lock...
unsigned char * old = _tbuffer;
- int new_size = _tbufferSize - offset;
- _tbuffer = new unsigned char[new_size];
+ int32 new_size = _tbufferSize - offset;
+ _tbuffer = new byte[new_size];
if(!_tbuffer) error("SaudChannel failed to allocate memory");
memcpy(_tbuffer, old + offset, new_size);
_tbufferSize = new_size;
@@ -159,7 +159,7 @@ bool SaudChannel::processBuffer() {
return true;
}
-SaudChannel::SaudChannel(int track, int freq) :
+SaudChannel::SaudChannel(int32 track, int32 freq) :
_track(track),
_nbframes(0),
_dataSize(-1),
@@ -186,28 +186,28 @@ bool SaudChannel::isTerminated() const {
}
void SaudChannel::recalcVolumeTable() {
- const int MAX_BALANCE = 100;
- int volume_left, volume_right;
+ const int32 MAX_BALANCE = 100;
+ int32 volume_left, volume_right;
if(_balance < -MAX_BALANCE || _balance > MAX_BALANCE) {
error("balance is out of range ! : %d", _balance);
}
- int left_multiplier = MAX_BALANCE - _balance;
- int right_multiplier = MAX_BALANCE + _balance;
+ int32 left_multiplier = MAX_BALANCE - _balance;
+ int32 right_multiplier = MAX_BALANCE + _balance;
volume_left = _volume * left_multiplier / (MAX_BALANCE * 2);
volume_right = _volume * right_multiplier / (MAX_BALANCE * 2);
if(volume_left < 0) volume_left = 0;
if(volume_left > 128) volume_left = 128;
if(volume_right < 0) volume_right = 0;
if(volume_right > 128) volume_right = 128;
- for(int i = 0; i < 256; i++) {
- int value = volume_left * (signed char)i;
+ for(int32 i = 0; i < 256; i++) {
+ int16 value = volume_left * (int8)i;
_voltable[0][i] = TO_BE_16(value);
- value = volume_right * (signed char)i;
+ value = volume_right * (int8)i;
_voltable[1][i] = TO_BE_16(value);
}
}
-bool SaudChannel::setParameters(int nb, int flags, int volume, int balance) {
+bool SaudChannel::setParameters(int32 nb, int32 flags, int32 volume, int32 balance) {
_nbframes = nb;
_flags = flags; // bit 7 == IS_VOICE, bit 6 == IS_BACKGROUND_MUSIC, other ??
_volume = volume;
@@ -217,7 +217,7 @@ bool SaudChannel::setParameters(int nb, int flags, int volume, int balance) {
return true;
}
-bool SaudChannel::checkParameters(int index, int nb, int flags, int volume, int balance) {
+bool SaudChannel::checkParameters(int32 index, int32 nb, int32 flags, int32 volume, int32 balance) {
if(++_index != index) error("invalid index in SaudChannel::checkParameters()");
if(_nbframes != nb) error("invalid duration in SaudChannel::checkParameters()");
if(_flags != flags) error("invalid flags in SaudChannel::checkParameters()");
@@ -229,18 +229,18 @@ bool SaudChannel::checkParameters(int index, int nb, int flags, int volume, int
return true;
}
-bool SaudChannel::appendData(Chunk & b, int size) {
+bool SaudChannel::appendData(Chunk & b, int32 size) {
if(_dataSize == -1) { // First call
assert(size > 8);
Chunk::type saud_type = b.getDword(); saud_type = SWAP_BYTES(saud_type);
- unsigned int saud_size = b.getDword(); saud_size = SWAP_BYTES(saud_size);
+ uint32 saud_size = b.getDword(); saud_size = SWAP_BYTES(saud_size);
if(saud_type != TYPE_SAUD) error("Invalid Chunk for SaudChannel : %X", saud_type);
size -= 8;
_dataSize = -2; // We don't get here again...
}
if(_tbuffer) {
- unsigned char * old = _tbuffer;
- _tbuffer = new unsigned char[_tbufferSize + size];
+ byte * old = _tbuffer;
+ _tbuffer = new byte[_tbufferSize + size];
if(!_tbuffer) error("saud_channel failed to allocate memory");
memcpy(_tbuffer, old, _tbufferSize);
delete []old;
@@ -248,19 +248,19 @@ bool SaudChannel::appendData(Chunk & b, int size) {
_tbufferSize += size;
} else {
_tbufferSize = size;
- _tbuffer = new unsigned char[_tbufferSize];
+ _tbuffer = new byte[_tbufferSize];
if(!_tbuffer) error("saud_channel failed to allocate memory");
b.read(_tbuffer, _tbufferSize);
}
return processBuffer();
}
-int SaudChannel::availableSoundData(void) const {
+int32 SaudChannel::availableSoundData(void) const {
return _sbufferSize;
}
-void SaudChannel::getSoundData(short * snd, int size) {
- for(int i = 0; i < size; i++) {
+void SaudChannel::getSoundData(int16 * snd, int32 size) {
+ for(int32 i = 0; i < size; i++) {
snd[2 * i] = _voltable[0][_sbuffer[i] ^ 0x80];
snd[2 * i + 1] = _voltable[1][_sbuffer[i] ^ 0x80];
}
diff --git a/scumm/smush/scumm_renderer.cpp b/scumm/smush/scumm_renderer.cpp
index 96fab15586..3375d275d9 100644
--- a/scumm/smush/scumm_renderer.cpp
+++ b/scumm/smush/scumm_renderer.cpp
@@ -41,7 +41,7 @@ public:
scumm_mixer(SoundMixer *);
virtual ~scumm_mixer();
bool init();
- _Channel * findChannel(int track);
+ _Channel * findChannel(int32 track);
bool addChannel(_Channel * c);
bool handleFrame();
bool stop();
@@ -49,7 +49,7 @@ public:
};
scumm_mixer::scumm_mixer(SoundMixer * m) : _mixer(m), _nextIndex(0) {
- for(int i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
+ for(int32 i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
_channels[i].id = -1;
_channels[i].chan = 0;
_channels[i].first = true;
@@ -64,9 +64,9 @@ bool scumm_mixer::init() {
return true;
}
-_Channel * scumm_mixer::findChannel(int track) {
+_Channel * scumm_mixer::findChannel(int32 track) {
debug(9, "scumm_mixer::findChannel(%d)", track);
- for(int i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
+ for(int32 i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
if(_channels[i].id == track)
return _channels[i].chan;
}
@@ -74,8 +74,8 @@ _Channel * scumm_mixer::findChannel(int track) {
}
bool scumm_mixer::addChannel(_Channel * c) {
- int track = c->getTrackIdentifier();
- int i;
+ int32 track = c->getTrackIdentifier();
+ int32 i;
debug(9, "scumm_mixer::addChannel(%d)", track);
@@ -129,17 +129,17 @@ bool scumm_mixer::handleFrame() {
_channels[i].id = -1;
_channels[i].chan = 0;
} else {
- int rate;
+ int32 rate;
bool stereo, is_short;
_channels[i].chan->getParameters(rate, stereo, is_short);
- int size = _channels[i].chan->availableSoundData();
+ int32 size = _channels[i].chan->availableSoundData();
debug(9, "channel %d : %d, %s, %d bits, %d", _channels[i].id, rate, stereo ? "stereo" : "mono", is_short ? 16 : 8, size);
- int flags = stereo ? SoundMixer::FLAG_STEREO : 0;
+ int32 flags = stereo ? SoundMixer::FLAG_STEREO : 0;
if(is_short) {
// FIXME this is one more data copy... we could get rid of it...
- short * data = new short[size * (stereo ? 2 : 1)];
+ short * data = new int16[size * (stereo ? 2 : 1)];
_channels[i].chan->getSoundData(data, size);
size *= stereo ? 4 : 2;
@@ -154,7 +154,7 @@ bool scumm_mixer::handleFrame() {
delete []data;
} else {
- char * data = new char[size*(stereo ? 2 : 1)];
+ int8 * data = new int8[size * (stereo ? 2 : 1)];
_channels[i].chan->getSoundData(data, size);
size *= stereo ? 2 : 1;
@@ -218,14 +218,14 @@ ScummRenderer::~ScummRenderer() {
_scumm->_sound->pauseBundleMusic(false);
}
-bool ScummRenderer::wait(int ms) {
+bool ScummRenderer::wait(int32 ms) {
while(_wait) {
_scumm->waitForTimer(1);
}
return true;
}
-bool ScummRenderer::startDecode(const char * fname, int version, int nbframes) {
+bool ScummRenderer::startDecode(const char * fname, int32 version, int32 nbframes) {
_scumm->_sound->pauseBundleMusic(true);
_scumm->videoFinished = 0;
_scumm->_insaneState = 1;
@@ -249,7 +249,7 @@ bool ScummRenderer::setPalette(const Palette & pal) {
return BaseRenderer::setPalette(pal); // For compatibility with possible subclass...
}
-void ScummRenderer::save(int frame) {
+void ScummRenderer::save(int32 frame) {
int width = MIN(getWidth(), _scumm->_realWidth);
int height = MIN(getHeight(), _scumm->_realHeight);
diff --git a/scumm/smush/scumm_renderer.h b/scumm/smush/scumm_renderer.h
index a9d6e18ff4..31dbd8af6e 100644
--- a/scumm/smush/scumm_renderer.h
+++ b/scumm/smush/scumm_renderer.h
@@ -48,12 +48,12 @@ private:
public:
ScummRenderer(Scumm * scumm);
virtual ~ScummRenderer();
- virtual bool wait(int ms);
+ virtual bool wait(int32 ms);
bool update();
protected:
- virtual bool startDecode(const char * fname, int version, int nbframes);
+ virtual bool startDecode(const char * fname, int32 version, int32 nbframes);
virtual bool setPalette(const Palette & pal);
- virtual void save(int frame = -1);
+ virtual void save(int32 frame = -1);
virtual Mixer * getMixer();
virtual bool prematureClose();
};