diff options
165 files changed, 2180 insertions, 1578 deletions
diff --git a/backends/events/dinguxsdl/dinguxsdl-events.cpp b/backends/events/dinguxsdl/dinguxsdl-events.cpp index 0492c569e1..7730e8f915 100644 --- a/backends/events/dinguxsdl/dinguxsdl-events.cpp +++ b/backends/events/dinguxsdl/dinguxsdl-events.cpp @@ -72,54 +72,54 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { if (ev.key.keysym.sym == PAD_UP) { if (ev.type == SDL_KEYDOWN) { - _km.y_vel = -1; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 0; + _km.y_vel = 0 * MULTIPLIER; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == PAD_DOWN) { if (ev.type == SDL_KEYDOWN) { - _km.y_vel = 1; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 0; + _km.y_vel = 0 * MULTIPLIER; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == PAD_LEFT) { if (ev.type == SDL_KEYDOWN) { - _km.x_vel = -1; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 0; + _km.x_vel = 0 * MULTIPLIER; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == PAD_RIGHT) { if (ev.type == SDL_KEYDOWN) { - _km.x_vel = 1; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 0; + _km.x_vel = 0 * MULTIPLIER; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == BUT_Y) { // left mouse button @@ -129,7 +129,7 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_LBUTTONUP; } - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == BUT_B) { // right mouse button @@ -139,7 +139,7 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_RBUTTONUP; } - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == BUT_X) { // '.' skip dialogue diff --git a/backends/events/gph/gph-events.cpp b/backends/events/gph/gph-events.cpp index 88fc97d3d1..d59d0bead5 100644 --- a/backends/events/gph/gph-events.cpp +++ b/backends/events/gph/gph-events.cpp @@ -230,116 +230,116 @@ bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { switch (ev.jbutton.button) { case BUTTON_UP: if (_km.y_down_count != 2) { - _km.y_vel = -1; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = -4; + _km.y_vel = -4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_DOWN: if (_km.y_down_count != 2) { - _km.y_vel = 1; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 4; + _km.y_vel = 4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_LEFT: if (_km.x_down_count != 2) { - _km.x_vel = -1; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = -4; + _km.x_vel = -4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_RIGHT: if (_km.x_down_count != 3) { - _km.x_vel = 1; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 4; + _km.x_vel = 4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_UPLEFT: if (_km.x_down_count != 2) { - _km.x_vel = -1; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = -4; + _km.x_vel = -4 * MULTIPLIER; } if (_km.y_down_count != 2) { - _km.y_vel = -1; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = -4; + _km.y_vel = -4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_UPRIGHT: if (_km.x_down_count != 2) { - _km.x_vel = 1; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 4; + _km.x_vel = 4 * MULTIPLIER; } if (_km.y_down_count != 2) { - _km.y_vel = -1; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = -4; + _km.y_vel = -4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_DOWNLEFT: if (_km.x_down_count != 2) { - _km.x_vel = -1; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = -4; + _km.x_vel = -4 * MULTIPLIER; } if (_km.y_down_count != 2) { - _km.y_vel = 1; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 4; + _km.y_vel = 4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_DOWNRIGHT: if (_km.x_down_count != 2) { - _km.x_vel = 1; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 4; + _km.x_vel = 4 * MULTIPLIER; } if (_km.y_down_count != 2) { - _km.y_vel = 1; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 4; + _km.y_vel = 4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_B: case BUTTON_CLICK: event.type = Common::EVENT_LBUTTONDOWN; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_X: event.type = Common::EVENT_RBUTTONDOWN; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_L: BUTTON_STATE_L = true; @@ -454,16 +454,16 @@ bool GPHEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { _km.x_vel = 0; _km.x_down_count = 0; event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_B: case BUTTON_CLICK: event.type = Common::EVENT_LBUTTONUP; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_X: event.type = Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_L: BUTTON_STATE_L = false; diff --git a/backends/events/linuxmotosdl/linuxmotosdl-events.cpp b/backends/events/linuxmotosdl/linuxmotosdl-events.cpp index b0d443ff9f..00453a036c 100644 --- a/backends/events/linuxmotosdl/linuxmotosdl-events.cpp +++ b/backends/events/linuxmotosdl/linuxmotosdl-events.cpp @@ -130,53 +130,53 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { // Joystick to Mouse else if (ev.key.keysym.sym == SDLK_LEFT) { if (ev.type == SDL_KEYDOWN) { - _km.x_vel = -1; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 0; + _km.x_vel = 0 * MULTIPLIER; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == SDLK_RIGHT) { if (ev.type == SDL_KEYDOWN) { - _km.x_vel = 1; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 0; + _km.x_vel = 0 * MULTIPLIER; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == SDLK_DOWN) { if (ev.type == SDL_KEYDOWN) { - _km.y_vel = 1; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 0; + _km.y_vel = 0 * MULTIPLIER; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == SDLK_UP) { if (ev.type == SDL_KEYDOWN) { - _km.y_vel = -1; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 0; + _km.y_vel = 0 * MULTIPLIER; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == SDLK_RETURN) { @@ -187,7 +187,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_LBUTTONUP; } - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == SDLK_PLUS) { @@ -197,7 +197,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { } else { event.type = Common::EVENT_RBUTTONUP; } - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == SDLK_MINUS) { @@ -208,7 +208,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_LBUTTONUP; } - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else { diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index 8b7514004a..e864c7d81c 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -96,7 +96,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { } } else if (ev.key.keysym.sym == SDLK_F7) { event.type = Common::EVENT_RBUTTONDOWN; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); debug(9, "remapping to right click down"); return true; } else if (ev.key.keysym.sym == SDLK_F8) { @@ -134,7 +134,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { } } else if (ev.key.keysym.sym == SDLK_F7) { event.type = Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); debug(9, "remapping to right click up"); return true; } else if (ev.key.keysym.sym == SDLK_F8) { diff --git a/backends/events/openpandora/op-events.cpp b/backends/events/openpandora/op-events.cpp index b9d5fa8c7b..abb1458d66 100644 --- a/backends/events/openpandora/op-events.cpp +++ b/backends/events/openpandora/op-events.cpp @@ -126,18 +126,18 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { switch (ev.key.keysym.sym) { case SDLK_LEFT: event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; case SDLK_RIGHT: event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; #if defined(SDL_BUTTON_MIDDLE) case SDLK_UP: event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_MBUTTONDOWN : Common::EVENT_MBUTTONUP; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; #endif @@ -150,12 +150,12 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { switch (ev.key.keysym.sym) { case SDLK_HOME: event.type = Common::EVENT_LBUTTONDOWN; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; case SDLK_END: event.type = Common::EVENT_RBUTTONDOWN; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; case SDLK_PAGEDOWN: @@ -188,12 +188,12 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { switch (ev.key.keysym.sym) { case SDLK_HOME: event.type = Common::EVENT_LBUTTONUP; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; case SDLK_END: event.type = Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; case SDLK_PAGEDOWN: diff --git a/backends/events/ps3sdl/ps3sdl-events.cpp b/backends/events/ps3sdl/ps3sdl-events.cpp index 1fc10559c2..01cdc2f0f6 100644 --- a/backends/events/ps3sdl/ps3sdl-events.cpp +++ b/backends/events/ps3sdl/ps3sdl-events.cpp @@ -60,11 +60,11 @@ bool PS3SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) switch (ev.jbutton.button) { case BTN_CROSS: // Left mouse button event.type = Common::EVENT_LBUTTONDOWN; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BTN_CIRCLE: // Right mouse button event.type = Common::EVENT_RBUTTONDOWN; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BTN_TRIANGLE: // Game menu event.type = Common::EVENT_KEYDOWN; @@ -98,11 +98,11 @@ bool PS3SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { switch (ev.jbutton.button) { case BTN_CROSS: // Left mouse button event.type = Common::EVENT_LBUTTONUP; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BTN_CIRCLE: // Right mouse button event.type = Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BTN_TRIANGLE: // Game menu event.type = Common::EVENT_KEYUP; diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 5fb66a7ec4..469f1d5a44 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -30,6 +30,10 @@ #include "common/config-manager.h" #include "common/textconsole.h" +#ifdef JOY_ANALOG +#include "math.h" +#endif + // FIXME move joystick defines out and replace with confile file options // we should really allow users to map any key to a joystick button #define JOY_DEADZONE 3200 @@ -175,15 +179,20 @@ void SdlEventSource::processMouseEvent(Common::Event &event, int x, int y) { } // Update the "keyboard mouse" coords - _km.x = x; - _km.y = y; + _km.x = x * MULTIPLIER; + _km.y = y * MULTIPLIER; } -void SdlEventSource::handleKbdMouse() { +bool SdlEventSource::handleKbdMouse(Common::Event &event) { + // returns true if an event is generated // Skip recording of these events uint32 curTime = g_system->getMillis(true); if (curTime >= _km.last_time + _km.delay_time) { + + int16 oldKmX = _km.x; + int16 oldKmY = _km.y; + _km.last_time = curTime; if (_km.x_down_count == 1) { _km.x_down_time = curTime; @@ -196,60 +205,84 @@ void SdlEventSource::handleKbdMouse() { if (_km.x_vel || _km.y_vel) { if (_km.x_down_count) { - if (curTime > _km.x_down_time + _km.delay_time * 12) { + if (curTime > _km.x_down_time + 300) { if (_km.x_vel > 0) - _km.x_vel++; + _km.x_vel += MULTIPLIER; else - _km.x_vel--; - } else if (curTime > _km.x_down_time + _km.delay_time * 8) { + _km.x_vel -= MULTIPLIER; + } else if (curTime > _km.x_down_time + 200) { if (_km.x_vel > 0) - _km.x_vel = 5; + _km.x_vel = 5 * MULTIPLIER; else - _km.x_vel = -5; + _km.x_vel = -5 * MULTIPLIER; } } if (_km.y_down_count) { - if (curTime > _km.y_down_time + _km.delay_time * 12) { + if (curTime > _km.y_down_time + 300) { if (_km.y_vel > 0) - _km.y_vel++; + _km.y_vel += MULTIPLIER; else - _km.y_vel--; - } else if (curTime > _km.y_down_time + _km.delay_time * 8) { + _km.y_vel -= MULTIPLIER; + } else if (curTime > _km.y_down_time + 200) { if (_km.y_vel > 0) - _km.y_vel = 5; + _km.y_vel = 5 * MULTIPLIER; else - _km.y_vel = -5; + _km.y_vel = -5 * MULTIPLIER; } } - _km.x += _km.x_vel; - _km.y += _km.y_vel; + // - The modifier key makes the mouse movement slower + // - The extra factor "delay/25" ensures velocities + // are independent of the kbdMouse update rate + // - all velocities were originally chosen + // at a delay of 25, so that is the reference used here + // - note: operator order is important to avoid overflow + if (_km.modifier) { + _km.x += ((_km.x_vel / 10) * ((int16)_km.delay_time)) / 25; + _km.y += ((_km.y_vel / 10) * ((int16)_km.delay_time)) / 25; + } else { + _km.x += (_km.x_vel * ((int16)_km.delay_time)) / 25; + _km.y += (_km.y_vel * ((int16)_km.delay_time)) / 25; + } if (_km.x < 0) { _km.x = 0; - _km.x_vel = -1; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; - } else if (_km.x > _km.x_max) { - _km.x = _km.x_max; - _km.x_vel = 1; + } else if (_km.x > _km.x_max * MULTIPLIER) { + _km.x = _km.x_max * MULTIPLIER; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } if (_km.y < 0) { _km.y = 0; - _km.y_vel = -1; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; - } else if (_km.y > _km.y_max) { - _km.y = _km.y_max; - _km.y_vel = 1; + } else if (_km.y > _km.y_max * MULTIPLIER) { + _km.y = _km.y_max * MULTIPLIER; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } if (_graphicsManager) { - _graphicsManager->getWindow()->warpMouseInWindow((Uint16)_km.x, (Uint16)_km.y); + _graphicsManager->getWindow()->warpMouseInWindow((Uint16)(_km.x / MULTIPLIER), (Uint16)(_km.y / MULTIPLIER)); + } + + if (_km.x != oldKmX || _km.y != oldKmY) { + // keep hi-res coordinates since + // processMouseEvent will overwrite them with lo-res numbers + oldKmX = _km.x; + oldKmY = _km.y; + event.type = Common::EVENT_MOUSEMOVE; + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); + _km.x = oldKmX; + _km.y = oldKmY; + return true; } } } + return false; } void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) { @@ -425,7 +458,6 @@ Common::KeyCode SdlEventSource::SDLToOSystemKeycode(const SDLKey key) { } bool SdlEventSource::pollEvent(Common::Event &event) { - handleKbdMouse(); #if SDL_VERSION_ATLEAST(2, 0, 0) // In case we still need to send a key up event for a key down from a @@ -451,6 +483,12 @@ bool SdlEventSource::pollEvent(Common::Event &event) { if (dispatchSDLEvent(ev, event)) return true; } + + // Handle mouse control via analog joystick and keyboard + if (handleKbdMouse(event)) { + return true; + } + return false; } @@ -485,7 +523,7 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) { // with a mouse wheel event. However, SDL2 does not supply // these, thus we use whatever we got last time. It seems // these are always stored in _km.x, _km.y. - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); if (yDir < 0) { event.type = Common::EVENT_WHEELDOWN; return true; @@ -712,10 +750,10 @@ bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { if (ev.jbutton.button == JOY_BUT_LMOUSE) { event.type = Common::EVENT_LBUTTONDOWN; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); } else if (ev.jbutton.button == JOY_BUT_RMOUSE) { event.type = Common::EVENT_RBUTTONDOWN; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); } else { event.type = Common::EVENT_KEYDOWN; switch (ev.jbutton.button) { @@ -743,10 +781,10 @@ bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { if (ev.jbutton.button == JOY_BUT_LMOUSE) { event.type = Common::EVENT_LBUTTONUP; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); } else if (ev.jbutton.button == JOY_BUT_RMOUSE) { event.type = Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); } else { event.type = Common::EVENT_KEYUP; switch (ev.jbutton.button) { @@ -772,23 +810,27 @@ bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { } bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) { + int axis = ev.jaxis.value; +#ifdef JOY_ANALOG + // conversion factor between keyboard mouse and joy axis value + int vel_to_axis = (1500 / MULTIPLIER); +#else if (axis > JOY_DEADZONE) { axis -= JOY_DEADZONE; - event.type = Common::EVENT_MOUSEMOVE; } else if (axis < -JOY_DEADZONE) { axis += JOY_DEADZONE; - event.type = Common::EVENT_MOUSEMOVE; } else axis = 0; +#endif if (ev.jaxis.axis == JOY_XAXIS) { #ifdef JOY_ANALOG - _km.x_vel = axis / 2000; + _km.x_vel = axis / vel_to_axis; _km.x_down_count = 0; #else if (axis != 0) { - _km.x_vel = (axis > 0) ? 1:-1; + _km.x_vel = (axis > 0) ? 1 * MULTIPLIER:-1 * MULTIPLIER; _km.x_down_count = 1; } else { _km.x_vel = 0; @@ -800,11 +842,11 @@ bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) { axis = -axis; #endif #ifdef JOY_ANALOG - _km.y_vel = -axis / 2000; + _km.y_vel = -axis / vel_to_axis; _km.y_down_count = 0; #else if (axis != 0) { - _km.y_vel = (-axis > 0) ? 1: -1; + _km.y_vel = (-axis > 0) ? 1 * MULTIPLIER: -1 * MULTIPLIER; _km.y_down_count = 1; } else { _km.y_vel = 0; @@ -812,10 +854,27 @@ bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) { } #endif } +#ifdef JOY_ANALOG + // radial and scaled analog joystick deadzone + float analogX = (float) (_km.x_vel * vel_to_axis); + float analogY = (float) (_km.y_vel * vel_to_axis); + float deadZone = (float) JOY_DEADZONE; + float scalingFactor = 1.0f; + float magnitude = 0.0f; + + magnitude = sqrt(analogX * analogX + analogY * analogY); + + if (magnitude >= deadZone) { + scalingFactor = 1.0f / magnitude * (magnitude - deadZone) / (32769.0f - deadZone); + _km.x_vel = (int16) (analogX * scalingFactor * 32768.0f / vel_to_axis); + _km.y_vel = (int16) (analogY * scalingFactor * 32768.0f / vel_to_axis); + } else { + _km.y_vel = 0; + _km.x_vel = 0; + } +#endif - processMouseEvent(event, _km.x, _km.y); - - return true; + return false; } bool SdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { @@ -889,8 +948,9 @@ bool SdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { void SdlEventSource::resetKeyboardEmulation(int16 x_max, int16 y_max) { _km.x_max = x_max; _km.y_max = y_max; - _km.delay_time = 25; + _km.delay_time = 12; _km.last_time = 0; + _km.modifier = false; } bool SdlEventSource::handleResizeEvent(Common::Event &event, int w, int h) { diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h index c43699420b..334bf8acfc 100644 --- a/backends/events/sdl/sdl-events.h +++ b/backends/events/sdl/sdl-events.h @@ -28,6 +28,8 @@ #include "common/events.h" +// multiplier used to increase resolution for keyboard/joystick mouse +#define MULTIPLIER 16 /** * The SDL event source. @@ -60,6 +62,7 @@ protected: struct KbdMouse { int16 x, y, x_vel, y_vel, x_max, y_max, x_down_count, y_down_count; uint32 last_time, delay_time, x_down_time, y_down_time; + bool modifier; }; KbdMouse _km; @@ -106,7 +109,7 @@ protected: virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event); virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event); virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event); - virtual void handleKbdMouse(); + virtual bool handleKbdMouse(Common::Event &event); //@} diff --git a/backends/events/symbiansdl/symbiansdl-events.cpp b/backends/events/symbiansdl/symbiansdl-events.cpp index b0d2c25302..9272cbaf9d 100644 --- a/backends/events/symbiansdl/symbiansdl-events.cpp +++ b/backends/events/symbiansdl/symbiansdl-events.cpp @@ -56,76 +56,76 @@ bool SymbianSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { switch (loop) { case GUI::ACTION_UP: if (ev.type == SDL_KEYDOWN) { - _km.y_vel = -1; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 0; + _km.y_vel = 0 * MULTIPLIER; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; case GUI::ACTION_DOWN: if (ev.type == SDL_KEYDOWN) { - _km.y_vel = 1; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 0; + _km.y_vel = 0 * MULTIPLIER; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; case GUI::ACTION_LEFT: if (ev.type == SDL_KEYDOWN) { - _km.x_vel = -1; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 0; + _km.x_vel = 0 * MULTIPLIER; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; case GUI::ACTION_RIGHT: if (ev.type == SDL_KEYDOWN) { - _km.x_vel = 1; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 0; + _km.x_vel = 0 * MULTIPLIER; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; case GUI::ACTION_LEFTCLICK: event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP); - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; case GUI::ACTION_RIGHTCLICK: event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP); - processMouseEvent(event, _km.x, _km.y); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; case GUI::ACTION_ZONE: if (ev.type == SDL_KEYDOWN) { for (int i = 0; i < TOTAL_ZONES; i++) - if (_km.x >= _zones[i].x && _km.y >= _zones[i].y && - _km.x <= _zones[i].x + _zones[i].width && _km.y <= _zones[i].y + _zones[i].height + if ( (_km.x / MULTIPLIER) >= _zones[i].x && (_km.y / MULTIPLIER) >= _zones[i].y && + (_km.x / MULTIPLIER) <= _zones[i].x + _zones[i].width && (_km.y / MULTIPLIER <= _zones[i].y + _zones[i].height ) { - _mouseXZone[i] = _km.x; - _mouseYZone[i] = _km.y; + _mouseXZone[i] = _km.x / MULTIPLIER; + _mouseYZone[i] = _km.y / MULTIPLIER; break; } _currentZone++; diff --git a/backends/events/wincesdl/wincesdl-events.cpp b/backends/events/wincesdl/wincesdl-events.cpp index d3141ee50c..7001d5fec6 100644 --- a/backends/events/wincesdl/wincesdl-events.cpp +++ b/backends/events/wincesdl/wincesdl-events.cpp @@ -48,8 +48,8 @@ void WINCESdlEventSource::processMouseEvent(Common::Event &event, int x, int y) event.mouse.y = y; // Update the "keyboard mouse" coords - _km.x = event.mouse.x; - _km.y = event.mouse.y; + _km.x = event.mouse.x * MULTIPLIER; + _km.y = event.mouse.y * MULTIPLIER; // Adjust for the screen scaling if (_graphicsMan->_zoomDown) @@ -69,7 +69,9 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) { memset(&event, 0, sizeof(Common::Event)); - handleKbdMouse(); + if (handleKbdMouse(event) { + return true; + } // If the screen changed, send an Common::EVENT_SCREEN_CHANGED int screenID = _graphicsMan->getScreenChangeID(); diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp index 845fc524e1..58d5fa9e67 100644 --- a/engines/adl/adl.cpp +++ b/engines/adl/adl.cpp @@ -55,10 +55,11 @@ AdlEngine::AdlEngine(OSystem *syst, const AdlGameDescription *gd) : _dumpFile(nullptr), _display(nullptr), _graphics(nullptr), + _textMode(false), _isRestarting(false), _isRestoring(false), _isQuitting(false), - _skipOneCommand(false), + _abortScript(false), _gameDescription(gd), _console(nullptr), _messageIds(), @@ -911,10 +912,6 @@ byte AdlEngine::convertKey(uint16 ascii) const { } Common::String AdlEngine::getLine() { - // Original engine uses a global here, which isn't reset between - // calls and may not match actual mode - bool textMode = false; - while (1) { Common::String line = inputString(APPLECHAR('?')); @@ -922,8 +919,8 @@ Common::String AdlEngine::getLine() { return ""; if ((byte)line[0] == ('\r' | 0x80)) { - textMode = !textMode; - _display->setMode(textMode ? DISPLAY_MODE_TEXT : DISPLAY_MODE_MIXED); + _textMode = !_textMode; + _display->setMode(_textMode ? DISPLAY_MODE_TEXT : DISPLAY_MODE_MIXED); continue; } @@ -1320,20 +1317,18 @@ bool AdlEngine::doOneCommand(const Commands &commands, byte verb, byte noun) { Commands::const_iterator cmd; for (cmd = commands.begin(); cmd != commands.end(); ++cmd) { - - if (_skipOneCommand) { - _skipOneCommand = false; - continue; - } - ScriptEnv env(*cmd, _state.room, verb, noun); if (matchCommand(env)) { doActions(env); return true; } + + if (_abortScript) { + _abortScript = false; + return false; + } } - _skipOneCommand = false; return false; } @@ -1341,11 +1336,6 @@ void AdlEngine::doAllCommands(const Commands &commands, byte verb, byte noun) { Commands::const_iterator cmd; for (cmd = commands.begin(); cmd != commands.end(); ++cmd) { - if (_skipOneCommand) { - _skipOneCommand = false; - continue; - } - ScriptEnv env(*cmd, _state.room, verb, noun); if (matchCommand(env)) { doActions(env); @@ -1353,9 +1343,12 @@ void AdlEngine::doAllCommands(const Commands &commands, byte verb, byte noun) { if (_isRestarting) return; } - } - _skipOneCommand = false; + if (_abortScript) { + _abortScript = false; + return; + } + } } Common::String AdlEngine::toAscii(const Common::String &str) { diff --git a/engines/adl/adl.h b/engines/adl/adl.h index 3630cd69b9..d71d40816e 100644 --- a/engines/adl/adl.h +++ b/engines/adl/adl.h @@ -348,6 +348,7 @@ protected: Display *_display; GraphicsMan *_graphics; + bool _textMode; // Opcodes typedef Common::Functor1<ScriptEnv &, int> Opcode; @@ -391,7 +392,7 @@ protected: bool _isRestarting, _isRestoring, _isQuitting; bool _canSaveNow, _canRestoreNow; - bool _skipOneCommand; + bool _abortScript; const AdlGameDescription *_gameDescription; diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp index 9653e2e40b..272e7801e7 100644 --- a/engines/adl/adl_v2.cpp +++ b/engines/adl/adl_v2.cpp @@ -37,6 +37,7 @@ AdlEngine_v2::~AdlEngine_v2() { AdlEngine_v2::AdlEngine_v2(OSystem *syst, const AdlGameDescription *gd) : AdlEngine(syst, gd), _linesPrinted(0), + _maxLines(4), _disk(nullptr), _itemRemoved(false), _roomOnScreen(0), @@ -151,9 +152,11 @@ void AdlEngine_v2::checkTextOverflow(char c) { ++_linesPrinted; - if (_linesPrinted < 4) - return; + if (_linesPrinted >= _maxLines) + handleTextOverflow(); +} +void AdlEngine_v2::handleTextOverflow() { _linesPrinted = 0; _display->updateTextScreen(); bell(); diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h index f0af9eba22..5447974a2e 100644 --- a/engines/adl/adl_v2.h +++ b/engines/adl/adl_v2.h @@ -62,6 +62,7 @@ protected: int askForSlot(const Common::String &question); void checkTextOverflow(char c); + void handleTextOverflow(); int o2_isFirstTime(ScriptEnv &e); int o2_isRandomGT(ScriptEnv &e); @@ -85,7 +86,7 @@ protected: Common::String restoreInsert, restoreReplace; } _strings_v2; - uint _linesPrinted; + uint _linesPrinted, _maxLines; DiskImage *_disk; Common::Array<DataBlockPtr> _itemPics; bool _itemRemoved; diff --git a/engines/adl/adl_v4.cpp b/engines/adl/adl_v4.cpp index 8370bead6f..e8ee798199 100644 --- a/engines/adl/adl_v4.cpp +++ b/engines/adl/adl_v4.cpp @@ -127,7 +127,7 @@ void AdlEngine_v4::loadState(Common::ReadStream &stream) { if (size != expectedSize) error("Variable count mismatch (expected %i; found %i)", expectedSize, size); - for (uint i = getRegion(1).vars.size(); i < size; ++i) + for (uint i = getRegion(1).vars.size(); i < _state.vars.size(); ++i) _state.vars[i] = stream.readByte(); if (stream.err() || stream.eos()) @@ -238,6 +238,11 @@ void AdlEngine_v4::loadRegionInitDataOffsets(Common::ReadStream &stream, uint re } } +void AdlEngine_v4::initRoomState(RoomState &roomState) const { + roomState.picture = 1; + roomState.isFirstTime = 1; +} + void AdlEngine_v4::initRegions(const byte *roomsPerRegion, uint regions) { _state.regions.resize(regions); @@ -247,12 +252,8 @@ void AdlEngine_v4::initRegions(const byte *roomsPerRegion, uint regions) { regn.vars.resize(24); regn.rooms.resize(roomsPerRegion[r]); - for (uint rm = 0; rm < roomsPerRegion[r]; ++rm) { - // TODO: hires6 uses 0xff and has slightly different - // code working on these values - regn.rooms[rm].picture = 1; - regn.rooms[rm].isFirstTime = 1; - } + for (uint rm = 0; rm < roomsPerRegion[r]; ++rm) + initRoomState(regn.rooms[rm]); } } @@ -395,13 +396,16 @@ void AdlEngine_v4::backupRoomState(byte room) { backup.picture = getRoom(room).picture; } -void AdlEngine_v4::restoreRoomState(byte room) { +byte AdlEngine_v4::restoreRoomState(byte room) { const RoomState &backup = getCurRegion().rooms[room - 1]; if (backup.isFirstTime != 1) { getRoom(room).curPicture = getRoom(room).picture = backup.picture; getRoom(room).isFirstTime = false; + return 0; } + + return 1; } void AdlEngine_v4::backupVars() { diff --git a/engines/adl/adl_v4.h b/engines/adl/adl_v4.h index 08cea21181..ca9aeff492 100644 --- a/engines/adl/adl_v4.h +++ b/engines/adl/adl_v4.h @@ -81,7 +81,8 @@ protected: void loadRegion(byte region); void loadItemPicIndex(Common::ReadStream &stream, uint items); void backupRoomState(byte room); - void restoreRoomState(byte room); + virtual void initRoomState(RoomState &roomState) const; + virtual byte restoreRoomState(byte room); void backupVars(); void restoreVars(); diff --git a/engines/adl/adl_v5.cpp b/engines/adl/adl_v5.cpp index 795899c070..929ffff7f4 100644 --- a/engines/adl/adl_v5.cpp +++ b/engines/adl/adl_v5.cpp @@ -33,6 +33,27 @@ AdlEngine_v5::AdlEngine_v5(OSystem *syst, const AdlGameDescription *gd) : AdlEngine_v4(syst, gd) { } +void AdlEngine_v5::initRoomState(RoomState &roomState) const { + roomState.picture = 0xff; + roomState.isFirstTime = 0xff; +} + +byte AdlEngine_v5::restoreRoomState(byte room) { + const RoomState &backup = getCurRegion().rooms[room - 1]; + + if (backup.isFirstTime != 0xff) { + getRoom(room).curPicture = getRoom(room).picture = backup.picture; + + // CHECKME: Why doesn't this just copy the flag unconditionally? + if (backup.isFirstTime != 1) { + getRoom(room).isFirstTime = false; + return 0; + } + } + + return backup.isFirstTime; +} + AdlEngine_v5::RegionChunkType AdlEngine_v5::getRegionChunkType(const uint16 addr) const { switch (addr) { case 0x7b00: @@ -44,75 +65,6 @@ AdlEngine_v5::RegionChunkType AdlEngine_v5::getRegionChunkType(const uint16 addr } } -typedef Common::Functor1Mem<ScriptEnv &, int, AdlEngine_v5> OpcodeV5; -#define SetOpcodeTable(x) table = &x; -#define Opcode(x) table->push_back(new OpcodeV5(this, &AdlEngine_v5::x)) -#define OpcodeUnImpl() table->push_back(new OpcodeV5(this, 0)) - -void AdlEngine_v5::setupOpcodeTables() { - Common::Array<const Opcode *> *table = 0; - - SetOpcodeTable(_condOpcodes); - // 0x00 - OpcodeUnImpl(); - Opcode(o2_isFirstTime); - Opcode(o2_isRandomGT); - Opcode(o4_isItemInRoom); - // 0x04 - Opcode(o5_isNounNotInRoom); - Opcode(o1_isMovesGT); - Opcode(o1_isVarEQ); - Opcode(o2_isCarryingSomething); - // 0x08 - Opcode(o4_isVarGT); - Opcode(o1_isCurPicEQ); - Opcode(o5_skipOneCommand); - - SetOpcodeTable(_actOpcodes); - // 0x00 - OpcodeUnImpl(); - Opcode(o1_varAdd); - Opcode(o1_varSub); - Opcode(o1_varSet); - // 0x04 - Opcode(o1_listInv); - Opcode(o4_moveItem); - Opcode(o1_setRoom); - Opcode(o2_setCurPic); - // 0x08 - Opcode(o2_setPic); - Opcode(o1_printMsg); - Opcode(o5_dummy); - Opcode(o5_setTextMode); - // 0x0c - Opcode(o2_moveAllItems); - Opcode(o1_quit); - Opcode(o5_dummy); - Opcode(o2_save); - // 0x10 - Opcode(o2_restore); - Opcode(o1_restart); - Opcode(o5_setRegionRoom); - Opcode(o5_dummy); - // 0x14 - Opcode(o1_resetPic); - Opcode(o1_goDirection<IDI_DIR_NORTH>); - Opcode(o1_goDirection<IDI_DIR_SOUTH>); - Opcode(o1_goDirection<IDI_DIR_EAST>); - // 0x18 - Opcode(o1_goDirection<IDI_DIR_WEST>); - Opcode(o1_goDirection<IDI_DIR_UP>); - Opcode(o1_goDirection<IDI_DIR_DOWN>); - Opcode(o1_takeItem); - // 0x1c - Opcode(o1_dropItem); - Opcode(o1_setRoomPic); - Opcode(o_winGame); - OpcodeUnImpl(); - // 0x20 - Opcode(o2_initDisk); -} - int AdlEngine_v5::o5_isNounNotInRoom(ScriptEnv &e) { OP_DEBUG_1("\t&& NO_SUCH_ITEMS_IN_ROOM(%s)", itemRoomStr(e.arg(1)).c_str()); @@ -131,10 +83,10 @@ int AdlEngine_v5::o5_isNounNotInRoom(ScriptEnv &e) { return 1; } -int AdlEngine_v5::o5_skipOneCommand(ScriptEnv &e) { - OP_DEBUG_0("\t&& SKIP_ONE_COMMAND()"); +int AdlEngine_v5::o5_abortScript(ScriptEnv &e) { + OP_DEBUG_0("\t&& ABORT_SCRIPT()"); - _skipOneCommand = true; + _abortScript = true; setVar(2, 0); return -1; @@ -149,33 +101,54 @@ int AdlEngine_v5::o5_dummy(ScriptEnv &e) { int AdlEngine_v5::o5_setTextMode(ScriptEnv &e) { OP_DEBUG_1("\tSET_TEXT_MODE(%d)", e.arg(1)); - // TODO - // 1: 4-line mode - // 2: 24-line mode - switch (e.arg(1)) { + case 1: + if (_linesPrinted != 0) { + _display->printChar(APPLECHAR(' ')); + handleTextOverflow(); + _display->moveCursorTo(Common::Point(0, 23)); + _maxLines = 4; + } + return 1; + case 2: + _textMode = true; + _display->setMode(DISPLAY_MODE_TEXT); + _display->home(); + _maxLines = 24; + _linesPrinted = 0; + return 1; case 3: // We re-use the restarting flag here, to simulate a long jump _isRestarting = true; return -1; + default: + error("Invalid text mode %d", e.arg(1)); } - - return 1; } int AdlEngine_v5::o5_setRegionRoom(ScriptEnv &e) { OP_DEBUG_2("\tSET_REGION_ROOM(%d, %d)", e.arg(1), e.arg(2)); - // TODO - return 2; + getCurRoom().curPicture = getCurRoom().picture; + getCurRoom().isFirstTime = false; + switchRegion(e.arg(1)); + _state.room = e.arg(2); + restoreRoomState(_state.room); + return -1; } -int AdlEngine_v5::o_winGame(ScriptEnv &e) { - OP_DEBUG_0("\tWIN_GAME()"); +int AdlEngine_v5::o5_setRoomPic(ScriptEnv &e) { + const byte isFirstTime = restoreRoomState(e.arg(1)); - // TODO + // CHECKME: More peculiar isFirstTime handling (see also restoreRoomState). + // Is this here to prevent changing the backed up flag from 1 to 0? Since + // that could only happen if the room isFirstTime is 0 while the backed up flag + // is 1, is this scenario even possible? + if (isFirstTime != 0xff) + getRoom(e.arg(1)).isFirstTime = isFirstTime; - return 0; + o4_setRoomPic(e); + return 2; } } // End of namespace Adl diff --git a/engines/adl/adl_v5.h b/engines/adl/adl_v5.h index bb1cc3015a..473b244993 100644 --- a/engines/adl/adl_v5.h +++ b/engines/adl/adl_v5.h @@ -34,18 +34,17 @@ public: protected: AdlEngine_v5(OSystem *syst, const AdlGameDescription *gd); - // AdlEngine - virtual void setupOpcodeTables(); - // AdlEngine_v4 virtual RegionChunkType getRegionChunkType(const uint16 addr) const; + virtual void initRoomState(RoomState &roomState) const; + virtual byte restoreRoomState(byte room); int o5_isNounNotInRoom(ScriptEnv &e); - int o5_skipOneCommand(ScriptEnv &e); + int o5_abortScript(ScriptEnv &e); int o5_dummy(ScriptEnv &e); int o5_setTextMode(ScriptEnv &e); int o5_setRegionRoom(ScriptEnv &e); - int o_winGame(ScriptEnv &e); + int o5_setRoomPic(ScriptEnv &e); }; } // End of namespace Adl diff --git a/engines/adl/detection.cpp b/engines/adl/detection.cpp index 66bbe84ea2..02fadd255b 100644 --- a/engines/adl/detection.cpp +++ b/engines/adl/detection.cpp @@ -141,6 +141,21 @@ static const AdlGameDescription gameDescriptions[] = { }, GAME_TYPE_HIRES0 }, + { // Hi-Res Adventure #4: Ulysses and the Golden Fleece - Apple II - Load 'N' Go + { + "hires4", 0, + { + { "ULYSSESA.DSK", 0, "df21f28ae94440f958dbbcfdfaf0c36e", 143360 }, + { "ULYSSESB.DSK", 1, "c204e8fe265e9534049f3c0f816cc9fc", 143360 }, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformApple2, + ADGF_UNSTABLE, + GUIO2(GAMEOPTION_COLOR_DEFAULT_ON, GAMEOPTION_SCANLINES) + }, + GAME_TYPE_HIRES4 + }, { // Hi-Res Adventure #4: Ulysses and the Golden Fleece - Atari 8-bit - Re-release { "hires4", 0, diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp index 91ab16313b..b3b66f6873 100644 --- a/engines/adl/hires6.cpp +++ b/engines/adl/hires6.cpp @@ -44,22 +44,162 @@ public: private: // AdlEngine + void gameLoop(); + void setupOpcodeTables(); void runIntro(); void init(); void initGameState(); void showRoom(); Common::String formatVerbError(const Common::String &verb) const; Common::String formatNounError(const Common::String &verb, const Common::String &noun) const; + void loadState(Common::ReadStream &stream); + void saveState(Common::WriteStream &stream); // AdlEngine_v2 void printString(const Common::String &str); + template <Direction D> + int o_goDirection(ScriptEnv &e); + int o_fluteSound(ScriptEnv &e); + static const uint kRegions = 3; static const uint kItems = 15; byte _currVerb, _currNoun; }; +void HiRes6Engine::gameLoop() { + AdlEngine_v5::gameLoop(); + + // Variable 25 starts at 5 and counts down every 160 moves. + // When it reaches 0, the game ends. This variable determines + // what you see when you "LOOK SUNS". + // Variable 39 is used to advance the suns based on game events, + // so even a fast player will see the suns getting closer together + // as he progresses. + if (getVar(39) != 0) { + if (getVar(39) < getVar(25)) + setVar(25, getVar(39)); + setVar(39, 0); + } + + if (getVar(25) != 0) { + if (getVar(25) > 5) + error("Variable 25 has unexpected value %d", getVar(25)); + if ((6 - getVar(25)) * 160 == _state.moves) + setVar(25, getVar(25) - 1); + } +} + +typedef Common::Functor1Mem<ScriptEnv &, int, HiRes6Engine> OpcodeH6; +#define SetOpcodeTable(x) table = &x; +#define Opcode(x) table->push_back(new OpcodeH6(this, &HiRes6Engine::x)) +#define OpcodeUnImpl() table->push_back(new OpcodeH6(this, 0)) + +void HiRes6Engine::setupOpcodeTables() { + Common::Array<const Opcode *> *table = 0; + + SetOpcodeTable(_condOpcodes); + // 0x00 + OpcodeUnImpl(); + Opcode(o2_isFirstTime); + Opcode(o2_isRandomGT); + Opcode(o4_isItemInRoom); + // 0x04 + Opcode(o5_isNounNotInRoom); + Opcode(o1_isMovesGT); + Opcode(o1_isVarEQ); + Opcode(o2_isCarryingSomething); + // 0x08 + Opcode(o4_isVarGT); + Opcode(o1_isCurPicEQ); + Opcode(o5_abortScript); + + SetOpcodeTable(_actOpcodes); + // 0x00 + OpcodeUnImpl(); + Opcode(o1_varAdd); + Opcode(o1_varSub); + Opcode(o1_varSet); + // 0x04 + Opcode(o1_listInv); + Opcode(o4_moveItem); + Opcode(o1_setRoom); + Opcode(o2_setCurPic); + // 0x08 + Opcode(o2_setPic); + Opcode(o1_printMsg); + Opcode(o5_dummy); + Opcode(o5_setTextMode); + // 0x0c + Opcode(o4_moveAllItems); + Opcode(o1_quit); + Opcode(o5_dummy); + Opcode(o4_save); + // 0x10 + Opcode(o4_restore); + Opcode(o1_restart); + Opcode(o5_setRegionRoom); + Opcode(o5_dummy); + // 0x14 + Opcode(o1_resetPic); + Opcode(o_goDirection<IDI_DIR_NORTH>); + Opcode(o_goDirection<IDI_DIR_SOUTH>); + Opcode(o_goDirection<IDI_DIR_EAST>); + // 0x18 + Opcode(o_goDirection<IDI_DIR_WEST>); + Opcode(o_goDirection<IDI_DIR_UP>); + Opcode(o_goDirection<IDI_DIR_DOWN>); + Opcode(o1_takeItem); + // 0x1c + Opcode(o1_dropItem); + Opcode(o5_setRoomPic); + Opcode(o_fluteSound); + OpcodeUnImpl(); + // 0x20 + Opcode(o2_initDisk); +} + +template <Direction D> +int HiRes6Engine::o_goDirection(ScriptEnv &e) { + OP_DEBUG_0((Common::String("\tGO_") + dirStr(D) + "()").c_str()); + + byte room = getCurRoom().connections[D]; + + if (room == 0) { + if (getVar(33) == 2) + setVar(34, getVar(34) + 1); + + printMessage(_messageIds.cantGoThere); + return -1; + } + + switchRoom(room); + + if (getVar(33) == 2) { + printMessage(102); + setVar(33, 0); + } + + return -1; +} + +int HiRes6Engine::o_fluteSound(ScriptEnv &e) { + OP_DEBUG_0("\tFLUTE_SOUND()"); + + Tones tones; + + tones.push_back(Tone(1072.0, 587.6)); + tones.push_back(Tone(1461.0, 495.8)); + tones.push_back(Tone(0.0, 1298.7)); + + playTones(tones, false); + + _linesPrinted = 0; + + return 0; +} + #define SECTORS_PER_TRACK 16 #define BYTES_PER_SECTOR 256 @@ -146,12 +286,9 @@ void HiRes6Engine::init() { _strings.lineFeeds = readStringAt(*stream, 0x408); - // Read opcode strings (TODO) _strings_v2.saveInsert = readStringAt(*stream, 0xad8); - readStringAt(*stream, 0xb95); // Confirm save - // _strings_v2.saveReplace + _strings_v2.saveReplace = readStringAt(*stream, 0xb95); _strings_v2.restoreInsert = readStringAt(*stream, 0xc07); - // _strings_v2.restoreReplace _strings.playAgain = readStringAt(*stream, 0xcdf, 0xff); _messageIds.cantGoThere = 249; @@ -275,10 +412,26 @@ Common::String HiRes6Engine::formatNounError(const Common::String &verb, const C return err; } +void HiRes6Engine::loadState(Common::ReadStream &stream) { + AdlEngine_v5::loadState(stream); + _state.moves = (getVar(39) << 8) | getVar(24); + setVar(39, 0); +} + +void HiRes6Engine::saveState(Common::WriteStream &stream) { + // Move counter is stuffed into variables, in order to save it + setVar(24, _state.moves & 0xff); + setVar(39, _state.moves >> 8); + AdlEngine_v5::saveState(stream); + setVar(39, 0); +} + void HiRes6Engine::printString(const Common::String &str) { Common::String s; uint found = 0; + // Variable 27 is 1 when Kira is present, 0 otherwise. It's used for choosing + // between singular and plural variants of a string. // This does not emulate the corner cases of the original, hence this check if (getVar(27) > 1) error("Invalid value %i encountered for variable 27", getVar(27)); @@ -294,21 +447,24 @@ void HiRes6Engine::printString(const Common::String &str) { } } - if (getVar(2) != 0xff) { - AdlEngine_v5::printString(s); - } else { + // Variables 2 and 26 are used for controlling the printing of room descriptions + if (getVar(2) == 0xff) { if (getVar(26) == 0) { + // This checks for special room description string " " if (str.size() != 1 || APPLECHAR(str[0]) != APPLECHAR(' ')) return AdlEngine_v5::printString(s); - setVar(2, APPLECHAR(' ')); - } else if (getVar(26) != 0xff) { - setVar(2, 'P'); - } else { + setVar(2, 160); + } else if (getVar(26) == 0xff) { + // Storing the room number in a variable allows for range comparisons setVar(26, _state.room); setVar(2, 1); + } else { + setVar(2, 80); } doAllCommands(_globalCommands, _currVerb, _currNoun); + } else { + AdlEngine_v5::printString(s); } } diff --git a/engines/adl/sound.cpp b/engines/adl/sound.cpp index 63eea45953..3d46ea0409 100644 --- a/engines/adl/sound.cpp +++ b/engines/adl/sound.cpp @@ -47,10 +47,9 @@ private: Speaker::Speaker(int sampleRate) : _rate(sampleRate), - _curSample(32767) { - - stopTone(); -} + _halfWaveLen(0), + _halfWaveRem(0), + _curSample(32767) { } void Speaker::startTone(double freq) { _halfWaveLen = _halfWaveRem = doubleToFrac(_rate / freq / 2); @@ -63,10 +62,15 @@ void Speaker::startTone(double freq) { void Speaker::stopTone() { _halfWaveLen = 0; - _halfWaveRem = intToFrac(32767); } void Speaker::generateSamples(int16 *buffer, int numSamples) { + if (_halfWaveLen == 0) { + // Silence + memset(buffer, 0, numSamples * sizeof(int16)); + return; + } + int offset = 0; while (offset < numSamples) { @@ -79,15 +83,14 @@ void Speaker::generateSamples(int16 *buffer, int numSamples) { // Compute next transition point _halfWaveRem += _halfWaveLen - FRAC_ONE; } else { - // Low/high level (incl. silence) + // Low/high level // Generate as many samples as we can const int samples = MIN(numSamples - offset, (int)fracToInt(_halfWaveRem)); Common::fill(buffer + offset, buffer + offset + samples, _curSample); offset += samples; - // Count down to level transition point, unless we're playing silence - if (_halfWaveLen > 0) - _halfWaveRem -= intToFrac(samples); + // Count down to level transition point + _halfWaveRem -= intToFrac(samples); } } } diff --git a/engines/cryo/eden.cpp b/engines/cryo/eden.cpp index b79eb4e984..a9476f8199 100644 --- a/engines/cryo/eden.cpp +++ b/engines/cryo/eden.cpp @@ -35,8 +35,6 @@ #include "graphics/screen.h" #include "graphics/palette.h" #include "common/timer.h" - -//#include "audio/audiostream.h" #include "audio/mixer.h" #include "cryo/defs.h" @@ -5334,7 +5332,7 @@ void EdenGame::save() { //SaveDialog(byte_37150, byte_37196->ff_A); //TODO strcpy(name, "edsave1.000"); - savegame(name); + saveGame(name); _vm->hideMouse(); CLBlitter_FillScreenView(0xFFFFFFFF); fadeToBlack(3); @@ -6369,55 +6367,126 @@ void EdenGame::phase560() { _gameRooms[127]._exits[1] = 0; } -void EdenGame::savegame(char *name) { - int32 size; - - Common::OutSaveFile *handle = g_system->getSavefileManager()->openForSaving(name); - if (!handle) +void EdenGame::saveGame(char *name) { + Common::OutSaveFile *fh = g_system->getSavefileManager()->openForSaving(name); + if (!fh) return; -#define CLFile_Write(h, ptr, size) \ -debug("writing 0x%X bytes", *size); \ -h->write(ptr, *size); + Common::Serializer s(nullptr, fh); - vavaoffsetout(); - size = (char *)(&_globals->_saveEnd) - (char *)(_globals); - CLFile_Write(handle, _globals, &size); - size = (char *)(&_gameIcons[134]) - (char *)(&_gameIcons[123]); - CLFile_Write(handle, &_gameIcons[123], &size); - lieuoffsetout(); - size = (char *)(&_areasTable[12]) - (char *)(&_areasTable[0]); - CLFile_Write(handle, &_areasTable[0], &size); - size = (char *)(&_gameRooms[423]) - (char *)(&_gameRooms[0]); - CLFile_Write(handle, &_gameRooms[0], &size); - size = (char *)(&_objects[42]) - (char *)(&_objects[0]); - CLFile_Write(handle, &_objects[0], &size); - size = (char *)(&_objectLocations[45]) - (char *)(&_objectLocations[0]); - CLFile_Write(handle, &_objectLocations[0], &size); - size = (char *)(&_followerList[14]) - (char *)(&_followerList[13]); - CLFile_Write(handle, &_followerList[13], &size); - size = (char *)(&_persons[PER_UNKN_3DE]) - (char *)(&_persons[PER_KING]); - CLFile_Write(handle, &_persons[PER_KING], &size); - bandeoffsetout(); - size = (char *)(&_tapes[16]) - (char *)(&_tapes[0]); - CLFile_Write(handle, &_tapes[0], &size); - size = (char *)(&_tabletView[6]) - (char *)(&_tabletView[0]); - CLFile_Write(handle, &_tabletView[0], &size); - size = (char *)(&_gameDialogs[10240]) - (char *)(&_gameDialogs[0]); //TODO: const size 10240 - CLFile_Write(handle, &_gameDialogs[0], &size); + syncGame(s); - delete handle; + delete fh; +} -#undef CLFile_Write +void EdenGame::syncGame(Common::Serializer s) { + syncGlobalPointers(s); + syncGlobalValues(s); - vavaoffsetin(); - lieuoffsetin(); - bandeoffsetin(); + // _gameIcons + // CHECKME: only from #123 to #133? + for (int i = 123; i < 134; i++) { + s.syncAsSint16LE(_gameIcons[i].sx); + s.syncAsSint16LE(_gameIcons[i].sy); + s.syncAsSint16LE(_gameIcons[i].ex); + s.syncAsSint16LE(_gameIcons[i].ey); + s.syncAsUint16LE(_gameIcons[i]._cursorId); + s.syncAsUint16LE(_gameIcons[i]._actionId); + s.syncAsUint16LE(_gameIcons[i]._objectId); + } + + syncCitadelRoomPointers(s); + + // _areasTable + for (int i = 0; i < 12; i++) { + s.syncAsByte(_areasTable[i]._num); + s.syncAsByte(_areasTable[i]._type); + s.syncAsUint16LE(_areasTable[i]._flags); + s.syncAsUint16LE(_areasTable[i]._firstRoomIdx); + s.syncAsByte(_areasTable[i]._citadelLevel); + s.syncAsByte(_areasTable[i]._placeNum); + s.syncAsSint16LE(_areasTable[i]._visitCount); + } + + // _gameRooms + for (int i = 0; i < 423; i++) { + s.syncAsByte(_gameRooms[i]._id); + for (int j = 0; j < 4; j++) + s.syncAsByte(_gameRooms[i]._exits[j]); + s.syncAsByte(_gameRooms[i]._flags); + s.syncAsUint16LE(_gameRooms[i]._bank); + s.syncAsUint16LE(_gameRooms[i]._party); + s.syncAsByte(_gameRooms[i]._level); + s.syncAsByte(_gameRooms[i]._video); + s.syncAsByte(_gameRooms[i]._location); + s.syncAsByte(_gameRooms[i]._backgroundBankNum); + } + + // _Objects + for (int i = 0; i < 42; i++) { + s.syncAsByte(_objects[i]._id); + s.syncAsByte(_objects[i]._flags); + s.syncAsSint16LE(_objects[i]._locations); + s.syncAsUint16LE(_objects[i]._itemMask); + s.syncAsUint16LE(_objects[i]._powerMask); + s.syncAsSint16LE(_objects[i]._count); + } + + for (int i = 0; i < 45; i++) + s.syncAsUint16LE(_objectLocations[i]); + + // _followerList[13] + // CHECKME: Only #13? + s.syncAsByte(_followerList[13]._id); + s.syncAsByte(_followerList[13]._spriteNum); + s.syncAsSint16LE(_followerList[13].sx); + s.syncAsSint16LE(_followerList[13].sy); + s.syncAsSint16LE(_followerList[13].ex); + s.syncAsSint16LE(_followerList[13].ey); + s.syncAsSint16LE(_followerList[13]._spriteBank); + s.syncAsSint16LE(_followerList[13].ff_C); + s.syncAsSint16LE(_followerList[13].ff_E); + + // _persons + for (int i = 0; i < 58; i++) { + s.syncAsUint16LE(_persons[i]._roomNum); + s.syncAsUint16LE(_persons[i]._actionId); + s.syncAsUint16LE(_persons[i]._partyMask); + s.syncAsByte(_persons[i]._id); + s.syncAsByte(_persons[i]._flags); + s.syncAsByte(_persons[i]._roomBankId); + s.syncAsByte(_persons[i]._spriteBank); + s.syncAsUint16LE(_persons[i]._items); + s.syncAsUint16LE(_persons[i]._powers); + s.syncAsByte(_persons[i]._targetLoc); + s.syncAsByte(_persons[i]._lastLoc); + s.syncAsByte(_persons[i]._speed); + s.syncAsByte(_persons[i]._steps); + } + + syncTapePointers(s); + + // _tapes + for (int i = 0; i < MAX_TAPES; i++) { + s.syncAsSint16LE(_tapes[i]._textNum); + s.syncAsSint16LE(_tapes[i]._party); + s.syncAsSint16LE(_tapes[i]._roomNum); + s.syncAsSint16LE(_tapes[i]._backgroundBankNum); + } + + // _tabletView + // CHECKME: Only 6 out of 12? + for (int i = 0; i < 6; i++) + s.syncAsByte(_tabletView[i]); - debug("* Game saved to %s", name); + // _gameDialogs + for (int i = 0; i < 10240; i++) + s.syncAsByte(_gameDialogs[i]); } void EdenGame::loadrestart() { + _quitFlag3 = true; +/* assert(0); //TODO: this won't work atm - all snapshots are BE int32 offs = 0; int32 size; @@ -6457,112 +6526,270 @@ void EdenGame::loadrestart() { size = (char *)(&_gameDialogs[10240]) - (char *)(&_gameDialogs[0]); //TODO: const size 10240 loadpartoffile(2495, &_gameDialogs[0], offs, size); _gameLoaded = true; + */ } void EdenGame::loadgame(char *name) { - Common::InSaveFile *handle = g_system->getSavefileManager()->openForLoading(name); - if (!handle) + Common::InSaveFile *fh = g_system->getSavefileManager()->openForLoading(name); + if (!fh) return; -#define CLFile_Read(h, ptr, size) \ - h->read(ptr, *size); - - int32 size = (char *)(&_globals->_saveEnd) - (char *)(_globals); - CLFile_Read(handle, _globals, &size); - vavaoffsetin(); - size = (char *)(&_gameIcons[134]) - (char *)(&_gameIcons[123]); - CLFile_Read(handle, &_gameIcons[123], &size); - size = (char *)(&_areasTable[12]) - (char *)(&_areasTable[0]); - CLFile_Read(handle, &_areasTable[0], &size); - lieuoffsetin(); - size = (char *)(&_gameRooms[423]) - (char *)(&_gameRooms[0]); - CLFile_Read(handle, &_gameRooms[0], &size); - size = (char *)(&_objects[42]) - (char *)(&_objects[0]); - CLFile_Read(handle, &_objects[0], &size); - size = (char *)(&_objectLocations[45]) - (char *)(&_objectLocations[0]); - CLFile_Read(handle, &_objectLocations[0], &size); - size = (char *)(&_followerList[14]) - (char *)(&_followerList[13]); - CLFile_Read(handle, &_followerList[13], &size); - size = (char *)(&_persons[55]) - (char *)(&_persons[0]); - CLFile_Read(handle, &_persons[0], &size); - size = (char *)(&_tapes[16]) - (char *)(&_tapes[0]); - CLFile_Read(handle, &_tapes[0], &size); - bandeoffsetin(); - size = (char *)(&_tabletView[6]) - (char *)(&_tabletView[0]); - CLFile_Read(handle, &_tabletView[0], &size); - size = (char *)(&_gameDialogs[10240]) - (char *)(&_gameDialogs[0]); //TODO: const size 10240 - CLFile_Read(handle, &_gameDialogs[0], &size); - - delete handle; -#undef CLFile_Read + Common::Serializer s(fh, nullptr); + syncGame(s); -// CLFile_Close(handle); + delete fh; _gameLoaded = true; - debug("* Game loaded from %s", name); } -#define NULLPTR (void*)0xFFFFFF -#define OFSOUT(val, base, typ) if (val) (val) = (typ*)((char*)(val) - (size_t)(base)); else (val) = (typ*)NULLPTR; +#define NULLPTR 0xFFFFFF +#define IDXOUT(val, base, typ, idx) if (val) (idx) = ((byte*)val - (byte*)base) / sizeof(typ); else (idx) = NULLPTR; #define OFSIN(val, base, typ) if ((void*)(val) != NULLPTR) (val) = (typ*)((char*)(val) + (size_t)(base)); else (val) = 0; -void EdenGame::vavaoffsetout() { - OFSOUT(_globals->_dialogPtr, _gameDialogs, Dialog); - OFSOUT(_globals->_nextDialogPtr, _gameDialogs, Dialog); - OFSOUT(_globals->_narratorDialogPtr, _gameDialogs, Dialog); - OFSOUT(_globals->_lastDialogPtr, _gameDialogs, Dialog); - OFSOUT(_globals->_tapePtr, _tapes, tape_t); - OFSOUT(_globals->_nextRoomIcon, _gameIcons, Icon); - OFSOUT(_globals->_roomPtr, _gameRooms, Room); - OFSOUT(_globals->_citaAreaFirstRoom, _gameRooms, Room); - OFSOUT(_globals->_areaPtr, _areasTable, Area); - OFSOUT(_globals->_lastAreaPtr, _areasTable, Area); - OFSOUT(_globals->_curAreaPtr, _areasTable, Area); - OFSOUT(_globals->_characterPtr, _persons, perso_t); - OFSOUT(_globals->_roomCharacterPtr, _persons, perso_t); -} - -void EdenGame::vavaoffsetin() { - OFSIN(_globals->_dialogPtr, _gameDialogs, Dialog); - OFSIN(_globals->_nextDialogPtr, _gameDialogs, Dialog); - OFSIN(_globals->_narratorDialogPtr, _gameDialogs, Dialog); - OFSIN(_globals->_lastDialogPtr, _gameDialogs, Dialog); - OFSIN(_globals->_tapePtr, _tapes, tape_t); - OFSIN(_globals->_nextRoomIcon, _gameIcons, Icon); - OFSIN(_globals->_roomPtr, _gameRooms, Room); - OFSIN(_globals->_citaAreaFirstRoom, _gameRooms, Room); - OFSIN(_globals->_areaPtr, _areasTable, Area); - OFSIN(_globals->_lastAreaPtr, _areasTable, Area); - OFSIN(_globals->_curAreaPtr, _areasTable, Area); - OFSIN(_globals->_characterPtr, _persons, perso_t); - OFSIN(_globals->_roomCharacterPtr, _persons, perso_t); -} - -void EdenGame::lieuoffsetout() { - for (int i = 0; i < 12; i++) - OFSOUT(_areasTable[i]._citadelRoomPtr, _gameRooms, Room); -} - -void EdenGame::lieuoffsetin() { - for (int i = 0; i < 12; i++) - OFSIN(_areasTable[i]._citadelRoomPtr, _gameRooms, Room); -} - -void EdenGame::bandeoffsetout() { - for (int i = 0; i < 16; i++) { - OFSOUT(_tapes[i]._perso, _persons, perso_t); - OFSOUT(_tapes[i]._dialog, _gameDialogs, Dialog); - } -} +void EdenGame::syncGlobalPointers(Common::Serializer s) { + uint32 dialogIdx, nextDialogIdx, narratorDialogIdx, lastDialogIdx, tapeIdx, nextRoomIconIdx, roomIdx; + uint32 citaAreaFirstRoomIdx, areaIdx, lastAreaIdx, curAreaIdx, characterIdx, roomCharacterIdx; + + if (s.isSaving()) { + IDXOUT(_globals->_dialogPtr, _gameDialogs, Dialog, dialogIdx); + IDXOUT(_globals->_nextDialogPtr, _gameDialogs, Dialog, nextDialogIdx); + IDXOUT(_globals->_narratorDialogPtr, _gameDialogs, Dialog, narratorDialogIdx); + IDXOUT(_globals->_lastDialogPtr, _gameDialogs, Dialog, lastDialogIdx); + IDXOUT(_globals->_tapePtr, _tapes, tape_t, tapeIdx); + IDXOUT(_globals->_nextRoomIcon, _gameIcons, Icon, nextRoomIconIdx); + IDXOUT(_globals->_roomPtr, _gameRooms, Room, roomIdx); + IDXOUT(_globals->_citaAreaFirstRoom, _gameRooms, Room, citaAreaFirstRoomIdx); + IDXOUT(_globals->_areaPtr, _areasTable, Area, areaIdx); + IDXOUT(_globals->_lastAreaPtr, _areasTable, Area, lastAreaIdx); + IDXOUT(_globals->_curAreaPtr, _areasTable, Area, curAreaIdx); + IDXOUT(_globals->_characterPtr, _persons, perso_t, characterIdx); + IDXOUT(_globals->_roomCharacterPtr, _persons, perso_t, roomCharacterIdx); + } + + s.syncAsUint32LE(dialogIdx); + s.syncAsUint32LE(nextDialogIdx); + s.syncAsUint32LE(narratorDialogIdx); + s.syncAsUint32LE(lastDialogIdx); + s.syncAsUint32LE(tapeIdx); + s.syncAsUint32LE(nextRoomIconIdx); + s.syncAsUint32LE(roomIdx); + s.syncAsUint32LE(citaAreaFirstRoomIdx); + s.syncAsUint32LE(areaIdx); + s.syncAsUint32LE(lastAreaIdx); + s.syncAsUint32LE(curAreaIdx); + s.syncAsUint32LE(characterIdx); + s.syncAsUint32LE(roomCharacterIdx); + + if (s.isLoading()) { + _globals->_dialogPtr = (dialogIdx == NULLPTR) ? nullptr : (Dialog *)getElem(_gameDialogs, dialogIdx); + _globals->_nextDialogPtr = (nextDialogIdx == NULLPTR) ? nullptr : (Dialog *)getElem(_gameDialogs, nextDialogIdx); + _globals->_narratorDialogPtr = (narratorDialogIdx == NULLPTR) ? nullptr : (Dialog *)getElem(_gameDialogs, narratorDialogIdx); + _globals->_lastDialogPtr = (lastDialogIdx == NULLPTR) ? nullptr : (Dialog *)getElem(_gameDialogs, lastDialogIdx); + _globals->_tapePtr = (tapeIdx == NULLPTR) ? nullptr : &_tapes[tapeIdx]; + _globals->_nextRoomIcon = (nextRoomIconIdx == NULLPTR) ? nullptr : &_gameIcons[nextRoomIconIdx]; + _globals->_roomPtr = (roomIdx == NULLPTR) ? nullptr : &_gameRooms[roomIdx]; + _globals->_citaAreaFirstRoom = (citaAreaFirstRoomIdx == NULLPTR) ? nullptr : &_gameRooms[citaAreaFirstRoomIdx]; + _globals->_areaPtr = (areaIdx == NULLPTR) ? nullptr : &_areasTable[areaIdx]; + _globals->_lastAreaPtr = (lastAreaIdx == NULLPTR) ? nullptr : &_areasTable[lastAreaIdx]; + _globals->_curAreaPtr = (curAreaIdx == NULLPTR) ? nullptr : &_areasTable[curAreaIdx]; + _globals->_characterPtr = (characterIdx == NULLPTR) ? nullptr : &_persons[characterIdx]; + _globals->_roomCharacterPtr = (roomCharacterIdx == NULLPTR) ? nullptr : &_persons[roomCharacterIdx]; + } +} + +void EdenGame::syncGlobalValues(Common::Serializer s) { + s.syncAsByte(_globals->_areaNum); + s.syncAsByte(_globals->_areaVisitCount); + s.syncAsByte(_globals->_menuItemIdLo); + s.syncAsByte(_globals->_menuItemIdHi); + s.syncAsUint16LE(_globals->_randomNumber); + s.syncAsUint16LE(_globals->_gameTime); + s.syncAsUint16LE(_globals->_gameDays); + s.syncAsUint16LE(_globals->_chrono); + s.syncAsUint16LE(_globals->_eloiDepartureDay); + s.syncAsUint16LE(_globals->_roomNum); + s.syncAsUint16LE(_globals->_newRoomNum); + s.syncAsUint16LE(_globals->_phaseNum); + s.syncAsUint16LE(_globals->_metPersonsMask1); + s.syncAsUint16LE(_globals->_party); + s.syncAsUint16LE(_globals->_partyOutside); + s.syncAsUint16LE(_globals->_metPersonsMask2); + s.syncAsUint16LE(_globals->_var1C); + s.syncAsUint16LE(_globals->_phaseActionsCount); + s.syncAsUint16LE(_globals->_curAreaFlags); + s.syncAsUint16LE(_globals->_curItemsMask); + s.syncAsUint16LE(_globals->_curPowersMask); + s.syncAsUint16LE(_globals->_curPersoItems); + s.syncAsUint16LE(_globals->_curCharacterPowers); + s.syncAsUint16LE(_globals->_wonItemsMask); + s.syncAsUint16LE(_globals->_wonPowersMask); + s.syncAsUint16LE(_globals->_stepsToFindAppleFast); + s.syncAsUint16LE(_globals->_stepsToFindAppleNormal); + s.syncAsUint16LE(_globals->_roomPersoItems); + s.syncAsUint16LE(_globals->_roomCharacterPowers); + s.syncAsUint16LE(_globals->_gameFlags); + s.syncAsUint16LE(_globals->_curVideoNum); + s.syncAsUint16LE(_globals->_morkusSpyVideoNum1); + s.syncAsUint16LE(_globals->_morkusSpyVideoNum2); + s.syncAsUint16LE(_globals->_morkusSpyVideoNum3); + s.syncAsUint16LE(_globals->_morkusSpyVideoNum4); + s.syncAsByte(_globals->_newMusicType); + s.syncAsByte(_globals->_var43); + s.syncAsByte(_globals->_videoSubtitleIndex); + s.syncAsByte(_globals->_partyInstruments); + s.syncAsByte(_globals->_monkGotRing); + s.syncAsByte(_globals->_chronoFlag); + s.syncAsByte(_globals->_curRoomFlags); + s.syncAsByte(_globals->_endGameFlag); + s.syncAsByte(_globals->_lastInfo); + + byte autoDialog; + if (s.isSaving()) + autoDialog = _globals->_autoDialog ? 1 : 0; + s.syncAsByte(autoDialog); + if (s.isLoading()) + _globals->_autoDialog = (autoDialog == 1); + + s.syncAsByte(_globals->_worldTyranSighted); + s.syncAsByte(_globals->_var4D); + s.syncAsByte(_globals->_var4E); + s.syncAsByte(_globals->_worldGaveGold); + s.syncAsByte(_globals->_worldHasTriceraptors); + s.syncAsByte(_globals->_worldHasVelociraptors); + s.syncAsByte(_globals->_worldHasTyran); + s.syncAsByte(_globals->_var53); + s.syncAsByte(_globals->_var54); + s.syncAsByte(_globals->_var55); + s.syncAsByte(_globals->_gameHours); + s.syncAsByte(_globals->_textToken1); + s.syncAsByte(_globals->_textToken2); + s.syncAsByte(_globals->_eloiHaveNews); + s.syncAsByte(_globals->_dialogFlags); + s.syncAsByte(_globals->_curAreaType); + s.syncAsByte(_globals->_curCitadelLevel); + s.syncAsByte(_globals->_newLocation); + s.syncAsByte(_globals->_prevLocation); + s.syncAsByte(_globals->_curPersoFlags); + s.syncAsByte(_globals->_var60); + s.syncAsByte(_globals->_eventType); + s.syncAsByte(_globals->_var62); + s.syncAsByte(_globals->_curObjectId); + s.syncAsByte(_globals->_curObjectFlags); + s.syncAsByte(_globals->_var65); + s.syncAsByte(_globals->_roomCharacterType); + s.syncAsByte(_globals->_roomCharacterFlags); + s.syncAsByte(_globals->_narratorSequence); + s.syncAsByte(_globals->_var69); + s.syncAsByte(_globals->_var6A); + s.syncAsByte(_globals->_frescoNumber); + s.syncAsByte(_globals->_var6C); + s.syncAsByte(_globals->_var6D); + s.syncAsByte(_globals->_labyrinthDirections); + s.syncAsByte(_globals->_labyrinthRoom); + +/* + CHECKME: *_sentenceBufferPtr +*/ + + s.syncAsByte(_globals->_lastInfoIdx); + s.syncAsByte(_globals->_nextInfoIdx); + +/* + CHECKME + * _persoSpritePtr + * _persoSpritePtr2 + * _curCharacterAnimPtr + * _varC2 +*/ + + s.syncAsSint16LE(_globals->_iconsIndex); + s.syncAsSint16LE(_globals->_curObjectCursor); + s.syncAsSint16LE(_globals->_varCA); + s.syncAsSint16LE(_globals->_varCC); + s.syncAsSint16LE(_globals->_characterImageBank); + s.syncAsUint16LE(_globals->_roomImgBank); + s.syncAsUint16LE(_globals->_characterBackgroundBankIdx); + s.syncAsUint16LE(_globals->_varD4); + s.syncAsUint16LE(_globals->_frescoeWidth); + s.syncAsUint16LE(_globals->_frescoeImgBank); + s.syncAsUint16LE(_globals->_varDA); + s.syncAsUint16LE(_globals->_varDC); + s.syncAsUint16LE(_globals->_roomBaseX); + s.syncAsUint16LE(_globals->_varE0); + s.syncAsUint16LE(_globals->_dialogType); + s.syncAsUint16LE(_globals->_varE4); + s.syncAsUint16LE(_globals->_currMusicNum); + s.syncAsSint16LE(_globals->_textNum); + s.syncAsUint16LE(_globals->_travelTime); + s.syncAsUint16LE(_globals->_varEC); + s.syncAsByte(_globals->_displayFlags); + s.syncAsByte(_globals->_oldDisplayFlags); + s.syncAsByte(_globals->_drawFlags); + s.syncAsByte(_globals->_varF1); + s.syncAsByte(_globals->_varF2); + s.syncAsByte(_globals->_menuFlags); + s.syncAsByte(_globals->_varF4); + s.syncAsByte(_globals->_varF5); + s.syncAsByte(_globals->_varF6); + s.syncAsByte(_globals->_varF7); + s.syncAsByte(_globals->_varF8); + s.syncAsByte(_globals->_varF9); + s.syncAsByte(_globals->_varFA); + s.syncAsByte(_globals->_animationFlags); + s.syncAsByte(_globals->_giveObj1); + s.syncAsByte(_globals->_giveObj2); + s.syncAsByte(_globals->_giveObj3); + s.syncAsByte(_globals->_var100); + s.syncAsByte(_globals->_roomVidNum); + s.syncAsByte(_globals->_mirrorEffect); + s.syncAsByte(_globals->_var103); + s.syncAsByte(_globals->_roomBackgroundBankNum); + s.syncAsByte(_globals->_valleyVidNum); + s.syncAsByte(_globals->_updatePaletteFlag); + s.syncAsByte(_globals->_inventoryScrollPos); + s.syncAsByte(_globals->_objCount); + s.syncAsByte(_globals->_textBankIndex); + s.syncAsByte(_globals->_prefLanguage); + for (int i = 0; i < 2; i++) { + s.syncAsByte(_globals->_prefMusicVol[i]); + s.syncAsByte(_globals->_prefVoiceVol[i]); + s.syncAsByte(_globals->_prefSoundVolume[i]); + } + s.syncAsByte(_globals->_citadelAreaNum); + s.syncAsByte(_globals->_var113); + s.syncAsByte(_globals->_lastPlaceNum); + s.syncAsByte(_globals->_saveEnd); +} + +void EdenGame::syncCitadelRoomPointers(Common::Serializer s) { + uint32 citadelRoomIdx; + for (int i = 0; i < 12; i++) { + if (s.isSaving()) + IDXOUT(_areasTable[i]._citadelRoomPtr, _gameRooms, Room, citadelRoomIdx); + s.syncAsUint32LE(citadelRoomIdx); + if (s.isLoading()) + _areasTable[i]._citadelRoomPtr = (citadelRoomIdx == NULLPTR) ? nullptr : &_gameRooms[citadelRoomIdx]; + } +} + +void EdenGame::syncTapePointers(Common::Serializer s) { + int persoIdx, dialogIdx; -void EdenGame::bandeoffsetin() { for (int i = 0; i < 16; i++) { - OFSIN(_tapes[i]._perso, _persons, perso_t); - OFSIN(_tapes[i]._dialog, _gameDialogs, Dialog); + if (s.isSaving()) { + IDXOUT(_tapes[i]._perso, _persons, perso_t, persoIdx); + IDXOUT(_tapes[i]._dialog, _gameDialogs, Dialog, dialogIdx); + } + + s.syncAsUint32LE(persoIdx); + s.syncAsUint32LE(dialogIdx); + + if (s.isLoading()) { + _tapes[i]._perso = (persoIdx == NULLPTR) ? nullptr : &_persons[persoIdx]; + _tapes[i]._dialog = (dialogIdx == NULLPTR) ? nullptr : (Dialog *)getElem(_gameDialogs, dialogIdx); + } } } -//// cond.c - char EdenGame::testCondition(int16 index) { bool endFl = false; uint16 stack[32]; diff --git a/engines/cryo/eden.h b/engines/cryo/eden.h index bdd1ba89ce..1fd5415163 100644 --- a/engines/cryo/eden.h +++ b/engines/cryo/eden.h @@ -24,6 +24,8 @@ #define CRYO_EDEN_H #include "common/file.h" +#include "common/savefile.h" +#include "common/serializer.h" #include "cryo/sound.h" #include "cryo/defs.h" @@ -461,15 +463,14 @@ private: void phase528(); void phase544(); void phase560(); - void savegame(char *name); + void saveGame(char *name); void loadrestart(); void loadgame(char *name); - void vavaoffsetout(); - void vavaoffsetin(); - void lieuoffsetout(); - void lieuoffsetin(); - void bandeoffsetout(); - void bandeoffsetin(); + void syncGame(Common::Serializer s); + void syncGlobalPointers(Common::Serializer s); + void syncGlobalValues(Common::Serializer s); + void syncCitadelRoomPointers(Common::Serializer s); + void syncTapePointers(Common::Serializer s); char testCondition(int16 index); uint16 operAdd(uint16 v1, uint16 v2); uint16 operSub(uint16 v1, uint16 v2); diff --git a/engines/director/archive.cpp b/engines/director/archive.cpp index c9b6cc1cfa..f426107ee3 100644 --- a/engines/director/archive.cpp +++ b/engines/director/archive.cpp @@ -441,14 +441,13 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff debugCN(2, kDebugLoading, "CAS*: %d [", casSize); for (uint i = 0; i < casSize; i++) { - uint32 index = casStream.readUint32(); + uint32 index = casStream.readUint32BE(); + debugCN(2, kDebugLoading, "%d ", index); Resource &res = resources[index]; res.index = index; res.castId = i + 1; _types[castTag][res.castId] = res; - - debugCN(2, kDebugLoading, "%d ", index); } debugC(2, kDebugLoading, "]"); } diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp index 8b1e57cf18..ed5b05643c 100644 --- a/engines/director/cast.cpp +++ b/engines/director/cast.cpp @@ -95,7 +95,9 @@ TextCast::TextCast(Common::ReadStreamEndian &stream, uint16 version) { palinfo3 = stream.readUint16(); int t = stream.readUint32(); - assert(t == 0); // So far we saw only 0 here + if (t != 0) { // In D2 there are values + warning("TextCast: t: %x", t); + } initialRect = Score::readRect(stream); textShadow = static_cast<SizeType>(stream.readByte()); diff --git a/engines/director/detection.cpp b/engines/director/detection.cpp index c26084ac6c..43c5bf2b4f 100644 --- a/engines/director/detection.cpp +++ b/engines/director/detection.cpp @@ -78,6 +78,7 @@ static const PlainGameDescriptor directorGames[] = { { "jewels", "Jewels of the Oracle" }, { "jman", "The Journeyman Project" }, { "majestic", "Majestic Part I: Alien Encounter" }, + { "mediaband", "Meet Mediaband" }, { "melements", "Masters of the Elements" }, { "spyclub", "Spy Club" }, { "amber", "AMBER: Journeys Beyond"}, diff --git a/engines/director/detection_tables.h b/engines/director/detection_tables.h index 15bdf37968..11f70e033c 100644 --- a/engines/director/detection_tables.h +++ b/engines/director/detection_tables.h @@ -69,8 +69,21 @@ static const DirectorGameDescription gameDescriptions[] = { { { "theapartment", + "D2", + AD_ENTRY1s("Main Menu", "fc56c179cb8c6d4938e61ee61fd0032c", 48325), // Original name is "âĸMain Menu" + Common::EN_ANY, + Common::kPlatformMacintosh, + ADGF_MACRESFORK, + GUIO1(GUIO_NOASPECT) + }, + GID_GENERIC, + 2 + }, + { + { + "theapartment", "D3", - AD_ENTRY1s("Main Menu", "9e838fe1a6af7992d656ca325e38dee5", 47911), + AD_ENTRY1s("Main Menu", "9e838fe1a6af7992d656ca325e38dee5", 47911), // Original name is "âĸMain Menu" Common::EN_ANY, Common::kPlatformMacintosh, ADGF_MACRESFORK, @@ -83,7 +96,7 @@ static const DirectorGameDescription gameDescriptions[] = { { "theapartment", "D4", - AD_ENTRY1s("Main Menu", "ff86181f03fe6eb060f65a985ca0580d", 160612), + AD_ENTRY1s("Main Menu", "ff86181f03fe6eb060f65a985ca0580d", 160612),// Original name is "âĸMain Menu" Common::EN_ANY, Common::kPlatformMacintosh, ADGF_NO_FLAGS, @@ -291,6 +304,20 @@ static const DirectorGameDescription gameDescriptions[] = { 4 }, + { // Meet Mediaband + { + "mediaband", + "", + AD_ENTRY1s("MEDIABND.EXE", "0cfb9b4762e33ab56d656a0eb146a048", 717921), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO1(GUIO_NOASPECT) + }, + GID_GENERIC, + 4 + }, + { { // Masters of the Elements - English (from rootfather) diff --git a/engines/director/director.cpp b/engines/director/director.cpp index 4806b57cdf..bfe9a724be 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -42,9 +42,11 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam _rnd("director") { DebugMan.addDebugChannel(kDebugLingoExec, "lingoexec", "Lingo Execution"); DebugMan.addDebugChannel(kDebugLingoCompile, "lingocompile", "Lingo Compilation"); + DebugMan.addDebugChannel(kDebugLingoParse, "lingoparse", "Lingo code parsing"); DebugMan.addDebugChannel(kDebugLoading, "loading", "Loading"); DebugMan.addDebugChannel(kDebugImages, "images", "Image drawing"); DebugMan.addDebugChannel(kDebugText, "text", "Text rendering"); + DebugMan.addDebugChannel(kDebugEvents, "events", "Event processing"); g_director = this; @@ -83,12 +85,14 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam const Common::FSNode gameDataDir(ConfMan.get("path")); SearchMan.addSubDirectoryMatching(gameDataDir, "data"); SearchMan.addSubDirectoryMatching(gameDataDir, "install"); + SearchMan.addSubDirectoryMatching(gameDataDir, "main"); // Meet Mediaband _colorDepth = 8; // 256-color _key = 0; _keyCode = 0; _machineType = 9; // Macintosh IIci _playbackPaused = false; + g_director->_skipFrameAdvance = false; } DirectorEngine::~DirectorEngine() { @@ -136,13 +140,14 @@ Common::Error DirectorEngine::run() { //_mainArchive = new RIFFArchive(); //_mainArchive->openFile("bookshelf_example.mmm"); - if (getPlatform() == Common::kPlatformWindows) { - _sharedCastFile = "SHARDCST.MMM"; - } else { - if (getVersion() < 4) + if (getVersion() < 4) { + if (getPlatform() == Common::kPlatformWindows) { + _sharedCastFile = "SHARDCST.MMM"; + } else { _sharedCastFile = "Shared Cast"; - else - _sharedCastFile = "Shared.dir"; + } + } else { + _sharedCastFile = "Shared.dir"; } loadSharedCastsFrom(_sharedCastFile); diff --git a/engines/director/director.h b/engines/director/director.h index 001393bc97..fdbe8ded48 100644 --- a/engines/director/director.h +++ b/engines/director/director.h @@ -57,7 +57,9 @@ enum { kDebugLingoCompile = 1 << 1, kDebugLoading = 1 << 2, kDebugImages = 1 << 3, - kDebugText = 1 << 4 + kDebugText = 1 << 4, + kDebugEvents = 1 << 5, + kDebugLingoParse = 1 << 6 }; extern byte defaultPalette[768]; @@ -108,6 +110,7 @@ public: int _keyCode; int _machineType; bool _playbackPaused; + bool _skipFrameAdvance; Common::String _nextMovie; Common::String _nextMovieFrameS; diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index 3dcfd57466..3c73b82af1 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -595,7 +595,10 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { continue; } - assert(_sprites[i]->_cast); + if (!_sprites[i]->_cast) { + warning("No cast ID for sprite %d", i); + continue; + } BitmapCast *bitmapCast = static_cast<BitmapCast *>(_sprites[i]->_cast); // TODO: might want a quicker way to determine if cast is from Shared Cast. @@ -724,7 +727,7 @@ Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId) { BitmapCast *bc = NULL; if (_vm->getSharedBMP() != NULL && _vm->getSharedBMP()->contains(imgId)) { - debugC(2, kDebugImages, "Shared cast BMP: id: %d", imgId); + debugC(4, kDebugImages, "Shared cast BMP: id: %d", imgId); pic = _vm->getSharedBMP()->getVal(imgId); pic->seek(0); // TODO: this actually gets re-read every loop... we need to rewind it! bc = static_cast<BitmapCast *>(_vm->getSharedCasts()->getVal(spriteId)); @@ -737,14 +740,14 @@ Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId) { if (_vm->getVersion() < 4) { int w = bc->initialRect.width(), h = bc->initialRect.height(); - debugC(2, kDebugImages, "id: %d, w: %d, h: %d, flags: %x, some: %x, unk1: %d, unk2: %d", + debugC(4, kDebugImages, "id: %d, w: %d, h: %d, flags: %x, some: %x, unk1: %d, unk2: %d", imgId, w, h, bc->flags, bc->someFlaggyThing, bc->unk1, bc->unk2); img = new BITDDecoder(w, h); } else if (_vm->getVersion() < 6) { bc = static_cast<BitmapCast *>(_vm->getCurrentScore()->_casts[spriteId]); int w = bc->initialRect.width(), h = bc->initialRect.height(); - debugC(2, kDebugImages, "id: %d, w: %d, h: %d, flags: %x, some: %x, unk1: %d, unk2: %d", + debugC(4, kDebugImages, "id: %d, w: %d, h: %d, flags: %x, some: %x, unk1: %d, unk2: %d", imgId, w, h, bc->flags, bc->someFlaggyThing, bc->unk1, bc->unk2); img = new BITDDecoderV4(w, h, bc->bitsPerPixel); } else { diff --git a/engines/director/images.cpp b/engines/director/images.cpp index 53e91ac494..4574165bb6 100644 --- a/engines/director/images.cpp +++ b/engines/director/images.cpp @@ -147,7 +147,7 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) { // If the stream has exactly the required number of bits for this image, // we assume it is uncompressed. if (stream.size() * 8 == _surface->pitch * _surface->h) { - debugC(3, kDebugImages, "Skipping compression"); + debugC(6, kDebugImages, "Skipping compression"); for (y = 0; y < _surface->h; y++) { for (x = 0; x < _surface->pitch; ) { byte color = stream.readByte(); @@ -265,7 +265,7 @@ bool BITDDecoderV4::loadStream(Common::SeekableReadStream &stream) { // If the stream has exactly the required number of bits for this image, // we assume it is uncompressed. if (stream.size() * 8 == _surface->pitch * _surface->h) { - debugC(3, kDebugImages, "Skipping compression"); + debugC(6, kDebugImages, "Skipping compression"); for (y = 0; y < _surface->h; y++) { for (x = 0; x < _surface->pitch; ) { byte color = stream.readByte(); diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp index be0a191a5b..f4c26a2193 100644 --- a/engines/director/lingo/lingo-builtins.cpp +++ b/engines/director/lingo/lingo-builtins.cpp @@ -20,6 +20,7 @@ * */ +#include "common/system.h" #include "director/lingo/lingo.h" namespace Director { @@ -871,7 +872,8 @@ void Lingo::b_nothing(int nargs) { void Lingo::b_delay(int nargs) { Datum d = g_lingo->pop(); d.toInt(); - warning("STUB: b_delay(%d)", d.u.i); + + g_director->getCurrentScore()->_nextFrameTime = g_system->getMillis() + (float)d.u.i / 60 * 1000; } void Lingo::b_do(int nargs) { @@ -894,8 +896,6 @@ void Lingo::b_pass(int nargs) { void Lingo::b_pause(int nargs) { g_director->_playbackPaused = true; - - g_lingo->pushVoid(); // Fake value } void Lingo::b_playAccel(int nargs) { diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp index 7056d9a863..ddc51f4149 100644 --- a/engines/director/lingo/lingo-funcs.cpp +++ b/engines/director/lingo/lingo-funcs.cpp @@ -223,6 +223,8 @@ void Lingo::func_goto(Datum &frame, Datum &movie) { if (frame.type == VOID) return; + _vm->_skipFrameAdvance = true; + if (frame.type == STRING) { if (_vm->getCurrentScore()) _vm->getCurrentScore()->setStartToLabel(*frame.u.s); @@ -240,6 +242,8 @@ void Lingo::func_gotoloop() { return; _vm->getCurrentScore()->gotoLoop(); + + g_director->_skipFrameAdvance = true; } void Lingo::func_gotonext() { @@ -247,6 +251,8 @@ void Lingo::func_gotonext() { return; _vm->getCurrentScore()->gotoNext(); + + g_director->_skipFrameAdvance = true; } void Lingo::func_gotoprevious() { @@ -254,6 +260,8 @@ void Lingo::func_gotoprevious() { return; _vm->getCurrentScore()->gotoPrevious(); + + g_director->_skipFrameAdvance = true; } void Lingo::func_cursor(int c) { diff --git a/engines/director/lingo/lingo-lex.cpp b/engines/director/lingo/lingo-lex.cpp index c9a7be7ae5..48a5166b95 100644 --- a/engines/director/lingo/lingo-lex.cpp +++ b/engines/director/lingo/lingo-lex.cpp @@ -2549,7 +2549,7 @@ namespace Director { int Lingo::parse(const char *code) { YY_BUFFER_STATE bp; - if (debugChannelSet(-1, kDebugLingoCompile)) + if (debugChannelSet(-1, kDebugLingoParse)) yydebug = 1; else yydebug = 0; diff --git a/engines/director/lingo/lingo-lex.l b/engines/director/lingo/lingo-lex.l index a53a2f04de..37bad1247d 100644 --- a/engines/director/lingo/lingo-lex.l +++ b/engines/director/lingo/lingo-lex.l @@ -325,7 +325,7 @@ namespace Director { int Lingo::parse(const char *code) { YY_BUFFER_STATE bp; - if (debugChannelSet(-1, kDebugLingoCompile)) + if (debugChannelSet(-1, kDebugLingoParse)) yydebug = 1; else yydebug = 0; diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index d90fac34c7..cf0038bfdc 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -158,7 +158,7 @@ const char *Lingo::findNextDefinition(const char *s) { } void Lingo::addCode(const char *code, ScriptType type, uint16 id) { - debugC(2, kDebugLingoCompile, "Add code \"%s\" for type %d with id %d", code, type, id); + debugC(2, kDebugLingoCompile, "Add code \"%s\" for type %s with id %d", code, scriptType2str(type), id); if (_scripts[type].contains(id)) { delete _scripts[type][id]; @@ -247,7 +247,7 @@ void Lingo::executeScript(ScriptType type, uint16 id) { return; } - debugC(2, kDebugLingoExec, "Executing script type: %d, id: %d", type, id); + debugC(2, kDebugLingoExec, "Executing script type: %s, id: %d", scriptType2str(type), id); _currentScript = _scripts[type][id]; _pc = 0; @@ -294,6 +294,8 @@ void Lingo::processEvent(LEvent event, ScriptType st, int entityId) { if (entityId <= 0) return; + debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d)", _eventHandlerTypes[event], scriptType2str(st), entityId); + _currentEntityId = entityId; if (!_eventHandlerTypes.contains(event)) @@ -303,7 +305,7 @@ void Lingo::processEvent(LEvent event, ScriptType st, int entityId) { call(_eventHandlerTypes[event], 0); // D4+ Events pop(); } else if (_scripts[st].contains(entityId)) { - executeScript(st, entityId - 1); // D3 list of scripts. + executeScript(st, entityId); // D3 list of scripts. } else { debugC(8, kDebugLingoExec, "STUB: processEvent(%s) for %d", _eventHandlerTypes[event], entityId); } diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 9cc108d739..975c6efe33 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -41,6 +41,24 @@ namespace Director { +const char *scriptTypes[] = { + "MovieScript", + "SpriteScript", + "FrameScript", + "CastScript" +}; + +const char *scriptType2str(ScriptType scr) { + if (scr < 0) + return "NoneScript"; + + if (scr > kMaxScriptType) + return "<unknown>"; + + return scriptTypes[scr]; +} + + Score::Score(DirectorEngine *vm, Archive *archive) { _vm = vm; _surface = new Graphics::ManagedSurface; @@ -48,6 +66,12 @@ Score::Score(DirectorEngine *vm, Archive *archive) { _movieArchive = archive; _lingo = _vm->getLingo(); _soundManager = _vm->getSoundManager(); + + // FIXME: TODO: Check whether the original truely does it + if (_vm->getVersion() <= 3) { + _lingo->executeScript(kMovieScript, 0); + } + _lingo->processEvent(kEventPrepareMovie, kMovieScript, 0); _movieScriptCount = 0; _labels = NULL; @@ -136,10 +160,13 @@ void Score::loadArchive() { setSpriteCasts(); - //Common::Array<uint16> stxt = _movieArchive->getResourceIDList(MKTAG('S','T','X','T')); - //if (stxt.size() > 0) { - // loadScriptText(*_movieArchive->getResource(MKTAG('S','T','X','T'), *stxt.begin())); - //} + // Try to load movie script, it sits in resource A11 + if (_vm->getVersion() <= 3) { + Common::Array<uint16> stxt = _movieArchive->getResourceIDList(MKTAG('S','T','X','T')); + if (stxt.size() > 0) { + loadScriptText(*_movieArchive->getResource(MKTAG('S','T','X','T'), *stxt.begin())); + } + } } Score::~Score() { @@ -237,6 +264,8 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) { //Common::hexdump(channelData, ARRAYSIZE(channelData)); frame->readChannels(str); + debugC(3, kDebugLoading, "Frame %d actionId: %d", _frames.size(), frame->_actionId); + delete str; _frames.push_back(frame); @@ -478,12 +507,13 @@ void Score::loadActions(Common::SeekableSubReadStreamEndian &stream) { uint16 offset = count * 4 + 2; byte id = stream.readByte(); - /*byte subId = */ stream.readByte(); // I couldn't find how it used in continuity (except print). Frame actionId = 1 byte. + + byte subId = stream.readByte(); // I couldn't find how it used in continuity (except print). Frame actionId = 1 byte. uint16 stringPos = stream.readUint16() + offset; for (uint16 i = 0; i < count; i++) { uint16 nextId = stream.readByte(); - /*byte subId = */ stream.readByte(); + byte nextSubId = stream.readByte(); uint16 nextStringPos = stream.readUint16() + offset; uint16 streamPos = stream.pos(); @@ -494,12 +524,15 @@ void Score::loadActions(Common::SeekableSubReadStreamEndian &stream) { if (ch == 0x0d) { ch = '\n'; } - _actions[id] += ch; + _actions[i + 1] += ch; } + debugC(3, kDebugLoading, "id: %d nextId: %d subId: %d, code: %s", id, nextId, subId, _actions[id].c_str()); + stream.seek(streamPos); id = nextId; + subId = nextSubId; stringPos = nextStringPos; if (stringPos == stream.size()) @@ -633,6 +666,8 @@ void Score::gotoLoop() { } } } + + g_director->_skipFrameAdvance = true; } int Score::getCurrentLabelNumber() { @@ -651,11 +686,15 @@ int Score::getCurrentLabelNumber() { void Score::gotoNext() { // we can just try to use the current frame and get the next label _currentFrame = getNextLabelNumber(_currentFrame); + + g_director->_skipFrameAdvance = true; } void Score::gotoPrevious() { // we actually need the frame of the label prior to the most recent label. _currentFrame = getPreviousLabelNumber(getCurrentLabelNumber()); + + g_director->_skipFrameAdvance = true; } int Score::getNextLabelNumber(int referenceFrame) { @@ -833,7 +872,6 @@ void Score::startLoop() { _stopPlay = false; _nextFrameTime = 0; - _lingo->processEvent(kEventStartMovie, kMovieScript, 0); _frames[_currentFrame]->prepareFrame(this); while (!_stopPlay && _currentFrame < _frames.size()) { @@ -865,7 +903,7 @@ void Score::update() { } } - // TODO Director 6 step: send prepareFrame event to all sprites and the script channel in upcoming frame + // TODO: Director 6 step: send prepareFrame event to all sprites and the script channel in upcoming frame if (_vm->getVersion() >= 6) _lingo->processEvent(kEventPrepareFrame, kFrameScript, _currentFrame); @@ -878,9 +916,11 @@ void Score::update() { } } - if (!g_director->_playbackPaused) + if (!g_director->_playbackPaused && !g_director->_skipFrameAdvance) _currentFrame++; + g_director->_skipFrameAdvance = false; + if (_currentFrame >= _frames.size()) return; @@ -922,7 +962,7 @@ void Score::update() { } void Score::processEvents() { - //TODO: re-instate when we know which script to run. + // TODO: re-instate when we know which script to run. //if (_currentFrame > 0) // _lingo->processEvent(kEventIdle, _currentFrame - 1); @@ -938,9 +978,9 @@ void Score::processEvents() { if (event.type == Common::EVENT_LBUTTONDOWN) { Common::Point pos = g_system->getEventManager()->getMousePos(); - //D3 doesn't have both mouse up and down. + // D3 doesn't have both mouse up and down. if (_vm->getVersion() > 3) { - //TODO: check that this is the order of script execution! + // TODO: check that this is the order of script execution! uint16 spriteId = _frames[_currentFrame]->getSpriteIDFromPos(pos); _lingo->processEvent(kEventMouseDown, kCastScript, _frames[_currentFrame]->_sprites[spriteId]->_castId); _lingo->processEvent(kEventMouseDown, kSpriteScript, _frames[_currentFrame]->_sprites[spriteId]->_scriptId); @@ -952,11 +992,11 @@ void Score::processEvents() { uint16 spriteId = _frames[_currentFrame]->getSpriteIDFromPos(pos); if (_vm->getVersion() > 3) { - //TODO: check that this is the order of script execution! + // TODO: check that this is the order of script execution! _lingo->processEvent(kEventMouseUp, kCastScript, _frames[_currentFrame]->_sprites[spriteId]->_castId); _lingo->processEvent(kEventMouseUp, kSpriteScript, _frames[_currentFrame]->_sprites[spriteId]->_scriptId); } else { - //D3 doesn't have cast member or sprite scripts. Just Frame Scripts. + // D3 doesn't have cast member or sprite scripts. Just Frame Scripts. _lingo->processEvent(kEventMouseUp, kFrameScript, _frames[_currentFrame]->_sprites[spriteId]->_scriptId); } } @@ -982,7 +1022,7 @@ void Score::processEvents() { warning("Keycode: %d", _vm->_keyCode); } - //TODO: is movie script correct? Can this be elsewhere? + // TODO: is movie script correct? Can this be elsewhere? _lingo->processEvent(kEventKeyDown, kMovieScript, 0); } } diff --git a/engines/director/score.h b/engines/director/score.h index dca1b8fc02..6db5e33988 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -52,6 +52,8 @@ enum ScriptType { kMaxScriptType = 3 }; +const char *scriptType2str(ScriptType scr); + class Score { public: Score(DirectorEngine *vm, Archive *); @@ -110,6 +112,7 @@ public: Common::Rect _movieRect; bool _stopPlay; + uint32 _nextFrameTime; private: uint16 _versionMinor; @@ -123,7 +126,6 @@ private: uint16 _castArrayStart; uint16 _currentFrame; Common::String _currentLabel; - uint32 _nextFrameTime; uint32 _flags; uint16 _castArrayEnd; uint16 _movieScriptCount; diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 561b74d354..a3a690be59 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -456,9 +456,6 @@ void Script::syncStringHeap(Common::Serializer &s) { s.syncBytes(buf, blockSize); buf += blockSize; - - if (_buf - buf == 0) - break; } while (1); } else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1_LATE){ diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 77c3d4e637..aaa1c8ccfe 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -2234,7 +2234,7 @@ bool ResourceManager::checkResourceDataForSignature(Resource *resource, const by if (signatureSize > resource->size) return false; - const uint32 signatureDWord = *((const uint32 *)signature); + const uint32 signatureDWord = READ_UINT32(signature); signature += 4; signatureSize -= 4; const uint32 searchLimit = resource->size - signatureSize + 1; diff --git a/engines/titanic/carry/arm.cpp b/engines/titanic/carry/arm.cpp index 5105ea81b4..23b0710c30 100644 --- a/engines/titanic/carry/arm.cpp +++ b/engines/titanic/carry/arm.cpp @@ -35,55 +35,41 @@ BEGIN_MESSAGE_MAP(CArm, CCarry) ON_MESSAGE(MouseDragMoveMsg) END_MESSAGE_MAP() -CArm::CArm() : CCarry(), _string6("Key"), - _field138(0), _field158(0), _field16C(3), _field170(0), +CArm::CArm() : CCarry(), _heldItemName("Key"), + _puzzleUnused(0), _armUnlocked(false), _arboretumFrame(3), _unlockedFrame(0), _armRect(220, 208, 409, 350) { } void CArm::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string6, indent); - file->writeNumberLine(_field138, indent); - file->writeNumberLine(_hookedRect.left, indent); - file->writeNumberLine(_hookedRect.top, indent); - file->writeNumberLine(_hookedRect.right, indent); - file->writeNumberLine(_hookedRect.bottom, indent); - - file->writeQuotedLine(_string7, indent); - file->writeNumberLine(_field158, indent); - file->writeNumberLine(_armRect.left, indent); - file->writeNumberLine(_armRect.top, indent); - file->writeNumberLine(_armRect.right, indent); - file->writeNumberLine(_armRect.bottom, indent); - file->writeNumberLine(_field16C, indent); - file->writeNumberLine(_field170, indent); + file->writeQuotedLine(_heldItemName, indent); + file->writeNumberLine(_puzzleUnused, indent); + file->writeRect(_hookedRect, indent); + file->writeQuotedLine(_hookedTarget, indent); + file->writeNumberLine(_armUnlocked, indent); + file->writeRect(_armRect, indent); + file->writeNumberLine(_arboretumFrame, indent); + file->writeNumberLine(_unlockedFrame, indent); CCarry::save(file, indent); } void CArm::load(SimpleFile *file) { file->readNumber(); - _string6 = file->readString(); - _field138 = file->readNumber(); - _hookedRect.left = file->readNumber(); - _hookedRect.top = file->readNumber(); - _hookedRect.right = file->readNumber(); - _hookedRect.bottom = file->readNumber(); - - _string7 = file->readString(); - _field158 = file->readNumber(); - _armRect.left = file->readNumber(); - _armRect.top = file->readNumber(); - _armRect.right = file->readNumber(); - _armRect.bottom = file->readNumber(); - _field16C = file->readNumber(); - _field170 = file->readNumber(); + _heldItemName = file->readString(); + _puzzleUnused = file->readNumber(); + _hookedRect = file->readRect(); + _hookedTarget = file->readString(); + _armUnlocked = file->readNumber(); + _armRect = file->readRect(); + _arboretumFrame = file->readNumber(); + _unlockedFrame = file->readNumber(); CCarry::load(file); } bool CArm::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) { - _field138 = 0; + _puzzleUnused = 0; _canTake = true; CString name = getName(); @@ -101,13 +87,13 @@ bool CArm::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) { } bool CArm::TranslateObjectMsg(CTranslateObjectMsg *msg) { - Point newPos(_bounds.left - msg->_delta.x, _bounds.top - msg->_delta.y); + Point newPos(_bounds.left + msg->_delta.x, _bounds.top + msg->_delta.y); setPosition(newPos); return true; } bool CArm::UseWithOtherMsg(CUseWithOtherMsg *msg) { - if (_string6 != "None") { + if (_heldItemName != "None") { CShowTextMsg textMsg(ARM_ALREADY_HOLDING); textMsg.execute("PET"); return false; @@ -116,8 +102,8 @@ bool CArm::UseWithOtherMsg(CUseWithOtherMsg *msg) { hookedMsg._rect.translate(_bounds.left, _bounds.top); hookedMsg.execute("GondolierLeftLever"); - if (hookedMsg._result) { - _string7 = "GondolierLeftLever"; + if (hookedMsg._isHooked) { + _hookedTarget = "GondolierLeftLever"; } else { petAddToInventory(); } @@ -126,11 +112,13 @@ bool CArm::UseWithOtherMsg(CUseWithOtherMsg *msg) { hookedMsg._rect.translate(_bounds.left, _bounds.top); hookedMsg.execute("GondolierRightLever"); - if (hookedMsg._result) { - _string7 = "GondolierRightLever"; + if (hookedMsg._isHooked) { + _hookedTarget = "GondolierRightLever"; } else { petAddToInventory(); } + } else { + petAddToInventory(); } return true; @@ -142,13 +130,13 @@ bool CArm::MouseDragStartMsg(CMouseDragStartMsg *msg) { textMsg.execute("PET"); } else if (checkStartDragging(msg)) { hideMouse(); - _tempPos = msg->_mousePos - _bounds; - setPosition(msg->_mousePos - _tempPos); + _centroid = msg->_mousePos - _bounds; + setPosition(msg->_mousePos - _centroid); - if (!_string7.empty()) { + if (!_hookedTarget.empty()) { CActMsg actMsg("Unhook"); - actMsg.execute(_string7); - _string7.clear(); + actMsg.execute(_hookedTarget); + _hookedTarget.clear(); } loadFrame(_visibleFrame); @@ -161,39 +149,39 @@ bool CArm::MouseDragStartMsg(CMouseDragStartMsg *msg) { bool CArm::MaitreDHappyMsg(CMaitreDHappyMsg *msg) { CGameObject *petItem; if (find(getName(), &petItem, FIND_PET)) { - if (!_field158) + if (!_armUnlocked) playSound("z#47.wav"); - if (_string6 == "Key" || _string6 == "AuditoryCentre") { - CGameObject *child = dynamic_cast<CGameObject *>(getFirstChild()); - if (child) { - child->setVisible(true); - petAddToInventory(); + if (_heldItemName == "Key" || _heldItemName == "AuditoryCentre") { + CGameObject *heldItem = dynamic_cast<CGameObject *>(getFirstChild()); + if (heldItem) { + heldItem->setVisible(true); + heldItem->petAddToInventory(); } - _visibleFrame = _field170; + _visibleFrame = _unlockedFrame; loadFrame(_visibleFrame); - _string6 = "None"; + _heldItemName = "None"; petInvChange(); } } - _field158 = 1; + _armUnlocked = true; _canTake = true; return true; } bool CArm::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { - if (_field158) { - if (_string6 == "Key" || _string6 == "AuditoryCentre") { + if (_armUnlocked) { + if (_heldItemName == "Key" || _heldItemName == "AuditoryCentre") { CCarry *child = dynamic_cast<CCarry *>(getFirstChild()); if (child) { - _visibleFrame = _field170; + _visibleFrame = _unlockedFrame; loadFrame(_visibleFrame); child->setVisible(true); child->petAddToInventory(); } - _string6 = "None"; + _heldItemName = "None"; } } @@ -201,11 +189,11 @@ bool CArm::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { } bool CArm::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { - setPosition(msg->_mousePos - _tempPos); + setPosition(msg->_mousePos - _centroid); - if (_string6 != "None" && compareViewNameTo("FrozenArboretum.Node 5.S")) { + if (_heldItemName == "None" && compareViewNameTo("FrozenArboretum.Node 5.S")) { loadFrame(_armRect.contains(msg->_mousePos) ? - _field16C : _visibleFrame); + _arboretumFrame : _visibleFrame); } return true; diff --git a/engines/titanic/carry/arm.h b/engines/titanic/carry/arm.h index fc8bba1f08..3eec4b6995 100644 --- a/engines/titanic/carry/arm.h +++ b/engines/titanic/carry/arm.h @@ -40,14 +40,14 @@ class CArm : public CCarry { bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); bool MouseDragMoveMsg(CMouseDragMoveMsg *msg); private: - CString _string6; - int _field138; + CString _heldItemName; + int _puzzleUnused; Rect _hookedRect; - CString _string7; - int _field158; + CString _hookedTarget; + bool _armUnlocked; Rect _armRect; - int _field16C; - int _field170; + int _arboretumFrame; + int _unlockedFrame; public: CLASSDEF; CArm(); diff --git a/engines/titanic/carry/brain.cpp b/engines/titanic/carry/brain.cpp index b00f026718..73970c404c 100644 --- a/engines/titanic/carry/brain.cpp +++ b/engines/titanic/carry/brain.cpp @@ -33,14 +33,14 @@ BEGIN_MESSAGE_MAP(CBrain, CCarry) ON_MESSAGE(PETGainedObjectMsg) END_MESSAGE_MAP() -CBrain::CBrain() : CCarry(), _field134(0), _field138(0) { +CBrain::CBrain() : CCarry(), _pieceAdded(false), _perchGained(false) { } void CBrain::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writePoint(_pos1, indent); - file->writeNumberLine(_field134, indent); - file->writeNumberLine(_field138, indent); + file->writeNumberLine(_pieceAdded, indent); + file->writeNumberLine(_perchGained, indent); CCarry::save(file, indent); } @@ -48,36 +48,38 @@ void CBrain::save(SimpleFile *file, int indent) { void CBrain::load(SimpleFile *file) { file->readNumber(); _pos1 = file->readPoint(); - _field134 = file->readNumber(); - _field138 = file->readNumber(); + _pieceAdded = file->readNumber(); + _perchGained = file->readNumber(); CCarry::load(file); } bool CBrain::UseWithOtherMsg(CUseWithOtherMsg *msg) { CBrainSlot *slot = dynamic_cast<CBrainSlot *>(msg->_other); - if (slot) { - if (slot->getName() == "CentralCore") { - setVisible(false); - petMoveToHiddenRoom(); - CAddHeadPieceMsg headpieceMsg(getName()); - headpieceMsg.execute("CentralCoreSlot"); - } - else if (!slot->_value1 && slot->getName() == "CentralCoreSlot") { - setVisible(false); - petMoveToHiddenRoom(); - CAddHeadPieceMsg headpieceMsg(getName()); - headpieceMsg.execute(msg->_other); - playSound("z#116.wav"); - setPosition(Point(0, 0)); - setVisible(false); - _field134 = 1; - } + if (!slot) + return CCarry::UseWithOtherMsg(msg); - return true; + if (isEquals("CentralCore")) { + setVisible(false); + petMoveToHiddenRoom(); + CAddHeadPieceMsg headpieceMsg(getName()); + headpieceMsg.execute("CentralCoreSlot"); + } else if (!slot->_occupied && slot->getName() != "CentralCoreSlot") { + // Brain card goes into vacant slot + setVisible(false); + petMoveToHiddenRoom(); + CAddHeadPieceMsg headpieceMsg(getName()); + headpieceMsg.execute(msg->_other); + playSound("z#116.wav"); + setPosition(Point(0, 0)); + setVisible(false); + _pieceAdded = true; } else { - return CCarry::UseWithOtherMsg(msg); + // Trying to put brain card into an already occupied slot + petAddToInventory(); } + + return true; } bool CBrain::VisibleMsg(CVisibleMsg *msg) { @@ -89,11 +91,11 @@ bool CBrain::MouseDragStartMsg(CMouseDragStartMsg *msg) { if (!checkStartDragging(msg)) return false; - if (_field134) { + if (_pieceAdded) { CTakeHeadPieceMsg headpieceMsg(getName()); headpieceMsg.execute("TitaniaControl"); - _field134 = 0; + _pieceAdded = false; setVisible(true); moveToView(); @@ -105,10 +107,10 @@ bool CBrain::MouseDragStartMsg(CMouseDragStartMsg *msg) { } bool CBrain::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { - if (_field134) { + if (_pieceAdded) { CTakeHeadPieceMsg headpieceMsg(getName()); headpieceMsg.execute("TitaniaControl"); - _field134 = 0; + _pieceAdded = false; setVisible(true); moveToView(); @@ -120,10 +122,10 @@ bool CBrain::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { } bool CBrain::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { - if (!_field138) { + if (!_perchGained) { if (getName() == "Perch") { - stateInc38(); - _field138 = 1; + incParrotResponse(); + _perchGained = true; } } diff --git a/engines/titanic/carry/brain.h b/engines/titanic/carry/brain.h index bcba161e27..4c41378702 100644 --- a/engines/titanic/carry/brain.h +++ b/engines/titanic/carry/brain.h @@ -39,8 +39,8 @@ class CBrain : public CCarry { bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); private: Point _pos1; - int _field134; - int _field138; + bool _pieceAdded; + bool _perchGained; public: CLASSDEF; CBrain(); diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp index f6403b18b9..fd5b593fa3 100644 --- a/engines/titanic/carry/carry.cpp +++ b/engines/titanic/carry/carry.cpp @@ -44,30 +44,29 @@ BEGIN_MESSAGE_MAP(CCarry, CGameObject) ON_MESSAGE(PassOnDragStartMsg) END_MESSAGE_MAP() -CCarry::CCarry() : CGameObject(), _fieldDC(0), _canTake(true), - _field100(0), _field104(0), _field108(0), _field10C(0), - _itemFrame(0), _enterFrame(0), _enterFrameSet(false), _visibleFrame(0), - _string1("None"), - _fullViewName("NULL"), - _string3(g_vm->_strings[DOESNT_DO_ANYTHING]), - _string4(g_vm->_strings[DOESNT_WANT_THIS]) { +CCarry::CCarry() : CGameObject(), _unused5(0), _canTake(true), + _unusedR(0), _unusedG(0), _unusedB(0), _itemFrame(0), + _enterFrame(0), _enterFrameSet(false), _visibleFrame(0), + _npcUse("None"), _fullViewName("NULL"), + _doesNothingMsg(g_vm->_strings[DOESNT_DO_ANYTHING]), + _doesntWantMsg(g_vm->_strings[DOESNT_WANT_THIS]) { } void CCarry::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_npcUse, indent); file->writePoint(_origPos, indent); file->writeQuotedLine(_fullViewName, indent); - file->writeNumberLine(_fieldDC, indent); + file->writeNumberLine(_unused5, indent); file->writeNumberLine(_canTake, indent); - file->writeQuotedLine(_string3, indent); - file->writeQuotedLine(_string4, indent); - file->writePoint(_tempPos, indent); - file->writeNumberLine(_field104, indent); - file->writeNumberLine(_field108, indent); - file->writeNumberLine(_field10C, indent); + file->writeQuotedLine(_doesNothingMsg, indent); + file->writeQuotedLine(_doesntWantMsg, indent); + file->writePoint(_centroid, indent); + file->writeNumberLine(_unusedR, indent); + file->writeNumberLine(_unusedG, indent); + file->writeNumberLine(_unusedB, indent); file->writeNumberLine(_itemFrame, indent); - file->writeQuotedLine(_string5, indent); + file->writeQuotedLine(_unused6, indent); file->writeNumberLine(_enterFrame, indent); file->writeNumberLine(_enterFrameSet, indent); file->writeNumberLine(_visibleFrame, indent); @@ -77,19 +76,19 @@ void CCarry::save(SimpleFile *file, int indent) { void CCarry::load(SimpleFile *file) { file->readNumber(); - _string1 = file->readString(); + _npcUse = file->readString(); _origPos = file->readPoint(); _fullViewName = file->readString(); - _fieldDC = file->readNumber(); + _unused5 = file->readNumber(); _canTake = file->readNumber(); - _string3 = file->readString(); - _string4 = file->readString(); - _tempPos = file->readPoint(); - _field104 = file->readNumber(); - _field108 = file->readNumber(); - _field10C = file->readNumber(); + _doesNothingMsg = file->readString(); + _doesntWantMsg = file->readString(); + _centroid = file->readPoint(); + _unusedR = file->readNumber(); + _unusedG = file->readNumber(); + _unusedB = file->readNumber(); _itemFrame = file->readNumber(); - _string5 = file->readString(); + _unused6 = file->readString(); _enterFrame = file->readNumber(); _enterFrameSet = file->readNumber(); _visibleFrame = file->readNumber(); @@ -118,7 +117,7 @@ bool CCarry::MouseDragStartMsg(CMouseDragStartMsg *msg) { } bool CCarry::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { - setPosition(msg->_mousePos - _tempPos); + setPosition(msg->_mousePos - _centroid); return true; } @@ -167,7 +166,7 @@ bool CCarry::UseWithCharMsg(CUseWithCharMsg *msg) { carryMsg._item = this; carryMsg.execute(succubus); } else { - CShowTextMsg textMsg(_string4); + CShowTextMsg textMsg(_doesntWantMsg); textMsg.execute("PET"); petAddToInventory(); } @@ -180,7 +179,7 @@ bool CCarry::LeaveViewMsg(CLeaveViewMsg *msg) { } bool CCarry::UseWithOtherMsg(CUseWithOtherMsg *msg) { - CShowTextMsg textMsg(_string3); + CShowTextMsg textMsg(_doesNothingMsg); textMsg.execute("PET"); if (!compareViewNameTo(_fullViewName) || _bounds.top >= 360) { @@ -233,13 +232,13 @@ bool CCarry::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { loadFrame(_visibleFrame); if (msg->_value3) { - _tempPos.x = _bounds.width() / 2; - _tempPos.y = _bounds.height() / 2; + _centroid.x = _bounds.width() / 2; + _centroid.y = _bounds.height() / 2; } else { - _tempPos = msg->_mousePos - _bounds; + _centroid = msg->_mousePos - _bounds; } - setPosition(getMousePos() - _tempPos); + setPosition(getMousePos() - _centroid); return true; } diff --git a/engines/titanic/carry/carry.h b/engines/titanic/carry/carry.h index cb53df47a5..e9069da925 100644 --- a/engines/titanic/carry/carry.h +++ b/engines/titanic/carry/carry.h @@ -43,22 +43,20 @@ class CCarry : public CGameObject { bool MoveToStartPosMsg(CMoveToStartPosMsg *msg); bool EnterViewMsg(CEnterViewMsg *msg); bool PassOnDragStartMsg(CPassOnDragStartMsg *msg); -protected: - int _fieldDC; - CString _string3; - CString _string4; - Point _tempPos; - int _field100; - int _field104; - int _field108; - int _field10C; +private: + int _unused5; + CString _doesNothingMsg; + CString _doesntWantMsg; + int _unusedR, _unusedG, _unusedB; int _itemFrame; - CString _string5; + CString _unused6; int _enterFrame; bool _enterFrameSet; +protected: + Point _centroid; int _visibleFrame; public: - CString _string1; + CString _npcUse; bool _canTake; Point _origPos; CString _fullViewName; diff --git a/engines/titanic/carry/carry_parrot.cpp b/engines/titanic/carry/carry_parrot.cpp index 3a2f2c9368..4bb3a96bfb 100644 --- a/engines/titanic/carry/carry_parrot.cpp +++ b/engines/titanic/carry/carry_parrot.cpp @@ -113,7 +113,7 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) { CTreeItem *perchedParrot = findUnder(getRoot(), "PerchedParrot"); detach(); addUnder(perchedParrot); - sound8(true); + stopSoundChannel(true); CPutParrotBackMsg backMsg(msg->_mousePos.x); backMsg.execute(perchedParrot); @@ -122,7 +122,7 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) { _canTake = false; CParrot::_state = PARROT_ESCAPED; playSound("z#475.wav"); - sound8(true); + stopSoundChannel(true); moveUnder(findRoom()); CActMsg actMsg("Shut"); @@ -137,7 +137,7 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) { setVisible(false); _canTake = false; playSound("z#475.wav"); - sound8(true); + stopSoundChannel(true); moveUnder(findRoom()); } } diff --git a/engines/titanic/carry/ear.cpp b/engines/titanic/carry/ear.cpp index 580ebd662f..c5196dc557 100644 --- a/engines/titanic/carry/ear.cpp +++ b/engines/titanic/carry/ear.cpp @@ -59,9 +59,11 @@ bool CEar::UseWithOtherMsg(CUseWithOtherMsg *msg) { CAddHeadPieceMsg addMsg(getName()); if (addMsg._value != "NULL") addMsg.execute(addMsg._value == "Ear1" ? "Ear1Slot" : "Ear2Slot"); - } - return CCarry::UseWithOtherMsg(msg); + return true; + } else { + return CCarry::UseWithOtherMsg(msg); + } } } // End of namespace Titanic diff --git a/engines/titanic/carry/head_piece.cpp b/engines/titanic/carry/head_piece.cpp index 1ce1d5ba1e..fa025158a5 100644 --- a/engines/titanic/carry/head_piece.cpp +++ b/engines/titanic/carry/head_piece.cpp @@ -60,7 +60,7 @@ bool CHeadPiece::SenseWorkingMsg(CSenseWorkingMsg *msg) { bool CHeadPiece::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { _visibleFrame = 1; if (!_field13C) { - stateInc38(); + incParrotResponse(); _field13C = true; } diff --git a/engines/titanic/carry/magazine.cpp b/engines/titanic/carry/magazine.cpp index e68c63f8f9..94e853bda9 100644 --- a/engines/titanic/carry/magazine.cpp +++ b/engines/titanic/carry/magazine.cpp @@ -52,19 +52,18 @@ void CMagazine::load(SimpleFile *file) { } bool CMagazine::UseWithCharMsg(CUseWithCharMsg *msg) { + // WORKAROUND: Slight difference to original to ensure that when the + // magazine is used on an incorrect char, it's returned to inventory CDeskbot *deskbot = dynamic_cast<CDeskbot *>(msg->_character); - if (deskbot) { - if (deskbot->_deskbotActive) { - setVisible(false); - setPosition(Point(1000, 1000)); - CActMsg actMsg("2ndClassUpgrade"); - actMsg.execute("Deskbot"); - } - + if (deskbot && deskbot->_deskbotActive) { + setVisible(false); + setPosition(Point(1000, 1000)); + CActMsg actMsg("2ndClassUpgrade"); + actMsg.execute("Deskbot"); return true; - } else { - return CCarry::UseWithCharMsg(msg); } + + return CCarry::UseWithCharMsg(msg); } bool CMagazine::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { @@ -77,17 +76,20 @@ bool CMagazine::VisibleMsg(CVisibleMsg *msg) { } bool CMagazine::UseWithOtherMsg(CUseWithOtherMsg *msg) { + // WORKAROUND: Slight difference to original to ensure that when the + // magazine is used on an incorrect object, it's returned to inventory if (msg->_other->getName() == "SwitchOnDeskbot") { - // TODO: other _field108 if - if (false) { + CDeskbot *deskbot = dynamic_cast<CDeskbot *>(msg->_other); + if (deskbot && deskbot->_deskbotActive) { setVisible(false); setPosition(Point(1000, 1000)); CActMsg actMsg("2ndClassUpgrade"); actMsg.execute("Deskbot"); + return true; } } - return true; + return CCarry::UseWithOtherMsg(msg); } } // End of namespace Titanic diff --git a/engines/titanic/carry/mouth.cpp b/engines/titanic/carry/mouth.cpp index e48929a391..d750fc969e 100644 --- a/engines/titanic/carry/mouth.cpp +++ b/engines/titanic/carry/mouth.cpp @@ -70,7 +70,7 @@ bool CMouth::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { loadFrame(2); setVisible(true); if (!_field13C) { - stateInc38(); + incParrotResponse(); _field13C = true; } diff --git a/engines/titanic/carry/phonograph_cylinder.cpp b/engines/titanic/carry/phonograph_cylinder.cpp index 67ea301681..fa260ef876 100644 --- a/engines/titanic/carry/phonograph_cylinder.cpp +++ b/engines/titanic/carry/phonograph_cylinder.cpp @@ -104,6 +104,7 @@ void CPhonographCylinder::load(SimpleFile *file) { bool CPhonographCylinder::UseWithOtherMsg(CUseWithOtherMsg *msg) { CPhonograph *phonograph = dynamic_cast<CPhonograph *>(msg->_other); if (phonograph) { + // Below is redundant, since original never actually executes message CSetVarMsg varMsg("m_RecordStatus", 1); return true; } else { diff --git a/engines/titanic/core/background.cpp b/engines/titanic/core/background.cpp index 9f22f1e992..d6419f23db 100644 --- a/engines/titanic/core/background.cpp +++ b/engines/titanic/core/background.cpp @@ -58,7 +58,7 @@ void CBackground::load(SimpleFile *file) { bool CBackground::StatusChangeMsg(CStatusChangeMsg *msg) { setVisible(true); if (_isBlocking) { - playMovie(_startFrame, _endFrame, MOVIE_GAMESTATE); + playMovie(_startFrame, _endFrame, MOVIE_WAIT_FOR_FINISH); } else { playMovie(_startFrame, _endFrame, 0); } diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index af7020532c..314746e496 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -56,26 +56,25 @@ void CGameObject::deinit() { CGameObject::CGameObject(): CNamedItem() { _bounds = Rect(0, 0, 15, 15); - _field34 = 0; - _field38 = 0; - _field3C = 0; + _unused1 = 0; + _unused2 = 0; + _unused3 = 0; _nonvisual = false; - _field44 = 0xF0; - _field48 = 0xF0; - _field4C = 0xFF; + _toggleR = 0xF0; + _toggleG = 0xF0; + _toggleB = 0xFF; _isPendingMail = false; _destRoomFlags = 0; _roomFlags = 0; _visible = true; - _field60 = 0; + _handleMouseFlag = false; _cursorId = CURSOR_ARROW; _initialFrame = 0; _frameNumber = -1; _text = nullptr; _textBorder = _textBorderRight = 0; - _field9C = 0; _surface = nullptr; - _fieldB8 = 0; + _unused4 = 0; } CGameObject::~CGameObject() { @@ -105,19 +104,19 @@ void CGameObject::save(SimpleFile *file, int indent) { file->writeNumberLine(getMovieFrame(), indent + 1); file->writeNumberLine(_cursorId, indent + 1); _movieClips.save(file, indent + 1); - file->writeNumberLine(_field60, indent + 1); + file->writeNumberLine(_handleMouseFlag, indent + 1); file->writeNumberLine(_nonvisual, indent + 1); file->writeQuotedLine(_resource, indent + 1); file->writeBounds(_bounds, indent + 1); - file->writeFloatLine(_field34, indent + 1); - file->writeFloatLine(_field38, indent + 1); - file->writeFloatLine(_field3C, indent + 1); + file->writeFloatLine(_unused1, indent + 1); + file->writeFloatLine(_unused2, indent + 1); + file->writeFloatLine(_unused3, indent + 1); - file->writeNumberLine(_field44, indent + 1); - file->writeNumberLine(_field48, indent + 1); - file->writeNumberLine(_field4C, indent + 1); - file->writeNumberLine(_fieldB8, indent + 1); + file->writeNumberLine(_toggleR, indent + 1); + file->writeNumberLine(_toggleG, indent + 1); + file->writeNumberLine(_toggleB, indent + 1); + file->writeNumberLine(_unused4, indent + 1); file->writeNumberLine(_visible, indent + 1); file->writeNumberLine(_isPendingMail, indent + 1); file->writeNumberLine(_destRoomFlags, indent + 1); @@ -153,7 +152,7 @@ void CGameObject::load(SimpleFile *file) { // Deliberate fall-through case 4: - _field60 = file->readNumber(); + _handleMouseFlag = file->readNumber(); // Deliberate fall-through case 3: @@ -166,13 +165,13 @@ void CGameObject::load(SimpleFile *file) { case 1: _bounds = file->readBounds(); - _field34 = file->readFloat(); - _field38 = file->readFloat(); - _field3C = file->readFloat(); - _field44 = file->readNumber(); - _field48 = file->readNumber(); - _field4C = file->readNumber(); - _fieldB8 = file->readNumber(); + _unused1 = file->readFloat(); + _unused2 = file->readFloat(); + _unused3 = file->readFloat(); + _toggleR = file->readNumber(); + _toggleG = file->readNumber(); + _toggleB = file->readNumber(); + _unused4 = file->readNumber(); _visible = file->readNumber() != 0; _isPendingMail = file->readNumber(); _destRoomFlags = file->readNumber(); @@ -543,15 +542,11 @@ void CGameObject::setGlobalSoundVolume(int mode, uint seconds, int handleIndex) } } -void CGameObject::sound8(bool flag) const { - getGameManager()->_sound.stopChannel(flag ? 3 : 0); +void CGameObject::stopSoundChannel(bool channel3) { + getGameManager()->_sound.stopChannel(channel3 ? 3 : 0); } void CGameObject::setVisible(bool val) { - if (_name.contains("ylinder")) { - warning("TODO"); - } - if (val != _visible) { _visible = val; makeDirty(); @@ -611,7 +606,7 @@ void CGameObject::playMovie(uint flags) { CGameObject *obj = (flags & MOVIE_NOTIFY_OBJECT) ? this : nullptr; if (_surface) { _surface->playMovie(flags, obj); - if (flags & MOVIE_GAMESTATE) + if (flags & MOVIE_WAIT_FOR_FINISH) getGameManager()->_gameState.addMovie(_surface->_movie); } } @@ -627,7 +622,7 @@ void CGameObject::playMovie(int startFrame, int endFrame, uint flags) { CGameObject *obj = (flags & MOVIE_NOTIFY_OBJECT) ? this : nullptr; if (_surface) { _surface->playMovie(startFrame, endFrame, flags, obj); - if (flags & MOVIE_GAMESTATE) + if (flags & MOVIE_WAIT_FOR_FINISH) getGameManager()->_gameState.addMovie(_surface->_movie); } } @@ -644,7 +639,7 @@ void CGameObject::playMovie(int startFrame, int endFrame, int initialFrame, uint CGameObject *obj = (flags & MOVIE_NOTIFY_OBJECT) ? this : nullptr; if (_surface) { _surface->playMovie(startFrame, endFrame, initialFrame, flags, obj); - if (flags & MOVIE_GAMESTATE) + if (flags & MOVIE_WAIT_FOR_FINISH) getGameManager()->_gameState.addMovie(_surface->_movie); } } @@ -1058,12 +1053,12 @@ bool CGameObject::stateGetParrotMet() const { return getGameManager()->_gameState.getParrotMet(); } -void CGameObject::stateInc38() { - getGameManager()->_gameState.inc38(); +void CGameObject::incParrotResponse() { + getGameManager()->_gameState.incParrotResponse(); } -int CGameObject::stateGet38() const { - return getGameManager()->_gameState._field38; +int CGameObject::getParrotResponse() const { + return getGameManager()->_gameState._parrotResponseIndex; } void CGameObject::quitGame() { @@ -1373,11 +1368,11 @@ void CGameObject::createCredits() { _credits->load(this, screenManager, _bounds); } -void CGameObject::fn10(int v1, int v2, int v3) { +void CGameObject::setToggleColor(byte r, byte g, byte b) { makeDirty(); - _field44 = v1; - _field48 = v2; - _field4C = v3; + _toggleR = r; + _toggleG = g; + _toggleB = b; } void CGameObject::movieSetAudioTiming(bool flag) { @@ -1429,8 +1424,8 @@ bool CGameObject::compareRoomFlags(RoomFlagsComparison compareType, uint flags1, } } -void CGameObject::setState1C(bool flag) { - getGameManager()->_gameState._field1C = flag; +void CGameObject::stateSetSoundMakerAllowed(bool flag) { + getGameManager()->_gameState._soundMakerAllowed = flag; } void CGameObject::addMail(uint destRoomFlags) { @@ -1648,9 +1643,9 @@ void CGameObject::starFn1(int v) { starControl->fn1(v); } -bool CGameObject::starFn2() { +bool CGameObject::starIsSolved() const { CStarControl *starControl = getStarControl(); - return starControl ? starControl->fn4() : false; + return starControl ? starControl->isSolved() : false; } /*------------------------------------------------------------------------*/ diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index a56095c60f..b214cf8c9e 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -77,13 +77,11 @@ private: protected: static CCreditText *_credits; protected: - double _field34; - double _field38; - double _field3C; + double _unused1; + double _unused2; + double _unused3; bool _nonvisual; - int _field44; - int _field48; - int _field4C; + byte _toggleR, _toggleG, _toggleB; CMovieClipList _movieClips; int _initialFrame; CMovieRangeInfoList _movieRangeInfoList; @@ -91,11 +89,10 @@ protected: CTextControl *_text; uint _textBorder; uint _textBorderRight; - int _field9C; Common::Point _savedPos; CVideoSurface *_surface; CString _resource; - int _fieldB8; + int _unused4; protected: /** * Saves the current position the object is located at @@ -277,7 +274,10 @@ protected: */ void setGlobalSoundVolume(int mode, uint seconds, int handleIndex); - void sound8(bool flag) const; + /** + * Stops sound channel 3 or 0 + */ + void stopSoundChannel(bool channel3); /** * Adds a timer @@ -462,7 +462,11 @@ protected: */ void setPassengerClass(PassengerClass newClass); - void fn10(int v1, int v2, int v3); + /** + * Sets color RGB for toggles + * @remarks The color set isn't actually used anywhere + */ + void setToggleColor(byte r, byte g, byte b); /** * Gets the duration of a specified clip in milliseconds @@ -523,7 +527,7 @@ public: bool _isPendingMail; uint _destRoomFlags; uint _roomFlags; - int _field60; + bool _handleMouseFlag; CursorId _cursorId; bool _visible; public: @@ -942,7 +946,11 @@ public: CStarControl *getStarControl() const; void starFn1(int v); - bool starFn2(); + + /** + * Returns true if the starmap puzzle has been solved + */ + bool starIsSolved() const; /*--- CTrueTalkManager Methods ---*/ @@ -987,7 +995,10 @@ public: /*--- CGameState Methods ---*/ - void setState1C(bool flag); + /** + * Sets whether a background sound maker is allowed for the rooms if available + */ + void stateSetSoundMakerAllowed(bool flag); /** * Change to the next season @@ -1009,8 +1020,15 @@ public: */ bool stateGetParrotMet() const; - void stateInc38(); - int stateGet38() const; + /** + * Moves the parrot to the next idle response + */ + void incParrotResponse(); + + /** + * Gets the index to use for parrot idle responses + */ + int getParrotResponse() const; /** * Gets the game state node changed counter diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp index 8bb8a92b7f..0257f6a087 100644 --- a/engines/titanic/core/saveable_object.cpp +++ b/engines/titanic/core/saveable_object.cpp @@ -955,6 +955,7 @@ DEFFN(CUseWithCharMsg); DEFFN(CUseWithOtherMsg); DEFFN(CVirtualKeyCharMsg); DEFFN(CVisibleMsg); +DEFFN(CCheckCodeWheelsMsg); DEFFN(CEnterBombRoom); DEFFN(CEnterBridge); @@ -1538,6 +1539,7 @@ void CSaveableObject::initClassList() { ADDFN(CUseWithOtherMsg, CMessage); ADDFN(CVirtualKeyCharMsg, CMessage); ADDFN(CVisibleMsg, CMessage); + ADDFN(CCheckCodeWheelsMsg, CMessage); ADDFN(CMovePlayerTo, CGameObject); ADDFN(CMovePlayerToFrom, CGameObject); diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp index 97d06d7bbe..b9b9aca67f 100644 --- a/engines/titanic/core/tree_item.cpp +++ b/engines/titanic/core/tree_item.cpp @@ -274,7 +274,7 @@ CNamedItem *CTreeItem::findByName(const CString &name, bool subMatch) { itemName.toLowercase(); if (subMatch) { - if (itemName.left(name.size()).compareTo(nameLower)) + if (!itemName.left(nameLower.size()).compareTo(nameLower)) return dynamic_cast<CNamedItem *>(treeItem); } else { if (!itemName.compareTo(nameLower)) diff --git a/engines/titanic/core/turn_on_turn_off.cpp b/engines/titanic/core/turn_on_turn_off.cpp index a6051c7c6f..3c1e623b6e 100644 --- a/engines/titanic/core/turn_on_turn_off.cpp +++ b/engines/titanic/core/turn_on_turn_off.cpp @@ -58,7 +58,7 @@ void CTurnOnTurnOff::load(SimpleFile *file) { bool CTurnOnTurnOff::TurnOn(CTurnOn *msg) { if (!_isOn) { if (_isBlocking) - playMovie(_startFrameOn, _endFrameOn, MOVIE_GAMESTATE); + playMovie(_startFrameOn, _endFrameOn, MOVIE_WAIT_FOR_FINISH); else playMovie(_startFrameOn, _endFrameOn, MOVIE_NOTIFY_OBJECT); _isOn = true; @@ -70,7 +70,7 @@ bool CTurnOnTurnOff::TurnOn(CTurnOn *msg) { bool CTurnOnTurnOff::TurnOff(CTurnOff *msg) { if (_isOn) { if (_isBlocking) - playMovie(_startFrameOff, _endFrameOff, MOVIE_GAMESTATE); + playMovie(_startFrameOff, _endFrameOff, MOVIE_WAIT_FOR_FINISH); else playMovie(_startFrameOff, _endFrameOff, MOVIE_NOTIFY_OBJECT); _isOn = false; diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp index 9109bcc5b2..15d187e194 100644 --- a/engines/titanic/core/view_item.cpp +++ b/engines/titanic/core/view_item.cpp @@ -260,7 +260,7 @@ bool CViewItem::handleMouseMsg(CMouseMsg *msg, bool flag) { CGameObject *gameObject = dynamic_cast<CGameObject *>(treeItem); if (gameObject) { if (gameObject->checkPoint(msg->_mousePos, false, true) && - (!flag || !gameObject->_field60)) { + (!flag || !gameObject->_handleMouseFlag)) { if (gameObjects.size() < 256) gameObjects.push_back(gameObject); } diff --git a/engines/titanic/game/arboretum_gate.cpp b/engines/titanic/game/arboretum_gate.cpp index 2a79c31339..903f5efb54 100644 --- a/engines/titanic/game/arboretum_gate.cpp +++ b/engines/titanic/game/arboretum_gate.cpp @@ -275,27 +275,27 @@ bool CArboretumGate::TurnOff(CTurnOff *msg) { if (!_disabled) { switch (_seasonNum) { case SEASON_SUMMER: - playMovie(_startFrameSummerOff, _endFrameSummerOff, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameSummerOff, _endFrameSummerOff, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); break; case SEASON_AUTUMN: if (_gotSpeechCentre) { - playMovie(_startFrameAutumnOff2, _endFrameAutumnOff2, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameAutumnOff2, _endFrameAutumnOff2, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); } else { - playMovie(_startFrameAutumnOff1, _endFrameAutumnOff1, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameAutumnOff1, _endFrameAutumnOff1, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); } break; case SEASON_WINTER: if (_gotSpeechCentre) { - playMovie(_startFrameWinterOff2, _endFrameWinterOff2, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameWinterOff2, _endFrameWinterOff2, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); } else { - playMovie(_startFrameWinterOff1, _endFrameWinterOff1, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameWinterOff1, _endFrameWinterOff1, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); } break; case SEASON_SPRING: - playMovie(_startFrameSpringOff, _endFrameSpringOff, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameSpringOff, _endFrameSpringOff, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); break; default: @@ -303,7 +303,7 @@ bool CArboretumGate::TurnOff(CTurnOff *msg) { } _disabled = true; - CArboretumGateMsg gateMsg; + CArboretumGateMsg gateMsg(1); gateMsg.execute("Arboretum", nullptr, MSGFLAG_SCAN); } @@ -318,27 +318,27 @@ bool CArboretumGate::TurnOn(CTurnOn *msg) { switch (_seasonNum) { case SEASON_SUMMER: - playMovie(_startFrameSummerOn, _endFrameSummerOn, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameSummerOn, _endFrameSummerOn, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); break; case SEASON_AUTUMN: if (_gotSpeechCentre) { - playMovie(_startFrameAutumnOn2, _endFrameAutumnOn2, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameAutumnOn2, _endFrameAutumnOn2, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); } else { - playMovie(_startFrameAutumnOn1, _endFrameAutumnOn1, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameAutumnOn1, _endFrameAutumnOn1, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); } break; case SEASON_WINTER: if (_gotSpeechCentre) { - playMovie(_startFrameWinterOn2, _endFrameWinterOn2, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameWinterOn2, _endFrameWinterOn2, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); } else { - playMovie(_startFrameWinterOn1, _endFrameWinterOn1, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameWinterOn1, _endFrameWinterOn1, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); } break; case SEASON_SPRING: - playMovie(_startFrameSpringOn, _endFrameSpringOn, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameSpringOn, _endFrameSpringOn, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); break; default: diff --git a/engines/titanic/game/bomb.cpp b/engines/titanic/game/bomb.cpp index f3f1129e22..17c10c5082 100644 --- a/engines/titanic/game/bomb.cpp +++ b/engines/titanic/game/bomb.cpp @@ -21,6 +21,7 @@ */ #include "titanic/game/bomb.h" +#include "titanic/game/code_wheel.h" namespace Titanic { @@ -36,19 +37,19 @@ BEGIN_MESSAGE_MAP(CBomb, CBackground) ON_MESSAGE(SetFrameMsg) END_MESSAGE_MAP() -static const char *const WAVE_NAMES1[] = { - "z#353.wav", "z#339.wav", "z#325.wav", "z#311.wav", "z#297.wav", +const int CORRECT_WHEELS = 23; + +static const char *const HUNDREDS_WAVS[] = { + "", "z#353.wav", "z#339.wav", "z#325.wav", "z#311.wav", "z#297.wav", "z#283.wav", "z#269.wav", "z#255.wav", "z#241.wav" }; -static const char *const WAVE_NAMES2[] = { +static const char *const HUNDREDS_AND_WAVS[] = { "", "z#352.wav", "z#338.wav", "z#324.wav", "z#310.wav", "z#296.wav", - "z#281.wav", "z#268.wav", "z#254.wav", "z#240.wav", "", "z#351.wav", - "z#337.wav", "z#323.wav", "z#309.wav", "z#295.wav", "z#282.wav", - "z#267.wav", "z#253.wav", "z#239.wav" + "z#281.wav", "z#268.wav", "z#254.wav", "z#240.wav" }; -static const char *const WAVE_NAMES3[100] = { +static const char *const COUNTDOWN_WAVS[100] = { "bombcountdown_c0.wav", "z#355.wav", "z#341.wav", "z#327.wav", "z#313.wav", "z#299.wav", "z#285.wav", "z#271.wav", "z#257.wav", "z#243.wav", "z#354.wav", "z#350.wav", "z#349.wav", "z#348.wav", "z#347.wav", @@ -72,28 +73,28 @@ static const char *const WAVE_NAMES3[100] = { }; CBomb::CBomb() : CBackground() { - _fieldE0 = 0; - _fieldE4 = 0; - _fieldE8 = 17; - _fieldEC = 9; - _fieldF0 = 0; + _active = false; + _numCorrectWheels = 0; + _tappedCtr = 17; + _hammerCtr = 9; + _commentCtr = 0; _countdown = 999; _soundHandle = 0; - _fieldFC = 0; + _unusedHandle = 0; _startingTicks = 0; _volume = 60; } void CBomb::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_fieldE8, indent); - file->writeNumberLine(_fieldEC, indent); - file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_active, indent); + file->writeNumberLine(_numCorrectWheels, indent); + file->writeNumberLine(_tappedCtr, indent); + file->writeNumberLine(_hammerCtr, indent); + file->writeNumberLine(_commentCtr, indent); file->writeNumberLine(_countdown, indent); file->writeNumberLine(_soundHandle, indent); - file->writeNumberLine(_fieldFC, indent); + file->writeNumberLine(_unusedHandle, indent); file->writeNumberLine(_startingTicks, indent); file->writeNumberLine(_volume, indent); @@ -102,14 +103,14 @@ void CBomb::save(SimpleFile *file, int indent) { void CBomb::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); - _fieldE8 = file->readNumber(); - _fieldEC = file->readNumber(); - _fieldF0 = file->readNumber(); + _active = file->readNumber(); + _numCorrectWheels = file->readNumber(); + _tappedCtr = file->readNumber(); + _hammerCtr = file->readNumber(); + _commentCtr = file->readNumber(); _countdown = file->readNumber(); _soundHandle = file->readNumber(); - _fieldFC = file->readNumber(); + _unusedHandle = file->readNumber(); _startingTicks = file->readNumber(); _volume = file->readNumber(); @@ -117,34 +118,39 @@ void CBomb::load(SimpleFile *file) { } bool CBomb::StatusChangeMsg(CStatusChangeMsg *msg) { - _fieldE4 += msg->_newStatus; + // Check whether the wheels are corect + CCheckCodeWheelsMsg checkMsg; + checkMsg.execute(findRoom(), nullptr, MSGFLAG_SCAN); + + _numCorrectWheels = checkMsg._isCorrect ? CORRECT_WHEELS : 0; - if (_fieldE4 == 23) { + if (_numCorrectWheels == CORRECT_WHEELS) { + // Nobody likes a smartass startAnimTimer("Disarmed", 2000); lockMouse(); } - _fieldF0 %= 1000; - if (!(_fieldF0 % 20) && _countdown < 995) { + _commentCtr = (_commentCtr % 1000) + 1; + if (!(_commentCtr % 20) && _countdown < 995) { int val = getRandomNumber(5) + 25; - if (_fieldF0 < 20 || _fieldF0 > 80) + if (_commentCtr < 20 || _commentCtr > 80) val = 28; CString name; - switch (val - 25) { - case 0: + switch (val) { + case 25: name = "z#372.wav"; break; - case 1: + case 26: name = "z#371.wav"; break; - case 2: + case 27: name = "z#370.wav"; break; - case 3: + case 28: name = "z#369.wav"; break; - case 4: + case 29: name = "z#368.wav"; break; default: @@ -159,20 +165,22 @@ bool CBomb::StatusChangeMsg(CStatusChangeMsg *msg) { } bool CBomb::EnterViewMsg(CEnterViewMsg *msg) { - _fieldE4 = 2; + // WORKAROUND: Don't keep resetting wheels return true; } bool CBomb::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { playSound("z#62.wav"); - if (_fieldE0) { + if (_active) { stopSound(_soundHandle); - if (_fieldE4 < 23) { - _fieldE8 = MIN(_fieldE8 + 1, 23); + //stopSound(_unusedHandle); + + if (_numCorrectWheels < CORRECT_WHEELS) { + _tappedCtr = MIN(_tappedCtr + 1, 23); CString name; - switch (_fieldE8) { + switch (_tappedCtr) { case 18: name = "z#380.wav"; break; @@ -198,7 +206,7 @@ bool CBomb::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { } } else { _soundHandle = playSound("z#389.wav", _volume); - _fieldE0 = true; + _active = true; CActMsg actMsg("Arm Bomb"); actMsg.execute("EndExplodeShip"); } @@ -207,9 +215,9 @@ bool CBomb::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { } bool CBomb::EnterRoomMsg(CEnterRoomMsg *msg) { - _fieldE8 = 17; - _fieldEC = 9; - _fieldF0 = 0; + _tappedCtr = 17; + _hammerCtr = 9; + _commentCtr = 0; _startingTicks = getTicksCount(); return true; } @@ -219,11 +227,11 @@ bool CBomb::ActMsg(CActMsg *msg) { playSound("z#63.wav"); stopSound(_soundHandle); - if (_fieldEC < 17) - ++_fieldEC; + if (_hammerCtr < 17) + ++_hammerCtr; CString name; - switch (_fieldEC) { + switch (_hammerCtr) { case 10: name = "z#388.wav"; break; @@ -258,9 +266,19 @@ bool CBomb::ActMsg(CActMsg *msg) { } bool CBomb::TurnOn(CTurnOn *msg) { - if (!_fieldE0) { + if (!_active) { _soundHandle = playSound("z#389.wav", _volume); - _fieldE0 = true; + _active = true; + + // WORKAROUND: Only reset the code wheels back to 'O' value + // when first arming the bomb, not whenever the bomb view is entered + _numCorrectWheels = 2; + CRoomItem *room = findRoom(); + for (CTreeItem *treeItem = room; treeItem; treeItem = treeItem->scan(room)) { + CodeWheel *codeWheel = dynamic_cast<CodeWheel *>(treeItem); + if (codeWheel) + codeWheel->reset(); + } CActMsg actMsg("Arm Bomb"); actMsg.execute("EndExplodeShip"); @@ -282,7 +300,7 @@ bool CBomb::TimerMsg(CTimerMsg *msg) { CActMsg actMsg1("Disarm Bomb"); actMsg1.execute("EndExplodeShip"); - _fieldE0 = false; + _active = false; CActMsg actMsg2("Titania.Node 5.N"); actMsg2.execute("BombNav"); actMsg2.execute("EnterBombNav"); @@ -294,49 +312,54 @@ bool CBomb::TimerMsg(CTimerMsg *msg) { if (compareRoomNameTo("Titania")) { if (msg->_actionVal == 1 && getRandomNumber(9) == 0) { - if (!_fieldE0) + if (!_active) return true; CParrotSpeakMsg speakMsg("Bomb", "BombCountdown"); speakMsg.execute("PerchedParrot"); } - if (_fieldE0) { - if (isSoundActive(_soundHandle)) { + if (_active) { + if (!isSoundActive(_soundHandle)) { if (msg->_actionVal == 0) { addTimer(1, 1000, 0); } else { _soundHandle = 0; - int section = _countdown / 100; - int index = _countdown % 100; + int hundreds = _countdown / 100; + int remainder = _countdown % 100; if (_countdown >= 100) { - CString name1 = index ? WAVE_NAMES2[section] : - WAVE_NAMES1[section]; - playSound(name1, _volume); + // Play "x hundred and" or just "x hundred" + CString hName = remainder ? HUNDREDS_AND_WAVS[hundreds] : HUNDREDS_WAVS[hundreds]; + _soundHandle = playSound(hName, _volume); } - CString name2 = WAVE_NAMES3[index]; + CString ctrName = COUNTDOWN_WAVS[remainder]; if (_countdown == 10) { - name2 = "z#229.wav"; + ctrName = "z#229.wav"; _countdown = 998; } + // Play the sub-hundred portion of the countdown amount if (_soundHandle > 0) { - _soundHandle = queueSound(name2, _soundHandle, _volume); + _soundHandle = queueSound(ctrName, _soundHandle, _volume); } else { - _soundHandle = playSound(name2, _volume); + _soundHandle = playSound(ctrName, _volume); } + // Reduce countdown and schedule another timer --_countdown; addTimer(0, 1000, 0); } } else { + // Bomb speech currently active, so schedule the method' + // to re-trigger after 100ms to check if speech is finished addTimer(0, 100, 0); } } } else { - if (_fieldE0) { + // In rooms other than the bomb room + if (_active) { --_countdown; addTimer(6000); @@ -350,7 +373,7 @@ bool CBomb::TimerMsg(CTimerMsg *msg) { bool CBomb::TrueTalkGetStateValueMsg(CTrueTalkGetStateValueMsg *msg) { if (msg->_stateNum == 10) - msg->_stateVal = _fieldE0; + msg->_stateVal = _active ? 1 : 0; return true; } diff --git a/engines/titanic/game/bomb.h b/engines/titanic/game/bomb.h index f78c42cff0..c474abf554 100644 --- a/engines/titanic/game/bomb.h +++ b/engines/titanic/game/bomb.h @@ -40,14 +40,14 @@ class CBomb : public CBackground { bool SetFrameMsg(CSetFrameMsg *msg); DECLARE_MESSAGE_MAP; private: - int _fieldE0; - int _fieldE4; - int _fieldE8; - int _fieldEC; - int _fieldF0; + bool _active; + int _numCorrectWheels; + int _tappedCtr; + int _hammerCtr; + int _commentCtr; int _countdown; int _soundHandle; - int _fieldFC; + int _unusedHandle; int _startingTicks; int _volume; public: diff --git a/engines/titanic/game/brain_slot.cpp b/engines/titanic/game/brain_slot.cpp index 1518d9b0b3..c0eb145d59 100644 --- a/engines/titanic/game/brain_slot.cpp +++ b/engines/titanic/game/brain_slot.cpp @@ -33,14 +33,14 @@ BEGIN_MESSAGE_MAP(CBrainSlot, CGameObject) ON_MESSAGE(MouseDragStartMsg) END_MESSAGE_MAP() -int CBrainSlot::_added; +int CBrainSlot::_numAdded; bool CBrainSlot::_woken; void CBrainSlot::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value1, indent); + file->writeNumberLine(_occupied, indent); file->writeQuotedLine(_target, indent); - file->writeNumberLine(_added, indent); + file->writeNumberLine(_numAdded, indent); file->writeNumberLine(_woken, indent); CGameObject::save(file, indent); @@ -48,9 +48,9 @@ void CBrainSlot::save(SimpleFile *file, int indent) { void CBrainSlot::load(SimpleFile *file) { file->readNumber(); - _value1 = file->readNumber(); + _occupied = file->readNumber(); _target = file->readString(); - _added = file->readNumber(); + _numAdded = file->readNumber(); _woken = file->readNumber(); CGameObject::load(file); @@ -58,12 +58,12 @@ void CBrainSlot::load(SimpleFile *file) { bool CBrainSlot::SetFrameMsg(CSetFrameMsg *msg) { loadFrame(msg->_frameNumber); - _value1 = 1; + _occupied = true; return true; } bool CBrainSlot::AddHeadPieceMsg(CAddHeadPieceMsg *msg) { - _added = 1; + _numAdded++; _cursorId = CURSOR_HAND; CAddHeadPieceMsg addMsg("NULL"); @@ -87,21 +87,21 @@ bool CBrainSlot::AddHeadPieceMsg(CAddHeadPieceMsg *msg) { if (addMsg._value != "NULL") addMsg.execute("TitaniaControl"); - if (addMsg._value == "OlfactoryCentre") + if (msg->_value == "OlfactoryCentre") loadFrame(2); - else if (addMsg._value == "AuditoryCentre") + else if (msg->_value == "AuditoryCentre") loadFrame(1); - else if (addMsg._value == "SpeechCentre") + else if (msg->_value == "SpeechCentre") loadFrame(3); - else if (addMsg._value == "VisionCentre") + else if (msg->_value == "VisionCentre") loadFrame(4); - else if (addMsg._value == "CentralCore") { + else if (msg->_value == "CentralCore") { CActMsg actMsg("Insert Central Core"); actMsg.execute("CentralCoreSlot"); } _target = msg->_value; - _value1 = 1; + _occupied = true; return true; } @@ -124,7 +124,7 @@ bool CBrainSlot::ActMsg(CActMsg *msg) { } bool CBrainSlot::MouseDragStartMsg(CMouseDragStartMsg *msg) { - if (!_value1 || _woken || !checkPoint(msg->_mousePos, false, true)) + if (!_occupied || _woken || !checkPoint(msg->_mousePos, false, true)) return false; _cursorId = CURSOR_ARROW; @@ -134,14 +134,14 @@ bool CBrainSlot::MouseDragStartMsg(CMouseDragStartMsg *msg) { takeMsg.execute("TitaniaControl"); loadFrame(isEquals("CentralCoreSlot") ? 21 : 0); - _value1 = 0; + _occupied = false; CPassOnDragStartMsg passMsg; passMsg._mousePos = msg->_mousePos; passMsg.execute(_target); msg->_dragItem = getRoot()->findByName(_target); - _added = 0; + _numAdded--; return true; } diff --git a/engines/titanic/game/brain_slot.h b/engines/titanic/game/brain_slot.h index 4d500cc59a..a85036303e 100644 --- a/engines/titanic/game/brain_slot.h +++ b/engines/titanic/game/brain_slot.h @@ -35,14 +35,14 @@ class CBrainSlot : public CGameObject { bool ActMsg(CActMsg *msg); bool MouseDragStartMsg(CMouseDragStartMsg *msg); public: - static int _added; + static int _numAdded; static bool _woken; public: - int _value1; + bool _occupied; CString _target; public: CLASSDEF; - CBrainSlot() : CGameObject(), _value1(0) {} + CBrainSlot() : CGameObject(), _occupied(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/bridge_view.cpp b/engines/titanic/game/bridge_view.cpp index 5b2b8809d9..e8d70c8c43 100644 --- a/engines/titanic/game/bridge_view.cpp +++ b/engines/titanic/game/bridge_view.cpp @@ -31,13 +31,13 @@ END_MESSAGE_MAP() void CBridgeView::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_mode, indent); + file->writeNumberLine(_action, indent); CBackground::save(file, indent); } void CBridgeView::load(SimpleFile *file) { file->readNumber(); - _mode = file->readNumber(); + _action = (BridgeAction)file->readNumber(); CBackground::load(file); } @@ -47,13 +47,13 @@ bool CBridgeView::ActMsg(CActMsg *msg) { volumeMsg._secondsTransition = 1; if (msg->_action == "End") { - _mode = 4; + _action = BA_ENDING2; petLockInput(); petHide(); setVisible(true); playMovie(MOVIE_NOTIFY_OBJECT); } else if (msg->_action == "Go") { - _mode = 1; + _action = BA_GO; setVisible(true); volumeMsg._volume = 100; volumeMsg.execute("EngineSounds"); @@ -65,11 +65,11 @@ bool CBridgeView::ActMsg(CActMsg *msg) { onMsg.execute("EngineSounds"); if (msg->_action == "Cruise") { - _mode = 2; + _action = BA_CRUISE; setVisible(true); playMovie(MOVIE_NOTIFY_OBJECT); - } else if (msg->_action == "GoENd") { - _mode = 3; + } else if (msg->_action == "GoEnd") { + _action = BA_ENDING1; setVisible(true); CChangeMusicMsg musicMsg; musicMsg._flags = 1; @@ -86,21 +86,21 @@ bool CBridgeView::MovieEndMsg(CMovieEndMsg *msg) { CTurnOff offMsg; offMsg.execute("EngineSounds"); - switch (_mode) { - case 0: - case 1: + switch (_action) { + case BA_GO: + case BA_CRUISE: setVisible(false); decTransitions(); break; - case 2: { + case BA_ENDING1: { setVisible(false); CActMsg actMsg("End"); actMsg.execute("HomeSequence"); break; } - case 3: + case BA_ENDING2: setVisible(false); changeView("TheEnd.Node 3.N"); break; diff --git a/engines/titanic/game/bridge_view.h b/engines/titanic/game/bridge_view.h index 45cfa3f4c8..01bd6310ce 100644 --- a/engines/titanic/game/bridge_view.h +++ b/engines/titanic/game/bridge_view.h @@ -27,15 +27,19 @@ namespace Titanic { +enum BridgeAction { + BA_NONE = 0, BA_GO = 1, BA_CRUISE = 2, BA_ENDING1 = 3, BA_ENDING2 = 4 +}; + class CBridgeView : public CBackground { DECLARE_MESSAGE_MAP; bool ActMsg(CActMsg *msg); bool MovieEndMsg(CMovieEndMsg *msg); public: - int _mode; + BridgeAction _action; public: CLASSDEF; - CBridgeView() : CBackground(), _mode(0) {} + CBridgeView() : CBackground(), _action(BA_NONE) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/captains_wheel.cpp b/engines/titanic/game/captains_wheel.cpp index 72d3cf70d9..1f0b177a67 100644 --- a/engines/titanic/game/captains_wheel.cpp +++ b/engines/titanic/game/captains_wheel.cpp @@ -34,17 +34,17 @@ BEGIN_MESSAGE_MAP(CCaptainsWheel, CBackground) END_MESSAGE_MAP() CCaptainsWheel::CCaptainsWheel() : CBackground(), - _fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0), - _fieldF0(0), _fieldF4(0) { + _stopEnabled(false), _actionNum(0), _fieldE8(0), + _cruiseEnabled(false), _goEnabled(false), _fieldF4(0) { } void CCaptainsWheel::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_stopEnabled, indent); + file->writeNumberLine(_actionNum, indent); file->writeNumberLine(_fieldE8, indent); - file->writeNumberLine(_fieldEC, indent); - file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_cruiseEnabled, indent); + file->writeNumberLine(_goEnabled, indent); file->writeNumberLine(_fieldF4, indent); CBackground::save(file, indent); @@ -52,19 +52,19 @@ void CCaptainsWheel::save(SimpleFile *file, int indent) { void CCaptainsWheel::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); + _stopEnabled = file->readNumber(); + _actionNum = file->readNumber(); _fieldE8 = file->readNumber(); - _fieldEC = file->readNumber(); - _fieldF0 = file->readNumber(); + _cruiseEnabled = file->readNumber(); + _goEnabled = file->readNumber(); _fieldF4 = file->readNumber(); CBackground::load(file); } bool CCaptainsWheel::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { - if (_fieldE0) { - _fieldE0 = false; + if (_stopEnabled) { + _stopEnabled = false; CTurnOff offMsg; offMsg.execute(this); playMovie(162, 168, 0); @@ -76,11 +76,11 @@ bool CCaptainsWheel::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { } bool CCaptainsWheel::LeaveViewMsg(CLeaveViewMsg *msg) { - if (_fieldE0) { - _fieldE0 = false; + if (_stopEnabled) { + _stopEnabled = false; CTurnOff offMsg; offMsg.execute(this); - playMovie(162, 168, MOVIE_GAMESTATE); + playMovie(162, 168, MOVIE_WAIT_FOR_FINISH); } return true; @@ -88,34 +88,34 @@ bool CCaptainsWheel::LeaveViewMsg(CLeaveViewMsg *msg) { bool CCaptainsWheel::ActMsg(CActMsg *msg) { if (msg->_action == "Spin") { - if (_fieldE0) { + if (_stopEnabled) { CTurnOn onMsg; onMsg.execute("RatchetySound"); - playMovie(8, 142, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(8, 142, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } } else if (msg->_action == "Honk") { - if (_fieldE0) { - playMovie(150, 160, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + if (_stopEnabled) { + playMovie(150, 160, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } } else if (msg->_action == "Go") { - if (!_fieldE0) { + if (!_stopEnabled) { incTransitions(); - _fieldE0 = false; - _fieldE4 = 1; + _stopEnabled = false; + _actionNum = 1; CTurnOff offMsg; offMsg.execute(this); - playMovie(162, 168, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(162, 168, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } } else if (msg->_action == "Cruise") { - if (_fieldE0) { + if (_stopEnabled) { incTransitions(); - _fieldE0 = false; - _fieldE4 = 2; + _stopEnabled = false; + _actionNum = 2; CTurnOff offMsg; offMsg.execute(this); - playMovie(162, 168, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(162, 168, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } } else if (msg->_action == "SetDestin") { playSound("a#44.wav"); @@ -124,9 +124,9 @@ bool CCaptainsWheel::ActMsg(CActMsg *msg) { volumeMsg.execute("EngineSounds"); CTurnOn onMsg; onMsg.execute("EngineSounds"); - _fieldF0 = 1; + _goEnabled = true; } else if (msg->_action == "ClearDestin") { - _fieldF0 = 0; + _goEnabled = false; } return true; @@ -152,17 +152,17 @@ bool CCaptainsWheel::TurnOn(CTurnOn *msg) { signalMsg.execute("WheelSpin"); signalMsg.execute("SeagullHorn"); - if (_fieldE0) { + if (_stopEnabled) { signalMsg.execute("WheelStopButt"); signalMsg.execute("StopHotSpot"); } - if (_fieldEC) { + if (_cruiseEnabled) { signalMsg.execute("WheelCruiseButt"); signalMsg.execute("CruiseHotSpot"); } - if (_fieldF0) { + if (_goEnabled) { signalMsg.execute("WheelGoButt"); signalMsg.execute("GoHotSpot"); } @@ -172,7 +172,7 @@ bool CCaptainsWheel::TurnOn(CTurnOn *msg) { bool CCaptainsWheel::MovieEndMsg(CMovieEndMsg *msg) { if (msg->_endFrame == 8) { - _fieldE0 = true; + _stopEnabled = true; CTurnOn onMsg; onMsg.execute(this); } @@ -183,9 +183,9 @@ bool CCaptainsWheel::MovieEndMsg(CMovieEndMsg *msg) { } if (msg->_endFrame == 168) { - switch (_fieldE4) { + switch (_actionNum) { case 1: { - CActMsg actMsg(starFn2() ? "GoEnd" : "Go"); + CActMsg actMsg(starIsSolved() ? "GoEnd" : "Go"); actMsg.execute("GoSequence"); break; } @@ -200,7 +200,7 @@ bool CCaptainsWheel::MovieEndMsg(CMovieEndMsg *msg) { break; } - _fieldE4 = 0; + _actionNum = 0; } return true; diff --git a/engines/titanic/game/captains_wheel.h b/engines/titanic/game/captains_wheel.h index 3aca45c21f..7dce1ac6ee 100644 --- a/engines/titanic/game/captains_wheel.h +++ b/engines/titanic/game/captains_wheel.h @@ -36,11 +36,11 @@ class CCaptainsWheel : public CBackground { bool TurnOn(CTurnOn *msg); bool MovieEndMsg(CMovieEndMsg *msg); public: - int _fieldE0; - int _fieldE4; + bool _stopEnabled; + int _actionNum; int _fieldE8; - int _fieldEC; - int _fieldF0; + bool _cruiseEnabled; + bool _goEnabled; int _fieldF4; public: CLASSDEF; diff --git a/engines/titanic/game/cdrom.cpp b/engines/titanic/game/cdrom.cpp index 0d1cd3a6f2..d8d31ecc1a 100644 --- a/engines/titanic/game/cdrom.cpp +++ b/engines/titanic/game/cdrom.cpp @@ -38,21 +38,21 @@ CCDROM::CCDROM() : CGameObject() { void CCDROM::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writePoint(_tempPos, indent); + file->writePoint(_centroid, indent); CGameObject::save(file, indent); } void CCDROM::load(SimpleFile *file) { file->readNumber(); - _tempPos = file->readPoint(); + _centroid = file->readPoint(); CGameObject::load(file); } bool CCDROM::MouseDragStartMsg(CMouseDragStartMsg *msg) { if (checkStartDragging(msg)) { hideMouse(); - _tempPos = msg->_mousePos - _bounds; - setPosition(msg->_mousePos - _tempPos); + _centroid = msg->_mousePos - _bounds; + setPosition(msg->_mousePos - _centroid); return true; } else { return false; @@ -77,7 +77,7 @@ bool CCDROM::MouseDragEndMsg(CMouseDragEndMsg *msg) { } bool CCDROM::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { - setPosition(msg->_mousePos - _tempPos); + setPosition(msg->_mousePos - _centroid); return true; } diff --git a/engines/titanic/game/cdrom.h b/engines/titanic/game/cdrom.h index 017914830c..12175f6450 100644 --- a/engines/titanic/game/cdrom.h +++ b/engines/titanic/game/cdrom.h @@ -36,7 +36,7 @@ class CCDROM : public CGameObject { bool MouseDragMoveMsg(CMouseDragMoveMsg *msg); bool ActMsg(CActMsg *msg); private: - Point _tempPos; + Point _centroid; public: CLASSDEF; CCDROM(); diff --git a/engines/titanic/game/chicken_dispensor.cpp b/engines/titanic/game/chicken_dispensor.cpp index 8a56f43fff..89873dcc4d 100644 --- a/engines/titanic/game/chicken_dispensor.cpp +++ b/engines/titanic/game/chicken_dispensor.cpp @@ -89,10 +89,10 @@ bool CChickenDispensor::StatusChangeMsg(CStatusChangeMsg *msg) { setVisible(true); if (_disabled) { - playMovie(0, 12, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(0, 12, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); playSound("z#400.wav"); } else { - playMovie(12, 16, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(12, 16, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } break; @@ -186,7 +186,7 @@ bool CChickenDispensor::MouseDragStartMsg(CMouseDragStartMsg *msg) { bool CChickenDispensor::TurnOff(CTurnOff *msg) { if (getMovieFrame() != 16) setVisible(false); - playMovie(16, 12, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(16, 12, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _dispensed = false; return true; diff --git a/engines/titanic/game/code_wheel.cpp b/engines/titanic/game/code_wheel.cpp index 441fddec02..1df99ae749 100644 --- a/engines/titanic/game/code_wheel.cpp +++ b/engines/titanic/game/code_wheel.cpp @@ -30,17 +30,25 @@ BEGIN_MESSAGE_MAP(CodeWheel, CBomb) ON_MESSAGE(EnterViewMsg) ON_MESSAGE(MouseButtonUpMsg) ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(CheckCodeWheelsMsg) END_MESSAGE_MAP() -CodeWheel::CodeWheel() : CBomb(), _field108(0), _state(4), - _field110(0), _field114(0), _field118(0) { +static const int START_FRAMES[15] = { + 0, 5, 10, 15, 19, 24, 28, 33, 38, 42, 47, 52, 57, 61, 66 +}; +static const int END_FRAMES[15] = { + 5, 10, 15, 19, 24, 28, 33, 38, 42, 47, 52, 57, 61, 66, 70 +}; + +CodeWheel::CodeWheel() : CBomb(), _correctValue(0), _value(4), + _matched(false), _field114(0), _field118(0) { } void CodeWheel::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_field108, indent); - file->writeNumberLine(_state, indent); - file->writeNumberLine(_field110, indent); + file->writeNumberLine(_correctValue, indent); + file->writeNumberLine(_value, indent); + file->writeNumberLine(_matched, indent); if (g_vm->isGerman()) { file->writeNumberLine(_field114, indent); file->writeNumberLine(_field118, indent); @@ -51,9 +59,9 @@ void CodeWheel::save(SimpleFile *file, int indent) { void CodeWheel::load(SimpleFile *file) { file->readNumber(); - _field108 = file->readNumber(); - _state = file->readNumber(); - _field110 = file->readNumber(); + _correctValue = file->readNumber(); + _value = file->readNumber(); + _matched = file->readNumber(); if (g_vm->isGerman()) { _field114 = file->readNumber(); _field118 = file->readNumber(); @@ -63,29 +71,24 @@ void CodeWheel::load(SimpleFile *file) { } bool CodeWheel::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { - static const int START_FRAMES[15] = { - 0, 5, 10, 15, 19, 24, 28, 33, 38, 42, 47, 52, 57, 61, 66 - }; - static const int END_FRAMES[15] = { - 5, 10, 15, 19, 24, 28, 33, 38, 42, 47, 52, 57, 61, 66, 70 - }; - int yp = _bounds.top + _bounds.height() / 2; + _matched = false; + if (msg->_mousePos.y > yp) { - if (_state == _field108) - _field110 = true; + if (_value == _correctValue) + _matched = true; - _state = (_state + 1) % 15; - playMovie(START_FRAMES[_state], END_FRAMES[_state], - MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + _value = (_value + 1) % 15; + playMovie(START_FRAMES[_value], END_FRAMES[_value], + MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); } else { - if (_state == _field108) - _field110 = true; + if (_value == _correctValue) + _matched = true; - playMovie(START_FRAMES[14 - _state] + 68, END_FRAMES[14 - _state] + 68, - MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(START_FRAMES[14 - _value] + 68, END_FRAMES[14 - _value] + 68, + MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); - _state = (_state <= 0) ? 14 : _state - 1; + _value = (_value <= 0) ? 14 : _value - 1; } playSound("z#59.wav"); @@ -93,8 +96,8 @@ bool CodeWheel::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { } bool CodeWheel::EnterViewMsg(CEnterViewMsg *msg) { - loadFrame(24); - _state = 4; + // WORKAROUND: Don't keep resetting code wheels back to default + loadFrame(END_FRAMES[_value]); return true; } @@ -104,15 +107,18 @@ bool CodeWheel::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { bool CodeWheel::MovieEndMsg(CMovieEndMsg *msg) { sleep(200); + + // Signal that a code wheel has changed CStatusChangeMsg changeMsg; - changeMsg._newStatus = 0; - if (_field110) - changeMsg._newStatus = -1; - if (_field108 == _state) - changeMsg._newStatus = 1; changeMsg.execute("Bomb"); return true; } +bool CodeWheel::CheckCodeWheelsMsg(CCheckCodeWheelsMsg *msg) { + if (_value != _correctValue) + msg->_isCorrect = false; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/code_wheel.h b/engines/titanic/game/code_wheel.h index de246f56c4..3d19eeb53c 100644 --- a/engines/titanic/game/code_wheel.h +++ b/engines/titanic/game/code_wheel.h @@ -33,10 +33,11 @@ class CodeWheel : public CBomb { bool EnterViewMsg(CEnterViewMsg *msg); bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); bool MovieEndMsg(CMovieEndMsg *msg); + bool CheckCodeWheelsMsg(CCheckCodeWheelsMsg *msg); private: - int _field108; - int _state; - int _field110; + int _correctValue; + int _value; + bool _matched; // German specific fields int _field114; int _field118; @@ -53,6 +54,11 @@ public: * Load the data for the class from file */ virtual void load(SimpleFile *file); + + /** + * Resets a code wheel back to the default 'O' value + */ + void reset() { _value = 4; } }; } // End of namespace Titanic diff --git a/engines/titanic/game/computer_screen.cpp b/engines/titanic/game/computer_screen.cpp index 98bef6eb63..7d549d0497 100644 --- a/engines/titanic/game/computer_screen.cpp +++ b/engines/titanic/game/computer_screen.cpp @@ -47,10 +47,10 @@ void CComputerScreen::load(SimpleFile *file) { bool CComputerScreen::ActMsg(CActMsg *msg) { if (msg->_action == "newCD1" || msg->_action == "newCD2") { - playMovie(27, 53, MOVIE_GAMESTATE); - playMovie(19, 26, MOVIE_GAMESTATE); + playMovie(27, 53, MOVIE_WAIT_FOR_FINISH); + playMovie(19, 26, MOVIE_WAIT_FOR_FINISH); } else if (msg->_action == "newSTCD") { - playMovie(0, 18, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(0, 18, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); } return true; diff --git a/engines/titanic/game/end_sequence_control.cpp b/engines/titanic/game/end_sequence_control.cpp index 033a7752a3..0f3a97c3a2 100644 --- a/engines/titanic/game/end_sequence_control.cpp +++ b/engines/titanic/game/end_sequence_control.cpp @@ -77,7 +77,7 @@ bool CEndSequenceControl::EnterRoomMsg(CEnterRoomMsg *msg) { bool CEndSequenceControl::EnterViewMsg(CEnterViewMsg *msg) { movieSetAudioTiming(true); - playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); return true; } diff --git a/engines/titanic/game/fan_control.cpp b/engines/titanic/game/fan_control.cpp index ca664764ea..7ed22fd560 100644 --- a/engines/titanic/game/fan_control.cpp +++ b/engines/titanic/game/fan_control.cpp @@ -121,7 +121,7 @@ bool CFanControl::StatusChangeMsg(CStatusChangeMsg *msg) { // It's puret time incTransitions(); _starlingsDying = true; - playMovie(12, 18, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(12, 18, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } else { playMovie(12, 18, 0); } diff --git a/engines/titanic/game/games_console.cpp b/engines/titanic/game/games_console.cpp index 40311f70ee..6c13f4b862 100644 --- a/engines/titanic/game/games_console.cpp +++ b/engines/titanic/game/games_console.cpp @@ -56,7 +56,7 @@ bool CGamesConsole::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { bool CGamesConsole::LeaveViewMsg(CLeaveViewMsg *msg) { if (_active) { _active = false; - playMovie(23, 44, MOVIE_GAMESTATE); + playMovie(23, 44, MOVIE_WAIT_FOR_FINISH); } return true; diff --git a/engines/titanic/game/glass_smasher.cpp b/engines/titanic/game/glass_smasher.cpp index 2123f2dfd0..7de034c2ee 100644 --- a/engines/titanic/game/glass_smasher.cpp +++ b/engines/titanic/game/glass_smasher.cpp @@ -42,7 +42,7 @@ void CGlassSmasher::load(SimpleFile *file) { bool CGlassSmasher::StatusChangeMsg(CStatusChangeMsg *msg) { setVisible(true); playSound("b#40.wav"); - playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); return true; } diff --git a/engines/titanic/game/gondolier/gondolier_base.cpp b/engines/titanic/game/gondolier/gondolier_base.cpp index f3dc31c9f5..8b753ec264 100644 --- a/engines/titanic/game/gondolier/gondolier_base.cpp +++ b/engines/titanic/game/gondolier/gondolier_base.cpp @@ -28,45 +28,45 @@ BEGIN_MESSAGE_MAP(CGondolierBase, CGameObject) ON_MESSAGE(PuzzleSolvedMsg) END_MESSAGE_MAP() -int CGondolierBase::_v1; +bool CGondolierBase::_chestOpen; bool CGondolierBase::_puzzleSolved; int CGondolierBase::_volume1; int CGondolierBase::_v4; -int CGondolierBase::_v5; int CGondolierBase::_volume2; int CGondolierBase::_v7; -int CGondolierBase::_v8; -int CGondolierBase::_v9; -int CGondolierBase::_v10; +bool CGondolierBase::_rightSliderHooked; +bool CGondolierBase::_leftSliderHooked; +bool CGondolierBase::_priorLeftSliderHooked; +bool CGondolierBase::_priorRightSliderHooked; void CGondolierBase::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_v1, indent); + file->writeNumberLine(_chestOpen, indent); file->writeNumberLine(_puzzleSolved, indent); file->writeNumberLine(_volume1, indent); file->writeNumberLine(_v4, indent); - file->writeNumberLine(_v5, indent); + file->writeNumberLine(_rightSliderHooked, indent); file->writeNumberLine(_volume2, indent); file->writeNumberLine(_v7, indent); - file->writeNumberLine(_v8, indent); - file->writeNumberLine(_v9, indent); - file->writeNumberLine(_v10, indent); + file->writeNumberLine(_leftSliderHooked, indent); + file->writeNumberLine(_priorLeftSliderHooked, indent); + file->writeNumberLine(_priorRightSliderHooked, indent); CGameObject::save(file, indent); } void CGondolierBase::load(SimpleFile *file) { file->readNumber(); - _v1 = file->readNumber(); + _chestOpen = file->readNumber(); _puzzleSolved = file->readNumber(); _volume1 = file->readNumber(); _v4 = file->readNumber(); - _v5 = file->readNumber(); + _rightSliderHooked = file->readNumber(); _volume2 = file->readNumber(); _v7 = file->readNumber(); - _v8 = file->readNumber(); - _v9 = file->readNumber(); - _v10 = file->readNumber(); + _leftSliderHooked = file->readNumber(); + _priorLeftSliderHooked = file->readNumber(); + _priorRightSliderHooked = file->readNumber(); CGameObject::load(file); } diff --git a/engines/titanic/game/gondolier/gondolier_base.h b/engines/titanic/game/gondolier/gondolier_base.h index 06d77ba85f..3b5df9f371 100644 --- a/engines/titanic/game/gondolier/gondolier_base.h +++ b/engines/titanic/game/gondolier/gondolier_base.h @@ -31,16 +31,16 @@ class CGondolierBase : public CGameObject { DECLARE_MESSAGE_MAP; bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg); protected: - static int _v1; + static bool _chestOpen; static bool _puzzleSolved; static int _volume1; static int _v4; - static int _v5; static int _volume2; static int _v7; - static int _v8; - static int _v9; - static int _v10; + static bool _leftSliderHooked; + static bool _rightSliderHooked; + static bool _priorLeftSliderHooked; + static bool _priorRightSliderHooked; public: CLASSDEF; diff --git a/engines/titanic/game/gondolier/gondolier_chest.cpp b/engines/titanic/game/gondolier/gondolier_chest.cpp index cf6656732b..6058b582f7 100644 --- a/engines/titanic/game/gondolier/gondolier_chest.cpp +++ b/engines/titanic/game/gondolier/gondolier_chest.cpp @@ -41,13 +41,13 @@ void CGondolierChest::load(SimpleFile *file) { } bool CGondolierChest::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { - if (!_v1) + if (!_chestOpen) playMovie(0, 14, MOVIE_NOTIFY_OBJECT); else if (msg->_mousePos.y < 330) return false; - else if (!_v8 && !_v5) { + else if (!_leftSliderHooked && !_rightSliderHooked) { playMovie(14, 29, 0); - _v1 = 0; + _chestOpen = false; } return true; @@ -55,7 +55,7 @@ bool CGondolierChest::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { bool CGondolierChest::MovieEndMsg(CMovieEndMsg *msg) { if (msg->_endFrame == 14) - _v1 = 1; + _chestOpen = true; return true; } diff --git a/engines/titanic/game/gondolier/gondolier_mixer.cpp b/engines/titanic/game/gondolier/gondolier_mixer.cpp index fc71ddd357..205d1f42da 100644 --- a/engines/titanic/game/gondolier/gondolier_mixer.cpp +++ b/engines/titanic/game/gondolier/gondolier_mixer.cpp @@ -141,7 +141,7 @@ bool CGondolierMixer::SignalObject(CSignalObject *msg) { if (msg->_strValue == "Fly") { _v4 = CLIP(msg->_numValue, 0, 10); - if (!_v8) { + if (!_leftSliderHooked) { _v7 = 10 - _v4; CStatusChangeMsg statusMsg; statusMsg._newStatus = _v7; @@ -152,7 +152,7 @@ bool CGondolierMixer::SignalObject(CSignalObject *msg) { if (msg->_strValue == "Tos") { _v7 = CLIP(msg->_numValue, 0, 10); - if (!_v5) { + if (!_rightSliderHooked) { _v4 = 10 - _v7; CStatusChangeMsg statusMsg; statusMsg._newStatus = _v4; @@ -160,7 +160,7 @@ bool CGondolierMixer::SignalObject(CSignalObject *msg) { } } - if (!_v4 && !_v7 && _v5 && _v8) { + if (!_v4 && !_v7 && _rightSliderHooked && _leftSliderHooked) { _puzzleSolved = true; CStatusChangeMsg statusMsg; statusMsg._newStatus = 1; diff --git a/engines/titanic/game/gondolier/gondolier_slider.cpp b/engines/titanic/game/gondolier/gondolier_slider.cpp index e7ca61de9c..b5edac57d4 100644 --- a/engines/titanic/game/gondolier/gondolier_slider.cpp +++ b/engines/titanic/game/gondolier/gondolier_slider.cpp @@ -24,7 +24,10 @@ namespace Titanic { -static const int ARRAY[11] = { 0, 0, 1, 4, 9, 15, 21, 27, 32, 35, 36 }; +/** + * Y offsets within slider for each successive thumbnail position + */ +static const int Y_OFFSETS[11] = { 0, 0, 1, 4, 9, 15, 21, 27, 32, 35, 36 }; BEGIN_MESSAGE_MAP(CGondolierSlider, CGondolierBase) ON_MESSAGE(MouseButtonDownMsg) @@ -40,86 +43,66 @@ BEGIN_MESSAGE_MAP(CGondolierSlider, CGondolierBase) END_MESSAGE_MAP() CGondolierSlider::CGondolierSlider() : CGondolierBase(), - _fieldBC(0), _fieldC0(0), _fieldC4(0), _fieldC8(0), - _arrayIndex(0), _string1("NULL"), _fieldFC(0), _field118(0) { + _sliderIndex(0), _stringUnused("NULL"), _sliderNum(0), _dragging(false) { } void CGondolierSlider::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldBC, indent); - file->writeNumberLine(_fieldC0, indent); - file->writeNumberLine(_fieldC4, indent); - file->writeNumberLine(_fieldC8, indent); - file->writeNumberLine(_sliderRect1.left, indent); - file->writeNumberLine(_sliderRect1.top, indent); - file->writeNumberLine(_sliderRect1.right, indent); - file->writeNumberLine(_sliderRect1.bottom, indent); - file->writeNumberLine(_sliderRect2.left, indent); - file->writeNumberLine(_sliderRect2.top, indent); - file->writeNumberLine(_sliderRect2.right, indent); - file->writeNumberLine(_sliderRect2.bottom, indent); - file->writeNumberLine(_sliderRect1.left, indent); - file->writeQuotedLine(_string1, indent); - file->writeNumberLine(_fieldFC, indent); - file->writeQuotedLine(_string2, indent); - file->writeQuotedLine(_string3, indent); - file->writeNumberLine(_field118, indent); + file->writeRect(_rectUnused, indent); + file->writeRect(_thumbRect, indent); + file->writeRect(_defaultThumbRect, indent); + file->writeNumberLine(_sliderIndex, indent); + file->writeQuotedLine(_stringUnused, indent); + file->writeNumberLine(_sliderNum, indent); + file->writeQuotedLine(_armName, indent); + file->writeQuotedLine(_signalTarget, indent); + file->writeNumberLine(_dragging, indent); CGondolierBase::save(file, indent); } void CGondolierSlider::load(SimpleFile *file) { file->readNumber(); - _fieldBC = file->readNumber(); - _fieldC0 = file->readNumber(); - _fieldC4 = file->readNumber(); - _fieldC8 = file->readNumber(); - _sliderRect1.left = file->readNumber(); - _sliderRect1.top = file->readNumber(); - _sliderRect1.right = file->readNumber(); - _sliderRect1.bottom = file->readNumber(); - _sliderRect2.left = file->readNumber(); - _sliderRect2.top = file->readNumber(); - _sliderRect2.right = file->readNumber(); - _sliderRect2.bottom = file->readNumber(); - _arrayIndex = file->readNumber(); - _string1 = file->readString(); - _fieldFC = file->readNumber(); - _string2 = file->readString(); - _string3 = file->readString(); - _field118 = file->readNumber(); + _rectUnused = file->readRect(); + _thumbRect = file->readRect(); + _defaultThumbRect = file->readRect(); + _sliderIndex = file->readNumber(); + _stringUnused = file->readString(); + _sliderNum = file->readNumber(); + _armName = file->readString(); + _signalTarget = file->readString(); + _dragging = file->readNumber(); CGondolierBase::load(file); } bool CGondolierSlider::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { - if (!_v1) + if (!_chestOpen) return false; - if (_fieldFC ? _v5 : _v8) + if (_sliderNum ? _rightSliderHooked : _leftSliderHooked) return false; - return _sliderRect1.contains(msg->_mousePos); + return _thumbRect.contains(msg->_mousePos); } bool CGondolierSlider::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { - if (!(_fieldFC ? _v5 : _v8)) { + if (!(_sliderNum ? _rightSliderHooked : _leftSliderHooked)) { int minVal = 0x7FFFFFFF; int foundIndex = -1; - int yp = (_sliderRect2.top + _sliderRect2.bottom) / 2 + int yp = (_defaultThumbRect.top + _defaultThumbRect.bottom) / 2 + _bounds.top - msg->_mousePos.y; for (int idx = 0; idx < 11; ++idx) { - int yv = yp + ARRAY[idx]; - if (yv < 0) - yv = -yv; - if (yv < minVal) { - minVal = yv; + int yDiff = ABS(yp + Y_OFFSETS[idx]); + + if (yDiff < minVal) { + minVal = yDiff; foundIndex = idx; } } if (foundIndex >= 0) { - _arrayIndex = foundIndex; + _sliderIndex = foundIndex; CSignalObject signalMsg; signalMsg.execute(this); } @@ -135,70 +118,70 @@ bool CGondolierSlider::EnterViewMsg(CEnterViewMsg *msg) { } bool CGondolierSlider::MouseDragStartMsg(CMouseDragStartMsg *msg) { - if (!_v1) + if (!_chestOpen) return false; - if (_fieldFC ? _v5 : _v8) + if (_sliderNum ? _rightSliderHooked : _leftSliderHooked) return false; - _field118 = checkStartDragging(msg); - return _field118; + _dragging = checkStartDragging(msg); + return _dragging; } bool CGondolierSlider::StatusChangeMsg(CStatusChangeMsg *msg) { - _arrayIndex = CLIP(10 - msg->_newStatus, 0, 10); - _sliderRect1 = _sliderRect2; - _sliderRect1.translate(_bounds.left, _bounds.top); - _sliderRect1.translate(0, ARRAY[_arrayIndex]); + _sliderIndex = CLIP(10 - msg->_newStatus, 0, 10); + _thumbRect = _defaultThumbRect; + _thumbRect.translate(_bounds.left, _bounds.top); + _thumbRect.translate(0, Y_OFFSETS[_sliderIndex]); - loadFrame(_arrayIndex); + loadFrame(_sliderIndex); return true; } bool CGondolierSlider::MouseDragEndMsg(CMouseDragEndMsg *msg) { - _field118 = false; + _dragging = false; return true; } bool CGondolierSlider::IsHookedOnMsg(CIsHookedOnMsg *msg) { - if (_fieldFC ? _v5 : _v8) + if (_sliderNum ? _rightSliderHooked : _leftSliderHooked) return false; - if (!_sliderRect1.intersects(msg->_rect)) { - _string2 = CString(); - msg->_result = false; + if (!_thumbRect.intersects(msg->_rect)) { + _armName = CString(); + msg->_isHooked = false; } else { - _string2 = _string1; - if (_fieldFC) { - _v5 = _v9 = 1; + _armName = msg->_armName; + if (_sliderNum) { + _rightSliderHooked = _priorLeftSliderHooked = true; } else { - _v8 = _v10 = 1; + _leftSliderHooked = _priorRightSliderHooked = true; } - msg->_result = true; + msg->_isHooked = true; } return true; } bool CGondolierSlider::FrameMsg(CFrameMsg *msg) { - if (_fieldFC ? _v5 : _v8) { - if (_arrayIndex < 10) { - ++_arrayIndex; + if (_sliderNum ? _rightSliderHooked : _leftSliderHooked) { + if (_sliderIndex < 10) { + ++_sliderIndex; CSignalObject signalMsg; signalMsg.execute(this); int yp = 0; - if (_arrayIndex > 0) - yp = ARRAY[_arrayIndex] - ARRAY[_arrayIndex - 1]; + if (_sliderIndex > 0) + yp = Y_OFFSETS[_sliderIndex] - Y_OFFSETS[_sliderIndex - 1]; - if (!_string2.empty()) { + if (!_armName.empty()) { CTranslateObjectMsg transMsg; transMsg._delta = Point(0, yp); - transMsg.execute(_string2); + transMsg.execute(_armName); } } - } else if (_fieldFC ? _v10 : _v9) { - if (!_field118 && !_puzzleSolved && _arrayIndex > 0) { + } else if (_sliderNum ? _priorRightSliderHooked : _priorLeftSliderHooked) { + if (!_dragging && !_puzzleSolved && _sliderIndex > 0) { CSignalObject signalMsg; signalMsg.execute(this); } @@ -208,28 +191,28 @@ bool CGondolierSlider::FrameMsg(CFrameMsg *msg) { } bool CGondolierSlider::SignalObject(CSignalObject *msg) { - _arrayIndex = CLIP(_arrayIndex, 0, 10); - _sliderRect1 = _sliderRect2; - _sliderRect1.translate(_bounds.left, _bounds.top); - _sliderRect1.translate(0, ARRAY[_arrayIndex]); - loadFrame(_arrayIndex); + _sliderIndex = CLIP(_sliderIndex, 0, 10); + _thumbRect = _defaultThumbRect; + _thumbRect.translate(_bounds.left, _bounds.top); + _thumbRect.translate(0, Y_OFFSETS[_sliderIndex]); + loadFrame(_sliderIndex); CSignalObject signalMsg; - signalMsg._numValue = 10 - _arrayIndex; - signalMsg._strValue = _fieldFC ? "Fly" : "Tos"; - signalMsg.execute(_string3); + signalMsg._numValue = 10 - _sliderIndex; + signalMsg._strValue = _sliderNum ? "Fly" : "Tos"; + signalMsg.execute(_signalTarget); return true; } bool CGondolierSlider::ActMsg(CActMsg *msg) { if (msg->_action == "Unhook") { - if (_fieldFC) { - _v5 = _v9 = 0; - _v10 = _v8; + if (_sliderNum) { + _rightSliderHooked = _priorLeftSliderHooked = false; + _priorRightSliderHooked = _leftSliderHooked; } else { - _v8 = _v10 = 0; - _v9 = _v5; + _leftSliderHooked = _priorRightSliderHooked = false; + _priorLeftSliderHooked = _rightSliderHooked; } } diff --git a/engines/titanic/game/gondolier/gondolier_slider.h b/engines/titanic/game/gondolier/gondolier_slider.h index d1562f5b2d..0679c0d993 100644 --- a/engines/titanic/game/gondolier/gondolier_slider.h +++ b/engines/titanic/game/gondolier/gondolier_slider.h @@ -40,18 +40,15 @@ class CGondolierSlider : public CGondolierBase { bool SignalObject(CSignalObject *msg); bool ActMsg(CActMsg *msg); private: - int _fieldBC; - int _fieldC0; - int _fieldC4; - int _fieldC8; - Rect _sliderRect1; - Rect _sliderRect2; - int _arrayIndex; - CString _string1; - int _fieldFC; - CString _string2; - CString _string3; - bool _field118; + Rect _rectUnused; + Rect _thumbRect; + Rect _defaultThumbRect; + int _sliderIndex; + CString _stringUnused; + int _sliderNum; + CString _armName; + CString _signalTarget; + bool _dragging; public: CLASSDEF; CGondolierSlider(); diff --git a/engines/titanic/game/hammer_dispensor.cpp b/engines/titanic/game/hammer_dispensor.cpp index 2450868b14..82aeec12cb 100644 --- a/engines/titanic/game/hammer_dispensor.cpp +++ b/engines/titanic/game/hammer_dispensor.cpp @@ -77,9 +77,9 @@ bool CHammerDispensor::EnterViewMsg(CEnterViewMsg *msg) { bool CHammerDispensor::LeaveViewMsg(CLeaveViewMsg *msg) { if (_isOpen) - playMovie(32, 50, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(32, 50, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); else - playMovie(0, 7, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(0, 7, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _panUp = true; _isOpen = false; diff --git a/engines/titanic/game/head_slot.cpp b/engines/titanic/game/head_slot.cpp index 06c366abd6..f8a65715ad 100644 --- a/engines/titanic/game/head_slot.cpp +++ b/engines/titanic/game/head_slot.cpp @@ -37,77 +37,77 @@ BEGIN_MESSAGE_MAP(CHeadSlot, CGameObject) ON_MESSAGE(MouseDragStartMsg) END_MESSAGE_MAP() -int CHeadSlot::_v1; +bool CHeadSlot::_titaniaWoken; -CHeadSlot::CHeadSlot() : CGameObject(), _string1("NotWorking"), _string2("NULL"), - _fieldBC(0), _fieldD8(0), _fieldDC(27), _fieldE0(56), - _fieldE4(82), _fieldE8(112), _fieldEC(false) { +CHeadSlot::CHeadSlot() : CGameObject(), _senseState("NotWorking"), _target("NULL"), + _occupied(false), _timerDuration(0), _frameNum1(27), _frameNum2(56), + _frameNum3(82), _frameNum4(112), _workingFlag(false) { } void CHeadSlot::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldBC, indent); - file->writeQuotedLine(_string1, indent); - file->writeQuotedLine(_string2, indent); - file->writeNumberLine(_fieldD8, indent); - file->writeNumberLine(_fieldDC, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_fieldE8, indent); - file->writeNumberLine(_v1, indent); - file->writeNumberLine(_fieldEC, indent); + file->writeNumberLine(_occupied, indent); + file->writeQuotedLine(_senseState, indent); + file->writeQuotedLine(_target, indent); + file->writeNumberLine(_timerDuration, indent); + file->writeNumberLine(_frameNum1, indent); + file->writeNumberLine(_frameNum2, indent); + file->writeNumberLine(_frameNum3, indent); + file->writeNumberLine(_frameNum4, indent); + file->writeNumberLine(_titaniaWoken, indent); + file->writeNumberLine(_workingFlag, indent); CGameObject::save(file, indent); } void CHeadSlot::load(SimpleFile *file) { file->readNumber(); - _fieldBC = file->readNumber(); - _string1 = file->readString(); - _string2 = file->readString(); - _fieldD8 = file->readNumber(); - _fieldDC = file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); - _fieldE8 = file->readNumber(); - _v1 = file->readNumber(); - _fieldEC = file->readNumber(); + _occupied = file->readNumber(); + _senseState = file->readString(); + _target = file->readString(); + _timerDuration = file->readNumber(); + _frameNum1 = file->readNumber(); + _frameNum2 = file->readNumber(); + _frameNum3 = file->readNumber(); + _frameNum4 = file->readNumber(); + _titaniaWoken = file->readNumber(); + _workingFlag = file->readNumber(); CGameObject::load(file); } bool CHeadSlot::AddHeadPieceMsg(CAddHeadPieceMsg *msg) { setVisible(true); - _fieldBC = 1; - _string2 = msg->_value; - playMovie(_fieldDC, _fieldE8, 0); + _occupied = true; + _target = msg->_value; + playMovie(_frameNum1, _frameNum4, 0); _cursorId = CURSOR_HAND; msg->execute("TitaniaControl"); return true; } bool CHeadSlot::SenseWorkingMsg(CSenseWorkingMsg *msg) { - if (_fieldEC) - playMovie(_fieldE4, _fieldE8, 0); + if (_workingFlag) + playMovie(_frameNum3, _frameNum4, 0); - _string1 = msg->_value; - _fieldEC = false; + _senseState = msg->_value; + _workingFlag = false; return true; } bool CHeadSlot::EnterViewMsg(CEnterViewMsg *msg) { setVisible(true); - if (_v1) + if (_titaniaWoken) _cursorId = CURSOR_ARROW; - if (_v1 == 1 || _string1 == "Working") { - playMovie(_fieldE0, _fieldE4, MOVIE_GAMESTATE); - _fieldEC = true; - } else if (_fieldBC) { - playMovie(_fieldE0, _fieldE8, MOVIE_GAMESTATE); - _fieldEC = false; + if (_titaniaWoken || _senseState == "Working") { + playMovie(_frameNum2, _frameNum3, MOVIE_WAIT_FOR_FINISH); + _workingFlag = true; + } else if (_occupied) { + playMovie(_frameNum2, _frameNum4, MOVIE_WAIT_FOR_FINISH); + _workingFlag = false; } else { - playMovie(0, _fieldDC, MOVIE_GAMESTATE); + playMovie(0, _frameNum1, MOVIE_WAIT_FOR_FINISH); } addTimer(5000 + getRandomNumber(3000)); @@ -118,16 +118,15 @@ bool CHeadSlot::LeaveViewMsg(CLeaveViewMsg *msg) { if (getName() == "YepItsASlot") { stopMovie(); - if (_fieldBC) { - loadFrame(_fieldE0); - playMovie(_fieldE0, _fieldE8, MOVIE_GAMESTATE); - _fieldEC = false; + if (_occupied) { + loadFrame(_frameNum2); + playMovie(_frameNum2, _frameNum4, MOVIE_WAIT_FOR_FINISH); } else { - loadFrame(_fieldDC); - playMovie(_fieldDC, _fieldE0, MOVIE_GAMESTATE); + loadFrame(_frameNum1); + playMovie(_frameNum1, _frameNum2, MOVIE_WAIT_FOR_FINISH); } - _fieldEC = false; + _workingFlag = false; } return true; @@ -138,19 +137,19 @@ bool CHeadSlot::LoadSuccessMsg(CLoadSuccessMsg *msg) { } bool CHeadSlot::TimerMsg(CTimerMsg *msg) { - if (compareViewNameTo("Titania.Node 15.S") && CBrainSlot::_added == 5 - && _fieldBC == 1) { - if (_string1 == "Working" && !_fieldEC) { - playMovie(_fieldE0, _fieldE4, 0); - _fieldEC = true; - } else if (_string1 == "Random") { - playMovie(_fieldE0, _fieldE8, 0); + if (compareViewNameTo("Titania.Node 15.S") && CBrainSlot::_numAdded == 5 + && _occupied) { + if (_senseState == "Working" && !_workingFlag) { + playMovie(_frameNum2, _frameNum3, 0); + _workingFlag = true; + } else if (_senseState == "Random") { + playMovie(_frameNum2, _frameNum4, 0); } } if (compareViewNameTo("Titania.Node 15.S")) { - _fieldD8 = 7000 + getRandomNumber(5000); - addTimer(_fieldD8); + _timerDuration = 7000 + getRandomNumber(5000); + addTimer(_timerDuration); } return true; @@ -158,27 +157,29 @@ bool CHeadSlot::TimerMsg(CTimerMsg *msg) { bool CHeadSlot::ActMsg(CActMsg *msg) { if (msg->_action == "Woken") - _v1 = 1; + _titaniaWoken = true; return true; } bool CHeadSlot::MouseDragStartMsg(CMouseDragStartMsg *msg) { - if (_fieldBC && !_v1 && checkPoint(msg->_mousePos, false, true)) { + if (_occupied && !_titaniaWoken && checkPoint(msg->_mousePos, false, true)) { CPassOnDragStartMsg passMsg; passMsg._mousePos = msg->_mousePos; - passMsg.execute(_string2); + passMsg.execute(_target); - msg->_dragItem = getRoot()->findByName(_string2); + msg->_dragItem = getRoot()->findByName(_target); _cursorId = CURSOR_ARROW; - _fieldBC = 0; - _fieldEC = false; - _string2 = "NULL"; + _occupied = false; + _workingFlag = false; + _target = "NULL"; stopMovie(); loadFrame(0); - playMovie(0, _fieldDC, 0); + playMovie(0, _frameNum1, 0); + + return true; } - return true; + return false; } } // End of namespace Titanic diff --git a/engines/titanic/game/head_slot.h b/engines/titanic/game/head_slot.h index 2767db3b61..1474e03ff3 100644 --- a/engines/titanic/game/head_slot.h +++ b/engines/titanic/game/head_slot.h @@ -38,17 +38,17 @@ class CHeadSlot : public CGameObject { bool ActMsg(CActMsg *msg); bool MouseDragStartMsg(CMouseDragStartMsg *msg); public: - static int _v1; + static bool _titaniaWoken; public: - int _fieldBC; - CString _string1; - CString _string2; - int _fieldD8; - int _fieldDC; - int _fieldE0; - int _fieldE4; - int _fieldE8; - bool _fieldEC; + bool _occupied; + CString _senseState; + CString _target; + int _timerDuration; + int _frameNum1; + int _frameNum2; + int _frameNum3; + int _frameNum4; + bool _workingFlag; public: CLASSDEF; CHeadSlot(); diff --git a/engines/titanic/game/head_smash_event.cpp b/engines/titanic/game/head_smash_event.cpp index 5ec3d299d5..dd5e516b0d 100644 --- a/engines/titanic/game/head_smash_event.cpp +++ b/engines/titanic/game/head_smash_event.cpp @@ -42,7 +42,7 @@ void CHeadSmashEvent::load(SimpleFile *file) { bool CHeadSmashEvent::ActMsg(CActMsg *msg) { if (msg->_action == "PlayToEnd") { setVisible(true); - playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } return true; diff --git a/engines/titanic/game/long_stick_dispenser.cpp b/engines/titanic/game/long_stick_dispenser.cpp index bf2dae53be..c340cae75b 100644 --- a/engines/titanic/game/long_stick_dispenser.cpp +++ b/engines/titanic/game/long_stick_dispenser.cpp @@ -109,9 +109,9 @@ bool CLongStickDispenser::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { bool CLongStickDispenser::LeaveViewMsg(CLeaveViewMsg *msg) { if (_fieldC0 == 1) { if (_fieldC4) { - playMovie(19, 38, MOVIE_GAMESTATE); + playMovie(19, 38, MOVIE_WAIT_FOR_FINISH); } else { - playMovie(0, 18, MOVIE_GAMESTATE); + playMovie(0, 18, MOVIE_WAIT_FOR_FINISH); _fieldBC = 1; } diff --git a/engines/titanic/game/music_room_stop_phonograph_button.cpp b/engines/titanic/game/music_room_stop_phonograph_button.cpp index dee2c0883e..0a72406b0f 100644 --- a/engines/titanic/game/music_room_stop_phonograph_button.cpp +++ b/engines/titanic/game/music_room_stop_phonograph_button.cpp @@ -49,7 +49,7 @@ bool CMusicRoomStopPhonographButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg CPhonographStopMsg stopMsg; stopMsg.execute(getParent(), nullptr, MSGFLAG_SCAN); - if (stopMsg._value2) { + if (stopMsg._cylinderPresent) { _ticks = getTicksCount(); } else { CEjectCylinderMsg ejectMsg; diff --git a/engines/titanic/game/nut_replacer.cpp b/engines/titanic/game/nut_replacer.cpp index 6b05d1d0e9..3b1247fd8c 100644 --- a/engines/titanic/game/nut_replacer.cpp +++ b/engines/titanic/game/nut_replacer.cpp @@ -41,7 +41,7 @@ void CNutReplacer::load(SimpleFile *file) { bool CNutReplacer::ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg) { setVisible(true); - playMovie(MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); return true; } diff --git a/engines/titanic/game/parrot/parrot_nut_eater.cpp b/engines/titanic/game/parrot/parrot_nut_eater.cpp index b9697d7b61..7196d76ccb 100644 --- a/engines/titanic/game/parrot/parrot_nut_eater.cpp +++ b/engines/titanic/game/parrot/parrot_nut_eater.cpp @@ -67,7 +67,7 @@ bool CParrotNutEater::ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg) { bool CParrotNutEater::NutPuzzleMsg(CNutPuzzleMsg *msg) { if (msg->_value == "Jiggle") { setVisible(true); - playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); movieEvent(68); movieEvent(132); playSound("z#215.wav"); diff --git a/engines/titanic/game/phonograph.cpp b/engines/titanic/game/phonograph.cpp index 408cfa3413..b86fa0b6e0 100644 --- a/engines/titanic/game/phonograph.cpp +++ b/engines/titanic/game/phonograph.cpp @@ -34,32 +34,32 @@ BEGIN_MESSAGE_MAP(CPhonograph, CMusicPlayer) END_MESSAGE_MAP() CPhonograph::CPhonograph() : CMusicPlayer(), - _fieldE0(false), _fieldE4(0), _fieldE8(0), _fieldEC(0), - _fieldF0(0), _fieldF4(0) { + _isPlaying(false), _isRecording(false), _isDisabled(false), + _playUnpressedFrame(false), _playPressedFrame(false), _unused5(0) { } void CPhonograph::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string2, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_fieldE8, indent); - file->writeNumberLine(_fieldEC, indent); - file->writeNumberLine(_fieldF0, indent); - file->writeNumberLine(_fieldF4, indent); + file->writeQuotedLine(_unused, indent); + file->writeNumberLine(_isPlaying, indent); + file->writeNumberLine(_isRecording, indent); + file->writeNumberLine(_isDisabled, indent); + file->writeNumberLine(_playUnpressedFrame, indent); + file->writeNumberLine(_playPressedFrame, indent); + file->writeNumberLine(_unused5, indent); CMusicPlayer::save(file, indent); } void CPhonograph::load(SimpleFile *file) { file->readNumber(); - _string2 = file->readString(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); - _fieldE8 = file->readNumber(); - _fieldEC = file->readNumber(); - _fieldF0 = file->readNumber(); - _fieldF4 = file->readNumber(); + _unused = file->readString(); + _isPlaying = file->readNumber(); + _isRecording = file->readNumber(); + _isDisabled = file->readNumber(); + _playUnpressedFrame = file->readNumber(); + _playPressedFrame = file->readNumber(); + _unused5 = file->readNumber(); CMusicPlayer::load(file); } @@ -67,8 +67,8 @@ void CPhonograph::load(SimpleFile *file) { bool CPhonograph::PhonographPlayMsg(CPhonographPlayMsg *msg) { CQueryCylinderHolderMsg holderMsg; holderMsg.execute(this); - if (!holderMsg._value2) { - _fieldE0 = false; + if (!holderMsg._isPresent) { + _isPlaying = false; return true; } @@ -76,16 +76,16 @@ bool CPhonograph::PhonographPlayMsg(CPhonographPlayMsg *msg) { cylinderMsg.execute(holderMsg._target); if (cylinderMsg._name.empty()) { - _fieldE0 = false; + _isPlaying = false; } else if (cylinderMsg._name.hasPrefix("STMusic")) { CStartMusicMsg startMsg(this); startMsg.execute(this); - _fieldE0 = true; + _isPlaying = true; msg->_value = 1; } else { - stopGlobalSound(0, -1); + stopGlobalSound(false, -1); playGlobalSound(cylinderMsg._name, -2, true, true, 0); - _fieldE0 = true; + _isPlaying = true; msg->_value = 1; } @@ -95,45 +95,45 @@ bool CPhonograph::PhonographPlayMsg(CPhonographPlayMsg *msg) { bool CPhonograph::PhonographStopMsg(CPhonographStopMsg *msg) { CQueryCylinderHolderMsg holderMsg; holderMsg.execute(this); - if (!holderMsg._value2) + if (!holderMsg._isPresent) return true; - _fieldE0 = false; CQueryCylinderMsg cylinderMsg; cylinderMsg.execute(holderMsg._target); - if (_fieldE0) { + if (_isPlaying) { if (!cylinderMsg._name.empty()) { if (cylinderMsg._name.hasPrefix("STMusic")) { CStopMusicMsg stopMsg; stopMsg.execute(this); } else { - stopGlobalSound(msg->_value1, -1); + stopGlobalSound(msg->_leavingRoom, -1); } - msg->_value2 = 1; + msg->_cylinderPresent = true; } - if (!msg->_value3) - _fieldE0 = false; - } else if (_fieldE4) { - _fieldE4 = false; - msg->_value2 = 1; + if (!msg->_dontStop) + _isPlaying = false; + } else if (_isRecording) { + _isRecording = false; + msg->_cylinderPresent = true; } return true; } bool CPhonograph::PhonographRecordMsg(CPhonographRecordMsg *msg) { - if (!_fieldE0 && !_fieldE4 && !_fieldE8) { + if (!_isPlaying && !_isRecording && !_isDisabled) { CQueryCylinderHolderMsg holderMsg; holderMsg.execute(this); - if (holderMsg._value2) { - _fieldE4 = true; + if (holderMsg._isPresent) { + _isRecording = true; + msg->_canRecord = true; CErasePhonographCylinderMsg eraseMsg; eraseMsg.execute(holderMsg._target); } else { - _fieldE4 = false; + _isRecording = false; } } @@ -141,7 +141,7 @@ bool CPhonograph::PhonographRecordMsg(CPhonographRecordMsg *msg) { } bool CPhonograph::EnterRoomMsg(CEnterRoomMsg *msg) { - if (_fieldE0) { + if (_isPlaying) { CPhonographPlayMsg playMsg; playMsg.execute(this); } @@ -150,9 +150,9 @@ bool CPhonograph::EnterRoomMsg(CEnterRoomMsg *msg) { } bool CPhonograph::LeaveRoomMsg(CLeaveRoomMsg *msg) { - if (_fieldE0) { + if (_isPlaying) { CPhonographStopMsg stopMsg; - stopMsg._value1 = 1; + stopMsg._leavingRoom = true; stopMsg.execute(this); } @@ -160,14 +160,14 @@ bool CPhonograph::LeaveRoomMsg(CLeaveRoomMsg *msg) { } bool CPhonograph::MusicHasStartedMsg(CMusicHasStartedMsg *msg) { - if (_fieldE4) { + if (_isRecording) { CQueryCylinderHolderMsg holderMsg; holderMsg.execute(this); - if (holderMsg._value2) { + if (holderMsg._isPresent) { CRecordOntoCylinderMsg recordMsg; recordMsg.execute(holderMsg._target); } else { - _fieldE4 = false; + _isRecording = false; } } diff --git a/engines/titanic/game/phonograph.h b/engines/titanic/game/phonograph.h index b13a5ea910..6630a18f27 100644 --- a/engines/titanic/game/phonograph.h +++ b/engines/titanic/game/phonograph.h @@ -37,13 +37,13 @@ class CPhonograph : public CMusicPlayer { bool LeaveRoomMsg(CLeaveRoomMsg *msg); bool MusicHasStartedMsg(CMusicHasStartedMsg *msg); protected: - CString _string2; - bool _fieldE0; - int _fieldE4; - int _fieldE8; - int _fieldEC; - int _fieldF0; - int _fieldF4; + CString _unused; + bool _isPlaying; + bool _isRecording; + bool _isDisabled; + int _playUnpressedFrame; + int _playPressedFrame; + int _unused5; public: CLASSDEF; CPhonograph(); diff --git a/engines/titanic/game/phonograph_lid.cpp b/engines/titanic/game/phonograph_lid.cpp index e4e5f4882c..cde9415e02 100644 --- a/engines/titanic/game/phonograph_lid.cpp +++ b/engines/titanic/game/phonograph_lid.cpp @@ -76,7 +76,7 @@ bool CPhonographLid::LockPhonographMsg(CLockPhonographMsg *msg) { bool CPhonographLid::LeaveViewMsg(CLeaveViewMsg *msg) { if (_open) { - playMovie(27, 55, MOVIE_GAMESTATE); + playMovie(27, 55, MOVIE_WAIT_FOR_FINISH); _open = false; } diff --git a/engines/titanic/game/play_on_act.cpp b/engines/titanic/game/play_on_act.cpp index 9c368c335d..ffed45c11f 100644 --- a/engines/titanic/game/play_on_act.cpp +++ b/engines/titanic/game/play_on_act.cpp @@ -45,7 +45,7 @@ bool CPlayOnAct::ActMsg(CActMsg *msg) { playMovie(0); } else if (msg->_action == "PlayToEnd") { setVisible(true); - playMovie(MOVIE_GAMESTATE); + playMovie(MOVIE_WAIT_FOR_FINISH); } return true; diff --git a/engines/titanic/game/port_hole.cpp b/engines/titanic/game/port_hole.cpp index 25807b1b1d..9111561588 100644 --- a/engines/titanic/game/port_hole.cpp +++ b/engines/titanic/game/port_hole.cpp @@ -79,7 +79,7 @@ bool CPortHole::MovieEndMsg(CMovieEndMsg *msg) { bool CPortHole::LeaveViewMsg(CLeaveViewMsg *msg) { if (_open) { playSound(_closeSoundName); - playMovie(14, 26, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(14, 26, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _open = false; } diff --git a/engines/titanic/game/record_phonograph_button.cpp b/engines/titanic/game/record_phonograph_button.cpp index 1ffaec4228..1bd2060193 100644 --- a/engines/titanic/game/record_phonograph_button.cpp +++ b/engines/titanic/game/record_phonograph_button.cpp @@ -45,7 +45,7 @@ bool CRecordPhonographButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { CPhonographRecordMsg recordMsg; recordMsg.execute(getParent()); - if (recordMsg._value) { + if (recordMsg._canRecord) { playSound("z#58.wav"); loadFrame(1); _active = true; diff --git a/engines/titanic/game/replacement_ear.cpp b/engines/titanic/game/replacement_ear.cpp index e8bd384207..d1274e92db 100644 --- a/engines/titanic/game/replacement_ear.cpp +++ b/engines/titanic/game/replacement_ear.cpp @@ -40,7 +40,7 @@ void CReplacementEar::load(SimpleFile *file) { bool CReplacementEar::VisibleMsg(CVisibleMsg *msg) { setVisible(true); - playMovie(MOVIE_GAMESTATE); + playMovie(MOVIE_WAIT_FOR_FINISH); playSound("z#64.wav"); return true; } diff --git a/engines/titanic/game/restaurant_cylinder_holder.cpp b/engines/titanic/game/restaurant_cylinder_holder.cpp index 5fb8c97cde..eddd4d2288 100644 --- a/engines/titanic/game/restaurant_cylinder_holder.cpp +++ b/engines/titanic/game/restaurant_cylinder_holder.cpp @@ -34,13 +34,13 @@ BEGIN_MESSAGE_MAP(CRestaurantCylinderHolder, CDropTarget) END_MESSAGE_MAP() CRestaurantCylinderHolder::CRestaurantCylinderHolder() : CDropTarget(), - _field118(0), _field11C(0), _field12C(0), _field130(0), + _isOpen(false), _field11C(0), _field12C(0), _field130(0), _ejectSoundName("z#61.wav"), _defaultCursorId(CURSOR_ARROW) { } void CRestaurantCylinderHolder::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_field118, indent); + file->writeNumberLine(_isOpen, indent); file->writeNumberLine(_field11C, indent); file->writeQuotedLine(_target, indent); file->writeNumberLine(_field12C, indent); @@ -53,7 +53,7 @@ void CRestaurantCylinderHolder::save(SimpleFile *file, int indent) { void CRestaurantCylinderHolder::load(SimpleFile *file) { file->readNumber(); - _field118 = file->readNumber(); + _isOpen = file->readNumber(); _field11C = file->readNumber(); _target = file->readString(); _field12C = file->readNumber(); @@ -66,15 +66,15 @@ void CRestaurantCylinderHolder::load(SimpleFile *file) { bool CRestaurantCylinderHolder::EjectCylinderMsg(CEjectCylinderMsg *msg) { _field11C = true; - bool hasCylinder = findByName("Phonograph Cylinder") != nullptr; + bool hasCylinder = findByName("Phonograph Cylinder", true) != nullptr; - if (_field118) { + if (_isOpen) { playClip(hasCylinder ? "CloseHolder_Full" : "CloseHolder_Empty", - MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _dropEnabled = true; } else { playClip(hasCylinder ? "OpenHolder_Full" : "OpenHolder_Empty", - MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } playSound(_ejectSoundName, 50); @@ -82,7 +82,7 @@ bool CRestaurantCylinderHolder::EjectCylinderMsg(CEjectCylinderMsg *msg) { } bool CRestaurantCylinderHolder::EnterViewMsg(CEnterViewMsg *msg) { - if (_field118) { + if (_isOpen) { CTreeItem *cylinder = findByName("Phonograph Cylinder", true); if (cylinder) { loadFrame(_dropFrame); @@ -101,14 +101,14 @@ bool CRestaurantCylinderHolder::EnterViewMsg(CEnterViewMsg *msg) { bool CRestaurantCylinderHolder::MovieEndMsg(CMovieEndMsg *msg) { _field11C = false; - if (_field118) { - _field118 = false; + if (_isOpen) { + _isOpen = false; _cursorId = _defaultCursorId; CPhonographReadyToPlayMsg readyMsg; readyMsg.execute(_target); } else { - _field118 = true; + _isOpen = true; _dropEnabled = false; _cursorId = findByName("Phonograph Cylinder") ? _dropCursorId : _dragCursorId; } @@ -121,9 +121,9 @@ bool CRestaurantCylinderHolder::MovieEndMsg(CMovieEndMsg *msg) { bool CRestaurantCylinderHolder::QueryCylinderHolderMsg(CQueryCylinderHolderMsg *msg) { CNamedItem *cylinder = findByName("Phonograph Cylinder", true); - msg->_value1 = _field118; + msg->_isOpen = _isOpen; if (cylinder) { - msg->_value2 = 1; + msg->_isPresent = true; msg->_target = cylinder; } @@ -143,7 +143,7 @@ bool CRestaurantCylinderHolder::QueryCylinderNameMsg(CQueryCylinderNameMsg *msg) } bool CRestaurantCylinderHolder::MouseDragStartMsg(CMouseDragStartMsg *msg) { - if (_field118) + if (_isOpen) return CDropTarget::MouseDragStartMsg(msg); else return true; diff --git a/engines/titanic/game/restaurant_cylinder_holder.h b/engines/titanic/game/restaurant_cylinder_holder.h index cd0b0783bd..7be73df074 100644 --- a/engines/titanic/game/restaurant_cylinder_holder.h +++ b/engines/titanic/game/restaurant_cylinder_holder.h @@ -36,7 +36,7 @@ class CRestaurantCylinderHolder : public CDropTarget { bool QueryCylinderNameMsg(CQueryCylinderNameMsg *msg); bool MouseDragStartMsg(CMouseDragStartMsg *msg); private: - int _field118; + bool _isOpen; int _field11C; CString _target; int _field12C; diff --git a/engines/titanic/game/restaurant_phonograph.cpp b/engines/titanic/game/restaurant_phonograph.cpp index 881079e020..3b35514a52 100644 --- a/engines/titanic/game/restaurant_phonograph.cpp +++ b/engines/titanic/game/restaurant_phonograph.cpp @@ -36,13 +36,13 @@ BEGIN_MESSAGE_MAP(CRestaurantPhonograph, CPhonograph) END_MESSAGE_MAP() CRestaurantPhonograph::CRestaurantPhonograph() : CPhonograph(), - _fieldF8(1), _field114(0) {} + _isLocked(true), _field114(0) {} void CRestaurantPhonograph::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldF8, indent); - file->writeQuotedLine(_string2, indent); - file->writeQuotedLine(_string3, indent); + file->writeNumberLine(_isLocked, indent); + file->writeQuotedLine(_ejectSoundName, indent); + file->writeQuotedLine(_stopSoundName, indent); file->writeNumberLine(_field114, indent); @@ -51,29 +51,31 @@ void CRestaurantPhonograph::save(SimpleFile *file, int indent) { void CRestaurantPhonograph::load(SimpleFile *file) { file->readNumber(); - _fieldF8 = file->readNumber(); - _string2 = file->readString(); - _string3 = file->readString(); + _isLocked = file->readNumber(); + _ejectSoundName = file->readString(); + _stopSoundName = file->readString(); _field114 = file->readNumber(); CPhonograph::load(file); } bool CRestaurantPhonograph::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { - if (!_fieldF8 && !_fieldE0) { + if (!_isLocked && !_isPlaying) { CQueryCylinderHolderMsg holderMsg; holderMsg.execute(this); - if (!holderMsg._value1) { + if (!holderMsg._isOpen) { + // Start playing immediately CPhonographPlayMsg playMsg; playMsg.execute(this); - } else if (holderMsg._value2) { + } else if (holderMsg._isPresent) { + // Need to close the cylinder holder before playing CEjectCylinderMsg ejectMsg; - ejectMsg.execute(this); + ejectMsg.execute(this, nullptr, MSGFLAG_SCAN); - _fieldE8 = true; + _isDisabled = true; if (_field114) { - loadFrame(_fieldEC); + loadFrame(_playUnpressedFrame); playSound(_ejectSoundName); } } @@ -83,9 +85,11 @@ bool CRestaurantPhonograph::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { } bool CRestaurantPhonograph::PhonographPlayMsg(CPhonographPlayMsg *msg) { - if (_fieldE0) { - if (findView() == getView() && (!_fieldE8 || !_field114)) { - loadFrame(_fieldEC); + CPhonograph::PhonographPlayMsg(msg); + + if (_isPlaying) { + if (findView() == getView() && (!_isDisabled || !_field114)) { + loadFrame(_playUnpressedFrame); playSound(_ejectSoundName); } @@ -94,39 +98,39 @@ bool CRestaurantPhonograph::PhonographPlayMsg(CPhonographPlayMsg *msg) { CRestaurantMusicChanged musicMsg(nameMsg._name); musicMsg.execute(findRoom()); } else { - loadFrame(_fieldF0); + loadFrame(_playPressedFrame); } return true; } bool CRestaurantPhonograph::PhonographStopMsg(CPhonographStopMsg *msg) { - bool flag = _fieldE0; + bool flag = _isPlaying; CPhonograph::PhonographStopMsg(msg); - if (_fieldE0) { - loadFrame(_fieldF0); - if (flag) - playSound(_string3); + if (_isPlaying) { + loadFrame(_playUnpressedFrame); } else { - loadFrame(_fieldEC); + loadFrame(_playPressedFrame); + if (flag) + playSound(_stopSoundName); } return true; } bool CRestaurantPhonograph::PhonographReadyToPlayMsg(CPhonographReadyToPlayMsg *msg) { - if (_fieldE8) { + if (_isDisabled) { CPhonographPlayMsg playMsg; playMsg.execute(this); - _fieldE8 = false; + _isDisabled = false; } return true; } bool CRestaurantPhonograph::EjectCylinderMsg(CEjectCylinderMsg *msg) { - if (_fieldE0) { + if (_isPlaying) { CPhonographStopMsg stopMsg; stopMsg.execute(this); } @@ -135,12 +139,12 @@ bool CRestaurantPhonograph::EjectCylinderMsg(CEjectCylinderMsg *msg) { } bool CRestaurantPhonograph::QueryPhonographState(CQueryPhonographState *msg) { - msg->_value = _fieldF8; + msg->_value = _isLocked; return true; } bool CRestaurantPhonograph::LockPhonographMsg(CLockPhonographMsg *msg) { - _fieldF8 = msg->_value; + _isLocked = msg->_value; return true; } diff --git a/engines/titanic/game/restaurant_phonograph.h b/engines/titanic/game/restaurant_phonograph.h index 9661df0dfb..67248447ab 100644 --- a/engines/titanic/game/restaurant_phonograph.h +++ b/engines/titanic/game/restaurant_phonograph.h @@ -37,9 +37,9 @@ class CRestaurantPhonograph : public CPhonograph { bool QueryPhonographState(CQueryPhonographState *msg); bool LockPhonographMsg(CLockPhonographMsg *msg); private: - int _fieldF8; + bool _isLocked; CString _ejectSoundName; - CString _string3; + CString _stopSoundName; int _field114; public: CLASSDEF; diff --git a/engines/titanic/game/season_background.cpp b/engines/titanic/game/season_background.cpp index 20ad6aca1d..d663c405ce 100644 --- a/engines/titanic/game/season_background.cpp +++ b/engines/titanic/game/season_background.cpp @@ -65,39 +65,39 @@ bool CSeasonBackground::ChangeSeasonMsg(CChangeSeasonMsg *msg) { switch (_seasonNum) { case SEASON_SUMMER: - playMovie(0, 45, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(0, 45, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _defaultFrame = 45; break; case SEASON_AUTUMN: if (_flag) { - playMovie(232, 278, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(232, 278, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _defaultFrame = 278; } else { - playMovie(45, 91, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(45, 91, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _defaultFrame = 91; } break; case SEASON_WINTER: if (_flag) { - playMovie(278, 326, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(278, 326, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _defaultFrame = 326; } else { CStatusChangeMsg changeMsg; changeMsg._newStatus = 0; changeMsg.execute("PickUpSpeechCentre"); - playMovie(91, 139, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(91, 139, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _defaultFrame = 139; } break; case SEASON_SPRING: if (_flag) { - playMovie(326, 417, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(326, 417, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _defaultFrame = 417; } else { - playMovie(139, 228, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(139, 228, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _defaultFrame = 228; } break; diff --git a/engines/titanic/game/sgt/armchair.cpp b/engines/titanic/game/sgt/armchair.cpp index 681b1ae61d..6c0e7fe0ca 100644 --- a/engines/titanic/game/sgt/armchair.cpp +++ b/engines/titanic/game/sgt/armchair.cpp @@ -55,7 +55,7 @@ bool CArmchair::TurnOn(CTurnOn *msg) { _endFrame = 10; } - playMovie(_startFrame, _endFrame, MOVIE_GAMESTATE); + playMovie(_startFrame, _endFrame, MOVIE_WAIT_FOR_FINISH); playSound("b#0.wav"); _statics->_armchair = "Open"; _isClosed = false; @@ -70,7 +70,7 @@ bool CArmchair::TurnOff(CTurnOff *msg) { _startFrame = 11; _endFrame = 21; _isClosed = true; - playMovie(11, 21, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(11, 21, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); playSound("b#0.wav"); } diff --git a/engines/titanic/game/sgt/basin.cpp b/engines/titanic/game/sgt/basin.cpp index ce34a49250..fe3216e002 100644 --- a/engines/titanic/game/sgt/basin.cpp +++ b/engines/titanic/game/sgt/basin.cpp @@ -48,7 +48,7 @@ bool CBasin::TurnOn(CTurnOn *msg) { _isClosed = false; _startFrame = 0; _endFrame = 6; - playMovie(0, 6, MOVIE_GAMESTATE); + playMovie(0, 6, MOVIE_WAIT_FOR_FINISH); playSound("b#13.wav"); } @@ -61,7 +61,7 @@ bool CBasin::TurnOff(CTurnOff *msg) { _isClosed = true; _startFrame = 8; _endFrame = 14; - playMovie(8, 14, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(8, 14, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); playSound("b#13.wav"); } diff --git a/engines/titanic/game/sgt/bedfoot.cpp b/engines/titanic/game/sgt/bedfoot.cpp index d84a73f0a5..8f90e0f100 100644 --- a/engines/titanic/game/sgt/bedfoot.cpp +++ b/engines/titanic/game/sgt/bedfoot.cpp @@ -53,7 +53,7 @@ bool CBedfoot::TurnOn(CTurnOn *msg) { playSound("b#4.wav"); } - playMovie(_startFrame, _endFrame, MOVIE_GAMESTATE); + playMovie(_startFrame, _endFrame, MOVIE_WAIT_FOR_FINISH); } else if (_statics->_bedfoot == "RestingUnderTV") { _isClosed = false; _startFrame = 8; @@ -65,7 +65,7 @@ bool CBedfoot::TurnOn(CTurnOn *msg) { playSound("192_436_bed hits floor.wav"); } - playMovie(_startFrame, _endFrame, MOVIE_GAMESTATE); + playMovie(_startFrame, _endFrame, MOVIE_WAIT_FOR_FINISH); } if (_statics->_bedfoot == "Open") @@ -94,7 +94,7 @@ bool CBedfoot::TurnOff(CTurnOff *msg) { _endFrame = 25; } - playMovie(_startFrame, _endFrame, MOVIE_GAMESTATE); + playMovie(_startFrame, _endFrame, MOVIE_WAIT_FOR_FINISH); playSound("b#7.wav"); } else if (_statics->_bedfoot == "NotOnWashstand" && _statics->_bedhead == "ClosedWrong") { @@ -109,14 +109,14 @@ bool CBedfoot::TurnOff(CTurnOff *msg) { _endFrame = 25; } - playMovie(_startFrame, _endFrame, MOVIE_GAMESTATE); + playMovie(_startFrame, _endFrame, MOVIE_WAIT_FOR_FINISH); playSound("b#7.wav"); } else if (_statics->_bedfoot == "RestingUTV" && _statics->_tv == "Closed") { _statics->_bedfoot = "Closed"; _startFrame = 25; _endFrame = 30; - playMovie(25, 30, MOVIE_GAMESTATE); + playMovie(25, 30, MOVIE_WAIT_FOR_FINISH); playSound("b#7.wav"); } diff --git a/engines/titanic/game/sgt/bedhead.cpp b/engines/titanic/game/sgt/bedhead.cpp index b42c1c1146..1356afea83 100644 --- a/engines/titanic/game/sgt/bedhead.cpp +++ b/engines/titanic/game/sgt/bedhead.cpp @@ -110,7 +110,7 @@ bool CBedhead::TurnOn(CTurnOn *msg) { setVisible(true); _statics->_bedhead = entry._name4; - playMovie(entry._startFrame, entry._endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(entry._startFrame, entry._endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); playSound("b#6.wav"); _isClosed = false; } @@ -157,7 +157,7 @@ bool CBedhead::TurnOff(CTurnOff *msg) { setVisible(true); _statics->_bedhead = entry._name4; - playMovie(entry._startFrame, entry._endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(entry._startFrame, entry._endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); playSound("193_436_bed fold up 1.wav"); _isClosed = false; } diff --git a/engines/titanic/game/sgt/chest_of_drawers.cpp b/engines/titanic/game/sgt/chest_of_drawers.cpp index 9e00d4fde7..648308fc8f 100644 --- a/engines/titanic/game/sgt/chest_of_drawers.cpp +++ b/engines/titanic/game/sgt/chest_of_drawers.cpp @@ -46,7 +46,7 @@ bool CChestOfDrawers::TurnOn(CTurnOn *msg) { _statics->_chestOfDrawers = "Open"; _startFrame = 1; _endFrame = 14; - playMovie(1, 14, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(1, 14, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); playSound("b#11.wav"); } @@ -62,7 +62,7 @@ bool CChestOfDrawers::TurnOff(CTurnOff *msg) { _startFrame = 14; _endFrame = 27; - playMovie(14, 27, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(14, 27, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); playSound("b#11.wav"); } diff --git a/engines/titanic/game/sgt/desk.cpp b/engines/titanic/game/sgt/desk.cpp index a31efe9e5d..1aea9a8ab3 100644 --- a/engines/titanic/game/sgt/desk.cpp +++ b/engines/titanic/game/sgt/desk.cpp @@ -47,7 +47,7 @@ bool CDesk::TurnOn(CTurnOn *msg) { _isClosed = false; _startFrame = 1; _endFrame = 26; - playMovie(1, 26, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(1, 26, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); playSound("b#12.wav"); } @@ -64,7 +64,7 @@ bool CDesk::TurnOff(CTurnOff *msg) { _isClosed = true; _startFrame = 26; _endFrame = 51; - playMovie(26, 51, MOVIE_GAMESTATE); + playMovie(26, 51, MOVIE_WAIT_FOR_FINISH); playSound("b#9.wav"); } diff --git a/engines/titanic/game/sgt/deskchair.cpp b/engines/titanic/game/sgt/deskchair.cpp index 2b25f57d03..23b6ad64d7 100644 --- a/engines/titanic/game/sgt/deskchair.cpp +++ b/engines/titanic/game/sgt/deskchair.cpp @@ -48,7 +48,7 @@ bool CDeskchair::TurnOn(CTurnOn *msg) { _isClosed = false; _startFrame = 0; _endFrame = 16; - playMovie(0, 16, MOVIE_GAMESTATE); + playMovie(0, 16, MOVIE_WAIT_FOR_FINISH); playSound("b#8.wav"); } @@ -61,7 +61,7 @@ bool CDeskchair::TurnOff(CTurnOff *msg) { _isClosed = true; _startFrame = 16; _endFrame = 32; - playMovie(16, 32, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(16, 32, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); playSound("b#2.wav"); } diff --git a/engines/titanic/game/sgt/drawer.cpp b/engines/titanic/game/sgt/drawer.cpp index 68752b3d2f..7288bbdc61 100644 --- a/engines/titanic/game/sgt/drawer.cpp +++ b/engines/titanic/game/sgt/drawer.cpp @@ -53,7 +53,7 @@ bool CDrawer::TurnOn(CTurnOn *msg) { _endFrame = 75; setVisible(true); _statics->_drawer = "Open"; - playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); playSound("b#10.wav"); } @@ -66,7 +66,7 @@ bool CDrawer::TurnOff(CTurnOff *msg) { _startFrame = 75; _endFrame = 100; _isClosed = true; - playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); playSound("b#10.wav"); } diff --git a/engines/titanic/game/sgt/sgt_doors.cpp b/engines/titanic/game/sgt/sgt_doors.cpp index 71eae9800c..2dabd21077 100644 --- a/engines/titanic/game/sgt/sgt_doors.cpp +++ b/engines/titanic/game/sgt/sgt_doors.cpp @@ -60,9 +60,9 @@ bool CSGTDoors::EnterViewMsg(CEnterViewMsg *msg) { if (pet->getRooms1CC() == 1) playMovie(START_FRAMES[roomNum], END_FRAMES[roomNum], - MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); else - playMovie(0, 12, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(0, 12, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } return true; @@ -89,9 +89,9 @@ bool CSGTDoors::LeaveRoomMsg(CLeaveRoomMsg *msg) { if (pet->getRooms1CC() == 1) playMovie(START_FRAMES[roomNum], END_FRAMES[roomNum], - MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); else - playMovie(12, 25, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(12, 25, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } return true; diff --git a/engines/titanic/game/sgt/sgt_navigation.cpp b/engines/titanic/game/sgt/sgt_navigation.cpp index 031226226f..d0b57ba1ec 100644 --- a/engines/titanic/game/sgt/sgt_navigation.cpp +++ b/engines/titanic/game/sgt/sgt_navigation.cpp @@ -71,9 +71,9 @@ bool CSGTNavigation::StatusChangeMsg(CStatusChangeMsg *msg) { int startVal = pet->getRooms1CC(); if (startVal > _statics->_changeViewNum) - playMovie(FRAMES[startVal], FRAMES[_statics->_changeViewNum], MOVIE_GAMESTATE); + playMovie(FRAMES[startVal], FRAMES[_statics->_changeViewNum], MOVIE_WAIT_FOR_FINISH); else - playMovie(FRAMES[startVal + 3], FRAMES[_statics->_changeViewNum + 3], MOVIE_GAMESTATE); + playMovie(FRAMES[startVal + 3], FRAMES[_statics->_changeViewNum + 3], MOVIE_WAIT_FOR_FINISH); _cursorId = _statics->_changeViewNum != 1 ? CURSOR_MOVE_FORWARD : CURSOR_INVALID; diff --git a/engines/titanic/game/sgt/sgt_tv.cpp b/engines/titanic/game/sgt/sgt_tv.cpp index ebec334781..5ce7c5b20e 100644 --- a/engines/titanic/game/sgt/sgt_tv.cpp +++ b/engines/titanic/game/sgt/sgt_tv.cpp @@ -46,7 +46,7 @@ bool CSGTTV::TurnOff(CTurnOff *msg) { _isClosed = true; _startFrame = 6; _endFrame = 12; - playMovie(6, 12, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(6, 12, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } return true; @@ -60,7 +60,7 @@ bool CSGTTV::TurnOn(CTurnOn *msg) { _isClosed = false; _startFrame = 1; _endFrame = 6; - playMovie(1, 6, MOVIE_GAMESTATE); + playMovie(1, 6, MOVIE_WAIT_FOR_FINISH); } return true; diff --git a/engines/titanic/game/sgt/toilet.cpp b/engines/titanic/game/sgt/toilet.cpp index 544cdda0c6..0f796c2b9d 100644 --- a/engines/titanic/game/sgt/toilet.cpp +++ b/engines/titanic/game/sgt/toilet.cpp @@ -50,7 +50,7 @@ bool CToilet::TurnOn(CTurnOn *msg) { _isClosed = false; _startFrame = 0; _endFrame = 11; - playMovie(0, 11, MOVIE_GAMESTATE); + playMovie(0, 11, MOVIE_WAIT_FOR_FINISH); playSound("b#1.wav"); } @@ -64,7 +64,7 @@ bool CToilet::TurnOff(CTurnOff *msg) { _isClosed = true; _startFrame = 11; _endFrame = 18; - playMovie(11, 18, MOVIE_GAMESTATE); + playMovie(11, 18, MOVIE_WAIT_FOR_FINISH); playSound("b#1.wav"); } diff --git a/engines/titanic/game/sgt/vase.cpp b/engines/titanic/game/sgt/vase.cpp index f9ee292be2..e7b427c28f 100644 --- a/engines/titanic/game/sgt/vase.cpp +++ b/engines/titanic/game/sgt/vase.cpp @@ -47,7 +47,7 @@ bool CVase::TurnOn(CTurnOn *msg) { _isClosed = false; _startFrame = 1; _endFrame = 12; - playMovie(1, 12, MOVIE_GAMESTATE); + playMovie(1, 12, MOVIE_WAIT_FOR_FINISH); } return true; @@ -61,7 +61,7 @@ bool CVase::TurnOff(CTurnOff *msg) { _isClosed = true; _startFrame = 12; _endFrame = 25; - playMovie(12, 25, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(12, 25, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } return true; diff --git a/engines/titanic/game/sgt/washstand.cpp b/engines/titanic/game/sgt/washstand.cpp index 5be722bec4..217e36c1e9 100644 --- a/engines/titanic/game/sgt/washstand.cpp +++ b/engines/titanic/game/sgt/washstand.cpp @@ -47,7 +47,7 @@ bool CWashstand::TurnOn(CTurnOn *msg) { _isClosed = false; _startFrame = 0; _endFrame = 14; - playMovie(0, 14, MOVIE_GAMESTATE); + playMovie(0, 14, MOVIE_WAIT_FOR_FINISH); playSound("b#14.wav"); } @@ -61,7 +61,7 @@ bool CWashstand::TurnOff(CTurnOff *msg) { _isClosed = true; _startFrame = 14; _endFrame = 28; - playMovie(14, 28, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(14, 28, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); playSound("b#14.wav"); } diff --git a/engines/titanic/game/starling_puret.cpp b/engines/titanic/game/starling_puret.cpp index 2f1909d963..f598f134ba 100644 --- a/engines/titanic/game/starling_puret.cpp +++ b/engines/titanic/game/starling_puret.cpp @@ -59,7 +59,7 @@ bool CStarlingPuret::EnterViewMsg(CEnterViewMsg *msg) { changeMsg._newStatus = 1; changeMsg.execute("PromDeckStarlings"); - playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); CSignalObject signalMsg; signalMsg._numValue = 4; signalMsg.execute("PromDeckStarlings"); diff --git a/engines/titanic/game/sub_glass.cpp b/engines/titanic/game/sub_glass.cpp index 041f49097d..48cc84815a 100644 --- a/engines/titanic/game/sub_glass.cpp +++ b/engines/titanic/game/sub_glass.cpp @@ -88,7 +88,7 @@ bool CSUBGlass::SignalObject(CSignalObject *msg) { setVisible(true); if (_signalStartFrame >= 0) { - playMovie(_signalStartFrame, _signalEndFrame, MOVIE_GAMESTATE); + playMovie(_signalStartFrame, _signalEndFrame, MOVIE_WAIT_FOR_FINISH); playSound("z#30.wav"); _fieldBC = false; } diff --git a/engines/titanic/game/sweet_bowl.cpp b/engines/titanic/game/sweet_bowl.cpp index 7a3832e7c2..a1d0dc2b01 100644 --- a/engines/titanic/game/sweet_bowl.cpp +++ b/engines/titanic/game/sweet_bowl.cpp @@ -55,7 +55,7 @@ bool CSweetBowl::EnterViewMsg(CEnterViewMsg *msg) { bool CSweetBowl::ActMsg(CActMsg *msg) { if (msg->_action == "Jiggle") { setVisible(true); - playMovie(MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); playSound(getRandomNumber(1) == 1 ? "b#42.wav" : "b#43.wav"); } diff --git a/engines/titanic/game/throw_tv_down_well.cpp b/engines/titanic/game/throw_tv_down_well.cpp index be61f6e9ab..680fc7e29f 100644 --- a/engines/titanic/game/throw_tv_down_well.cpp +++ b/engines/titanic/game/throw_tv_down_well.cpp @@ -60,7 +60,7 @@ bool CThrowTVDownWell::ActMsg(CActMsg *msg) { } bool CThrowTVDownWell::EnterViewMsg(CEnterViewMsg *msg) { - playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); movieEvent(49); return true; } diff --git a/engines/titanic/game/transport/lift.cpp b/engines/titanic/game/transport/lift.cpp index a6f45bda98..8dfc55905a 100644 --- a/engines/titanic/game/transport/lift.cpp +++ b/engines/titanic/game/transport/lift.cpp @@ -120,20 +120,20 @@ bool CLift::StatusChangeMsg(CStatusChangeMsg *msg) { if (oldClass == newClass) { debugStr = CString::format("Same (%d-%d)", _startFrame, _endFrame); - playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } else if (oldClass == 1 && newClass == 2) { debugStr = CString::format("1 to 2 (%d-108, 108-%d)", _startFrame, _endFrame); - playMovie(_startFrame, 108, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); - playMovie(108, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_startFrame, 108, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); + playMovie(108, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } else if (oldClass == 1 && newClass == 3) { debugStr = CString::format("1 to 3 (%d-108, 108-190, 190-%d)", _startFrame, _endFrame); - playMovie(_startFrame, 108, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); - playMovie(108, 190, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); - playMovie(190, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_startFrame, 108, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); + playMovie(108, 190, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); + playMovie(190, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } else { debugStr = CString::format("2 to 3 (%d-190, 190-%d)", _startFrame, _endFrame); - playMovie(_startFrame, 190, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); - playMovie(190, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_startFrame, 190, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); + playMovie(190, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } } @@ -144,20 +144,20 @@ bool CLift::StatusChangeMsg(CStatusChangeMsg *msg) { if (oldClass == newClass) { debugStr = CString::format("Same (%d-%d)", _startFrame, _endFrame); - playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } else if (oldClass == 3 && newClass == 2) { debugStr = CString::format("3 to 2 (%d-407, 407-%d)", _startFrame, _endFrame); - playMovie(_startFrame, 407, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); - playMovie(407, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_startFrame, 407, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); + playMovie(407, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } else if (oldClass == 3 && newClass == 1) { debugStr = CString::format("3 to 1 (%d-407, 407-489, 489-%d)", _startFrame, _endFrame); - playMovie(_startFrame, 407, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); - playMovie(407, 489, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); - playMovie(489, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_startFrame, 407, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); + playMovie(407, 489, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); + playMovie(489, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } else { debugStr = CString::format("2 to 1 (%d-489, 489-%d)", _startFrame, _endFrame); - playMovie(_startFrame, 489, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); - playMovie(489, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_startFrame, 489, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); + playMovie(489, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } } diff --git a/engines/titanic/game/transport/pellerator.cpp b/engines/titanic/game/transport/pellerator.cpp index 095202d176..0228f9bc8b 100644 --- a/engines/titanic/game/transport/pellerator.cpp +++ b/engines/titanic/game/transport/pellerator.cpp @@ -83,7 +83,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(315, 323, 0); for (int idx = 0; idx < 3; ++idx) playMovie(299, 304, 0); - playMovie(305, 313, MOVIE_GAMESTATE); + playMovie(305, 313, MOVIE_WAIT_FOR_FINISH); break; case 2: @@ -95,7 +95,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(153, 197, 0); for (int idx = 0; idx < 5; ++idx) playMovie(253, 263, 0); - playMovie(290, 293, MOVIE_GAMESTATE); + playMovie(290, 293, MOVIE_WAIT_FOR_FINISH); break; case 4: @@ -107,7 +107,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(253, 263, 0); for (int idx = 0; idx < 7; ++idx) playMovie(336, 341, 0); - playMovie(342, 348, MOVIE_GAMESTATE); + playMovie(342, 348, MOVIE_WAIT_FOR_FINISH); break; case 5: @@ -130,7 +130,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(315, 323, 0); for (int idx = 0; idx < 3; ++idx) playMovie(299, 304, 0); - playMovie(305, 313, MOVIE_GAMESTATE); + playMovie(305, 313, MOVIE_WAIT_FOR_FINISH); break; case 2: @@ -139,7 +139,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(299, 304, 0); for (int idx = 0; idx < 15; ++idx) playMovie(245, 255, 0); - playMovie(264, 267, MOVIE_GAMESTATE); + playMovie(264, 267, MOVIE_WAIT_FOR_FINISH); ++_destination; break; @@ -149,7 +149,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(245, 255, 0); for (int idx = 0; idx < 7; ++idx) playMovie(336, 341, 0); - playMovie(342, 348, MOVIE_GAMESTATE); + playMovie(342, 348, MOVIE_WAIT_FOR_FINISH); break; case 5: @@ -160,7 +160,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(245, 255, 0); for (int idx = 0; idx < 3; ++idx) playMovie(299, 304, 0); - playMovie(305, 313, MOVIE_GAMESTATE); + playMovie(305, 313, MOVIE_WAIT_FOR_FINISH); break; default: @@ -184,7 +184,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(351, 359, 0); for (int idx = 0; idx < 3; ++idx) playMovie(336, 341, 0); - playMovie(342, 348, MOVIE_GAMESTATE); + playMovie(342, 348, MOVIE_WAIT_FOR_FINISH); break; case 3: @@ -196,7 +196,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(245, 255, 0); for (int idx = 0; idx < 3; ++idx) playMovie(336, 341, 0); - playMovie(342, 348, MOVIE_GAMESTATE); + playMovie(342, 348, MOVIE_WAIT_FOR_FINISH); --_destination; break; @@ -209,7 +209,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(78, 149, 0); for (int idx = 0; idx < 5; ++idx) playMovie(245, 255, 0); - playMovie(264, 267, MOVIE_GAMESTATE); + playMovie(264, 267, MOVIE_WAIT_FOR_FINISH); break; case 5: @@ -221,7 +221,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(78, 149, 0); for (int idx = 0; idx < 3; ++idx) playMovie(336, 341, 0); - playMovie(342, 348, MOVIE_GAMESTATE); + playMovie(342, 348, MOVIE_WAIT_FOR_FINISH); break; default: @@ -236,7 +236,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(351, 359, 0); for (int idx = 0; idx < 3; ++idx) playMovie(336, 341, 0); - playMovie(342, 348, MOVIE_GAMESTATE); + playMovie(342, 348, MOVIE_WAIT_FOR_FINISH); break; case 3: @@ -245,7 +245,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(253, 263, 0); for (int idx = 0; idx < 3; ++idx) playMovie(336, 341, 0); - playMovie(342, 348, MOVIE_GAMESTATE); + playMovie(342, 348, MOVIE_WAIT_FOR_FINISH); --_destination; break; @@ -255,7 +255,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(299, 304, 0); for (int idx = 0; idx < 15; ++idx) playMovie(253, 263, 0); - playMovie(290, 293, MOVIE_GAMESTATE); + playMovie(290, 293, MOVIE_WAIT_FOR_FINISH); break; case 5: @@ -266,7 +266,7 @@ bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) { playMovie(253, 263, 0); for (int idx = 0; idx < 3; ++idx) playMovie(336, 341, 0); - playMovie(342, 348, MOVIE_GAMESTATE); + playMovie(342, 348, MOVIE_WAIT_FOR_FINISH); break; default: diff --git a/engines/titanic/game/wheel_button.cpp b/engines/titanic/game/wheel_button.cpp index 730a5d9005..71532e52af 100644 --- a/engines/titanic/game/wheel_button.cpp +++ b/engines/titanic/game/wheel_button.cpp @@ -31,33 +31,33 @@ BEGIN_MESSAGE_MAP(CWheelButton, CBackground) END_MESSAGE_MAP() CWheelButton::CWheelButton() : CBackground(), - _fieldE0(false), _timerId(0), _fieldE8(0) { + _blinking(false), _timerId(0), _unused5(0) { } void CWheelButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_blinking, indent); file->writeNumberLine(_timerId, indent); - file->writeNumberLine(_fieldE8, indent); + file->writeNumberLine(_unused5, indent); CBackground::save(file, indent); } void CWheelButton::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); + _blinking = file->readNumber(); _timerId = file->readNumber(); - _fieldE8 = file->readNumber(); + _unused5 = file->readNumber(); CBackground::load(file); } bool CWheelButton::SignalObject(CSignalObject *msg) { - bool oldFlag = _fieldE0; - _fieldE0 = msg->_numValue != 0; + bool oldBlinking = _blinking; + _blinking = msg->_numValue != 0; - if (oldFlag != _fieldE0) { - if (_fieldE0) { + if (oldBlinking != _blinking) { + if (_blinking) { _timerId = addTimer(500, 500); } else { stopAnimTimer(_timerId); diff --git a/engines/titanic/game/wheel_button.h b/engines/titanic/game/wheel_button.h index 2725e60622..7bdcecef75 100644 --- a/engines/titanic/game/wheel_button.h +++ b/engines/titanic/game/wheel_button.h @@ -33,9 +33,9 @@ class CWheelButton : public CBackground { bool TimerMsg(CTimerMsg *msg); bool LeaveViewMsg(CLeaveViewMsg *msg); public: - bool _fieldE0; + bool _blinking; int _timerId; - int _fieldE8; + int _unused5; public: CLASSDEF; CWheelButton(); diff --git a/engines/titanic/game/wheel_hotspot.cpp b/engines/titanic/game/wheel_hotspot.cpp index aeca7130b5..aec1c8b96d 100644 --- a/engines/titanic/game/wheel_hotspot.cpp +++ b/engines/titanic/game/wheel_hotspot.cpp @@ -31,36 +31,36 @@ END_MESSAGE_MAP() void CWheelHotSpot::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_active, indent); + file->writeNumberLine(_action, indent); CBackground::save(file, indent); } void CWheelHotSpot::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); + _active = file->readNumber(); + _action = (WheelHotspotAction)file->readNumber(); CBackground::load(file); } bool CWheelHotSpot::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { - if (_fieldE0) { + if (_active) { CActMsg actMsg; - switch (_fieldE4) { - case 1: + switch (_action) { + case WH_STOP: actMsg._action = "Stop"; actMsg.execute("CaptainsWheel"); break; - case 2: + case WH_CRUISE: actMsg._action = "Cruise"; actMsg.execute("CaptainsWheel"); break; - case 3: + case WH_GO: actMsg._action = "Go"; actMsg.execute("CaptainsWheel"); break; @@ -68,7 +68,7 @@ bool CWheelHotSpot::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { default: break; } - } else if (_fieldE4 == 3) { + } else if (_action == WH_GO) { petDisplayMessage(GO_WHERE); } @@ -76,7 +76,7 @@ bool CWheelHotSpot::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { } bool CWheelHotSpot::SignalObject(CSignalObject *msg) { - _fieldE0 = msg->_numValue != 0; + _active = msg->_numValue != 0; return true; } diff --git a/engines/titanic/game/wheel_hotspot.h b/engines/titanic/game/wheel_hotspot.h index e9071a2fa4..41da0fba81 100644 --- a/engines/titanic/game/wheel_hotspot.h +++ b/engines/titanic/game/wheel_hotspot.h @@ -27,16 +27,20 @@ namespace Titanic { +enum WheelHotspotAction { + WH_NONE = 0, WH_STOP = 1, WH_CRUISE = 2, WH_GO = 3 +}; + class CWheelHotSpot : public CBackground { DECLARE_MESSAGE_MAP; bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); bool SignalObject(CSignalObject *msg); public: - int _fieldE0; - int _fieldE4; + bool _active; + WheelHotspotAction _action; public: CLASSDEF; - CWheelHotSpot() : CBackground(), _fieldE0(0), _fieldE4(0) {} + CWheelHotSpot() : CBackground(), _active(false), _action(WH_NONE) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/wheel_spin_horn.cpp b/engines/titanic/game/wheel_spin_horn.cpp index b01cc678df..c299ffc8ff 100644 --- a/engines/titanic/game/wheel_spin_horn.cpp +++ b/engines/titanic/game/wheel_spin_horn.cpp @@ -24,20 +24,39 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CWheelSpinHorn, CWheelSpin) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CWheelSpinHorn::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string1, indent); - file->writeQuotedLine(_string2, indent); + file->writeQuotedLine(_soundName, indent); + file->writeQuotedLine(_message, indent); CWheelSpin::save(file, indent); } void CWheelSpinHorn::load(SimpleFile *file) { file->readNumber(); - _string1 = file->readString(); - _string2 = file->readString(); + _soundName = file->readString(); + _message = file->readString(); CWheelSpin::load(file); } +bool CWheelSpinHorn::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_active) { + if (!_soundName.empty()) + playSound(_soundName); + + if (!_message.empty()) + petDisplayMessage(_message); + + CActMsg actMsg("Honk"); + actMsg.execute("CaptainsWheel"); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/wheel_spin_horn.h b/engines/titanic/game/wheel_spin_horn.h index 21182253b3..b8546b01b6 100644 --- a/engines/titanic/game/wheel_spin_horn.h +++ b/engines/titanic/game/wheel_spin_horn.h @@ -28,9 +28,11 @@ namespace Titanic { class CWheelSpinHorn : public CWheelSpin { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: - CString _string1; - CString _string2; + CString _soundName; + CString _message; public: CLASSDEF; diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp index 96aeda1b83..5f51498e93 100644 --- a/engines/titanic/game_manager.cpp +++ b/engines/titanic/game_manager.cpp @@ -276,7 +276,7 @@ void CGameManager::frameMessage(CRoomItem *room) { CFrameMsg frameMsg(g_vm->_events->getTicksCount()); frameMsg.execute(room, nullptr, MSGFLAG_SCAN); - if (!_soundMaker) { + if (_gameState._soundMakerAllowed && !_soundMaker) { // Check for a sound maker in the room _soundMaker = dynamic_cast<CBackgroundSoundMaker *>( _project->findByName("zBackgroundSoundMaker")); diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp index 964d6e604a..7ddd16ab22 100644 --- a/engines/titanic/game_state.cpp +++ b/engines/titanic/game_state.cpp @@ -46,8 +46,8 @@ bool CGameStateMovieList::empty() { CGameState::CGameState(CGameManager *gameManager) : _gameManager(gameManager), _gameLocation(this), _passengerClass(NO_CLASS), _priorClass(NO_CLASS), _mode(GSMODE_NONE), _seasonNum(SEASON_SUMMER), - _petActive(false), _field1C(false), _quitGame(false), _parrotMet(false), - _nodeChangeCtr(0), _nodeEnterTicks(0), _field38(0) { + _petActive(false), _soundMakerAllowed(false), _quitGame(false), _parrotMet(false), + _nodeChangeCtr(0), _nodeEnterTicks(0), _parrotResponseIndex(0) { } void CGameState::save(SimpleFile *file) const { @@ -56,9 +56,9 @@ void CGameState::save(SimpleFile *file) const { file->writeNumber(_priorClass); file->writeNumber(_seasonNum); file->writeNumber(_parrotMet); - file->writeNumber(_field38); + file->writeNumber(_parrotResponseIndex); _gameLocation.save(file); - file->writeNumber(_field1C); + file->writeNumber(_soundMakerAllowed); } void CGameState::load(SimpleFile *file) { @@ -67,10 +67,10 @@ void CGameState::load(SimpleFile *file) { _priorClass = (PassengerClass)file->readNumber(); _seasonNum = (Season)file->readNumber(); _parrotMet = file->readNumber(); - _field38 = file->readNumber(); + _parrotResponseIndex = file->readNumber(); _gameLocation.load(file); - _field1C = file->readNumber(); + _soundMakerAllowed = file->readNumber(); _nodeChangeCtr = 0; _nodeEnterTicks = 0; } diff --git a/engines/titanic/game_state.h b/engines/titanic/game_state.h index 5d0f67c02c..547e8f8221 100644 --- a/engines/titanic/game_state.h +++ b/engines/titanic/game_state.h @@ -69,13 +69,13 @@ public: GameStateMode _mode; Season _seasonNum; bool _petActive; - bool _field1C; + bool _soundMakerAllowed; bool _quitGame; bool _parrotMet; uint _nodeChangeCtr; uint32 _nodeEnterTicks; Point _mousePos; - int _field38; + int _parrotResponseIndex; public: CGameState(CGameManager *gameManager); @@ -151,9 +151,21 @@ public: */ bool getParrotMet() const { return _parrotMet; } + /** + * Gets the counter for the number of times different nodes have + * been entered + */ int getNodeChangedCtr() const { return _nodeChangeCtr; } + + /** + * Gets the node enter ticks amount + */ uint32 getNodeEnterTicks() const { return _nodeEnterTicks; } - void inc38() { ++_field38; } + + /** + * Increments the index to use for parrot idle responses + */ + void incParrotResponse() { ++_parrotResponseIndex; } }; } // End of namespace Titanic diff --git a/engines/titanic/gfx/toggle_switch.cpp b/engines/titanic/gfx/toggle_switch.cpp index 815f96cb5a..dae9acba0e 100644 --- a/engines/titanic/gfx/toggle_switch.cpp +++ b/engines/titanic/gfx/toggle_switch.cpp @@ -52,9 +52,9 @@ void CToggleSwitch::load(SimpleFile *file) { bool CToggleSwitch::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { _pressed = !_pressed; if (_pressed) - fn10(0, 0, 0); + setToggleColor(0, 0, 0); else - fn10(0xff, 0xff, 0xff); + setToggleColor(0xff, 0xff, 0xff); return true; } diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index 6832c69f3c..a1e9ccbf9d 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -273,7 +273,7 @@ MESSAGE1(CGetChevRoomNum, int, roomNum, 0); MESSAGE2(CHoseConnectedMsg, bool, connected, true, CGameObject *, object, nullptr); MESSAGE0(CInitializeAnimMsg); MESSAGE1(CIsEarBowlPuzzleDone, int, value, 0); -MESSAGE3(CIsHookedOnMsg, Rect, rect, Rect(), bool, result, false, CString, string1, ""); +MESSAGE3(CIsHookedOnMsg, Rect, rect, Rect(), bool, isHooked, false, CString, armName, ""); MESSAGE1(CIsParrotPresentMsg, bool, value, false); MESSAGE1(CKeyCharMsg, int, key, 32); MESSAGE2(CLeaveNodeMsg, CNodeItem *, oldNode, nullptr, CNodeItem *, newNode, nullptr); @@ -304,8 +304,8 @@ MESSAGE2(CParrotSpeakMsg, CString, target, "", CString, action, ""); MESSAGE2(CParrotTriesChickenMsg, int, value1, 0, int, value2, 0); MESSAGE1(CPhonographPlayMsg, int, value, 0); MESSAGE0(CPhonographReadyToPlayMsg); -MESSAGE1(CPhonographRecordMsg, int, value, 0); -MESSAGE3(CPhonographStopMsg, int, value1, 0, int, value2, 0, int, value3, 0); +MESSAGE1(CPhonographRecordMsg, bool, canRecord, false); +MESSAGE3(CPhonographStopMsg, bool, leavingRoom, false, bool, cylinderPresent, false, bool, dontStop, false); MESSAGE2(CPlayRangeMsg, int, value1, 0, int, value2, 0); MESSAGE2(CPlayerTriesRestaurantTableMsg, int, tableId, 0, bool, result, false); MESSAGE1(CPreSaveMsg, int, value, 0); @@ -314,7 +314,7 @@ MESSAGE2(CPumpingMsg, int, value, 0, CGameObject *, object, nullptr); MESSAGE1(CPutBotBackInHisBoxMsg, int, value, 0); MESSAGE1(CPutParrotBackMsg, int, value, 0); MESSAGE0(CPuzzleSolvedMsg); -MESSAGE3(CQueryCylinderHolderMsg, int, value1, 0, int, value2, 0, CTreeItem *, target, (CTreeItem *)nullptr); +MESSAGE3(CQueryCylinderHolderMsg, bool, isOpen, false, bool, isPresent, false, CTreeItem *, target, (CTreeItem *)nullptr); MESSAGE1(CQueryCylinderMsg, CString, name, ""); MESSAGE1(CQueryCylinderNameMsg, CString, name, ""); MESSAGE3(CQueryCylinderTypeMsg, int, value1, 0, int, value2, 0, int, value3, 0); @@ -378,6 +378,7 @@ MESSAGE1(CUseWithCharMsg, CCharacter *, character, nullptr); MESSAGE1(CUseWithOtherMsg, CGameObject *, other, 0); MESSAGE1(CVirtualKeyCharMsg, Common::KeyState, keyState, Common::KeyState()); MESSAGE1(CVisibleMsg, bool, visible, true); +MESSAGE1(CCheckCodeWheelsMsg, bool, isCorrect, true); } // End of namespace Titanic diff --git a/engines/titanic/moves/enter_bridge.cpp b/engines/titanic/moves/enter_bridge.cpp index fb44fe2e02..a9fbb5aff1 100644 --- a/engines/titanic/moves/enter_bridge.cpp +++ b/engines/titanic/moves/enter_bridge.cpp @@ -45,7 +45,7 @@ bool CEnterBridge::EnterRoomMsg(CEnterRoomMsg *msg) { CActMsg actMsg("Disable"); actMsg.execute("ShipAnnouncements"); - setState1C(false); + stateSetSoundMakerAllowed(false); _flag = false; } diff --git a/engines/titanic/moves/enter_sec_class_state.cpp b/engines/titanic/moves/enter_sec_class_state.cpp index af2bc4ac00..9ea8ae732a 100644 --- a/engines/titanic/moves/enter_sec_class_state.cpp +++ b/engines/titanic/moves/enter_sec_class_state.cpp @@ -85,9 +85,9 @@ bool CEnterSecClassState::StatusChangeMsg(CStatusChangeMsg *msg) { if (msg->_newStatus != 3) { if (msg->_newStatus == 2 && _mode == 1) - playMovie(0, 10, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(0, 10, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); else if (msg->_newStatus == 1) - playMovie(11, 21, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(11, 21, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } _cursorId = msg->_newStatus == 2 ? CURSOR_MOVE_FORWARD : CURSOR_INVALID; diff --git a/engines/titanic/npcs/barbot.cpp b/engines/titanic/npcs/barbot.cpp index 58575d1c35..489ed39c4b 100644 --- a/engines/titanic/npcs/barbot.cpp +++ b/engines/titanic/npcs/barbot.cpp @@ -166,7 +166,7 @@ bool CBarbot::ActMsg(CActMsg *msg) { playRange(_frames[7]); playRange(_frames[8]); playRange(_frames[13]); - playRange(_frames[40], MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playRange(_frames[40], MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _frameNum = _frames[40]._endFrame; } } else if (msg->_action == "GiveBackVisCentre") { @@ -316,7 +316,7 @@ bool CBarbot::TurnOn(CTurnOn *msg) { playRange(_frames[38], MOVIE_NOTIFY_OBJECT); playRange(_frames[58], MOVIE_NOTIFY_OBJECT); playRange(_frames[57], MOVIE_NOTIFY_OBJECT); - playRange(_frames[56], MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playRange(_frames[56], MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _frameNum = _frames[56]._endFrame; } else { playRange(_frames[38]); @@ -363,13 +363,13 @@ bool CBarbot::TurnOff(CTurnOff *msg) { if (_visCenterOnCounter) { // Barbot will put away the vision center - playRange(_frames[28], MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playRange(_frames[28], MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _frameNum = _frames[28]._endFrame; _visCenterOnCounter = false; _field134 = 1; } - playRange(_frames[29], MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playRange(_frames[29], MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); movieEvent(_frames[29]._startFrame); _frameNum = _frames[29]._endFrame; _fieldC4 = 0; @@ -560,7 +560,7 @@ bool CBarbot::TrueTalkTriggerActionMsg(CTrueTalkTriggerActionMsg *msg) { _frameNum = _frames[27]._endFrame; } else if (!_gottenDrunk && _drunkFlag) { playRange(_frames[45], MOVIE_NOTIFY_OBJECT); - playRange(_frames[44], MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playRange(_frames[44], MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _frameNum = _frames[44]._endFrame; } break; diff --git a/engines/titanic/npcs/bellbot.cpp b/engines/titanic/npcs/bellbot.cpp index 26c9b13e40..36c57fe467 100644 --- a/engines/titanic/npcs/bellbot.cpp +++ b/engines/titanic/npcs/bellbot.cpp @@ -89,7 +89,7 @@ bool CBellBot::OnSummonBotMsg(COnSummonBotMsg *msg) { _npcFlags &= ~NPCFLAG_MOVE_LOOP; } - playClip("Walk On", MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playClip("Walk On", MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); movieEvent(); _npcFlags |= NPCFLAG_MOVING; @@ -135,13 +135,13 @@ bool CBellBot::MovieEndMsg(CMovieEndMsg *msg) { } bool CBellBot::Use(CUse *msg) { - dynamic_cast<CCarry *>(msg->_item)->_string1 = "Bellbot"; + dynamic_cast<CCarry *>(msg->_item)->_npcUse = "Bellbot"; return true; } bool CBellBot::DismissBotMsg(CDismissBotMsg *msg) { if (_npcFlags & NPCFLAG_MOVING) { - playClip("Walk Off", MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playClip("Walk Off", MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); if (_npcFlags & NPCFLAG_START_IDLING) { _npcFlags &= ~NPCFLAG_START_IDLING; performAction(true); @@ -168,7 +168,7 @@ bool CBellBot::TrueTalkTriggerActionMsg(CTrueTalkTriggerActionMsg *msg) { case 5: _npcFlags &= ~NPCFLAG_MOVE_START; - playClip("Walk Off", MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playClip("Walk Off", MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); movieEvent(); break; diff --git a/engines/titanic/npcs/bilge_succubus.cpp b/engines/titanic/npcs/bilge_succubus.cpp index 63d0006885..4db4d8d595 100644 --- a/engines/titanic/npcs/bilge_succubus.cpp +++ b/engines/titanic/npcs/bilge_succubus.cpp @@ -75,9 +75,9 @@ bool CBilgeSuccUBus::PETReceiveMsg(CPETReceiveMsg *msg) { if (_style) { if (_receiveStartFrame >= 0) - playMovie(_receiveStartFrame, _receiveEndFrame, MOVIE_GAMESTATE); + playMovie(_receiveStartFrame, _receiveEndFrame, MOVIE_WAIT_FOR_FINISH); if (_afterReceiveStartFrame >= 0) - playMovie(_afterReceiveStartFrame, _afterReceiveEndFrame, MOVIE_GAMESTATE); + playMovie(_afterReceiveStartFrame, _afterReceiveEndFrame, MOVIE_WAIT_FOR_FINISH); playSound("z#28.wav", 70); } else if (!_isOn) { @@ -94,7 +94,7 @@ bool CBilgeSuccUBus::PETReceiveMsg(CPETReceiveMsg *msg) { if (mailObject) { _mailP = mailObject; if (_receiveStartFrame >= 0) - playMovie(_receiveStartFrame, _receiveEndFrame, MOVIE_GAMESTATE); + playMovie(_receiveStartFrame, _receiveEndFrame, MOVIE_WAIT_FOR_FINISH); } else { petDisplayMessage(2, NOTHING_TO_DELIVER); } @@ -138,20 +138,20 @@ bool CBilgeSuccUBus::PETDeliverMsg(CPETDeliverMsg *msg) { playMovie(_sendStartFrame, _sendEndFrame, MOVIE_NOTIFY_OBJECT); if (_sneezing2StartFrame >= 0) { - playMovie(_trayOutStartFrame, _trayOutEndFrame, MOVIE_GAMESTATE); - playMovie(_sneezing1StartFrame, _sneezing1EndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); - playMovie(_sneezing2StartFrame, _sneezing2EndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_trayOutStartFrame, _trayOutEndFrame, MOVIE_WAIT_FOR_FINISH); + playMovie(_sneezing1StartFrame, _sneezing1EndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); + playMovie(_sneezing2StartFrame, _sneezing2EndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); incTransitions(); } } else { startTalking(this, 230012); _sendAction = SA_EATEN; if (_sendStartFrame >= 0) - playMovie(_sendStartFrame, _sendEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_sendStartFrame, _sendEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); if (_receiveStartFrame >= 0) - playMovie(_receiveStartFrame, _receiveEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_receiveStartFrame, _receiveEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); if (_afterReceiveStartFrame >= 0) - playMovie(_afterReceiveStartFrame, _afterReceiveEndFrame, MOVIE_GAMESTATE); + playMovie(_afterReceiveStartFrame, _afterReceiveEndFrame, MOVIE_WAIT_FOR_FINISH); } } else { if (_isFeathers) { @@ -159,17 +159,17 @@ bool CBilgeSuccUBus::PETDeliverMsg(CPETDeliverMsg *msg) { _sendAction = SA_BILGE_FEATHERS; if (_sendStartFrame >= 0) - playMovie(_sendStartFrame, _sendEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_sendStartFrame, _sendEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); if (_receiveStartFrame >= 0) - playMovie(_receiveStartFrame, _receiveEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_receiveStartFrame, _receiveEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); if (_afterReceiveStartFrame >= 0) - playMovie(_afterReceiveStartFrame, _afterReceiveEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_afterReceiveStartFrame, _afterReceiveEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } else { sendMail(petRoomFlags, roomFlags); startTalking(this, 230012); if (_sendStartFrame >= 0) { _sendAction = SA_BILGE_SENT; - playMovie(_sendStartFrame, _sendEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_sendStartFrame, _sendEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } } } diff --git a/engines/titanic/npcs/deskbot.cpp b/engines/titanic/npcs/deskbot.cpp index 56f4d98f18..2b88160e47 100644 --- a/engines/titanic/npcs/deskbot.cpp +++ b/engines/titanic/npcs/deskbot.cpp @@ -306,7 +306,7 @@ bool CDeskbot::TurnOff(CTurnOff *msg) { performAction(1, findView()); _npcFlags = (_npcFlags & ~(NPCFLAG_SPEAKING | NPCFLAG_IDLING | NPCFLAG_START_IDLING)) | NPCFLAG_MOVE_LOOP; - playClip("Closing", MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playClip("Closing", MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); } return true; diff --git a/engines/titanic/npcs/doorbot.cpp b/engines/titanic/npcs/doorbot.cpp index 79e3dafed4..03d723a384 100644 --- a/engines/titanic/npcs/doorbot.cpp +++ b/engines/titanic/npcs/doorbot.cpp @@ -95,7 +95,7 @@ bool CDoorbot::MovieEndMsg(CMovieEndMsg *msg) { case 6: if (clipExistsByEnd("Cloak On", msg->_endFrame)) { petShow(); - setState1C(true); + stateSetSoundMakerAllowed(true); changeView("ServiceElevator.Node 1.S"); changeView("ServiceElevator.Node 1.N"); } @@ -129,7 +129,7 @@ bool CDoorbot::MovieEndMsg(CMovieEndMsg *msg) { _introMovieNum = 0; } else if (clipExistsByEnd("Cloak On", msg->_endFrame)) { petShow(); - setState1C(true); + stateSetSoundMakerAllowed(true); changeView("ServiceElevator.Node 1.S"); } else { CTrueTalkNPC::MovieEndMsg(msg); @@ -185,7 +185,7 @@ bool CDoorbot::OnSummonBotMsg(COnSummonBotMsg *msg) { } playClip(getRandomNumber(1) ? "Whizz On Left" : "Whizz On Right", - MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); movieEvent(); _npcFlags |= NPCFLAG_MOVE_END; @@ -200,7 +200,7 @@ bool CDoorbot::TrueTalkTriggerActionMsg(CTrueTalkTriggerActionMsg *msg) { case 4: _npcFlags = (_npcFlags & ~NPCFLAG_IDLING) | NPCFLAG_SUMMON_BELLBOT; - playClip("Whizz Off Left", MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playClip("Whizz Off Left", MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); break; case 28: { @@ -387,7 +387,7 @@ bool CDoorbot::PutBotBackInHisBoxMsg(CPutBotBackInHisBoxMsg *msg) { bool CDoorbot::DismissBotMsg(CDismissBotMsg *msg) { if (_npcFlags & NPCFLAG_MOVE_END) { playClip(getRandomNumber(1) ? "Whizz Off Left" : "Whizz Off Right", - MOVIE_STOP_PREVIOUS | MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + MOVIE_STOP_PREVIOUS | MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); movieEvent(); if (_npcFlags & NPCFLAG_START_IDLING) { diff --git a/engines/titanic/npcs/maitre_d.cpp b/engines/titanic/npcs/maitre_d.cpp index 88eceab46b..6ac69d9079 100644 --- a/engines/titanic/npcs/maitre_d.cpp +++ b/engines/titanic/npcs/maitre_d.cpp @@ -40,25 +40,24 @@ BEGIN_MESSAGE_MAP(CMaitreD, CTrueTalkNPC) ON_MESSAGE(TriggerNPCEvent) END_MESSAGE_MAP() -int CMaitreD::_v1; - CMaitreD::CMaitreD() : CTrueTalkNPC(), - _string2("z#40.wav"), _string3("z#40.wav"), _field108(0), _field118(1), - _field11C(0), _field12C(0), _field130(1), _field134(0), _timerId(0) { + _priorMusicName("z#40.wav"), _musicName("z#40.wav"), _unused5(0), _hasMusic(true), + _musicSet(false), _fightFlag(false), _unused6(true), _savedFightFlag(false), + _timerId(0), _defeated(false) { } void CMaitreD::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_field108, indent); - file->writeQuotedLine(_string2, indent); - file->writeNumberLine(_field118, indent); - file->writeNumberLine(_field11C, indent); - file->writeQuotedLine(_string3, indent); - file->writeNumberLine(_field12C, indent); - file->writeNumberLine(_field130, indent); - - file->writeNumberLine(_v1, indent); - file->writeNumberLine(_field134, indent); + file->writeNumberLine(_unused5, indent); + file->writeQuotedLine(_priorMusicName, indent); + file->writeNumberLine(_hasMusic, indent); + file->writeNumberLine(_musicSet, indent); + file->writeQuotedLine(_musicName, indent); + file->writeNumberLine(_fightFlag, indent); + file->writeNumberLine(_unused6, indent); + + file->writeNumberLine(_defeated, indent); + file->writeNumberLine(_savedFightFlag, indent); file->writeNumberLine(_timerId, indent); CTrueTalkNPC::save(file, indent); @@ -66,16 +65,16 @@ void CMaitreD::save(SimpleFile *file, int indent) { void CMaitreD::load(SimpleFile *file) { file->readNumber(); - _field108 = file->readNumber(); - _string2 = file->readString(); - _field118 = file->readNumber(); - _field11C = file->readNumber(); - _string3 = file->readString(); - _field12C = file->readNumber(); - _field130 = file->readNumber(); - - _v1 = file->readNumber(); - _field134 = file->readNumber(); + _unused5 = file->readNumber(); + _priorMusicName = file->readString(); + _hasMusic = file->readNumber(); + _musicSet = file->readNumber(); + _musicName = file->readString(); + _fightFlag = file->readNumber(); + _unused6 = file->readNumber(); + + _defeated = file->readNumber(); + _savedFightFlag = file->readNumber(); _timerId = file->readNumber(); CTrueTalkNPC::load(file); @@ -83,10 +82,10 @@ void CMaitreD::load(SimpleFile *file) { bool CMaitreD::RestaurantMusicChanged(CRestaurantMusicChanged *msg) { if (msg->_value.empty()) { - _field118 = 0; + _hasMusic = false; } else { - _string3 = msg->_value; - _field118 = _field11C = 1; + _musicName = msg->_value; + _hasMusic = _musicSet = true; } return true; @@ -94,15 +93,15 @@ bool CMaitreD::RestaurantMusicChanged(CRestaurantMusicChanged *msg) { bool CMaitreD::TrueTalkTriggerActionMsg(CTrueTalkTriggerActionMsg *msg) { if (msg->_action == 8) { - _field12C = 1; + _fightFlag = true; stopAnimTimer(_timerId); _timerId = startAnimTimer("MD Fight", 3500, 0); } else if (msg->_action == 9) { stopAnimTimer(_timerId); _timerId = 0; } else if (msg->_action == 10) { - _field12C = 0; - _v1 = 1; + _fightFlag = false; + _defeated = true; stopAnimTimer(_timerId); _timerId = 0; @@ -115,12 +114,17 @@ bool CMaitreD::TrueTalkTriggerActionMsg(CTrueTalkTriggerActionMsg *msg) { bool CMaitreD::EnterViewMsg(CEnterViewMsg *msg) { setTalking(this, true, findView()); - _field12C = _field134; + _fightFlag = _savedFightFlag; + + if (_musicName != "STMusic" && (!_musicSet || _priorMusicName == _musicName)) + return true; - if (_string3 == "STMusic" && (!_field11C || _string2 == _string3)) + // WORKAROUND: It's possible in the original to not have a music handler set + // if you start and stop the phonograph, then save and restore the game + if (!CMusicRoom::_musicHandler) return true; - if (_string3.contains("nasty ambient")) + if (_musicName.contains("nasty ambient")) startTalking(this, 111, findView()); else if (!CMusicRoom::_musicHandler->checkInstrument(SNAKE)) startTalking(this, 114, findView()); @@ -135,16 +139,17 @@ bool CMaitreD::EnterViewMsg(CEnterViewMsg *msg) { happyMsg.execute("MaitreD Right Arm"); } + _priorMusicName = _musicName; return true; } bool CMaitreD::LeaveViewMsg(CLeaveViewMsg *msg) { - _field134 = _field12C; + _savedFightFlag = _fightFlag; performAction(true); stopAnimTimer(_timerId); _timerId = 0; - _field12C = 0; + _fightFlag = false; return true; } @@ -158,7 +163,7 @@ bool CMaitreD::NPCPlayTalkingAnimationMsg(CNPCPlayTalkingAnimationMsg *msg) { msg->_names = NAMES; CAnimateMaitreDMsg animMsg; - if (_field12C) + if (_fightFlag) animMsg._value = 0; animMsg.execute(this); } @@ -168,7 +173,7 @@ bool CMaitreD::NPCPlayTalkingAnimationMsg(CNPCPlayTalkingAnimationMsg *msg) { bool CMaitreD::TimerMsg(CTimerMsg *msg) { if (msg->_action == "MD Fight") { - if (_field12C && compareViewNameTo("1stClassRestaurant.MaitreD Node.N")) { + if (_fightFlag && compareViewNameTo("1stClassRestaurant.MaitreD Node.N")) { startTalking(this, 131, findView()); } } else { @@ -179,7 +184,7 @@ bool CMaitreD::TimerMsg(CTimerMsg *msg) { } bool CMaitreD::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *msg) { - if (_field12C) { + if (_fightFlag) { stopAnimTimer(_timerId); _timerId = 0; } @@ -189,7 +194,7 @@ bool CMaitreD::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *m } bool CMaitreD::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) { - if (_field12C) { + if (_fightFlag) { stopAnimTimer(_timerId); _timerId = startAnimTimer("MD Fight", 3000 + getRandomNumber(3000)); } @@ -199,7 +204,7 @@ bool CMaitreD::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) } bool CMaitreD::LoadSuccessMsg(CLoadSuccessMsg *msg) { - if (_field12C) { + if (_fightFlag) { _timerId = startAnimTimer("MD Fight", 3000 + getRandomNumber(3000)); } diff --git a/engines/titanic/npcs/maitre_d.h b/engines/titanic/npcs/maitre_d.h index 878c32cc0b..6677a587a8 100644 --- a/engines/titanic/npcs/maitre_d.h +++ b/engines/titanic/npcs/maitre_d.h @@ -41,17 +41,16 @@ class CMaitreD : public CTrueTalkNPC { bool TextInputMsg(CTextInputMsg *msg); bool TriggerNPCEvent(CTriggerNPCEvent *msg); private: - static int _v1; -private: - int _field108; - CString _string2; - int _field118; - int _field11C; - CString _string3; - int _field12C; - int _field130; - int _field134; + int _unused5; + CString _priorMusicName; + bool _hasMusic; + bool _musicSet; + CString _musicName; + bool _fightFlag; + bool _unused6; + bool _savedFightFlag; int _timerId; + bool _defeated; public: CLASSDEF; CMaitreD(); diff --git a/engines/titanic/npcs/parrot.cpp b/engines/titanic/npcs/parrot.cpp index b570bea6ae..6a48837d08 100644 --- a/engines/titanic/npcs/parrot.cpp +++ b/engines/titanic/npcs/parrot.cpp @@ -43,6 +43,7 @@ BEGIN_MESSAGE_MAP(CParrot, CTrueTalkNPC) ON_MESSAGE(PreEnterViewMsg) ON_MESSAGE(PanningAwayFromParrotMsg) ON_MESSAGE(LeaveRoomMsg) + ON_MESSAGE(TrueTalkNotifySpeechEndedMsg) END_MESSAGE_MAP() bool CParrot::_eatingChicken; @@ -475,7 +476,7 @@ bool CParrot::NPCPlayIdleAnimationMsg(CNPCPlayIdleAnimationMsg *msg) { } } else { int id = -1; - switch (stateGet38()) { + switch (getParrotResponse()) { case 0: id = 280107; break; @@ -729,4 +730,15 @@ bool CParrot::LeaveRoomMsg(CLeaveRoomMsg *msg) { return true; } +bool CParrot::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) { + if (msg->_dialogueId == 80022) { + // WORKAROUND: End of parrot speech after having fixed Titania + unlockMouse(); + changeView("Titania.Node 18.N", ""); + } + + return CTrueTalkNPC::TrueTalkNotifySpeechEndedMsg(msg); +} + + } // End of namespace Titanic diff --git a/engines/titanic/npcs/parrot.h b/engines/titanic/npcs/parrot.h index c178a2086a..d3558dfa3e 100644 --- a/engines/titanic/npcs/parrot.h +++ b/engines/titanic/npcs/parrot.h @@ -51,6 +51,7 @@ class CParrot : public CTrueTalkNPC { bool PreEnterViewMsg(CPreEnterViewMsg *msg); bool PanningAwayFromParrotMsg(CPanningAwayFromParrotMsg *msg); bool LeaveRoomMsg(CLeaveRoomMsg *msg); + bool TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg); public: static bool _eatingChicken; static bool _takeOff; diff --git a/engines/titanic/npcs/succubus.cpp b/engines/titanic/npcs/succubus.cpp index 71272fad03..ef681f64b8 100644 --- a/engines/titanic/npcs/succubus.cpp +++ b/engines/titanic/npcs/succubus.cpp @@ -701,11 +701,11 @@ bool CSuccUBus::TurnOff(CTurnOff *msg) { if (_offStartFrame >= 0) { playSound("z#27.wav", 100); - playMovie(_offStartFrame, _offEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_offStartFrame, _offEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); } if (!_signalFlag && _endingStartFrame >= 0) - playMovie(_endingStartFrame, _endingEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playMovie(_endingStartFrame, _endingEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_WAIT_FOR_FINISH); _isOn = false; performAction(true); diff --git a/engines/titanic/npcs/titania.cpp b/engines/titanic/npcs/titania.cpp index db0c85d5f5..e0ea4f1459 100644 --- a/engines/titanic/npcs/titania.cpp +++ b/engines/titanic/npcs/titania.cpp @@ -43,7 +43,7 @@ CTitania::CTitania() : CCharacter() { _ear2 = false; _nose = false; _mouth = false; - _showIntro = true; + _showSpeech = true; } void CTitania::save(SimpleFile *file, int indent) { @@ -59,7 +59,7 @@ void CTitania::save(SimpleFile *file, int indent) { file->writeNumberLine(_ear2, indent); file->writeNumberLine(_nose, indent); file->writeNumberLine(_mouth, indent); - file->writeNumberLine(_showIntro, indent); + file->writeNumberLine(_showSpeech, indent); CCharacter::save(file, indent); } @@ -77,7 +77,7 @@ void CTitania::load(SimpleFile *file) { _ear2 = file->readNumber(); _nose = file->readNumber(); _mouth = file->readNumber(); - _showIntro = file->readNumber(); + _showSpeech = file->readNumber(); CCharacter::load(file); } @@ -99,7 +99,7 @@ bool CTitania::AddHeadPieceMsg(CAddHeadPieceMsg *msg) { _eye2 = true; } else if (msg->_value == "Ear1") { _ear1 = true; - } else if (msg->_value == "Ear2") { + } else if (msg->_value == "Ear 2") { _ear2 = true; } else if (msg->_value == "Mouth") { _mouth = true; @@ -197,8 +197,8 @@ bool CTitania::ActMsg(CActMsg *msg) { } bool CTitania::EnterViewMsg(CEnterViewMsg *msg) { - if (_showIntro) { - _showIntro = false; + if (_showSpeech) { + _showSpeech = false; disableMouse(); petHide(); @@ -216,8 +216,11 @@ bool CTitania::EnterViewMsg(CEnterViewMsg *msg) { } bool CTitania::TimerMsg(CTimerMsg *msg) { - changeView("Titania.Node 18.N", ""); + // WORKAROUND: The original uses the disc change dialog as a pause + // to allow the parrot speech to finish. I've rewritten it to instead + // use the standard TrueTalkNotifySpeechEndedMsg message instead startTalking("PerchedParrot", 80022); + lockMouse(); return true; } diff --git a/engines/titanic/npcs/titania.h b/engines/titanic/npcs/titania.h index 61f8c86018..f94442d317 100644 --- a/engines/titanic/npcs/titania.h +++ b/engines/titanic/npcs/titania.h @@ -46,7 +46,7 @@ private: bool _ear2; bool _nose; bool _mouth; - bool _showIntro; + bool _showSpeech; public: CLASSDEF; CTitania(); diff --git a/engines/titanic/sound/audio_buffer.cpp b/engines/titanic/sound/audio_buffer.cpp index 1f0693181a..636f4a5107 100644 --- a/engines/titanic/sound/audio_buffer.cpp +++ b/engines/titanic/sound/audio_buffer.cpp @@ -27,6 +27,7 @@ namespace Titanic { CAudioBuffer::CAudioBuffer(int maxSize) : _finished(false) { _data.resize(maxSize); + reset(); } void CAudioBuffer::reset() { diff --git a/engines/titanic/sound/music_room_instrument.cpp b/engines/titanic/sound/music_room_instrument.cpp index 5e7bd9bb8c..b92329850b 100644 --- a/engines/titanic/sound/music_room_instrument.cpp +++ b/engines/titanic/sound/music_room_instrument.cpp @@ -234,7 +234,7 @@ void CMusicRoomInstrument::update(int val) { double tempVal = 46.0 - ((double)(val - 14) * 1.43); int frameNum = _field4C; - int frameNum1 = (tempVal - frameNum) * 0.25; + int frameNum1 = (int)((tempVal - frameNum) * 0.25); _gameObjects[1]->playMovie(frameNum1, frameNum1, MOVIE_STOP_PREVIOUS); frameNum += frameNum1; diff --git a/engines/titanic/sound/titania_speech.cpp b/engines/titanic/sound/titania_speech.cpp index d0ff423342..1adce7a5ac 100644 --- a/engines/titanic/sound/titania_speech.cpp +++ b/engines/titanic/sound/titania_speech.cpp @@ -34,16 +34,16 @@ END_MESSAGE_MAP() void CTitaniaSpeech::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_paraNum, indent); - file->writeNumberLine(_frameNum, indent); + file->writeNumberLine(_actionNum, indent); + file->writeNumberLine(_backgroundFrame, indent); CGameObject::save(file, indent); } void CTitaniaSpeech::load(SimpleFile *file) { file->readNumber(); - _paraNum = file->readNumber(); - _frameNum = file->readNumber(); + _actionNum = file->readNumber(); + _backgroundFrame = file->readNumber(); CGameObject::load(file); } @@ -54,16 +54,16 @@ bool CTitaniaSpeech::ActMsg(CActMsg *msg) { CActMsg actMsg; if (msg->_action == "TitaniaSpeech") { - switch (_paraNum) { - case 0: + switch (_actionNum) { + case 1: movieSetAudioTiming(true); loadSound("a#12.wav"); sleep(1000); - playMovie(0, 187, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(0, 187, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); movieEvent(0); break; - case 1: + case 2: loadSound("a#11.wav"); addTimer(0); startAnimTimer("Para2", 300); @@ -74,34 +74,34 @@ bool CTitaniaSpeech::ActMsg(CActMsg *msg) { startAnimTimer("NextPara", 30000); break; - case 2: + case 3: visibleMsg._visible = false; visibleMsg.execute("TitaniaStillControl"); loadSound("a#10.wav"); - playMovie(585, 706, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(585, 706, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); playSound("a#10.wav"); break; - case 3: + case 4: visibleMsg._visible = false; visibleMsg.execute("TitaniaStillControl"); loadSound("a#9.wav"); - playMovie(707, 905, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(707, 905, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); playSound("a#9.wav"); break; - case 4: + case 5: visibleMsg._visible = false; visibleMsg.execute("TitaniaStillControl"); loadSound("a#8.wav"); - playMovie(906, 938, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playMovie(906, 938, MOVIE_WAIT_FOR_FINISH | MOVIE_NOTIFY_OBJECT); playSound("a#8.wav"); break; default: sleep(3000); actMsg._action = "SleepTitania"; - actMsg.execute(this); + actMsg.execute("TitaniaControl"); } } @@ -109,10 +109,10 @@ bool CTitaniaSpeech::ActMsg(CActMsg *msg) { } bool CTitaniaSpeech::MovieEndMsg(CMovieEndMsg *msg) { - if (_paraNum == 5) { + if (_actionNum == 5) { startAnimTimer("NextPara", 0); } else { - if (_paraNum != 1) + if (_actionNum != 1) addTimer(0); startAnimTimer("NextPara", 3000); } @@ -135,12 +135,12 @@ bool CTitaniaSpeech::TimerMsg(CTimerMsg *msg) { if (msg->_action == "NextPara") { visibleMsg.execute("TitaniaStillControl"); - ++_paraNum; + ++_actionNum; actMsg.execute(this); } else if (msg->_action == "Para2") { playSound("a#11.wav"); } else { - frameMsg._frameNumber = _frameNum; + frameMsg._frameNumber = _backgroundFrame++; frameMsg.execute("TitaniaStillControl"); } diff --git a/engines/titanic/sound/titania_speech.h b/engines/titanic/sound/titania_speech.h index 2244bb01af..48e0b7bdad 100644 --- a/engines/titanic/sound/titania_speech.h +++ b/engines/titanic/sound/titania_speech.h @@ -36,10 +36,11 @@ class CTitaniaSpeech : public CGameObject { bool TimerMsg(CTimerMsg *msg); bool EnterRoomMsg(CEnterRoomMsg *msg); private: - int _paraNum, _frameNum; + int _actionNum; + int _backgroundFrame; public: CLASSDEF; - CTitaniaSpeech() : CGameObject(), _paraNum(1), _frameNum(0) {} + CTitaniaSpeech() : CGameObject(), _actionNum(1), _backgroundFrame(0) {} /** * Save the data for the class to file diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp index b094adbafe..c9205c76ac 100644 --- a/engines/titanic/sound/wave_file.cpp +++ b/engines/titanic/sound/wave_file.cpp @@ -171,7 +171,8 @@ void CWaveFile::load(byte *data, uint dataSize) { // Parse the wave header Common::MemoryReadStream wavStream(data, dataSize, DisposeAfterUse::NO); - Audio::loadWAVFromStream(wavStream, _dataSize, _rate, _flags, &_wavType); + if (!Audio::loadWAVFromStream(wavStream, _dataSize, _rate, _flags, &_wavType)) + error("Invalid wave file"); _headerSize = wavStream.pos(); } diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp index dcb004231a..a1c4f33ad2 100644 --- a/engines/titanic/star_control/star_control.cpp +++ b/engines/titanic/star_control/star_control.cpp @@ -133,8 +133,8 @@ void CStarControl::fn1(int action) { // TODO } -bool CStarControl::fn4() { - return _starField.get6(); +bool CStarControl::isSolved() const { + return _starField.isSolved(); } bool CStarControl::canSetStarDestination() const { diff --git a/engines/titanic/star_control/star_control.h b/engines/titanic/star_control/star_control.h index bf964b7cfa..0ee7c6530e 100644 --- a/engines/titanic/star_control/star_control.h +++ b/engines/titanic/star_control/star_control.h @@ -69,7 +69,11 @@ public: virtual void draw(CScreenManager *screenManager); void fn1(int action); - bool fn4(); + + /** + * Returns true if the starfield puzzle has been solved + */ + bool isSolved() const; /** * Returns true if a star destination can be set diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp index 0dbc5fd700..7502f84d3d 100644 --- a/engines/titanic/star_control/star_field.cpp +++ b/engines/titanic/star_control/star_field.cpp @@ -26,7 +26,7 @@ namespace Titanic { CStarField::CStarField() : _val1(0), _val2(0), _val3(0), _val4(true), - _val5(0), _val6(false) { + _val5(0), _isSolved(false) { } void CStarField::load(SimpleFile *file) { @@ -36,7 +36,7 @@ void CStarField::load(SimpleFile *file) { _val2 = file->readNumber(); _val3 = file->readNumber(); _val4 = file->readNumber(); - _val6 = file->readNumber(); + _isSolved = file->readNumber(); } void CStarField::save(SimpleFile *file, int indent) { @@ -46,7 +46,7 @@ void CStarField::save(SimpleFile *file, int indent) { file->writeNumberLine(_val2, indent); file->writeNumberLine(_val3, indent); file->writeNumberLine(_val4, indent); - file->writeNumberLine(_val6, indent); + file->writeNumberLine(_isSolved, indent); } bool CStarField::initDocument() { @@ -119,12 +119,12 @@ int CStarField::get5() const { return _val5; } -void CStarField::update6() { - _val6 = _sub8._field8 == 2; +void CStarField::setSolved() { + _isSolved = _sub8._field8 == 2; } -int CStarField::get6() const { - return _val6; +bool CStarField::isSolved() const { + return _isSolved; } } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_field.h b/engines/titanic/star_control/star_field.h index 91cefbb457..41f01894f4 100644 --- a/engines/titanic/star_control/star_field.h +++ b/engines/titanic/star_control/star_field.h @@ -44,7 +44,7 @@ private: int _val3; bool _val4; int _val5; - bool _val6; + bool _isSolved; public: CStarField(); @@ -77,8 +77,16 @@ public: bool set4(bool val); int get88() const; int get5() const; - void update6(); - int get6() const; + + /** + * Sets the flag that the starfield has been solved + */ + void setSolved(); + + /** + * Returns true if the starfield puzzle has been solved + */ + bool isSolved() const; }; } // End of namespace Titanic diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp index 42e3618b97..a1dbecbe1c 100644 --- a/engines/titanic/support/avi_surface.cpp +++ b/engines/titanic/support/avi_surface.cpp @@ -284,10 +284,13 @@ void AVISurface::copyMovieFrame(const Graphics::Surface &src, Graphics::ManagedS if (src.format.bytesPerPixel == 1) { // Paletted 8-bit, so convert to 16-bit and copy over - Graphics::Surface *s = src.convertTo(dest.format, _decoder->getPalette()); - dest.blitFrom(*s, copyRect, Common::Point(0, 0)); - s->free(); - delete s; + const byte *palette = _decoder->getPalette(); + if (palette) { + Graphics::Surface *s = src.convertTo(dest.format, palette); + dest.blitFrom(*s, copyRect, Common::Point(0, 0)); + s->free(); + delete s; + } } else if (src.format.bytesPerPixel == 2) { // Source is already 16-bit, with no alpha, so do a straight copy dest.blitFrom(src, copyRect, Common::Point(0, 0)); diff --git a/engines/titanic/support/avi_surface.h b/engines/titanic/support/avi_surface.h index f45db3599e..d3442a12f7 100644 --- a/engines/titanic/support/avi_surface.h +++ b/engines/titanic/support/avi_surface.h @@ -34,8 +34,11 @@ class CSoundManager; class CVideoSurface; enum MovieFlag { - MOVIE_REPEAT = 1, MOVIE_STOP_PREVIOUS = 2, MOVIE_NOTIFY_OBJECT = 4, - MOVIE_REVERSE = 8, MOVIE_GAMESTATE = 0x10 + MOVIE_REPEAT = 1, // Repeat movie + MOVIE_STOP_PREVIOUS = 2, // Stop any prior movie playing on the object + MOVIE_NOTIFY_OBJECT = 4, // Notify the object when the movie finishes + MOVIE_REVERSE = 8, // Play the movie in reverse + MOVIE_WAIT_FOR_FINISH = 0x10 // Let finish before playing next movie for object }; class AVIDecoder : public Video::AVIDecoder { diff --git a/engines/titanic/support/files_manager.cpp b/engines/titanic/support/files_manager.cpp index fc09c5702c..cf706974a7 100644 --- a/engines/titanic/support/files_manager.cpp +++ b/engines/titanic/support/files_manager.cpp @@ -106,7 +106,7 @@ void CFilesManager::loadDrive() { } void CFilesManager::insertCD(CScreenManager *screenManager) { - // We not support running game directly from the original CDs, + // We don't support running the game directly from the original CDs, // so this method can remain stubbed } diff --git a/engines/titanic/true_talk/tt_title_script.cpp b/engines/titanic/true_talk/tt_title_script.cpp index 2effb96cc7..b69318dbe5 100644 --- a/engines/titanic/true_talk/tt_title_script.cpp +++ b/engines/titanic/true_talk/tt_title_script.cpp @@ -24,8 +24,7 @@ namespace Titanic { -TTTitleScript::TTTitleScript() : TTscriptBase(1, "", 0, "", 0, -1, -1, -1, 0), - _field50(0), _field5C(-1), _field60(0) { +TTTitleScript::TTTitleScript() : TTscriptBase(1, "", 0, "", 0, -1, -1, -1, 0) { } } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_title_script.h b/engines/titanic/true_talk/tt_title_script.h index f02e591c54..03d1b04ac7 100644 --- a/engines/titanic/true_talk/tt_title_script.h +++ b/engines/titanic/true_talk/tt_title_script.h @@ -29,11 +29,6 @@ namespace Titanic { class TTTitleScript : public TTscriptBase { -private: - int _field50; - TTstring _string1; - int _field5C; - int _field60; public: TTTitleScript(); }; diff --git a/gui/options.cpp b/gui/options.cpp index aa5f7b46bb..8b459b2739 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -2013,7 +2013,7 @@ void GlobalOptionsDialog::reflowLayout() { void GlobalOptionsDialog::setupCloudTab() { int serverLabelPosition = -1; //no override #ifdef USE_LIBCURL - _selectedStorageIndex = _storagePopUp->getSelectedTag(); + _selectedStorageIndex = (_storagePopUp ? _storagePopUp->getSelectedTag() : Cloud::kStorageNoneId); if (_storagePopUpDesc) _storagePopUpDesc->setVisible(true); if (_storagePopUp) _storagePopUp->setVisible(true); diff --git a/po/ca_ES.po b/po/ca_ES.po index 92b88c0344..dd647df6fe 100644 --- a/po/ca_ES.po +++ b/po/ca_ES.po @@ -8,10 +8,10 @@ msgstr "" "Project-Id-Version: ScummVM 1.6.0git\n" "Report-Msgid-Bugs-To: scummvm-devel@lists.scummvm.org\n" "POT-Creation-Date: 2017-02-11 08:56+0100\n" -"PO-Revision-Date: 2016-12-04 15:46+0000\n" +"PO-Revision-Date: 2017-02-20 14:15+0000\n" "Last-Translator: Eugene Sandulenko <sev@scummvm.org>\n" -"Language-Team: Catalan <https://translations.scummvm.org/projects/scummvm/" -"scummvm/ca/>\n" +"Language-Team: Catalan " +"<https://translations.scummvm.org/projects/scummvm/scummvm/ca/>\n" "Language: ca_ES\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-1\n" @@ -79,9 +79,8 @@ msgid "Choose" msgstr "Escull" #: gui/downloaddialog.cpp:48 -#, fuzzy msgid "Select directory where to download game data" -msgstr "Seleccioneu el directori amb les dades del joc" +msgstr "Seleccioneu el directori on descarregar les dades del joc" #: gui/downloaddialog.cpp:49 gui/editgamedialog.cpp:470 gui/launcher.cpp:197 msgid "Select directory with game data" @@ -89,30 +88,32 @@ msgstr "Seleccioneu el directori amb les dades del joc" #: gui/downloaddialog.cpp:51 gui/downloaddialog.cpp:263 msgid "From: " -msgstr "" +msgstr "Des de: " #: gui/downloaddialog.cpp:52 gui/downloaddialog.cpp:264 msgid "To: " -msgstr "" +msgstr "Fins: " #: gui/downloaddialog.cpp:63 msgid "Cancel download" -msgstr "" +msgstr "Cancelˇlar descārrega" #: gui/downloaddialog.cpp:65 msgctxt "lowres" msgid "Cancel download" -msgstr "" +msgstr "Cancelˇlar descārrega" #: gui/downloaddialog.cpp:67 msgid "Hide" -msgstr "" +msgstr "Amagar" #: gui/downloaddialog.cpp:117 msgid "" "It looks like your connection is limited. Do you really want to download " "files with it?" msgstr "" +"Sembla que estās utilitzant una connexiķ limitada. Estās segur que vols " +"descarregar els arxius?" #: gui/downloaddialog.cpp:118 gui/downloaddialog.cpp:152 #: gui/filebrowser-dialog.cpp:132 gui/fluidsynth-dialog.cpp:217 @@ -149,6 +150,8 @@ msgid "" "Cannot create a directory to download - the specified directory has a file " "with the same name." msgstr "" +"No s'ha pogut crear un directori per la descārrega. El directori conté un " +"arxiu amb el mateix nom." #: gui/downloaddialog.cpp:146 gui/editgamedialog.cpp:293 #: gui/fluidsynth-dialog.cpp:153 gui/KeysDialog.cpp:42 gui/launcher.cpp:522 @@ -176,16 +179,18 @@ msgid "" "The \"%s\" already exists in the specified directory.\n" "Do you really want to download files into that directory?" msgstr "" +"Ja existeix un directori %s a la ruta especificada.\n" +"Estās segur que vols descarregar els arxius dins d'aquest directori?" #: gui/downloaddialog.cpp:251 #, c-format msgid "Downloaded %s %s / %s %s" -msgstr "" +msgstr "Descarregat: %s %s / %s %s" #: gui/downloaddialog.cpp:258 -#, fuzzy, c-format +#, c-format msgid "Download speed: %s %s" -msgstr "S'ha acabat la cerca!" +msgstr "Velocitat de descārrega: %s %s" #: gui/editgamedialog.cpp:132 msgid "Game" @@ -422,28 +427,27 @@ msgstr "" #: gui/editrecorddialog.cpp:58 msgid "Author:" -msgstr "" +msgstr "Autor:" #: gui/editrecorddialog.cpp:60 msgid "Notes:" -msgstr "" +msgstr "Notes:" #: gui/editrecorddialog.cpp:68 gui/predictivedialog.cpp:74 msgid "Ok" -msgstr "" +msgstr "Acceptar" #: gui/filebrowser-dialog.cpp:49 msgid "Choose file for loading" -msgstr "" +msgstr "Tria l'arxiu a carregar" #: gui/filebrowser-dialog.cpp:49 msgid "Enter filename for saving" msgstr "" #: gui/filebrowser-dialog.cpp:132 -#, fuzzy msgid "Do you really want to overwrite the file?" -msgstr "Realment voleu suprimir aquesta partida?" +msgstr "Realment vols sobreescriure aquest arxiu?" #: gui/fluidsynth-dialog.cpp:68 msgid "Reverb" @@ -711,9 +715,8 @@ msgid "Do you really want to remove this game configuration?" msgstr "Realment voleu suprimir la configuraciķ d'aquest joc?" #: gui/launcher.cpp:473 -#, fuzzy msgid "Do you want to load saved game?" -msgstr "Voleu carregar o desar el joc?" +msgstr "Desitges carregar la partida guardada?" #: gui/launcher.cpp:522 msgid "This game does not support loading games from the launcher." @@ -773,14 +776,12 @@ msgid "Edit record description" msgstr "" #: gui/onscreendialog.cpp:108 -#, fuzzy msgid "Switch to Game" -msgstr "Commuta" +msgstr "Tornar al joc" #: gui/onscreendialog.cpp:110 -#, fuzzy msgid "Fast replay" -msgstr "Mode rāpid" +msgstr "Repeticiķ rāpida" #: gui/options.cpp:119 common/updates.cpp:56 msgid "Never" @@ -845,9 +846,8 @@ msgid "the fullscreen setting could not be changed" msgstr "no s'ha pogut canviar l'ajust de pantalla completa" #: gui/options.cpp:486 -#, fuzzy msgid "the filtering setting could not be changed" -msgstr "no s'ha pogut canviar l'ajust de pantalla completa" +msgstr "no s'han pogut canviar els ajustes de filtratge" #: gui/options.cpp:842 msgid "Graphics mode:" @@ -867,9 +867,8 @@ msgid "Fullscreen mode" msgstr "Mode pantalla completa" #: gui/options.cpp:871 -#, fuzzy msgid "Filter graphics" -msgstr "Grāfics" +msgstr "Filtres de grāfics" #: gui/options.cpp:871 msgid "Use linear filtering when scaling graphics" @@ -999,9 +998,8 @@ msgid "True Roland MT-32 (no GM emulation)" msgstr "Roland MT-32 real (sense emulaciķ GM)" #: gui/options.cpp:998 -#, fuzzy msgid "Roland GS Device (enable MT-32 mappings)" -msgstr "Mode Roland GS (desactiva el mapeig GM)" +msgstr "Dispositiu Roland GS (activar conversiķ MT-32)" #: gui/options.cpp:998 msgid "" @@ -1231,9 +1229,8 @@ msgid "Refresh current cloud storage information (username and usage)" msgstr "" #: gui/options.cpp:1484 -#, fuzzy msgid "Download" -msgstr "Avall" +msgstr "Descarregar" #: gui/options.cpp:1484 msgid "Open downloads manager dialog" @@ -1248,30 +1245,25 @@ msgid "Run local webserver" msgstr "" #: gui/options.cpp:1487 gui/options.cpp:2136 -#, fuzzy msgid "Not running" -msgstr "Error al executar el joc:" +msgstr "Aturat" #: gui/options.cpp:1491 -#, fuzzy msgid "/root/ Path:" -msgstr "Camí extra:" +msgstr "Directori /arrel/:" #: gui/options.cpp:1491 gui/options.cpp:1493 gui/options.cpp:1494 -#, fuzzy msgid "Specifies which directory the Files Manager can access" -msgstr "Especifica on es desaran les partides" +msgstr "Especifica els directoris accessibles per al gestor d'arxius" #: gui/options.cpp:1493 -#, fuzzy msgctxt "lowres" msgid "/root/ Path:" -msgstr "Camí extra:" +msgstr "Directori /arrel/:" #: gui/options.cpp:1503 -#, fuzzy msgid "Server's port:" -msgstr "Servidor:" +msgstr "Port del servidor:" #: gui/options.cpp:1503 msgid "" @@ -1284,9 +1276,8 @@ msgid "Apply" msgstr "" #: gui/options.cpp:1682 -#, fuzzy msgid "Failed to change cloud storage!" -msgstr "No s'ha pogut desar l'estat del joc" +msgstr "Fallada al canviar l'emmagatzematge en línia!" #: gui/options.cpp:1685 msgid "Another cloud storage is already active." @@ -1319,9 +1310,8 @@ msgid "Select directory for plugins" msgstr "Seleccioneu el directori dels connectors" #: gui/options.cpp:1798 -#, fuzzy msgid "Select directory for Files Manager /root/" -msgstr "Seleccioneu el directori dels fitxers extra" +msgstr "Selecciona el directori /arrel/ per al gestor d'arxius" #: gui/options.cpp:2033 #, c-format @@ -1333,14 +1323,12 @@ msgid "<right now>" msgstr "" #: gui/options.cpp:2043 -#, fuzzy msgid "<never>" -msgstr "Mai" +msgstr "<mai>" #: gui/options.cpp:2127 -#, fuzzy msgid "Stop server" -msgstr "Servidor:" +msgstr "Aturar servidor" #: gui/options.cpp:2128 msgid "Stop local webserver" @@ -1362,9 +1350,8 @@ msgid "add" msgstr "" #: gui/predictivedialog.cpp:92 gui/predictivedialog.cpp:167 -#, fuzzy msgid "Delete char" -msgstr "Suprimeix" +msgstr "Suprimeix personatge" #: gui/predictivedialog.cpp:97 gui/predictivedialog.cpp:171 msgid "<" @@ -1399,9 +1386,8 @@ msgid "Record" msgstr "" #: gui/recorderdialog.cpp:71 -#, fuzzy msgid "Playback" -msgstr "Jugar" +msgstr "Reproducciķ" #: gui/recorderdialog.cpp:73 msgid "Edit" @@ -1418,19 +1404,16 @@ msgid "Notes: " msgstr "" #: gui/recorderdialog.cpp:154 -#, fuzzy msgid "Do you really want to delete this record?" -msgstr "Realment voleu suprimir aquesta partida?" +msgstr "Realment voleu suprimir aquest enregistrament?" #: gui/recorderdialog.cpp:173 -#, fuzzy msgid "Unknown Author" -msgstr "Error desconegut" +msgstr "Autor desconegut" #: gui/remotebrowser.cpp:128 -#, fuzzy msgid "ScummVM could not access the directory!" -msgstr "ScummVM no ha pogut obrir el directori especificat!" +msgstr "ScummVM no ha pogut accedir al directori especificat!" #: gui/saveload-dialog.cpp:334 msgid "List view" @@ -1469,9 +1452,8 @@ msgid "Playtime: " msgstr "Temps de joc: " #: gui/saveload-dialog.cpp:577 gui/saveload-dialog.cpp:665 -#, fuzzy msgid "Untitled saved game" -msgstr "Partida sense títol" +msgstr "Partida sense nom" #: gui/saveload-dialog.cpp:718 msgid "Next" @@ -1516,9 +1498,8 @@ msgid "in the following field and press 'Connect':" msgstr "" #: gui/storagewizarddialog.cpp:69 -#, fuzzy msgid "Open URL" -msgstr "Obre" +msgstr "Obre URL" #: gui/storagewizarddialog.cpp:70 msgid "Paste" @@ -1613,9 +1594,8 @@ msgid "(You can always enable it in the options dialog on the Misc tab)" msgstr "" #: gui/updates-dialog.cpp:92 -#, fuzzy msgid "Check for updates automatically" -msgstr "Comprova les actualitzacions..." +msgstr "Comprova les actualitzacions automāticament" #: gui/updates-dialog.cpp:111 msgid "Proceed" @@ -1710,9 +1690,8 @@ msgid "Could not find suitable engine plugin" msgstr "No s'ha pogut trobar un connector de motor apropiat" #: common/error.cpp:68 -#, fuzzy msgid "Engine plugin does not support saved games" -msgstr "El connector de motor no suporta el nivell partides desades'" +msgstr "El connector de motor no suporta partides desades" #: common/error.cpp:71 msgid "User canceled" @@ -1762,9 +1741,8 @@ msgid "Monthly" msgstr "" #: common/updates.cpp:64 -#, fuzzy msgid "<Bad value>" -msgstr "Neteja el valor" +msgstr "<Valor incorrecte>" #: engines/advancedDetector.cpp:335 #, c-format @@ -1893,9 +1871,8 @@ msgid "Could not apply fullscreen setting." msgstr "No s'ha pogut aplicar l'ajust de pantalla completa." #: engines/engine.cpp:373 -#, fuzzy msgid "Could not apply filtering setting." -msgstr "No s'ha pogut aplicar l'ajust de pantalla completa." +msgstr "No s'ha pogut aplicar la configuraciķ de filtratge." #: engines/engine.cpp:473 msgid "" @@ -2026,9 +2003,8 @@ msgid "FM-Towns Audio" msgstr "" #: audio/softsynth/fmtowns_pc98/towns_pc98_plugins.cpp:58 -#, fuzzy msgid "PC-98 Audio" -msgstr "Āudio" +msgstr "PC-98 Āudio" #: audio/softsynth/mt32.cpp:175 msgid "Initializing MT-32 Emulator" @@ -2051,9 +2027,8 @@ msgid "C64 Audio Emulator" msgstr "Emulador d'āudio C64" #: backends/cloud/storage.cpp:211 -#, fuzzy msgid "Saved games sync complete." -msgstr "S'ha acabat la cerca!" +msgstr "Sincronitzaciķ dels jocs desats completada." #: backends/cloud/storage.cpp:222 msgid "Saved games sync was cancelled." @@ -2073,14 +2048,12 @@ msgid "" msgstr "" #: backends/cloud/storage.cpp:330 -#, fuzzy msgid "Download complete." -msgstr "S'ha acabat la cerca!" +msgstr "Descārrega completada." #: backends/cloud/storage.cpp:340 -#, fuzzy msgid "Download failed." -msgstr "Carrega partida:" +msgstr "La descārrega ha fallat." #: backends/events/default/default-events.cpp:196 msgid "Do you really want to return to the Launcher?" @@ -2155,9 +2128,8 @@ msgstr "Vols sortir?" #. I18N: Trackpad mode toggle status. #: backends/events/webossdl/webossdl-events.cpp:308 -#, fuzzy msgid "Trackpad mode is now" -msgstr "Mode Touchpad desactivat." +msgstr "El mode trackpad estā" #. I18N: Trackpad mode on or off. #. I18N: Auto-drag on or off. @@ -2185,9 +2157,8 @@ msgid "Swipe three fingers to the right to toggle." msgstr "" #: backends/graphics/opengl/opengl-graphics.cpp:146 -#, fuzzy msgid "OpenGL" -msgstr "Obre" +msgstr "OpenGL" #: backends/graphics/openglsdl/openglsdl-graphics.cpp:617 #: backends/graphics/surfacesdl/surfacesdl-graphics.cpp:2462 @@ -2211,15 +2182,13 @@ msgstr "S'ha desactivat la correcciķ de la relaciķ d'aspecte" #: backends/graphics/openglsdl/openglsdl-graphics.cpp:753 #: backends/graphics/surfacesdl/surfacesdl-graphics.cpp:2362 -#, fuzzy msgid "Filtering enabled" -msgstr "Clicat activat" +msgstr "Filtratge activat" #: backends/graphics/openglsdl/openglsdl-graphics.cpp:755 #: backends/graphics/surfacesdl/surfacesdl-graphics.cpp:2364 -#, fuzzy msgid "Filtering disabled" -msgstr "Clicat desactivat" +msgstr "Filtratge desactivat" #: backends/graphics/surfacesdl/surfacesdl-graphics.cpp:47 #: backends/graphics/wincesdl/wincesdl-graphics.cpp:88 @@ -2509,9 +2478,8 @@ msgid "[ Media ]" msgstr "" #: backends/platform/tizen/fs.cpp:275 -#, fuzzy msgid "[ Shared ]" -msgstr "Comparticiķ:" +msgstr "[ Compartit ]" #: backends/platform/wii/options.cpp:51 msgid "Video" @@ -2786,9 +2754,8 @@ msgid "" msgstr "" #: engines/adl/detection.cpp:45 engines/adl/detection.cpp:55 -#, fuzzy msgid "Color mode" -msgstr "Mode clic" +msgstr "Mode de color" #: engines/adl/detection.cpp:46 engines/adl/detection.cpp:56 msgid "Use color graphics" |