Skip to content

Commit

Permalink
MORTEVIELLE: Some renaming, remove useless variables, add debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Feb 20, 2013
1 parent 87d9769 commit f74600b
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 15 deletions.
36 changes: 36 additions & 0 deletions engines/mortevielle/debugger.cpp
@@ -0,0 +1,36 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include "mortevielle/debugger.h"
#include "mortevielle/mortevielle.h"

namespace Mortevielle {

Debugger::Debugger() : GUI::Debugger() {
DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit));
}

void Debugger::setParent(MortevielleEngine *vm) {
_vm = vm;
}

} // End of namespace Mortevielle
45 changes: 45 additions & 0 deletions engines/mortevielle/debugger.h
@@ -0,0 +1,45 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#ifndef MORTEVIELLE_DEBUGGER_H
#define MORTEVIELLE_DEBUGGER_H

#include "common/scummsys.h"
#include "gui/debugger.h"

namespace Mortevielle {

class MortevielleEngine;

class Debugger : public GUI::Debugger {
private:
MortevielleEngine *_vm;

public:
Debugger();
virtual ~Debugger() {}
void setParent(MortevielleEngine *vm);
};

} // End of namespace Mortevielle

#endif
4 changes: 2 additions & 2 deletions engines/mortevielle/graphics.h
Expand Up @@ -48,8 +48,8 @@ class PaletteManager {
class GfxSurface: public Graphics::Surface {
private:
int _xp, _yp;
int _xSize, _ySize, _var12;
int _var14, _lookupIndex, _lookupValue;
int _xSize, _ySize;
int _lookupIndex, _lookupValue;
bool _nibbleFlag;
int _thickness;
int _yInc, _yEnd, _xInc, _xEnd;
Expand Down
7 changes: 4 additions & 3 deletions engines/mortevielle/menu.cpp
Expand Up @@ -390,9 +390,9 @@ void Menu::menuDown(int ii) {
/**
* Menu is being removed, so restore the previous background area.
*/
void Menu::menuUp(int xx) {
void Menu::menuUp(int msgId) {
if (_multiTitle) {
g_vm->charecr(10, (_menuConstants[xx - 1][1] + 1) << 1);
g_vm->charecr(10, (_menuConstants[msgId - 1][1] + 1) << 1);

/* Restore the background area */
assert(g_vm->_screenSurface.pitch == g_vm->_backgroundSurface.pitch);
Expand Down Expand Up @@ -420,8 +420,9 @@ void Menu::eraseMenu() {

/**
* Handle updates to the menu
* @remarks Originally called 'mdn'
*/
void Menu::mdn() {
void Menu::updateMenu() {
if (!_menuActive)
return;

Expand Down
4 changes: 2 additions & 2 deletions engines/mortevielle/menu.h
Expand Up @@ -68,9 +68,9 @@ class Menu {
void enableMenuItem(int menuId);
void displayMenu();
void drawMenu();
void menuUp(int xx);
void menuUp(int msgId);
void eraseMenu();
void mdn();
void updateMenu();
void initMenu();

void setSearchMenu();
Expand Down
1 change: 1 addition & 0 deletions engines/mortevielle/module.mk
Expand Up @@ -2,6 +2,7 @@ MODULE := engines/mortevielle

MODULE_OBJS := \
actions.o \
debugger.o \
detection.o \
dialogs.o \
graphics.o \
Expand Down
23 changes: 15 additions & 8 deletions engines/mortevielle/mortevielle.cpp
Expand Up @@ -74,6 +74,7 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const ADGameDescription *g
Engine(system), _gameDescription(gameDesc), _randomSource("mortevielle"),
_soundManager(_mixer) {
g_vm = this;
_debugger.setParent(this);
_lastGameFrame = 0;
_mouseClick = false;
_inMainGameLoop = false;
Expand Down Expand Up @@ -345,6 +346,8 @@ bool MortevielleEngine::keyPressed() {
_lastGameFrame = g_system->getMillis();

_screenSurface.updateScreen();

_debugger.onFrame();
}

// Delay briefly to keep CPU usage down
Expand Down Expand Up @@ -409,8 +412,13 @@ void MortevielleEngine::addKeypress(Common::Event &evt) {
// Character to add
char ch = evt.kbd.ascii;

// Handle alphabetic keys
if ((evt.kbd.keycode >= Common::KEYCODE_a) && (evt.kbd.keycode <= Common::KEYCODE_z)) {
// Check for debugger
if ((evt.kbd.keycode == Common::KEYCODE_d) && (evt.kbd.flags & Common::KBD_CTRL)) {
// Attach to the debugger
_debugger.attach();
_debugger.onFrame();
} else if ((evt.kbd.keycode >= Common::KEYCODE_a) && (evt.kbd.keycode <= Common::KEYCODE_z)) {
// Handle alphabetic keys
if (evt.kbd.hasFlags(Common::KBD_CTRL))
ch = evt.kbd.keycode - Common::KEYCODE_a + 1;
else
Expand Down Expand Up @@ -523,6 +531,8 @@ void MortevielleEngine::delay(int amount) {
if (g_system->getMillis() > (_lastGameFrame + GAME_FRAME_DELAY)) {
_lastGameFrame = g_system->getMillis();
_screenSurface.updateScreen();

_debugger.onFrame();
}

g_system->delayMillis(10);
Expand Down Expand Up @@ -647,7 +657,7 @@ void MortevielleEngine::handleAction() {

_inMainGameLoop = true;
do {
_menu.mdn();
_menu.updateMenu();
prepareRoom();
_mouse.moveMouse(funct, inkey);
CHECK_QUIT;
Expand Down Expand Up @@ -982,7 +992,7 @@ int MortevielleEngine::getPresenceStatsGreenRoom() {
else if ((hour >= 0) && (hour < 8))
retVal = 70;

_menu.mdn();
_menu.updateMenu();

return retVal;
}
Expand Down Expand Up @@ -2258,11 +2268,8 @@ Common::String MortevielleEngine::getString(int num) {
}

void MortevielleEngine::copcha() {
int i = kAcha;
do {
for (int i = kAcha; i < kAcha + 390; i++)
_tabdon[i] = _tabdon[i + 390];
++i;
} while (i != kAcha + 390);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions engines/mortevielle/mortevielle.h
Expand Up @@ -37,6 +37,7 @@
#include "engines/engine.h"
#include "common/error.h"
#include "graphics/surface.h"
#include "mortevielle/debugger.h"
#include "mortevielle/graphics.h"
#include "mortevielle/menu.h"
#include "mortevielle/mouse.h"
Expand Down Expand Up @@ -475,6 +476,7 @@ class MortevielleEngine : public Engine {
// TODO: Replace the following with proper implementations, or refactor out the code using them
byte _mem[65536 * 16];

Debugger _debugger;
ScreenSurface _screenSurface;
PaletteManager _paletteManager;
GfxSurface _backgroundSurface;
Expand Down

0 comments on commit f74600b

Please sign in to comment.