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

View file

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

View file

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

View file

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

View file

@ -27,8 +27,8 @@
namespace Queen { namespace Queen {
Graphics::Graphics(Display *display, Resource *resource) Graphics::Graphics(Display *display, Input *input, Resource *resource)
: _cameraBob(0), _display(display), _resource(resource) { : _cameraBob(0), _display(display), _input(input), _resource(resource) {
memset(_frames, 0, sizeof(_frames)); memset(_frames, 0, sizeof(_frames));
memset(_banks, 0, sizeof(_banks)); memset(_banks, 0, sizeof(_banks));
@ -727,7 +727,6 @@ void Graphics::loadBackdrop(const char* name, uint16 room) {
if (room >= 90) { if (room >= 90) {
_cameraBob = 0; _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() // FIXME: temporary code, move to Logic::update()
bobSortAll(); bobSortAll();
if (_cameraBob >= 0) { if (_cameraBob >= 0) {
_display->horizontalScrollUpdate(_bobs[_cameraBob].x); _display->horizontalScrollUpdate(_bobs[_cameraBob].x);
} }
// FIXME: currently, we use the _lastRoom variable only bobCustomParallax(room);
// 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);
_display->prepareUpdate(); _display->prepareUpdate();
bobDrawAll(); bobDrawAll();
textDrawAll(); textDrawAll();
if (!fastmode) {
g_queen->delay(100);
}
_display->palCustomScroll(_lastRoom);
_display->update(_bobs[0].active, _bobs[0].x, _bobs[0].y);
} }
void Graphics::bobSetText( void Graphics::bobSetText(

View file

@ -23,6 +23,7 @@
#define QUEENGRAPHICS_H #define QUEENGRAPHICS_H
#include "queen/queen.h" #include "queen/queen.h"
#include "queen/input.h"
#include "queen/defs.h" #include "queen/defs.h"
#include "queen/structs.h" #include "queen/structs.h"
@ -105,11 +106,12 @@ struct TextSlot {
class Display; class Display;
class Input;
class Graphics { class Graphics {
public: public:
Graphics(Display *display, Resource *resource); Graphics(Display *display, Input *input, Resource *resource);
~Graphics(); ~Graphics();
void bankLoad(const char *bankname, uint32 bankslot); // loadbank() void bankLoad(const char *bankname, uint32 bankslot); // loadbank()
@ -161,7 +163,7 @@ public:
void cameraBob(int bobNum); void cameraBob(int bobNum);
int cameraBob() { return _cameraBob; } int cameraBob() { return _cameraBob; }
void update(bool fastmode = false); void update(uint16 room);
private: private:
@ -199,9 +201,8 @@ private:
int _cameraBob; // cambob int _cameraBob; // cambob
uint16 _lastRoom; // TEMP
Display *_display; Display *_display;
Input *_input;
Resource *_resource; 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/defs.h"
#include "queen/display.h" #include "queen/display.h"
#include "queen/graphics.h" #include "queen/graphics.h"
#include "queen/input.h"
#include "queen/walk.h" #include "queen/walk.h"
namespace Queen { namespace Queen {
Logic::Logic(Resource *resource, Graphics *graphics, Display *theDisplay, Sound *sound) Logic::Logic(Resource *resource, Graphics *graphics, Display *theDisplay, Input *input, Sound *sound)
: _resource(resource), _graphics(graphics), _display(theDisplay), _sound(sound), _talkSpeed(DEFAULT_TALK_SPEED) { : _resource(resource), _graphics(graphics), _display(theDisplay),
_input(input), _sound(sound), _talkSpeed(DEFAULT_TALK_SPEED) {
_jas = _resource->loadFile("QUEEN.JAS", 20); _jas = _resource->loadFile("QUEEN.JAS", 20);
_joe.x = _joe.y = 0; _joe.x = _joe.y = 0;
_joe.scale = 100; _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 // FIXME: commented for now, to avoid color glitches when
// switching rooms during cutaway // switching rooms during cutaway
// if (mode != RDM_NOFADE_JOE) { // if (mode != RDM_NOFADE_JOE) {
_graphics->update(); update();
if (_currentRoom >= 114) { if (_currentRoom >= 114) {
_display->palFadeIn(0, 255, _currentRoom); _display->palFadeIn(0, 255, _currentRoom);
} }
@ -1609,26 +1611,26 @@ uint16 Logic::joeFace() {
if (_joe.facing == DIR_FRONT) { if (_joe.facing == DIR_FRONT) {
if (_joe.prevFacing == DIR_BACK) { if (_joe.prevFacing == DIR_BACK) {
pbs->frameNum = 33 + FRAMES_JOE_XTRA; pbs->frameNum = 33 + FRAMES_JOE_XTRA;
_graphics->update(); update();
} }
frame = 34; frame = 34;
} }
else if (_joe.facing == DIR_BACK) { else if (_joe.facing == DIR_BACK) {
if (_joe.prevFacing == DIR_FRONT) { if (_joe.prevFacing == DIR_FRONT) {
pbs->frameNum = 33 + FRAMES_JOE_XTRA; pbs->frameNum = 33 + FRAMES_JOE_XTRA;
_graphics->update(); update();
} }
frame = 35; frame = 35;
} }
else if ((_joe.facing == DIR_LEFT && _joe.prevFacing == DIR_RIGHT) else if ((_joe.facing == DIR_LEFT && _joe.prevFacing == DIR_RIGHT)
|| (_joe.facing == DIR_RIGHT && _joe.prevFacing == DIR_LEFT)) { || (_joe.facing == DIR_RIGHT && _joe.prevFacing == DIR_LEFT)) {
pbs->frameNum = 34 + FRAMES_JOE_XTRA; pbs->frameNum = 34 + FRAMES_JOE_XTRA;
_graphics->update(); update();
} }
pbs->frameNum = frame + FRAMES_JOE_XTRA; pbs->frameNum = frame + FRAMES_JOE_XTRA;
pbs->scale = _joe.scale; pbs->scale = _joe.scale;
pbs->xflip = (_joe.facing == DIR_LEFT); pbs->xflip = (_joe.facing == DIR_LEFT);
_graphics->update(); update();
_joe.prevFacing = _joe.facing; _joe.prevFacing = _joe.facing;
switch (frame) { switch (frame) {
case 33: frame = 1; break; case 33: frame = 1; break;
@ -1755,12 +1757,12 @@ void Logic::joeGrabDirection(StateGrab grab, uint16 speed) {
_graphics->bankUnpack(5, 29 + FRAMES_JOE_XTRA, 7); _graphics->bankUnpack(5, 29 + FRAMES_JOE_XTRA, 7);
bobJoe->xflip = (_joe.facing == DIR_LEFT); bobJoe->xflip = (_joe.facing == DIR_LEFT);
bobJoe->scale = _joe.scale; bobJoe->scale = _joe.scale;
_graphics->update(); update();
// grab up // grab up
_graphics->bankUnpack(7, 29 + FRAMES_JOE_XTRA, 7); _graphics->bankUnpack(7, 29 + FRAMES_JOE_XTRA, 7);
bobJoe->xflip = (_joe.facing == DIR_LEFT); bobJoe->xflip = (_joe.facing == DIR_LEFT);
bobJoe->scale = _joe.scale; bobJoe->scale = _joe.scale;
_graphics->update(); update();
// turn back // turn back
if (speed == 0) { if (speed == 0) {
frame = 7; frame = 7;
@ -1775,12 +1777,12 @@ void Logic::joeGrabDirection(StateGrab grab, uint16 speed) {
_graphics->bankUnpack(frame, 29 + FRAMES_JOE_XTRA, 7); _graphics->bankUnpack(frame, 29 + FRAMES_JOE_XTRA, 7);
bobJoe->xflip = (_joe.facing == DIR_LEFT); bobJoe->xflip = (_joe.facing == DIR_LEFT);
bobJoe->scale = _joe.scale; bobJoe->scale = _joe.scale;
_graphics->update(); update();
// extra delay for grab down // extra delay for grab down
if (grab == STATE_GRAB_DOWN) { if (grab == STATE_GRAB_DOWN) {
_graphics->update(); update();
_graphics->update(); update();
} }
if (speed > 0) { if (speed > 0) {
@ -1838,9 +1840,17 @@ void Logic::joeUseUnderwear() {
void Logic::playCutaway(const char* cutFile) { void Logic::playCutaway(const char* cutFile) {
char next[20]; 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 } // End of namespace Queen

View file

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

View file

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

View file

@ -28,6 +28,7 @@
#include "queen/cutaway.h" #include "queen/cutaway.h"
#include "queen/display.h" #include "queen/display.h"
#include "queen/graphics.h" #include "queen/graphics.h"
#include "queen/input.h"
#include "queen/queen.h" #include "queen/queen.h"
#include "queen/sound.h" #include "queen/sound.h"
#include "queen/talk.h" #include "queen/talk.h"
@ -85,13 +86,9 @@ REGISTER_PLUGIN("Flight of the Amazon Queen", Engine_QUEEN_gameList, Engine_QUEE
namespace Queen { namespace Queen {
QueenEngine *g_queen;
QueenEngine::QueenEngine(GameDetector *detector, OSystem *syst) QueenEngine::QueenEngine(GameDetector *detector, OSystem *syst)
: Engine(detector, syst) { : Engine(detector, syst) {
g_queen = this;
_game = detector->_game.id; _game = detector->_game.id;
if (!_mixer->bindToSystem(syst)) if (!_mixer->bindToSystem(syst))
@ -111,8 +108,10 @@ QueenEngine::QueenEngine(GameDetector *detector, OSystem *syst)
QueenEngine::~QueenEngine() { QueenEngine::~QueenEngine() {
delete _resource; delete _resource;
delete _display; delete _display;
delete _logic;
delete _graphics; delete _graphics;
delete _logic; delete _logic;
delete _input;
} }
void QueenEngine::errorString(const char *buf1, char *buf2) { void QueenEngine::errorString(const char *buf1, char *buf2) {
@ -132,35 +131,33 @@ void QueenEngine::roomChanged() {
// XXX fadeout(0,223); // XXX fadeout(0,223);
} }
else if (_logic->currentRoom() == 95 && _logic->gameState(VAR_INTRO_PLAYED) == 0) { 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); _logic->roomDisplay(_logic->roomName(_logic->currentRoom()), RDM_FADE_NOJOE, 100, 2, true);
if (_resource->isDemo()) { if (_resource->isDemo()) {
if (_resource->exists("pclogo.cut")) if (_resource->exists("pclogo.cut"))
Cutaway::run("pclogo.cut", nextFilename, _graphics, _logic, _resource, _sound); _logic->playCutaway("pclogo.cut");
else else
Cutaway::run("clogo.cut", nextFilename, _graphics, _logic, _resource, _sound); _logic->playCutaway("clogo.cut");
} }
else { else {
Cutaway::run("copy.cut", nextFilename, _graphics, _logic, _resource, _sound); _logic->playCutaway("copy.cut");
Cutaway::run("clogo.cut", nextFilename, _graphics, _logic, _resource, _sound); _logic->playCutaway("clogo.cut");
// TODO enable talking for talkie version // 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 // restore palette colors ranging from 144 to 256
_graphics->loadPanel(); _graphics->loadPanel();
Cutaway::run("cred.cut", nextFilename, _graphics, _logic, _resource, _sound); _logic->playCutaway("cred.cut");
} }
_logic->currentRoom(73); _logic->currentRoom(73);
_logic->entryObj(584); _logic->entryObj(584);
_logic->roomDisplay(_logic->roomName(_logic->currentRoom()), RDM_FADE_JOE, 100, 2, true); _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); _logic->gameState(VAR_INTRO_PLAYED, 1);
@ -188,7 +185,7 @@ void QueenEngine::go() {
// queen.c lines 4080-4104 // queen.c lines 4080-4104
if (_logic->newRoom() > 0) { if (_logic->newRoom() > 0) {
_graphics->textClear(151, 151); _graphics->textClear(151, 151);
_graphics->update(); _logic->update();
_logic->oldRoom(_logic->currentRoom()); _logic->oldRoom(_logic->currentRoom());
_logic->currentRoom(_logic->newRoom()); _logic->currentRoom(_logic->newRoom());
roomChanged(); roomChanged();
@ -211,18 +208,15 @@ void QueenEngine::go() {
break; // XXX don't loop yet break; // XXX don't loop yet
} }
while (1) { //main loop
delay(1000);
}
} }
void QueenEngine::initialise(void) { void QueenEngine::initialise(void) {
_resource = new Resource(_gameDataPath, _detector->_game.detectname); _resource = new Resource(_gameDataPath, _detector->_game.detectname);
_display = new Display(_system); _display = new Display(_system);
_graphics = new Graphics(_display, _resource); _input = new Input(_system);
_sound = Sound::giveSound(_mixer, _resource, _resource->compression()); _graphics = new Graphics(_display, _input, _resource);
_logic = new Logic(_resource, _graphics, _display, _sound); _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 _timer->installTimerProc(&timerHandler, 1000000 / 50, this); //call 50 times per second
} }
@ -238,73 +232,4 @@ void QueenEngine::gotTimerTick() {
_display->handleTimer(); _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 } // End of namespace Queen

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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