Initial version of the Input class. Some things still missing.

svn-id: r10944
This commit is contained in:
David Eriksson 2003-10-23 06:44:35 +00:00
parent 3ccd6704bd
commit ad98347eb0
19 changed files with 371 additions and 187 deletions

View file

@ -23,6 +23,7 @@
#include "cutaway.h"
#include "display.h"
#include "graphics.h"
#include "input.h"
#include "sound.h"
#include "talk.h"
#include "walk.h"
@ -64,10 +65,11 @@ void Cutaway::run(
const char *filename,
char *nextFilename,
Graphics *graphics,
Input *input,
Logic *logic,
Resource *resource,
Sound *sound) {
Cutaway *cutaway = new Cutaway(filename, graphics, logic, resource, sound);
Cutaway *cutaway = new Cutaway(filename, graphics, input, logic, resource, sound);
cutaway->run(nextFilename);
delete cutaway;
}
@ -75,10 +77,11 @@ void Cutaway::run(
Cutaway::Cutaway(
const char *filename,
Graphics *graphics,
Input *input,
Logic *logic,
Resource *resource,
Sound *sound)
: _graphics(graphics), _logic(logic), _resource(resource), _sound(sound), _walk(logic->walk()),
: _graphics(graphics), _input(input), _logic(logic), _resource(resource), _sound(sound), _walk(logic->walk()),
_quit(false), _personDataCount(0), _personFaceCount(0), _lastSong(0), _songBeforeComic(0) {
memset(&_bankNames, 0, sizeof(_bankNames));
load(filename);
@ -304,7 +307,7 @@ void Cutaway::actionSpecialMove(int index) {
for (i = 5; i <= 100; i +=5) {
bob->scale = i;
bob->y -= 4;
_graphics->update();
_logic->update();
}
}
break;
@ -324,9 +327,8 @@ void Cutaway::actionSpecialMove(int index) {
BobSlot *bob_thugB2 = _graphics->bob(26);
_graphics->cameraBob(-1);
// XXX fastmode = 1;
_graphics->update(true);
_input->fastMode(true);
_logic->update();
int i = 4, k = 160;
@ -372,14 +374,14 @@ void Cutaway::actionSpecialMove(int index) {
bob_thugB1->x -= i * 4;
bob_thugB2->x -= i * 4;
_graphics->update(true);
_logic->update();
if (_quit)
return;
}
// XXX fastmode = 0;
_input->fastMode(false);
}
break;
@ -400,9 +402,9 @@ void Cutaway::actionSpecialMove(int index) {
BobSlot *bob_hands = _graphics->bob(24);
_graphics->cameraBob(-1);
// XXX fastmode = 1;
_input->fastMode(true);
_graphics->update(true);
_logic->update();
bob_box ->x += 280 * 2;
bob_beam ->x += 30;
@ -427,14 +429,14 @@ void Cutaway::actionSpecialMove(int index) {
bob_clock->x -= i * 2;
bob_hands->x -= i * 2;
_graphics->update(true);
_logic->update();
if (_quit)
return;
}
// XXX fastmode = 0;
_input->fastMode(false);
}
break;
@ -447,7 +449,7 @@ void Cutaway::actionSpecialMove(int index) {
BobSlot *bob22 = _graphics->bob(22);
_graphics->cameraBob(-1);
// XXX fastmode = 1;
_input->fastMode(true);
int horizontalScroll = display->horizontalScroll();
@ -466,14 +468,14 @@ void Cutaway::actionSpecialMove(int index) {
bob22->x += i;
_graphics->update(true);
_logic->update();
if (_quit)
return;
}
// XXX fastmode = 0;
_input->fastMode(false);
}
break;
@ -928,7 +930,7 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) {
int j;
for (j = 0; j < objAnim[i].speed; j++)
_graphics->update();
_logic->update();
}
if (_quit)
@ -951,7 +953,7 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) {
while (moving) {
moving = false;
_graphics->update();
_logic->update();
for (i = 0; i < frameCount; i++) {
BobSlot *bob = _graphics->bob(objAnim[i].object);
@ -1043,7 +1045,7 @@ void Cutaway::handlePersonRecord(
char voiceFilePrefix[MAX_STRING_SIZE];
findCdCut(_basename, index, voiceFilePrefix);
Talk::speak(sentence, (object.objectNumber == OBJECT_JOE) ? NULL : &p, voiceFilePrefix,
_graphics, _logic, _resource, _sound);
_graphics, _input, _logic, _resource, _sound);
}
}
@ -1401,7 +1403,7 @@ void Cutaway::talk(char *nextFilename) {
if (0 == scumm_stricmp(right(_talkFile, 4), ".dog")) {
nextFilename[0] = '\0';
Talk::talk(_talkFile, 0 /* XXX */, nextFilename, _graphics, _logic, _resource, _sound);
Talk::talk(_talkFile, 0 /* XXX */, nextFilename, _graphics, _input, _logic, _resource, _sound);
}
}
@ -1487,7 +1489,7 @@ void Cutaway::handleText(
int i;
for (i = 0; i < spaces; i++) {
_graphics->update();
_logic->update();
if (OBJECT_TYPE_TEXT_SPEAK == type || OBJECT_TYPE_TEXT_DISPLAY_AND_SPEAK == type) {
// XXX: see if speaking is finished
@ -1504,7 +1506,7 @@ void Cutaway::handleText(
}
_graphics->textClear(0,198);
_graphics->update();
_logic->update();
}
int Cutaway::countSpaces(ObjectType type, const char *segment) {

View file

@ -41,6 +41,7 @@ class Cutaway {
const char *filename,
char *nextFilename,
Graphics *graphics,
Input *input,
Logic *logic,
Resource *resource,
Sound *sound);
@ -136,6 +137,7 @@ class Cutaway {
};
Graphics *_graphics;
Input *_input;
Logic *_logic;
Resource *_resource;
Sound *_sound;
@ -214,6 +216,7 @@ class Cutaway {
Cutaway(
const char *filename,
Graphics *graphics,
Input *input,
Logic *logic,
Resource *resource,
Sound *sound);

View file

@ -108,21 +108,31 @@ enum Language {
enum Verb {
VERB_NONE = 0,
VERB_PANEL_COMMAND_FIRST = 1,
VERB_OPEN = 1,
VERB_CLOSE = 2,
VERB_MOVE = 3,
// no verb 4
VERB_GIVE = 5,
VERB_USE = 6,
VERB_PICK_UP = 7,
VERB_LOOK_AT = 9,
VERB_TALK_TO = 8,
VERB_PANEL_COMMAND_LAST = 8,
VERB_WALK_TO = 10,
VERB_SCROLL_UP = 11,
VERB_SCROLL_DOWN = 12,
VERB_INV_ITEM1 = 13,
VERB_INV_ITEM2 = 14,
VERB_INV_ITEM3 = 15,
VERB_INV_ITEM4 = 16,
VERB_DIGIT_FIRST = 13,
VERB_KEY_1 = 13,
VERB_KEY_2 = 14,
VERB_KEY_3 = 15,
VERB_KEY_4 = 16,
VERB_DIGIT_LAST = 16,
VERB_USE_JOURNAL = 20,
VERB_SKIP_TEXT = 101
};

View file

@ -592,7 +592,7 @@ void Display::palCustomFlash() {
// set flash palette
palSet(tempPal, 0, 255, true);
// restore original palette
palSet(_pals.screen, 0, 255, true);
// palSet(_pals.screen, 0, 255, true);
}

View file

@ -27,8 +27,8 @@
namespace Queen {
Graphics::Graphics(Display *display, Resource *resource)
: _cameraBob(0), _display(display), _resource(resource) {
Graphics::Graphics(Display *display, Input *input, Resource *resource)
: _cameraBob(0), _display(display), _input(input), _resource(resource) {
memset(_frames, 0, sizeof(_frames));
memset(_banks, 0, sizeof(_banks));
@ -727,7 +727,6 @@ void Graphics::loadBackdrop(const char* name, uint16 room) {
if (room >= 90) {
_cameraBob = 0;
}
_lastRoom = room; // TEMP
}
@ -806,26 +805,16 @@ void Graphics::cameraBob(int bobNum) {
}
void Graphics::update(bool fastmode) {
void Graphics::update(uint16 room) {
// FIXME: temporary code, move to Logic::update()
bobSortAll();
if (_cameraBob >= 0) {
_display->horizontalScrollUpdate(_bobs[_cameraBob].x);
}
// FIXME: currently, we use the _lastRoom variable only
// to know in which current room we are. This is necessary
// for the parallax stuff as it relies on the room number.
// When we switch to the Logic::update() method, we will be
// able to get rid of this variable...
bobCustomParallax(_lastRoom);
bobCustomParallax(room);
_display->prepareUpdate();
bobDrawAll();
textDrawAll();
if (!fastmode) {
g_queen->delay(100);
}
_display->palCustomScroll(_lastRoom);
_display->update(_bobs[0].active, _bobs[0].x, _bobs[0].y);
}
void Graphics::bobSetText(

View file

@ -23,6 +23,7 @@
#define QUEENGRAPHICS_H
#include "queen/queen.h"
#include "queen/input.h"
#include "queen/defs.h"
#include "queen/structs.h"
@ -105,11 +106,12 @@ struct TextSlot {
class Display;
class Input;
class Graphics {
public:
Graphics(Display *display, Resource *resource);
Graphics(Display *display, Input *input, Resource *resource);
~Graphics();
void bankLoad(const char *bankname, uint32 bankslot); // loadbank()
@ -161,7 +163,7 @@ public:
void cameraBob(int bobNum);
int cameraBob() { return _cameraBob; }
void update(bool fastmode = false);
void update(uint16 room);
private:
@ -199,9 +201,8 @@ private:
int _cameraBob; // cambob
uint16 _lastRoom; // TEMP
Display *_display;
Input *_input;
Resource *_resource;
};

116
queen/input.cpp Normal file
View file

@ -0,0 +1,116 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 The ScummVM project
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*
*/
#include "stdafx.h"
#include "queen/input.h"
#include "common/system.h"
#include "common/util.h"
namespace Queen {
Input::Input(OSystem *system) :
_system(system), _fastMode(false), _keyVerb(VERB_NONE),
_cutawayRunning(false), _cutQuit(false), _talkQuit(false) {
}
void Input::delay() {
delay(_fastMode ? DELAY_SHORT : DELAY_NORMAL);
}
void Input::delay(uint amount) {
OSystem::Event event;
uint32 start = _system->get_msecs();
uint32 cur = start;
_key_pressed = 0; //reset
do {
while (_system->poll_event(&event)) {
switch (event.event_code) {
case OSystem::EVENT_KEYDOWN:
if (event.kbd.flags == OSystem::KBD_CTRL) {
if (event.kbd.keycode == 'f') {
_fastMode ^= 1;
break;
}
if (event.kbd.keycode == 'g') {
_fastMode ^= 2;
break;
}
}
debug(1, "event.kbd.keycode = %i (%c)",
event.kbd.keycode,
isprint(event.kbd.keycode) ? event.kbd.keycode : '.');
// Make sure backspace works right (this fixes a small issue on OS X)
if (event.kbd.keycode == 8)
_key_pressed = 8;
else
_key_pressed = (byte)event.kbd.ascii;
break;
case OSystem::EVENT_MOUSEMOVE:
_sdl_mouse_x = event.mouse.x;
_sdl_mouse_y = event.mouse.y;
break;
case OSystem::EVENT_LBUTTONDOWN:
#ifdef _WIN32_WCE
_sdl_mouse_x = event.mouse.x;
_sdl_mouse_y = event.mouse.y;
#endif
break;
case OSystem::EVENT_RBUTTONDOWN:
break;
case OSystem::EVENT_QUIT:
_system->quit();
break;
default:
break;
}
}
if (amount == 0)
break;
{
uint this_delay = 20; // 1?
if (this_delay > amount)
this_delay = amount;
_system->delay_msecs(this_delay);
}
cur = _system->get_msecs();
} while (cur < start + amount);
}
void Input::checkKeys() {
}
} // End of namespace Queen

116
queen/input.h Normal file
View file

@ -0,0 +1,116 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 The ScummVM project
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*
*/
#ifndef INPUT_H
#define INPUT_H
#include "queen/defs.h"
class OSystem;
namespace Queen {
class Input {
public:
//! Adjust here to change delays!
enum {
DELAY_SHORT = 10,
DELAY_NORMAL = 100
};
Input(OSystem *system);
//! calls the other delay() with a value adjusted depending on _fastMode
void delay();
//! moved QueenEngine::delay() here
void delay(uint amount);
//! convert input to verb
void checkKeys();
//! use instead of KEYVERB=0
void clearKeyVerb() { _keyVerb = VERB_NONE; }
//! _keyVerb is open/close/move/give/look at/pick up/talk to
bool verbIsPanelCommand() {
return
_keyVerb >= VERB_PANEL_COMMAND_FIRST &&
_keyVerb <= VERB_PANEL_COMMAND_LAST;
}
//! return _keyVerb if isPanelCommand() is true, otherwise VERB_NONE
Verb verbPanelCommand();
//! If _keyVerb is VERB_USE_JOURNAL
bool verbUseJournal() { return _keyVerb == VERB_USE_JOURNAL; }
//! If _keyVerb is VERB_KEY_1 to VERB_KEY_4
bool verbIsDigit() {
return
_keyVerb >= VERB_DIGIT_FIRST &&
_keyVerb <= VERB_DIGIT_LAST;
}
//! Returns 1-4 if keyDigit() is true, otherwise -1
int verbDigit();
bool cutQuit() { return _cutQuit; }
void cutQuitReset() { _cutQuit = false; }
bool talkQuit() { return _talkQuit; }
void talkQuitReset() { _talkQuit = false; }
void fastMode(bool fm) { _fastMode = fm; }
private:
//! Used to get keyboard and mouse events
OSystem *_system;
//! Some cutaways require update() run faster
bool _fastMode;
//! The current verb received from keyboard
Verb _keyVerb; // KEYVERB
//! set if a cutaway is running
bool _cutawayRunning; // CUTON
//! moved Cutaway::_quit here
bool _cutQuit; // CUTQUIT
//! moved Talk::_quit here
bool _talkQuit; // TALKQUIT
//! Set by delay();
int _key_pressed;
//! Set by delay();
int _sdl_mouse_x, _sdl_mouse_y;
};
} // End of namespace Queen
#endif

View file

@ -25,13 +25,15 @@
#include "queen/defs.h"
#include "queen/display.h"
#include "queen/graphics.h"
#include "queen/input.h"
#include "queen/walk.h"
namespace Queen {
Logic::Logic(Resource *resource, Graphics *graphics, Display *theDisplay, Sound *sound)
: _resource(resource), _graphics(graphics), _display(theDisplay), _sound(sound), _talkSpeed(DEFAULT_TALK_SPEED) {
Logic::Logic(Resource *resource, Graphics *graphics, Display *theDisplay, Input *input, Sound *sound)
: _resource(resource), _graphics(graphics), _display(theDisplay),
_input(input), _sound(sound), _talkSpeed(DEFAULT_TALK_SPEED) {
_jas = _resource->loadFile("QUEEN.JAS", 20);
_joe.x = _joe.y = 0;
_joe.scale = 100;
@ -1124,7 +1126,7 @@ void Logic::roomDisplay(const char* room, RoomDisplayMode mode, uint16 scale, in
// FIXME: commented for now, to avoid color glitches when
// switching rooms during cutaway
// if (mode != RDM_NOFADE_JOE) {
_graphics->update();
update();
if (_currentRoom >= 114) {
_display->palFadeIn(0, 255, _currentRoom);
}
@ -1609,26 +1611,26 @@ uint16 Logic::joeFace() {
if (_joe.facing == DIR_FRONT) {
if (_joe.prevFacing == DIR_BACK) {
pbs->frameNum = 33 + FRAMES_JOE_XTRA;
_graphics->update();
update();
}
frame = 34;
}
else if (_joe.facing == DIR_BACK) {
if (_joe.prevFacing == DIR_FRONT) {
pbs->frameNum = 33 + FRAMES_JOE_XTRA;
_graphics->update();
update();
}
frame = 35;
}
else if ((_joe.facing == DIR_LEFT && _joe.prevFacing == DIR_RIGHT)
|| (_joe.facing == DIR_RIGHT && _joe.prevFacing == DIR_LEFT)) {
pbs->frameNum = 34 + FRAMES_JOE_XTRA;
_graphics->update();
update();
}
pbs->frameNum = frame + FRAMES_JOE_XTRA;
pbs->scale = _joe.scale;
pbs->xflip = (_joe.facing == DIR_LEFT);
_graphics->update();
update();
_joe.prevFacing = _joe.facing;
switch (frame) {
case 33: frame = 1; break;
@ -1755,12 +1757,12 @@ void Logic::joeGrabDirection(StateGrab grab, uint16 speed) {
_graphics->bankUnpack(5, 29 + FRAMES_JOE_XTRA, 7);
bobJoe->xflip = (_joe.facing == DIR_LEFT);
bobJoe->scale = _joe.scale;
_graphics->update();
update();
// grab up
_graphics->bankUnpack(7, 29 + FRAMES_JOE_XTRA, 7);
bobJoe->xflip = (_joe.facing == DIR_LEFT);
bobJoe->scale = _joe.scale;
_graphics->update();
update();
// turn back
if (speed == 0) {
frame = 7;
@ -1775,12 +1777,12 @@ void Logic::joeGrabDirection(StateGrab grab, uint16 speed) {
_graphics->bankUnpack(frame, 29 + FRAMES_JOE_XTRA, 7);
bobJoe->xflip = (_joe.facing == DIR_LEFT);
bobJoe->scale = _joe.scale;
_graphics->update();
update();
// extra delay for grab down
if (grab == STATE_GRAB_DOWN) {
_graphics->update();
_graphics->update();
update();
update();
}
if (speed > 0) {
@ -1838,9 +1840,17 @@ void Logic::joeUseUnderwear() {
void Logic::playCutaway(const char* cutFile) {
char next[20];
Cutaway::run(cutFile, next, _graphics, this, _resource, _sound);
Cutaway::run(cutFile, next, _graphics, _input, this, _resource, _sound);
}
void Logic::update() {
_graphics->update(_currentRoom);
_input->delay();
_display->palCustomScroll(_currentRoom);
BobSlot *joe = _graphics->bob(0);
_display->update(joe->active, joe->x, joe->y);
_input->checkKeys();
}
} // End of namespace Queen

View file

@ -54,13 +54,14 @@ struct Command {
class Graphics;
class Resource;
class Display;
class Input;
class Sound;
class Walk;
class Logic {
public:
Logic(Resource *resource, Graphics *graphics, Display *display, Sound *sound);
Logic(Resource *resource, Graphics *graphics, Display *display, Input *input, Sound *sound);
~Logic();
uint16 currentRoom();
@ -182,6 +183,8 @@ public:
Display *display() { return _display; }
void update();
protected:
bool _textToggle;
bool _speechToggle;
@ -277,6 +280,7 @@ protected:
Resource *_resource;
Graphics *_graphics;
Display *_display;
Input *_input;
Sound *_sound;
Walk *_walk;

View file

@ -4,6 +4,7 @@ MODULE_OBJS = \
queen/cutaway.o \
queen/display.o \
queen/graphics.o \
queen/input.o \
queen/logic.o \
queen/queen.o \
queen/resource.o \

View file

@ -28,6 +28,7 @@
#include "queen/cutaway.h"
#include "queen/display.h"
#include "queen/graphics.h"
#include "queen/input.h"
#include "queen/queen.h"
#include "queen/sound.h"
#include "queen/talk.h"
@ -85,13 +86,9 @@ REGISTER_PLUGIN("Flight of the Amazon Queen", Engine_QUEEN_gameList, Engine_QUEE
namespace Queen {
QueenEngine *g_queen;
QueenEngine::QueenEngine(GameDetector *detector, OSystem *syst)
: Engine(detector, syst) {
g_queen = this;
_game = detector->_game.id;
if (!_mixer->bindToSystem(syst))
@ -111,8 +108,10 @@ QueenEngine::QueenEngine(GameDetector *detector, OSystem *syst)
QueenEngine::~QueenEngine() {
delete _resource;
delete _display;
delete _logic;
delete _graphics;
delete _logic;
delete _input;
}
void QueenEngine::errorString(const char *buf1, char *buf2) {
@ -132,35 +131,33 @@ void QueenEngine::roomChanged() {
// XXX fadeout(0,223);
}
else if (_logic->currentRoom() == 95 && _logic->gameState(VAR_INTRO_PLAYED) == 0) {
char nextFilename[20];
_logic->roomDisplay(_logic->roomName(_logic->currentRoom()), RDM_FADE_NOJOE, 100, 2, true);
if (_resource->isDemo()) {
if (_resource->exists("pclogo.cut"))
Cutaway::run("pclogo.cut", nextFilename, _graphics, _logic, _resource, _sound);
_logic->playCutaway("pclogo.cut");
else
Cutaway::run("clogo.cut", nextFilename, _graphics, _logic, _resource, _sound);
_logic->playCutaway("clogo.cut");
}
else {
Cutaway::run("copy.cut", nextFilename, _graphics, _logic, _resource, _sound);
Cutaway::run("clogo.cut", nextFilename, _graphics, _logic, _resource, _sound);
_logic->playCutaway("copy.cut");
_logic->playCutaway("clogo.cut");
// TODO enable talking for talkie version
Cutaway::run("cdint.cut", nextFilename, _graphics, _logic, _resource, _sound);
_logic->playCutaway("cdint.cut");
// restore palette colors ranging from 144 to 256
_graphics->loadPanel();
Cutaway::run("cred.cut", nextFilename, _graphics, _logic, _resource, _sound);
_logic->playCutaway("cred.cut");
}
_logic->currentRoom(73);
_logic->entryObj(584);
_logic->roomDisplay(_logic->roomName(_logic->currentRoom()), RDM_FADE_JOE, 100, 2, true);
Cutaway::run("c70d.cut", nextFilename, _graphics, _logic, _resource, _sound);
_logic->playCutaway("c70d.cut");
_logic->gameState(VAR_INTRO_PLAYED, 1);
@ -188,7 +185,7 @@ void QueenEngine::go() {
// queen.c lines 4080-4104
if (_logic->newRoom() > 0) {
_graphics->textClear(151, 151);
_graphics->update();
_logic->update();
_logic->oldRoom(_logic->currentRoom());
_logic->currentRoom(_logic->newRoom());
roomChanged();
@ -211,18 +208,15 @@ void QueenEngine::go() {
break; // XXX don't loop yet
}
while (1) { //main loop
delay(1000);
}
}
void QueenEngine::initialise(void) {
_resource = new Resource(_gameDataPath, _detector->_game.detectname);
_display = new Display(_system);
_graphics = new Graphics(_display, _resource);
_sound = Sound::giveSound(_mixer, _resource, _resource->compression());
_logic = new Logic(_resource, _graphics, _display, _sound);
_input = new Input(_system);
_graphics = new Graphics(_display, _input, _resource);
_sound = Sound::giveSound(_mixer, _input, _resource, _resource->compression());
_logic = new Logic(_resource, _graphics, _display, _input, _sound);
_timer->installTimerProc(&timerHandler, 1000000 / 50, this); //call 50 times per second
}
@ -238,73 +232,4 @@ void QueenEngine::gotTimerTick() {
_display->handleTimer();
}
void QueenEngine::delay(uint amount) {
OSystem::Event event;
uint32 start = _system->get_msecs();
uint32 cur = start;
_key_pressed = 0; //reset
do {
while (_system->poll_event(&event)) {
switch (event.event_code) {
case OSystem::EVENT_KEYDOWN:
if (event.kbd.flags == OSystem::KBD_CTRL) {
if (event.kbd.keycode == 'f') {
_fastMode ^= 1;
break;
}
if (event.kbd.keycode == 'g') {
_fastMode ^= 2;
break;
}
}
// Make sure backspace works right (this fixes a small issue on OS X)
if (event.kbd.keycode == 8)
_key_pressed = 8;
else
_key_pressed = (byte)event.kbd.ascii;
break;
case OSystem::EVENT_MOUSEMOVE:
_sdl_mouse_x = event.mouse.x;
_sdl_mouse_y = event.mouse.y;
break;
case OSystem::EVENT_LBUTTONDOWN:
#ifdef _WIN32_WCE
_sdl_mouse_x = event.mouse.x;
_sdl_mouse_y = event.mouse.y;
#endif
break;
case OSystem::EVENT_RBUTTONDOWN:
break;
case OSystem::EVENT_QUIT:
_system->quit();
break;
default:
break;
}
}
if (amount == 0)
break;
{
uint this_delay = 20; // 1?
if (this_delay > amount)
this_delay = amount;
_system->delay_msecs(this_delay);
}
cur = _system->get_msecs();
} while (cur < start + amount);
}
} // End of namespace Queen

View file

@ -33,6 +33,7 @@
namespace Queen {
class Graphics;
class Input;
class Logic;
class Display;
class Sound;
@ -41,18 +42,17 @@ class QueenEngine : public Engine {
void errorString(const char *buf_input, char *buf_output);
protected:
byte _game;
byte _key_pressed;
bool _quickLaunch; // set when starting with -x
uint16 _debugMode;
int _numScreenUpdates;
int _number_of_savegames;
int _sdl_mouse_x, _sdl_mouse_y;
FILE *_dump_file;
Graphics *_graphics;
Input *_input;
Resource *_resource;
Logic *_logic;
Display *_display;
@ -64,8 +64,6 @@ public:
QueenEngine(GameDetector *detector, OSystem *syst);
virtual ~QueenEngine();
void delay(uint amount);
protected:
byte _fastMode;
@ -80,9 +78,6 @@ protected:
void gotTimerTick();
};
// XXX: Temporary hack to allow Graphics to call delay()
extern QueenEngine *g_queen;
} // End of namespace Queen
#endif

View file

@ -22,37 +22,38 @@
#include "stdafx.h"
#include "common/file.h"
#include "common/util.h"
#include "queen/input.h"
#include "queen/resource.h"
#include "queen/sound.h"
#include "queen/queen.h" //g_queen (temporary)
#define SB_HEADER_SIZE 110
namespace Queen {
Sound::Sound(SoundMixer *mixer, Resource *resource) : _mixer(mixer), _resource(resource), _sfxHandle(0) {
Sound::Sound(SoundMixer *mixer, Input *input, Resource *resource) :
_mixer(mixer), _input(input), _resource(resource), _sfxHandle(0) {
}
Sound::~Sound() {
}
Sound *Sound::giveSound(SoundMixer *mixer, Resource *resource, uint8 compression) {
Sound *Sound::giveSound(SoundMixer *mixer, Input *input, Resource *resource, uint8 compression) {
switch(compression) {
case COMPRESSION_NONE:
return new SBSound(mixer, resource);
return new SBSound(mixer, input, resource);
break;
case COMPRESSION_MP3:
#ifndef USE_MAD
warning("Using MP3 compressed datafile, but MP3 support not compiled in");
return new SilentSound(mixer, resource);
return new SilentSound(mixer, input, resource);
#else
return new MP3Sound(mixer, resource);
return new MP3Sound(mixer, input, resource);
#endif
break;
default:
warning("Unknown compression type");
return new SilentSound(mixer, resource);
return new SilentSound(mixer, input, resource);
}
}
@ -76,7 +77,7 @@ void SBSound::sfxPlay(const char *base) {
strcat(name, ".SB");
while(isPlaying())
g_queen->delay(10);
_input->delay(10);
if (_resource->exists(name))
playSound(_resource->loadFile(name, SB_HEADER_SIZE), _resource->fileSize(name) - SB_HEADER_SIZE);
@ -94,7 +95,7 @@ void MP3Sound::sfxPlay(const char *base) {
strcat(name, ".SB");
while(isPlaying())
g_queen->delay(10);
_input->delay(10);
if (_resource->exists(name))
_mixer->playMP3(&_sfxHandle, _resource->giveMP3(name), _resource->fileSize(name));

View file

@ -28,18 +28,20 @@
namespace Queen {
class Input;
class Resource;
class Sound {
public:
Sound(SoundMixer *mixer, Resource *resource);
Sound(SoundMixer *mixer, Input *input, Resource *resource);
virtual ~Sound();
virtual void sfxPlay(const char *base) = 0;
static Sound *giveSound(SoundMixer *mixer, Resource *resource, uint8 compression);
static Sound *giveSound(SoundMixer *mixer, Input *input, Resource *resource, uint8 compression);
bool isPlaying();
protected:
SoundMixer *_mixer;
Input *_input;
Resource *_resource;
PlayingSoundHandle _sfxHandle;
@ -47,13 +49,13 @@ protected:
class SilentSound : public Sound {
public:
SilentSound(SoundMixer *mixer, Resource *resource) : Sound(mixer, resource) {};
SilentSound(SoundMixer *mixer, Input *input, Resource *resource) : Sound(mixer, input, resource) {};
void sfxPlay(const char *base) { }
};
class SBSound : public Sound {
public:
SBSound(SoundMixer *mixer, Resource *resource) : Sound(mixer, resource) {};
SBSound(SoundMixer *mixer, Input *input, Resource *resource) : Sound(mixer, input, resource) {};
int playSound(byte *sound, uint32 size);
void sfxPlay(const char *base);
};
@ -61,7 +63,7 @@ public:
#ifdef USE_MAD
class MP3Sound : public Sound {
public:
MP3Sound(SoundMixer *mixer, Resource *resource) : Sound(mixer, resource) {};
MP3Sound(SoundMixer *mixer, Input *input, Resource *resource) : Sound(mixer, input, resource) {};
void sfxPlay(const char *base);
};
#endif

View file

@ -38,10 +38,11 @@ void Talk::talk(
int personInRoom,
char *cutawayFilename,
Graphics *graphics,
Input *input,
Logic *logic,
Resource *resource,
Sound *sound) {
Talk *talk = new Talk(graphics, logic, resource, sound);
Talk *talk = new Talk(graphics, input, logic, resource, sound);
talk->talk(filename, personInRoom, cutawayFilename);
delete talk;
}
@ -51,10 +52,11 @@ bool Talk::speak(
Person *person,
const char *voiceFilePrefix,
Graphics *graphics,
Input *input,
Logic *logic,
Resource *resource,
Sound *sound) {
Talk *talk = new Talk(graphics, logic, resource, sound);
Talk *talk = new Talk(graphics, input, logic, resource, sound);
bool result = talk->speak(sentence, person, voiceFilePrefix);
delete talk;
return result;
@ -62,10 +64,12 @@ bool Talk::speak(
Talk::Talk(
Graphics *graphics,
Input *input,
Logic *logic,
Resource *resource,
Sound *sound)
: _graphics(graphics), _logic(logic), _resource(resource), _sound(sound), _fileData(NULL), _quit(false) {
Sound *sound) :
_graphics(graphics), _input(input), _logic(logic), _resource(resource),
_sound(sound), _fileData(NULL), _quit(false) {
//! TODO Move this to the Logic class later!
memset(_talkSelected, 0, sizeof(_talkSelected));
@ -649,7 +653,7 @@ void Talk::speakSegment(
for (i = 0; i < 10; i++) {
if (_quit)
break;
_graphics->update();
_logic->update();
}
return;
@ -775,7 +779,7 @@ void Talk::speakSegment(
if (length == 0 && !isJoe && parameters->bf > 0) {
_graphics->bankOverpack(parameters->bf, startFrame, bankNum);
_graphics->update();
_logic->update();
}
/* A12 = the frame pointer for the full body frame, well use this */
@ -860,23 +864,23 @@ void Talk::speakSegment(
}
if (!_talkHead)
_graphics->update();
_logic->update();
}
else
_graphics->update();
_logic->update();
if (_logic->joeWalk() == 3) {
if (_quit)
break;
_graphics->update();
_logic->update();
}
else {
if (_quit)
break;
// XXX CHECK_PLAYER();
_graphics->update(); // XXX call it ourselves as CHECK_PLAYER is not called
_logic->update(); // XXX call it ourselves as CHECK_PLAYER is not called
if (_logic->joeWalk() == 2)
// Selected a command, so exit
@ -939,7 +943,7 @@ void Talk::speakSegment(
}
}
_graphics->update();
_logic->update();
}
const Talk::SpeechParameters *Talk::findSpeechParameters(
@ -1120,7 +1124,7 @@ int16 Talk::selectSentence() {
if (_quit)
break;
_graphics->update();
_logic->update();
// XXX zone = zone(1, mouseX, mouseY);

View file

@ -41,6 +41,7 @@ class Talk {
int personInRoom,
char *cutawayFilename,
Graphics *graphics,
Input *input,
Logic *logic,
Resource *resource,
Sound *sound);
@ -51,6 +52,7 @@ class Talk {
Person *person,
const char *voiceFilePrefix,
Graphics *graphics,
Input *input,
Logic *logic,
Resource *resource,
Sound *sound);
@ -108,6 +110,7 @@ class Talk {
Common::RandomSource _randomizer;
Graphics *_graphics;
Input *_input;
Logic *_logic;
Resource *_resource;
Sound *_sound;
@ -159,7 +162,7 @@ class Talk {
static const SpeechParameters _speechParameters[];
Talk(Graphics *graphics, Logic *logic, Resource *resource, Sound *sound);
Talk(Graphics *graphics, Input *input, Logic *logic, Resource *resource, Sound *sound);
~Talk();
//! Perform talk in file and return a cutaway filename

View file

@ -156,7 +156,7 @@ bool Walk::animateJoe() {
if (pbs->speed == 0) {
pbs->speed = 1;
}
_graphics->update(); // CHECK_PLAYER();
_logic->update(); // CHECK_PLAYER();
if (_logic->joeWalk() == 2) { // || cutQuit
// we are about to do something else, so stop walking
interrupted = true;
@ -290,7 +290,7 @@ void Walk::animatePerson(const MovePersonData *mpd, uint16 image, uint16 bobNum,
}
while (pbs->moving) {
_graphics->update();
_logic->update();
uint16 scale = pwd->area->calcScale(pbs->y);
pbs->scale = scale;
if (pbs->xmajor) {

View file

@ -142,15 +142,17 @@ scrollx Display::_horizontalScroll
INPUT
=====
check_keys() Input::checkKeys()
get_key() *not needed*
-
drawmouseflag
key_commands
key_language
KEYVERB
KEYVERB Input::_keyVerb
MKEY
MouseButton
mouseflag
no_check_keys
no_check_keys Input::_noCheckKeys
INVENTORY