aboutsummaryrefslogtreecommitdiff
path: root/sky/control.cpp
diff options
context:
space:
mode:
authorRobert Göffringmann2003-07-04 22:39:10 +0000
committerRobert Göffringmann2003-07-04 22:39:10 +0000
commita4bd31578b41bfd9fc33cf33d77cafed4de40013 (patch)
tree0772b8f941c055d9e535f1bc7e11579044b01268 /sky/control.cpp
parent67ba28170f26080fed61ce97b4ae6bb5d81a9d03 (diff)
downloadscummvm-rg350-a4bd31578b41bfd9fc33cf33d77cafed4de40013.tar.gz
scummvm-rg350-a4bd31578b41bfd9fc33cf33d77cafed4de40013.tar.bz2
scummvm-rg350-a4bd31578b41bfd9fc33cf33d77cafed4de40013.zip
support text and speech at the same time
svn-id: r8750
Diffstat (limited to 'sky/control.cpp')
-rw-r--r--sky/control.cpp126
1 files changed, 106 insertions, 20 deletions
diff --git a/sky/control.cpp b/sky/control.cpp
index ff9878a5eb..a2cbb54230 100644
--- a/sky/control.cpp
+++ b/sky/control.cpp
@@ -83,6 +83,16 @@ SkyTextResource::~SkyTextResource(void) {
free(_oldScreen);
}
+void SkyTextResource::flushForRedraw(void) {
+
+ if (_oldX < GAME_SCREEN_WIDTH) {
+ uint16 cpWidth = (PAN_LINE_WIDTH > (GAME_SCREEN_WIDTH - _oldX))?(GAME_SCREEN_WIDTH - _oldX):(PAN_LINE_WIDTH);
+ for (uint8 cnty = 0; cnty < PAN_CHAR_HEIGHT; cnty++)
+ memcpy(_screen + (cnty + _oldY) * GAME_SCREEN_WIDTH + _oldX, _oldScreen + cnty * PAN_LINE_WIDTH, cpWidth);
+ }
+ _oldX = GAME_SCREEN_WIDTH;
+}
+
void SkyTextResource::drawToScreen(bool doMask) {
doMask = true;
@@ -198,10 +208,7 @@ void SkyControl::initPanel(void) {
_fxPanButton = createResource( _sprites.button, 3, 2, 58, 99, 87, TOGGLE_FX, MAINPANEL);
if (SkyState::isCDVersion()) { // CD Version: Toggle text/speech
- if (SkyState::_systemVars.systemFlags & SF_ALLOW_TEXT)
- _musicPanButton = createResource( _sprites.button, 3, 2, 58, 119, 21, TOGGLE_TEXT, MAINPANEL);
- else
- _musicPanButton = createResource( _sprites.button, 3, 0, 58, 119, 35, TOGGLE_TEXT, MAINPANEL);
+ _musicPanButton = createResource( _sprites.button, 3, 0, 58, 119, 52, TOGGLE_TEXT, MAINPANEL);
} else { // disk version: toggle music on/off
_musicPanButton = createResource( _sprites.button, 3, 0, 58, 119, 91, TOGGLE_MS, MAINPANEL);
}
@@ -262,15 +269,46 @@ void SkyControl::buttonControl(SkyConResource *pButton) {
_text->setXY(_mouseX + 12, _mouseY - 16);
}
+void SkyControl::drawTextCross(uint32 flags) {
+
+ _bodge->drawToScreen(NO_MASK);
+ if (!(flags & SF_ALLOW_SPEECH))
+ drawCross(151, 124);
+ if (!(flags & SF_ALLOW_TEXT))
+ drawCross(173, 124);
+}
+
+void SkyControl::drawCross(uint16 x, uint16 y) {
+
+ _text->flushForRedraw();
+ uint8 *bufPos, *crossPos;
+ bufPos = _screenBuf + y * GAME_SCREEN_WIDTH + x;
+ crossPos = _crossImg;
+ for (uint16 cnty = 0; cnty < CROSS_SZ_Y; cnty++) {
+ for (uint16 cntx = 0; cntx < CROSS_SZ_X; cntx++)
+ if (crossPos[cntx] != 0xFF)
+ bufPos[cntx] = crossPos[cntx];
+ bufPos += GAME_SCREEN_WIDTH;
+ crossPos += CROSS_SZ_X;
+ }
+ bufPos = _screenBuf + y * GAME_SCREEN_WIDTH + x;
+ _system->copy_rect(bufPos, GAME_SCREEN_WIDTH, x, y, CROSS_SZ_X, CROSS_SZ_Y);
+ _text->drawToScreen(WITH_MASK);
+}
+
void SkyControl::animClick(SkyConResource *pButton) {
if (pButton->_curSprite != pButton->_numSprites -1) {
pButton->_curSprite++;
+ _text->flushForRedraw();
pButton->drawToScreen(NO_MASK);
+ _text->drawToScreen(WITH_MASK);
_system->update_screen();
delay(150);
pButton->_curSprite--;
+ _text->flushForRedraw();
pButton->drawToScreen(NO_MASK);
+ _text->drawToScreen(WITH_MASK);
_system->update_screen();
}
}
@@ -291,6 +329,8 @@ void SkyControl::drawMainPanel(void) {
_slide->drawToScreen(WITH_MASK);
_slide2->drawToScreen(WITH_MASK);
_bodge->drawToScreen(WITH_MASK);
+ if (SkyState::isCDVersion())
+ drawTextCross(SkyState::_systemVars.systemFlags & TEXT_FLAG_MASK);
}
void SkyControl::restartGame(void) {
@@ -372,9 +412,9 @@ void SkyControl::doControlPanel(void) {
buttonControl(_controlPanLookList[lookCnt]);
if (_mouseClicked && _controlPanLookList[lookCnt]->_onClick) {
clickRes = handleClick(_controlPanLookList[lookCnt]);
- buttonControl(NULL);
- _text->drawToScreen(WITH_MASK); // flush text restore buffer
+ _text->flushForRedraw();
drawMainPanel();
+ _text->drawToScreen(WITH_MASK);
if ((clickRes == QUIT_PANEL) || (clickRes == GAME_SAVED) ||
(clickRes == GAME_RESTORED))
quitPanel = true;
@@ -455,7 +495,8 @@ uint16 SkyControl::handleClick(SkyConResource *pButton) {
return 0;
case TOGGLE_TEXT:
- return toggleText(pButton);
+ animClick(pButton);
+ return toggleText();
case EXIT:
animClick(pButton);
@@ -585,20 +626,23 @@ uint16 SkyControl::toggleFx(SkyConResource *pButton) {
return TOGGLED;
}
-uint16 SkyControl::toggleText(SkyConResource *pButton) {
+uint16 SkyControl::toggleText(void) {
+
+ uint32 flags = SkyState::_systemVars.systemFlags & TEXT_FLAG_MASK;
+ SkyState::_systemVars.systemFlags &= ~TEXT_FLAG_MASK;
+
+
+ if (flags == SF_ALLOW_TEXT)
+ flags = SF_ALLOW_SPEECH;
+ else if (flags == SF_ALLOW_SPEECH)
+ flags = SF_ALLOW_SPEECH | SF_ALLOW_TEXT;
+ else
+ flags = SF_ALLOW_TEXT;
+
+ SkyState::_systemVars.systemFlags |= flags;
+
+ drawTextCross(flags);
- SkyState::_systemVars.systemFlags ^= SF_ALLOW_SPEECH;
- if (SkyState::_systemVars.systemFlags & SF_ALLOW_SPEECH) {
- pButton->_curSprite = 0;
- pButton->_text = 0x7000 + 35;
- SkyState::_systemVars.systemFlags &= ~SF_ALLOW_TEXT;
- } else {
- pButton->_curSprite = 2;
- pButton->_text = 0x7000 + 21;
- SkyState::_systemVars.systemFlags |= SF_ALLOW_TEXT;
- }
- pButton->drawToScreen(WITH_MASK);
- buttonControl(pButton);
_system->update_screen();
return TOGGLED;
}
@@ -1384,3 +1428,45 @@ char SkyControl::_quitTexts[12][30] = {
"Fim de jogo para o jogador um",
"BE VIGILANT"
};
+
+uint8 SkyControl::_crossImg[594] = {
+ 0xFF, 0xFF, 0xFF, 0xFF, 0x09, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0B, 0x61, 0xFF, 0xFF, 0xFF, 0xFF, 0x4F, 0x4D, 0x61,
+ 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0x08, 0x4E, 0x53, 0x50, 0x4F, 0x0C, 0x4D, 0x4E, 0x51, 0x58, 0x58, 0x54, 0x4E, 0x08, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4E, 0x54, 0x58, 0x50, 0x4E, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0x50, 0x4E, 0x54, 0x58, 0x58, 0x54, 0x4E, 0x0C, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0x61, 0x53, 0x58, 0x54, 0x4E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0x50, 0x4E, 0x55, 0x58, 0x58, 0x53, 0x4E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x05, 0x51, 0x58, 0x58,
+ 0x51, 0x50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