Skip to content

Commit

Permalink
ACCESS: Implemented cmdSpecial script opcode
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 14, 2014
1 parent ed645e4 commit 28bfe73
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 1 deletion.
5 changes: 5 additions & 0 deletions engines/access/amazon/amazon_scripts.cpp
Expand Up @@ -31,6 +31,11 @@ namespace Amazon {
AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) {
}

void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
warning("TODO");
}


} // End of namespace Amazon

} // End of namespace Access
2 changes: 2 additions & 0 deletions engines/access/amazon/amazon_scripts.h
Expand Up @@ -31,6 +31,8 @@ namespace Access {
namespace Amazon {

class AmazonScripts: public Scripts {
protected:
virtual void executeSpecial(int commandIndex, int param1, int param2);
public:
AmazonScripts(AccessEngine *vm);
};
Expand Down
18 changes: 18 additions & 0 deletions engines/access/screen.cpp
Expand Up @@ -40,6 +40,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
Common::fill(&_manPal[0], &_manPal[0x60], 0);
Common::fill(&_scaleTable1[0], &_scaleTable1[256], 0);
Common::fill(&_scaleTable2[0], &_scaleTable2[256], 0);
_savedPaletteCount = 0;
_vesaMode = 0;
_vesaCurrentWin = 0;
_currentPanel = 0;
Expand Down Expand Up @@ -114,6 +115,23 @@ void Screen::updatePalette() {
updateScreen();
}

void Screen::savePalette() {
Common::copy(&_rawPalette[0], &_rawPalette[PALETTE_SIZE],
&_savedPalettes[_savedPaletteCount][0]);

if (++_savedPaletteCount == 2)
_savedPaletteCount = 1;
}

void Screen::restorePalette() {
if (--_savedPaletteCount < 0)
_savedPaletteCount = 0;

Common::copy(&_savedPalettes[_savedPaletteCount][0],
&_savedPalettes[_savedPaletteCount][PALETTE_SIZE], &_rawPalette[0]);
}


void Screen::forceFadeOut() {
const int FADE_AMOUNT = 2;
bool repeatFlag;
Expand Down
6 changes: 6 additions & 0 deletions engines/access/screen.h
Expand Up @@ -52,6 +52,8 @@ class Screen: public ASurface {
AccessEngine *_vm;
byte _tempPalette[PALETTE_SIZE];
byte _rawPalette[PALETTE_SIZE];
byte _savedPalettes[2][PALETTE_SIZE];
int _savedPaletteCount;
int _vesaCurrentWin;
int _currentPanel;
Common::Point _msVirtualOffset;
Expand Down Expand Up @@ -117,6 +119,10 @@ class Screen: public ASurface {

void loadRawPalette(Common::SeekableReadStream *stream);

void savePalette();

void restorePalette();

/**
* Copy a buffer to the screen
*/
Expand Down
21 changes: 20 additions & 1 deletion engines/access/scripts.cpp
Expand Up @@ -326,7 +326,26 @@ void Scripts::cmdRemoveLast() {
--_vm->_numAnimTimers;
}

void Scripts::CMDSPECIAL() { error("TODO"); }
void Scripts::CMDSPECIAL() {
_specialFunction = _data->readUint16LE();
int p1 = _data->readUint16LE();
int p2 = _data->readUint16LE();

if (_specialFunction == 1) {
if (_vm->_establishTable[p2] == 1)
return;

_vm->_screen->savePalette();
}

executeSpecial(_specialFunction, p1, p2);

if (_specialFunction == 1) {
_vm->_screen->restorePalette();
_vm->_room->_function = 3;
}
}

void Scripts::CMDSETCYCLE() { error("TODO"); }
void Scripts::CMDCYCLE() { error("TODO"); }
void Scripts::CMDCHARSPEAK() { error("TODO"); }
Expand Down
2 changes: 2 additions & 0 deletions engines/access/scripts.h
Expand Up @@ -37,9 +37,11 @@ class Scripts {
private:
const byte *_rawData;
Common::MemoryReadStream *_data;
int _specialFunction;
protected:
AccessEngine *_vm;

virtual void executeSpecial(int commandIndex, int param1, int param2) = 0;
virtual void executeCommand(int commandIndex);
void CMDOBJECT();
void CMDENDOBJECT();
Expand Down

0 comments on commit 28bfe73

Please sign in to comment.