fixed some endian issues in the new SMUSH decoder; cleanup

svn-id: r4842
This commit is contained in:
Max Horn 2002-08-25 10:50:18 +00:00
parent 492400e9fa
commit ec47d8c80c
10 changed files with 46 additions and 52 deletions

View File

@ -23,6 +23,19 @@
#include "scummsys.h"
#ifndef ABS
#define ABS(x) ((x)>=0?(x):-(x))
#endif
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
int RGBMatch(byte *palette, int r, int g, int b);
int Blend(int src, int dst, byte *palette);
void ClearBlendCache(byte *palette, int weight);

View File

@ -60,7 +60,7 @@ public:
void setList(const StringList& list) { _list = list; scrollBarRecalc(); }
const StringList& getList() const { return _list; }
int getSelected() const { return _selectedItem; }
const ScummVM::String& getSelectedString() const { return _list[_selectedItem]; }
const String& getSelectedString() const { return _list[_selectedItem]; }
void setNumberingMode(int numberingMode) { _numberingMode = numberingMode; }
virtual void handleMouseDown(int x, int y, int button, int clickCount);

View File

@ -36,8 +36,6 @@
* - ...
*/
#define ABS(x) ((x) < 0 ? -(x) : (x))
NewGui::NewGui(Scumm *s) : _s(s), _use_alpha_blending(false),
_need_redraw(false),_prepare_for_gui(true),
_pauseDialog(0), _saveLoadDialog(0), _aboutDialog(0), _optionsDialog(0),

View File

@ -50,7 +50,7 @@ bool Bundle::openVoiceFile(char *filename)
_voiceFile = fopen(filename, "rb");
if (_voiceFile == NULL) {
printf("Bundle: Can't open voice bundle file: %s\n", filename);
warning("Bundle: Can't open voice bundle file: %s", filename);
return false;
}
@ -93,7 +93,7 @@ bool Bundle::openMusicFile(char *filename)
_musicFile = fopen(filename, "rb");
if (_musicFile == NULL) {
printf("Bundle: Can't open music bundle file: %s\n", filename);
warning("Bundle: Can't open music bundle file: %s", filename);
return false;
}
@ -132,7 +132,7 @@ int32 Bundle::decompressVoiceSampleByIndex(int32 index, byte *comp_final)
byte *comp_input, *comp_output;
if (_voiceFile == NULL) {
printf("Bundle: voice file is not open !\n");
warning("Bundle: voice file is not open!");
return 0;
}
@ -182,7 +182,7 @@ int32 Bundle::decompressMusicSampleByIndex(int32 index, int32 number, byte *comp
byte *comp_input;
if (_musicFile == NULL) {
printf("Bundle: music file is not open !\n");
warning("Bundle: music file is not open!");
return 0;
}
@ -228,7 +228,7 @@ int32 Bundle::decompressVoiceSampleByName(char *name, byte *comp_final)
int32 final_size = 0, i;
if (_voiceFile == NULL) {
printf("Bundle: voice file is not open !\n");
warning("Bundle: voice file is not open!");
return 0;
}
@ -246,7 +246,7 @@ int32 Bundle::decompressMusicSampleByName(char *name, int32 number, byte *comp_f
int32 final_size = 0, i;
if (_voiceFile == NULL) {
printf("Bundle: voice file is not open !\n");
warning("Bundle: voice file is not open!");
return 0;
}
@ -262,7 +262,7 @@ int32 Bundle::decompressMusicSampleByName(char *name, int32 number, byte *comp_f
int32 Bundle::getNumberOfMusicSamplesByIndex(int32 index)
{
if (_musicFile == NULL) {
printf("Bundle: music file is not open !\n");
warning("Bundle: music file is not open!");
return 0;
}
@ -276,7 +276,7 @@ int32 Bundle::getNumberOfMusicSamplesByName(char *name)
int32 number = 0, i;
if (_musicFile == NULL) {
printf("Bundle: music file is not open !\n");
warning("Bundle: music file is not open!");
return 0;
}
@ -651,7 +651,7 @@ int32 Bundle::decompressCodec(int32 codec, byte *comp_input, byte *comp_output,
break;
default:
printf("Bundle: Unknown codec %d!\n", (int)codec);
warning("Bundle: Unknown codec %d!", (int)codec);
output_size = 0;
break;
}

View File

@ -19,17 +19,14 @@
*
*/
#include <stdafx.h>
#include "stdafx.h"
#include "common/util.h"
#include "blitter.h"
#include "chunk.h"
#include <assert.h>
#include <string.h> // for memcpy
#ifndef min
#define min(x, y) ((x) > (y) ? (y) : (x))
#endif
Blitter::Blitter(char * ptr, const Point & dstsize, const Rect & src) :
_ptr(ptr),
_clip(dstsize),
@ -91,7 +88,7 @@ void Blitter::put(char data, unsigned int len) {
#endif
break;
}
int l = min((int)len, min(_clip.getX() - _cur.getX(), _src.right() - _cur.getX()));
int l = MIN((int)len, MIN(_clip.getX() - _cur.getX(), _src.right() - _cur.getX()));
len -= l;
memset(_offset, data, l);
advance(l);
@ -106,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()));
int l = MIN((int)len, MIN(_clip.getX() - _cur.getX(), _src.right() - _cur.getX()));
len -= l;
memcpy(_offset, ptr, l);
ptr += l;
@ -122,7 +119,7 @@ void Blitter::blit(Chunk & src, unsigned int len) {
#endif
break;
}
int l = min((int)len, min(_clip.getX() -_cur.getX(), _src.right() - _cur.getX()));
int l = MIN((int)len, MIN(_clip.getX() -_cur.getX(), _src.right() - _cur.getX()));
len -= l;
src.read(_offset, l);
advance(l);
@ -134,6 +131,7 @@ void Blitter::putBlock(unsigned int data) {
assert((_clip.getX() & 3) == 0);
unsigned int * dst = (unsigned int *)_offset;
int line_size = _clip.getX() >> 2;
data = TO_LE_32(data);
*dst = data; dst += line_size;
*dst = data; dst += line_size;
@ -154,10 +152,10 @@ void Blitter::putBlock(unsigned int d1, unsigned int d2, unsigned int d3, unsign
unsigned int * dst = (unsigned int *)_offset;
int line_size = _clip.getX() >> 2;
*dst = d4; dst += line_size;
*dst = d3; dst += line_size;
*dst = d2; dst += line_size;
*dst = d1;
*dst = TO_LE_32(d4); dst += line_size;
*dst = TO_LE_32(d3); dst += line_size;
*dst = TO_LE_32(d2); dst += line_size;
*dst = TO_LE_32(d1);
#ifdef DEBUG_CLIPPER
} else {
@ -173,10 +171,10 @@ void Blitter::putBlock(unsigned char * data) {
unsigned int * dst = (unsigned int *)_offset;
int line_size = _clip.getX() >> 2;
unsigned int * src = (unsigned int *)data;
*dst = *src++; dst += line_size;
*dst = *src++; dst += line_size;
*dst = *src++; dst += line_size;
*dst = *src++;
*dst = TO_LE_32(*src++); dst += line_size;
*dst = TO_LE_32(*src++); dst += line_size;
*dst = TO_LE_32(*src++); dst += line_size;
*dst = TO_LE_32(*src++);
#ifdef DEBUG_CLIPPER
} else {
_clippedBlock ++;
@ -190,10 +188,10 @@ void Blitter::putBlock(Chunk & src) {
assert((_clip.getX() & 3) == 0);
unsigned int * dst = (unsigned int *)_offset;
int line_size = _clip.getX() >> 2;
*dst = src.getDword(); dst += line_size;
*dst = src.getDword(); dst += line_size;
*dst = src.getDword(); dst += line_size;
*dst = src.getDword();
*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;
*dst = TO_LE_32(src.getDword());
#ifdef DEBUG_CLIPPER
} else {
_clippedBlock ++;

View File

@ -20,16 +20,14 @@
*/
#include <stdafx.h>
#include "common/util.h"
#include "frenderer.h"
#include "rect.h"
#include <assert.h>
#include <string.h> // for memcpy, strcat, strdup
#ifndef max
#define max(x, y) ((x) > (y) ? (x) : (y))
#endif
FontRenderer::FontRenderer(bool use_original_colors) : _nbChars(0), _color(-1), _original(use_original_colors) {
}
@ -75,7 +73,7 @@ int FontRenderer::stringHeight(const char * str) const {
for(int i = 0; str[i] != 0; i++) {
int h = charHeight(str[i]);
ret = max(ret, h);
ret = MAX(ret, h);
}
return ret;

View File

@ -26,9 +26,6 @@
#include <assert.h>
#include <string.h> // for memcpy.h
#ifndef min
#define min(x, y) ((x) > (y) ? (y) : (x))
#endif
ImuseChannel::ImuseChannel(int track, int freq) :
_track(track),

View File

@ -20,6 +20,7 @@
*/
#include <stdafx.h>
#include "common/util.h"
#include "player.h"
#include "renderer.h"
@ -34,10 +35,6 @@
#include <string.h> // for strchr, strrchr
#include <ctype.h> // for isdigit
#ifndef max
#define max(x, y) ((x) > (y) ? (x) : (y))
#endif
const int WAIT = 100;
/*! @brief parser and map of string resources
@ -371,7 +368,7 @@ void SmushPlayer::handleTextResource(Chunk & b) {
if(flags == 0 || flags == 4) {
fr->drawStringAbsolute(str, _curBuffer, _frameSize, pos_x, pos_y);
} else {
fr->drawStringCentered(str, _curBuffer, _frameSize, max(pos_y, top), left, width, pos_x);
fr->drawStringCentered(str, _curBuffer, _frameSize, MAX(pos_y, top), left, width, pos_x);
}
}

View File

@ -26,9 +26,6 @@
#include <assert.h>
#include <string.h> // for memcpy.h
#ifndef min
#define min(x, y) ((x) > (y) ? (y) : (x))
#endif
void SaudChannel::handleStrk(Chunk & b) {
int size = b.getSize();

View File

@ -39,10 +39,6 @@
#include "rect.h"
#include "blitter.h"
#ifndef min
#define min(x, y) ((x) > (y) ? (y) : (x))
#endif
class scumm_mixer;
class ScummRenderer : public BaseRenderer {