From 54eeb8aeed1d7d8d5fcf89f59efe3810bd7654bb Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Fri, 5 May 2006 05:53:36 +0000 Subject: Match fade code of original games and minor cleanup svn-id: r22359 --- engines/simon/debug.cpp | 2 +- engines/simon/draw.cpp | 32 ++++++++++++------------ engines/simon/intern.h | 65 ++++++++++++++++++++++++------------------------- engines/simon/items.cpp | 24 +++++++++--------- engines/simon/simon.cpp | 26 ++++++++++---------- engines/simon/simon.h | 18 ++++++-------- engines/simon/vga.cpp | 65 ++++++++++++++++++++++++++++--------------------- 7 files changed, 117 insertions(+), 115 deletions(-) diff --git a/engines/simon/debug.cpp b/engines/simon/debug.cpp index d3c9744db6..037777bac9 100644 --- a/engines/simon/debug.cpp +++ b/engines/simon/debug.cpp @@ -380,7 +380,7 @@ void SimonEngine::dump_single_bitmap(int file, int image, const byte *offs, int return; #endif - dump_bitmap(buf, offs, w, h, 0, _palette, base); + dump_bitmap(buf, offs, w, h, 0, _displayPalette, base); } void pal_load(byte *pal, const byte *vga1, int a, int b) { diff --git a/engines/simon/draw.cpp b/engines/simon/draw.cpp index f42c48b7d3..7ab3f22cbf 100644 --- a/engines/simon/draw.cpp +++ b/engines/simon/draw.cpp @@ -423,11 +423,11 @@ void SimonEngine::fillBackGroundFromBack(uint lines) { } void SimonEngine::dx_update_screen_and_palette() { - if (_paletteColorCount == 0 && _paletteFlag == 1) { + if (_fastFadeInFlag == 0 && _paletteFlag == 1) { _paletteFlag = 0; - if (memcmp(_palette, _paletteBackup, 1024) != 0) { - memcpy(_paletteBackup, _palette, 1024); - _system->setPalette(_palette, 0, 256); + if (memcmp(_displayPalette, _currentPalette, 1024)) { + memcpy(_currentPalette, _displayPalette, 1024); + _system->setPalette(_displayPalette, 0, 256); } } @@ -440,7 +440,7 @@ void SimonEngine::dx_update_screen_and_palette() { scrollScreen(); } - if (_paletteColorCount != 0) { + if (_fastFadeInFlag) { if (getGameType() == GType_SIMON1 && _usePaletteDelay) { delay(100); _usePaletteDelay = false; @@ -450,13 +450,13 @@ void SimonEngine::dx_update_screen_and_palette() { } void SimonEngine::fastFadeIn() { - if (_paletteColorCount & 0x8000) { + if (_fastFadeInFlag & 0x8000) { slowFadeIn(); } else { _paletteFlag = false; - memcpy(_paletteBackup, _palette, 1024); - _system->setPalette(_palette, 0, _paletteColorCount); - _paletteColorCount = 0; + memcpy(_currentPalette, _displayPalette, 1024); + _system->setPalette(_displayPalette, 0, _fastFadeInFlag); + _fastFadeInFlag = 0; } } @@ -464,30 +464,28 @@ void SimonEngine::slowFadeIn() { uint8 *src, *dst; int c, p; - _paletteColorCount &= 0x7fff; + _fastFadeInFlag &= 0x7fff; _paletteFlag = false; - memcpy(_videoBuf1, _palette, 768); memset(_videoBuf1, 0, 768); - - memcpy(_paletteBackup, _palette, 768); - memcpy(_videoBuf1 + 768, _palette, 768); + memcpy(_currentPalette, _displayPalette, 768); + memcpy(_videoBuf1 + 768, _displayPalette, 768); for (c = 255; c >= 0; c -= 4) { src = _videoBuf1 + 768; dst = _videoBuf1; - for (p = _paletteColorCount; p !=0 ; p--) { + for (p = _fastFadeInFlag; p !=0 ; p--) { if (*src >= c) *dst = *dst + 4; src++; dst++; } - _system->setPalette(_videoBuf1, 0, _videoNumPalColors); + _system->setPalette(_videoBuf1, 0, _fastFadeCount); delay(5); } - _paletteColorCount = 0; + _fastFadeInFlag = 0; } } // End of namespace Simon diff --git a/engines/simon/intern.h b/engines/simon/intern.h index 1c2937c995..8881fd4a27 100644 --- a/engines/simon/intern.h +++ b/engines/simon/intern.h @@ -65,12 +65,6 @@ struct Item { Item() { memset(this, 0, sizeof(*this)); } }; -struct Subroutine { - uint16 id; /* subroutine ID */ - uint16 first; /* offset from subroutine start to first subroutine line */ - Subroutine *next; /* next subroutine in linked list */ -}; - struct IconEntry { Item *item; uint16 boxCode; @@ -100,37 +94,17 @@ struct WindowBlock { // the actual x-coordinate is: textColumn * 8 + textColumnOffset // the actual y-coordinate is: textRow * 8 - -enum BoxFlags { - kBFTextBox = 0x1, - kBFBoxSelected = 0x2, - kBFNoTouchName = 0x4, - kBFInvertTouch = 0x8, - kBFDragBox = 0x10, // Simon 1/2 - kBFHyperBox = 0x10, // Feeble Files - kBFBoxInUse = 0x20, - kBFBoxDead = 0x40, - kBFBoxItem = 0x80 -}; - -enum SubObjectFlags { - kOFText = 0x1, - kOFSize = 0x2, - kOFWeight = 0x4, - kOFVolume = 0x8, - kOFIcon = 0x10, - kOFKeyColor1 = 0x20, - kOFKeyColor2 = 0x40, - kOFMenu = 0x80, - kOFNumber = 0x100, - kOFVoice = 0x200 -}; - enum { SUBROUTINE_LINE_SMALL_SIZE = 2, SUBROUTINE_LINE_BIG_SIZE = 8 }; +struct Subroutine { + uint16 id; /* subroutine ID */ + uint16 first; /* offset from subroutine start to first subroutine line */ + Subroutine *next; /* next subroutine in linked list */ +}; + struct SubroutineLine { uint16 next; int16 verb; @@ -154,7 +128,30 @@ struct GameSpecificSettings { #endif }; -} // End of namespace Simon +enum BoxFlags { + kBFTextBox = 0x1, + kBFBoxSelected = 0x2, + kBFNoTouchName = 0x4, + kBFInvertTouch = 0x8, + kBFDragBox = 0x10, // Simon 1/2 + kBFHyperBox = 0x10, // Feeble Files + kBFBoxInUse = 0x20, + kBFBoxDead = 0x40, + kBFBoxItem = 0x80 +}; + +enum SubObjectFlags { + kOFText = 0x1, + kOFSize = 0x2, + kOFWeight = 0x4, + kOFVolume = 0x8, + kOFIcon = 0x10, + kOFKeyColor1 = 0x20, + kOFKeyColor2 = 0x40, + kOFMenu = 0x80, + kOFNumber = 0x100, + kOFVoice = 0x200 +}; enum GameFeatures { GF_TALKIE = 1 << 0, @@ -232,4 +229,6 @@ enum GameIds { GID_FEEBLEFILES_DE }; +} // End of namespace Simon + #endif diff --git a/engines/simon/items.cpp b/engines/simon/items.cpp index c8e2292d7a..700546c6a4 100644 --- a/engines/simon/items.cpp +++ b/engines/simon/items.cpp @@ -1622,20 +1622,18 @@ void SimonEngine::o1_specialFade() { // 187: fade to black uint i; - memcpy(_videoBuf1, _paletteBackup, 1024); - - i = NUM_PALETTE_FADEOUT; - do { - paletteFadeOut((uint32 *)_videoBuf1, 32); - paletteFadeOut((uint32 *)_videoBuf1 + 32 + 16, 144); - paletteFadeOut((uint32 *)_videoBuf1 + 32 + 16 + 144 + 16, 48); + memcpy(_videoBuf1, _currentPalette, 1024); + for (i = 32; i != 0; --i) { + paletteFadeOut(_videoBuf1, 32, 4); + paletteFadeOut(_videoBuf1 + 64, 144, 4); + paletteFadeOut(_videoBuf1 + 128, 48, 4); _system->setPalette(_videoBuf1, 0, 256); delay(5); - } while (--i); + } - memcpy(_paletteBackup, _videoBuf1, 1024); - memcpy(_palette, _videoBuf1, 1024); + memcpy(_currentPalette, _videoBuf1, 1024); + memcpy(_displayPalette, _videoBuf1, 1024); } // ----------------------------------------------------------------------- @@ -2132,9 +2130,9 @@ void SimonEngine::o3_setColour() { uint g = getVarOrByte(); uint b = getVarOrByte(); - _palette[c + 0] = r; - _palette[c + 1] = g; - _palette[c + 2] = b; + _displayPalette[c + 0] = r; + _displayPalette[c + 1] = g; + _displayPalette[c + 2] = b; _paletteFlag = 2; } diff --git a/engines/simon/simon.cpp b/engines/simon/simon.cpp index 1bc65a6e72..73f6b34af0 100644 --- a/engines/simon/simon.cpp +++ b/engines/simon/simon.cpp @@ -241,7 +241,7 @@ SimonEngine::SimonEngine(OSystem *syst) _scrollUpHitArea = 0; _scrollDownHitArea = 0; - _paletteColorCount = 0; + _fastFadeInFlag = 0; _noOverWrite = 0; _rejectCount = 0; @@ -259,7 +259,7 @@ SimonEngine::SimonEngine(OSystem *syst) _showPreposition = 0; _showMessageFlag = 0; - _videoNumPalColors = 0; + _fastFadeCount = 0; _vgaSpriteChanged = 0; @@ -334,8 +334,8 @@ SimonEngine::SimonEngine(OSystem *syst) _PVCount1 = 0; _GPVCount1 = 0; - memset(_paletteBackup, 0, sizeof(_paletteBackup)); - memset(_palette, 0, sizeof(_palette)); + memset(_currentPalette, 0, sizeof(_currentPalette)); + memset(_displayPalette, 0, sizeof(_displayPalette)); memset(_videoBuf1, 0, sizeof(_videoBuf1)); @@ -629,20 +629,20 @@ void SimonEngine::errorString(const char *buf1, char *buf2) { } } -void SimonEngine::paletteFadeOut(uint32 *pal_values, uint num) { - byte *p = (byte *)pal_values; +void SimonEngine::paletteFadeOut(byte *palPtr, uint num, uint size) { + byte *p = palPtr; do { - if (p[0] >= 8) - p[0] -= 8; + if (p[0] >= size) + p[0] -= size; else p[0] = 0; - if (p[1] >= 8) - p[1] -= 8; + if (p[1] >= size) + p[1] -= size; else p[1] = 0; - if (p[2] >= 8) - p[2] -= 8; + if (p[2] >= size) + p[2] -= size; else p[2] = 0; p += 4; @@ -1541,7 +1541,7 @@ void SimonEngine::set_video_mode_internal(uint16 mode, uint16 vga_res_id) { if (getGameType() == GType_SIMON1) { if (_unkPalFlag) { _unkPalFlag = false; - while (_paletteColorCount != 0) { + while (_fastFadeInFlag != 0) { delay(10); } } diff --git a/engines/simon/simon.h b/engines/simon/simon.h index 6ecab2f889..ff9226bd29 100644 --- a/engines/simon/simon.h +++ b/engines/simon/simon.h @@ -43,7 +43,6 @@ namespace Simon { uint fileReadItemID(Common::File *in); #define CHECK_BOUNDS(x, y) assert((uint)(x) < ARRAYSIZE(y)) -#define NUM_PALETTE_FADEOUT 32 struct Child; struct SubObject; @@ -343,7 +342,11 @@ protected: uint16 _scrollUpHitArea; uint16 _scrollDownHitArea; - volatile uint16 _paletteColorCount; + bool _fastFadeOutFlag; + bool _unkPalFlag; + byte _paletteFlag; + uint _fastFadeCount; + volatile uint16 _fastFadeInFlag; int _screenWidth, _screenHeight; @@ -351,10 +354,7 @@ protected: byte _rejectCount; bool _rejectBlock; - bool _fastFadeOutFlag; - bool _unkPalFlag; bool _exitCutscene; - byte _paletteFlag; uint _soundFileId; int16 _lastMusicPlayed; @@ -363,8 +363,6 @@ protected: bool _showPreposition; bool _showMessageFlag; - uint _videoNumPalColors; - uint _vgaSpriteChanged; byte *_vgaBufFreeStart, *_vgaBufEnd, *_vgaBufStart; @@ -431,8 +429,8 @@ protected: uint16 _PVCount1; uint16 _GPVCount1; - uint8 _paletteBackup[1024]; - uint8 _palette[1024]; + uint8 _currentPalette[1024]; + uint8 _displayPalette[1024]; byte _videoBuf1[3000]; @@ -502,7 +500,7 @@ protected: void loadSound(uint sound, int pan, int vol, uint type); void loadVoice(uint speechId); - void paletteFadeOut(uint32 *pal_values, uint num); + void paletteFadeOut(byte *palPtr, uint num, uint size = 8); byte *allocateItem(uint size); byte *allocateTable(uint size); diff --git a/engines/simon/vga.cpp b/engines/simon/vga.cpp index 9be750e500..9c4172e85f 100644 --- a/engines/simon/vga.cpp +++ b/engines/simon/vga.cpp @@ -301,7 +301,7 @@ void SimonEngine::vc2_call() { uint16 count, num, res; byte *old_file_1, *old_file_2; byte *b, *bb; - const byte *vc_ptr_org; + const byte *vcPtrOrg; num = vcReadVarOrWord(); @@ -349,7 +349,7 @@ void SimonEngine::vc2_call() { assert(READ_BE_UINT16(&((ImageHeader_Simon *) b)->id) == num); } - vc_ptr_org = _vcPtr; + vcPtrOrg = _vcPtr; if (getGameType() == GType_FF) { _vcPtr = _curVgaFile1 + READ_LE_UINT16(&((ImageHeader_Feeble *) b)->scriptOffs); @@ -363,7 +363,7 @@ void SimonEngine::vc2_call() { _curVgaFile1 = old_file_1; _curVgaFile2 = old_file_2; - _vcPtr = vc_ptr_org; + _vcPtr = vcPtrOrg; } void SimonEngine::vc3_loadSprite() { @@ -1622,7 +1622,7 @@ void SimonEngine::vc22_setSpritePalette() { palSize = 768; } - palptr = &_palette[(a * 64)]; + palptr = &_displayPalette[(a * 64)]; src = _curVgaFile1 + 6 + b * palSize; do { @@ -2130,7 +2130,7 @@ void SimonEngine::vc59() { void SimonEngine::vc58() { uint16 sprite = _vgaCurSpriteId; uint16 file = _vgaCurZoneNum; - const byte *vc_ptr_org; + const byte *vcPtrOrg; uint16 tmp; _vgaCurZoneNum = vcReadNextWord(); @@ -2138,11 +2138,11 @@ void SimonEngine::vc58() { tmp = to16Wrapper(vcReadNextWord()); - vc_ptr_org = _vcPtr; + vcPtrOrg = _vcPtr; _vcPtr = (byte *)&tmp; vc23_setSpritePriority(); - _vcPtr = vc_ptr_org; + _vcPtr = vcPtrOrg; _vgaCurSpriteId = sprite; _vgaCurZoneNum = file; } @@ -2156,11 +2156,11 @@ void SimonEngine::vc_kill_sprite(uint file, uint sprite) { VgaSleepStruct *vfs; VgaSprite *vsp; VgaTimerEntry *vte; - const byte *vc_ptr_org; + const byte *vcPtrOrg; old_sprite_id = _vgaCurSpriteId; old_cur_file_id = _vgaCurZoneNum; - vc_ptr_org = _vcPtr; + vcPtrOrg = _vcPtr; _vgaCurZoneNum = file; _vgaCurSpriteId = sprite; @@ -2193,7 +2193,7 @@ void SimonEngine::vc_kill_sprite(uint file, uint sprite) { _vgaCurZoneNum = old_cur_file_id; _vgaCurSpriteId = old_sprite_id; - _vcPtr = vc_ptr_org; + _vcPtr = vcPtrOrg; } void SimonEngine::vc60_killSprite() { @@ -2221,23 +2221,32 @@ void SimonEngine::vc61_setMaskImage() { } void SimonEngine::vc62_fastFadeOut() { - uint i; - vc29_stopAllSounds(); if (!_fastFadeOutFlag) { + uint i, fadeSize, fadeCount; + _fastFadeOutFlag = true; - _videoNumPalColors = 256; + _fastFadeCount = 256; if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { if (_windowNum == 4) - _videoNumPalColors = 208; + _fastFadeCount = 208; + } + + memcpy(_videoBuf1, _currentPalette, _fastFadeCount * 4); + + if (getGameType() == GType_FF && !getBitFlag(75)) { + fadeCount = 32; + fadeSize = 8; + } else { + fadeCount = 4; + fadeSize = 64; } - memcpy(_videoBuf1, _paletteBackup, _videoNumPalColors * 4); - for (i = NUM_PALETTE_FADEOUT; i != 0; --i) { - paletteFadeOut((uint32 *)_videoBuf1, _videoNumPalColors); - _system->setPalette(_videoBuf1, 0, _videoNumPalColors); + for (i = fadeCount; i != 0; --i) { + paletteFadeOut(_videoBuf1, _fastFadeCount, fadeSize); + _system->setPalette(_videoBuf1, 0, _fastFadeCount); delay(5); } @@ -2245,7 +2254,7 @@ void SimonEngine::vc62_fastFadeOut() { uint16 params[5]; /* parameters to vc10_draw */ VgaSprite *vsp; VgaPointersEntry *vpe; - const byte *vc_ptr_org = _vcPtr; + const byte *vcPtrOrg = _vcPtr; vsp = _vgaSprites; while (vsp->id != 0) { @@ -2274,7 +2283,7 @@ void SimonEngine::vc62_fastFadeOut() { } vsp++; } - _vcPtr = vc_ptr_org; + _vcPtr = vcPtrOrg; } // Allow one section of Simon the Sorcerer 1 introduction to be displayed @@ -2295,11 +2304,11 @@ void SimonEngine::vc62_fastFadeOut() { void SimonEngine::vc63_fastFadeIn() { if (getGameType() == GType_FF) { - _paletteColorCount = 256; + _fastFadeInFlag = 256; } else { - _paletteColorCount = 208; + _fastFadeInFlag = 208; if (_windowNum != 4) { - _paletteColorCount = 256; + _fastFadeInFlag = 256; } } _fastFadeOutFlag = false; @@ -2313,13 +2322,13 @@ void SimonEngine::vc64_skipIfSpeechEnded() { } void SimonEngine::vc65_slowFadeIn() { - _paletteColorCount = 624; - _videoNumPalColors = 208; + _fastFadeInFlag = 624; + _fastFadeCount = 208; if (_windowNum != 4) { - _paletteColorCount = 768; - _videoNumPalColors = 256; + _fastFadeInFlag = 768; + _fastFadeCount = 256; } - _paletteColorCount |= 0x8000; + _fastFadeInFlag |= 0x8000; _fastFadeOutFlag = false; } -- cgit v1.2.3