mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
SCUMM: Take advantage of the fact that Chunk now is a ReadStream subclass
svn-id: r24546
This commit is contained in:
parent
a3bc66bcbd
commit
10478617c6
@ -62,15 +62,15 @@ void BaseChunk::seek(int32 delta, int dir) {
|
||||
case SEEK_SET:
|
||||
if (delta < 0)
|
||||
error("invalid seek request");
|
||||
|
||||
_curPos = (uint32)delta;
|
||||
break;
|
||||
case SEEK_END:
|
||||
if (delta > 0 || _size < (uint32)-delta)
|
||||
error("invalid seek request");
|
||||
|
||||
_curPos = (uint32)(_size + delta);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (_curPos > _size) {
|
||||
@ -116,7 +116,7 @@ FileChunk::~FileChunk() {
|
||||
|
||||
Chunk *FileChunk::subBlock() {
|
||||
FileChunk *ptr = new FileChunk(_data, _offset + _curPos);
|
||||
seek(sizeof(Chunk::type) + sizeof(uint32) + ptr->size(), SEEK_CUR);
|
||||
skip(sizeof(Chunk::type) + sizeof(uint32) + ptr->size());
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ MemoryChunk::MemoryChunk(byte *data) {
|
||||
|
||||
Chunk *MemoryChunk::subBlock() {
|
||||
MemoryChunk *ptr = new MemoryChunk(_data + _curPos);
|
||||
seek(sizeof(Chunk::type) + sizeof(uint32) + ptr->size(), SEEK_CUR);
|
||||
skip(sizeof(Chunk::type) + sizeof(uint32) + ptr->size());
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
uint32 size() const;
|
||||
bool eos() const;
|
||||
uint32 pos() const;
|
||||
void seek(int32 delta, int dir = SEEK_CUR);
|
||||
void seek(int32 delta, int dir);
|
||||
};
|
||||
|
||||
class FileChunk : public BaseChunk {
|
||||
|
@ -60,8 +60,8 @@ bool ImuseChannel::checkParameters(int32 index, int32 nbframes, int32 size, int3
|
||||
bool ImuseChannel::appendData(Chunk &b, int32 size) {
|
||||
if (_dataSize == -1) {
|
||||
assert(size > 8);
|
||||
Chunk::type imus_type = b.readUint32LE(); imus_type = SWAP_BYTES_32(imus_type);
|
||||
uint32 imus_size = b.readUint32LE(); imus_size = SWAP_BYTES_32(imus_size);
|
||||
Chunk::type imus_type = b.readUint32BE();
|
||||
/*uint32 imus_size =*/ b.readUint32BE();
|
||||
if (imus_type != MKID_BE('iMUS'))
|
||||
error("Invalid Chunk for imuse_channel");
|
||||
size -= 8;
|
||||
@ -103,15 +103,11 @@ bool ImuseChannel::appendData(Chunk &b, int32 size) {
|
||||
|
||||
bool ImuseChannel::handleFormat(Chunk &src) {
|
||||
if (src.size() != 20) error("invalid size for FRMT Chunk");
|
||||
uint32 imuse_start = src.readUint32LE();
|
||||
imuse_start = SWAP_BYTES_32(imuse_start);
|
||||
src.seek(4, SEEK_CUR);
|
||||
_bitsize = src.readUint32LE();
|
||||
_bitsize = SWAP_BYTES_32(_bitsize);
|
||||
_rate = src.readUint32LE();
|
||||
_rate = SWAP_BYTES_32(_rate);
|
||||
_channels = src.readUint32LE();
|
||||
_channels = SWAP_BYTES_32(_channels);
|
||||
/*uint32 imuse_start =*/ src.readUint32BE();
|
||||
src.skip(4);
|
||||
_bitsize = src.readUint32BE();
|
||||
_rate = src.readUint32BE();
|
||||
_channels = src.readUint32BE();
|
||||
assert(_channels == 1 || _channels == 2);
|
||||
return true;
|
||||
}
|
||||
|
@ -133,10 +133,8 @@ bool SaudChannel::checkParameters(int32 index, int32 nb, int32 flags, int32 volu
|
||||
bool SaudChannel::appendData(Chunk &b, int32 size) {
|
||||
if (_dataSize == -1) {
|
||||
assert(size > 8);
|
||||
Chunk::type saud_type = b.readUint32LE();
|
||||
saud_type = SWAP_BYTES_32(saud_type);
|
||||
uint32 saud_size = b.readUint32LE();
|
||||
saud_size = SWAP_BYTES_32(saud_size);
|
||||
Chunk::type saud_type = b.readUint32BE();
|
||||
/*uint32 saud_size =*/ b.readUint32BE();
|
||||
if (saud_type != MKID_BE('SAUD'))
|
||||
error("Invalid Chunk for SaudChannel : %X", saud_type);
|
||||
size -= 8;
|
||||
|
@ -989,7 +989,7 @@ void SmushPlayer::handleFrame(Chunk &b) {
|
||||
|
||||
b.reseek();
|
||||
if (sub->size() & 1)
|
||||
b.seek(1, SEEK_CUR);
|
||||
b.skip(1);
|
||||
|
||||
delete sub;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user