mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-11 11:11:20 +00:00
changed name from Chunck to Chunk
svn-id: r4829
This commit is contained in:
parent
69cca0906e
commit
901b4a07a6
@ -28,7 +28,7 @@ SIMON_OBJS = simon/debug.o simon/items.o simon/midi.o simon/res.o simon/simon.o
|
|||||||
|
|
||||||
SMUSH_OBJS = scumm/smush/blitter.o \
|
SMUSH_OBJS = scumm/smush/blitter.o \
|
||||||
scumm/smush/brenderer.o \
|
scumm/smush/brenderer.o \
|
||||||
scumm/smush/chunck.o \
|
scumm/smush/chunk.o \
|
||||||
scumm/smush/codec1.o \
|
scumm/smush/codec1.o \
|
||||||
scumm/smush/codec37.o \
|
scumm/smush/codec37.o \
|
||||||
scumm/smush/codec44.o \
|
scumm/smush/codec44.o \
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <stdafx.h>
|
#include <stdafx.h>
|
||||||
#include "blitter.h"
|
#include "blitter.h"
|
||||||
#include "chunck.h"
|
#include "chunk.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h> // for memcpy
|
#include <string.h> // for memcpy
|
||||||
@ -114,7 +114,7 @@ void Blitter::blit(char * ptr, unsigned int len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Blitter::blit(Chunck & src, unsigned int len) {
|
void Blitter::blit(Chunk & src, unsigned int len) {
|
||||||
while(len) {
|
while(len) {
|
||||||
if(_outside) {
|
if(_outside) {
|
||||||
#ifdef DEBUG_CLIPPER
|
#ifdef DEBUG_CLIPPER
|
||||||
@ -185,7 +185,7 @@ void Blitter::putBlock(unsigned char * data) {
|
|||||||
advanceBlock();
|
advanceBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Blitter::putBlock(Chunck & src) {
|
void Blitter::putBlock(Chunk & src) {
|
||||||
if(_cur.getX() + 3 < _src.right() && _cur.getY() + 3 < _src.bottom()) { // This is clipping
|
if(_cur.getX() + 3 < _src.right() && _cur.getY() + 3 < _src.bottom()) { // This is clipping
|
||||||
assert((_clip.getX() & 3) == 0);
|
assert((_clip.getX() & 3) == 0);
|
||||||
unsigned int * dst = (unsigned int *)_offset;
|
unsigned int * dst = (unsigned int *)_offset;
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include "rect.h"
|
#include "rect.h"
|
||||||
|
|
||||||
class Chunck;
|
class Chunk;
|
||||||
/*! @brief class for handling blitting on a frame buffer
|
/*! @brief class for handling blitting on a frame buffer
|
||||||
|
|
||||||
This class allows to perform secure blitting to a frame buffer in several ways.
|
This class allows to perform secure blitting to a frame buffer in several ways.
|
||||||
@ -64,13 +64,13 @@ public:
|
|||||||
Blitter(char * buffer, const Point & dstsize, const Rect & src);
|
Blitter(char * buffer, const Point & dstsize, const Rect & src);
|
||||||
virtual ~Blitter();
|
virtual ~Blitter();
|
||||||
void blit(char *, unsigned int); //!< This method allows to blit directly some data from a buffer
|
void blit(char *, unsigned int); //!< This method allows to blit directly some data from a buffer
|
||||||
void blit(Chunck &, unsigned int); //!< This method allows to blit directly some data from a chunck
|
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); //!< This method allows to blit one byte
|
||||||
void put(char, unsigned int); //!< This method allows to blit one byte several times
|
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 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 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 putBlock(unsigned int); //!< This method allows to blit one block from an int value repeated 4 time
|
||||||
void putBlock(Chunck &); //!< This method allows to blit one block directly read from a chunck
|
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 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 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 blockCopy(int); //!< This method allows to copy one block from another separated by the given offset
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class Chunck;
|
class Chunk;
|
||||||
class ContChunck;
|
class ContChunk;
|
||||||
|
|
||||||
/*! @brief interface for a sound channel (a track)
|
/*! @brief interface for a sound channel (a track)
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class _Channel {
|
|||||||
public:
|
public:
|
||||||
virtual ~_Channel() {};
|
virtual ~_Channel() {};
|
||||||
// called by the smush_player
|
// called by the smush_player
|
||||||
virtual bool appendData(Chunck & b, int size) = 0;
|
virtual bool appendData(Chunk & b, int size) = 0;
|
||||||
virtual bool setParameters(int, int, int, int) = 0;
|
virtual bool setParameters(int, int, int, int) = 0;
|
||||||
virtual bool checkParameters(int, int, int, int, int) = 0;
|
virtual bool checkParameters(int, int, int, int, int) = 0;
|
||||||
// called by the mixer
|
// called by the mixer
|
||||||
@ -76,9 +76,9 @@ private:
|
|||||||
int _sbufferSize; //!< sound buffer size
|
int _sbufferSize; //!< sound buffer size
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void handleStrk(Chunck & c);
|
void handleStrk(Chunk & c);
|
||||||
void handleSmrk(Chunck & c);
|
void handleSmrk(Chunk & c);
|
||||||
void handleShdr(Chunck & c);
|
void handleShdr(Chunk & c);
|
||||||
bool handleSubTags(int & offset);
|
bool handleSubTags(int & offset);
|
||||||
bool processBuffer();
|
bool processBuffer();
|
||||||
void recalcVolumeTable();
|
void recalcVolumeTable();
|
||||||
@ -89,7 +89,7 @@ public:
|
|||||||
bool isTerminated() const;
|
bool isTerminated() const;
|
||||||
bool setParameters(int duration, int flags, int vol1, int vol2);
|
bool setParameters(int duration, int flags, int vol1, int vol2);
|
||||||
bool checkParameters(int index, int duration, int flags, int vol1, int vol2);
|
bool checkParameters(int index, int duration, int flags, int vol1, int vol2);
|
||||||
bool appendData(Chunck & b, int size);
|
bool appendData(Chunk & b, int size);
|
||||||
int availableSoundData() const;
|
int availableSoundData() const;
|
||||||
void getSoundData(short * sound_buffer, int size);
|
void getSoundData(short * sound_buffer, int size);
|
||||||
void getSoundData(char * sound_buffer, int size) { error("16bit request for SAUD channel should never happen"); };
|
void getSoundData(char * sound_buffer, int size) { error("16bit request for SAUD channel should never happen"); };
|
||||||
@ -128,11 +128,11 @@ protected:
|
|||||||
int decode(int size, int &ret);
|
int decode(int size, int &ret);
|
||||||
void decode();
|
void decode();
|
||||||
bool processBuffer();
|
bool processBuffer();
|
||||||
bool handleMap(Chunck &);
|
bool handleMap(Chunk &);
|
||||||
bool handleFormat(Chunck &);
|
bool handleFormat(Chunk &);
|
||||||
bool handleText(Chunck &);
|
bool handleText(Chunk &);
|
||||||
bool handleRegion(Chunck &);
|
bool handleRegion(Chunk &);
|
||||||
bool handleStop(Chunck &);
|
bool handleStop(Chunk &);
|
||||||
bool handleSubTags(int & offset);
|
bool handleSubTags(int & offset);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -141,7 +141,7 @@ public:
|
|||||||
bool isTerminated() const;
|
bool isTerminated() const;
|
||||||
bool setParameters(int nbframes, int size, int unk1, int unk2);
|
bool setParameters(int nbframes, int size, int unk1, int unk2);
|
||||||
bool checkParameters(int index, int nbframes, int size, int unk1, int unk2);
|
bool checkParameters(int index, int nbframes, int size, int unk1, int unk2);
|
||||||
bool appendData(Chunck & b, int size);
|
bool appendData(Chunk & b, int size);
|
||||||
int availableSoundData() const;
|
int availableSoundData() const;
|
||||||
void getSoundData(short * sound_buffer, int size);
|
void getSoundData(short * sound_buffer, int size);
|
||||||
void getSoundData(char * sound_buffer, int size);
|
void getSoundData(char * sound_buffer, int size);
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
/* ScummVM - Scumm Interpreter
|
|
||||||
* Copyright (C) 2001/2002 The ScummVM project
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*
|
|
||||||
* $Header$
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __CHUNCK_TYPE_H
|
|
||||||
#define __CHUNCK_TYPE_H
|
|
||||||
|
|
||||||
#include "chunck.h"
|
|
||||||
|
|
||||||
#define MAKE_TYPE(a,b,c,d) (Chunck::type)( ((a) << 24) | ((b) << 16) | ((c) << 8) | (d) )
|
|
||||||
|
|
||||||
static const Chunck::type TYPE_ANIM = MAKE_TYPE('A', 'N', 'I', 'M');
|
|
||||||
static const Chunck::type TYPE_AHDR = MAKE_TYPE('A', 'H', 'D', 'R');
|
|
||||||
static const Chunck::type TYPE_FRME = MAKE_TYPE('F', 'R', 'M', 'E');
|
|
||||||
static const Chunck::type TYPE_NPAL = MAKE_TYPE('N', 'P', 'A', 'L');
|
|
||||||
static const Chunck::type TYPE_FOBJ = MAKE_TYPE('F', 'O', 'B', 'J');
|
|
||||||
static const Chunck::type TYPE_PSAD = MAKE_TYPE('P', 'S', 'A', 'D');
|
|
||||||
static const Chunck::type TYPE_TRES = MAKE_TYPE('T', 'R', 'E', 'S');
|
|
||||||
static const Chunck::type TYPE_XPAL = MAKE_TYPE('X', 'P', 'A', 'L');
|
|
||||||
static const Chunck::type TYPE_IACT = MAKE_TYPE('I', 'A', 'C', 'T');
|
|
||||||
static const Chunck::type TYPE_STOR = MAKE_TYPE('S', 'T', 'O', 'R');
|
|
||||||
static const Chunck::type TYPE_FTCH = MAKE_TYPE('F', 'T', 'C', 'H');
|
|
||||||
static const Chunck::type TYPE_SKIP = MAKE_TYPE('S', 'K', 'I', 'P');
|
|
||||||
static const Chunck::type TYPE_STRK = MAKE_TYPE('S', 'T', 'R', 'K');
|
|
||||||
static const Chunck::type TYPE_SMRK = MAKE_TYPE('S', 'M', 'R', 'K');
|
|
||||||
static const Chunck::type TYPE_SHDR = MAKE_TYPE('S', 'H', 'D', 'R');
|
|
||||||
static const Chunck::type TYPE_SDAT = MAKE_TYPE('S', 'D', 'A', 'T');
|
|
||||||
static const Chunck::type TYPE_SAUD = MAKE_TYPE('S', 'A', 'U', 'D');
|
|
||||||
static const Chunck::type TYPE_iMUS = MAKE_TYPE('i', 'M', 'U', 'S');
|
|
||||||
static const Chunck::type TYPE_FRMT = MAKE_TYPE('F', 'R', 'M', 'T');
|
|
||||||
static const Chunck::type TYPE_TEXT = MAKE_TYPE('T', 'E', 'X', 'T');
|
|
||||||
static const Chunck::type TYPE_REGN = MAKE_TYPE('R', 'E', 'G', 'N');
|
|
||||||
static const Chunck::type TYPE_STOP = MAKE_TYPE('S', 'T', 'O', 'P');
|
|
||||||
static const Chunck::type TYPE_MAP_ = MAKE_TYPE('M', 'A', 'P', ' ');
|
|
||||||
static const Chunck::type TYPE_DATA = MAKE_TYPE('D', 'A', 'T', 'A');
|
|
||||||
static const Chunck::type TYPE_ETRS = MAKE_TYPE('E', 'T', 'R', 'S');
|
|
||||||
|
|
||||||
#undef MAKE_TYPE
|
|
||||||
|
|
||||||
#endif
|
|
@ -20,14 +20,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdafx.h>
|
#include <stdafx.h>
|
||||||
#include "chunck.h"
|
#include "Chunk.h"
|
||||||
|
|
||||||
#include <stdio.h> // for FILE, fopen, fclose, fseek and ftell
|
#include <stdio.h> // for FILE, fopen, fclose, fseek and ftell
|
||||||
#include <string.h> // for memcpy
|
#include <string.h> // for memcpy
|
||||||
|
|
||||||
/*! @brief very small and fast wrapper for a ifstream.
|
/*! @brief very small and fast wrapper for a ifstream.
|
||||||
|
|
||||||
implements reference counting, so that ::file_chunck does not leak memory !
|
implements reference counting, so that ::file_Chunk does not leak memory !
|
||||||
*/
|
*/
|
||||||
class FilePtr {
|
class FilePtr {
|
||||||
char * _filename;
|
char * _filename;
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const char * Chunck::ChunckString(Chunck::type t) {
|
const char * Chunk::ChunkString(Chunk::type t) {
|
||||||
static char data[5];
|
static char data[5];
|
||||||
data[0] = (char)((t >> 24) & 0xFF);
|
data[0] = (char)((t >> 24) & 0xFF);
|
||||||
data[1] = (char)((t >> 16) & 0xFF);
|
data[1] = (char)((t >> 16) & 0xFF);
|
||||||
@ -80,14 +80,14 @@ const char * Chunck::ChunckString(Chunck::type t) {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileChunck::FileChunck() : _data(0), _type(0), _size(0), _curPos(0) {
|
FileChunk::FileChunk() : _data(0), _type(0), _size(0), _curPos(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileChunck::~FileChunck() {
|
FileChunk::~FileChunk() {
|
||||||
if(_data) _data->decRef();
|
if(_data) _data->decRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileChunck::FileChunck(const char * fname) {
|
FileChunk::FileChunk(const char * fname) {
|
||||||
_data = new FilePtr(fname);
|
_data = new FilePtr(fname);
|
||||||
_data->read(&_type, 4);
|
_data->read(&_type, 4);
|
||||||
_type = TO_BE_32(_type);
|
_type = TO_BE_32(_type);
|
||||||
@ -97,16 +97,16 @@ FileChunck::FileChunck(const char * fname) {
|
|||||||
_curPos = 0;
|
_curPos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chunck::type FileChunck::getType() const {
|
Chunk::type FileChunk::getType() const {
|
||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int FileChunck::getSize() const {
|
unsigned int FileChunk::getSize() const {
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chunck * FileChunck::subBlock() {
|
Chunk * FileChunk::subBlock() {
|
||||||
FileChunck * ptr = new FileChunck;
|
FileChunk * ptr = new FileChunk;
|
||||||
ptr->_data = _data;
|
ptr->_data = _data;
|
||||||
_data->incRef();
|
_data->incRef();
|
||||||
_data->seek(_offset + _curPos);
|
_data->seek(_offset + _curPos);
|
||||||
@ -121,15 +121,15 @@ Chunck * FileChunck::subBlock() {
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileChunck::eof() const {
|
bool FileChunk::eof() const {
|
||||||
return _curPos >= _size;
|
return _curPos >= _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int FileChunck::tell() const {
|
unsigned int FileChunk::tell() const {
|
||||||
return _curPos;
|
return _curPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileChunck::seek(int delta, seek_type dir) {
|
bool FileChunk::seek(int delta, seek_type dir) {
|
||||||
switch(dir) {
|
switch(dir) {
|
||||||
case seek_cur:
|
case seek_cur:
|
||||||
_curPos += delta;
|
_curPos += delta;
|
||||||
@ -149,7 +149,7 @@ bool FileChunck::seek(int delta, seek_type dir) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileChunck::read(void * buffer, unsigned int size) {
|
bool FileChunk::read(void * buffer, unsigned int size) {
|
||||||
if(size <= 0 || (_curPos + size) > _size) error("invalid buffer read request");
|
if(size <= 0 || (_curPos + size) > _size) error("invalid buffer read request");
|
||||||
_data->seek(_offset + _curPos);
|
_data->seek(_offset + _curPos);
|
||||||
_data->read(buffer, size);
|
_data->read(buffer, size);
|
||||||
@ -157,7 +157,7 @@ bool FileChunck::read(void * buffer, unsigned int size) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char FileChunck::getChar() {
|
char FileChunk::getChar() {
|
||||||
if(_curPos >= _size) error("invalid char read request");
|
if(_curPos >= _size) error("invalid char read request");
|
||||||
_data->seek(_offset + _curPos);
|
_data->seek(_offset + _curPos);
|
||||||
char buffer;
|
char buffer;
|
||||||
@ -166,7 +166,7 @@ char FileChunck::getChar() {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char FileChunck::getByte() {
|
unsigned char FileChunk::getByte() {
|
||||||
if(_curPos >= _size) error("invalid byte read request");
|
if(_curPos >= _size) error("invalid byte read request");
|
||||||
_data->seek(_offset + _curPos);
|
_data->seek(_offset + _curPos);
|
||||||
unsigned char buffer;
|
unsigned char buffer;
|
||||||
@ -175,12 +175,12 @@ unsigned char FileChunck::getByte() {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
short FileChunck::getShort() {
|
short FileChunk::getShort() {
|
||||||
unsigned short buffer = getWord();
|
unsigned short buffer = getWord();
|
||||||
return *((short*)&buffer);
|
return *((short*)&buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short FileChunck::getWord() {
|
unsigned short FileChunk::getWord() {
|
||||||
if(_curPos >= _size - 1) error("invalid word read request");
|
if(_curPos >= _size - 1) error("invalid word read request");
|
||||||
_data->seek(_offset + _curPos);
|
_data->seek(_offset + _curPos);
|
||||||
unsigned short buffer;
|
unsigned short buffer;
|
||||||
@ -189,7 +189,7 @@ unsigned short FileChunck::getWord() {
|
|||||||
return TO_LE_16(buffer);
|
return TO_LE_16(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int FileChunck::getDword() {
|
unsigned int FileChunk::getDword() {
|
||||||
if(_curPos >= _size - 3) error("invalid dword read request");
|
if(_curPos >= _size - 3) error("invalid dword read request");
|
||||||
_data->seek(_offset + _curPos);
|
_data->seek(_offset + _curPos);
|
||||||
unsigned int buffer;
|
unsigned int buffer;
|
||||||
@ -198,37 +198,37 @@ unsigned int FileChunck::getDword() {
|
|||||||
return TO_LE_32(buffer);
|
return TO_LE_32(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContChunck::ContChunck(char * data) {
|
ContChunk::ContChunk(char * data) {
|
||||||
if(data == 0) error("Chunck() called with NULL pointer");
|
if(data == 0) error("Chunk() called with NULL pointer");
|
||||||
_type = (Chunck::type)READ_BE_UINT32(data);
|
_type = (Chunk::type)READ_BE_UINT32(data);
|
||||||
_size = READ_BE_UINT32(data+4);
|
_size = READ_BE_UINT32(data+4);
|
||||||
_data = data + sizeof(Chunck::type) + sizeof(unsigned int);
|
_data = data + sizeof(Chunk::type) + sizeof(unsigned int);
|
||||||
_curPos = 0;
|
_curPos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chunck::type ContChunck::getType() const {
|
Chunk::type ContChunk::getType() const {
|
||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ContChunck::getSize() const {
|
unsigned int ContChunk::getSize() const {
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chunck * ContChunck::subBlock() {
|
Chunk * ContChunk::subBlock() {
|
||||||
ContChunck * ptr = new ContChunck(_data + _curPos);
|
ContChunk * ptr = new ContChunk(_data + _curPos);
|
||||||
seek(sizeof(Chunck::type) + sizeof(unsigned int) + ptr->getSize());
|
seek(sizeof(Chunk::type) + sizeof(unsigned int) + ptr->getSize());
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContChunck::eof() const {
|
bool ContChunk::eof() const {
|
||||||
return _curPos >= _size;
|
return _curPos >= _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ContChunck::tell() const {
|
unsigned int ContChunk::tell() const {
|
||||||
return _curPos;
|
return _curPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContChunck::seek(int delta, seek_type dir) {
|
bool ContChunk::seek(int delta, seek_type dir) {
|
||||||
switch(dir) {
|
switch(dir) {
|
||||||
case seek_cur:
|
case seek_cur:
|
||||||
_curPos += delta;
|
_curPos += delta;
|
||||||
@ -248,39 +248,39 @@ bool ContChunck::seek(int delta, seek_type dir) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContChunck::read(void * buffer, unsigned int size) {
|
bool ContChunk::read(void * buffer, unsigned int size) {
|
||||||
if(size <= 0 || (_curPos + size) > _size) error("invalid buffer read request");
|
if(size <= 0 || (_curPos + size) > _size) error("invalid buffer read request");
|
||||||
memcpy(buffer, _data + _curPos, size);
|
memcpy(buffer, _data + _curPos, size);
|
||||||
_curPos += size;
|
_curPos += size;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char ContChunck::getChar() {
|
char ContChunk::getChar() {
|
||||||
if(_curPos >= _size) error("invalid char read request");
|
if(_curPos >= _size) error("invalid char read request");
|
||||||
return _data[_curPos++];
|
return _data[_curPos++];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char ContChunck::getByte() {
|
unsigned char ContChunk::getByte() {
|
||||||
if(_curPos >= _size) error("invalid byte read request");
|
if(_curPos >= _size) error("invalid byte read request");
|
||||||
unsigned char * ptr = (unsigned char *)(_data + _curPos);
|
unsigned char * ptr = (unsigned char *)(_data + _curPos);
|
||||||
_curPos += 1;
|
_curPos += 1;
|
||||||
return *ptr;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
short ContChunck::getShort() {
|
short ContChunk::getShort() {
|
||||||
if(_curPos >= _size - 1) error("invalid short read request");
|
if(_curPos >= _size - 1) error("invalid short read request");
|
||||||
unsigned short buffer = getWord();
|
unsigned short buffer = getWord();
|
||||||
return *((short*)&buffer);
|
return *((short*)&buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short ContChunck::getWord() {
|
unsigned short ContChunk::getWord() {
|
||||||
if(_curPos >= _size - 1) error("invalid word read request");
|
if(_curPos >= _size - 1) error("invalid word read request");
|
||||||
unsigned short * ptr = (unsigned short *)(_data + _curPos);
|
unsigned short * ptr = (unsigned short *)(_data + _curPos);
|
||||||
_curPos += 2;
|
_curPos += 2;
|
||||||
return READ_LE_UINT16(ptr);
|
return READ_LE_UINT16(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ContChunck::getDword() {
|
unsigned int ContChunk::getDword() {
|
||||||
if(_curPos >= _size - 3) error("invalid dword read request");
|
if(_curPos >= _size - 3) error("invalid dword read request");
|
||||||
unsigned int * ptr = (unsigned int *)(_data + _curPos);
|
unsigned int * ptr = (unsigned int *)(_data + _curPos);
|
||||||
_curPos += 4;
|
_curPos += 4;
|
@ -19,22 +19,22 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __CHUNCK_H_
|
#ifndef __CHUNK_H_
|
||||||
#define __CHUNCK_H_
|
#define __CHUNK_H_
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
/*! @brief Interface for chunck handling
|
/*! @brief Interface for Chunk handling
|
||||||
|
|
||||||
This class is an interface for reading from a chunck.
|
This class is an interface for reading from a Chunk.
|
||||||
|
|
||||||
\todo handle big endian system.
|
\todo handle big endian system.
|
||||||
*/
|
*/
|
||||||
class Chunck {
|
class Chunk {
|
||||||
public:
|
public:
|
||||||
enum seek_type { seek_start, seek_end, seek_cur };
|
enum seek_type { seek_start, seek_end, seek_cur };
|
||||||
virtual ~Chunck() {};
|
virtual ~Chunk() {};
|
||||||
typedef unsigned int type; //!< type of a chunck (i.e. The first 4byte field of the chunck structure).
|
typedef unsigned int type; //!< type of a Chunk (i.e. The first 4byte field of the Chunk structure).
|
||||||
/*! @brief convert a type to a string
|
/*! @brief convert a type to a string
|
||||||
|
|
||||||
Utility function that convert a type to a string.
|
Utility function that convert a type to a string.
|
||||||
@ -43,14 +43,14 @@ public:
|
|||||||
|
|
||||||
@return the converted string
|
@return the converted string
|
||||||
*/
|
*/
|
||||||
static const char * ChunckString(type t);
|
static const char * ChunkString(type t);
|
||||||
|
|
||||||
virtual type getType() const = 0; //!< return the type of the chunck
|
virtual type getType() const = 0; //!< return the type of the Chunk
|
||||||
virtual unsigned int getSize() const = 0; //!< return the size of the chunck
|
virtual unsigned int getSize() const = 0; //!< return the size of the Chunk
|
||||||
virtual Chunck * subBlock() = 0; //!< extract a subchunck from the current read position
|
virtual Chunk * subBlock() = 0; //!< extract a subChunk from the current read position
|
||||||
virtual bool eof() const = 0; //!< is the chunck completely read ?
|
virtual bool eof() const = 0; //!< is the Chunk completely read ?
|
||||||
virtual unsigned int tell() const = 0; //!< get the chunck current read position
|
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 chunck
|
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 bool read(void * buffer, unsigned int size) = 0; //!< read some data for the current read position
|
||||||
virtual char getChar() = 0; //!< extract the character at the current read position
|
virtual char getChar() = 0; //!< extract the character at the current read position
|
||||||
virtual unsigned char getByte() = 0; //!< extract the byte at the current read position
|
virtual unsigned char getByte() = 0; //!< extract the byte at the current read position
|
||||||
@ -61,12 +61,12 @@ public:
|
|||||||
|
|
||||||
class FilePtr;
|
class FilePtr;
|
||||||
|
|
||||||
/*! @brief file based ::chunck
|
/*! @brief file based ::Chunk
|
||||||
|
|
||||||
This class is an implementation of ::chunck that handles file.
|
This class is an implementation of ::Chunk that handles file.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
class FileChunck : public Chunck {
|
class FileChunk : public Chunk {
|
||||||
private:
|
private:
|
||||||
FilePtr * _data;
|
FilePtr * _data;
|
||||||
type _type;
|
type _type;
|
||||||
@ -74,13 +74,13 @@ private:
|
|||||||
unsigned int _offset;
|
unsigned int _offset;
|
||||||
unsigned int _curPos;
|
unsigned int _curPos;
|
||||||
protected:
|
protected:
|
||||||
FileChunck();
|
FileChunk();
|
||||||
public:
|
public:
|
||||||
FileChunck(const char * fname);
|
FileChunk(const char * fname);
|
||||||
virtual ~FileChunck();
|
virtual ~FileChunk();
|
||||||
type getType() const;
|
type getType() const;
|
||||||
unsigned int getSize() const;
|
unsigned int getSize() const;
|
||||||
Chunck * subBlock();
|
Chunk * subBlock();
|
||||||
bool eof() const;
|
bool eof() const;
|
||||||
unsigned int tell() const;
|
unsigned int tell() const;
|
||||||
bool seek(int delta, seek_type dir = seek_cur);
|
bool seek(int delta, seek_type dir = seek_cur);
|
||||||
@ -92,21 +92,21 @@ public:
|
|||||||
unsigned int getDword();
|
unsigned int getDword();
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! @brief memory based ::chunck
|
/*! @brief memory based ::Chunk
|
||||||
|
|
||||||
This class is an implementation of ::chunck that handles a memory buffer.
|
This class is an implementation of ::Chunk that handles a memory buffer.
|
||||||
*/
|
*/
|
||||||
class ContChunck : public Chunck {
|
class ContChunk : public Chunk {
|
||||||
private:
|
private:
|
||||||
char * _data;
|
char * _data;
|
||||||
Chunck::type _type;
|
Chunk::type _type;
|
||||||
unsigned int _size;
|
unsigned int _size;
|
||||||
unsigned int _curPos;
|
unsigned int _curPos;
|
||||||
public:
|
public:
|
||||||
ContChunck(char * data);
|
ContChunk(char * data);
|
||||||
Chunck::type getType() const;
|
Chunk::type getType() const;
|
||||||
unsigned int getSize() const;
|
unsigned int getSize() const;
|
||||||
Chunck * subBlock();
|
Chunk * subBlock();
|
||||||
bool eof() const;
|
bool eof() const;
|
||||||
unsigned int tell() const;
|
unsigned int tell() const;
|
||||||
bool seek(int delta, seek_type dir = seek_cur);
|
bool seek(int delta, seek_type dir = seek_cur);
|
57
scumm/smush/chunk_type.h
Normal file
57
scumm/smush/chunk_type.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/* ScummVM - Scumm Interpreter
|
||||||
|
* Copyright (C) 2001/2002 The ScummVM project
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* $Header$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CHUNK_TYPE_H
|
||||||
|
#define __CHUNK_TYPE_H
|
||||||
|
|
||||||
|
#include "Chunk.h"
|
||||||
|
|
||||||
|
#define MAKE_TYPE(a,b,c,d) (Chunk::type)( ((a) << 24) | ((b) << 16) | ((c) << 8) | (d) )
|
||||||
|
|
||||||
|
static const Chunk::type TYPE_ANIM = MAKE_TYPE('A', 'N', 'I', 'M');
|
||||||
|
static const Chunk::type TYPE_AHDR = MAKE_TYPE('A', 'H', 'D', 'R');
|
||||||
|
static const Chunk::type TYPE_FRME = MAKE_TYPE('F', 'R', 'M', 'E');
|
||||||
|
static const Chunk::type TYPE_NPAL = MAKE_TYPE('N', 'P', 'A', 'L');
|
||||||
|
static const Chunk::type TYPE_FOBJ = MAKE_TYPE('F', 'O', 'B', 'J');
|
||||||
|
static const Chunk::type TYPE_PSAD = MAKE_TYPE('P', 'S', 'A', 'D');
|
||||||
|
static const Chunk::type TYPE_TRES = MAKE_TYPE('T', 'R', 'E', 'S');
|
||||||
|
static const Chunk::type TYPE_XPAL = MAKE_TYPE('X', 'P', 'A', 'L');
|
||||||
|
static const Chunk::type TYPE_IACT = MAKE_TYPE('I', 'A', 'C', 'T');
|
||||||
|
static const Chunk::type TYPE_STOR = MAKE_TYPE('S', 'T', 'O', 'R');
|
||||||
|
static const Chunk::type TYPE_FTCH = MAKE_TYPE('F', 'T', 'C', 'H');
|
||||||
|
static const Chunk::type TYPE_SKIP = MAKE_TYPE('S', 'K', 'I', 'P');
|
||||||
|
static const Chunk::type TYPE_STRK = MAKE_TYPE('S', 'T', 'R', 'K');
|
||||||
|
static const Chunk::type TYPE_SMRK = MAKE_TYPE('S', 'M', 'R', 'K');
|
||||||
|
static const Chunk::type TYPE_SHDR = MAKE_TYPE('S', 'H', 'D', 'R');
|
||||||
|
static const Chunk::type TYPE_SDAT = MAKE_TYPE('S', 'D', 'A', 'T');
|
||||||
|
static const Chunk::type TYPE_SAUD = MAKE_TYPE('S', 'A', 'U', 'D');
|
||||||
|
static const Chunk::type TYPE_iMUS = MAKE_TYPE('i', 'M', 'U', 'S');
|
||||||
|
static const Chunk::type TYPE_FRMT = MAKE_TYPE('F', 'R', 'M', 'T');
|
||||||
|
static const Chunk::type TYPE_TEXT = MAKE_TYPE('T', 'E', 'X', 'T');
|
||||||
|
static const Chunk::type TYPE_REGN = MAKE_TYPE('R', 'E', 'G', 'N');
|
||||||
|
static const Chunk::type TYPE_STOP = MAKE_TYPE('S', 'T', 'O', 'P');
|
||||||
|
static const Chunk::type TYPE_MAP_ = MAKE_TYPE('M', 'A', 'P', ' ');
|
||||||
|
static const Chunk::type TYPE_DATA = MAKE_TYPE('D', 'A', 'T', 'A');
|
||||||
|
static const Chunk::type TYPE_ETRS = MAKE_TYPE('E', 'T', 'R', 'S');
|
||||||
|
|
||||||
|
#undef MAKE_TYPE
|
||||||
|
|
||||||
|
#endif
|
@ -21,13 +21,13 @@
|
|||||||
|
|
||||||
#include <stdafx.h>
|
#include <stdafx.h>
|
||||||
#include "codec1.h"
|
#include "codec1.h"
|
||||||
#include "chunck.h"
|
#include "chunk.h"
|
||||||
#include "blitter.h"
|
#include "blitter.h"
|
||||||
|
|
||||||
Codec1Decoder::~Codec1Decoder() {
|
Codec1Decoder::~Codec1Decoder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Codec1Decoder::decode(Blitter & dst, Chunck & src) {
|
bool Codec1Decoder::decode(Blitter & dst, Chunk & src) {
|
||||||
int val;
|
int val;
|
||||||
int size_line;
|
int size_line;
|
||||||
int code, length;
|
int code, length;
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
class Codec1Decoder : public Decoder {
|
class Codec1Decoder : public Decoder {
|
||||||
public:
|
public:
|
||||||
virtual ~Codec1Decoder();
|
virtual ~Codec1Decoder();
|
||||||
bool decode(Blitter &, Chunck &);
|
bool decode(Blitter &, Chunk &);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <stdafx.h>
|
#include <stdafx.h>
|
||||||
#include "codec37.h"
|
#include "codec37.h"
|
||||||
#include "chunck.h"
|
#include "chunk.h"
|
||||||
#include "blitter.h"
|
#include "blitter.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -200,7 +200,7 @@ void Codec37Decoder::maketable(int pitch, int index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Codec37Decoder::proc1(Blitter & dst, Chunck & src, int next_offs, int bw, int bh, int size) {
|
void Codec37Decoder::proc1(Blitter & dst, Chunk & src, int next_offs, int bw, int bh, int size) {
|
||||||
unsigned char * decoded = new unsigned char[size];
|
unsigned char * decoded = new unsigned char[size];
|
||||||
int w = 0;
|
int w = 0;
|
||||||
while(!src.eof()) {
|
while(!src.eof()) {
|
||||||
@ -234,7 +234,7 @@ void Codec37Decoder::proc1(Blitter & dst, Chunck & src, int next_offs, int bw, i
|
|||||||
delete []decoded;
|
delete []decoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Codec37Decoder::proc2(Blitter & dst, Chunck & src, int size) { // This is codec1 like...
|
void Codec37Decoder::proc2(Blitter & dst, Chunk & src, int size) { // This is codec1 like...
|
||||||
#ifdef DEBUG_CODEC37_PROC2
|
#ifdef DEBUG_CODEC37_PROC2
|
||||||
int decoded_size = 0;
|
int decoded_size = 0;
|
||||||
int coded_size = 0;
|
int coded_size = 0;
|
||||||
@ -258,7 +258,7 @@ void Codec37Decoder::proc2(Blitter & dst, Chunck & src, int size) { // This is c
|
|||||||
} while (size);
|
} while (size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Codec37Decoder::proc3WithFDFE(Blitter & dst, Chunck & src, int next_offs, int bw, int bh) {
|
void Codec37Decoder::proc3WithFDFE(Blitter & dst, Chunk & src, int next_offs, int bw, int bh) {
|
||||||
do {
|
do {
|
||||||
int i = bw;
|
int i = bw;
|
||||||
do {
|
do {
|
||||||
@ -293,7 +293,7 @@ void Codec37Decoder::proc3WithFDFE(Blitter & dst, Chunck & src, int next_offs, i
|
|||||||
} while (--bh);
|
} while (--bh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Codec37Decoder::proc3WithoutFDFE(Blitter & dst, Chunck & src, int next_offs, int bw, int bh) {
|
void Codec37Decoder::proc3WithoutFDFE(Blitter & dst, Chunk & src, int next_offs, int bw, int bh) {
|
||||||
do {
|
do {
|
||||||
int i = bw;
|
int i = bw;
|
||||||
do {
|
do {
|
||||||
@ -316,7 +316,7 @@ void Codec37Decoder::proc3WithoutFDFE(Blitter & dst, Chunck & src, int next_offs
|
|||||||
} while (--bh);
|
} while (--bh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Codec37Decoder::proc4(Blitter & dst, Chunck & src, int next_offs, int bw, int bh) {
|
void Codec37Decoder::proc4(Blitter & dst, Chunk & src, int next_offs, int bw, int bh) {
|
||||||
#ifdef DEBUG_CODEC37_PROC4
|
#ifdef DEBUG_CODEC37_PROC4
|
||||||
int b_nb = 0;
|
int b_nb = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -371,7 +371,7 @@ void Codec37Decoder::proc4(Blitter & dst, Chunck & src, int next_offs, int bw, i
|
|||||||
} while (--bh);
|
} while (--bh);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Codec37Decoder::decode(Blitter & dst, Chunck & src) {
|
bool Codec37Decoder::decode(Blitter & dst, Chunk & src) {
|
||||||
int width = getRect().width();
|
int width = getRect().width();
|
||||||
int height = getRect().height();
|
int height = getRect().height();
|
||||||
int bw = (width + 3) >> 2, bh = (height + 3) >> 2;
|
int bw = (width + 3) >> 2, bh = (height + 3) >> 2;
|
||||||
|
@ -74,13 +74,13 @@ protected:
|
|||||||
return r | (r << 16);
|
return r | (r << 16);
|
||||||
}
|
}
|
||||||
void maketable(int, int);
|
void maketable(int, int);
|
||||||
void proc1(Blitter &, Chunck &, int, int, int, int);
|
void proc1(Blitter &, Chunk &, int, int, int, int);
|
||||||
void proc2(Blitter &, Chunck &, int);
|
void proc2(Blitter &, Chunk &, int);
|
||||||
void proc3WithFDFE(Blitter &, Chunck &, int, int, int);
|
void proc3WithFDFE(Blitter &, Chunk &, int, int, int);
|
||||||
void proc3WithoutFDFE(Blitter &, Chunck &, int, int, int);
|
void proc3WithoutFDFE(Blitter &, Chunk &, int, int, int);
|
||||||
void proc4(Blitter &, Chunck &, int, int, int);
|
void proc4(Blitter &, Chunk &, int, int, int);
|
||||||
public:
|
public:
|
||||||
bool decode(Blitter &, Chunck &);
|
bool decode(Blitter &, Chunk &);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
#include <stdafx.h>
|
#include <stdafx.h>
|
||||||
#include "codec44.h"
|
#include "codec44.h"
|
||||||
#include "chunck.h"
|
#include "chunk.h"
|
||||||
#include "blitter.h"
|
#include "blitter.h"
|
||||||
|
|
||||||
bool Codec44Decoder::decode(Blitter & dst, Chunck & src) {
|
bool Codec44Decoder::decode(Blitter & dst, Chunk & src) {
|
||||||
int size_line;
|
int size_line;
|
||||||
int num;
|
int num;
|
||||||
int w, width = getRect().width() + 1;
|
int w, width = getRect().width() + 1;
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
*/
|
*/
|
||||||
class Codec44Decoder : public Decoder {
|
class Codec44Decoder : public Decoder {
|
||||||
public:
|
public:
|
||||||
bool decode(Blitter & dst, Chunck & src);
|
bool decode(Blitter & dst, Chunk & src);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,13 +21,13 @@
|
|||||||
|
|
||||||
#include <stdafx.h>
|
#include <stdafx.h>
|
||||||
#include "codec47.h"
|
#include "codec47.h"
|
||||||
#include "chunck.h"
|
#include "chunk.h"
|
||||||
#include "blitter.h"
|
#include "blitter.h"
|
||||||
|
|
||||||
DumpDecoder::~DumpDecoder() {
|
DumpDecoder::~DumpDecoder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DumpDecoder::decode(Blitter & dst, Chunck & src) {
|
bool DumpDecoder::decode(Blitter & dst, Chunk & src) {
|
||||||
int n = 0, i = 0;
|
int n = 0, i = 0;
|
||||||
int seq = src.getWord();
|
int seq = src.getWord();
|
||||||
int codec = src.getByte();
|
int codec = src.getByte();
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
class DumpDecoder : public Decoder {
|
class DumpDecoder : public Decoder {
|
||||||
public:
|
public:
|
||||||
virtual ~DumpDecoder();
|
virtual ~DumpDecoder();
|
||||||
bool decode(Blitter &, Chunck &);
|
bool decode(Blitter &, Chunk &);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,18 +19,18 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __COLOR_H_
|
#ifndef __Chunk_H_
|
||||||
#define __COLOR_H_
|
#define __Chunk_H_
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
/*! @brief simple class for handling a color.
|
/*! @brief simple class for handling a Chunk.
|
||||||
|
|
||||||
This small class is an helper for colors.
|
This small class is an helper for Chunks.
|
||||||
*/
|
*/
|
||||||
class Color {
|
class Color {
|
||||||
public:
|
public:
|
||||||
typedef unsigned char value_type; //!< The type of the color components.
|
typedef unsigned char value_type; //!< The type of the Chunk components.
|
||||||
private:
|
private:
|
||||||
value_type _r; //!< The red component.
|
value_type _r; //!< The red component.
|
||||||
value_type _g; //!< The green component.
|
value_type _g; //!< The green component.
|
||||||
@ -47,7 +47,7 @@ public:
|
|||||||
/*! @brief handle delta palette modification
|
/*! @brief handle delta palette modification
|
||||||
|
|
||||||
This method is used specifically by player::handleDeltaPalette().
|
This method is used specifically by player::handleDeltaPalette().
|
||||||
It updates the color component using delta values given as short.
|
It updates the Chunk component using delta values given as short.
|
||||||
|
|
||||||
@param ptr pointer to a table of 3 shorts that contain delta values to use.
|
@param ptr pointer to a table of 3 shorts that contain delta values to use.
|
||||||
*/
|
*/
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "rect.h"
|
#include "rect.h"
|
||||||
|
|
||||||
class Blitter;
|
class Blitter;
|
||||||
class Chunck;
|
class Chunk;
|
||||||
|
|
||||||
/*! @brief base class for codec decompression.
|
/*! @brief base class for codec decompression.
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public:
|
|||||||
Decoder() {};
|
Decoder() {};
|
||||||
virtual ~Decoder() {};
|
virtual ~Decoder() {};
|
||||||
virtual bool initSize(const Point & p, const Rect & r) { _p = p; _r = r; return true; };
|
virtual bool initSize(const Point & p, const Rect & r) { _p = p; _r = r; return true; };
|
||||||
virtual bool decode(Blitter &, Chunck &) = 0;
|
virtual bool decode(Blitter &, Chunk &) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -131,7 +131,7 @@ public:
|
|||||||
/*! @brief draw a centered and possibly using multiple lines string.
|
/*! @brief draw a centered and possibly using multiple lines string.
|
||||||
|
|
||||||
This method performs calculation of the string size before choosing where to draw it.
|
This method performs calculation of the string size before choosing where to draw it.
|
||||||
As I still not have figured out exactly what is the meaning of the fields in the TRES chunck,
|
As I still not have figured out exactly what is the meaning of the fields in the TRES Chunk,
|
||||||
the real meaning of the parameters can be quite difficult to understand.
|
the real meaning of the parameters can be quite difficult to understand.
|
||||||
|
|
||||||
@remark The current implementation is incorrect in the sense that it does not conform to the original game.
|
@remark The current implementation is incorrect in the sense that it does not conform to the original game.
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
#include <stdafx.h>
|
#include <stdafx.h>
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
#include "chunck.h"
|
#include "chunk.h"
|
||||||
#include "chunck_type.h"
|
#include "chunk_type.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h> // for memcpy.h
|
#include <string.h> // for memcpy.h
|
||||||
@ -63,12 +63,12 @@ bool ImuseChannel::checkParameters(int index, int nbframes, int size, int unk1,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImuseChannel::appendData(Chunck & b, int size) {
|
bool ImuseChannel::appendData(Chunk & b, int size) {
|
||||||
if(_dataSize == -1) { // First call
|
if(_dataSize == -1) { // First call
|
||||||
assert(size > 8);
|
assert(size > 8);
|
||||||
Chunck::type imus_type = b.getDword(); imus_type = TO_BE_32(imus_type);
|
Chunk::type imus_type = b.getDword(); imus_type = TO_BE_32(imus_type);
|
||||||
unsigned int imus_size = b.getDword(); imus_size = TO_BE_32(imus_size);
|
unsigned int imus_size = b.getDword(); imus_size = TO_BE_32(imus_size);
|
||||||
if(imus_type != TYPE_iMUS) error("Invalid CHUNCK for imuse_channel");
|
if(imus_type != TYPE_iMUS) error("Invalid Chunk for imuse_channel");
|
||||||
size -= 8;
|
size -= 8;
|
||||||
_tbufferSize = size;
|
_tbufferSize = size;
|
||||||
assert(_tbufferSize);
|
assert(_tbufferSize);
|
||||||
@ -96,8 +96,8 @@ bool ImuseChannel::appendData(Chunck & b, int size) {
|
|||||||
return processBuffer();
|
return processBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImuseChannel::handleFormat(Chunck & src) {
|
bool ImuseChannel::handleFormat(Chunk & src) {
|
||||||
if(src.getSize() != 20) error("invalid size for FRMT chunck");
|
if(src.getSize() != 20) error("invalid size for FRMT Chunk");
|
||||||
unsigned imuse_start = src.getDword();
|
unsigned imuse_start = src.getDword();
|
||||||
imuse_start = TO_BE_32(imuse_start);
|
imuse_start = TO_BE_32(imuse_start);
|
||||||
src.seek(4);
|
src.seek(4);
|
||||||
@ -111,23 +111,23 @@ bool ImuseChannel::handleFormat(Chunck & src) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImuseChannel::handleText(Chunck & src) {
|
bool ImuseChannel::handleText(Chunk & src) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImuseChannel::handleRegion(Chunck & src) {
|
bool ImuseChannel::handleRegion(Chunk & src) {
|
||||||
if(src.getSize() != 8) error("invalid size for REGN chunck");
|
if(src.getSize() != 8) error("invalid size for REGN Chunk");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImuseChannel::handleStop(Chunck & src) {
|
bool ImuseChannel::handleStop(Chunk & src) {
|
||||||
if(src.getSize() != 4) error("invalid size for STOP chunck");
|
if(src.getSize() != 4) error("invalid size for STOP Chunk");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImuseChannel::handleMap(Chunck & map) {
|
bool ImuseChannel::handleMap(Chunk & map) {
|
||||||
while(!map.eof()) {
|
while(!map.eof()) {
|
||||||
Chunck * sub = map.subBlock();
|
Chunk * sub = map.subBlock();
|
||||||
switch(sub->getType()) {
|
switch(sub->getType()) {
|
||||||
case TYPE_FRMT:
|
case TYPE_FRMT:
|
||||||
handleFormat(*sub);
|
handleFormat(*sub);
|
||||||
@ -142,7 +142,7 @@ bool ImuseChannel::handleMap(Chunck & map) {
|
|||||||
handleStop(*sub);
|
handleStop(*sub);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error("Unknown iMUS subchunck found : %s, %d", Chunck::ChunckString(sub->getType()), sub->getSize());
|
error("Unknown iMUS subChunk found : %s, %d", Chunk::ChunkString(sub->getType()), sub->getSize());
|
||||||
}
|
}
|
||||||
delete sub;
|
delete sub;
|
||||||
}
|
}
|
||||||
@ -195,13 +195,13 @@ void ImuseChannel::decode() {
|
|||||||
bool ImuseChannel::handleSubTags(int & offset) {
|
bool ImuseChannel::handleSubTags(int & offset) {
|
||||||
int available_size = _tbufferSize - offset;
|
int available_size = _tbufferSize - offset;
|
||||||
if(available_size >= 8) {
|
if(available_size >= 8) {
|
||||||
Chunck::type type = READ_BE_UINT32(_tbuffer + offset);
|
Chunk::type type = READ_BE_UINT32(_tbuffer + offset);
|
||||||
unsigned int size = READ_BE_UINT32(_tbuffer + offset + 4);
|
unsigned int size = READ_BE_UINT32(_tbuffer + offset + 4);
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case TYPE_MAP_:
|
case TYPE_MAP_:
|
||||||
_inData = false;
|
_inData = false;
|
||||||
if(available_size >= (size + 8)) {
|
if(available_size >= (size + 8)) {
|
||||||
ContChunck c((char*)_tbuffer + offset);
|
ContChunk c((char*)_tbuffer + offset);
|
||||||
handleMap(c);
|
handleMap(c);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -225,7 +225,7 @@ bool ImuseChannel::handleSubTags(int & offset) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
error("unknown chunck in iMUS track : %s ", Chunck::ChunckString(type));
|
error("unknown Chunk in iMUS track : %s ", Chunk::ChunkString(type));
|
||||||
}
|
}
|
||||||
offset += size + 8;
|
offset += size + 8;
|
||||||
return true;
|
return true;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
#include "chunck_type.h"
|
#include "Chunk_type.h"
|
||||||
#include "rect.h"
|
#include "rect.h"
|
||||||
#include "blitter.h"
|
#include "blitter.h"
|
||||||
|
|
||||||
@ -209,16 +209,16 @@ void SmushPlayer::clean() {
|
|||||||
if(_fr[3]) delete _fr[3];
|
if(_fr[3]) delete _fr[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::checkBlock(const Chunck & b, Chunck::type type_expected, unsigned int min_size) {
|
void SmushPlayer::checkBlock(const Chunk & b, Chunk::type type_expected, unsigned int min_size) {
|
||||||
if(type_expected != b.getType()) {
|
if(type_expected != b.getType()) {
|
||||||
error("chunck type is different from expected : %d != %d", b.getType(), type_expected);
|
error("Chunk type is different from expected : %d != %d", b.getType(), type_expected);
|
||||||
}
|
}
|
||||||
if(min_size > b.getSize()) {
|
if(min_size > b.getSize()) {
|
||||||
error( "chunck size is inferior than minimum required size : %d < %d", b.getSize(), min_size);
|
error( "Chunk size is inferior than minimum required size : %d < %d", b.getSize(), min_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleSoundBuffer(int track_id, int index, int max_frames, int flags, int vol, int bal, Chunck & b, int size) {
|
void SmushPlayer::handleSoundBuffer(int track_id, int index, int max_frames, int flags, int vol, int bal, Chunk & b, int size) {
|
||||||
debug(6, "smush_player::handleSoundBuffer(%d)", track_id);
|
debug(6, "smush_player::handleSoundBuffer(%d)", track_id);
|
||||||
if(!_voices && (flags & 128) == 128) return;
|
if(!_voices && (flags & 128) == 128) return;
|
||||||
if(!_bgmusic && (flags & 64) == 64) return;
|
if(!_bgmusic && (flags & 64) == 64) return;
|
||||||
@ -234,7 +234,7 @@ void SmushPlayer::handleSoundBuffer(int track_id, int index, int max_frames, int
|
|||||||
c->appendData(b, size);
|
c->appendData(b, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleSoundFrame(Chunck & b) {
|
void SmushPlayer::handleSoundFrame(Chunk & b) {
|
||||||
checkBlock(b, TYPE_PSAD);
|
checkBlock(b, TYPE_PSAD);
|
||||||
debug(6, "SmushPlayer::handleSoundFrame()");
|
debug(6, "SmushPlayer::handleSoundFrame()");
|
||||||
if(!_outputSound) return;
|
if(!_outputSound) return;
|
||||||
@ -253,7 +253,7 @@ void SmushPlayer::handleSoundFrame(Chunck & b) {
|
|||||||
handleSoundBuffer(track_id, index, max_frames, flags, vol, bal, b, size);
|
handleSoundBuffer(track_id, index, max_frames, flags, vol, bal, b, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleSkip(Chunck & b) {
|
void SmushPlayer::handleSkip(Chunk & b) {
|
||||||
checkBlock(b, TYPE_SKIP, 4);
|
checkBlock(b, TYPE_SKIP, 4);
|
||||||
int code = b.getDword();
|
int code = b.getDword();
|
||||||
debug(6, "SmushPlayer::handleSkip(%d)", code);
|
debug(6, "SmushPlayer::handleSkip(%d)", code);
|
||||||
@ -263,17 +263,17 @@ void SmushPlayer::handleSkip(Chunck & b) {
|
|||||||
_skipNext =true;
|
_skipNext =true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleStore(Chunck & b) {
|
void SmushPlayer::handleStore(Chunk & b) {
|
||||||
checkBlock(b, TYPE_STOR, 4);
|
checkBlock(b, TYPE_STOR, 4);
|
||||||
debug(6, "SmushPlayer::handleStore()");
|
debug(6, "SmushPlayer::handleStore()");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleFetch(Chunck & b) {
|
void SmushPlayer::handleFetch(Chunk & b) {
|
||||||
checkBlock(b, TYPE_FTCH, 6);
|
checkBlock(b, TYPE_FTCH, 6);
|
||||||
debug(6, "SmushPlayer::handleFetch()");
|
debug(6, "SmushPlayer::handleFetch()");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleImuseBuffer(int track_id, int index, int nbframes, int size, int unk1, int unk2, Chunck & b, int bsize) {
|
void SmushPlayer::handleImuseBuffer(int track_id, int index, int nbframes, int size, int unk1, int unk2, Chunk & b, int bsize) {
|
||||||
_Channel * c = _mixer->findChannel(track_id);
|
_Channel * c = _mixer->findChannel(track_id);
|
||||||
if(c == 0) {
|
if(c == 0) {
|
||||||
c = new ImuseChannel(track_id, _soundFrequency);
|
c = new ImuseChannel(track_id, _soundFrequency);
|
||||||
@ -286,7 +286,7 @@ void SmushPlayer::handleImuseBuffer(int track_id, int index, int nbframes, int s
|
|||||||
c->appendData(b, bsize);
|
c->appendData(b, bsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleImuseAction8(Chunck & b, int flags, int unknown, int track_id) {
|
void SmushPlayer::handleImuseAction8(Chunk & b, int flags, int unknown, int track_id) {
|
||||||
assert(flags == 46 && unknown == 0);
|
assert(flags == 46 && unknown == 0);
|
||||||
int unknown2 = b.getWord();
|
int unknown2 = b.getWord();
|
||||||
track_id |= unknown2 << 16;
|
track_id |= unknown2 << 16;
|
||||||
@ -297,7 +297,7 @@ void SmushPlayer::handleImuseAction8(Chunck & b, int flags, int unknown, int tra
|
|||||||
handleImuseBuffer(track_id, index, nbframes, size, unknown, unknown2, b, bsize);
|
handleImuseBuffer(track_id, index, nbframes, size, unknown, unknown2, b, bsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleImuseAction(Chunck & b) {
|
void SmushPlayer::handleImuseAction(Chunk & b) {
|
||||||
checkBlock(b, TYPE_IACT, 8);
|
checkBlock(b, TYPE_IACT, 8);
|
||||||
debug(6, "SmushPlayer::handleImuseAction()");
|
debug(6, "SmushPlayer::handleImuseAction()");
|
||||||
if(!_outputSound) return;
|
if(!_outputSound) return;
|
||||||
@ -320,7 +320,7 @@ void SmushPlayer::handleImuseAction(Chunck & b) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleTextResource(Chunck & b) {
|
void SmushPlayer::handleTextResource(Chunk & b) {
|
||||||
checkBlock(b, TYPE_TRES, 18);
|
checkBlock(b, TYPE_TRES, 18);
|
||||||
int pos_x = b.getShort();
|
int pos_x = b.getShort();
|
||||||
int pos_y = b.getShort();
|
int pos_y = b.getShort();
|
||||||
@ -375,13 +375,13 @@ void SmushPlayer::handleTextResource(Chunck & b) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::readPalette(Palette & out, Chunck & in) {
|
void SmushPlayer::readPalette(Palette & out, Chunk & in) {
|
||||||
unsigned char buffer[768];
|
unsigned char buffer[768];
|
||||||
in.read(buffer, 768);
|
in.read(buffer, 768);
|
||||||
out = Palette(buffer);
|
out = Palette(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleDeltaPalette(Chunck & b) {
|
void SmushPlayer::handleDeltaPalette(Chunk & b) {
|
||||||
checkBlock(b, TYPE_XPAL);
|
checkBlock(b, TYPE_XPAL);
|
||||||
debug(6, "SmushPlayer::handleDeltaPalette()");
|
debug(6, "SmushPlayer::handleDeltaPalette()");
|
||||||
if(b.getSize() == 768 * 3 + 4) {
|
if(b.getSize() == 768 * 3 + 4) {
|
||||||
@ -407,14 +407,14 @@ void SmushPlayer::handleDeltaPalette(Chunck & b) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleNewPalette(Chunck & b) {
|
void SmushPlayer::handleNewPalette(Chunk & b) {
|
||||||
checkBlock(b, TYPE_NPAL, 768);
|
checkBlock(b, TYPE_NPAL, 768);
|
||||||
debug(6, "SmushPlayer::handleNewPalette()");
|
debug(6, "SmushPlayer::handleNewPalette()");
|
||||||
readPalette(_pal, b);
|
readPalette(_pal, b);
|
||||||
updatePalette();
|
updatePalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::decodeCodec(Chunck & b, const Rect & r, Decoder & codec) {
|
void SmushPlayer::decodeCodec(Chunk & b, const Rect & r, Decoder & codec) {
|
||||||
assert(_curBuffer);
|
assert(_curBuffer);
|
||||||
Blitter blit(_curBuffer, _frameSize, r);
|
Blitter blit(_curBuffer, _frameSize, r);
|
||||||
codec.decode(blit, b);
|
codec.decode(blit, b);
|
||||||
@ -449,7 +449,7 @@ void SmushPlayer::initSize(const Rect & r, bool always, bool transparent) {
|
|||||||
_alreadyInit = true;
|
_alreadyInit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleFrameObject(Chunck & b) {
|
void SmushPlayer::handleFrameObject(Chunk & b) {
|
||||||
checkBlock(b, TYPE_FOBJ, 14);
|
checkBlock(b, TYPE_FOBJ, 14);
|
||||||
if(_skipNext) {
|
if(_skipNext) {
|
||||||
_skipNext = false;
|
_skipNext = false;
|
||||||
@ -496,14 +496,14 @@ void SmushPlayer::handleFrameObject(Chunck & b) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleFrame(Chunck & b) {
|
void SmushPlayer::handleFrame(Chunk & b) {
|
||||||
checkBlock(b, TYPE_FRME);
|
checkBlock(b, TYPE_FRME);
|
||||||
debug(6, "SmushPlayer::handleFrame(%d)", _frame);
|
debug(6, "SmushPlayer::handleFrame(%d)", _frame);
|
||||||
_alreadyInit = false;
|
_alreadyInit = false;
|
||||||
_skipNext = false;
|
_skipNext = false;
|
||||||
|
|
||||||
while(!b.eof()) {
|
while(!b.eof()) {
|
||||||
Chunck * sub = b.subBlock();
|
Chunk * sub = b.subBlock();
|
||||||
if(sub->getSize() & 1) b.seek(1);
|
if(sub->getSize() & 1) b.seek(1);
|
||||||
switch(sub->getType()) {
|
switch(sub->getType()) {
|
||||||
case TYPE_NPAL:
|
case TYPE_NPAL:
|
||||||
@ -534,7 +534,7 @@ void SmushPlayer::handleFrame(Chunck & b) {
|
|||||||
handleSkip(*sub);
|
handleSkip(*sub);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error("Unknown frame subchunck found : %s, %d", Chunck::ChunckString(sub->getType()), sub->getSize());
|
error("Unknown frame subChunk found : %s, %d", Chunk::ChunkString(sub->getType()), sub->getSize());
|
||||||
}
|
}
|
||||||
delete sub;
|
delete sub;
|
||||||
}
|
}
|
||||||
@ -553,7 +553,7 @@ void SmushPlayer::handleFrame(Chunck & b) {
|
|||||||
_frame++;
|
_frame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmushPlayer::handleAnimHeader(Chunck & b) {
|
void SmushPlayer::handleAnimHeader(Chunk & b) {
|
||||||
checkBlock(b, TYPE_AHDR, 774);
|
checkBlock(b, TYPE_AHDR, 774);
|
||||||
debug(6, "SmushPlayer::handleAnimHeader()");
|
debug(6, "SmushPlayer::handleAnimHeader()");
|
||||||
_version = b.getWord();
|
_version = b.getWord();
|
||||||
@ -619,7 +619,7 @@ static StringResource * getStrings(const char * file, bool is_encoded) {
|
|||||||
if(is_encoded) {
|
if(is_encoded) {
|
||||||
static const int ETRS_HEADER_LENGTH = 16;
|
static const int ETRS_HEADER_LENGTH = 16;
|
||||||
assert(length > ETRS_HEADER_LENGTH);
|
assert(length > ETRS_HEADER_LENGTH);
|
||||||
Chunck::type type = READ_BE_UINT32(filebuffer);
|
Chunk::type type = READ_BE_UINT32(filebuffer);
|
||||||
if(type != TYPE_ETRS) error("invalid type for file"); // mem leak !!!
|
if(type != TYPE_ETRS) error("invalid type for file"); // mem leak !!!
|
||||||
char * old = filebuffer;
|
char * old = filebuffer;
|
||||||
filebuffer = new char[length - ETRS_HEADER_LENGTH];
|
filebuffer = new char[length - ETRS_HEADER_LENGTH];
|
||||||
@ -730,12 +730,12 @@ bool SmushPlayer::play(const char * file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FileChunck base = FileChunck(file);
|
FileChunk base = FileChunk(file);
|
||||||
|
|
||||||
checkBlock(base, TYPE_ANIM);
|
checkBlock(base, TYPE_ANIM);
|
||||||
|
|
||||||
while(!base.eof()) {
|
while(!base.eof()) {
|
||||||
Chunck * sub = base.subBlock();
|
Chunk * sub = base.subBlock();
|
||||||
switch(sub->getType()) {
|
switch(sub->getType()) {
|
||||||
case TYPE_AHDR:
|
case TYPE_AHDR:
|
||||||
handleAnimHeader(*sub);
|
handleAnimHeader(*sub);
|
||||||
@ -744,7 +744,7 @@ bool SmushPlayer::play(const char * file) {
|
|||||||
handleFrame(*sub);
|
handleFrame(*sub);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error("Unknown chunck found : %d, %d", sub->getType(), sub->getSize());
|
error("Unknown Chunk found : %d, %d", sub->getType(), sub->getSize());
|
||||||
}
|
}
|
||||||
delete sub;
|
delete sub;
|
||||||
if(_renderer->prematureClose())
|
if(_renderer->prematureClose())
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "rect.h"
|
#include "rect.h"
|
||||||
#include "mixer.h"
|
#include "mixer.h"
|
||||||
#include "chunck.h"
|
#include "chunk.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "codec1.h"
|
#include "codec1.h"
|
||||||
#include "codec37.h"
|
#include "codec37.h"
|
||||||
@ -81,23 +81,23 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
bool readString(const char * file, bool &);
|
bool readString(const char * file, bool &);
|
||||||
void clean();
|
void clean();
|
||||||
void checkBlock(const Chunck &, Chunck::type, unsigned int = 0);
|
void checkBlock(const Chunk &, Chunk::type, unsigned int = 0);
|
||||||
void handleAnimHeader(Chunck &);
|
void handleAnimHeader(Chunk &);
|
||||||
void handleFrame(Chunck &);
|
void handleFrame(Chunk &);
|
||||||
void handleNewPalette(Chunck &);
|
void handleNewPalette(Chunk &);
|
||||||
void handleFrameObject(Chunck &);
|
void handleFrameObject(Chunk &);
|
||||||
void handleSoundBuffer(int, int, int, int, int, int, Chunck &, int);
|
void handleSoundBuffer(int, int, int, int, int, int, Chunk &, int);
|
||||||
void handleImuseBuffer(int, int, int, int, int, int, Chunck &, int);
|
void handleImuseBuffer(int, int, int, int, int, int, Chunk &, int);
|
||||||
void handleSoundFrame(Chunck &);
|
void handleSoundFrame(Chunk &);
|
||||||
void handleSkip(Chunck &);
|
void handleSkip(Chunk &);
|
||||||
void handleStore(Chunck &);
|
void handleStore(Chunk &);
|
||||||
void handleFetch(Chunck &);
|
void handleFetch(Chunk &);
|
||||||
void handleImuseAction8(Chunck &, int flags, int unknown, int track_id);
|
void handleImuseAction8(Chunk &, int flags, int unknown, int track_id);
|
||||||
void handleImuseAction(Chunck &);
|
void handleImuseAction(Chunk &);
|
||||||
void handleTextResource(Chunck &);
|
void handleTextResource(Chunk &);
|
||||||
void handleDeltaPalette(Chunck &);
|
void handleDeltaPalette(Chunk &);
|
||||||
void decodeCodec(Chunck &, const Rect &, Decoder &);
|
void decodeCodec(Chunk &, const Rect &, Decoder &);
|
||||||
void readPalette(Palette &, Chunck &);
|
void readPalette(Palette &, Chunk &);
|
||||||
void initSize(const Rect &, bool, bool);
|
void initSize(const Rect &, bool, bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
#include <stdafx.h>
|
#include <stdafx.h>
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
#include "chunck.h"
|
#include "chunk.h"
|
||||||
#include "chunck_type.h"
|
#include "chunk_type.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h> // for memcpy.h
|
#include <string.h> // for memcpy.h
|
||||||
@ -30,18 +30,18 @@
|
|||||||
#define min(x, y) ((x) > (y) ? (y) : (x))
|
#define min(x, y) ((x) > (y) ? (y) : (x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void SaudChannel::handleStrk(Chunck & b) {
|
void SaudChannel::handleStrk(Chunk & b) {
|
||||||
int size = b.getSize();
|
int size = b.getSize();
|
||||||
if(size != 14 && size != 10) {
|
if(size != 14 && size != 10) {
|
||||||
error("STRK has a invalid size : %d", size);
|
error("STRK has a invalid size : %d", size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaudChannel::handleSmrk(Chunck & b) {
|
void SaudChannel::handleSmrk(Chunk & b) {
|
||||||
_markReached = true;
|
_markReached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaudChannel::handleShdr(Chunck & b) {
|
void SaudChannel::handleShdr(Chunk & b) {
|
||||||
int size = b.getSize();
|
int size = b.getSize();
|
||||||
if(size != 4) warning("SMRK has a invalid size : %d", size);
|
if(size != 4) warning("SMRK has a invalid size : %d", size);
|
||||||
}
|
}
|
||||||
@ -49,14 +49,14 @@ void SaudChannel::handleShdr(Chunck & b) {
|
|||||||
bool SaudChannel::handleSubTags(int & offset) {
|
bool SaudChannel::handleSubTags(int & offset) {
|
||||||
int available_size = _tbufferSize - offset;
|
int available_size = _tbufferSize - offset;
|
||||||
if(available_size >= 8) {
|
if(available_size >= 8) {
|
||||||
Chunck::type type = READ_BE_UINT32(_tbuffer + offset);
|
Chunk::type type = READ_BE_UINT32(_tbuffer + offset);
|
||||||
unsigned int size = READ_BE_UINT32(_tbuffer + offset + 4);
|
unsigned int size = READ_BE_UINT32(_tbuffer + offset + 4);
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case TYPE_STRK:
|
case TYPE_STRK:
|
||||||
_inData = false;
|
_inData = false;
|
||||||
if(available_size >= (size + 8)) {
|
if(available_size >= (size + 8)) {
|
||||||
ContChunck c((char*)_tbuffer + offset);
|
ContChunk c((char*)_tbuffer + offset);
|
||||||
handleStrk(c);
|
handleStrk(c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -65,7 +65,7 @@ bool SaudChannel::handleSubTags(int & offset) {
|
|||||||
case TYPE_SMRK:
|
case TYPE_SMRK:
|
||||||
_inData = false;
|
_inData = false;
|
||||||
if(available_size >= (size + 8)) {
|
if(available_size >= (size + 8)) {
|
||||||
ContChunck c((char*)_tbuffer + offset);
|
ContChunk c((char*)_tbuffer + offset);
|
||||||
handleSmrk(c);
|
handleSmrk(c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -74,7 +74,7 @@ bool SaudChannel::handleSubTags(int & offset) {
|
|||||||
case TYPE_SHDR:
|
case TYPE_SHDR:
|
||||||
_inData = false;
|
_inData = false;
|
||||||
if(available_size >= (size + 8)) {
|
if(available_size >= (size + 8)) {
|
||||||
ContChunck c((char*)_tbuffer + offset);
|
ContChunk c((char*)_tbuffer + offset);
|
||||||
handleShdr(c);
|
handleShdr(c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -86,7 +86,7 @@ bool SaudChannel::handleSubTags(int & offset) {
|
|||||||
offset += 8;
|
offset += 8;
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
error("unknown chunck in SAUD track : %s ", Chunck::ChunckString(type));
|
error("unknown Chunk in SAUD track : %s ", Chunk::ChunkString(type));
|
||||||
}
|
}
|
||||||
offset += size + 8;
|
offset += size + 8;
|
||||||
return true;
|
return true;
|
||||||
@ -232,12 +232,12 @@ bool SaudChannel::checkParameters(int index, int nb, int flags, int volume, int
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SaudChannel::appendData(Chunck & b, int size) {
|
bool SaudChannel::appendData(Chunk & b, int size) {
|
||||||
if(_dataSize == -1) { // First call
|
if(_dataSize == -1) { // First call
|
||||||
assert(size > 8);
|
assert(size > 8);
|
||||||
Chunck::type saud_type = b.getDword(); saud_type = TO_BE_32(saud_type);
|
Chunk::type saud_type = b.getDword(); saud_type = TO_BE_32(saud_type);
|
||||||
unsigned int saud_size = b.getDword(); saud_size = TO_BE_32(saud_size);
|
unsigned int saud_size = b.getDword(); saud_size = TO_BE_32(saud_size);
|
||||||
if(saud_type != TYPE_SAUD) error("Invalid CHUNCK for SaudChannel : %X", saud_type);
|
if(saud_type != TYPE_SAUD) error("Invalid Chunk for SaudChannel : %X", saud_type);
|
||||||
size -= 8;
|
size -= 8;
|
||||||
_dataSize = -2; // We don't get here again...
|
_dataSize = -2; // We don't get here again...
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user