diff options
author | Torbjörn Andersson | 2005-10-29 21:24:54 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2005-10-29 21:24:54 +0000 |
commit | 7f4cda6622990b7aa26e433ecdc8f17b8a3b237d (patch) | |
tree | 5a7e7f9613ff2601a7bf70477b34b30b8c0a21dc /sword2/driver/animation.cpp | |
parent | bcccd3f558bbbdab07d355dabfb072298e4f5cf2 (diff) | |
download | scummvm-rg350-7f4cda6622990b7aa26e433ecdc8f17b8a3b237d.tar.gz scummvm-rg350-7f4cda6622990b7aa26e433ecdc8f17b8a3b237d.tar.bz2 scummvm-rg350-7f4cda6622990b7aa26e433ecdc8f17b8a3b237d.zip |
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
Diffstat (limited to 'sword2/driver/animation.cpp')
-rw-r--r-- | sword2/driver/animation.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/sword2/driver/animation.cpp b/sword2/driver/animation.cpp index 41987dd2d4..071a88ac1a 100644 --- a/sword2/driver/animation.cpp +++ b/sword2/driver/animation.cpp @@ -176,12 +176,11 @@ int32 MoviePlayer::play(const char *filename, MovieTextObject *text[], int32 lea if (leadInRes) { byte *leadIn = _vm->_resman->openResource(leadInRes); - uint32 leadInLen = _vm->_resman->fetchLen(leadInRes) - sizeof(StandardHeader); - StandardHeader *header = (StandardHeader *)leadIn; + uint32 leadInLen = _vm->_resman->fetchLen(leadInRes) - ResHeader::size(); - assert(header->fileType == WAV_FILE); + assert(_vm->_resman->fetchType(leadIn) == WAV_FILE); - leadIn += sizeof(StandardHeader); + leadIn += ResHeader::size(); _vm->_sound->playFx(&leadInHandle, leadIn, leadInLen, Audio::Mixer::kMaxChannelVolume, 0, false, Audio::Mixer::kMusicSoundType); } @@ -191,15 +190,14 @@ int32 MoviePlayer::play(const char *filename, MovieTextObject *text[], int32 lea if (leadOutRes) { leadOut = _vm->_resman->openResource(leadOutRes); - leadOutLen = _vm->_resman->fetchLen(leadOutRes) - sizeof(StandardHeader); - StandardHeader *header = (StandardHeader *)leadOut; + leadOutLen = _vm->_resman->fetchLen(leadOutRes) - ResHeader::size(); - assert(header->fileType == WAV_FILE); + assert(_vm->_resman->fetchType(leadOut) == WAV_FILE); - leadOut += sizeof(StandardHeader); + leadOut += ResHeader::size(); } - _leadOutFrame = (uint) -1; + _leadOutFrame = (uint)-1; int i; @@ -420,16 +418,18 @@ void MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte data = _vm->_fontRenderer->makeTextSprite(msg, RENDERWIDE, 255, _vm->_speechFontId); } - FrameHeader *frame = (FrameHeader *)data; + FrameHeader frame_head; SpriteInfo msgSprite; byte *msgSurface; - msgSprite.x = _vm->_screen->getScreenWide() / 2 - frame->width / 2; - msgSprite.y = MENUDEEP / 2 - frame->height / 2; - msgSprite.w = frame->width; - msgSprite.h = frame->height; + frame_head.read(data); + + msgSprite.x = _vm->_screen->getScreenWide() / 2 - frame_head.width / 2; + msgSprite.y = MENUDEEP / 2 - frame_head.height / 2; + msgSprite.w = frame_head.width; + msgSprite.h = frame_head.height; msgSprite.type = RDSPR_NOCOMPRESSION; - msgSprite.data = data + sizeof(FrameHeader); + msgSprite.data = data + FrameHeader::size(); _vm->_screen->createSurface(&msgSprite, &msgSurface); _vm->_screen->drawSurface(&msgSprite, msgSurface); |