diff options
-rw-r--r-- | engines/hopkins/computer.cpp | 58 | ||||
-rw-r--r-- | engines/hopkins/computer.h | 8 | ||||
-rw-r--r-- | engines/hopkins/events.cpp | 50 | ||||
-rw-r--r-- | engines/hopkins/events.h | 1 | ||||
-rw-r--r-- | engines/hopkins/font.cpp | 17 | ||||
-rw-r--r-- | engines/hopkins/hopkins.cpp | 12 |
6 files changed, 86 insertions, 60 deletions
diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp index 3c2a0573b9..f9d86d35b2 100644 --- a/engines/hopkins/computer.cpp +++ b/engines/hopkins/computer.cpp @@ -98,8 +98,9 @@ void ComputerManager::settextposition(int yp, int xp) { _textPosition.y = yp << 4; } -void ComputerManager::COMPUT_HOPKINS(int mode) { - int v2; +void ComputerManager::COMPUT_HOPKINS(ComputerEnum mode) { + bool passwordMatch; + bool numericFlag; char *v3; int v4; char v5; @@ -114,22 +115,22 @@ void ComputerManager::COMPUT_HOPKINS(int mode) { const char *s2; _vm->_eventsManager.ESC_KEY = 0; - v2 = 0; + passwordMatch = false; _vm->_graphicsManager.RESET_SEGMENT_VESA(); setvideomode(); settextcolor(4); _vm->_eventsManager.videkey(); settextposition(2, 4); - if (mode == 1) + if (mode == COMPUTER_HOPKINS) outtext(Common::String(MenuText[0]._line)); - if (mode == 2) + if (mode == COMPUTER_SAMANTHAS) outtext(Common::String(MenuText[1]._line)); - if (mode == 3) + if (mode == COMPUTER_PUBLIC) outtext(Common::String(MenuText[2]._line)); settextcolor(1); - if (mode == 3) { + if (mode == COMPUTER_PUBLIC) { settextposition(10, 8); outtext(Common::String(MenuText[3]._line)); } @@ -143,7 +144,7 @@ void ComputerManager::COMPUT_HOPKINS(int mode) { strcpy(s, Sup_string); - if (mode == 1) { + if (mode == COMPUTER_HOPKINS) { s2 = "HOPKINS"; v4 = 8; v5 = 1; @@ -154,9 +155,9 @@ void ComputerManager::COMPUT_HOPKINS(int mode) { --v4; } while (v5); if (v5) - v2 = 1; + passwordMatch = true; } - if (mode == 2) { + if (mode == COMPUTER_SAMANTHAS) { v6 = &s[0]; s2 = "328MHZA"; v7 = 8; @@ -168,9 +169,9 @@ void ComputerManager::COMPUT_HOPKINS(int mode) { --v7; } while (v8); if (v8) - v2 = 1; + passwordMatch = true; } - if (mode == 3) { + if (mode == COMPUTER_PUBLIC) { v9 = &s[0]; s2 = "ALLFREE"; v10 = 8; @@ -182,20 +183,20 @@ void ComputerManager::COMPUT_HOPKINS(int mode) { --v10; } while (v11); if (v11) - v2 = 1; + passwordMatch = true; } - if (v2) { + if (passwordMatch) { while (!_vm->shouldQuit()) { - _vm->_eventsManager.ESC_KEY = 0; + _vm->_eventsManager.ESC_KEY = false; _vm->_eventsManager.videkey(); clearscreen(); settextcolor(4); settextposition(2, 4); - if (mode == 1) + if (mode == COMPUTER_HOPKINS) outtext(Common::String(MenuText[0]._line)); - if (mode == 2) + if (mode == COMPUTER_SAMANTHAS) outtext(Common::String(MenuText[1]._line)); - if (mode == 3) + if (mode == COMPUTER_PUBLIC) outtext(Common::String(MenuText[2]._line)); settextcolor(15); settextposition(8, 25); @@ -203,7 +204,7 @@ void ComputerManager::COMPUT_HOPKINS(int mode) { outtext2(Common::String(MenuText[6]._line)); settextposition(20, 25); outtext2(Common::String(MenuText[7]._line)); - if (mode == 1) { + if (mode == COMPUTER_HOPKINS) { settextposition(10, 25); outtext2(Common::String(MenuText[8]._line)); settextposition(12, 25); @@ -213,7 +214,7 @@ void ComputerManager::COMPUT_HOPKINS(int mode) { settextposition(16, 25); outtext2(Common::String(MenuText[11]._line)); } - if (mode == 2) { + if (mode == COMPUTER_SAMANTHAS) { _vm->_eventsManager.videkey(); settextposition(10, 25); // outtext2(Common::String(MenuText[0x95A])); <=== CHECKME: Unexpected value! replaced by the following line, for consistancy @@ -233,16 +234,16 @@ void ComputerManager::COMPUT_HOPKINS(int mode) { if (_vm->shouldQuit()) return; - v2 = 0; + numericFlag = false; if ((uint16)(v12 - 48) <= 8u) - v2 = 1; - } while (v2 != 1); + numericFlag = true; + } while (!numericFlag); if (v12 == 48) break; if (v12 == 49) { GAMES(); - } else if (mode == 1) { + } else if (mode == COMPUTER_HOPKINS) { _vm->_eventsManager.videkey(); clearscreen(); settextcolor(4); @@ -257,7 +258,7 @@ void ComputerManager::COMPUT_HOPKINS(int mode) { LIT_TEXTE(3); if (v12 == 53) LIT_TEXTE(4); - } else if (mode == 2) { + } else if (mode == COMPUTER_SAMANTHAS) { clearscreen(); settextcolor(4); settextposition(2, 4); @@ -283,10 +284,13 @@ void ComputerManager::COMPUT_HOPKINS(int mode) { _vm->_graphicsManager.DD_VBL(); RESTORE_POLICE(); } else { + // Access Denied settextcolor(4); settextposition(16, 25); outtext(Common::String(MenuText[5]._line)); _vm->_eventsManager.VBL(); + _vm->_eventsManager.delay(1000); + memset(_vm->_graphicsManager.VESA_BUFFER, 0, 0x4AFFFu); _vm->_graphicsManager.DD_Lock(); _vm->_graphicsManager.Cls_Video(); @@ -443,7 +447,7 @@ void ComputerManager::TXT4(int xp, int yp, int a3) { v3 -= _vm->_globals.police_l; v8 = v3 + 2 * _vm->_globals.police_l; v9 = v7; - _vm->_graphicsManager.Copy_Mem(_vm->_graphicsManager.VESA_SCREEN, v3, yp, 2 * _vm->_globals.police_l, 12, _vm->_graphicsManager.VESA_BUFFER, v3, yp); + _vm->_graphicsManager.Copy_Mem(_vm->_graphicsManager.VESA_SCREEN, v3, yp, 3 * _vm->_globals.police_l, 12, _vm->_graphicsManager.VESA_BUFFER, v3, yp); _vm->_graphicsManager.Ajoute_Segment_Vesa(v3, yp, v8, yp + 12); _vm->_fontManager.TEXT_NOW(v3, yp, "_", -4); v7 = v9; @@ -592,7 +596,7 @@ void ComputerManager::GAMES() { _vm->_soundManager.CHARGE_SAMPLE(1, "SOUND37.WAV"); _vm->_soundManager.CHARGE_SAMPLE(2, "SOUND38.WAV"); _vm->_soundManager.CHARGE_SAMPLE(3, "SOUND39.WAV"); - _vm->_fileManager.CONSTRUIT_SYSTEM("_vm->_eventsManager.CASSE.SPR"); + _vm->_fileManager.CONSTRUIT_SYSTEM("CASSE.SPR"); CASSESPR = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); CHARGE_SCORE(); MODE_VGA256(); diff --git a/engines/hopkins/computer.h b/engines/hopkins/computer.h index 8cccd67197..15f36cc089 100644 --- a/engines/hopkins/computer.h +++ b/engines/hopkins/computer.h @@ -37,6 +37,8 @@ struct MenuItem { char _line[90]; }; +enum ComputerEnum { COMPUTER_HOPKINS = 1, COMPUTER_SAMANTHAS = 2, COMPUTER_PUBLIC = 3 }; + class ComputerManager { private: HopkinsEngine *_vm; @@ -134,10 +136,10 @@ public: void setParent(HopkinsEngine *vm); /** - * Show Hopkin's computer - * @param mode Display mode + * Show a computer in the FBI office + * @param mode Which computer to display */ - void COMPUT_HOPKINS(int mode); + void COMPUT_HOPKINS(ComputerEnum mode); }; } // End of namespace Hopkins diff --git a/engines/hopkins/events.cpp b/engines/hopkins/events.cpp index 9f2743c5b8..f91dceabde 100644 --- a/engines/hopkins/events.cpp +++ b/engines/hopkins/events.cpp @@ -50,6 +50,7 @@ EventsManager::EventsManager() { OLD_ICONE = 0; Bufferobjet = NULL; + Common::fill(&keyState[0], &keyState[256], false); _priorCounterTime = 0; _priorFrameTime = 0; } @@ -202,9 +203,12 @@ void EventsManager::pollEvents() { return; case Common::EVENT_KEYDOWN: + keyState[toupper(event.kbd.ascii)] = true; handleKey(event); return; - + case Common::EVENT_KEYUP: + keyState[toupper(event.kbd.ascii)] = false; + return; case Common::EVENT_LBUTTONDOWN: souris_b = 1; break; @@ -244,24 +248,46 @@ void EventsManager::handleKey(Common::Event &event) { } int EventsManager::keywin() { - Common::Event event; + char foundChar = '\0'; - while (!_vm->shouldQuit()) { - _vm->_soundManager.checkSounds(); - checkForNextFrameCounter(); + while (!foundChar) { + if (_vm->shouldQuit()) + return -1; + + for (char ch = 'A'; ch <= 'Z'; ++ch) { + if (keyState[ch]) { + foundChar = ch; + break; + } + } - // Handle pending events looking for keypress events - while (g_system->getEventManager()->pollEvent(event)) { - if (event.type == Common::EVENT_KEYDOWN) - return event.kbd.ascii; + for (char ch = '0'; ch <= '9'; ++ch) { + if (keyState[ch]) { + foundChar = ch; + break; + } } - // Slight delay been checks to avoid maxing CPU usage + if (keyState['.']) + foundChar = '.'; + else if (keyState[8]) + foundChar = 8; + else if (keyState[13]) + foundChar = 13; + else if (keyState[' ']) + foundChar = ' '; + + VBL(); + } + + // Wait for keypress release + while (keyState[foundChar] && !_vm->shouldQuit()) { + VBL(); g_system->delayMillis(10); } - // Game is quitting - return -1; + // Return character + return foundChar; } void EventsManager::VBL() { diff --git a/engines/hopkins/events.h b/engines/hopkins/events.h index 25bd60b510..24f71c1a97 100644 --- a/engines/hopkins/events.h +++ b/engines/hopkins/events.h @@ -66,6 +66,7 @@ public: DIALOG_KEY GAME_KEY; int btsouris; byte *Bufferobjet; + bool keyState[256]; public: EventsManager(); ~EventsManager(); diff --git a/engines/hopkins/font.cpp b/engines/hopkins/font.cpp index 0ddd257939..8fd69fa766 100644 --- a/engines/hopkins/font.cpp +++ b/engines/hopkins/font.cpp @@ -485,6 +485,7 @@ void FontManager::TEXT_NOW(int xp, int yp, const Common::String &message, int co const char *srcP; char currChar; int charIndex; + int currentX = xp; srcP = message.c_str(); for (;;) { @@ -494,11 +495,12 @@ void FontManager::TEXT_NOW(int xp, int yp, const Common::String &message, int co if (currChar >= 32) { charIndex = currChar - 32; _vm->_graphicsManager.Affiche_Fonte(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.police, - xp, yp, currChar - 32, col); - xp += _vm->_objectsManager.Get_Largeur(_vm->_globals.police, charIndex); + currentX, yp, currChar - 32, col); + currentX += _vm->_objectsManager.Get_Largeur(_vm->_globals.police, charIndex); } } - _vm->_graphicsManager.Ajoute_Segment_Vesa(xp, yp, xp, yp + 12); + + _vm->_graphicsManager.Ajoute_Segment_Vesa(xp, yp, currentX, yp + 12); } @@ -552,15 +554,6 @@ void FontManager::TEXT_COMPUT(int xp, int yp, const Common::String &msg, int col _vm->_eventsManager.VBL(); _vm->_globals.iRegul = 1; } - - if (_vm->_eventsManager.ESC_KEY) { - _vm->_globals.iRegul = 1; - _vm->_eventsManager.VBL(); - } else { - _vm->_globals.iRegul = 4; - _vm->_eventsManager.VBL(); - _vm->_globals.iRegul = 1; - } } } while (v7); } diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp index 7f261cb698..40d689df49 100644 --- a/engines/hopkins/hopkins.cpp +++ b/engines/hopkins/hopkins.cpp @@ -433,7 +433,7 @@ LABEL_124: *((byte *)_globals.SAUVEGARDE + 6) = _globals.ECRAN; _globals.ECRAN = 113; *((byte *)_globals.SAUVEGARDE + 5) = 113; - _computerManager.COMPUT_HOPKINS(1); + _computerManager.COMPUT_HOPKINS(COMPUTER_HOPKINS); _graphicsManager.DD_Lock(); _graphicsManager.Cls_Video(); @@ -450,7 +450,7 @@ LABEL_124: *((byte *)_globals.SAUVEGARDE + 6) = _globals.ECRAN; _globals.ECRAN = 114; *((byte *)_globals.SAUVEGARDE + 5) = 114; - _computerManager.COMPUT_HOPKINS(2); + _computerManager.COMPUT_HOPKINS(COMPUTER_SAMANTHAS); goto LABEL_128; } if (_globals.SORTIE == 115) { @@ -459,7 +459,7 @@ LABEL_124: *((byte *)_globals.SAUVEGARDE + 6) = _globals.ECRAN; _globals.ECRAN = 115; *((byte *)_globals.SAUVEGARDE + 5) = 115; - _computerManager.COMPUT_HOPKINS(3); + _computerManager.COMPUT_HOPKINS(COMPUTER_PUBLIC); LABEL_128: _graphicsManager.DD_Lock(); @@ -1261,7 +1261,7 @@ LABEL_239: *((byte *)_globals.SAUVEGARDE + 6) = _globals.ECRAN; _globals.ECRAN = 113; *((byte *)_globals.SAUVEGARDE + 5) = 113; - _computerManager.COMPUT_HOPKINS(1); + _computerManager.COMPUT_HOPKINS(COMPUTER_HOPKINS); _graphicsManager.DD_Lock(); _graphicsManager.Cls_Video(); _graphicsManager.DD_Unlock(); @@ -1277,7 +1277,7 @@ LABEL_239: *((byte *)_globals.SAUVEGARDE + 6) = _globals.ECRAN; _globals.ECRAN = 114; *((byte *)_globals.SAUVEGARDE + 5) = 114; - _computerManager.COMPUT_HOPKINS(2); + _computerManager.COMPUT_HOPKINS(COMPUTER_SAMANTHAS); goto LABEL_243; } switch (_globals.SORTIE) { @@ -1287,7 +1287,7 @@ LABEL_239: *((byte *)_globals.SAUVEGARDE + 6) = _globals.ECRAN; _globals.ECRAN = 115; *((byte *)_globals.SAUVEGARDE + 5) = 115; - _computerManager.COMPUT_HOPKINS(3); + _computerManager.COMPUT_HOPKINS(COMPUTER_PUBLIC); LABEL_243: _graphicsManager.DD_Lock(); _graphicsManager.Cls_Video(); |