Skip to content

Commit

Permalink
KYRA: (EOB) - add debugger, etc.
Browse files Browse the repository at this point in the history
- add basic debugger support
- fix several minor bugs
  • Loading branch information
athrxx authored and Johannes Schickel committed Dec 26, 2011
1 parent 2448d88 commit 816b40e
Show file tree
Hide file tree
Showing 17 changed files with 179 additions and 70 deletions.
39 changes: 23 additions & 16 deletions engines/kyra/chargen.cpp
Expand Up @@ -47,6 +47,7 @@ class CharacterGenerator {
int raceSexMenu();
int classMenu(int raceSex);
int alignmentMenu(int cClass);
int getInput(Button *buttonList);
void updateMagicShapes();
void generateStats(int index);
void modifyMenu();
Expand Down Expand Up @@ -153,8 +154,7 @@ bool CharacterGenerator::start(EobCharacter *characters, uint8 ***faceShapes) {
_characters = characters;
_faceShapes = *faceShapes;

_vm->sound()->playTrack(0);

_vm->snd_stopSound();
_vm->delay(_vm->_tickLength);

init();
Expand All @@ -169,8 +169,7 @@ bool CharacterGenerator::start(EobCharacter *characters, uint8 ***faceShapes) {

for (bool loop = true; loop && (!_vm->shouldQuit()); ) {
_vm->_gui->updateBoxFrameHighLight(_activeBox + 6);
_vm->sound()->process();
int inputFlag = _vm->checkInput(_vm->_activeButtons, false, 0);
int inputFlag = getInput(_vm->_activeButtons);
_vm->removeInputTop();

if (inputFlag) {
Expand Down Expand Up @@ -381,9 +380,7 @@ int CharacterGenerator::viewDeleteCharacter() {
int res = 0;
for (bool loop = true; loop && _characters[_activeBox].name[0] && !_vm->shouldQuit(); ) {
_vm->_gui->updateBoxFrameHighLight(_activeBox + 6);
_vm->sound()->process();

int inputFlag = _vm->checkInput(_vm->_activeButtons, false, 0);
int inputFlag =getInput(_vm->_activeButtons);
int cbx = _activeBox;
_vm->removeInputTop();

Expand Down Expand Up @@ -520,8 +517,7 @@ int CharacterGenerator::classMenu(int raceSex) {

while (res == -1 && !_vm->shouldQuit()) {
updateMagicShapes();

int in = _vm->checkInput(0, false, 0) & 0xff;
int in = getInput(_vm->_activeButtons) & 0xff;
Common::Point mp = _vm->getMousePos();

if (in == _vm->_keyMap[Common::KEYCODE_ESCAPE] || _vm->_gui->_menuLastInFlags == _vm->_keyMap[Common::KEYCODE_ESCAPE] || _vm->_gui->_menuLastInFlags == _vm->_keyMap[Common::KEYCODE_b]) {
Expand Down Expand Up @@ -569,8 +565,7 @@ int CharacterGenerator::alignmentMenu(int cClass) {

while (res == -1 && !_vm->shouldQuit()) {
updateMagicShapes();

int in = _vm->checkInput(0, false, 0) & 0xff;
int in = getInput(_vm->_activeButtons) & 0xff;
Common::Point mp = _vm->getMousePos();

if (in == _vm->_keyMap[Common::KEYCODE_ESCAPE] || _vm->_gui->_menuLastInFlags == _vm->_keyMap[Common::KEYCODE_ESCAPE] || _vm->_gui->_menuLastInFlags == _vm->_keyMap[Common::KEYCODE_b]) {
Expand All @@ -593,9 +588,21 @@ int CharacterGenerator::alignmentMenu(int cClass) {
return res;
}

void CharacterGenerator::updateMagicShapes() {
_vm->sound()->process();
int CharacterGenerator::getInput(Button *buttonList) {
if (_vm->game() == GI_EOB1 && _vm->sound()->checkTrigger()) {
_vm->sound()->resetTrigger();
_vm->sound()->playTrack(20);
// WORKAROUND for EOB II: The original implements the same sound trigger check as in EOB I.
// However, Westwood seems to have forgotten to set the trigger at the end of the AdLib song,
// so that the music will not loop. We simply check whether the sound driver is still playing.
} else if (_vm->game() == GI_EOB2 && !_vm->sound()->isPlaying()) {
_vm->delay(3 * _vm->_tickLength);
_vm->sound()->playTrack(13);
}
return _vm->checkInput(buttonList, false, 0);
}

void CharacterGenerator::updateMagicShapes() {
if (_magicShapesBox != _activeBox) {
_chargenMagicShapeTimer = 0;
_magicShapesBox = _activeBox;
Expand Down Expand Up @@ -719,7 +726,7 @@ void CharacterGenerator::statsAndFacesMenu() {

while (!in && !_vm->shouldQuit()) {
updateMagicShapes();
in = _vm->checkInput(_vm->_activeButtons, false, 0);
in = getInput(_vm->_activeButtons);
_vm->removeInputTop();

if (in == 0x8001) {
Expand Down Expand Up @@ -786,7 +793,7 @@ void CharacterGenerator::faceSelectMenu() {

while (!in && !_vm->shouldQuit()) {
updateMagicShapes();
in = _vm->checkInput(_vm->_activeButtons, false, 0);
in = getInput(_vm->_activeButtons);
_vm->removeInputTop();

_vm->_gui->updateBoxFrameHighLight(box + 10);
Expand Down Expand Up @@ -978,7 +985,7 @@ int CharacterGenerator::modifyStat(int index, int8 *stat1, int8 *stat2) {
for (bool loop = true; loop && !_vm->shouldQuit(); ) {
uint8 v1 = *s1;
updateMagicShapes();
int inputFlag = _vm->checkInput(_vm->_activeButtons, false, 0);
int inputFlag = getInput(_vm->_activeButtons);
_vm->removeInputTop();

if (inputFlag == _vm->_keyMap[Common::KEYCODE_LEFT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP4] || inputFlag == _vm->_keyMap[Common::KEYCODE_MINUS] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP_MINUS] || inputFlag == 0x8009) {
Expand Down
6 changes: 6 additions & 0 deletions engines/kyra/debugger.cpp
Expand Up @@ -26,6 +26,7 @@
#include "kyra/timer.h"
#include "kyra/resource.h"
#include "kyra/lol.h"
#include "kyra/eobcommon.h"

#include "common/system.h"

Expand Down Expand Up @@ -470,4 +471,9 @@ Debugger_LoL::Debugger_LoL(LoLEngine *vm) : Debugger(vm), _vm(vm) {
}
#endif // ENABLE_LOL

#ifdef ENABLE_EOB
Debugger_Eob::Debugger_Eob(EobCoreEngine *vm) : Debugger(vm), _vm(vm) {
}
#endif // ENABLE_EOB

} // End of namespace Kyra
12 changes: 12 additions & 0 deletions engines/kyra/debugger.h
Expand Up @@ -108,6 +108,18 @@ class Debugger_LoL : public Debugger {
};
#endif // ENABLE_LOL

#ifdef ENABLE_EOB
class EobCoreEngine;

class Debugger_Eob : public Debugger {
public:
Debugger_Eob(EobCoreEngine *vm);

protected:
EobCoreEngine *_vm;
};
#endif // ENABLE_EOB

} // End of namespace Kyra

#endif
2 changes: 1 addition & 1 deletion engines/kyra/eob1.h
Expand Up @@ -65,8 +65,8 @@ friend class GUI_Eob;

void seq_xdeath();

void loadSetIntroPalette(const char *filename);
void copyBlurRegion(int x1, int y1, int x2, int y2, int w, int h, int step);

void boxMorphTransition(int targetDestX, int targetDestY, int targetFinalX, int targetFinalY, int targetSrcX, int targetSrcY, int targetFinalW, int targetFinalH, int originX1, int originY1, int originW, int originH);
void whirlTransition();

Expand Down
2 changes: 1 addition & 1 deletion engines/kyra/eob2.cpp
Expand Up @@ -115,7 +115,7 @@ void DarkMoonEngine::runNpcDialogue(int npcIndex) {
int r = runDialogue(-1, 0, _npc1Strings[0], _npc1Strings[1], 0) - 1;

if (r == 0) {
_sound->playTrack(0);
snd_stopSound();
delay(3 * _tickLength);
snd_playSoundEffect(91);
npcJoinDialogue(1, 5, 6, 7);
Expand Down
19 changes: 17 additions & 2 deletions engines/kyra/eobcommon.cpp
Expand Up @@ -27,6 +27,7 @@
#include "kyra/sound_intern.h"
#include "kyra/script_eob.h"
#include "kyra/timer.h"
#include "kyra/debugger.h"

#include "common/config-manager.h"

Expand All @@ -40,6 +41,7 @@ EobCoreEngine::EobCoreEngine(OSystem *system, const GameFlags &flags) : LolEobBa
_teleporterWallId(flags.gameID == GI_EOB1 ? 52 : 44) {
_screen = 0;
_gui = 0;
_debugger = 0;

_playFinale = false;
_runFlag = true;
Expand Down Expand Up @@ -220,8 +222,11 @@ EobCoreEngine::~EobCoreEngine() {
_menuDefs = 0;

delete _inf;
_inf = 0;
delete _timer;
_timer = 0;
delete _debugger;
_debugger = 0;
}

Common::Error EobCoreEngine::init() {
Expand All @@ -241,6 +246,7 @@ Common::Error EobCoreEngine::init() {

//MidiDriverType midiDriver = MidiDriver::detectDevice(MDT_PCSPK | MDT_ADLIB);
_sound = new SoundAdLibPC(this, _mixer);
_sound->init();
assert(_sound);

if (_sound)
Expand All @@ -266,8 +272,13 @@ Common::Error EobCoreEngine::init() {

setupKeyMap();
_gui = new GUI_Eob(this);
assert(_gui);
_txt = new TextDisplayer_Eob(this, _screen);
assert(_txt);
_inf = new EobInfProcessor(this, _screen);
assert(_inf);
_debugger = new Debugger_Eob(this);
assert(_debugger);

_screen->loadFont(Screen::FID_6_FNT, "FONT6.FNT");
_screen->loadFont(Screen::FID_8_FNT, "FONT8.FNT");
Expand Down Expand Up @@ -682,7 +693,7 @@ void EobCoreEngine::setHandItem(Item itemIndex) {
int icon = _items[_itemInHand].icon;
const uint8 *shp = _itemIconShapes[icon];

if (icon && (_items[_itemInHand].flags & 0x80) && ((_flags.gameID == GI_EOB2 && (_partyEffectFlags & 2)) || (_flags.gameID == GI_EOB1 && (_partyEffectFlags & 0x10000)))) {
if (icon && (_items[_itemInHand].flags & 0x80) && (_partyEffectFlags & 2)) {
memcpy(_tempIconShape, shp, 300);
if (_flags.gameID == GI_EOB1)
_screen->replaceShapePalette(_tempIconShape, &_itemsOverlay[icon << 4]);
Expand Down Expand Up @@ -1246,7 +1257,7 @@ void EobCoreEngine::initDialogueSequence() {
gui_updateControls();
//_allowSkip = true;

_sound->playTrack(0);
snd_stopSound();
Common::SeekableReadStream *s = _res->createReadStream("TEXT.DAT");
_screen->loadFileDataToPage(s, 5, 32000);
_txt->setupField(9, 0);
Expand Down Expand Up @@ -2246,6 +2257,10 @@ void EobCoreEngine::snd_playSoundEffect(int id, int volume) {
_sound->playSoundEffect(id, volume);
}

void EobCoreEngine::snd_stopSound() {
_sound->playSoundEffect(0);
}

} // End of namespace Kyra

#endif // ENABLE_EOB
1 change: 1 addition & 0 deletions engines/kyra/eobcommon.h
Expand Up @@ -1139,6 +1139,7 @@ friend class CharacterGenerator;

// sound
void snd_playSoundEffect(int id, int volume=0xFF);
void snd_stopSound();
};

} // End of namespace Kyra
Expand Down
2 changes: 1 addition & 1 deletion engines/kyra/items_eob.cpp
Expand Up @@ -303,7 +303,7 @@ int EobCoreEngine::countQueuedItems(Item itemQueue, int16 id, int16 type, int co
EobItem *itm = &_items[o1];
forceLoop = false;
if (id != -1 || type != -1) {
if (((id != -1 ) || (id == -1 && type != itm->type)) && ((type != -1) || (type == -1 && id != o1)))
if (((id != -1) || (id == -1 && type != itm->type)) && ((type != -1) || (type == -1 && id != o1)))
continue;
}

Expand Down
6 changes: 5 additions & 1 deletion engines/kyra/saveload_eob.cpp
Expand Up @@ -411,9 +411,13 @@ Common::Error EobCoreEngine::saveGameStateIntern(int slot, const char *saveName,

completeDoorOperations();
generateTempData();
advanceTimers(_restPartyElapsedTime);
_restPartyElapsedTime = 0;

for (int i = 0; i < 6; i++) {
for (int i = 0; i < 6; i++)
timerSpecialCharacterUpdate(0x30 + i);

for (int i = 0; i < 6; i++) {
EobCharacter *c = &_characters[i];

out->writeByte(c->id);
Expand Down
8 changes: 2 additions & 6 deletions engines/kyra/scene_eob.cpp
Expand Up @@ -708,8 +708,6 @@ Common::String EobCoreEngine::initLevelData(int sub){

int slen = (_flags.gameID == GI_EOB1) ? 12 : 13;

_sound->playTrack(0);

for (int i = 0; i < sub; i++)
pos = data + READ_LE_UINT16(pos);

Expand Down Expand Up @@ -762,7 +760,7 @@ Common::String EobCoreEngine::initLevelData(int sub){
}

if (_flags.gameID == GI_EOB2) {
delay(_tickLength);
delay(3 * _tickLength);
_sound->loadSoundFile((const char*) pos);
pos += 13;
}
Expand Down Expand Up @@ -1029,10 +1027,8 @@ void EobCoreEngine::drawScene(int refresh) {
}
}

if (_sceneDefaultUpdate) {
if (_sceneDefaultUpdate)
delayUntil(_drawSceneTimer);
removeInputTop();
}

if (refresh && !_partyResting)
_screen->copyRegion(0, 0, 0, 0, 176, 120, 2, 0, Screen::CR_NO_P_CHECK);
Expand Down

0 comments on commit 816b40e

Please sign in to comment.