aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Kagerer2009-10-03 20:42:26 +0000
committerFlorian Kagerer2009-10-03 20:42:26 +0000
commitf6de0b4ec9fcc240cdc0c46aedb2e2089e07bd5c (patch)
tree29445b690968061b7d2a82e0bbb15ae1a4c693c9
parenta3fc7230eb6aecce6ad48c22540fa1dbe11606b1 (diff)
downloadscummvm-rg350-f6de0b4ec9fcc240cdc0c46aedb2e2089e07bd5c.tar.gz
scummvm-rg350-f6de0b4ec9fcc240cdc0c46aedb2e2089e07bd5c.tar.bz2
scummvm-rg350-f6de0b4ec9fcc240cdc0c46aedb2e2089e07bd5c.zip
LOL/PC-98: add keyboard support
svn-id: r44564
-rw-r--r--engines/kyra/gui_lol.cpp83
-rw-r--r--engines/kyra/kyra_v1.cpp81
-rw-r--r--engines/kyra/kyra_v1.h2
-rw-r--r--engines/kyra/lol.cpp31
-rw-r--r--engines/kyra/script_tim.cpp36
-rw-r--r--engines/kyra/text_lol.cpp20
6 files changed, 69 insertions, 184 deletions
diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp
index 9d11024bc7..499877af11 100644
--- a/engines/kyra/gui_lol.cpp
+++ b/engines/kyra/gui_lol.cpp
@@ -266,14 +266,9 @@ void LoLEngine::gui_printCharacterStats(int index, int redraw, int value) {
if (offs)
_screen->copyRegion(294, y, 182 + offs, y, 18, 8, 6, _screen->_curPage, Screen::CR_NO_P_CHECK);
- Screen::FontId of;
- if (_flags.use16ColorMode)
- of = _screen->setFont(Screen::FID_SJIS_FNT);
-
+ Screen::FontId of = _flags.use16ColorMode ? _screen->setFont(Screen::FID_SJIS_FNT) : _screen->_currentFont;
_screen->fprintString("%d", 200 + offs, y, col, 0, _flags.use16ColorMode ? 2 : 6, value);
-
- if (_flags.use16ColorMode)
- _screen->setFont(of);
+ _screen->setFont(of);
}
void LoLEngine::gui_changeCharacterStats(int charNum) {
@@ -815,13 +810,9 @@ void LoLEngine::gui_updateInput() {
inputFlag = 0;
}
- switch (inputFlag) {
- case 43:
- case 61:
- // space or enter
+ if (inputFlag == _keyMap[Common::KEYCODE_SPACE] || inputFlag == _keyMap[Common::KEYCODE_RETURN]) {
snd_stopSpeech(true);
- break;
- case 55:
+ } else if (inputFlag == _keyMap[Common::KEYCODE_SLASH]) {
if (_weaponsDisabled || _availableSpells[1] == -1)
return;
@@ -829,13 +820,7 @@ void LoLEngine::gui_updateInput() {
if (_availableSpells[++_selectedSpell] == -1)
_selectedSpell = 0;
gui_highlightSelectedSpell(true);
-
gui_drawAllCharPortraitsWithStats();
- break;
- case 0x71a:
- break;
- default:
- break;
}
}
@@ -852,55 +837,10 @@ void LoLEngine::gui_triggerEvent(int eventType) {
} else {
evt.type = Common::EVENT_KEYDOWN;
- switch (eventType) {
- case 96:
- evt.kbd.keycode = Common::KEYCODE_UP;
- break;
- case 102:
- evt.kbd.keycode = Common::KEYCODE_RIGHT;
- break;
- case 97:
- evt.kbd.keycode = Common::KEYCODE_DOWN;
- break;
- case 92:
- evt.kbd.keycode = Common::KEYCODE_LEFT;
- break;
- case 91:
- evt.kbd.keycode = Common::KEYCODE_HOME;
- break;
- case 101:
- evt.kbd.keycode = Common::KEYCODE_PAGEUP;
- break;
- case 112:
- evt.kbd.keycode = Common::KEYCODE_F1;
- break;
- case 113:
- evt.kbd.keycode = Common::KEYCODE_F2;
- break;
- case 114:
- evt.kbd.keycode = Common::KEYCODE_F3;
- break;
- case 25:
- evt.kbd.keycode = Common::KEYCODE_o;
- break;
- case 20:
- evt.kbd.keycode = Common::KEYCODE_r;
- break;
- case 110:
- evt.kbd.keycode = Common::KEYCODE_ESCAPE;
- break;
- case 43:
- evt.kbd.keycode = Common::KEYCODE_SPACE;
- break;
- case 61:
- evt.kbd.keycode = Common::KEYCODE_RETURN;
- break;
- case 55:
- evt.kbd.keycode = Common::KEYCODE_SLASH;
- break;
- default:
- break;
- }
+ for (Common::HashMap<int, int16>::const_iterator c = _keyMap.begin(); c != _keyMap.end(); ++c) {
+ if (c->_value == eventType)
+ evt.kbd.keycode = (Common::KeyCode) c->_key;
+ }
}
removeInputTop();
@@ -2343,9 +2283,7 @@ int GUI_LoL::runMenu(Menu &menu) {
// a menu has scroll buttons or slider bars.
uint8 hasSpecialButtons = 0;
- Screen::FontId of;
- if (_vm->gameFlags().use16ColorMode)
- of = _screen->setFont(Screen::FID_SJIS_FNT);
+ Screen::FontId of = _vm->gameFlags().use16ColorMode ? _screen->setFont(Screen::FID_SJIS_FNT) : _screen->_currentFont;
while (_displayMenu) {
_vm->_mouseX = _vm->_mouseY = 0;
@@ -2554,8 +2492,7 @@ int GUI_LoL::runMenu(Menu &menu) {
_newMenu = 0;
}
- if (_vm->gameFlags().use16ColorMode)
- _screen->setFont(of);
+ _screen->setFont(of);
return _menuResult;
}
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp
index 098a698e14..a461d464e3 100644
--- a/engines/kyra/kyra_v1.cpp
+++ b/engines/kyra/kyra_v1.cpp
@@ -202,6 +202,8 @@ Common::Error KyraEngine_v1::init() {
_gameToLoad = -1;
}
+ setupKeyMap();
+
// Prevent autosave on game startup
_lastAutosave = _system->getMillis();
@@ -212,6 +214,7 @@ KyraEngine_v1::~KyraEngine_v1() {
for (Common::Array<const Opcode*>::iterator i = _opcodes.begin(); i != _opcodes.end(); ++i)
delete *i;
_opcodes.clear();
+ _keyMap.clear();
delete _res;
delete _staticres;
@@ -278,62 +281,8 @@ int KyraEngine_v1::checkInput(Button *buttonList, bool mainLoop, int eventFlag)
} else if (event.kbd.keycode == 'q') {
quitGame();
}
- } else {
- switch (event.kbd.keycode) {
- case Common::KEYCODE_SPACE:
- keys = 61;
- break;
- case Common::KEYCODE_RETURN:
- keys = 43;
- break;
- case Common::KEYCODE_UP:
- case Common::KEYCODE_KP8:
- keys = 96;
- break;
- case Common::KEYCODE_RIGHT:
- case Common::KEYCODE_KP6:
- keys = 102;
- break;
- case Common::KEYCODE_DOWN:
- case Common::KEYCODE_KP2:
- keys = 97;
- break;
- case Common::KEYCODE_LEFT:
- case Common::KEYCODE_KP4:
- keys = 92;
- break;
- case Common::KEYCODE_HOME:
- case Common::KEYCODE_KP7:
- keys = 91;
- break;
- case Common::KEYCODE_PAGEUP:
- case Common::KEYCODE_KP9:
- keys = 101;
- break;
- case Common::KEYCODE_F1:
- keys = 112;
- break;
- case Common::KEYCODE_F2:
- keys = 113;
- break;
- case Common::KEYCODE_F3:
- keys = 114;
- break;
- case Common::KEYCODE_o:
- keys = 25;
- break;
- case Common::KEYCODE_r:
- keys = 20;
- break;
- case Common::KEYCODE_SLASH:
- keys = 55;
- break;
- case Common::KEYCODE_ESCAPE:
- keys = 110;
- break;
- default:
- keys = 0;
- }
+ } else {
+ keys = _keyMap[event.kbd.keycode];
// When we got an keypress, which we might need to handle,
// break the event loop and pass it to GUI code.
@@ -398,6 +347,26 @@ int KyraEngine_v1::checkInput(Button *buttonList, bool mainLoop, int eventFlag)
}
}
+void KyraEngine_v1::setupKeyMap() {
+ static const Common::KeyCode keyboardEvents[] = {
+ Common::KEYCODE_SPACE, Common::KEYCODE_RETURN, Common::KEYCODE_UP, Common::KEYCODE_KP8,
+ Common::KEYCODE_RIGHT, Common::KEYCODE_KP6, Common::KEYCODE_DOWN, Common::KEYCODE_KP2,
+ Common::KEYCODE_LEFT, Common::KEYCODE_KP4, Common::KEYCODE_HOME, Common::KEYCODE_KP7,
+ Common::KEYCODE_PAGEUP, Common::KEYCODE_KP9, Common::KEYCODE_F1, Common::KEYCODE_F2,
+ Common::KEYCODE_F3, Common::KEYCODE_o, Common::KEYCODE_r, Common::KEYCODE_SLASH,
+ Common::KEYCODE_ESCAPE
+ };
+
+ static const int16 keyCodesDOS[] = { 61, 43, 96, 96, 102, 102, 97, 97, 92, 92, 91, 91, 101, 101, 112, 113, 114, 25, 20, 55, 110};
+ static const int16 keyCodesPC98[] = { 53, 29, 68, 68, 73, 73, 72, 72, 71, 71, 67, 67, 69, 69, 99, 100, 101, 25, 20, 55, 1 };
+
+ const int16 *keyCodes = _flags.platform == Common::kPlatformPC98 ? keyCodesPC98 : keyCodesDOS;
+ _keyMap.clear();
+
+ for (int i = 0; i < ARRAYSIZE(keyboardEvents); i++)
+ _keyMap[keyboardEvents[i]] = keyCodes[i];
+}
+
void KyraEngine_v1::updateInput() {
Common::Event event;
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index 5ece70e3f1..3b9436c3be 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -205,6 +205,7 @@ protected:
Debugger *_debugger;
// input
+ void setupKeyMap();
void updateInput();
int checkInput(Button *buttonList, bool mainLoop = false, int eventFlag = 0x8000);
void removeInputTop();
@@ -222,6 +223,7 @@ protected:
operator Common::Event() const { return event; }
};
Common::List<Event> _eventList;
+ Common::HashMap<int, int16> _keyMap;
// config specific
virtual void registerDefaultSettings();
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp
index aac1b2fe34..2bfe687680 100644
--- a/engines/kyra/lol.cpp
+++ b/engines/kyra/lol.cpp
@@ -4001,7 +4001,7 @@ void LoLEngine::displayAutomap() {
for (int i = 0; i < 1024; i++)
_levelBlockProperties[i].flags |= 7;
_mapUpdateNeeded = true;
- } else if (f == 0x6e) {
+ } else if (f == _keyMap[Common::KEYCODE_ESCAPE]) {
exitAutomap = true;
}
@@ -4239,23 +4239,28 @@ void LoLEngine::drawMapPage(int pageNum) {
}
bool LoLEngine::automapProcessButtons(int inputFlag) {
- if (inputFlag != 199)
- return false;
-
int r = -1;
- if (posWithinRect(_mouseX, _mouseY, 252, 175, 273, 200))
+ if (inputFlag == _keyMap[Common::KEYCODE_RIGHT] || inputFlag == _keyMap[Common::KEYCODE_KP6]) {
r = 0;
- else if (posWithinRect(_mouseX, _mouseY, 231, 175, 252, 200))
+ } else if (inputFlag == _keyMap[Common::KEYCODE_LEFT] || inputFlag == _keyMap[Common::KEYCODE_KP4]) {
r = 1;
- else if (posWithinRect(_mouseX, _mouseY, 275, 175, 315, 197))
- r = 2;
+ } else if (inputFlag == 199) {
+ if (posWithinRect(_mouseX, _mouseY, 252, 175, 273, 200))
+ r = 0;
+ else if (posWithinRect(_mouseX, _mouseY, 231, 175, 252, 200))
+ r = 1;
+ else if (posWithinRect(_mouseX, _mouseY, 275, 175, 315, 197))
+ r = 2;
- printMapExitButtonText();
+ printMapExitButtonText();
- while (inputFlag == 199 || inputFlag == 200) {
- inputFlag = checkInput(0, false);
- removeInputTop();
- delay(_tickLength);
+ while (inputFlag == 199 || inputFlag == 200) {
+ inputFlag = checkInput(0, false);
+ removeInputTop();
+ delay(_tickLength);
+ }
+ } else {
+ return false;
}
if (r == 0) {
diff --git a/engines/kyra/script_tim.cpp b/engines/kyra/script_tim.cpp
index 01f4f6171d..317ab01c22 100644
--- a/engines/kyra/script_tim.cpp
+++ b/engines/kyra/script_tim.cpp
@@ -1234,28 +1234,7 @@ uint16 TIMInterpreter_LoL::processDialogue() {
if (e)
_vm->gui_notifyButtonListChanged();
- switch (e) {
- case 43:
- case 61:
- _vm->snd_stopSpeech(true);
- //_dlgTimer = 0;
- res = _dialogueHighlightedButton + 1;
- break;
-
- case 92:
- case 97:
- if (_dialogueNumButtons > 1 && _dialogueHighlightedButton > 0)
- _dialogueHighlightedButton--;
- break;
-
- case 96:
- case 102:
- if (_dialogueNumButtons > 1 && _dialogueHighlightedButton < (_dialogueNumButtons - 1))
- _dialogueHighlightedButton++;
- break;
-
- case 200:
- case 202:
+ if (e == 200 || e == 202) {
x = _dialogueButtonPosX;
for (int i = 0; i < _dialogueNumButtons; i++) {
@@ -1267,10 +1246,15 @@ uint16 TIMInterpreter_LoL::processDialogue() {
}
x += _dialogueButtonXoffs;
}
- break;
-
- default:
- break;
+ } else if (e == _vm->_keyMap[Common::KEYCODE_SPACE] || e == _vm->_keyMap[Common::KEYCODE_RETURN]) {
+ _vm->snd_stopSpeech(true);
+ res = _dialogueHighlightedButton + 1;
+ } else if (e == _vm->_keyMap[Common::KEYCODE_LEFT] || e == _vm->_keyMap[Common::KEYCODE_DOWN]) {
+ if (_dialogueNumButtons > 1 && _dialogueHighlightedButton > 0)
+ _dialogueHighlightedButton--;
+ } else if (e == _vm->_keyMap[Common::KEYCODE_RIGHT] || e == _vm->_keyMap[Common::KEYCODE_UP]) {
+ if (_dialogueNumButtons > 1 && _dialogueHighlightedButton < (_dialogueNumButtons - 1))
+ _dialogueHighlightedButton++;
}
}
diff --git a/engines/kyra/text_lol.cpp b/engines/kyra/text_lol.cpp
index a5095790c1..0dd6a1b2f2 100644
--- a/engines/kyra/text_lol.cpp
+++ b/engines/kyra/text_lol.cpp
@@ -169,7 +169,7 @@ void TextDisplayer_LoL::printDialogueText(int dim, char *str, EMCState *script,
}
int cp = _screen->setCurPage(0);
- Screen::FontId of = _screen->setFont(Screen::FID_9_FNT);
+ Screen::FontId of = _screen->setFont(_vm->gameFlags().use16ColorMode ? Screen::FID_SJIS_FNT : Screen::FID_9_FNT);
preprocessString(str, script, paramList, paramIndex);
_numCharsTotal = strlen(_dialogueBuffer);
@@ -581,7 +581,6 @@ void TextDisplayer_LoL::printLine(char *str) {
int n2 = 0;
int n1 = s - 1;
- //bool ct = false;
while (n1 > 0) {
//cut off line after last space
@@ -741,26 +740,15 @@ void TextDisplayer_LoL::textPageBreak() {
_vm->gui_notifyButtonListChanged();
- switch (inputFlag) {
- case 43:
- case 61:
+ if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) {
loop = false;
- break;
-
- case 199:
- case 201:
+ } else if (inputFlag == 199 || inputFlag == 201) {
if (_vm->posWithinRect(_vm->_mouseX, _vm->_mouseY, x, y, x + 74, y + 9))
target = true;
- break;
- case 200:
- case 202:
+ } else if (inputFlag == 199 || inputFlag == 201) {
if (target)
loop = false;
- break;
-
- default:
- break;
}
} while (loop);