diff options
Diffstat (limited to 'engines/dreamweb/dreamweb.cpp')
-rw-r--r-- | engines/dreamweb/dreamweb.cpp | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp index 5f5d627553..c3ede46df2 100644 --- a/engines/dreamweb/dreamweb.cpp +++ b/engines/dreamweb/dreamweb.cpp @@ -208,7 +208,7 @@ DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gam _addToRed = 0; _addToBlue = 0; _lastSoundReel = 0; - _lastHardKey = 0; + _lastHardKey = Common::KEYCODE_INVALID; _bufferIn = 0; _bufferOut = 0; _blinkFrame = 23; @@ -263,7 +263,7 @@ void DreamWebEngine::waitForVSync() { void DreamWebEngine::quit() { _quitRequested = true; - _lastHardKey = 1; + _lastHardKey = Common::KEYCODE_ESCAPE; } void DreamWebEngine::processEvents() { @@ -274,7 +274,7 @@ void DreamWebEngine::processEvents() { _sound->soundHandler(); Common::Event event; - int softKey, hardKey; + int softKey; while (_eventMan->pollEvent(event)) { switch(event.type) { case Common::EVENT_RTL: @@ -309,28 +309,21 @@ void DreamWebEngine::processEvents() { return; //do not pass ctrl + key to the engine } - // Some parts of the ASM code uses the hardware key - // code directly. We don't have that code, so we fake - // it for the keys where it's needed and assume it's - // 0 (which is actually an invalid value, as far as I - // know) otherwise. - - hardKey = 0; + // Some parts of the code uses the hardware key + // code directly. switch (event.kbd.keycode) { case Common::KEYCODE_ESCAPE: - hardKey = 1; + _lastHardKey = Common::KEYCODE_ESCAPE; break; case Common::KEYCODE_SPACE: - hardKey = 57; + _lastHardKey = Common::KEYCODE_SPACE; break; default: - hardKey = 0; + _lastHardKey = Common::KEYCODE_INVALID; break; } - _lastHardKey = hardKey; - // The rest of the keys are converted to ASCII. This // is fairly restrictive, and eventually we may want // to let through more keys. I think this is mostly to @@ -338,11 +331,13 @@ void DreamWebEngine::processEvents() { softKey = 0; - if (event.kbd.keycode >= Common::KEYCODE_a && event.kbd.keycode <= Common::KEYCODE_z) { - softKey = event.kbd.ascii & ~0x20; - } else if (event.kbd.keycode == Common::KEYCODE_MINUS || - event.kbd.keycode == Common::KEYCODE_SPACE || - (event.kbd.keycode >= Common::KEYCODE_0 && event.kbd.keycode <= Common::KEYCODE_9)) { + debug(1, "DreamWebEngine::processEvents() KeyDown keycode:%d ascii:0x%02x", event.kbd.keycode, event.kbd.ascii); + if ((event.kbd.ascii >= 'a' && event.kbd.ascii <= 'z') || + (event.kbd.ascii >= 'A' && event.kbd.ascii <= 'Z')) { + softKey = event.kbd.ascii & ~0x20; // (& ~0x20) forces ascii codes for a-z to map to A-Z + } else if (event.kbd.ascii == '-' || + event.kbd.ascii == ' ' || + (event.kbd.ascii >= '0' && event.kbd.ascii <= '9')) { softKey = event.kbd.ascii; } else if (event.kbd.keycode >= Common::KEYCODE_KP0 && event.kbd.keycode <= Common::KEYCODE_KP9) { softKey = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; @@ -374,6 +369,7 @@ Common::Error DreamWebEngine::run() { ConfMan.registerDefault("bright_palette", true); _hasSpeech = Common::File::exists(_speechDirName + "/r01c0000.raw") && !ConfMan.getBool("speech_mute"); _brightPalette = ConfMan.getBool("bright_palette"); + _copyProtection = ConfMan.getBool("copy_protection"); _timer->installTimerProc(vSyncInterrupt, 1000000 / 70, this, "dreamwebVSync"); dreamweb(); @@ -403,14 +399,14 @@ Common::String DreamWebEngine::getSavegameFilename(int slot) const { void DreamWebEngine::keyPressed(uint16 ascii) { debug(2, "key pressed = %04x", ascii); - uint16 in = (_bufferIn + 1) & 0x0f; + uint16 in = (_bufferIn + 1) % ARRAYSIZE(_keyBuffer); uint16 out = _bufferOut; if (in == out) { warning("keyboard buffer is full"); return; } _bufferIn = in; - DreamWeb::g_keyBuffer[in] = ascii; + _keyBuffer[in] = ascii; } void DreamWebEngine::getPalette(uint8 *data, uint start, uint count) { @@ -421,7 +417,7 @@ void DreamWebEngine::getPalette(uint8 *data, uint start, uint count) { void DreamWebEngine::setPalette(const uint8 *data, uint start, uint count) { assert(start + count <= 256); - uint8 fixed[768]; + uint8 fixed[3*256]; for (uint i = 0; i < count * 3; ++i) { fixed[i] = data[i] << 2; } @@ -429,10 +425,10 @@ void DreamWebEngine::setPalette(const uint8 *data, uint start, uint count) { } void DreamWebEngine::blit(const uint8 *src, int pitch, int x, int y, int w, int h) { - if (y + h > 200) - h = 200 - y; - if (x + w > 320) - w = 320 - x; + if (y + h > (int)kScreenheight) + h = kScreenheight - y; + if (x + w > (int)kScreenwidth) + w = kScreenwidth - x; if (h <= 0 || w <= 0) return; _system->copyRectToScreen(src, pitch, x, y, w, h); |