Skip to content

Commit

Permalink
ACCESS: Implement two more opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Aug 18, 2014
1 parent 080a030 commit b6dc7a1
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 6 deletions.
117 changes: 113 additions & 4 deletions engines/access/scripts.cpp
Expand Up @@ -110,9 +110,9 @@ void Scripts::executeCommand(int commandIndex) {
&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast,
&Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial,
&Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak,
&Scripts::cmdTexSpeak, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT,
&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT,
&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice,
&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::CMDLOADSOUND,
&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound,
&Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND,
&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION,
&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff,
Expand Down Expand Up @@ -454,7 +454,111 @@ void Scripts::cmdTexSpeak() {
findNull();
}

void Scripts::CMDTEXCHOICE() { error("TODO CMDTEXCHOICE"); } // _choiceStart = _data->pos() - 1;
int Scripts::checkMouseBox1(Common::Rect *rectArr) {
int i = 0;
for (i = 0; ; i++){
if (rectArr[i].left == -1)
return -1;

if ((_vm->_events->_mousePos.x > rectArr[i].left) && (_vm->_events->_mousePos.x < rectArr[i].right)
&& (_vm->_events->_mousePos.y > rectArr[i].top) && (_vm->_events->_mousePos.y < rectArr[i].bottom))
return i;
}
}

void Scripts::cmdTexChoice() {
static Common::Point cMouse[7] = {
Common::Point(0, 76), Common::Point(77, 154), Common::Point(155, 232),
Common::Point(233, 276), Common::Point(0, 0), Common::Point(277, 319),
Common::Point(297, 319)
};

_vm->_oldRects.clear();
_choiceStart = _data->pos() - 1;
_vm->_fonts._charSet._lo = 1;
_vm->_fonts._charSet._hi = 8;
_vm->_fonts._charFor._lo = 55;
_vm->_fonts._charFor._hi = 255;
_vm->_bubbleBox->_maxChars = 20;

_vm->_fonts._printOrg = _texsOrg;
_vm->_fonts._printStart = _texsOrg;

_vm->_bubbleBox->clearBubbles();
_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 1").c_str();

byte v;
Common::String tmpStr = "";
while ((v = _data->readByte()) != 0)
tmpStr += (char)v;

_vm->_bubbleBox->calcBubble(tmpStr);
_vm->_bubbleBox->printBubble(tmpStr);

Common::Rect responseCoords[2];
responseCoords[0] = _vm->_bubbleBox->_bounds;
responseCoords[1] = Common::Rect(0, 0, 0, 0);
_vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;

findNull();

bool choice2Fl = false;
tmpStr = "";
while ((v = _data->readByte()) != 0)
tmpStr += (char)v;

Common::Rect termResponse2 = Common::Rect(-1, 0, 0, 0);
if (tmpStr.size() != 0) {
choice2Fl = true;
_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 2").c_str();
_vm->_bubbleBox->calcBubble(tmpStr);
_vm->_bubbleBox->printBubble(tmpStr);
responseCoords[1] = _vm->_bubbleBox->_bounds;
_vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
}

findNull();

bool choice3Fl = false;
tmpStr = "";
while ((v = _data->readByte()) != 0)
tmpStr += (char)v;

if (tmpStr.size() != 0) {
_vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 3").c_str();
_vm->_bubbleBox->calcBubble(tmpStr);
_vm->_bubbleBox->printBubble(tmpStr);
termResponse2 = _vm->_bubbleBox->_bounds;
_vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11;
}

findNull();

int choice = -1;
do {
warning("TODO CHARLOOP");
_vm->_bubbleBox->_bubblePtr = _vm->_bubbleBox->_bubbleTitle.c_str();
if (_vm->_events->_leftButton) {
if (_vm->_events->_mouseRow >= 22) {
_vm->_events->debounceLeft();
int x = _vm->_events->_mousePos.x;
for (int i = 0; i < 7; i++) {
if ((x >= cMouse->x) && (x < cMouse->y)) {
choice = i;
break;
}
}
} else {
_vm->_events->debounceLeft();
choice = checkMouseBox1(responseCoords);
}
}
} while ((choice == -1) || ((choice == 2) && choice3Fl));

_choice = choice + 1;
_vm->_bubbleBox->clearBubbles();
}

void Scripts::CMDWAIT() { error("TODO CMDWAIT"); }

void Scripts::cmdSetConPos() {
Expand Down Expand Up @@ -487,7 +591,12 @@ void Scripts::cmdClearBlock() {
_vm->_screen->restoreBlock();
}

void Scripts::CMDLOADSOUND() { error("TODO CMDLOADSOUND"); }
void Scripts::cmdLoadSound() {
int idx = _data->readSint16LE();
_vm->_sound->_soundTable[0]._data = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSTable, _vm->_extraCells[idx]._vidSTable1);
_vm->_sound->_soundPriority[0] = 1;
}

void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); }
void Scripts::CMDSETVIDSND() { error("TODO CMDSETVIDSND"); }
void Scripts::CMDPLAYVIDSND() { error("TODO CMDPLAYVIDSND"); }
Expand Down
6 changes: 4 additions & 2 deletions engines/access/scripts.h
Expand Up @@ -43,6 +43,8 @@ class Scripts: public Manager {
virtual void executeSpecial(int commandIndex, int param1, int param2) = 0;
virtual void executeCommand(int commandIndex);

int checkMouseBox1(Common::Rect *rectArr);

/**
* Print a given message to the screen in a bubble box
*/
Expand Down Expand Up @@ -103,14 +105,14 @@ class Scripts: public Manager {
void CMDCYCLE();
void cmdCharSpeak();
void cmdTexSpeak();
void CMDTEXCHOICE();
void cmdTexChoice();
void CMDWAIT();
void cmdSetConPos();
void CMDCHECKVFRAME();
void cmdJumpChoice();
void cmdReturnChoice();
void cmdClearBlock();
void CMDLOADSOUND();
void cmdLoadSound();
void CMDFREESOUND();
void CMDSETVIDSND();
void CMDPLAYVIDSND();
Expand Down

0 comments on commit b6dc7a1

Please sign in to comment.