diff options
author | Vicent Marti | 2008-08-16 00:08:12 +0000 |
---|---|---|
committer | Vicent Marti | 2008-08-16 00:08:12 +0000 |
commit | 146be8e16b0abd43f87274a305d9d65b594d1d7f (patch) | |
tree | 8c019cf6c35345de29946d681102cd036876b425 /engines/cine | |
parent | 2ae7dc0e32342a0b770bc67883f9b5b77967cb71 (diff) | |
parent | f2111eeb45dc8c41afb3e63bf3b86a09bf9a3532 (diff) | |
download | scummvm-rg350-146be8e16b0abd43f87274a305d9d65b594d1d7f.tar.gz scummvm-rg350-146be8e16b0abd43f87274a305d9d65b594d1d7f.tar.bz2 scummvm-rg350-146be8e16b0abd43f87274a305d9d65b594d1d7f.zip |
Merged revisions 33490,33492,33495-33496,33509-33512,33518-33519,33522-33527,33529-33530,33537,33541,33544,33546,33550,33552-33554,33556,33558,33561-33562,33565,33568,33570,33574,33576,33578-33581,33584-33587,33590,33596,33604-33611,33614-33615,33617-33618,33620-33621,33623,33626-33627,33632-33633,33635,33637,33639-33640,33642-33645,33648,33654-33655,33664,33667-33670,33673-33674,33678,33682,33686-33691,33693,33696,33698,33700,33703,33708,33710,33712-33714,33716,33719,33721-33723,33725-33727,33729-33730,33733,33736,33742,33754,33756,33758,33761,33763,33766,33777,33781-33788,33790,33792-33793,33795,33797,33805,33807-33812,33815-33817,33819,33822,33826,33829,33837,33839,33844,33847,33858-33861,33864,33871-33873,33875,33877-33879,33886,33889-33892,33894,33896,33900,33902-33903,33919 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk
........
r33490 | thebluegr | 2008-08-01 16:03:20 +0200 (Fri, 01 Aug 2008) | 2 lines
Added load confirmation dialog for IHNM, like in the original.
Fixes bug #1971699 - "IHNM: No Load Game Confirmation"
........
r33492 | thebluegr | 2008-08-01 16:27:40 +0200 (Fri, 01 Aug 2008) | 1 line
Fixed crash on exit from commit #32742 - the memory leak was only in IHNM, not ITE (in ITE, the 4 sprite lists are actually one)
........
r33495 | fingolfin | 2008-08-01 18:31:40 +0200 (Fri, 01 Aug 2008) | 1 line
Print a warning if unsupported XMIDI controllers are used
........
r33496 | fingolfin | 2008-08-01 18:33:22 +0200 (Fri, 01 Aug 2008) | 1 line
Moved Ludde & yaz0r to a new credits section, retired project leaders
........
r33509 | peres001 | 2008-08-02 04:24:36 +0200 (Sat, 02 Aug 2008) | 2 lines
* Added a preprocessor to deal with the crappy location scripts in BRA.
* Added some comments on how the parser and related code should be changed to make things smoother.
........
r33510 | peres001 | 2008-08-02 04:26:09 +0200 (Sat, 02 Aug 2008) | 1 line
Removed debug code I forgot a long time ago ;)
........
r33511 | peres001 | 2008-08-02 04:43:05 +0200 (Sat, 02 Aug 2008) | 1 line
Fixed issues detected by DrMcCoy's obnoxious compiler. ;)
........
r33512 | peres001 | 2008-08-02 05:19:45 +0200 (Sat, 02 Aug 2008) | 2 lines
* Increasing max number of allowed token on one line.
* Increasing buffer size to match old parser.
........
r33518 | lordhoto | 2008-08-02 13:40:09 +0200 (Sat, 02 Aug 2008) | 2 lines
Fix for bug #2035459 "KYRA1: long savegame names cause garbage".
........
r33519 | lordhoto | 2008-08-02 13:57:06 +0200 (Sat, 02 Aug 2008) | 2 lines
Proper fix for bug #2035459 "KYRA1: long savegame names cause garbage".
........
r33522 | lordhoto | 2008-08-02 16:32:05 +0200 (Sat, 02 Aug 2008) | 2 lines
Fixed regressions in kyra1 amiga.
........
r33523 | athrxx | 2008-08-02 16:35:38 +0200 (Sat, 02 Aug 2008) | 1 line
HOF: bug fix for FM-Towns music when using output rates other than 22050 khz
........
r33524 | lordhoto | 2008-08-02 16:35:43 +0200 (Sat, 02 Aug 2008) | 2 lines
Add warning when a voc file is not found.
........
r33525 | Kirben | 2008-08-02 16:37:10 +0200 (Sat, 02 Aug 2008) | 1 line
Detect both HOF non-interactive demos.
........
r33526 | lordhoto | 2008-08-02 16:42:44 +0200 (Sat, 02 Aug 2008) | 2 lines
Fixed yet another crash in kyra1 amiga.
........
r33527 | lordhoto | 2008-08-02 17:05:19 +0200 (Sat, 02 Aug 2008) | 2 lines
Added a member function loadSoundFile to Sound which accepts a filename string instead of a filename list id.
........
r33529 | buddha_ | 2008-08-02 17:47:25 +0200 (Sat, 02 Aug 2008) | 7 lines
- Combined loadAbs and loadResource into one function.
- Made resource loading functions (loadSpl, loadMsk etc)
return the number of the animDataTable entry right after
the loaded data.
- Made resource loading functions always load multiframe
data into directly sequential animDataTable entries
(Hopefully this won't break anything).
........
r33530 | buddha_ | 2008-08-02 17:59:38 +0200 (Sat, 02 Aug 2008) | 3 lines
Made loadResourcesFromSave internally use the loadResource-function.
Fixes Operation Stealth savegame loading! HURRAH! FINALLY!
........
r33537 | sev | 2008-08-02 23:05:46 +0200 (Sat, 02 Aug 2008) | 2 lines
Fix crash when drascula.dat file is missing
........
r33541 | sev | 2008-08-02 23:22:05 +0200 (Sat, 02 Aug 2008) | 2 lines
Fix bug #2007170: "DRASCULA: No Spaces in SaveGames Names"
........
r33544 | sev | 2008-08-02 23:36:08 +0200 (Sat, 02 Aug 2008) | 2 lines
Fix bug #2023727: "MONKEY2: Misplaced Text"
........
r33546 | sev | 2008-08-02 23:57:35 +0200 (Sat, 02 Aug 2008) | 2 lines
Fix bug #1879606: "MANIACNES: Crash when game ends"
........
r33550 | fingolfin | 2008-08-03 00:32:32 +0200 (Sun, 03 Aug 2008) | 1 line
Fix for bug #1972625 'ALL: On-the-fly targets are written to the config file'
........
r33552 | sev | 2008-08-03 00:51:53 +0200 (Sun, 03 Aug 2008) | 3 lines
Fix for bug #1945335: "SCUMM: Invalid charset id can be stored".
Regressions possible.
........
r33553 | fingolfin | 2008-08-03 01:01:14 +0200 (Sun, 03 Aug 2008) | 1 line
Renamed Tinsel v1->v0 (used in the demo only), and v2->v1, to avoid confusion with DW2
........
r33554 | sev | 2008-08-03 01:05:38 +0200 (Sun, 03 Aug 2008) | 2 lines
Fix bug #2035390: "GUI: setting game id to "scummvm" messes up list"
........
r33556 | athrxx | 2008-08-03 01:11:31 +0200 (Sun, 03 Aug 2008) | 1 line
add non-interactive lol demo
........
r33558 | eriktorbjorn | 2008-08-03 09:40:04 +0200 (Sun, 03 Aug 2008) | 3 lines
Fixed #2021902 ("DRASCULA: Can't adjust the volume inside the game"). I can't
verify that this matches the original behaviour, but at least it's better now.
........
r33561 | buddha_ | 2008-08-03 10:01:11 +0200 (Sun, 03 Aug 2008) | 1 line
Shut up MSVC warning about mgY being an unreferenced local variable.
........
r33562 | fingolfin | 2008-08-03 10:05:19 +0200 (Sun, 03 Aug 2008) | 1 line
Proper fix for bug #2035390: Check for ConfigManager::kApplicationDomain, and also forbid targets starting with an underscore
........
r33565 | eriktorbjorn | 2008-08-03 11:41:10 +0200 (Sun, 03 Aug 2008) | 4 lines
Fixed bug that prevented upper-case letters from being used in savegame names.
Apparently, strchr(..., 0) will find the string terminator - at least for me -
and when that's added to the name, it will terminate the string.
........
r33568 | eriktorbjorn | 2008-08-03 11:51:13 +0200 (Sun, 03 Aug 2008) | 2 lines
Fixed bug #1995022 ("BASS: wrong displayed 2 line text").
........
r33570 | eriktorbjorn | 2008-08-03 12:16:17 +0200 (Sun, 03 Aug 2008) | 5 lines
Fixed bug #1995033 ("BASS: BG Sound stopped on opening item list"). Apparently
the sound is supposed to be paused and then unpaused, but the pause function is
called many more times than the unpause function. In the original, this
presumably didn't matter. In ScummVM's mixer, it does.
........
r33574 | sev | 2008-08-03 13:42:05 +0200 (Sun, 03 Aug 2008) | 2 lines
Fix bug #2017432: "DRASCULA: Typing is slow when you save a game"
........
r33576 | sev | 2008-08-03 14:02:09 +0200 (Sun, 03 Aug 2008) | 2 lines
Fix bug #2011470: "DRASCULA: slowdown when you hold mouse buttons"
........
r33578 | athrxx | 2008-08-03 14:09:48 +0200 (Sun, 03 Aug 2008) | 1 line
add support for HOF Italian fan translation to kyra.dat
........
r33579 | lordhoto | 2008-08-03 14:16:53 +0200 (Sun, 03 Aug 2008) | 2 lines
Added detection entries for kyra2 cd italian fan translation (see fr#2003504 "KYRA: add support for Italian version of Kyrandia 2&3"). (totally untested!)
........
r33580 | athrxx | 2008-08-03 14:50:56 +0200 (Sun, 03 Aug 2008) | 1 line
fix last commit (invalid kyra.dat game features for HOFCD)
........
r33581 | lordhoto | 2008-08-03 14:53:12 +0200 (Sun, 03 Aug 2008) | 2 lines
Removed comment.
........
r33584 | fingolfin | 2008-08-03 18:54:18 +0200 (Sun, 03 Aug 2008) | 1 line
New OSystem API for loading/storing default config file
........
r33585 | fingolfin | 2008-08-03 19:05:01 +0200 (Sun, 03 Aug 2008) | 1 line
OSYSTEM: Pushed some SDL/Symbian specific code to the respective backends; made openConfigFileForReading/openConfigFileForWriting return 0 if they failed to open a file
........
r33586 | fingolfin | 2008-08-03 20:11:27 +0200 (Sun, 03 Aug 2008) | 1 line
Implemented DumpFile::open(FSNode)
........
r33587 | fingolfin | 2008-08-03 20:29:37 +0200 (Sun, 03 Aug 2008) | 1 line
cleanup
........
r33590 | fingolfin | 2008-08-03 20:35:51 +0200 (Sun, 03 Aug 2008) | 1 line
FilesystemNode code: some comment cleanup; added FilesystemNode::openForReading() and openForWriting() methods (for now these are simple wrappers around Common::File)
........
r33596 | Kirben | 2008-08-04 03:57:50 +0200 (Mon, 04 Aug 2008) | 1 line
Remove debug left over.
........
r33604 | fingolfin | 2008-08-04 13:30:47 +0200 (Mon, 04 Aug 2008) | 1 line
Moved the OutSaveFile::finalize method to WriteStream; implemented DumpFile::flush()
........
r33605 | fingolfin | 2008-08-04 13:32:42 +0200 (Mon, 04 Aug 2008) | 1 line
Removed join_paths from default save manager, and use FSNode API instead (may lead to regressions, watch out)
........
r33606 | fingolfin | 2008-08-04 13:38:25 +0200 (Mon, 04 Aug 2008) | 1 line
Turned InSaveFile & OutSaveFile into simple typedefs
........
r33607 | fingolfin | 2008-08-04 13:46:52 +0200 (Mon, 04 Aug 2008) | 1 line
SCUMM: Only try to load savefile metadata from slots >= 0
........
r33608 | fingolfin | 2008-08-04 13:48:33 +0200 (Mon, 04 Aug 2008) | 1 line
DefaultSaveFileManager: Killed class StdioSaveFile, used FilesystemNode::openForReading()/openForWriting() instead (may cause regressions, watch out)
........
r33609 | fingolfin | 2008-08-04 15:25:30 +0200 (Mon, 04 Aug 2008) | 1 line
Modified DumpFile::open to accept non-existing nodes, and to actually open files in write mode -- d'oh
........
r33610 | thebluegr | 2008-08-04 17:01:41 +0200 (Mon, 04 Aug 2008) | 1 line
Fixing compilation under MSVC
........
r33611 | thebluegr | 2008-08-04 17:23:08 +0200 (Mon, 04 Aug 2008) | 1 line
Added Italian translation for the load confirmation window in IHNM
........
r33614 | fingolfin | 2008-08-04 19:17:37 +0200 (Mon, 04 Aug 2008) | 1 line
Moved ConfMan.registerDefault calls for savepath to DefaultSaveFileManager (eventually, should be pushed into backends/platform/ code)
........
r33615 | fingolfin | 2008-08-04 19:41:07 +0200 (Mon, 04 Aug 2008) | 1 line
Modified DefaultSaveFileManager::checkPath to perform at least basic checks on non-UNIX, non-Symbian systems
........
r33617 | fingolfin | 2008-08-04 19:46:22 +0200 (Mon, 04 Aug 2008) | 1 line
Remove some code which was rendered obsolete by md5's commit r33610
........
r33618 | anotherguest | 2008-08-04 20:14:17 +0200 (Mon, 04 Aug 2008) | 3 lines
List the correct engines in about,
updated actions with Lure (from WinCE).
Increased min heap size to 5MB
........
r33620 | buddha_ | 2008-08-04 21:32:52 +0200 (Mon, 04 Aug 2008) | 7 lines
Fix for misplaced objects in mouse object selection (Operation Stealth specific).
- Implemented Operation Stealth specific part of getObjectUnderCursor
which handles negative frame values.
- Fixed a test case (Should test for ydif <= 0 although tested for ydif < 0).
- Made part-value be anded with 0x0F in a test case to comply with disassembly.
- Added comment about a test case which isn't present in the disassembly.
Removing it makes things crash sometimes so letting it be.
........
r33621 | fingolfin | 2008-08-04 21:38:28 +0200 (Mon, 04 Aug 2008) | 1 line
Pushed some port specific code from DefaultSaveFileManager out to port specific code in backends/platform/
........
r33623 | anotherguest | 2008-08-04 22:00:56 +0200 (Mon, 04 Aug 2008) | 1 line
Symbian build package should now contain drascula.dat also
........
r33626 | Kirben | 2008-08-05 02:21:46 +0200 (Tue, 05 Aug 2008) | 1 line
Fix win32 compile.
........
r33627 | Kirben | 2008-08-05 02:27:25 +0200 (Tue, 05 Aug 2008) | 1 line
Removed unneeded #includes.
........
r33632 | lordhoto | 2008-08-05 13:32:16 +0200 (Tue, 05 Aug 2008) | 2 lines
Changed implementation parameters/return values to match definition.
........
r33633 | Kirben | 2008-08-05 13:42:04 +0200 (Tue, 05 Aug 2008) | 1 line
Remove file attribute check, since getChild() can be called on file path that doesn'r exist.
........
r33635 | lordhoto | 2008-08-05 14:13:01 +0200 (Tue, 05 Aug 2008) | 2 lines
Output errors on (some) missing files.
........
r33637 | buddha_ | 2008-08-05 14:58:23 +0200 (Tue, 05 Aug 2008) | 7 lines
Fix prompt updating regression introduced in r32257:
Previously prompt didn't get updated all the time,
like e.g. when selecting EXAMINE and moving the
cursor over to DOOR and then moving the cursor to
a place where there was no selectable object. The
prompt would've still shown "EXAMINE DOOR", now
it shows just "EXAMINE" which is correct AFAIK.
........
r33639 | fingolfin | 2008-08-05 15:08:07 +0200 (Tue, 05 Aug 2008) | 1 line
SCUMM: Don't try to load metadata for slot -1 (i.e. don't try to load metadata if nothing is selected)
........
r33640 | fingolfin | 2008-08-05 15:11:22 +0200 (Tue, 05 Aug 2008) | 1 line
SCUMM: cleanup SaveLoadChooser::updateInfos code
........
r33642 | buddha_ | 2008-08-05 20:17:55 +0200 (Tue, 05 Aug 2008) | 1 line
Add detection entry for a previously unrecognized 16 color PC version of Operation Stealth (The John Glames variant).
........
r33643 | buddha_ | 2008-08-05 21:30:16 +0200 (Tue, 05 Aug 2008) | 5 lines
Made rest of resource loading functions used in loadResource return -1 on error.
This fixed a crash in Operation Stealth when walking out of the airport
(Some file couldn't be opened and the game crashed because of that.
Now it doesn't crash but handles the missing file gracefully).
........
r33644 | buddha_ | 2008-08-05 23:20:11 +0200 (Tue, 05 Aug 2008) | 1 line
Workaround for missing player character animation when exiting the airport in Santa Paragua in at least the 256 color PC version of Operation Stealth.
........
r33645 | fingolfin | 2008-08-05 23:26:04 +0200 (Tue, 05 Aug 2008) | 1 line
Patch #2014663: Do not mark stack as executable in HQx scaler
........
r33648 | eriktorbjorn | 2008-08-05 23:43:10 +0200 (Tue, 05 Aug 2008) | 4 lines
Committed my patch #2026097 ("ALSA: Try both 65:0 and 17:0 by default"), with a
slight modification to the README changes. (I don't know how to interpret all
the output from aconnect, so I'm only documenting "the most important bit".)
........
r33654 | fingolfin | 2008-08-06 11:13:57 +0200 (Wed, 06 Aug 2008) | 1 line
SCUMM: Renamed inventoryScript -> inventoryScriptIndy3Mac
........
r33655 | fingolfin | 2008-08-06 12:32:20 +0200 (Wed, 06 Aug 2008) | 1 line
Workaround for bug #2016521 (DOTT: Bernard impersonating LaVerne)
........
r33664 | fingolfin | 2008-08-06 18:03:06 +0200 (Wed, 06 Aug 2008) | 1 line
Do not query savestates which obviously do not exist (to shut up bogus console warnings)
........
r33667 | buddha_ | 2008-08-06 22:41:53 +0200 (Wed, 06 Aug 2008) | 5 lines
HACK: Force oxygen to maximum during Operation Stealth's first arcade sequence.
This way the arcade sequence is completable now.
This hack should be removed later and the first
arcade sequence be made properly playable!
........
r33668 | buddha_ | 2008-08-06 22:47:59 +0200 (Wed, 06 Aug 2008) | 5 lines
Add 320x200 screen bounds checking to Operation Stealth's checkCollision function.
Fixes teleporting bug when getting out of the water after first arcade sequence.
The player previously got teleported to the beach near the hotel. Now it doesn't happen.
The player is still caught motionless and can't move after this fix though...
........
r33669 | buddha_ | 2008-08-06 22:54:38 +0200 (Wed, 06 Aug 2008) | 1 line
Renamed page3Raw to collisionPage so it's more apparent what it does.
........
r33670 | buddha_ | 2008-08-06 22:58:02 +0200 (Wed, 06 Aug 2008) | 1 line
Tiny comment update to loadCt-opcodes: Load collision table data.
........
r33673 | buddha_ | 2008-08-07 01:12:25 +0200 (Thu, 07 Aug 2008) | 4 lines
HACK: In Operation Stealth after the first arcade sequence jump player's position to avoid getting stuck.
The player's position is changed only by *one* pixel but it helps
and makes it possible to carry on with the game (Previously the player was totally stuck).
........
r33674 | knakos | 2008-08-07 11:10:42 +0200 (Thu, 07 Aug 2008) | 1 line
smartphone-specific code not needed anymore
........
r33678 | eriktorbjorn | 2008-08-07 15:36:02 +0200 (Thu, 07 Aug 2008) | 3 lines
Initialise the _sound object. Otherwise, ScummVM crashes for me if I use a native
MIDI driver instead of Adlib.
........
r33682 | knakos | 2008-08-07 20:36:12 +0200 (Thu, 07 Aug 2008) | 1 line
setup interface for later kyra games
........
r33686 | buddha_ | 2008-08-07 21:04:19 +0200 (Thu, 07 Aug 2008) | 7 lines
Fix for popup boxes sometimes blocking animation when they shouldn't in Operation Stealth:
- Made waitForPlayerClick updating more like in the original.
- Moved removeMessages to after the frame drawing in main loop hoping to be more like the original.
- Added an additional test to Operation Stealth's implementation of overlay type 2 drawing.
- Added an additional parameter incrementing and testing to Operation Stealth's removeMessages.
Hopefully this won't cause any regressions in Future Wars!
........
r33687 | buddha_ | 2008-08-07 21:31:12 +0200 (Thu, 07 Aug 2008) | 1 line
Made drawPlainBox handle border cases so it won't corrupt memory so easily. This may help with some memory corruption issues when for an example trying to draw the player's command string out of screen.
........
r33688 | buddha_ | 2008-08-07 21:46:06 +0200 (Thu, 07 Aug 2008) | 1 line
Added precautionary tests to background scrolling function in Operation Stealth to avoid possible memory corruptions.
........
r33689 | buddha_ | 2008-08-07 23:46:56 +0200 (Thu, 07 Aug 2008) | 1 line
Implemented game speed changing by pressing - or + to e.g. ease testing.
........
r33690 | cyx | 2008-08-07 23:49:55 +0200 (Thu, 07 Aug 2008) | 1 line
fix for bug #2040311: TOUCHE: Missing characters in the spanish version
........
r33691 | cyx | 2008-08-07 23:50:12 +0200 (Thu, 07 Aug 2008) | 1 line
fix for bug #2040484: TOUCHE: Graphic glitch with long answer options
........
r33693 | Kirben | 2008-08-08 04:18:17 +0200 (Fri, 08 Aug 2008) | 1 line
Hopefully allow quiting at any stage AGOS engines games again.
........
r33696 | Kirben | 2008-08-08 04:49:51 +0200 (Fri, 08 Aug 2008) | 1 line
Remove debug leftover.
........
r33698 | buddha_ | 2008-08-08 15:30:01 +0200 (Fri, 08 Aug 2008) | 9 lines
Added basic moving using keyboard (Only works in Operation Stealth at the moment):
- Should make it possible to complete the first arcade sequence legitimately
Renamed input variables (Their names were mixed up between Future Wars and Operation Stealth):
- Future Wars's inputVar1 -> egoMovedWithKeyboard
- Future Wars's inputVar2 -> xMoveKeyb
- Future Wars's inputVar3 -> yMoveKeyb
- Operation Stealth's inputVar0 -> xMoveKeyb
- Operation Stealth's inputVar1 -> yMoveKeyb
........
r33700 | buddha_ | 2008-08-08 16:46:19 +0200 (Fri, 08 Aug 2008) | 1 line
Partially fix Adlib volume setting in Cine (Now uses music volume for Adlib volume, previously always played with full volume. Doesn't differentiate between playing sound effects and music!).
........
r33703 | buddha_ | 2008-08-08 20:28:13 +0200 (Fri, 08 Aug 2008) | 4 lines
Added detection entry for the Sony published CD version of Future Wars.
Also added decrypting of the crypted AUTO00.PRC for this particular version.
Now this version should work but no CD audio support for it yet though.
........
r33708 | buddha_ | 2008-08-09 12:44:12 +0200 (Sat, 09 Aug 2008) | 1 line
Small cleanup: Renamed rol to rolByte and made it handle all cases.
........
r33710 | buddha_ | 2008-08-09 12:52:48 +0200 (Sat, 09 Aug 2008) | 1 line
Removing moving with keys qweasdzxc for now because they messed with savegame name typing. One can move with the cursor keys anyway.
........
r33712 | buddha_ | 2008-08-09 17:17:32 +0200 (Sat, 09 Aug 2008) | 1 line
Added updating of global variable var5 to Operation Stealth's renderOverlay function's type 20 overlay case (Previously var5 wasn't updated anywhere!). Also added a lower bound for var5's value into a comparison (Previously only the upper bound was tested for).
........
r33713 | buddha_ | 2008-08-09 18:07:08 +0200 (Sat, 09 Aug 2008) | 1 line
Added preliminary version of drawing type 22 overlays (Such overlays are added with opcode 0xA4 (o2_loadMask22) and removed with opcode 0xA5 (o2_unloadMask22)). Things might be wrong so needs testing! WIP!
........
r33714 | knakos | 2008-08-09 20:09:24 +0200 (Sat, 09 Aug 2008) | 1 line
fix MR on ce: allocate large buffer on the heap instead and of the stack, and improve the workaround
........
r33716 | knakos | 2008-08-09 20:12:43 +0200 (Sat, 09 Aug 2008) | 1 line
hotfix around drascula mem leak problems. see also bug report
........
r33719 | dhewg | 2008-08-09 20:37:18 +0200 (Sat, 09 Aug 2008) | 1 line
Updates to the recent OSystem API changes
........
r33721 | buddha_ | 2008-08-09 21:47:05 +0200 (Sat, 09 Aug 2008) | 7 lines
Made drawPlainBox's effective width and height always at least one.
- Makes oxygen gauge during first arcade sequence visible as it gave drawPlainBox a height of zero.
Made type 21 overlays be drawn as type 22 (Filled rectangle).
- For an example the oxygen gauge during the first arcade sequence is a type 21 overlay.
Flipped type 21 & 22 overlays as it looks correct for the oxygen gauge.
These features are quite WIP, they need testing to see if they're correct.
........
r33722 | buddha_ | 2008-08-09 21:57:46 +0200 (Sat, 09 Aug 2008) | 1 line
Made type 21 & 22 overlays not be flipped (The oxygen gauge looks actually better when it reaches zero this way although in its fully charged state it still does look a bit off. Disassembly seems to agree with not flipping the overlays so I'm going with this one for now).
........
r33723 | dhewg | 2008-08-09 22:02:56 +0200 (Sat, 09 Aug 2008) | 3 lines
Updated the Makefile to the new build system.
Introduced a Makefile variable to build a gamecube version.
........
r33725 | buddha_ | 2008-08-09 22:50:10 +0200 (Sat, 09 Aug 2008) | 1 line
Converted objectTable from a plain array to a Common::Array. Should help to catch out of bounds access errors that may cause memory corruption.
........
r33726 | buddha_ | 2008-08-09 22:55:01 +0200 (Sat, 09 Aug 2008) | 1 line
Converted animDataTable from a plain array to a Common::Array. Should help to catch out of bounds access errors which may cause memory corruption.
........
r33727 | buddha_ | 2008-08-10 00:38:03 +0200 (Sun, 10 Aug 2008) | 1 line
Converted zoneData and zoneQuery tables from plain array types to Common::Array. Should help catch out of bounds access errors that may cause memory corruption.
........
r33729 | fingolfin | 2008-08-10 00:42:03 +0200 (Sun, 10 Aug 2008) | 1 line
If no default config file is present, just don't load it, instead of crashing
........
r33730 | fingolfin | 2008-08-10 01:07:32 +0200 (Sun, 10 Aug 2008) | 1 line
Use FSNode API in default OSystem::openConfigFileForReading & OSystem::openConfigFileForWriting method implementations
........
r33733 | lordhoto | 2008-08-10 02:17:56 +0200 (Sun, 10 Aug 2008) | 2 lines
Fixed crash in KyraEngine_HoF::pauseEngineIntern.
........
r33736 | lordhoto | 2008-08-10 02:36:46 +0200 (Sun, 10 Aug 2008) | 2 lines
Fixed kyra to support properly support restarting of engine (for GSoC RTL, based on a patch from Chris Page).
........
r33742 | lordhoto | 2008-08-10 03:28:00 +0200 (Sun, 10 Aug 2008) | 2 lines
Added fallback to text only mode when voice files are not found.
........
r33754 | knakos | 2008-08-10 19:10:09 +0200 (Sun, 10 Aug 2008) | 1 line
add support for drascula engine
........
r33756 | knakos | 2008-08-10 19:13:24 +0200 (Sun, 10 Aug 2008) | 1 line
hint the backend to show the VK
........
r33758 | knakos | 2008-08-10 19:15:30 +0200 (Sun, 10 Aug 2008) | 1 line
address the ignored events and bad inventory screen handling 'features'
........
r33761 | sev | 2008-08-10 19:35:42 +0200 (Sun, 10 Aug 2008) | 2 lines
Add checksums for ScummVM repacked Italian and Spanish versions.
........
r33763 | eriktorbjorn | 2008-08-10 19:59:42 +0200 (Sun, 10 Aug 2008) | 5 lines
Committed my patch #2040074 ("XMIDI callback control events"). At the moment, I'm
not aware of any game that actually uses this XMIDI feature, so its primary
function right now is to silence lots of warnings while running the DOS version
of Simon the Sorcerer 2.
........
r33766 | eriktorbjorn | 2008-08-10 20:44:00 +0200 (Sun, 10 Aug 2008) | 5 lines
Fixed a bunch of Valgrind warnings (mostly uninitialised variables, but also an
invalid free()), so that I can start and quit the game without any unexpected
warnings. (The obvious next step, of course, would be to actually *play* the game
for a bit...)
........
r33777 | athrxx | 2008-08-11 16:47:50 +0200 (Mon, 11 Aug 2008) | 2 lines
LOL: add support for floppy installer files
(startup will fail nonethelesse since we have different pak file names)
........
r33781 | buddha_ | 2008-08-11 22:09:03 +0200 (Mon, 11 Aug 2008) | 1 line
Changed readBundleFile to unpack data in-place and added debugging messages to the function.
........
r33782 | buddha_ | 2008-08-11 22:18:33 +0200 (Mon, 11 Aug 2008) | 1 line
Added a safeguard to readBundleFile so it shouldn't corrupt memory even if the input says the data's unpacked size is less than its packed size (This shouldn't ever happen with non-corrupted data).
........
r33783 | buddha_ | 2008-08-11 22:41:13 +0200 (Mon, 11 Aug 2008) | 1 line
Changed partBuffer from a pointer to a Common::Array. Removed numElementInPart variable as it's now equivalent with partBuffer.size().
........
r33784 | buddha_ | 2008-08-11 23:26:41 +0200 (Mon, 11 Aug 2008) | 1 line
Removed textDataPtr pointer as it's not used beyond the loadTextData function. Reworked loadTextData a bit so there are no two loops for the same thing (Also renamed some of the local variables).
........
r33785 | buddha_ | 2008-08-11 23:45:47 +0200 (Mon, 11 Aug 2008) | 1 line
Changed palPtr from a pointer to a Common::Array named palArray. Removed palEntriesCount variable as it's now equivalent to palArray.size().
........
r33786 | buddha_ | 2008-08-12 00:26:25 +0200 (Tue, 12 Aug 2008) | 1 line
Moved fontParamTable inside TextHandler struct and made it a constant size as that's what it is (No need for using malloc & free anymore). Previously we would've tried to free an array that wasn't heap-allocated in freePoldatDat (Freeing fontParamTable_standard or fontParamTable_alt), that's fixed.
........
r33787 | dhewg | 2008-08-12 00:43:00 +0200 (Tue, 12 Aug 2008) | 7 lines
video mode polishing:
* proper fullscreen video mode
* multiple graphic modes with different overscan values
* "fullscreen mode" stretches the picture on 16:9 displays
* fixed broken sword 1/2 gfx garbage
* support for setShakePos()
........
r33788 | dhewg | 2008-08-12 00:44:29 +0200 (Tue, 12 Aug 2008) | 1 line
build a wii binary per default
........
r33790 | buddha_ | 2008-08-12 01:01:32 +0200 (Tue, 12 Aug 2008) | 1 line
Implemented drawMessage changes for Operation Stealth's timed cutscenes (Negative colors are used for timed text boxes that are totally transparent, only the text is drawn).
........
r33792 | buddha_ | 2008-08-12 01:20:10 +0200 (Tue, 12 Aug 2008) | 1 line
Made Operation Stealth's action failure messages use a background color set by the opcode 0x49 'o1_setDefaultMenuBgColor'. Should fix the 'text hard to read' problems.
........
r33793 | buddha_ | 2008-08-12 02:13:27 +0200 (Tue, 12 Aug 2008) | 1 line
Changed commandBuffer from a char[80] to Common::String and made FWRenderer::setCommand use a Common::String. Hopefully this might help with the command buffer overflow stuff, although this isn't a fix for the problem behind it, just a bandaid.
........
r33795 | buddha_ | 2008-08-12 16:44:44 +0200 (Tue, 12 Aug 2008) | 1 line
Implemented Operation Stealth specific parts of processInventory and added another mouse button waiting loop into the function's end (It's in both Future Wars and Operation Stealth). Fixes inventory showing in Operation Stealth.
........
r33797 | aquadran | 2008-08-12 16:52:44 +0200 (Tue, 12 Aug 2008) | 1 line
added few ignores for build dirs
........
r33805 | buddha_ | 2008-08-12 21:33:17 +0200 (Tue, 12 Aug 2008) | 1 line
Implemented Operation Stealth's makeCommandLine.
........
r33807 | buddha_ | 2008-08-12 22:27:49 +0200 (Tue, 12 Aug 2008) | 1 line
Tiny comment fix.
........
r33808 | buddha_ | 2008-08-12 22:58:26 +0200 (Tue, 12 Aug 2008) | 1 line
Fix for GCC warning in OSRenderer::renderOverlay: declaration of 'len' shadows a previous local.
........
r33809 | joostp | 2008-08-12 23:23:40 +0200 (Tue, 12 Aug 2008) | 2 lines
fix typo 'baclup' -> 'backup'
........
r33810 | buddha_ | 2008-08-13 00:45:38 +0200 (Wed, 13 Aug 2008) | 1 line
Added possibility to get the read resource's size from readBundleFile. Made loadMsg handle input data that has empty strings residing just beyond the input buffer (Thanks Valgrind :-)).
........
r33811 | buddha_ | 2008-08-13 01:44:39 +0200 (Wed, 13 Aug 2008) | 1 line
Fixed drawPlainBox's boundary checking (It wrote outside the screen occasionally). Now using the Common::Rect for clipping, yay! It's good.
........
r33812 | buddha_ | 2008-08-13 01:56:13 +0200 (Wed, 13 Aug 2008) | 1 line
Hopefully fixes 'Conditional jump or move depends on uninitialised value(s)' Valgrind warning at sound.cpp:611.
........
r33815 | buddha_ | 2008-08-13 03:02:00 +0200 (Wed, 13 Aug 2008) | 1 line
Changed Agi::SoundMgr's sound buffer to a member array of size BUFFER_SIZE. Also added initialization of _playing to false in SoundMgr's constructor. Hopefully helps with the occasional crashes in the sound code when starting the first sound in an AGI game.
........
r33816 | buddha_ | 2008-08-13 03:10:03 +0200 (Wed, 13 Aug 2008) | 1 line
Shutting up Valgrind about using uninitialised values from array _chn in function stopNote.
........
r33817 | fingolfin | 2008-08-13 12:13:22 +0200 (Wed, 13 Aug 2008) | 1 line
Clarify SCUMM MD5 message: We do not want reports on fanmade translations
........
r33819 | buddha_ | 2008-08-13 13:36:45 +0200 (Wed, 13 Aug 2008) | 1 line
Reverted r33815 (But not r33816).
........
r33822 | buddha_ | 2008-08-13 13:57:48 +0200 (Wed, 13 Aug 2008) | 1 line
Fixed initialization of some SoundMgr-class's member variables. Moved _sndBuffer's allocation to SoundMgr's constructor and its deallocation to the destructor. Made fillAudio SoundMgr's method and removed a superfluous global static variable 'int16 *buffer'. Should help with the occasional crashes when starting the first sound in an AGI game.
........
r33826 | buddha_ | 2008-08-13 15:40:28 +0200 (Wed, 13 Aug 2008) | 1 line
Type 21 overlay comment update (Found the drawing routine in the disassembly and checked the original for how the oxygen gauge during the first arcade sequence looks like. They're some kind of sprites most likely and not just simply filled rectangles).
........
r33829 | knakos | 2008-08-13 17:16:38 +0200 (Wed, 13 Aug 2008) | 1 line
fix bug #2038992 by saving and restoring channel volumes
........
r33837 | lordhoto | 2008-08-13 21:10:31 +0200 (Wed, 13 Aug 2008) | 2 lines
Added detection entries for kyra3 Mac.
........
r33839 | knakos | 2008-08-13 21:13:53 +0200 (Wed, 13 Aug 2008) | 1 line
fix bug #1910057: FT multifunction
........
r33844 | knakos | 2008-08-13 21:32:25 +0200 (Wed, 13 Aug 2008) | 1 line
fix a small bug in the quit dialog
........
r33847 | fingolfin | 2008-08-13 22:37:54 +0200 (Wed, 13 Aug 2008) | 1 line
cleanup
........
r33858 | peres001 | 2008-08-14 09:10:42 +0200 (Thu, 14 Aug 2008) | 1 line
Removed cross-references between the general parser and the text formatter. To achieve this, I have rewritten the latter for both NS and BRA.
........
r33859 | peres001 | 2008-08-14 09:14:34 +0200 (Thu, 14 Aug 2008) | 1 line
Finally moved parseNextToken to Script, where it belongs!
........
r33860 | peres001 | 2008-08-14 12:04:43 +0200 (Thu, 14 Aug 2008) | 1 line
Cleanup.
........
r33861 | peres001 | 2008-08-14 12:24:39 +0200 (Thu, 14 Aug 2008) | 1 line
More cleanup.
........
r33864 | peres001 | 2008-08-14 15:45:32 +0200 (Thu, 14 Aug 2008) | 1 line
Some variable renamed to make more sense.
........
r33871 | buddha_ | 2008-08-14 22:18:13 +0200 (Thu, 14 Aug 2008) | 1 line
Added debug showing of the collision page when pressing the Alt key. Alt isn't used for anything else so one might as well use it for this.
........
r33872 | buddha_ | 2008-08-14 22:49:34 +0200 (Thu, 14 Aug 2008) | 1 line
Fix for bugging moving at the bottom of the ocean when trying to free the girl from the ropes and swimming to the surface. Some global variables related to mouse position weren't being updated in executePlayerInput, now they are and things seem to work. Also enables moving in the labyrinth arcade sequence at the palace.
........
r33873 | athrxx | 2008-08-14 23:21:04 +0200 (Thu, 14 Aug 2008) | 1 line
- HOF: another Italian fan translation
........
r33875 | athrxx | 2008-08-14 23:34:29 +0200 (Thu, 14 Aug 2008) | 1 line
- HOF: forgot french and german entries in last commit
........
r33877 | buddha_ | 2008-08-15 00:01:56 +0200 (Fri, 15 Aug 2008) | 1 line
Moved showing of the collision page from Alt-key to F11-key because Alt conflicted with taking screenshots using Alt-s. Great. Hopefully F11 doesn't conflict with anything useful.
........
r33878 | lordhoto | 2008-08-15 00:09:36 +0200 (Fri, 15 Aug 2008) | 2 lines
Improved version of my resource loading patch from -devel (check also r33876).
........
r33879 | lordhoto | 2008-08-15 00:11:56 +0200 (Fri, 15 Aug 2008) | 2 lines
Formatting.
........
r33886 | athrxx | 2008-08-15 01:46:37 +0200 (Fri, 15 Aug 2008) | 1 line
lol: new detection entry (german floppy extracted)
........
r33889 | peres001 | 2008-08-15 04:52:42 +0200 (Fri, 15 Aug 2008) | 2 lines
Simplified handling of script variables (especially locals).
........
r33890 | peres001 | 2008-08-15 05:36:01 +0200 (Fri, 15 Aug 2008) | 1 line
Disabled lip syncing code in BRA, since I couldn't find any scripts actually using it. Some warnings have been added as a sentinel.
........
r33891 | peres001 | 2008-08-15 05:59:45 +0200 (Fri, 15 Aug 2008) | 1 line
Made scripts access Animation fields via accessors and mutators, instead of using raw pointers.
........
r33892 | peres001 | 2008-08-15 06:30:45 +0200 (Fri, 15 Aug 2008) | 1 line
Made coordinates and frame number protected into Zone and Animation, and changed client code to use get/set. This will allow various simplifications (e.g. when calculating Z), and is a step towards correct handling of interactive zones of Zone/Animation in BRA.
........
r33894 | peres001 | 2008-08-15 10:44:41 +0200 (Fri, 15 Aug 2008) | 1 line
Updated layer calculation: animations are now hidden properly by background elements (but not items yet).
........
r33896 | drmccoy | 2008-08-15 12:47:42 +0200 (Fri, 15 Aug 2008) | 2 lines
Fixing a segfault in the Bargon Attack menu
........
r33900 | peres001 | 2008-08-15 16:25:43 +0200 (Fri, 15 Aug 2008) | 1 line
Added routines to load and handle item masks: animation are now correctly hidden when they are behind any object. The masks of items that are not explicitly activated (even if visible) still are handled (e.g. the crown in the museum is not visible in the foreground).
........
r33902 | anotherguest | 2008-08-15 16:38:25 +0200 (Fri, 15 Aug 2008) | 2 lines
UpdUpdated actions and Readme for Symbian OS port!
........
r33903 | peres001 | 2008-08-15 17:08:08 +0200 (Fri, 15 Aug 2008) | 1 line
Implemented raster operation for masks and postponed blitting of zones after everything in the location has been loaded. This fixes the remaining problems with animations not being masked by items.
........
r33919 | fingolfin | 2008-08-16 00:06:15 +0200 (Sat, 16 Aug 2008) | 1 line
SCUMM: Made some potentially ambiguous (to the reader, at least) checks slightly less ambiguous
........
svn-id: r33920
Diffstat (limited to 'engines/cine')
-rw-r--r-- | engines/cine/anim.cpp | 204 | ||||
-rw-r--r-- | engines/cine/anim.h | 5 | ||||
-rw-r--r-- | engines/cine/bg.cpp | 6 | ||||
-rw-r--r-- | engines/cine/cine.cpp | 53 | ||||
-rw-r--r-- | engines/cine/cine.h | 6 | ||||
-rw-r--r-- | engines/cine/detection.cpp | 34 | ||||
-rw-r--r-- | engines/cine/gfx.cpp | 173 | ||||
-rw-r--r-- | engines/cine/gfx.h | 10 | ||||
-rw-r--r-- | engines/cine/main_loop.cpp | 110 | ||||
-rw-r--r-- | engines/cine/main_loop.h | 5 | ||||
-rw-r--r-- | engines/cine/msg.cpp | 45 | ||||
-rw-r--r-- | engines/cine/object.cpp | 9 | ||||
-rw-r--r-- | engines/cine/object.h | 15 | ||||
-rw-r--r-- | engines/cine/pal.cpp | 36 | ||||
-rw-r--r-- | engines/cine/pal.h | 2 | ||||
-rw-r--r-- | engines/cine/part.cpp | 71 | ||||
-rw-r--r-- | engines/cine/part.h | 8 | ||||
-rw-r--r-- | engines/cine/prc.cpp | 2 | ||||
-rw-r--r-- | engines/cine/script_fw.cpp | 10 | ||||
-rw-r--r-- | engines/cine/script_os.cpp | 24 | ||||
-rw-r--r-- | engines/cine/sound.cpp | 1 | ||||
-rw-r--r-- | engines/cine/texte.cpp | 186 | ||||
-rw-r--r-- | engines/cine/texte.h | 24 | ||||
-rw-r--r-- | engines/cine/various.cpp | 266 | ||||
-rw-r--r-- | engines/cine/various.h | 10 |
25 files changed, 873 insertions, 442 deletions
diff --git a/engines/cine/anim.cpp b/engines/cine/anim.cpp index 8dbccebedf..a670328c12 100644 --- a/engines/cine/anim.cpp +++ b/engines/cine/anim.cpp @@ -49,7 +49,7 @@ struct AnimHeader2Struct { uint16 field_E; }; -AnimData animDataTable[NUM_MAX_ANIMDATA]; +Common::Array<AnimData> animDataTable; static const AnimDataEntry transparencyData[] = { {"ALPHA", 0xF}, @@ -511,14 +511,15 @@ int emptyAnimSpace(int start = 0) { /*! \brief Load SPL data into animDataTable * \param resourceName SPL filename - * \param idx Target index in animDataTable + * \param idx Target index in animDataTable (-1 if any empty space will do) + * \return The number of the animDataTable entry after the loaded SPL data (-1 if error) */ -void loadSpl(const char *resourceName, int16 idx) { +int loadSpl(const char *resourceName, int16 idx) { int16 foundFileIdx = findFileInBundle(resourceName); int entry; if (foundFileIdx < 0) { - return; + return -1; } byte *dataPtr = readBundleFile(foundFileIdx); @@ -528,13 +529,20 @@ void loadSpl(const char *resourceName, int16 idx) { animDataTable[entry].load(dataPtr, ANIM_RAW, partBuffer[foundFileIdx].unpackedSize, 1, foundFileIdx, 0, currentPartName); free(dataPtr); + return entry + 1; } /*! \brief Load 1bpp mask * \param resourceName Mask filename + * \param idx Target index in animDataTable (-1 if any empty space will do) + * \return The number of the animDataTable entry after the loaded mask (-1 if error) */ -void loadMsk(const char *resourceName) { +int loadMsk(const char *resourceName, int16 idx) { int16 foundFileIdx = findFileInBundle(resourceName); + if (foundFileIdx < 0) { + return -1; + } + int entry = 0; byte *dataPtr = readBundleFile(foundFileIdx); byte *ptr; @@ -544,21 +552,28 @@ void loadMsk(const char *resourceName) { loadAnimHeader(animHeader, readS); ptr = dataPtr + 0x16; + entry = idx < 0 ? emptyAnimSpace() : idx; + assert(entry >= 0); for (int16 i = 0; i < animHeader.numFrames; i++, entry++) { - entry = emptyAnimSpace(entry); - assert(entry >= 0); animDataTable[entry].load(ptr, ANIM_MASK, animHeader.frameWidth, animHeader.frameHeight, foundFileIdx, i, currentPartName); ptr += animHeader.frameWidth * animHeader.frameHeight; } free(dataPtr); + return entry; } /*! \brief Load animation * \param resourceName Animation filename + * \param idx Target index in animDataTable (-1 if any empty space will do) + * \return The number of the animDataTable entry after the loaded animation (-1 if error) */ -void loadAni(const char *resourceName) { +int loadAni(const char *resourceName, int16 idx) { int16 foundFileIdx = findFileInBundle(resourceName); + if (foundFileIdx < 0) { + return -1; + } + int entry = 0; byte *dataPtr = readBundleFile(foundFileIdx); byte *ptr; @@ -571,10 +586,10 @@ void loadAni(const char *resourceName) { transparentColor = getAnimTransparentColor(resourceName); - for (int16 i = 0; i < animHeader.numFrames; i++, entry++) { - entry = emptyAnimSpace(entry); - assert(entry >= 0); + entry = idx < 0 ? emptyAnimSpace() : idx; + assert(entry >= 0); + for (int16 i = 0; i < animHeader.numFrames; i++, entry++) { // special case transparency handling if (!strcmp(resourceName, "L2202.ANI")) { transparentColor = i < 2 ? 0 : 7; @@ -587,6 +602,7 @@ void loadAni(const char *resourceName) { } free(dataPtr); + return entry; } /*! \brief Decode 16 color image with palette @@ -642,16 +658,21 @@ void convert8BBP2(byte *dest, byte *source, int16 width, int16 height) { /*! \brief Load image set * \param resourceName Image set filename - * \param idx Target index in animDataTable + * \param idx Target index in animDataTable (-1 if any empty space will do) + * \return The number of the animDataTable entry after the loaded image set (-1 if error) */ -void loadSet(const char *resourceName, int16 idx) { +int loadSet(const char *resourceName, int16 idx) { AnimHeader2Struct header2; uint16 numSpriteInAnim; int16 foundFileIdx = findFileInBundle(resourceName); - int16 entry = idx >= 0 ? idx : 0; + int16 entry; byte *ptr, *startOfDataPtr, *dataPtr, *origDataPtr; int type; + if (foundFileIdx < 0) { + return -1; + } + origDataPtr = dataPtr = readBundleFile(foundFileIdx); assert(!memcmp(dataPtr, "SET", 3)); ptr = dataPtr + 4; @@ -661,6 +682,9 @@ void loadSet(const char *resourceName, int16 idx) { startOfDataPtr = ptr + numSpriteInAnim * 0x10; + entry = idx < 0 ? emptyAnimSpace() : idx; + assert(entry >= 0); + for (int16 i = 0; i < numSpriteInAnim; i++, entry++) { Common::MemoryReadStream readS(ptr, 0x10); @@ -674,9 +698,6 @@ void loadSet(const char *resourceName, int16 idx) { ptr += 0x10; - entry = idx < 0 ? emptyAnimSpace(entry) : idx + i; - assert(entry >= 0); - dataPtr = startOfDataPtr + header2.field_0; if (header2.type == 1) { @@ -693,78 +714,59 @@ void loadSet(const char *resourceName, int16 idx) { } free(origDataPtr); + return entry; } /*! \brief Load SEQ data into animDataTable * \param resourceName SEQ data filename - * \param idx Target index in animDataTable + * \param idx Target index in animDataTable (-1 if any empty space will do) + * \return The number of the animDataTable entry after the loaded SEQ data (-1 if error) */ -void loadSeq(const char *resourceName, int16 idx) { +int loadSeq(const char *resourceName, int16 idx) { int16 foundFileIdx = findFileInBundle(resourceName); + if (foundFileIdx < 0) { + return -1; + } + byte *dataPtr = readBundleFile(foundFileIdx); int entry = idx < 0 ? emptyAnimSpace() : idx; animDataTable[entry].load(dataPtr+0x16, ANIM_RAW, partBuffer[foundFileIdx].unpackedSize-0x16, 1, foundFileIdx, 0, currentPartName); free(dataPtr); + return entry + 1; } -void loadResource(const char *resourceName) { - /* byte isMask = 0; */ - /* byte isSpl = 0; */ - +/*! \brief Load a resource into animDataTable + * \param resourceName Resource's filename + * \param idx Target index in animDataTable (-1 if any empty space will do) + * \return The number of the animDataTable entry after the loaded resource (-1 if error) + * \todo Implement loading of all resource types + */ +int loadResource(const char *resourceName, int16 idx) { + int result = -1; // Return an error by default if (strstr(resourceName, ".SPL")) { - loadSpl(resourceName, -1); - return; + result = loadSpl(resourceName, idx); } else if (strstr(resourceName, ".MSK")) { - loadMsk(resourceName); - return; + result = loadMsk(resourceName, idx); } else if (strstr(resourceName, ".ANI")) { - loadAni(resourceName); - return; + result = loadAni(resourceName, idx); } else if (strstr(resourceName, ".ANM")) { - loadAni(resourceName); - return; + result = loadAni(resourceName, idx); } else if (strstr(resourceName, ".SET")) { - loadSet(resourceName, -1); - return; + result = loadSet(resourceName, idx); } else if (strstr(resourceName, ".SEQ")) { - loadSeq(resourceName, -1); - return; - } else if (strstr(resourceName, "ECHEC")) { // Echec (French) means failure - exitEngine = 1; - return; - } - - error("loadResource: Cannot determine type for '%s'", resourceName); -} - -/*! \todo There seems to be some additional resource file that is not loaded - */ -void loadAbs(const char *resourceName, uint16 idx) { - /* byte isMask = 0; */ - /* byte isSpl = 0; */ - - if (strstr(resourceName, ".SET")) { - loadSet(resourceName, idx); - return; + result = loadSeq(resourceName, idx); } else if (strstr(resourceName, ".H32")) { - warning("Ignoring file %s (load at %d)", resourceName, idx); - return; - } else if (strstr(resourceName, ".SEQ")) { - loadSeq(resourceName, idx); - return; - } else if (strstr(resourceName, ".SPL")) { - loadSpl(resourceName, idx); - return; + warning("loadResource: Ignoring file '%s' (Load at %d)", resourceName, idx); } else if (strstr(resourceName, ".AMI")) { - warning("Ignoring file %s (load at %d)", resourceName, idx); - return; - } else if (strstr(resourceName, ".ANI")) { - warning("Ignoring file %s (load at %d)", resourceName, idx); - return; + warning("loadResource: Ignoring file '%s' (Load at %d)", resourceName, idx); + } else if (strstr(resourceName, "ECHEC")) { // Echec (French) means failure + exitEngine = 1; + } else { + error("loadResource: Cannot determine type for '%s'", resourceName); } - error("loadAbs: Cannot determine type for '%s'", resourceName); + return result; } /*! \brief Load animDataTable from save @@ -776,17 +778,9 @@ void loadAbs(const char *resourceName, uint16 idx) { * at a time. */ void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGameFormat saveGameFormat) { - int16 currentAnim, foundFileIdx; - int8 isMask = 0, isSpl = 0; - byte *dataPtr, *ptr; - char *animName, part[256]; - byte transparentColor = 0; - AnimHeaderStruct animHeader; - + int16 currentAnim, foundFileIdx, frame; + char *animName, part[256], name[10]; uint16 width, height, bpp, var1; - int16 frame; - char name[10]; - int type; strcpy(part, currentPartName); @@ -795,11 +789,8 @@ void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGam const int entrySize = ((saveGameFormat == ANIMSIZE_23) ? 23 : 30); const int fileStartPos = fHandle.pos(); - for (currentAnim = 0; currentAnim < NUM_MAX_ANIMDATA; currentAnim += animHeader.numFrames) { - // Initialize the number of frames variable to a sane number. - // This is needed when using continue later in this function. - animHeader.numFrames = 1; - + currentAnim = 0; + while (currentAnim < NUM_MAX_ANIMDATA) { // Seek to the start of the current animation's entry fHandle.seek(fileStartPos + currentAnim * entrySize); // Read in the current animation entry @@ -826,6 +817,7 @@ void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGam // Don't try to load invalid entries. if (foundFileIdx < 0 || !validPtr) { + currentAnim++; // Jump over the invalid entry continue; } @@ -836,52 +828,10 @@ void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGam } animName = partBuffer[foundFileIdx].partName; - ptr = dataPtr = readBundleFile(foundFileIdx); - - // isSpl and isMask are mutually exclusive cases - isSpl = (strstr(animName, ".SPL")) ? 1 : 0; - isMask = (strstr(animName, ".MSK")) ? 1 : 0; - - if (isSpl) { - width = (uint16) partBuffer[foundFileIdx].unpackedSize; - height = 1; - animHeader.numFrames = 1; - type = ANIM_RAW; - } else { - Common::MemoryReadStream readS(ptr, 0x16); - loadAnimHeader(animHeader, readS); - ptr += 0x16; - - width = animHeader.frameWidth; - height = animHeader.frameHeight; - - if (isMask) { - type = ANIM_MASK; - } else { - type = ANIM_MASKSPRITE; - } - } - - loadRelatedPalette(animName); - transparentColor = getAnimTransparentColor(animName); - // Make sure we load at least one frame and also that we - // don't overflow the animDataTable by writing beyond its end. - animHeader.numFrames = CLIP<uint16>(animHeader.numFrames, 1, NUM_MAX_ANIMDATA - currentAnim); - - // Load the frames - for (frame = 0; frame < animHeader.numFrames; frame++) { - // special case transparency handling - if (!strcmp(animName, "L2202.ANI")) { - transparentColor = (frame < 2) ? 0 : 7; - } else if (!strcmp(animName, "L4601.ANI")) { - transparentColor = (frame < 1) ? 0xE : 0; - } - - // Load a single frame - animDataTable[currentAnim + frame].load(ptr + frame * width * height, type, width, height, foundFileIdx, frame, name, transparentColor); - } - - free(dataPtr); + loadRelatedPalette(animName); // Is this for Future Wars only? + const int16 prevAnim = currentAnim; + currentAnim = loadResource(animName, currentAnim); + assert(currentAnim > prevAnim); // Make sure we advance forward } loadPart(part); diff --git a/engines/cine/anim.h b/engines/cine/anim.h index b0ce55f7ee..8b1541eb3f 100644 --- a/engines/cine/anim.h +++ b/engines/cine/anim.h @@ -150,12 +150,11 @@ public: #define NUM_MAX_ANIMDATA 255 -extern AnimData animDataTable[NUM_MAX_ANIMDATA]; +extern Common::Array<AnimData> animDataTable; void freeAnimDataTable(void); void freeAnimDataRange(byte startIdx, byte numIdx); -void loadResource(const char *resourceName); -void loadAbs(const char *resourceName, uint16 idx); +int loadResource(const char *resourceName, int16 idx = -1); void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGameFormat saveGameFormat); void generateMask(const byte *sprite, byte *mask, uint16 size, byte transparency); diff --git a/engines/cine/bg.cpp b/engines/cine/bg.cpp index 2a4e7f0ab1..45bfae7925 100644 --- a/engines/cine/bg.cpp +++ b/engines/cine/bg.cpp @@ -56,7 +56,7 @@ byte loadCtFW(const char *ctName) { header[i] = readS.readUint16BE(); } - gfxConvertSpriteToRaw(page3Raw, ptr + 0x80, 160, 200); + gfxConvertSpriteToRaw(collisionPage, ptr + 0x80, 160, 200); free(dataPtr); return 0; @@ -74,10 +74,10 @@ byte loadCtOS(const char *ctName) { ptr += 2; if (bpp == 8) { - memcpy(page3Raw, ptr + 256 * 3, 320 * 200); + memcpy(collisionPage, ptr + 256 * 3, 320 * 200); renderer->loadCt256(ptr, ctName); } else { - gfxConvertSpriteToRaw(page3Raw, ptr + 32, 160, 200); + gfxConvertSpriteToRaw(collisionPage, ptr + 32, 160, 200); renderer->loadCt16(ptr, ctName); } diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index f6778b6457..9eb751835e 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -57,6 +57,10 @@ CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) : Eng // Setup mixer _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); + // Use music volume for plain sound types (At least the Adlib player uses a plain sound type + // so previously the music and sfx volume controls didn't affect it at all). + // FIXME: Make Adlib player differentiate between playing sound effects and music and remove this. + _mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, ConfMan.getInt("music_volume")); g_cine = this; @@ -65,14 +69,9 @@ CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) : Eng CineEngine::~CineEngine() { if (g_cine->getGameType() == Cine::GType_OS) { - freePoldatDat(); freeErrmessDat(); } Common::clearAllSpecialDebugLevels(); - - free(palPtr); - free(partBuffer); - free(textDataPtr); } int CineEngine::init() { @@ -100,13 +99,43 @@ int CineEngine::go() { mainLoop(1); delete renderer; - delete[] page3Raw; + delete[] collisionPage; delete g_sound; return 0; } +int CineEngine::getTimerDelay() const { + return (10923000 * _timerDelayMultiplier) / 1193180; +} + +/*! \brief Modify game speed + * \param speedChange Negative values slow game down, positive values speed it up, zero does nothing + * \return Timer delay multiplier's value after the game speed change + */ +int CineEngine::modifyGameSpeed(int speedChange) { + // If we want more speed we decrement the timer delay multiplier and vice versa. + _timerDelayMultiplier = CLIP(_timerDelayMultiplier - speedChange, 1, 50); + return _timerDelayMultiplier; +} void CineEngine::initialize() { + // Resize object table to its correct size and reset all its elements + objectTable.resize(NUM_MAX_OBJECT); + resetObjectTable(); + + // Resize animation data table to its correct size and reset all its elements + animDataTable.resize(NUM_MAX_ANIMDATA); + freeAnimDataTable(); + + // Resize zone data table to its correct size and reset all its elements + zoneData.resize(NUM_MAX_ZONE); + Common::set_to(zoneData.begin(), zoneData.end(), 0); + + // Resize zone query table to its correct size and reset all its elements + zoneQuery.resize(NUM_MAX_ZONE); + Common::set_to(zoneQuery.begin(), zoneQuery.end(), 0); + + _timerDelayMultiplier = 12; // Set default speed setupOpcodes(); initLanguage(g_cine->getLanguage()); @@ -117,16 +146,17 @@ void CineEngine::initialize() { renderer = new FWRenderer; } - page3Raw = new byte[320 * 200]; - textDataPtr = (byte *)malloc(8000); + collisionPage = new byte[320 * 200]; - partBuffer = (PartBuffer *)malloc(NUM_MAX_PARTDATA * sizeof(PartBuffer)); + // Clear part buffer as there's nothing loaded into it yet. + // Its size will change when loading data into it with the loadPart function. + partBuffer.clear(); if (g_cine->getGameType() == Cine::GType_OS) { readVolCnf(); } - loadTextData("texte.dat", textDataPtr); + loadTextData("texte.dat"); if (g_cine->getGameType() == Cine::GType_OS && !(g_cine->getFeatures() & GF_DEMO)) { loadPoldatDat("poldat.dat"); @@ -142,8 +172,7 @@ void CineEngine::initialize() { freeAnimDataTable(); overlayList.clear(); messageTable.clear(); - - memset(objectTable, 0, sizeof(objectTable)); + resetObjectTable(); var8 = 0; diff --git a/engines/cine/cine.h b/engines/cine/cine.h index eaae555812..6011036eb1 100644 --- a/engines/cine/cine.h +++ b/engines/cine/cine.h @@ -59,7 +59,8 @@ enum CineGameType { enum CineGameFeatures { GF_CD = 1 << 0, GF_DEMO = 1 << 1, - GF_ALT_FONT = 1 << 2 + GF_ALT_FONT = 1 << 2, + GF_CRYPTED_BOOT_PRC = 1 << 3 }; struct CINEGameDescription; @@ -86,6 +87,8 @@ public: bool loadSaveDirectory(void); void makeSystemMenu(void); + int modifyGameSpeed(int speedChange); + int getTimerDelay() const; const CINEGameDescription *_gameDescription; Common::File _partFileHandle; @@ -109,6 +112,7 @@ private: void readVolCnf(); bool _preLoad; + int _timerDelayMultiplier; }; extern CineEngine *g_cine; diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp index 8c940bcfd4..b15f30c35c 100644 --- a/engines/cine/detection.cpp +++ b/engines/cine/detection.cpp @@ -76,6 +76,25 @@ static const CINEGameDescription gameDescriptions[] = { 0, }, + // This is a CD version of Future Wars published by Sony. + // This version has a crypted AUTO00.PRC. + { + { + "fw", + "Sony CD version", + { + { "AUTO00.PRC", 0, "4fe1e7930b38e3c63f0f2474d471bf8f", -1}, + { "PART01", 0, "61d003202d301c29dd399acfb1354310", -1}, + { NULL, 0, NULL, 0} + }, + Common::EN_USA, + Common::kPlatformPC, + Common::ADGF_CD + }, + GType_FW, + GF_CD | GF_CRYPTED_BOOT_PRC, + }, + { // This is the version included in the UK "Classic Collection" { @@ -251,6 +270,21 @@ static const CINEGameDescription gameDescriptions[] = { }, { + // This is a 16 color PC version (It came on three 720kB 3.5" disks). + // The protagonist is named John Glames in this version. + { + "os", + "", + AD_ENTRY1("procs1", "9629129b86979fa592c1787385bf3695"), + Common::EN_GRB, + Common::kPlatformPC, + Common::ADGF_NO_FLAGS + }, + GType_OS, + 0, + }, + + { { "os", "", diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp index cbddf0fc59..cb900e8850 100644 --- a/engines/cine/gfx.cpp +++ b/engines/cine/gfx.cpp @@ -31,12 +31,13 @@ #include "common/endian.h" #include "common/system.h" +#include "common/events.h" #include "graphics/cursorman.h" namespace Cine { -byte *page3Raw; +byte *collisionPage; FWRenderer *renderer = NULL; static const byte mouseCursorNormal[] = { @@ -91,7 +92,7 @@ static const byte cursorPalette[] = { */ FWRenderer::FWRenderer() : _background(NULL), _palette(NULL), _cmd(""), _cmdY(0), _messageBg(0), _backBuffer(new byte[_screenSize]), - _activeLowPal(NULL), _changePal(0) { + _activeLowPal(NULL), _changePal(0), _showCollisionPage(false) { assert(_backBuffer); @@ -125,6 +126,7 @@ void FWRenderer::clear() { _cmdY = 0; _messageBg = 0; _changePal = 0; + _showCollisionPage = false; } /*! \brief Draw 1bpp sprite using selected color @@ -225,14 +227,18 @@ void FWRenderer::drawCommand() { * \param x Top left message box corner coordinate * \param y Top left message box corner coordinate * \param width Message box width - * \param color Message box background color + * \param color Message box background color (Or if negative draws only the text) + * \note Negative colors are used in Operation Stealth's timed cutscenes + * (e.g. when first meeting The Movement for the Liberation of Santa Paragua). */ -void FWRenderer::drawMessage(const char *str, int x, int y, int width, byte color) { +void FWRenderer::drawMessage(const char *str, int x, int y, int width, int color) { int i, tx, ty, tw; int line = 0, words = 0, cw = 0; int space = 0, extraSpace = 0; - drawPlainBox(x, y, width, 4, color); + if (color >= 0) { + drawPlainBox(x, y, width, 4, color); + } tx = x + 4; ty = str[0] ? y - 5 : y + 4; tw = width - 8; @@ -252,7 +258,9 @@ void FWRenderer::drawMessage(const char *str, int x, int y, int width, byte colo } ty += 9; - drawPlainBox(x, ty, width, 9, color); + if (color >= 0) { + drawPlainBox(x, ty, width, 9, color); + } tx = x + 4; } @@ -269,33 +277,56 @@ void FWRenderer::drawMessage(const char *str, int x, int y, int width, byte colo } ty += 9; - drawPlainBox(x, ty, width, 4, color); - drawDoubleBorder(x, y, width, ty - y + 4, 2); + if (color >= 0) { + drawPlainBox(x, ty, width, 4, color); + drawDoubleBorder(x, y, width, ty - y + 4, 2); + } } /*! \brief Draw rectangle on screen * \param x Top left corner coordinate * \param y Top left corner coordinate - * \param width Rectangle width - * \param height Rectangle height + * \param width Rectangle width (Negative values draw the box horizontally flipped) + * \param height Rectangle height (Negative values draw the box vertically flipped) * \param color Fill color + * \note An on-screen rectangle's drawn width is always at least one. + * \note An on-screen rectangle's drawn height is always at least one. */ void FWRenderer::drawPlainBox(int x, int y, int width, int height, byte color) { - int i; - byte *dest = _backBuffer + y * 320 + x; + // Make width's and height's absolute values at least one + // which forces this function to always draw something if the + // drawing position is inside screen bounds. This fixes at least + // the showing of the oxygen gauge meter in Operation Stealth's + // first arcade sequence where this function is called with a + // height of zero. + if (width == 0) { + width = 1; + } + if (height == 0) { + height = 1; + } + // Handle horizontally flipped boxes if (width < 0) { - x += width; - width = -width; + width = ABS(width); + x -= width; } + // Handle vertically flipped boxes if (height < 0) { - y += height; - height = -height; + height = ABS(height); + y -= height; } - for (i = 0; i < height; i++) { - memset(dest + i * 320, color, width); + // Clip the rectangle to screen dimensions + Common::Rect boxRect(x, y, x + width, y + height); + Common::Rect screenRect(320, 200); + boxRect.clip(screenRect); + + // Draw the filled rectangle + byte *dest = _backBuffer + boxRect.top * 320 + boxRect.left; + for (int i = 0; i < boxRect.height(); i++) { + memset(dest + i * 320, color, boxRect.width()); } } @@ -335,8 +366,8 @@ int FWRenderer::drawChar(char character, int x, int y) { if (character == ' ') { x += 5; - } else if ((width = fontParamTable[(unsigned char)character].characterWidth)) { - idx = fontParamTable[(unsigned char)character].characterIdx; + } else if ((width = g_cine->_textHandler.fontParamTable[(unsigned char)character].characterWidth)) { + idx = g_cine->_textHandler.fontParamTable[(unsigned char)character].characterIdx; drawSpriteRaw(g_cine->_textHandler.textTable[idx][0], g_cine->_textHandler.textTable[idx][1], 16, 8, _backBuffer, x, y); x += width + 1; } @@ -405,7 +436,7 @@ void FWRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { switch (it->type) { // color sprite case 0: - sprite = animDataTable + objectTable[it->objIdx].frame; + sprite = &animDataTable[objectTable[it->objIdx].frame]; len = sprite->_realWidth * sprite->_height; mask = new byte[len]; memcpy(mask, sprite->mask(), len); @@ -422,6 +453,7 @@ void FWRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { _messageLen += messageTable[it->objIdx].size(); drawMessage(messageTable[it->objIdx].c_str(), it->x, it->y, it->width, it->color); + waitForPlayerClick = 1; break; // action failure message @@ -433,12 +465,13 @@ void FWRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { width = width > 300 ? 300 : width; drawMessage(failureMessages[idx], (320 - width) / 2, 80, width, 4); + waitForPlayerClick = 1; break; // bitmap case 4: assert(it->objIdx < NUM_MAX_OBJECT); - obj = objectTable + it->objIdx; + obj = &objectTable[it->objIdx]; if (obj->frame < 0) { return; @@ -480,16 +513,28 @@ void FWRenderer::drawFrame() { blit(); } +/*! + * \brief Turn on or off the showing of the collision page. + * If turned on the blitting routine shows the collision page instead of the back buffer. + * \note Useful for debugging collision page related problems. + */ +void FWRenderer::showCollisionPage(bool state) { + _showCollisionPage = state; +} + /*! \brief Update screen */ void FWRenderer::blit() { - g_system->copyRectToScreen(_backBuffer, 320, 0, 0, 320, 200); + // Show the back buffer or the collision page. Normally the back + // buffer but showing the collision page is useful for debugging. + byte *source = (_showCollisionPage ? collisionPage : _backBuffer); + g_system->copyRectToScreen(source, 320, 0, 0, 320, 200); } /*! \brief Set player command string * \param cmd New command string */ -void FWRenderer::setCommand(const char *cmd) { +void FWRenderer::setCommand(Common::String cmd) { _cmd = cmd; } @@ -617,6 +662,11 @@ void FWRenderer::saveBgNames(Common::OutSaveFile &fHandle) { fHandle.write(_bgName, 13); } +const char *FWRenderer::getBgName(uint idx) const { + assert(idx == 0); + return _bgName; +} + /*! \brief Restore active and backup palette from save * \param fHandle Savefile open for reading */ @@ -985,8 +1035,8 @@ int OSRenderer::drawChar(char character, int x, int y) { if (character == ' ') { x += 5; - } else if ((width = fontParamTable[(unsigned char)character].characterWidth)) { - idx = fontParamTable[(unsigned char)character].characterIdx; + } else if ((width = g_cine->_textHandler.fontParamTable[(unsigned char)character].characterWidth)) { + idx = g_cine->_textHandler.fontParamTable[(unsigned char)character].characterIdx; drawSpriteRaw2(g_cine->_textHandler.textTable[idx][0], 0, 16, 8, _backBuffer, x, y); x += width + 1; } @@ -1011,8 +1061,12 @@ void OSRenderer::drawBackground() { assert(scroll); - memcpy(_backBuffer, main + mainShift, mainSize); - memcpy(_backBuffer + mainSize, scroll, mainShift); + if (mainSize > 0) { // Just a precaution + memcpy(_backBuffer, main + mainShift, mainSize); + } + if (mainShift > 0) { // Just a precaution + memcpy(_backBuffer + mainSize, scroll, mainShift); + } } } @@ -1021,10 +1075,11 @@ void OSRenderer::drawBackground() { * \todo Add handling of type 22 overlays */ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { - int len; + int len, idx, width, height; objectStruct *obj; AnimData *sprite; byte *mask; + byte color; switch (it->type) { // color sprite @@ -1032,7 +1087,7 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { if (objectTable[it->objIdx].frame < 0) { break; } - sprite = animDataTable + objectTable[it->objIdx].frame; + sprite = &animDataTable[objectTable[it->objIdx].frame]; len = sprite->_realWidth * sprite->_height; mask = new byte[len]; generateMask(sprite->data(), mask, len, objectTable[it->objIdx].part); @@ -1041,6 +1096,32 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { delete[] mask; break; + // game message + case 2: + if (it->objIdx >= messageTable.size()) { + return; + } + + _messageLen += messageTable[it->objIdx].size(); + drawMessage(messageTable[it->objIdx].c_str(), it->x, it->y, it->width, it->color); + if (it->color >= 0) { // This test isn't in Future Wars's implementation + waitForPlayerClick = 1; + } + break; + + // action failure message + case 3: + idx = it->objIdx * 4 + g_cine->_rnd.getRandomNumber(3); + len = strlen(failureMessages[idx]); + _messageLen += len; + width = 6 * len + 20; + width = width > 300 ? 300 : width; + + // The used color here differs from Future Wars + drawMessage(failureMessages[idx], (320 - width) / 2, 80, width, _messageBg); + waitForPlayerClick = 1; + break; + // bitmap case 4: if (objectTable[it->objIdx].frame >= 0) { @@ -1051,16 +1132,37 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { // masked background case 20: assert(it->objIdx < NUM_MAX_OBJECT); - obj = objectTable + it->objIdx; - sprite = animDataTable + obj->frame; + var5 = it->x; // A global variable updated here! + obj = &objectTable[it->objIdx]; + sprite = &animDataTable[obj->frame]; - if (obj->frame < 0 || it->x > 8 || !_bgTable[it->x].bg || sprite->_bpp != 1) { + if (obj->frame < 0 || it->x < 0 || it->x > 8 || !_bgTable[it->x].bg || sprite->_bpp != 1) { break; } maskBgOverlay(_bgTable[it->x].bg, sprite->data(), sprite->_realWidth, sprite->_height, _backBuffer, obj->x, obj->y); break; + // FIXME: Implement correct drawing of type 21 overlays. + // Type 21 overlays aren't just filled rectangles, I found their drawing routine + // from Operation Stealth's drawSprite routine. So they're likely some kind of sprites + // and it's just a coincidence that the oxygen meter during the first arcade sequence + // works even somehow currently. I tried the original under DOSBox and the oxygen gauge + // is a long red bar that gets shorter as the air runs out. + case 21: + // A filled rectangle: + case 22: + // TODO: Check it this implementation really works correctly (Some things might be wrong, needs testing). + assert(it->objIdx < NUM_MAX_OBJECT); + obj = &objectTable[it->objIdx]; + color = obj->part & 0x0F; + width = obj->frame; + height = obj->costume; + drawPlainBox(obj->x, obj->y, width, height, color); + debug(5, "renderOverlay: type=%d, x=%d, y=%d, width=%d, height=%d, color=%d", + it->type, obj->x, obj->y, width, height, color); + break; + // something else default: FWRenderer::renderOverlay(it); @@ -1332,6 +1434,11 @@ void OSRenderer::saveBgNames(Common::OutSaveFile &fHandle) { } } +const char *OSRenderer::getBgName(uint idx) const { + assert(idx < 9); + return _bgTable[idx].name; +} + /*! \brief Fade to black * \bug Operation Stealth sometimes seems to fade to black using * transformPalette resulting in double fadeout diff --git a/engines/cine/gfx.h b/engines/cine/gfx.h index 6a3aa1ef89..c07214028c 100644 --- a/engines/cine/gfx.h +++ b/engines/cine/gfx.h @@ -62,13 +62,14 @@ protected: byte *_backBuffer; ///< Screen backbuffer uint16 *_activeLowPal; ///< Active 16 color palette int _changePal; ///< Load active palette to video backend on next frame + bool _showCollisionPage; ///< Should we show the collision page instead of the back buffer? Used for debugging. void fillSprite(const objectStruct &obj, uint8 color = 0); void drawMaskedSprite(const objectStruct &obj, const byte *mask); virtual void drawSprite(const objectStruct &obj); void drawCommand(); - void drawMessage(const char *str, int x, int y, int width, byte color); + void drawMessage(const char *str, int x, int y, int width, int color); void drawPlainBox(int x, int y, int width, int height, byte color); void drawBorder(int x, int y, int width, int height, byte color); void drawDoubleBorder(int x, int y, int width, int height, byte color); @@ -94,7 +95,7 @@ public: void drawFrame(); void blit(); - void setCommand(const char *cmd); + void setCommand(Common::String cmd); virtual void incrustMask(const objectStruct &obj, uint8 color = 0); virtual void incrustSprite(const objectStruct &obj); @@ -111,6 +112,7 @@ public: virtual uint getScroll() const; virtual void removeBg(unsigned int idx); virtual void saveBgNames(Common::OutSaveFile &fHandle); + virtual const char *getBgName(uint idx = 0) const; virtual void refreshPalette(); virtual void reloadPalette(); @@ -123,6 +125,7 @@ public: void drawInputBox(const char *info, const char *input, int cursor, int x, int y, int width); virtual void fadeToBlack(); + void showCollisionPage(bool state); }; /*! \brief Operation Stealth renderer @@ -168,6 +171,7 @@ public: uint getScroll() const; void removeBg(unsigned int idx); void saveBgNames(Common::OutSaveFile &fHandle); + const char *getBgName(uint idx = 0) const; void refreshPalette(); void reloadPalette(); @@ -181,7 +185,7 @@ public: void gfxDrawSprite(byte *src4, uint16 sw, uint16 sh, byte *dst4, int16 sx, int16 sy); -extern byte *page3Raw; +extern byte *collisionPage; extern FWRenderer *renderer; void setMouseCursor(int cursor); diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp index e5e670c973..e2402a4c8d 100644 --- a/engines/cine/main_loop.cpp +++ b/engines/cine/main_loop.cpp @@ -125,11 +125,74 @@ static void processEvent(Common::Event &event) { g_cine->makeSystemMenu(); } break; + case Common::KEYCODE_F11: + renderer->showCollisionPage(true); + break; + case Common::KEYCODE_MINUS: + case Common::KEYCODE_KP_MINUS: + g_cine->modifyGameSpeed(-1); // Slower + break; + case Common::KEYCODE_PLUS: + case Common::KEYCODE_KP_PLUS: + g_cine->modifyGameSpeed(+1); // Faster + break; + case Common::KEYCODE_LEFT: + case Common::KEYCODE_KP4: + moveUsingKeyboard(-1, 0); // Left + break; + case Common::KEYCODE_RIGHT: + case Common::KEYCODE_KP6: + moveUsingKeyboard(+1, 0); // Right + break; + case Common::KEYCODE_UP: + case Common::KEYCODE_KP8: + moveUsingKeyboard(0, +1); // Up + break; + case Common::KEYCODE_DOWN: + case Common::KEYCODE_KP2: + moveUsingKeyboard(0, -1); // Down + break; + case Common::KEYCODE_KP9: + moveUsingKeyboard(+1, +1); // Up & Right + break; + case Common::KEYCODE_KP7: + moveUsingKeyboard(-1, +1); // Up & Left + break; + case Common::KEYCODE_KP1: + moveUsingKeyboard(-1, -1); // Down & Left + break; + case Common::KEYCODE_KP3: + moveUsingKeyboard(+1, -1); // Down & Right + break; default: lastKeyStroke = event.kbd.keycode; break; } break; + case Common::EVENT_KEYUP: + switch (event.kbd.keycode) { + case Common::KEYCODE_F11: + renderer->showCollisionPage(false); + break; + case Common::KEYCODE_KP5: // Emulated left mouse button click + case Common::KEYCODE_LEFT: // Left + case Common::KEYCODE_KP4: // Left + case Common::KEYCODE_RIGHT: // Right + case Common::KEYCODE_KP6: // Right + case Common::KEYCODE_UP: // Up + case Common::KEYCODE_KP8: // Up + case Common::KEYCODE_DOWN: // Down + case Common::KEYCODE_KP2: // Down + case Common::KEYCODE_KP9: // Up & Right + case Common::KEYCODE_KP7: // Up & Left + case Common::KEYCODE_KP1: // Down & Left + case Common::KEYCODE_KP3: // Down & Right + // Stop ego movement made with keyboard when releasing a known key + moveUsingKeyboard(0, 0); + break; + default: + break; + } default: break; } @@ -138,7 +201,7 @@ static void processEvent(Common::Event &event) { void manageEvents() { Common::EventManager *eventMan = g_system->getEventManager(); - uint32 nextFrame = g_system->getMillis() + kGameTimerDelay * kGameSpeed; + uint32 nextFrame = g_system->getMillis() + g_cine->getTimerDelay(); do { Common::Event event; while (eventMan->pollEvent(event)) { @@ -227,7 +290,7 @@ void CineEngine::mainLoop(int bootScriptIdx) { menuCommandLen = 0; playerCommand = -1; - strcpy(commandBuffer, ""); + commandBuffer = ""; globalVars[VAR_MOUSE_X_POS] = 0; globalVars[VAR_MOUSE_Y_POS] = 0; @@ -247,14 +310,44 @@ void CineEngine::mainLoop(int bootScriptIdx) { } do { + // HACK: Force amount of oxygen left to maximum during Operation Stealth's first arcade sequence. + // This makes it possible to pass the arcade sequence for now. + // FIXME: Remove the hack and make the first arcade sequence normally playable. + if (g_cine->getGameType() == Cine::GType_OS) { + Common::String bgName(renderer->getBgName()); + // Check if the background is one of the three backgrounds + // that are only used during the first arcade sequence. + if (bgName == "28.PI1" || bgName == "29.PI1" || bgName == "30.PI1") { + static const uint oxygenObjNum = 202, maxOxygen = 264; + // Force the amount of oxygen left to the maximum. + objectTable[oxygenObjNum].x = maxOxygen; + } + } + + // HACK: In Operation Stealth after the first arcade sequence jump player's position to avoid getting stuck. + // After the first arcade sequence the player comes up stairs from + // the water in Santa Paragua's downtown in front of the flower shop. + // Previously he was completely stuck after getting up the stairs. + // If the background is the one used in the flower shop scene ("21.PI1") + // and the player is at the exact location after getting up the stairs + // then we just nudge him a tiny bit away from the stairs and voila, he's free! + // Maybe the real problem behind all this is collision data related as it looks + // like there's some boundary right there near position (204, 110) which we can + // jump over by moving the character to (204, 109). The script handling the + // flower shop scene is AIRPORT.PRC's 13th script. + // FIXME: Remove the hack and solve what's really causing the problem in the first place. + if (g_cine->getGameType() == Cine::GType_OS) { + if (scumm_stricmp(renderer->getBgName(), "21.PI1") == 0 && objectTable[1].x == 204 && objectTable[1].y == 110) { + objectTable[1].y--; // Move the player character upward on-screen by one pixel + } + } + stopMusicAfterFadeOut(); di = executePlayerInput(); // Clear the zoneQuery table (Operation Stealth specific) if (g_cine->getGameType() == Cine::GType_OS) { - for (uint i = 0; i < NUM_MAX_ZONE; i++) { - zoneQuery[i] = 0; - } + Common::set_to(zoneQuery.begin(), zoneQuery.end(), 0); } if (g_cine->getGameType() == Cine::GType_OS) { @@ -279,6 +372,11 @@ void CineEngine::mainLoop(int bootScriptIdx) { renderer->drawFrame(); } + // NOTE: In the original Future Wars and Operation Stealth messages + // were removed when running the drawOverlays function which is + // currently called from the renderer's drawFrame function. + removeMessages(); + if (waitForPlayerClick) { playerAction = false; @@ -308,8 +406,6 @@ void CineEngine::mainLoop(int bootScriptIdx) { } while (mouseButton != 0); waitForPlayerClick = 0; - - removeMessages(); } if (checkForPendingDataLoadSwitch) { diff --git a/engines/cine/main_loop.h b/engines/cine/main_loop.h index a2f828fd34..c729b324ca 100644 --- a/engines/cine/main_loop.h +++ b/engines/cine/main_loop.h @@ -28,11 +28,6 @@ namespace Cine { -enum { - kGameTimerDelay = 1000 / (1193180 / 10923), - kGameSpeed = 12 -}; - void mainLoop(int bootScriptIdx); void manageEvents(); diff --git a/engines/cine/msg.cpp b/engines/cine/msg.cpp index 55eb627309..c826db3bf3 100644 --- a/engines/cine/msg.cpp +++ b/engines/cine/msg.cpp @@ -34,29 +34,40 @@ namespace Cine { Common::StringList messageTable; void loadMsg(char *pMsgName) { - int i, count, len; - byte *ptr, *dataPtr; - const char *messagePtr; + uint32 sourceSize; checkDataDisk(-1); - messageTable.clear(); - - ptr = dataPtr = readBundleFile(findFileInBundle(pMsgName)); + byte *dataPtr = readBundleFile(findFileInBundle(pMsgName), &sourceSize); setMouseCursor(MOUSE_CURSOR_DISK); - count = READ_BE_UINT16(ptr); - ptr += 2; - - messagePtr = (const char*)(ptr + 2 * count); - - for (i = 0; i < count; i++) { - len = READ_BE_UINT16(ptr); - ptr += 2; - - messageTable.push_back(messagePtr); - messagePtr += len; + uint count = READ_BE_UINT16(dataPtr); + uint messageLenPos = 2; + uint messageDataPos = messageLenPos + 2 * count; + + // Read in the messages + for (uint i = 0; i < count; i++) { + // Read message's length + uint messageLen = READ_BE_UINT16(dataPtr + messageLenPos); + messageLenPos += 2; + + // Store the read message. + // This code works around input data that has empty strings residing outside the input + // buffer (e.g. message indexes 58-254 in BATEAU.MSG in PROCS08 in Operation Stealth). + if (messageDataPos < sourceSize) { + messageTable.push_back((const char *)(dataPtr + messageDataPos)); + } else { + if (messageLen > 0) { // Only warn about overflowing non-empty strings + warning("loadMsg(%s): message (%d. / %d) is overflowing the input buffer. Replacing it with an empty string", pMsgName, i + 1, count); + } else { + debugC(5, kCineDebugPart, "loadMsg(%s): empty message (%d. / %d) resides outside input buffer", pMsgName, i + 1, count); + } + // Message resides outside the input buffer so we replace it with an empty string + messageTable.push_back(""); + } + // Jump to the next message + messageDataPos += messageLen; } free(dataPtr); diff --git a/engines/cine/object.cpp b/engines/cine/object.cpp index c02e01c8ce..9781975f7c 100644 --- a/engines/cine/object.cpp +++ b/engines/cine/object.cpp @@ -35,9 +35,16 @@ namespace Cine { -objectStruct objectTable[NUM_MAX_OBJECT]; +Common::Array<objectStruct> objectTable; Common::List<overlay> overlayList; +/*! \brief Resets all elements in the object table. */ +void resetObjectTable() { + for (Common::Array<objectStruct>::iterator it = objectTable.begin(); it != objectTable.end(); it++) { + it->clear(); + } +} + void loadObject(char *pObjectName) { uint16 numEntry; uint16 entrySize; diff --git a/engines/cine/object.h b/engines/cine/object.h index 7ad65eb75f..3bf6cdcc42 100644 --- a/engines/cine/object.h +++ b/engines/cine/object.h @@ -38,6 +38,17 @@ struct objectStruct { int16 costume; char name[20]; uint16 part; + + /*! \brief Sets all member variables to zero. */ + void clear() { + this->x = 0; + this->y = 0; + this->mask = 0; + this->frame = 0; + this->costume = 0; + memset(this->name, 0, sizeof(this->name)); + this->part = 0; + } }; struct overlay { @@ -52,10 +63,10 @@ struct overlay { #define NUM_MAX_OBJECT 255 #define NUM_MAX_VAR 255 -extern objectStruct objectTable[NUM_MAX_OBJECT]; - +extern Common::Array<objectStruct> objectTable; extern Common::List<overlay> overlayList; +void resetObjectTable(); void loadObject(char *pObjectName); void setupObject(byte objIdx, uint16 param1, uint16 param2, uint16 param3, uint16 param4); void modifyObjectParam(byte objIdx, byte paramIdx, int16 newValue); diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp index 3e6f5adf40..7f6307c640 100644 --- a/engines/cine/pal.cpp +++ b/engines/cine/pal.cpp @@ -28,10 +28,7 @@ namespace Cine { -uint16 palEntriesCount; - -PalEntry *palPtr = NULL; - +Common::Array<PalEntry> palArray; static byte paletteBuffer1[16]; static byte paletteBuffer2[16]; @@ -41,27 +38,20 @@ void loadPal(const char *fileName) { removeExtention(buffer, fileName); strcat(buffer, ".PAL"); - - if (palPtr) { - free(palPtr); - palPtr = NULL; - } - - palEntriesCount = 0; + palArray.clear(); Common::File palFileHandle; if (!palFileHandle.open(buffer)) error("loadPal(): Cannot open file %s", fileName); - palEntriesCount = palFileHandle.readUint16LE(); + uint16 palEntriesCount = palFileHandle.readUint16LE(); palFileHandle.readUint16LE(); // entry size - palPtr = (PalEntry *)malloc(palEntriesCount * sizeof(PalEntry)); - assert(palPtr); - for (int i = 0; i < palEntriesCount; ++i) { - palFileHandle.read(palPtr[i].name, 10); - palFileHandle.read(palPtr[i].pal1, 16); - palFileHandle.read(palPtr[i].pal2, 16); + palArray.resize(palEntriesCount); + for (uint i = 0; i < palArray.size(); ++i) { + palFileHandle.read(palArray[i].name, 10); + palFileHandle.read(palArray[i].pal1, 16); + palFileHandle.read(palArray[i].pal2, 16); } palFileHandle.close(); } @@ -81,8 +71,8 @@ int16 findPaletteFromName(const char *fileName) { position++; } - for (i = 0; i < palEntriesCount; i++) { - if (!strcmp(buffer, palPtr[i].name)) { + for (i = 0; i < palArray.size(); i++) { + if (!strcmp(buffer, palArray[i].name)) { return i; } } @@ -105,9 +95,9 @@ void loadRelatedPalette(const char *fileName) { paletteBuffer1[i] = paletteBuffer2[i] = (i << 4) + i; } } else { - assert(paletteIndex < palEntriesCount); - memcpy(paletteBuffer1, palPtr[paletteIndex].pal1, 16); - memcpy(paletteBuffer2, palPtr[paletteIndex].pal2, 16); + assert(paletteIndex < (int32)palArray.size()); + memcpy(paletteBuffer1, palArray[paletteIndex].pal1, 16); + memcpy(paletteBuffer2, palArray[paletteIndex].pal2, 16); } } diff --git a/engines/cine/pal.h b/engines/cine/pal.h index 768cf0d27d..819680973c 100644 --- a/engines/cine/pal.h +++ b/engines/cine/pal.h @@ -34,7 +34,7 @@ struct PalEntry { byte pal2[16]; }; -extern PalEntry *palPtr; +extern Common::Array<PalEntry> palArray; void loadPal(const char *fileName); diff --git a/engines/cine/part.cpp b/engines/cine/part.cpp index 88f2dcef52..657471be4e 100644 --- a/engines/cine/part.cpp +++ b/engines/cine/part.cpp @@ -31,13 +31,10 @@ namespace Cine { -uint16 numElementInPart; - -PartBuffer *partBuffer; +Common::Array<PartBuffer> partBuffer; void loadPart(const char *partName) { - memset(partBuffer, 0, sizeof(PartBuffer) * NUM_MAX_PARTDATA); - numElementInPart = 0; + partBuffer.clear(); g_cine->_partFileHandle.close(); @@ -48,13 +45,14 @@ void loadPart(const char *partName) { setMouseCursor(MOUSE_CURSOR_DISK); - numElementInPart = g_cine->_partFileHandle.readUint16BE(); + uint16 numElementInPart = g_cine->_partFileHandle.readUint16BE(); + partBuffer.resize(numElementInPart); g_cine->_partFileHandle.readUint16BE(); // entry size if (currentPartName != partName) strcpy(currentPartName, partName); - for (uint16 i = 0; i < numElementInPart; i++) { + for (uint16 i = 0; i < partBuffer.size(); i++) { g_cine->_partFileHandle.read(partBuffer[i].partName, 14); partBuffer[i].offset = g_cine->_partFileHandle.readUint32BE(); partBuffer[i].packedSize = g_cine->_partFileHandle.readUint32BE(); @@ -190,7 +188,7 @@ void CineEngine::readVolCnf() { int16 findFileInBundle(const char *fileName) { if (g_cine->getGameType() == Cine::GType_OS) { // look first in currently loaded resource file - for (int i = 0; i < numElementInPart; i++) { + for (uint i = 0; i < partBuffer.size(); i++) { if (!scumm_stricmp(fileName, partBuffer[i].partName)) { return i; } @@ -204,7 +202,7 @@ int16 findFileInBundle(const char *fileName) { const char *part = (*it)._value; loadPart(part); } - for (int i = 0; i < numElementInPart; i++) { + for (uint i = 0; i < partBuffer.size(); i++) { if (!scumm_stricmp(fileName, partBuffer[i].partName)) { return i; } @@ -212,26 +210,35 @@ int16 findFileInBundle(const char *fileName) { return -1; } -void readFromPart(int16 idx, byte *dataPtr) { +void readFromPart(int16 idx, byte *dataPtr, uint32 maxSize) { setMouseCursor(MOUSE_CURSOR_DISK); g_cine->_partFileHandle.seek(partBuffer[idx].offset, SEEK_SET); - g_cine->_partFileHandle.read(dataPtr, partBuffer[idx].packedSize); + g_cine->_partFileHandle.read(dataPtr, MIN(partBuffer[idx].packedSize, maxSize)); } -byte *readBundleFile(int16 foundFileIdx) { - assert(foundFileIdx >= 0 && foundFileIdx < numElementInPart); +byte *readBundleFile(int16 foundFileIdx, uint32 *size) { + assert(foundFileIdx >= 0 && foundFileIdx < (int32)partBuffer.size()); + bool error = false; byte *dataPtr = (byte *)calloc(partBuffer[foundFileIdx].unpackedSize, 1); - if (partBuffer[foundFileIdx].unpackedSize != partBuffer[foundFileIdx].packedSize) { - byte *unpackBuffer = (byte *)malloc(partBuffer[foundFileIdx].packedSize); - readFromPart(foundFileIdx, unpackBuffer); + readFromPart(foundFileIdx, dataPtr, partBuffer[foundFileIdx].unpackedSize); + if (partBuffer[foundFileIdx].unpackedSize > partBuffer[foundFileIdx].packedSize) { CineUnpacker cineUnpacker; - if (!cineUnpacker.unpack(unpackBuffer, partBuffer[foundFileIdx].packedSize, dataPtr, partBuffer[foundFileIdx].unpackedSize)) { - warning("Error unpacking '%s' from bundle file '%s'", partBuffer[foundFileIdx].partName, currentPartName); - } - free(unpackBuffer); - } else { - readFromPart(foundFileIdx, dataPtr); + error = !cineUnpacker.unpack(dataPtr, partBuffer[foundFileIdx].packedSize, dataPtr, partBuffer[foundFileIdx].unpackedSize); + } else if (partBuffer[foundFileIdx].unpackedSize < partBuffer[foundFileIdx].packedSize) { + // Unpacked size of a file should never be less than its packed size + error = true; + } else { // partBuffer[foundFileIdx].unpackedSize == partBuffer[foundFileIdx].packedSize + debugC(5, kCineDebugPart, "Loaded non-compressed file '%s' from bundle file '%s'", partBuffer[foundFileIdx].partName, currentPartName); + } + + if (error) { + warning("Error unpacking '%s' from bundle file '%s'", partBuffer[foundFileIdx].partName, currentPartName); + } + + // Set the size variable if a pointer to it has been given + if (size != NULL) { + *size = partBuffer[foundFileIdx].unpackedSize; } return dataPtr; @@ -259,7 +266,13 @@ byte *readBundleSoundFile(const char *entryName, uint32 *size) { return data; } -byte *readFile(const char *filename) { +/*! \brief Rotate byte value to the left by n bits */ +byte rolByte(byte value, uint n) { + n %= 8; + return (byte) ((value << n) | (value >> (8 - n))); +} + +byte *readFile(const char *filename, bool crypted) { Common::File in; in.open(filename); @@ -272,6 +285,16 @@ byte *readFile(const char *filename) { byte *dataPtr = (byte *)malloc(size); in.read(dataPtr, size); + // The Sony published CD version of Future Wars has its + // AUTO00.PRC file's bytes rotated to the right by one. + // So we decode the so called crypting by rotating all + // the bytes to the left by one. + if (crypted) { + for (uint index = 0; index < size; index++) { + dataPtr[index] = rolByte(dataPtr[index], 1); + } + } + return dataPtr; } @@ -284,7 +307,7 @@ void dumpBundle(const char *fileName) { strcpy(tmpPart, currentPartName); loadPart(fileName); - for (int i = 0; i < numElementInPart; i++) { + for (uint i = 0; i < partBuffer.size(); i++) { byte *data = readBundleFile(i); debug(0, "%s", partBuffer[i].partName); diff --git a/engines/cine/part.h b/engines/cine/part.h index 2a979e4879..755f843b4a 100644 --- a/engines/cine/part.h +++ b/engines/cine/part.h @@ -37,18 +37,18 @@ struct PartBuffer { #define NUM_MAX_PARTDATA 255 -extern PartBuffer *partBuffer; +extern Common::Array<PartBuffer> partBuffer; void loadPart(const char *partName); void closePart(void); int16 findFileInBundle(const char *fileName); -void readFromPart(int16 idx, byte *dataPtr); +void readFromPart(int16 idx, byte *dataPtr, uint32 maxSize); -byte *readBundleFile(int16 foundFileIdx); +byte *readBundleFile(int16 foundFileIdx, uint32 *size = NULL); byte *readBundleSoundFile(const char *entryName, uint32 *size = 0); -byte *readFile(const char *filename); +byte *readFile(const char *filename, bool crypted = false); void checkDataDisk(int16 param); diff --git a/engines/cine/prc.cpp b/engines/cine/prc.cpp index 27b1044620..5d789f9b3b 100644 --- a/engines/cine/prc.cpp +++ b/engines/cine/prc.cpp @@ -61,7 +61,7 @@ bool loadPrc(const char *pPrcName) { checkDataDisk(-1); if ((g_cine->getGameType() == Cine::GType_FW) && (!scumm_stricmp(pPrcName, BOOT_PRC_NAME) || !scumm_stricmp(pPrcName, "demo.prc"))) { - scriptPtr = dataPtr = readFile(pPrcName); + scriptPtr = dataPtr = readFile(pPrcName, (g_cine->getFeatures() & GF_CRYPTED_BOOT_PRC) != 0); } else { scriptPtr = dataPtr = readBundleFile(findFileInBundle(pPrcName)); } diff --git a/engines/cine/script_fw.cpp b/engines/cine/script_fw.cpp index e761a0c8e4..97f45488f2 100644 --- a/engines/cine/script_fw.cpp +++ b/engines/cine/script_fw.cpp @@ -1319,6 +1319,7 @@ int FWScript::o1_loadBg() { return 0; } +/*! \brief Load collision table data */ int FWScript::o1_loadCt() { const char *param = getNextString(); @@ -1789,7 +1790,14 @@ int16 checkCollision(int16 objIdx, int16 x, int16 y, int16 numZones, int16 zoneI int16 result = 0; for (int16 i = 0; i < numZones; i++) { - idx = getZoneFromPositionRaw(page3Raw, lx + i, ly, 320); + // Don't try to read data in Operation Stealth if position isn't in 320x200 screen bounds. + if (g_cine->getGameType() == Cine::GType_OS) { + if ((lx + i) < 0 || (lx + i) > 319 || ly < 0 || ly > 199) { + continue; + } + } + + idx = getZoneFromPositionRaw(collisionPage, lx + i, ly, 320); assert(idx >= 0 && idx < NUM_MAX_ZONE); diff --git a/engines/cine/script_os.cpp b/engines/cine/script_os.cpp index a764281758..e8f16ebfcc 100644 --- a/engines/cine/script_os.cpp +++ b/engines/cine/script_os.cpp @@ -365,6 +365,7 @@ FWScript *OSScriptInfo::create(const RawObjectScript &script, int16 index, const // OPERATION STEALTH opcodes // ------------------------------------------------------------------------ +/*! \brief Load collision table data */ int FWScript::o2_loadCt() { const char *param = getNextString(); @@ -636,7 +637,28 @@ int FWScript::o2_loadAbs() { const char *param2 = getNextString(); debugC(5, kCineDebugScript, "Line: %d: loadABS(%d,%s)", _line, param1, param2); - loadAbs(param2, param1); + // Load the resource to an absolute position + if (loadResource(param2, param1) == -1) { // Check if the loading failed + // WORKAROUND: In the 256 color PC version of Operation Stealth when + // walking out of the airport in Santa Paragua to the street the + // player character should be seen as a grey silhuette while walking + // behind the glass. But actually the player character is completely + // invisible when walking behind the glass because the animation files + // used are wrongly loaded. In AIRPORT.PRC's 6th script there are + // calls loadAbs("JOHN01.ANI", 73) and loadAbs("JOHN02.ANI", 37) to + // load the animations involved but no such files are found with the + // game. Corresponding SET-files are found though. As it worked and + // looked fine when I tried loading them instead of the missing ANI + // files I'm doing so here. NOTE: At least the German Amiga version + // of Operation Stealth seems to have all the files involved + // (JOHN01.ANI, JOHN02.ANI, JOHN01.SET and JOHN02.SET). + if (scumm_stricmp(param2, "JOHN01.ANI") == 0 && param1 == 73) { + loadResource("JOHN01.SET", param1); + } else if (scumm_stricmp(param2, "JOHN02.ANI") == 0 && param1 == 37) { + loadResource("JOHN02.SET", param1); + } + } + return 0; } diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp index f26032fe98..3618350476 100644 --- a/engines/cine/sound.cpp +++ b/engines/cine/sound.cpp @@ -604,6 +604,7 @@ bool PCSoundFxPlayer::load(const char *song) { _instrumentsData[i] = NULL; char instrument[64]; + memset(instrument, 0, 64); // Clear the data first memcpy(instrument, _sfxData + 20 + i * 30, 12); instrument[63] = '\0'; diff --git a/engines/cine/texte.cpp b/engines/cine/texte.cpp index e4fd334926..33c16159ec 100644 --- a/engines/cine/texte.cpp +++ b/engines/cine/texte.cpp @@ -29,70 +29,53 @@ namespace Cine { -byte *textDataPtr; - const char **failureMessages; const CommandeType *defaultActionCommand; const CommandeType *systemMenu; const CommandeType *confirmMenu; const char **otherMessages; -const char *commandPrepositionOn; +const char *defaultCommandPreposition; +const char **commandPrepositionTable; void generateMask(const byte *sprite, byte *mask, uint16 size, byte transparency); -void loadTextData(const char *pFileName, byte *pDestinationBuffer) { - Common::File pFileHandle; - uint16 entrySize; - uint16 numEntry; - uint16 i; - byte *tempBuffer; - uint16 dataSize; - - assert(pFileName); - assert(pDestinationBuffer); +void loadTextData(const char *filename) { + Common::File fileHandle; + assert(filename); - if (!pFileHandle.open(pFileName)) - error("loadTextData(): Cannot open file %s", pFileName); + if (!fileHandle.open(filename)) + error("loadTextData(): Cannot open file %s", filename); - entrySize = pFileHandle.readUint16BE(); - numEntry = pFileHandle.readUint16BE(); + uint entrySize = fileHandle.readUint16BE(); + uint numEntry = fileHandle.readUint16BE(); - dataSize = numEntry * entrySize; - pFileHandle.read(pDestinationBuffer, numEntry * entrySize); - - tempBuffer = pDestinationBuffer; + uint sourceSize = numEntry * entrySize; + Common::Array<byte> source; + source.resize(sourceSize); + fileHandle.read(source.begin(), sourceSize); + const int fontHeight = 8; + const int fontWidth = (g_cine->getGameType() == Cine::GType_FW) ? 16 : 8; + uint numCharacters; + uint bytesPerCharacter; if (g_cine->getGameType() == Cine::GType_FW) { - int numCharacters; - if (g_cine->getFeatures() & GF_ALT_FONT) { - numCharacters = 85; - } else { - numCharacters = 78; - } - - dataSize = dataSize / numCharacters; - - loadRelatedPalette(pFileName); - - for (i = 0; i < numCharacters; i++) { - gfxConvertSpriteToRaw(g_cine->_textHandler.textTable[i][0], tempBuffer, 16, 8); - generateMask(g_cine->_textHandler.textTable[i][0], g_cine->_textHandler.textTable[i][1], 16 * 8, 0); - tempBuffer += dataSize; - } + numCharacters = (g_cine->getFeatures() & GF_ALT_FONT) ? 85 : 78; + bytesPerCharacter = sourceSize / numCharacters; // TODO: Check if this could be replaced with fontWidth * fontHeight + loadRelatedPalette(filename); } else { - for (i = 0; i < 90; i++) { - gfxConvertSpriteToRaw(g_cine->_textHandler.textTable[i][0], tempBuffer, 8, 8); - generateMask(g_cine->_textHandler.textTable[i][0], g_cine->_textHandler.textTable[i][1], 8 * 8, 0); - tempBuffer += 0x40; - } + numCharacters = 90; + bytesPerCharacter = fontWidth * fontHeight; } - pFileHandle.close(); -} + for (uint i = 0; i < numCharacters; i++) { + gfxConvertSpriteToRaw(g_cine->_textHandler.textTable[i][0], &source[i * bytesPerCharacter], fontWidth, fontHeight); + generateMask(g_cine->_textHandler.textTable[i][0], g_cine->_textHandler.textTable[i][1], fontWidth * fontHeight, 0); + } -const CharacterEntry *fontParamTable; + fileHandle.close(); +} -const CharacterEntry fontParamTable_standard[256] = { +static const CharacterEntry fontParamTable_standard[NUM_FONT_CHARS] = { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, @@ -129,7 +112,7 @@ const CharacterEntry fontParamTable_standard[256] = { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} }; -const CharacterEntry fontParamTable_alt[256] = { +static const CharacterEntry fontParamTable_alt[NUM_FONT_CHARS] = { { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, @@ -208,6 +191,16 @@ void initLanguage(Common::Language lang) { "NOACTION" }; + static const char *commandPrepositionTable_EN[] = { + "", // EXAMINE + "", // TAKE + "", // INVENTORY + "on", // USE + "", // OPERATE + "to", // SPEAK + "" // NOACTION + }; + static const CommandeType systemMenu_EN[] = { "Pause", "Restart Game", @@ -223,9 +216,8 @@ void initLanguage(Common::Language lang) { "PAUSE", "Loading | %s", "Loading canceled ...", - "No baclup in the drive...", - "Please enter the backup name", - "on" + "No backup in the drive...", + "Please enter the backup name" }; static const CommandeType confirmMenu_EN[] = { @@ -276,6 +268,16 @@ void initLanguage(Common::Language lang) { "NOACTION" }; + static const char *commandPrepositionTable_FR[] = { + "", // EXAMINER + "", // PRENDRE + "", // INVENTAIRE + "sur", // UTILISER + "", // ACTIONNER + "a", // PARLER + "" // NOACTION + }; + static const CommandeType systemMenu_FR[] = { "Pause", "Nouvelle partie", @@ -297,8 +299,7 @@ void initLanguage(Common::Language lang) { "Sauvegarde de | %s", "Sauvegarde Annul\x82""e ...", "Aucune sauvegarde dans le lecteur ...", - "Veuillez entrer le Nom de la Sauvegarde .", - "sur" + "Veuillez entrer le Nom de la Sauvegarde ." }; static const char *failureMessages_ES[] = { @@ -344,6 +345,16 @@ void initLanguage(Common::Language lang) { "NOACTION" }; + static const char *commandPrepositionTable_ES[] = { + "", // EXAMINAR + "", // COGER + "", // INVENTARIO + "donde", // USAR + "", // ACCIONAR + "a", // HABLAR + "" // NOACTION + }; + static const CommandeType systemMenu_ES[] = { "Pause", "Nueva partida", @@ -365,8 +376,7 @@ void initLanguage(Common::Language lang) { "Gabacion de| %s", "Rrabacion anulada", "No hay partidas grabadas en este disco...", - "Teclea el nombre de la partida grabada", - "donde" + "Teclea el nombre de la partida grabada" }; static const char *failureMessages_DE[] = { @@ -403,15 +413,25 @@ void initLanguage(Common::Language lang) { }; static const CommandeType defaultActionCommand_DE[] = { - "Pr\x81""fe", + "Pr\x81""fe", // FIXME? The third letter should be Latin Small Letter U with diaeresis "Nimm", "Bestand", "Benutze", - "Bet\x84tige", + "Bet\x84tige", // FIXME? The fourth letter should be Latin Small Letter A with diaeresis "Sprich", "NOACTION" }; + static const char *commandPrepositionTable_DE[] = { + "", // Prufe + "", // Nimm + "", // Bestand + "gegen", // Benutze + "", // Betatige + "a", // Sprich + "" // NOACTION + }; + static const CommandeType systemMenu_DE[] = { "Pause", "Spiel Neu Starten", @@ -433,8 +453,7 @@ void initLanguage(Common::Language lang) { "Er L\x84""dt | %s", "Ladevorgang Abgebrochen...", "Kein Backup im Laufwerk...", - "Geben Sie den Namen|der Sicherungsdiskette ein", - "gegen" + "Geben Sie den Namen|der Sicherungsdiskette ein" }; static const char *failureMessages_IT[] = { @@ -480,6 +499,16 @@ void initLanguage(Common::Language lang) { "NOACTION" }; + static const char *commandPrepositionTable_IT[] = { + "", // ESAMINARE + "", // PRENDERE + "", // INVENTARIO + "su", // UTILIZZARE + "", // AZIONARE + "a", // PARLARE + "" // NOACTION + }; + static const CommandeType systemMenu_IT[] = { "Pausa", "Parte nuova", @@ -501,8 +530,7 @@ void initLanguage(Common::Language lang) { "Caricamento di| %s", "Caricamento annullato...", "Nessun salvataggio su questo disco...", - "Vogliate accedere con il nome del salvataggio", - "su" + "Vogliate accedere con il nome del salvataggio" }; switch (lang) { @@ -512,7 +540,8 @@ void initLanguage(Common::Language lang) { systemMenu = systemMenu_FR; confirmMenu = confirmMenu_FR; otherMessages = otherMessages_FR; - commandPrepositionOn = otherMessages_FR[7]; + defaultCommandPreposition = commandPrepositionTable_FR[3]; + commandPrepositionTable = commandPrepositionTable_FR; break; case Common::ES_ESP: @@ -521,7 +550,8 @@ void initLanguage(Common::Language lang) { systemMenu = systemMenu_ES; confirmMenu = confirmMenu_ES; otherMessages = otherMessages_ES; - commandPrepositionOn = otherMessages_ES[7]; + defaultCommandPreposition = commandPrepositionTable_ES[3]; + commandPrepositionTable = commandPrepositionTable_ES; break; case Common::DE_DEU: @@ -530,7 +560,8 @@ void initLanguage(Common::Language lang) { systemMenu = systemMenu_DE; confirmMenu = confirmMenu_DE; otherMessages = otherMessages_DE; - commandPrepositionOn = otherMessages_DE[7]; + defaultCommandPreposition = commandPrepositionTable_DE[3]; + commandPrepositionTable = commandPrepositionTable_DE; break; case Common::IT_ITA: @@ -539,7 +570,8 @@ void initLanguage(Common::Language lang) { systemMenu = systemMenu_IT; confirmMenu = confirmMenu_IT; otherMessages = otherMessages_IT; - commandPrepositionOn = otherMessages_IT[7]; + defaultCommandPreposition = commandPrepositionTable_IT[3]; + commandPrepositionTable = commandPrepositionTable_IT; break; default: @@ -548,14 +580,17 @@ void initLanguage(Common::Language lang) { systemMenu = systemMenu_EN; confirmMenu = confirmMenu_EN; otherMessages = otherMessages_EN; - commandPrepositionOn = otherMessages_EN[7]; + defaultCommandPreposition = commandPrepositionTable_EN[3]; + commandPrepositionTable = commandPrepositionTable_EN; break; } if (g_cine->getFeatures() & GF_ALT_FONT) { - fontParamTable = fontParamTable_alt; + // Copy alternative font parameter table to the current font parameter table + Common::copy(fontParamTable_alt, fontParamTable_alt + NUM_FONT_CHARS, g_cine->_textHandler.fontParamTable); } else { - fontParamTable = fontParamTable_standard; + // Copy standard font parameter to the current font parameter table + Common::copy(fontParamTable_standard, fontParamTable_standard + NUM_FONT_CHARS, g_cine->_textHandler.fontParamTable); } } @@ -590,25 +625,16 @@ void loadPoldatDat(const char *fname) { in.open(fname); if (in.isOpen()) { - CharacterEntry *ptr = (CharacterEntry *)malloc(sizeof(CharacterEntry) * 256); - - for (int i = 0; i < 256; i++) { - ptr[i].characterIdx = (int)in.readByte(); - ptr[i].characterWidth = (int)in.readByte(); + for (int i = 0; i < NUM_FONT_CHARS; i++) { + g_cine->_textHandler.fontParamTable[i].characterIdx = in.readByte(); + g_cine->_textHandler.fontParamTable[i].characterWidth = in.readByte(); } - fontParamTable = ptr; - in.close(); } else { error("Cannot open file %s for reading", fname); } } -void freePoldatDat() { - free(const_cast<Cine::CharacterEntry *>(fontParamTable)); - fontParamTable = 0; -} - /*! \brief Fit a substring of text into one line of fixed width text box * \param str Text to fit * \param maxWidth Text box width @@ -633,7 +659,7 @@ int fitLine(const char *str, int maxWidth, int &words, int &width) { bkpWidth = width; bkpLen = i + 1; } else { - charWidth = fontParamTable[(unsigned char)str[i]].characterWidth + 1; + charWidth = g_cine->_textHandler.fontParamTable[(unsigned char)str[i]].characterWidth + 1; width += charWidth; } diff --git a/engines/cine/texte.h b/engines/cine/texte.h index f471c3c49e..bc4beac492 100644 --- a/engines/cine/texte.h +++ b/engines/cine/texte.h @@ -33,10 +33,17 @@ namespace Cine { typedef char CommandeType[20]; -extern byte *textDataPtr; +// Number of characters in a font +#define NUM_FONT_CHARS 256 + +struct CharacterEntry { + byte characterIdx; + byte characterWidth; +}; struct TextHandler { - byte textTable[256][2][16 * 8]; + byte textTable[NUM_FONT_CHARS][2][16 * 8]; + CharacterEntry fontParamTable[NUM_FONT_CHARS]; }; extern const char **failureMessages; @@ -44,20 +51,13 @@ extern const CommandeType *defaultActionCommand; extern const CommandeType *systemMenu; extern const CommandeType *confirmMenu; extern const char **otherMessages; -extern const char *commandPrepositionOn; - -struct CharacterEntry { - byte characterIdx; - byte characterWidth; -}; - -extern const CharacterEntry *fontParamTable; +extern const char *defaultCommandPreposition; +extern const char **commandPrepositionTable; -void loadTextData(const char *pFileName, byte *pDestinationBuffer); +void loadTextData(const char *filename); void loadErrmessDat(const char *fname); void freeErrmessDat(void); void loadPoldatDat(const char *fname); -void freePoldatDat(void); int fitLine(const char *ptr, int maxWidth, int &words, int &width); diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index 2fcb015fcd..e96e03b03c 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -78,7 +78,7 @@ byte _danKeysPressed; int16 playerCommand; -char commandBuffer[80]; +Common::String commandBuffer; char currentPrcName[20]; char currentRelName[20]; char currentObjectName[20]; @@ -95,11 +95,23 @@ int16 saveVar2; byte isInPause = 0; -// TODO: Implement inputVar0's changes in the program -// Currently inputVar0 isn't updated anywhere even though it's used at least in processSeqListElement. -uint16 inputVar0 = 0; -byte inputVar1 = 0; -uint16 inputVar2 = 0, inputVar3 = 0; +/*! \brief Values used by the xMoveKeyb variable */ +enum xMoveKeybEnums { + kKeybMoveCenterX = 0, + kKeybMoveRight = 1, + kKeybMoveLeft = 2 +}; + +/*! \brief Values used by the yMoveKeyb variable */ +enum yMoveKeybEnums { + kKeybMoveCenterY = 0, + kKeybMoveDown = 1, + kKeybMoveUp = 2 +}; + +uint16 xMoveKeyb = kKeybMoveCenterX; +bool egoMovedWithKeyboard = false; +uint16 yMoveKeyb = kKeybMoveCenterY; SelectedObjStruct currentSelectedObject; @@ -114,9 +126,34 @@ CommandeType objectListCommand[20]; int16 objListTab[20]; uint16 exitEngine; -uint16 zoneData[NUM_MAX_ZONE]; -uint16 zoneQuery[NUM_MAX_ZONE]; //!< Only exists in Operation Stealth +Common::Array<uint16> zoneData; +Common::Array<uint16> zoneQuery; //!< Only exists in Operation Stealth + +/*! \brief Move the player character using the keyboard + * \param x Negative values move left, positive right, zero not at all + * \param y Negative values move down, positive up, zero not at all + * NOTE: If both x and y are zero then the character stops + * FIXME: This seems to only work in Operation Stealth. May need code changes somewhere else... + */ +void moveUsingKeyboard(int x, int y) { + if (x > 0) { + xMoveKeyb = kKeybMoveRight; + } else if (x < 0) { + xMoveKeyb = kKeybMoveLeft; + } else { + xMoveKeyb = kKeybMoveCenterX; + } + + if (y > 0) { + yMoveKeyb = kKeybMoveUp; + } else if (y < 0) { + yMoveKeyb = kKeybMoveDown; + } else { + yMoveKeyb = kKeybMoveCenterY; + } + egoMovedWithKeyboard = x || y; +} void stopMusicAfterFadeOut(void) { // if (g_sfxPlayer->_fadeOutCounter != 0 && g_sfxPlayer->_fadeOutCounter < 100) { @@ -141,7 +178,6 @@ void addPlayerCommandMessage(int16 cmd) { tmp.type = 3; overlayList.push_back(tmp); - waitForPlayerClick = 1; } int16 getRelEntryForObject(uint16 param1, uint16 param2, SelectedObjStruct *pSelectedObject) { @@ -189,6 +225,15 @@ int16 getObjectUnderCursor(uint16 x, uint16 y) { frame = ABS((int16)(objectTable[it->objIdx].frame)); part = objectTable[it->objIdx].part; + // Additional case for negative frame values in Operation Stealth + if (g_cine->getGameType() == Cine::GType_OS && objectTable[it->objIdx].frame < 0) { + if ((it->type == 1) && (x >= objX) && (objX + frame >= x) && (y >= objY) && (objY + part >= y)) { + return it->objIdx; + } else { + continue; + } + } + if (it->type == 0) { threshold = animDataTable[frame]._var1; } else { @@ -201,16 +246,19 @@ int16 getObjectUnderCursor(uint16 x, uint16 y) { xdif = x - objX; ydif = y - objY; - if ((xdif < 0) || ((threshold << 4) <= xdif) || (ydif < 0) || (ydif >= height) || !animDataTable[frame].data()) { + if ((xdif < 0) || ((threshold << 4) <= xdif) || (ydif <= 0) || (ydif >= height) || !animDataTable[frame].data()) { continue; } if (g_cine->getGameType() == Cine::GType_OS) { + // This test isn't present in Operation Stealth's PC version's disassembly + // but removing it makes things crash sometimes (e.g. when selecting a verb + // and moving the mouse cursor around the floor in the airport's bathroom). if (xdif >= width) { continue; } - if (it->type == 0 && animDataTable[frame].getColor(xdif, ydif) != part) { + if (it->type == 0 && animDataTable[frame].getColor(xdif, ydif) != (part & 0x0F)) { return it->objIdx; } else if (it->type == 1 && gfxGetBit(xdif, ydif, animDataTable[frame].data(), animDataTable[frame]._width * 4)) { return it->objIdx; @@ -270,6 +318,18 @@ void saveCommandVariables(Common::OutSaveFile &out) { } } +/*! \brief Save the 80 bytes long command buffer padded to that length with zeroes. */ +void saveCommandBuffer(Common::OutSaveFile &out) { + // Let's make sure there's space for the trailing zero + // (That's why we subtract one from the maximum command buffer size here). + uint32 size = MIN<uint32>(commandBuffer.size(), kMaxCommandBufferSize - 1); + out.write(commandBuffer.c_str(), size); + // Write the rest as zeroes (Here we also write the string's trailing zero) + for (uint i = 0; i < kMaxCommandBufferSize - size; i++) { + out.writeByte(0); + } +} + void saveAnimDataTable(Common::OutSaveFile &out) { out.writeUint16BE(NUM_MAX_ANIMDATA); // Entry count out.writeUint16BE(0x1E); // Entry size @@ -570,16 +630,7 @@ void CineEngine::resetEngine() { relTable.clear(); scriptTable.clear(); messageTable.clear(); - - for (int i = 0; i < NUM_MAX_OBJECT; i++) { - objectTable[i].x = 0; - objectTable[i].y = 0; - objectTable[i].part = 0; - objectTable[i].name[0] = 0; - objectTable[i].frame = 0; - objectTable[i].mask = 0; - objectTable[i].costume = 0; - } + resetObjectTable(); globalVars.reset(); @@ -596,7 +647,7 @@ void CineEngine::resetEngine() { playerCommand = -1; isDrawCommandEnabled = 0; - strcpy(commandBuffer, ""); + commandBuffer = ""; globalVars[VAR_MOUSE_X_POS] = 0; globalVars[VAR_MOUSE_Y_POS] = 0; @@ -797,7 +848,10 @@ bool CineEngine::loadTempSaveOS(Common::SeekableReadStream &in) { globalVars.load(in, NUM_MAX_VAR); loadZoneData(in); loadCommandVariables(in); - in.read(commandBuffer, 0x50); + char tempCommandBuffer[kMaxCommandBufferSize]; + in.read(tempCommandBuffer, kMaxCommandBufferSize); + commandBuffer = tempCommandBuffer; + renderer->setCommand(commandBuffer); loadZoneQuery(in); // TODO: Use the loaded string (Current music name (String, 13 bytes)). @@ -934,7 +988,9 @@ bool CineEngine::loadPlainSaveFW(Common::SeekableReadStream &in, CineSaveGameFor loadCommandVariables(in); // At 0x22A9 (i.e. 0x22A1 + 4 * 2): - in.read(commandBuffer, 0x50); + char tempCommandBuffer[kMaxCommandBufferSize]; + in.read(tempCommandBuffer, kMaxCommandBufferSize); + commandBuffer = tempCommandBuffer; renderer->setCommand(commandBuffer); // At 0x22F9 (i.e. 0x22A9 + 0x50): @@ -1082,7 +1138,7 @@ void CineEngine::makeSaveFW(Common::OutSaveFile &out) { globalVars.save(out, NUM_MAX_VAR); saveZoneData(out); saveCommandVariables(out); - out.write(commandBuffer, 0x50); + saveCommandBuffer(out); out.writeUint16BE(renderer->_cmdY); out.writeUint16BE(bgVar0); @@ -1297,7 +1353,7 @@ void CineEngine::makeSaveOS(Common::OutSaveFile &out) { globalVars.save(out, NUM_MAX_VAR); saveZoneData(out); saveCommandVariables(out); - out.write(commandBuffer, 0x50); + saveCommandBuffer(out); saveZoneQuery(out); // FIXME: Save a proper name here, saving an empty string currently. @@ -1360,19 +1416,38 @@ void drawDoubleMessageBox(int16 x, int16 y, int16 width, int16 currentY, int16 c } void processInventory(int16 x, int16 y) { - int16 listSize = buildObjectListCommand(-2); uint16 button; + int menuWidth; + int listSize; + int commandParam; + + if (g_cine->getGameType() == Cine::GType_FW) { + menuWidth = 140; + commandParam = -2; + } else { // Operation Stealth + menuWidth = 160; + commandParam = -3; + } + + listSize = buildObjectListCommand(commandParam); if (!listSize) return; - renderer->drawMenu(objectListCommand, listSize, x, y, 140, -1); + renderer->drawMenu(objectListCommand, listSize, x, y, menuWidth, -1); renderer->blit(); do { manageEvents(); getMouseData(mouseUpdateStatus, &button, &dummyU16, &dummyU16); } while (!button); + + do { + manageEvents(); + getMouseData(mouseUpdateStatus, &button, &dummyU16, &dummyU16); + } while (button); + + // TODO: Both Future Wars and Operation Stealth call showMouse, drawMouse or something similar here. } int16 buildObjectListCommand(int16 param) { @@ -1416,6 +1491,8 @@ int16 selectSubObject(int16 x, int16 y, int16 param) { return objListTab[selectedObject]; } +// TODO: Make separate functions for Future Wars's and Operation Stealth's version of this function, this is getting too messy +// TODO: Add support for using the different prepositions for different verbs (Doesn't work currently) void makeCommandLine(void) { uint16 x, y; @@ -1423,9 +1500,9 @@ void makeCommandLine(void) { commandVar2 = -10; if (playerCommand != -1) { - strcpy(commandBuffer, defaultActionCommand[playerCommand]); + commandBuffer = defaultActionCommand[playerCommand]; } else { - strcpy(commandBuffer, ""); + commandBuffer = ""; } if ((playerCommand != -1) && (choiceResultTable[playerCommand] == 2)) { // need object selection ? @@ -1440,8 +1517,12 @@ void makeCommandLine(void) { } if (si < 0) { - playerCommand = -1; - strcpy(commandBuffer, ""); + if (g_cine->getGameType() == Cine::GType_OS) { + canUseOnObject = 0; + } else { // Future Wars + playerCommand = -1; + commandBuffer = ""; + } } else { if (g_cine->getGameType() == Cine::GType_OS) { if (si >= 8000) { @@ -1454,23 +1535,28 @@ void makeCommandLine(void) { commandVar3[0] = si; commandVar1 = 1; - - strcat(commandBuffer, " "); - strcat(commandBuffer, objectTable[commandVar3[0]].name); - strcat(commandBuffer, " "); - strcat(commandBuffer, commandPrepositionOn); + commandBuffer += " "; + commandBuffer += objectTable[commandVar3[0]].name; + commandBuffer += " "; + if (g_cine->getGameType() == Cine::GType_OS) { + commandBuffer += commandPrepositionTable[playerCommand]; + } else { // Future Wars + commandBuffer += defaultCommandPreposition; + } } - } else { + } + + if (g_cine->getGameType() == Cine::GType_OS || !(playerCommand != -1 && choiceResultTable[playerCommand] == 2)) { if (playerCommand == 2) { getMouseData(mouseUpdateStatus, &dummyU16, &x, &y); processInventory(x, y + 8); playerCommand = -1; commandVar1 = 0; - strcpy(commandBuffer, ""); + commandBuffer = ""; } } - if (g_cine->getGameType() == Cine::GType_OS) { + if (g_cine->getGameType() == Cine::GType_OS && playerCommand != 2) { if (playerCommand != -1 && canUseOnObject != 0) { // call use on sub object int16 si; @@ -1478,34 +1564,38 @@ void makeCommandLine(void) { si = selectSubObject(x, y + 8, -subObjectUseTable[playerCommand]); - if (si) { + if (si >= 0) { if (si >= 8000) { si -= 8000; } commandVar3[commandVar1] = si; - commandVar1++; - - // TODO: add command message draw + commandBuffer += " "; + commandBuffer += objectTable[si].name; } + } - isDrawCommandEnabled = 1; + isDrawCommandEnabled = 1; - if (playerCommand != -1 && choiceResultTable[playerCommand] == commandVar1) { - SelectedObjStruct obj; - obj.idx = commandVar3[0]; - obj.param = commandVar3[1]; - int16 di = getRelEntryForObject(playerCommand, commandVar1, &obj); + if (playerCommand != -1 && choiceResultTable[playerCommand] == commandVar1) { + SelectedObjStruct obj; + obj.idx = commandVar3[0]; + obj.param = commandVar3[1]; + int16 di = getRelEntryForObject(playerCommand, commandVar1, &obj); - if (di != -1) { - runObjectScript(di); - } - } + if (di != -1) { + runObjectScript(di); + } // TODO: else addFailureMessage(playerCommand) + + playerCommand = -1; + commandVar1 = 0; + commandBuffer = ""; } } - if (!disableSystemMenu) { + if (g_cine->getGameType() == Cine::GType_OS || !disableSystemMenu) { + isDrawCommandEnabled = 1; renderer->setCommand(commandBuffer); } } @@ -1678,6 +1768,11 @@ uint16 executePlayerInput(void) { } if (allowPlayerInput) { + if (isDrawCommandEnabled) { + renderer->setCommand(commandBuffer); + isDrawCommandEnabled = 0; + } + getMouseData(mouseUpdateStatus, &mouseButton, &mouseX, &mouseY); while (mouseButton && currentEntry < 200) { @@ -1716,8 +1811,9 @@ uint16 executePlayerInput(void) { commandVar3[commandVar1] = si; commandVar1++; - strcat(commandBuffer, " "); - strcat(commandBuffer, objectTable[si].name); + commandBuffer += " "; + commandBuffer += objectTable[si].name; + isDrawCommandEnabled = 1; @@ -1739,8 +1835,8 @@ uint16 executePlayerInput(void) { playerCommand = -1; commandVar1 = 0; - strcpy(commandBuffer, ""); - renderer->setCommand(""); + commandBuffer = ""; + renderer->setCommand(commandBuffer); } } else { globalVars[VAR_MOUSE_X_POS] = mouseX; @@ -1761,13 +1857,7 @@ uint16 executePlayerInput(void) { if (commandVar2 != objIdx) { if (objIdx != -1) { - char command[256]; - - strcpy(command, commandBuffer); - strcat(command, " "); - strcat(command, objectTable[objIdx].name); - - renderer->setCommand(command); + renderer->setCommand(commandBuffer + " " + objectTable[objIdx].name); } else { isDrawCommandEnabled = 1; } @@ -1858,8 +1948,8 @@ uint16 executePlayerInput(void) { var_2 = 0; } - if (inputVar1 && allowPlayerInput) { // use keyboard - inputVar1 = 0; + if (egoMovedWithKeyboard && allowPlayerInput) { // use keyboard + egoMovedWithKeyboard = false; switch (globalVars[VAR_MOUSE_X_MODE]) { case 1: @@ -1891,8 +1981,8 @@ uint16 executePlayerInput(void) { globalVars[VAR_MOUSE_X_POS] = mouseX; globalVars[VAR_MOUSE_Y_POS] = mouseY; } else { - if (inputVar2) { - if (inputVar2 == 2) { + if (xMoveKeyb) { + if (xMoveKeyb == kKeybMoveLeft) { globalVars[VAR_MOUSE_X_POS] = 1; } else { globalVars[VAR_MOUSE_X_POS] = 320; @@ -1901,8 +1991,8 @@ uint16 executePlayerInput(void) { globalVars[VAR_MOUSE_X_POS] = mouseX; } - if (inputVar3) { - if (inputVar3 == 2) { + if (yMoveKeyb) { + if (yMoveKeyb == kKeybMoveUp) { globalVars[VAR_MOUSE_Y_POS] = 1; } else { globalVars[VAR_MOUSE_Y_POS] = 200; @@ -1943,6 +2033,14 @@ uint16 executePlayerInput(void) { } } + // Update Operation Stealth specific global variables. + // This fixes swimming at the bottom of the ocean after + // having been thrown into it with the girl. + if (g_cine->getGameType() == Cine::GType_OS) { + globalVars[251] = globalVars[VAR_MOUSE_X_POS]; + globalVars[252] = globalVars[VAR_MOUSE_Y_POS]; + } + return var_5E; } @@ -1984,9 +2082,22 @@ void drawSprite(Common::List<overlay>::iterator it, const byte *spritePtr, const void removeMessages() { Common::List<overlay>::iterator it; + bool remove; for (it = overlayList.begin(); it != overlayList.end(); ) { - if (it->type == 2 || it->type == 3) { + if (g_cine->getGameType() == Cine::GType_OS) { + // NOTE: These are really removeOverlay calls that have been deferred. + // In Operation Stealth's disassembly elements are removed from the + // overlay list right in the drawOverlays function (And actually in + // some other places too) and that's where incrementing a the overlay's + // last parameter by one if it's negative and testing it for positivity + // comes from too. + remove = it->type == 3 || (it->type == 2 && (it->color >= 0 || ++it->color >= 0)); + } else { // Future Wars + remove = it->type == 2 || it->type == 3; + } + + if (remove) { it = overlayList.erase(it); } else { ++it; @@ -2069,7 +2180,6 @@ void addMessage(byte param1, int16 param2, int16 param3, int16 param4, int16 par tmp.color = param5; overlayList.push_back(tmp); - waitForPlayerClick = 1; } Common::List<SeqListElement> seqList; @@ -2328,9 +2438,9 @@ void processSeqListElement(SeqListElement &element) { } computeMove1(element, ptr1[4] + x, ptr1[5] + y, param1, param2, x2, y2); } else { - if (inputVar0 && allowPlayerInput) { + if (xMoveKeyb && allowPlayerInput) { int16 adder = param1 + 1; - if (inputVar0 != 1) { + if (xMoveKeyb != kKeybMoveRight) { adder = -adder; } // FIXME: In Operation Stealth's disassembly global variable 251 is used here @@ -2339,9 +2449,9 @@ void processSeqListElement(SeqListElement &element) { globalVars[VAR_MOUSE_X_POS] = globalVars[251] = ptr1[4] + x + adder; } - if (inputVar1 && allowPlayerInput) { + if (yMoveKeyb && allowPlayerInput) { int16 adder = param2 + 1; - if (inputVar1 != 1) { + if (yMoveKeyb != kKeybMoveDown) { adder = -adder; } // TODO: Name currently unnamed global variable 252 diff --git a/engines/cine/various.h b/engines/cine/various.h index d87679ca08..0ee77c1b47 100644 --- a/engines/cine/various.h +++ b/engines/cine/various.h @@ -33,6 +33,9 @@ namespace Cine { +// Maximum size of the command buffer including the trailing zero +#define kMaxCommandBufferSize 80 + void initLanguage(Common::Language lang); int16 makeMenuChoice(const CommandeType commandList[], uint16 height, uint16 X, uint16 Y, uint16 width, bool recheckValue = false); @@ -85,7 +88,7 @@ extern byte _danKeysPressed; extern int16 playerCommand; -extern char commandBuffer[80]; +extern Common::String commandBuffer; extern char currentPrcName[20]; extern char currentRelName[20]; @@ -129,8 +132,8 @@ struct SelectedObjStruct { }; #define NUM_MAX_ZONE 16 -extern uint16 zoneData[NUM_MAX_ZONE]; -extern uint16 zoneQuery[NUM_MAX_ZONE]; +extern Common::Array<uint16> zoneData; +extern Common::Array<uint16> zoneQuery; void addMessage(byte param1, int16 param2, int16 param3, int16 param4, int16 param5); @@ -145,6 +148,7 @@ void processSeqList(void); void resetGfxEntityEntry(uint16 objIdx); bool makeTextEntryMenu(const char *caption, char *string, int strLen, int y); +void moveUsingKeyboard(int x, int y); } // End of namespace Cine |