Commit Graph

556 Commits

Author SHA1 Message Date
Robert Špalek
7bec12bbec Fix 2 MIDI bugs
svn-id: r45392
2009-10-26 09:03:54 +00:00
Robert Špalek
74da9e5e3b Fix Escape in the intro, and switching map and the inventory
svn-id: r45389
2009-10-26 04:59:52 +00:00
Robert Špalek
819449d099 Implemented GPL2 commands for music.
Debugged everything.

svn-id: r45330
2009-10-22 07:34:43 +00:00
Robert Špalek
8f75ee9a37 Fix uninitialized channel volumes.
This fixed stopped music after calling the configuration dialog.

svn-id: r45327
2009-10-22 06:41:11 +00:00
Robert Špalek
3903be61e7 Improved music handling:
- reading the volume from the configuration
- error handling of non-existent MIDI files
- pausing/resuming music

unfortunately, sometimes music stops playing or slows down, and my log
messages have so far not helped me to identify why

svn-id: r45326
2009-10-22 06:21:39 +00:00
Robert Špalek
958bc7ba81 Avoid opening and closing BArchive files all the time
svn-id: r45325
2009-10-22 06:05:34 +00:00
Robert Špalek
8d8b4dc50a Enabled music.
Several TODO's added.

svn-id: r45298
2009-10-21 08:41:57 +00:00
Robert Špalek
b2bf21f0da Fix memory leaks when reading thumbnails
svn-id: r45142
2009-10-16 00:09:20 +00:00
Robert Špalek
dddce5d97b Don't crash without sound support.
svn-id: r45137
2009-10-15 23:57:13 +00:00
Robert Špalek
baec8c2421 Set all sound/subtitle-related parameters from ConfMan.
Made it intelligent so that when, for example, the dubbing file doesn't exist,
we don't fail, but instead always show subtitles even if the GUI settings
says dubbing only, etc.

svn-id: r45002
2009-10-13 05:38:45 +00:00
Robert Špalek
7c311057c1 Dubbing is played.
I haven't implemented switching dubbing and subtitles on/off according to
the config manager nor the speed of the subtitles, yet.

svn-id: r45001
2009-10-13 04:44:22 +00:00
Robert Špalek
e779284403 Sound effects are now correctly played.
Dubbing is not yet played.

svn-id: r45000
2009-10-12 22:27:23 +00:00
Robert Špalek
43437eecb8 Dragon looks into the requested direction.
Parsing _lookDir and _useDir, and passing it all the way around to walkHero().

Also, added playHeroAnimation() to reduce code duplication.

svn-id: r44965
2009-10-12 03:08:28 +00:00
Robert Špalek
1a4dcd3c82 Implemented GPL commands JustTalk and JustStay.
The basic commands are done.  It remains to implement handling music (after
we play it at all), fading palette, and controlling the quick-hero and
speed-text flags (after I find out what they do).

Now the dragon switches between talking and staying during dialogs.  However,
the left/right direction doesn't work yet, because we don't respect _lookDir
and _useDir yet.

svn-id: r44964
2009-10-12 01:16:13 +00:00
Robert Špalek
ca35af2697 Fixed funcActPhase()
svn-id: r44963
2009-10-12 00:39:49 +00:00
Robert Špalek
b99e69f4d9 Fix indexing of the dragon's animations.
After inspection, I assert that it isn't true that the _anim array needs to
be sorted.  In fact, sorting ruins the ordering of the dragon's animations,
which corresponds to enum Movement.

After fixing this, let the dragon have a rest instead of constantly walking
down.

svn-id: r44962
2009-10-12 00:32:51 +00:00
Robert Špalek
3ef5145b41 Reduced huge code duplication by introducing Game::stopObjectAnimations()
svn-id: r44961
2009-10-12 00:15:34 +00:00
Robert Špalek
6aaf99ec67 Disambiguated _anims.
It's both a pointer to an AnimationManager and list of animation ID's fo
each object.  The latter renamed to _anim so that I can easily search for
them.

Also, fixed the bug promised in the previous commit.

svn-id: r44960
2009-10-12 00:01:39 +00:00
Robert Špalek
6768065f14 Reduced code duplication and fixed one deletion bug.
svn-id: r44959
2009-10-11 23:54:44 +00:00
Robert Špalek
62cebbb51e Implemented a few more harmless GPL2 commands
svn-id: r44958
2009-10-11 23:28:40 +00:00
Robert Špalek
f71b32dd96 Loading and caching sound samples in memory.
The sounds are not played yet, but the infrastructure is getting ready.

svn-id: r44957
2009-10-11 23:01:59 +00:00
Robert Špalek
c4563616ae Added support for sound archives.
We initialize them in the DraciEngine constructor, but don't play any sounds
yet.  Checked that it works for all existing sound files (required several
work-arounds against unspoken specification).

When copying the interface from barchive.h, I decided to remove some const's
from there, because getFile() wasn't really behaving like const.

Removed some static Common::String instances.

svn-id: r44953
2009-10-11 22:30:40 +00:00
Max Horn
3399c3aeb6 Change doxygen inline comments from "//!" to "///" as proposed on -devel
svn-id: r44802
2009-10-08 21:28:57 +00:00
Max Horn
42120ed626 Introduce a new struct TimeDate, replacing struct tm in client code. May lead to compilation issues in ports, which should be trivial to fix, though
svn-id: r44793
2009-10-08 19:41:38 +00:00
Filippos Karapetis
136dbba9c4 Fixed warning (GameObject is a struct)
svn-id: r44648
2009-10-05 07:00:59 +00:00
Robert Špalek
cc39c5022a Work-around a bug in the original game files.
svn-id: r44645
2009-10-04 22:55:54 +00:00
Robert Špalek
eb56dfa965 Fixed two bugs concerning loading:
1. a room need to be reloaded by force when the loaded game is in the same
room as the game before the load
2. objects from the last room and their animations must be deallocated
before I change the room number

svn-id: r44638
2009-10-04 22:11:46 +00:00
Max Horn
f242266f6d Change a couple places from 'end of namespace' to 'End of namespace', for consistency
svn-id: r44634
2009-10-04 21:26:33 +00:00
Robert Špalek
c8f002ae43 Removed Ctrl-Left Click treating as a Right Click
svn-id: r44633
2009-10-04 20:08:11 +00:00
Robert Špalek
42ee5350c3 Hack Game::_shouldExitLoop.
Immediate exit needed when loading a savegame hurts waiting in an inner
(strange) loop inside a GPL program, because animations don't progress at
all.  Reverted to the previous behavior and kept the immediate exit as a
hack for loading the game.

svn-id: r44590
2009-10-04 09:33:07 +00:00
Robert Špalek
1ed6a2668b Load inventory items properly after loading the game.
This solution is quite hacky, but so is the rest of the code, before a
future refactoring done one day.

svn-id: r44588
2009-10-04 09:13:15 +00:00
Robert Špalek
df14027c41 Implemented rudimentary game loading/saving.
Fixed many bugs in the boilerplate.  Saving (only) things that really need to
be saved.  Loading seems to work modulo dialogs and (possibly) inventory.

svn-id: r44586
2009-10-04 05:44:23 +00:00
Robert Špalek
b6d7da6927 Implement all boilerplate concerning Global Main Menu.
All currently defined featues will be supported.  I have implemented 
everything boilerplatish, except for the actual game saving/loading (which
will come in the next commit), getting volumes from the configuration
(because we don't play sounds yet), and changing subtitles.

svn-id: r44583
2009-10-04 03:50:10 +00:00
Robert Špalek
3035ca2fd3 Let Ctrl-Left click behave like Right lick in Dragon History.
Also, started implementing Advanced Engine Features:
- pause support
- RTL support

svn-id: r44575
2009-10-03 22:07:18 +00:00
Robert Špalek
43f84746bf Fixed positioning and update of the title under the mouse pointer.
Clamping on the border of the screen works precisely.  When switched to the
inventory, titles of game items are displayed instead of a (sticky) title of
the last object before entering the inventory.  Put some const's where
appropriate.

svn-id: r44550
2009-10-03 05:16:19 +00:00
Robert Špalek
4a7cea6813 Fixed event handling. ValGrind fixups.
My yesterday's fix on handling 1 event per call caused the game to be
unbearably slow on Linux.  The old way was much faster.  I have solved too
fast a succession of mouse button down and up by not clearing the mouse flag
when the button goes up instead.

Fixed a memory leak and uninitialized variable after my refactoring of game
location changes; found by ValGrind.

svn-id: r44525
2009-10-01 16:47:34 +00:00
Robert Špalek
24d649b972 Clean up room changing code and support returning from the map.
Completely changed the interface, removing unused methods and attributes,
renaming other ones to reflect what they do, and moving some methods into the
private section.  Code changing the location, originally scattered over many
pieces of code, has been unified into one place.  Remember the previous room
when entering the map so that one can return there.

Also, the event handler processes one event at a time, preventing lost clicks
on touchpads.

svn-id: r44508
2009-10-01 08:32:35 +00:00
Robert Špalek
5ad13a3dff Fix 2 ValGrind warnings.
svn-id: r44499
2009-09-30 21:07:04 +00:00
Max Horn
8ba75fc522 Fix code formatting (esp. 'if(' -> 'if (' etc., but also indention and other things)
svn-id: r44495
2009-09-30 16:16:53 +00:00
Max Horn
cc54ad650d Remove trailing whitespaces
svn-id: r44493
2009-09-30 16:04:21 +00:00
Johannes Schickel
c9ca057ae2 - Adapt parts of the Draci code to match our code formatting guidelines
- Remove use of tabs for formatting, now in nearly all cases tabs are only used for indentation
- Use "uint" instead of "unsigned int" in the whole engine for consistency's sake
- Strip some trailing tabs and leading whitespaces

svn-id: r44478
2009-09-30 10:45:14 +00:00
Robert Špalek
76a0bcb6c4 Implemented the map room, entered when 'm' is pressed.
svn-id: r44474
2009-09-30 04:33:52 +00:00
Torbjörn Andersson
c857369131 Fixed Valgrind warnings about invalid memory access. Hopefully without breaking
anything, but modifying a data structure while traversing it can be a bit
tricky...

svn-id: r44469
2009-09-29 19:51:37 +00:00
Robert Špalek
4be9e6cda0 Rewrite from scratch drawReScaled() and cropping now works well.
I left draw() as is for now, although it could also be similarly simplified.
Also, one could easily completely get rid of columnIndices[], but I was too
tired for the time being.

svn-id: r44457
2009-09-29 06:36:39 +00:00
Robert Špalek
00a733f7cf Clean up and unify positioning dragon's animations
svn-id: r44456
2009-09-29 05:54:59 +00:00
Denis Kasak
635769bd5d draci:
* Added const to some methods of Game.
* Removed some code cruft from Game::walkHero() (duplicate calculations and variables).
* Fixed small bug which prevented talking text from being centered above the dragon.

svn-id: r44455
2009-09-29 00:03:09 +00:00
Denis Kasak
137c44013c draci: Inverted a logical check to make it more obvious.
svn-id: r44454
2009-09-28 23:32:16 +00:00
Denis Kasak
0c0135e0ed draci: Added methods Game::positionAnimAsHero(), Game::getHeroX() and Game::getHeroY() and implemented correct positioning of all dragon animations. Fixed exiting the inventory by right-clicking outside it.
svn-id: r44453
2009-09-28 23:10:08 +00:00
Denis Kasak
a8d6e8774c Made AnimationManager::sortAnimations() do multiple passes, if necessary, and added some animation debug info.
svn-id: r44452
2009-09-28 23:02:39 +00:00
Robert Špalek
ccc737a714 Fix a memory leak
svn-id: r44447
2009-09-28 11:28:09 +00:00
Robert Špalek
359d374dc6 Added const's to getPalette() and several uses of getObject()
svn-id: r44434
2009-09-28 04:09:03 +00:00
Robert Špalek
8a78e96838 Make getFile() return a const pointer and clean-up all uses of it.
svn-id: r44433
2009-09-28 03:51:23 +00:00
Robert Špalek
7ef17ba73e get rid of static Common::String's
svn-id: r44432
2009-09-28 03:06:43 +00:00
Robert Špalek
42e3c63b11 get rid of static Common::String's
svn-id: r44431
2009-09-28 02:54:38 +00:00
Robert Špalek
d0db596311 Fix rounding coordinates at the edge of the screen.
svn-id: r44430
2009-09-27 23:57:39 +00:00
Robert Špalek
a04881072a Reduce code duplication when cleaning animations
svn-id: r44422
2009-09-27 21:25:34 +00:00
Robert Špalek
caa3b6707e Improved the interface of Sprite and Animation concerning relative coordinates and scaling.
It is no longer needed to modify the underlying animations when drawing them
on the screen or testing pixels in them.  Read access is enough, because
the displacement of the object is passed as a parameter.

Added some more const's where they logically belong.

svn-id: r44419
2009-09-27 20:49:59 +00:00
Robert Špalek
cf1031fc63 Fix renumbering of animation indexes
svn-id: r44414
2009-09-27 18:51:07 +00:00
Robert Špalek
fc2bb50600 Remove memory leak in animation manager. Get rid of 1 non-const reference parameter.
svn-id: r44413
2009-09-27 18:11:06 +00:00
Denis Kasak
27a638fa82 draci: Fixed bug in Surface::centerOn{X,Y}() which made it return a negative coordinate for strings that are too long. Resolves the crash caused by the English data files containing strings which are improperly line-breaked. Ideally, the engine should do the line-breaking itself when the string does not fit.
svn-id: r44376
2009-09-26 13:47:32 +00:00
Robert Špalek
431780297e Added some more const's to the interface of Dragon History
svn-id: r44362
2009-09-25 17:33:00 +00:00
Filippos Karapetis
e296cef9be Created a macro for lround(), for non-C99 compilers, and used that in places where lround() is used
svn-id: r44337
2009-09-25 09:48:43 +00:00
Robert Špalek
f51c81f344 Add const's to many interfaces of engines/draci/
svn-id: r44331
2009-09-25 08:13:39 +00:00
Filippos Karapetis
a74a9c6c01 Silenced some warnings
svn-id: r44329
2009-09-25 07:06:55 +00:00
Filippos Karapetis
7106caca81 Replaced the C99 lround() with floor(), to get draci to compile under non-C99 compilers (e.g. VS)
svn-id: r44328
2009-09-25 07:05:26 +00:00
Robert Špalek
edd338b229 Make engines/draci/ compilable after merging from a branch
svn-id: r44327
2009-09-25 06:43:33 +00:00
Denis Kasak
be0cfa50f2 Removed public data variables of Game concerning dialogues and added getters/setters.
svn-id: r43492
2009-08-17 19:37:55 +00:00
Denis Kasak
85bf130a50 Enabled hotkey 'i' for accessing or exiting the inventory.
svn-id: r43488
2009-08-17 18:51:45 +00:00
Denis Kasak
b0fea939f4 Added inventory and item handling support (monster patch, sorry). Items were previously called "icons" as in the original player. This commit also renamed every such instance to the proper "item".
svn-id: r43487
2009-08-17 18:50:38 +00:00
Denis Kasak
e5774d2881 * Added pause support for animations.
* Added AnimationManager::addItem() for adding inventory items animations.

svn-id: r43486
2009-08-17 18:47:17 +00:00
Denis Kasak
680bed134b * Set the _x and _y position for the mouse only when an EVENT_MOUSEMOVE happens.
* Stop calling Mouse::setPosition() on EVENT_MOUSEMOVE since it's not needed (the engine warps the mouse automatically; I still left the method for situations when we want to warp the mouse explicitly).

svn-id: r43484
2009-08-17 18:23:05 +00:00
Denis Kasak
74d4392a78 Added struct GameItem.
svn-id: r43424
2009-08-16 04:21:17 +00:00
Denis Kasak
1c0df34b4d Removed _roomChange hack since it's no longer needed.
svn-id: r43392
2009-08-15 02:53:14 +00:00
Denis Kasak
abf10049bb * Implemented LoadPalette, SetPalette and BlackPalette GPL commands.
* Used a more natural condition (whether the scheduled room number is different from the current room number) instead of the _roomChange hack.

svn-id: r43391
2009-08-15 02:42:34 +00:00
Denis Kasak
fad77de234 Sped up the game during dialogues by not updating every drawn char separately but the whole string at once. Also removed the markDirty parameter from Font::drawChar() since it's not needed anymore.
svn-id: r43368
2009-08-14 16:12:17 +00:00
Denis Kasak
87e64d27f7 Fixed bug which made the dragon's spoken line in a dialogue end too quickly.
svn-id: r43365
2009-08-14 13:17:53 +00:00
Denis Kasak
3022c623d6 Stopped returning from Animation::nextFrame() early even if the animation has only one frame because such animations may need to have callbacks called too. Fixes intro freeze during mother's lecture.
svn-id: r43313
2009-08-12 07:37:08 +00:00
Denis Kasak
8ca10ac3b0 Fixed dialogues logic (some indexes were calculated erroneously +/- 1).
svn-id: r43312
2009-08-12 07:34:31 +00:00
Denis Kasak
c57515b5f8 Moved setting inactive dialogue option colour to an else branch.
svn-id: r43311
2009-08-12 05:38:15 +00:00
Denis Kasak
45e4f88e4e Removed unnecessary else branch in the part of the loop handling substatus Talk.
svn-id: r43310
2009-08-12 05:35:08 +00:00
Denis Kasak
e526983dbe Fixed erroneous comment mentioning gates in Game::runDialogueProg().
svn-id: r43309
2009-08-12 05:22:50 +00:00
Denis Kasak
534158af87 * When setting the first two game variables (room and gate), first convert them back to 1-based indexing so they play well with the rest of the scripts. This fixes a number of bugs, e.g. the dragon now appears automatically when the game starts and the question mark animation in the intro is played / stopped at an appropriate time.
* Removed hack from Script::start() which loaded animation 657 before playing it to stop a crash. The fix above seems to fix this bug as well.

svn-id: r43308
2009-08-12 05:20:25 +00:00
Denis Kasak
303085c66b Whenever we enter the top-level loop, disable exiting by default (fixes the high-five scene between Bert and Eveline which ended too fast).
svn-id: r43306
2009-08-12 04:22:47 +00:00
Denis Kasak
6693b22851 * Split loop status and substatus into two different enums since they are two separate concepts
* Fixed slight glitch where object titles (which normally disappear when objects are used/looked at) reappeared for a moment after the script has finished

svn-id: r43305
2009-08-12 04:18:45 +00:00
Denis Kasak
100603e683 Fixed Script::walkOnPlay() (was setting loop status whereas it was substatus that needed to be set).
svn-id: r43297
2009-08-12 01:03:54 +00:00
Denis Kasak
3b0895dd2f Added some debug info for loop statuses and dialogues.
svn-id: r43295
2009-08-12 00:56:44 +00:00
Denis Kasak
9093e179cc Added dialogue selection colouring.
svn-id: r43256
2009-08-11 04:53:30 +00:00
Denis Kasak
ee7b9271a2 Implemented GPL command WalkOnPlay.
svn-id: r43255
2009-08-11 04:18:14 +00:00
Denis Kasak
0daad90685 Fix intro crash because of bug in the data files.
svn-id: r43254
2009-08-11 04:14:38 +00:00
Denis Kasak
51cc821619 Added dialogue support.
svn-id: r43253
2009-08-11 04:03:22 +00:00
Denis Kasak
d59d03e52f Multiply itemID by two before using it as an index into the item image archive because every item has a highlighted and a non-highlighted version.
svn-id: r43185
2009-08-09 20:33:58 +00:00
Denis Kasak
b9a9a5ef88 Implemented GPL function Script::funcObjStat().
svn-id: r43176
2009-08-09 16:58:04 +00:00
Denis Kasak
abedc7e9bb Moved cursor state setting (when entering a new room) from Game::loadRoom() to Game::start() (just after running the gate program). This fixes a black cursor bug when the game starts (the cursor should not be even displayed then).
svn-id: r43162
2009-08-09 04:24:52 +00:00
Denis Kasak
f68ceeb88c * Implemented GPL functions Script::funcActIco() and Script::funcIsIcoAct().
* Implemented GPL commands Script::loadMap() and Script::roomMap().
* Added temporary HACK to change some speech texts to use the small font because some strings overflow the screen (as stored in the data files).

svn-id: r43161
2009-08-09 04:12:36 +00:00
Denis Kasak
eeb72e3d0d * Implemented Game::loadWalkingMap().
* Extracted title updating from the main loop to a new method, Game::updateTitle().
* Added Game::updateCursor().
* Restructured the main loop to fix many subtle bugs and enable some new functionality concerning object scripts (like support for room-global use scripts).
* Added support for tracking currently selected icons (items, probably should be renamed).
* Changed walkDir, lookDir and useDir members of GameObject to int and adjusted them for zero-based indexing.
* Added Game::getCurrentIcon().
* Return from WalkingMap::findNearestWalkable immediately if the starting point is walkable.

svn-id: r43160
2009-08-09 04:09:24 +00:00
Denis Kasak
e46abf1643 Added Text::setFont().
svn-id: r43159
2009-08-09 03:59:39 +00:00
Denis Kasak
295ab7e6ff Added Mouse::loadItemCursor(). Removed hotspot FIXME as all cursors seem to use the same hotspot (the center of the sprite).
svn-id: r43158
2009-08-09 03:58:03 +00:00
Denis Kasak
c193c80e67 * Test whether an object can be used by evaluating its canUse script (warning: this will break many things currently working until I implement IsIcoAct in my next few commits).
* Removed old HACK note because look / use scripts are now more properly implemented.

svn-id: r43130
2009-08-08 16:17:21 +00:00
Denis Kasak
18b5d7ce33 Implemented Script::testExpression().
svn-id: r43129
2009-08-08 15:55:19 +00:00
Denis Kasak
d2f7268171 Removed TODO concerning the nearest walkable point feature and reworded some obsolete documentation.
svn-id: r43128
2009-08-08 15:53:47 +00:00
Denis Kasak
19d5d66fd7 * Implemented WalkingMap::findNearestWalkable() which mimics a heuristic from the original game that attempts to find walkable spots near the given point
* Implemented moving to the right place when looking / using objects.

svn-id: r43125
2009-08-08 12:31:49 +00:00
Denis Kasak
fc6ff00cbc Implemented Surface::getRect().
svn-id: r43109
2009-08-08 03:17:18 +00:00
Denis Kasak
58c56e28b9 Fixed the 'ESC room' feature to work as intended.
svn-id: r43087
2009-08-06 07:42:14 +00:00
Denis Kasak
907a35c929 Added ability to end the currently executing GPL program before it finishes via Script::endCurrentProgram().
svn-id: r43086
2009-08-06 07:40:14 +00:00
Denis Kasak
3ce16763c7 Enabled skipping the current line of text if a mouse click occurs.
svn-id: r43085
2009-08-06 05:17:18 +00:00
Denis Kasak
5ea44b9b5e Moved walkHero() (in the main loop) to the appropriate place (in anticipation of a smart finding a walkable point) and disabled walking during script execution / inventory.
svn-id: r43084
2009-08-06 05:04:21 +00:00
Denis Kasak
09e49a354f Turn off mouse cursor and disable titles when running look / use scripts.
svn-id: r43083
2009-08-06 04:50:37 +00:00
Denis Kasak
c2dccaafcd Added method Mouse::isCursorOn().
svn-id: r43082
2009-08-06 04:48:43 +00:00
Denis Kasak
da8bad0ef5 Made the game behave properly and safe when clicking on objects multiple times during talking or executing look/use scripts. Previously, the loop could be called nested arbitrarily many times.
svn-id: r43081
2009-08-06 03:52:08 +00:00
Denis Kasak
e632106169 * Made some type changes to struct/class members in game.cpp (uint -> int and uint16 -> uint)
* Added enum constant kNoEscRoom for rooms that have no escape room defined
* Fixed crash when ESC is pressed in rooms which have no escape room defined
* Renamed kNotFound (used as a return value for Game::getObjectWithAnimation) to kObjectNotFound for clarity.

svn-id: r43072
2009-08-05 17:58:14 +00:00
Denis Kasak
1363a0680a * Implemented the "escape room" feature of the original engine which lets a user switch to another location (or skip the intro) by pressing ESC (the escRoom for every location is stored in the data files).
* Reworked the left and right arrow key commands so they don't call changeRoom() themselves but instead schedule the room change via Game::setRoomNum(). In this way, changing rooms like that is still a hack but a bit more "natural", since the loop doesn't get skipped, the gate scripts get run, etc.

svn-id: r43065
2009-08-05 02:42:23 +00:00
Denis Kasak
6546c2ed8e * Added kTitleColour = 255 enum constant used in the following item.
* Added proper colouring of the title animation fonts
* Added Game::getEscRoom().

svn-id: r43063
2009-08-05 02:35:51 +00:00
Denis Kasak
c9b24d2ff9 * Changed title text to use the small instead of the big font
* Handled title positioning
* Cleaned up the main loop a bit (comments, stylistic changes, shortened some lines, etc)
* Fixed setting the dragon's feet position (the x coordinate should be at the midpoint of the animation)

svn-id: r43059
2009-08-05 00:11:09 +00:00
Denis Kasak
88276e91d9 Fixed second call to Surface::centerOnX() (should have been centerOnY()).
svn-id: r43058
2009-08-05 00:05:36 +00:00
Denis Kasak
71dbb75031 * Added Font::getLineWidth()
* Changed Font::getStringWidth() and Font::getStringHeight() to return uint instead of int.
* Made the Font::drawString() overload which accepts a Common::String the "default" one. The overload accepting a (byte *) now calls that one (it was the other way around before).
* Added proper line centering to the Font::drawString() routine. 

svn-id: r43053
2009-08-04 19:23:59 +00:00
Denis Kasak
d3412ea3a4 Refactored Script::talk() to use the new centering methods.
svn-id: r43052
2009-08-04 19:09:41 +00:00
Denis Kasak
561d55ff4d Added Surface methods centerOnX() and centerOnY().
svn-id: r43051
2009-08-04 19:07:12 +00:00
Denis Kasak
41d7590835 * Reverted change that subtracts 1 from font colour indexes for various speaking characters; they are 0-based after all.
* Fixed font blitting algorithm to allow for both white fonts and transparency.

svn-id: r43044
2009-08-04 15:41:27 +00:00
Denis Kasak
5e2eefd4fe * Fixed bug which made characters talk with the wrong colour; the colour indexes are indexed from 1 in the data files so we need to subtract 1.
* Turned on font transparency again. 

svn-id: r43022
2009-08-03 01:48:15 +00:00
Denis Kasak
96744e42c7 Fixed bug in the math expression evaluator; when evaluating operators, operands were being popped from the stack in the wrong order.
svn-id: r43019
2009-08-03 01:06:13 +00:00
Denis Kasak
f9bdd09659 * Fixed bug when reading in persons data. I was reading in coordinates as bytes and font colour as int16; it should be the other way around.
* Handled the kStatusTalk loop substatus properly inside Game::loop().
* Made Game::walkHero() set the person coordinates for the dragon after it warps him to a new location
* Added Game::getPerson() method (used by Script::talk())
* Added Game::setSpeechTick() method (set by Script::talk() and used inside the loop to determine when to switch to new text).

svn-id: r42994
2009-08-02 05:21:21 +00:00
Denis Kasak
77033ca9a1 * Fixed bug in Font::getStringWidth() which made it miscalculate string widths (a temporary variable used for storing the width of the current line was not being reset).
* Temporarily disabled font transparency because the dragon's text is rendered hollow (transparency inside glyph bodies). 

svn-id: r42993
2009-08-02 05:16:36 +00:00
Denis Kasak
6bd1cfa1bd Implemented the Talk GPL command.
svn-id: r42992
2009-08-02 05:12:42 +00:00
Denis Kasak
e6df651c08 Changed some uint16s to uints (to blend more naturally with the rest of the engine).
svn-id: r42991
2009-08-02 05:11:15 +00:00
Denis Kasak
854c27ffac Calculate the character length of Text objects (without the '|' separators) when setting a new string. Implemented Text::getLength().
svn-id: r42990
2009-08-02 05:09:55 +00:00
Denis Kasak
2d1df86f69 Added the strings archive to DraciEngine.
svn-id: r42989
2009-08-02 03:16:44 +00:00
Denis Kasak
014c33718f Added a dedicated animation for speech text.
svn-id: r42988
2009-08-02 03:02:22 +00:00
Denis Kasak
e0e06fc9e0 * Made the engine set the appropriate loop status before running a gate program or entering the main loop
* Removed hack which ran programs for all gates when the room was changed

svn-id: r42977
2009-08-01 17:52:16 +00:00
Denis Kasak
5c6643f0f3 When changing rooms, set the first two game variables to the new room and gate number. Also, if the new room is the map room, set the appropriate coordinates for the dragon in the persons array.
svn-id: r42972
2009-08-01 03:26:39 +00:00
Denis Kasak
240871aa20 * Added support for loop substatus
* Set loop substatus to Ordinary when changing rooms

svn-id: r42971
2009-08-01 03:07:18 +00:00
Denis Kasak
52a1c5df91 Added archives for item descriptions and images.
svn-id: r42970
2009-08-01 02:49:40 +00:00
Denis Kasak
18a8b5b3af * Added Game::runGateProgram()
* Added a separate mechanism to Game to keep track both of the current room number and the next room/gate. Periodically, I check whether the new room differs from the old one and, if it does, I do the change. Doing it any other would is nearly impossible because of the way the original scripts were written.
* Added GPL command Script::newRoom(). Rooms can now be traversed by clicking on their exits. Also, the intro animation partly works. Some parts go by far too soon. I assume this is because the engine still lacks a dialogue GPL command.
* Fixed bug where the gates array of a room was not cleared between uses.
* Save old jump value when we enter Script::run() and restore it in the end (mimicking the original engine).
* Fixed small bug where the gate was supposed to be stored as the first in-game variable and not the room number.

svn-id: r42957
2009-07-31 04:32:33 +00:00
Denis Kasak
167b6da230 * Woops, Game::getRoomNum() was already implemented. Removed the superfluous implementation.
* Set the first two game variables to the gate and room number in Game::init()
* Fixed compilation

svn-id: r42916
2009-07-30 03:43:44 +00:00
Denis Kasak
181b155a2f * Added support for keeping track of gates (exits from rooms)
* Added getters and setters for current room and gate numbers

svn-id: r42915
2009-07-30 03:37:04 +00:00
Denis Kasak
7532845fee Fixed sanity check in Animation::setCurrentFrame().
svn-id: r42914
2009-07-30 02:16:58 +00:00
Denis Kasak
b124c8b122 * Added Animation::setCurrentFrame()
* Moved rewinding the animation to the beginning from Animation::nextFrame() to AnimationManager::stop() (fixes the owl animation)

svn-id: r42913
2009-07-30 01:12:07 +00:00
Denis Kasak
6ed99df75a Removed some garbage I accidentally pasted into a comment.
svn-id: r42909
2009-07-29 20:42:55 +00:00
Denis Kasak
ad752b268b * Removed some code I forgot to remove in Game::startPlay() (a call to AnimationManager::play())
* Fixed logic checking for object visibility in various GPL commands (I originally misinterpreted the original engine code).

svn-id: r42908
2009-07-29 20:41:53 +00:00
Denis Kasak
a2cc4a6479 Explicitly set the kDragonObject enum constant value for clarity.
svn-id: r42906
2009-07-29 20:35:41 +00:00
Denis Kasak
393cd99a62 * Implemented the StartPlay and Play GPL commands properly
* Changed Script::load() to use the new animation callbacks

svn-id: r42902
2009-07-29 19:41:30 +00:00
Denis Kasak
f42894c33c Added support for animation callbacks and implemented a few callbacks (doNothing, exitGameLoop, stopAnimation).
svn-id: r42901
2009-07-29 19:39:10 +00:00
Denis Kasak
07042e31bc * Made Game::loop() exit conditionally depending on whether the internal Game::_shouldExitLoop variable is set.
* Added mechanisms for signalling whether the main game loop should exit or not (Game::setExitLoop() and Game::shouldExitLoop())

svn-id: r42899
2009-07-29 19:38:02 +00:00
Denis Kasak
bc89ce23d3 Fixed text bugs related to the fact that some strings in the data files don't end with '|' like they should.
svn-id: r42897
2009-07-29 16:39:12 +00:00
Denis Kasak
e9669b8e2b * Moved event handling to DraciEngine::handleEvents()
* Added Game::start() method which is called from DraciEngine::go()
* Made Game::loop() suitable for calling from other places (like GPL scripts) by handling events, redrawing the screen, etc from inside. This way it doesn't freeze the game if it doesn't return immediately.
* Added Game::shouldQuit() and Game::setQuit() which can be used to signal the engine to quit.
* Fixed race condition related to mouse buttons not getting released.
* Instead of deleting frames for the title animation and adding a new one, reset the text for its frame.

svn-id: r42875
2009-07-29 01:11:53 +00:00
Denis Kasak
dd9303d27e * Implemented GPL function ActPhase (as Script::funcActPhase())
* Trivial implementation of the Play GPL command
* Fixed Script::load() to load animation IDs to objects in increasing order (needed by funcActPhase())

svn-id: r42874
2009-07-29 01:02:50 +00:00
Denis Kasak
33af83c650 * Added method Animation::currentFrameNum()
* Renamed Animation::getFramesNum() to Animation::getFrameCount() for clarity.

svn-id: r42873
2009-07-29 00:46:36 +00:00
Denis Kasak
5a44af4433 Enabled running of look/use scripts on left/right mouse button press for testing (Warning: unstable in some places).
svn-id: r42841
2009-07-27 05:34:22 +00:00
Denis Kasak
21a22f7f77 Added methods to Mouse for setting the state of the button.
svn-id: r42840
2009-07-27 05:30:58 +00:00
Denis Kasak
019b7f310b * Added Game::getObjectWithAnimation() which finds the object that owns an animation with a certain ID
* Made GameObjects track their titles as Strings rather than byte *
* Made the engine display the title of the object under the cursor (added a special animation ID for that, kTitleText)

svn-id: r42839
2009-07-27 04:51:34 +00:00
Denis Kasak
0098084969 Fixed one more bug related to animations having no frames.
svn-id: r42838
2009-07-27 04:47:38 +00:00
Denis Kasak
aa6efa33f1 Fixed segfault when the screen is deleted before animations (the Animation destructor still needs to use the screen).
svn-id: r42837
2009-07-27 04:20:27 +00:00
Denis Kasak
673bae4443 * Added AnimationManager::addText() for adding text animations
* Added AnimationManager::getTopAnimationID(x, y) which returns the ID of the top layer animation located on a point
* Added Animation::getScale{X,Y}()
* Fixed a few bugs related to animations sometimes having no frames

svn-id: r42836
2009-07-27 04:18:44 +00:00
Denis Kasak
fa59e4b16b * Added Sprite::getPixel() (takes into account whether a sprite is mirrored or scaled)
* Made the Text class internally store a Common::String instead of a byte *

svn-id: r42835
2009-07-27 04:14:59 +00:00
Denis Kasak
ddf8f1cbb5 * Removed unused variable
* Fixed unsigned to signed comparison warning

svn-id: r42834
2009-07-27 03:57:43 +00:00
Denis Kasak
b14828c4ce * Added Font::getStringHeight()
* Made Font::getStringWidth() calculate the width of the string properly now that handling of multi-row strings is in
* Fixed bug which caused the last column of pixels in the last letter of a string to linger on the screen

svn-id: r42832
2009-07-27 03:08:19 +00:00
Denis Kasak
2525ec46de * Removed friend declarations in Drawable for Sprite and Text, and made Drawable's private members protected so they can access them
* Added Text::drawScaled() and altered Text::getRect() so Text instances can be accessed through a Drawable pointer. Scaling text is planned for later because it's not essential.

svn-id: r42789
2009-07-26 00:04:12 +00:00
Denis Kasak
3f571c7eae Handled the '|' char correctly when drawing text (it serves as both a newline and end-of-string marker).
svn-id: r42788
2009-07-25 23:43:21 +00:00
Denis Kasak
20a744bdd2 Simplified rectangle height and width calculation in Sprite::drawScaled() (use methods of Common::Rect instead of doing it manually).
svn-id: r42779
2009-07-25 18:33:20 +00:00
Denis Kasak
6970e178dc Replaced magic constant with enum kWalkingMapOverlay.
svn-id: r42778
2009-07-25 18:29:43 +00:00
Denis Kasak
20baaf93f5 * Moved walking code to Game::walkHero().
* Implemented WalkOn GPL command.
* Temporarily remaped StayOn and WalkOnPlay to WalkOn (for testing).

svn-id: r42735
2009-07-25 04:36:43 +00:00
Denis Kasak
22c372137f Added Movement enum that enumerates the animations for the dragon's movement.
svn-id: r42734
2009-07-25 04:23:59 +00:00
Denis Kasak
ceb9f18132 Made Script::run() manually mark the last animation index before it executes a program. This is done to prevent Release wreaking havoc if it is unpaired (i.e. if the script forgot to call a Mark first).
svn-id: r42733
2009-07-25 03:41:28 +00:00
Denis Kasak
ed59a12d53 Implemented ExecUse, ExecLook and ExecInit GPL commands.
svn-id: r42732
2009-07-25 03:37:22 +00:00
Denis Kasak
d28658984d * Added DraciEngine::_initArchive and made Game use it. Fixes a memory bug because Game uses pointers from the init archive which should outlive it (but didn't previously).
* Added support for setting loop status to Game.
* Made some GPL commands check whether we are in the correct loop status before executing.

svn-id: r42731
2009-07-25 03:28:04 +00:00
Denis Kasak
b7e97efb7f * Added handlers for the ObjStat and ObjStat_On GPL commands
* Removed temporary hack I accidentally committed

svn-id: r42730
2009-07-25 02:23:00 +00:00
Denis Kasak
5faceb595f Temporary mapped GPL command StartPlay to handler for Start and reenabled gates' scripts (for added effects and testing).
svn-id: r42684
2009-07-24 05:07:27 +00:00
Denis Kasak
c1ad0c3926 * Added tracking and deleting animations by index (which represents the order in which they were loaded). This is needed by some GPL commands.
* Added Game::getNumObjects() which returns the number of objects in the game
* Fixed segfault (accessing a null Animation *)
* Added some docs to various things

svn-id: r42683
2009-07-24 05:00:53 +00:00
Denis Kasak
a2bca06b3f Added support for per-animation scaling (via scaling factors). I have decided to go for a mixed approach (where Animation has a global scaling factor for the whole animation which is separate from Drawable's scaled width and height) so the animation can be scaled more naturally when the scale often changes (like with perspective when the dragon is walking). Previously, one had to alter the sizes of each frame of the dragon's animation whenever the dragon moved which was unclean.
svn-id: r42680
2009-07-24 01:54:13 +00:00
Denis Kasak
1726cc8d24 * Disabled unconditional execution of gates' scripts
* Fixed bug in Animation::nextFrame() which caused non-looping animations to linger on forever
* Stopped setting looping to false explicitly in AnimationManager::addAnimation() since the Animation constructor already does that

svn-id: r42657
2009-07-22 11:30:57 +00:00
Eugene Sandulenko
1c86a986d9 Fix warnings
svn-id: r42653
2009-07-22 07:22:12 +00:00
Denis Kasak
ef37d0a9b0 * Stopped AnimationManager::drawScene() from marking its own dirtiness.
* Instead, Animation::nextFrame() marks both the old and the new frame dirty. This makes it possible to only update the real screen when the animation changes and results in a pretty big speedup.
* Added utility method Animation::markDirtyRect() which takes a (Surface *) and marks a dirty rect on it for the current frame.
* Fixed artifacts when moving the dragon.

svn-id: r42652
2009-07-22 07:18:00 +00:00
Denis Kasak
5a77f089e1 Check whether the walking map overlay is already in the desired state so we don't start/stop it over and over.
svn-id: r42651
2009-07-22 05:03:34 +00:00
Denis Kasak
42e8e1e126 If a frame has scaled dimensions set to 0, the engine now does no scaling instead of scaling it to nothing. Fixes the disappearing chair bug.
svn-id: r42650
2009-07-22 05:00:11 +00:00
Denis Kasak
9b32771017 Fixed scaled mirrored sprite drawing. This change enables the NoSense logo animation to be played correctly.
svn-id: r42649
2009-07-22 04:50:11 +00:00
Denis Kasak
348cbc2b19 * Removed some unnecessary virtual qualifiers from methods in Drawable, Sprite and Text.
* Changed some Drawable members from uint16 to uint.
* Added some const qualifiers to methods of Drawable.

svn-id: r42648
2009-07-22 04:47:01 +00:00
Denis Kasak
b3a2d186bb * Moved scaling support from Animation to Sprite
* Now each Sprite (and hence frame in an animation) can have a separate zoom (which is needed for some animations in the game)
* Scale factors are not stored any more; instead, we only store scaled dimensions (since these are stored in the data files) and calculate the factors from those.

svn-id: r42647
2009-07-22 04:42:33 +00:00
Denis Kasak
6097828f54 Made 'show walking map overlay' setting persist when changing rooms.
svn-id: r42628
2009-07-20 17:34:19 +00:00
Denis Kasak
a2a71cb8fb * Added scaling support
* Made the dragon scale when it is in different parts of the room
* Added getters for relative coordinates (Animation::getRelativeX() and Animation::getRelativeY())
* Commented Game::loop() and Sprite::draw*() methods in more detail

svn-id: r42627
2009-07-20 17:25:57 +00:00
Denis Kasak
18301b6f78 * Used ldexp() in real_to_double() instead of doing the calculation manually
* Moved static declaration of real_to_double() to game.cpp

svn-id: r42616
2009-07-19 14:54:16 +00:00
Denis Kasak
1ec375bbd5 Added capability for reading in Pascal 6-byte floats and made Game::loadRoom() read in pers0 and persStep correctly.
svn-id: r42612
2009-07-19 13:28:05 +00:00
Denis Kasak
cb185f18cd Fixed bug which caused the dragon to be animated with the wrong Z coordinate for short periods of time when moved to a new location.
svn-id: r42586
2009-07-18 12:08:18 +00:00
Denis Kasak
a44cda5525 Fixed bug which caused animations to sometimes be played too fast if the engine was busier than usual (like when redrawing the whole screen when returning from minimized state).
svn-id: r42585
2009-07-18 05:21:01 +00:00
Denis Kasak
128fe6ea21 Made the engine handle the Z coordinate for the hero properly.
svn-id: r42584
2009-07-18 03:20:26 +00:00
Denis Kasak
10e9a780ce Made the engine stop the dragon animation when the room changes.
svn-id: r42583
2009-07-18 03:12:12 +00:00
Denis Kasak
18fda1b2f3 Fixed a bug where the cursor was not shown when the first room is loaded and has mouse enabled.
svn-id: r42582
2009-07-18 03:05:20 +00:00
Denis Kasak
94417e7743 * Added support for "walking" with the hero (i.e. moving the sprite to locations allowed by the walking map)
* Enabled drawing the walking map with the 'w' hotkey for testing

svn-id: r42581
2009-07-18 03:00:12 +00:00
Denis Kasak
3cde84fec4 Fixed bug where certain animations were played very fast when not played immediately when they are created.
svn-id: r42580
2009-07-18 02:58:11 +00:00
Denis Kasak
adf9e91e1f * Added Animation::getFrame()
* Added support for sorting animations when Z is changed later on (AnimationManager::sortAnimations())
* Added support for relative coordinates (Animation::setRelative())
* Fixed bug where AnimationManager::deleteOverlays() deleted all animations

svn-id: r42579
2009-07-18 02:53:37 +00:00
Denis Kasak
8e1f296308 Removed room switching hack from Mouse and re-added it to DraciEngine::go() (right arrow switches to the next room, left to the previous.
svn-id: r42577
2009-07-18 01:11:45 +00:00
Denis Kasak
aa82c39857 * Made Game::changeRoom() clear some more archives
* Modified the engine to leverage BArchive's memory management capabilities by using its pointers to data directly instead of copying
* Removed GameObject destructor (not needed because of the above change)
* Changed some more data members from uint16 to uint

svn-id: r42555
2009-07-17 01:20:51 +00:00
Denis Kasak
16530846ac * Renamed BAFile::closeFile() to close()
* Fixed leak in BArchive::loadFileDFW()

svn-id: r42554
2009-07-17 01:05:13 +00:00
Denis Kasak
8018216dea * Renamed Room::_numMasks to _numOverlays for consistency.
* Fixed unsigned to signed comparison.

svn-id: r42549
2009-07-17 00:27:21 +00:00
Denis Kasak
cfa4d5eba0 Added sanity checks for all archives (whether opening succeeded).
svn-id: r42547
2009-07-17 00:24:56 +00:00
Denis Kasak
e419110569 * Added Game::loop()
* Added WalkingMap::isWalkable()
* Renamed remaining _priority identifiers to _z which were left by mistake in the previous commit

svn-id: r42546
2009-07-17 00:20:57 +00:00
Denis Kasak
c420a4fba1 Renamed GameObject::_priority to _z.
svn-id: r42542
2009-07-16 18:39:39 +00:00
Denis Kasak
652acfc4ca * Added WalkingMaps class
* Added DraciEngine::walkingMapsArchive
* Made Game::loadRoom() read in the current walking map

svn-id: r42541
2009-07-16 18:31:15 +00:00
Denis Kasak
e031709989 Added _iconsArchive to DraciEngine and modified the Mouse class to use it.
svn-id: r42535
2009-07-16 16:06:29 +00:00
Denis Kasak
3d36ad3e67 Fixed loading the location's walking map index (needed to subtract 1).
svn-id: r42534
2009-07-16 15:00:46 +00:00
Denis Kasak
1bf574aaa9 Added proper cursor state handling (when in rooms that don't use the mouse). Added a HACK note for running the gates' scripts.
svn-id: r42532
2009-07-16 12:07:41 +00:00
Denis Kasak
ffffc1bea4 * Changed Game members _numMasks, _init, _look, _use and _canUse from uint16 to int
* Modified Game::loadRoom to load gates and execute their scripts
* The first room loaded is now Game::_info._startRoom instead of 0
* Fixed reading of _pers0 and _persStep from the data files (they are 6 instead of 12 bytes)
* Added more debug info to Script and Game

svn-id: r42515
2009-07-15 19:06:24 +00:00
Denis Kasak
a4a3ad123c Renamed Font::setFont() to loadFont(). Removed DraciEngine::_font and added _smallFont and _bigFont so each font can be handled separately.
svn-id: r42514
2009-07-15 18:16:54 +00:00
Denis Kasak
4ef46f4bb0 Adjusted levels for some Game debug messages and added some new ones.
svn-id: r42489
2009-07-14 19:13:49 +00:00
Denis Kasak
6d51a3ead4 * Fixed bug in Animation which made the first frame of an animation being drawn after it's stopped
* Fixed debugging info when starting and stopping animations

svn-id: r42485
2009-07-14 18:11:33 +00:00
Denis Kasak
d5e1611846 Renamed GameInfo::_currentRoom to _startRoom to better reflect its purpose.
svn-id: r42465
2009-07-14 00:51:35 +00:00
Denis Kasak
25b884512d Made Game allocate its _info member statically instead of dinamically.
svn-id: r42464
2009-07-14 00:41:17 +00:00
Denis Kasak
04e4bfdbbe * Implemented the following GPL functions: IsIcoOn, IcoStat, IsObjOn, IsObjOff, IsObjAway
* Changed GameObject::_location to an int since we sometimes use location -1.
* Some more uint <-> int changes to prevent comparisons between signed and unsigned.

svn-id: r42452
2009-07-13 19:53:53 +00:00
Denis Kasak
f8c20b9e9c Renamed Game::_itemStatus to _iconStatus. Added an assert to check if the number of icons is correct.
svn-id: r42449
2009-07-13 19:24:22 +00:00
Denis Kasak
f655999c15 Fixed bug in the NoScene logo room; the screen surface is now cleared between scene redraws (filled with the colour 0) to fix artifacts when animating the logo.
svn-id: r42448
2009-07-13 19:11:24 +00:00
Denis Kasak
224d8c087a Added Surface::fill() method and made Screen::fillScreen() use that instead of filling the surface manually. Changed Surface to use uint instead of uint8 throughout.
svn-id: r42447
2009-07-13 19:08:04 +00:00
Denis Kasak
77a810c0c9 Moved the delay mechanism from Animation to Drawable since each frame in an animation can have a different delay.
svn-id: r42427
2009-07-12 19:32:01 +00:00
Denis Kasak
eef64cc737 Enabled some more rooms in the demo and disabled loading the former distributor logo.
svn-id: r42426
2009-07-12 19:02:08 +00:00
Denis Kasak
d369a257d1 Enabled clearing the screen when the room changes since some rooms do not draw anything on some parts of the screen.
svn-id: r42425
2009-07-12 19:00:24 +00:00
Denis Kasak
a41d36de0f Fixed bug in the GPL math evaluator (GPL function results were not pushed onto the evaluation stack).
svn-id: r42424
2009-07-12 18:55:44 +00:00
Denis Kasak
6b2991f488 Made Script::run() seek in SEEK_CUR mode when jumping instead of the default SEEK_SET. It also now checks whether there is a non-zero jump value set before doing the jump.
svn-id: r42254
2009-07-08 06:14:17 +00:00
Denis Kasak
0ec737db69 Stopped doing a screen update immediately after changing the palette. This caused a noisy effect when changing rooms because the palette was changed before the new scene was loaded.
svn-id: r42251
2009-07-08 00:48:03 +00:00
Denis Kasak
32d692aea6 Made the engine clear some more caches when it changes rooms (room, sprites and palette caches). Made the DraciEngine destructor delete the rooms, overlays and animations archives.
svn-id: r42250
2009-07-08 00:40:22 +00:00
Denis Kasak
d8c33f6836 * Implemented GPL jumps
* Implemented c_If, c_Goto and c_Let opcodes
* Changed the interpreter to work with signed ints instead of uints (the interpreter uses negative values sometimes)
* Fixed documentation of Script::run() which said it is a disassembler (forgot to change it earlier)

svn-id: r42249
2009-07-08 00:34:53 +00:00
Denis Kasak
68ec1350c0 Fixed two mismatched (de)allocations in BArchive and BAFile.
svn-id: r42247
2009-07-07 21:46:34 +00:00
Denis Kasak
dd955bb08e * Made Game::_variables private and, instead, added Game::{get,set}Variable() methods.
* Removed obsolete comment about the cyclic field not being used in Game::loadAnimation()

svn-id: r42246
2009-07-07 21:30:36 +00:00
Denis Kasak
bab9293f97 Implementend F_Not GPL function.
svn-id: r42245
2009-07-07 21:24:39 +00:00
Denis Kasak
586af0ab42 * From Game::GameObject removed the following _idxSeq, _numSeq, _animObj, _seqTab (not used anymore), added Common::Array<int> _anims.
* Handled cylic animations properly
* Handled the Z coordinate properly

svn-id: r42244
2009-07-07 21:18:28 +00:00
Denis Kasak
9246e9cf4a * Added some more animation debug info
* Reordered Animation::nextFrame() a bit to make sure the timings are correct (particularly the last frame)
* Added checks to AnimationManager::play() and AnimationManager::stop() so it doesn't dereference a null pointer.

svn-id: r42243
2009-07-07 21:11:36 +00:00
Denis Kasak
b6b1402368 * Changed Game::_variables to public since the GPL interpreter needs to use it and made it int instead of uint16
* Implemented variable accessing by the math evaluator
* Fixed bug from previous commit (should have used && when checking for ending instructions, not ||)

svn-id: r42242
2009-07-07 20:57:14 +00:00
Denis Kasak
318d406242 Made GPL interpreter exit on both gplend and exit instructions.
svn-id: r42241
2009-07-07 20:46:26 +00:00
Denis Kasak
d37d49e50c Removed testing hack from Game::init() that displayed the dragon in the upper left corner. Replaced some more instances of magic numbers with kDragonObject. Made Game::init() a bit more readable.
svn-id: r42237
2009-07-07 19:53:40 +00:00
Denis Kasak
fd2ab9e3c0 Added enum constant for the dragon object (kDragonObject) and made Script::start() a bit more readable.
svn-id: r42236
2009-07-07 19:50:12 +00:00
Denis Kasak
c258eefc82 Made AnimationManager::getAnimation() return NULL when an animation is not found instead of Common::List<>::end().
svn-id: r42228
2009-07-07 15:39:18 +00:00
Denis Kasak
d519626c55 Added const keyword to "transparent" local variable in Sprite::draw() and removed leading underscore.
svn-id: r42227
2009-07-07 15:37:50 +00:00
Denis Kasak
4cfdf8c855 Shortened AnimationManager::{play,stop}(). Removed some excessive newlines.
svn-id: r42226
2009-07-07 15:35:35 +00:00
Denis Kasak
2e552bf643 Stopped running the room init scripts twice.
svn-id: r42225
2009-07-07 15:31:13 +00:00
Denis Kasak
7f3af129f2 mplemented changing rooms properly (overlays and objects' animations are deleted before a new room is loaded) and set up a quick demonstration (left click advances to the next room, right click goes back).
svn-id: r42224
2009-07-07 15:21:41 +00:00
Denis Kasak
82e6bcea2f * Added AnimationManager::deleteOverlays().
* Fixed bug in AnimationManager::deleteAnimation() that could result in accessing the Common::List::end() sentinel value.

svn-id: r42223
2009-07-07 14:52:36 +00:00
Denis Kasak
79c42abf08 * Fixed extracting visibility and location of object from its status byte
* Added Game::getRoomNum() which returns the current room number
* Made Game::loadRoom() execute the room's startup script, load the room's objects and run their init scripts as well

svn-id: r42194
2009-07-06 19:50:59 +00:00
Denis Kasak
3b75b8003d Removed two variables that were committed by mistake.
svn-id: r42193
2009-07-06 19:43:21 +00:00
Denis Kasak
61fa4d27d5 Cache the transparent colour instead of calling a function for every pixel.
svn-id: r42192
2009-07-06 19:41:13 +00:00
Denis Kasak
b2c24dd640 Implemented Script::funcRandom (GPL function).
svn-id: r42191
2009-07-06 19:26:53 +00:00
Denis Kasak
218a15d890 Made _rnd member of DraciEngine public.
svn-id: r42190
2009-07-06 19:22:13 +00:00
Denis Kasak
edaaca97f9 Set up GPL functions properly (the math evaluator now calls the handler if its implemented).
svn-id: r42188
2009-07-06 18:49:51 +00:00
Denis Kasak
237707dd6e Fixed bug where the GPL interpreter left parameters from previous commands on the stack.
svn-id: r42185
2009-07-06 17:29:44 +00:00
Denis Kasak
4e15262e74 Implemented Script::play() GPL opcode.
svn-id: r42184
2009-07-06 17:27:12 +00:00
Denis Kasak
f4ba64d2e4 Implemented GPL operators.
svn-id: r42183
2009-07-06 17:25:34 +00:00
Denis Kasak
8e341ee968 Renaming Animation -> AnimationManager and AnimObj -> Animation in light of the new API change.
svn-id: r42133
2009-07-05 11:52:17 +00:00
Denis Kasak
6c3e9f5151 * API change for Animation and AnimObj; AnimObj is now a proper class and each instance handles its own animation. Animation handles adding, fetching and deleting of AnimObjs (probably needs a namechange).
* Implemented actual animation (previously only the first frame was display)
* Implemented animation starting, stoping, looping
* Loaded looping dragon animation as a test

svn-id: r42114
2009-07-05 03:24:46 +00:00
Denis Kasak
960740fe83 Rewrote Sprite::draw() to draw overflowing sprites correctly. Stopped playing animations as soon as they're loaded from Game::loadAnimation().
svn-id: r42111
2009-07-04 23:05:13 +00:00
Denis Kasak
fdf9eb84d6 Implemented handler for the Load instruction. Removed Script::dummy().
svn-id: r42102
2009-07-04 18:36:45 +00:00
Denis Kasak
b96b434446 * Added Game::init() and moved some functionality from Game::Game to it (loading objects, changing rooms)
* Made Game::load*(), Game::getObject() and Game::changeRoom() methods public
* Stopped specifying Z coordinate when creating some Sprites (which I forgot in my previous commit)

svn-id: r42101
2009-07-04 18:35:08 +00:00
Denis Kasak
a06509f3c2 * Removed tracking of Z coordinates in Drawable since it's not used
* Made columnwise parameter mandatory
* Made Sprite coordinates signed (the engine sometimes uses negative coordinates)
* Prevented overflow when drawing sprites in some cases

svn-id: r42100
2009-07-04 18:29:01 +00:00
Denis Kasak
0888e8a6da * Split code from Game::changeRoom() into Game::loadRoom() and game::loadOverlays(). Game::changeRoom() now calls them instead.
* Added Game::loadAnimation()
* The engine now stores "real" indexes (zero-based) instead of Pascal's because the previous approach was messy. 

svn-id: r42092
2009-07-04 15:21:12 +00:00
Denis Kasak
b1d6377aa1 Added _animationsArchive member to DraciEngine.
svn-id: r42091
2009-07-04 14:54:22 +00:00
Denis Kasak
885ce59ce8 Restructured Script so I can start adding callbacks to GPL commands (added DraciEngine * member to Script, added Script::setupCommandList() which initialises the command list array, added Script::dummy() callback for the Load command for testing).
svn-id: r42090
2009-07-04 14:48:36 +00:00