Commit graph

220 commits

Author SHA1 Message Date
Colin Snover
57db3f7535 SCI: Partially clean up SCI16 video playback code 2017-12-01 18:48:35 -06:00
Colin Snover
2f9967524f SCI: Stop EngineState::wait mutating r_acc
This wait function is used by kernel calls other than kWait, and
those other functions do not mutate r_acc in SSCI.
2017-09-19 19:54:29 -05:00
Colin Snover
029eeeb803 SCI32: Fix Phant2 "auto-save"
The game has a feature where it will automatically create a save
game when you quit the game through the in-game control panel (or
when you die, for some reason).

Unfortunately, due to bad programming, this automatic save would
just overwrite whatever was in save slot 1 (slot 0 in the original
interpreter). Find this attempt to auto-save the game and redirect
it to the auto-save slot. This might not be totally correct, but
it is at least better than destroying a save game.

Fixes Trac#10201.
2017-09-14 20:45:02 -05:00
Colin Snover
57dd79d4dc SCI32: Detect and handle tight loops around kGetEvent
In SSCI, mouse events are received through a hardware interrupt
and the cursor is drawn directly to the graphics card by the
interrupt handler. This allows game scripts to omit calls to
kFrameOut without stopping the mouse cursor from being redrawn
in response to mouse movement.

ScummVM, in contrast, needs to poll for events and submit screen
updates explicitly from the main thread. Submitting screen updates
may block on vsync, which means that this call should really only
be made once per frame, just after the game has finished updating
its back buffer. The closest signal in SCI32 for having completed
drawing a frame is the kFrameOut call, so this is where the
update is submitted (by calling OSystem::updateScreen).

The problem with the approach in ScummVM is that, even though the
mouse position is being updated (by calls to kGetEvent) and drawn
to the backend's back buffer (by GfxCursor32::drawToHardware),
OSystem::updateScreen is never called during game loops that omit
calls to kFrameOut.

This commit introduces a workaround that looks at the number of
times kGetEvent is called between calls to kFrameOut. If the
number of kGetEvent calls is higher than usual (where "usual"
seems to be 0 or 1), we assume that the game is running one of
these tight event loops, and kGetEvent starts calling
OSystem::updateScreen until the next kFrameOut call. We also
then start throttling the calls to kGetEvent to keep CPU usage
down. This fixes at least two such known loops:

1. When interacting with the menu bar at the top of the screen
   in LSL6hires;
2. When restoring a game in Phant2 and sitting on the "click mouse"
   screen.

A similar workaround may also be needed for kGetTime, though loops
around kGetTime should preferably be replaced using a script patch
to call kWait instead.
2017-05-06 19:03:54 -05:00
Colin Snover
c8486395fa SCI: Clean up unnecessary delayed restore flags
_delayedRestoreGame is always set and cleared at the same time as
_delayedRestoreGameId, and _delayedRestoreFromLauncher is written
but never read.
2017-04-22 13:01:35 -05:00
Colin Snover
3303a88139 SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.

1. Fixes audio volumes syncing erroneously to ScummVM in games
   that modify the audio volume without user action (e.g. SCI1.1
   talkies that reduce music volume during speech playback). Now,
   volumes will only be synchronised when the user interacts with
   the game's audio settings. This mechanism works by looking for
   a known volume control object in the stack, and only syncing
   when the control object is present. (Ports and planes were
   researched and found unreliable.)

2. Fixes audio syncing in SCI32 games that do not set game
   volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
   GK2, Phant1, and Torin.

3. Fixes speech/subtitles syncing in SCI32 games that do not use
   global 90, like LSL6hires.

4. Fixes in-game volume controls in SCI32 games reflecting
   outdated audio volumes when a change is made during the game
   from the ScummVM launcher.

5. Fixes SCI32 games that would restore volumes from save games
   or reset volumes on startup, which caused game volumes to be
   out-of-sync with ScummVM when started.

6. ScummVM integration code for audio sync has been abstracted
   into a new GuestAdditions class. This keeps the ScummVM-
   specific code all in one place, with only small hooks into the
   engine code. ScummVM integrated save/load code should probably
   also go here in the future.

Fixes Trac#9700.
2017-04-21 19:00:27 -05:00
Colin Snover
8fd19f84c8 SCI: Deduplicate call origin formatting 2016-09-29 19:39:16 -05:00
Colin Snover
64dc37cfe2 SCI32: Start implementing kSave for SCI32 2016-09-29 19:39:16 -05:00
Colin Snover
3201440d11 SCI: Generalize code for getting information on the current call 2016-09-29 19:39:16 -05:00
Colin Snover
6708b58faf SCI: Remove references to SCI32 features from SCI16 video player 2016-08-19 15:23:10 -05:00
Colin Snover
4d91b458e5 SCI32: Implement kPlayVMD 2016-07-10 09:35:24 -05:00
Willem Jan Palenstijn
d832a23241 SCI32: Add SaveFileRewriteStream for read/write access to files
At least Phantasmagoria and PQ:SWAT require this.

This adds a ReadStream/WriteStream to support this. It replaces
the previous VirtualIndexFile which required reimplementation of
most read/write functions.
2016-07-06 21:06:12 +02:00
Martin Kiewitz
4ebca03534 SCI: Make cursor workaround work properly on OpenPandora
Other platforms, that support analog stick + touch screen at the
same time, are possibly also affected.

Cursor workarounds exist for qfg1vga, qfg3, lsl5 and Island of
Dr. Brain. Those sometimes worked and sometimes didn't on
at least OpenPandora and should be fixed now.
2016-03-05 21:28:09 +01:00
Martin Kiewitz
8588592947 SCI32: Don't do a syncWithScripts on restore from launcher
Causes issues in at least gk1 (option + inventory plane are shown)
Game::restore is not called, when doing restores from launcher,
so in the original interpreter this script code wasn't called
either.

Fixes option + inventory planes etc. being shown right after
restoring via launcher, when original save/load dialogs were
disabled.
2016-03-02 19:34:40 +01:00
Martin Kiewitz
04de7279a1 SCI: Blocking ScummVM auto-save slot 0 for saving
Auto-saving is not used by SCI, but slot 0 is ScummVM "standard"
for auto-saving, that's why it's not available for saving anymore.
Jones still uses slot 0 for saving/restoring (because it's
hardcoded and changing it would break it somewhat)
Deleting + restoring is still possible of couse.
2016-02-05 19:43:48 +01:00
Colin Snover
275db1f7f2 SCI: Remove unused member property _palCycleToColor 2016-01-07 16:35:09 -06:00
Martin Kiewitz
bfba28c335 SCI: implement delayed restore via ScummVM menu
will delay restoring a saved game until the next
 kGetEvent or kWait
also implement aborting playback for kPortrait
 and kShowMovie
2015-04-26 09:08:46 +02:00
Johannes Schickel
8fc7d60feb SCI: Make GPL headers consistent in themselves. 2014-02-18 02:39:37 +01:00
Filippos Karapetis
46ebf37ec9 SCI: Change wording for bug/further info references 2013-04-27 14:04:27 +03:00
Filippos Karapetis
fb215929ef SCI: Some updates to SCI32 kernel graphics functions
- Added a stub for kSetScroll, which sets the target picture immediately
for now
- Added an initial stub of kPalCycle (doesn't work correctly yet)
- Adjusted the signatures of kUpdateLine and kDeleteLine for LSL6
- Unmapped kSetHotRectangles again, with updated information on how it
is used in Phantasmagoria
2012-07-05 13:58:41 +03:00
Filippos Karapetis
f06eb05e8c SCI: Implement kPlayVMD subop 23 (set palette range)
Fixes the wrong palette during video sequences in GK2 and the demo of RAMA
2012-06-23 21:45:18 +03:00
Filippos Karapetis
5a17ea0585 SCI: Move all file-related functions in file.*
This way, there is a clear separation of the actual SCI kernel file
functions and the file classes and wrappers of ScummVM
2012-06-13 12:26:53 +03:00
Filippos Karapetis
aeac51d726 SCI: Implement the file operations needed for the save dialog in Phantasmagoria
Phantasmagoria's scripts keep polling for the existence of the savegame
index file and request to read and write it using the same parameters
when opening it. The index file is closed and reopened for every save
slot, which is slow and can be much slower on non-desktop devices.
Also, the game scripts request seeking in writable streams and request
to expand the existing index file.

To provide this functionality and to reduce constant slow file opening
and closing, this virtual class has been introduced
2012-06-13 12:26:49 +03:00
strangerke
69b1485a22 GIT: Clean up: Suppress SVN tags, now useless 2011-05-12 01:16:22 +02:00
Ori Avtalion
cd6ee0589d JANITORIAL: Format forward declarations to follow convention 2011-04-28 12:20:34 +03:00
md5
4133945850 SCI: Renamed restAdjust to r_rest (like r_acc and r_prev) 2011-03-28 02:23:58 +03:00
Max Horn
4130f66af2 SCI: Remove unused MAX_SAVE_DIR_SIZE 2011-03-18 14:43:52 +01:00
Filippos Karapetis
1528a3d904 SCI: A more efficient solution for bug #3037874 (SCI high CPU usage), which will hopefully
not clash with the speed throttler. This is a more proper fix for bug #3058865, and a
partial fix for bug #3127824

svn-id: r55046
2010-12-26 15:28:02 +00:00
Filippos Karapetis
1d98bf484e SCI: Also reset flags when resetting the video state
svn-id: r55007
2010-12-22 14:19:38 +00:00
Filippos Karapetis
430dc10c49 SCI: VMD video related changes
- VMD videos are now properly started from the associated play subop of the 
kPlayVMD kernel call, and are now properly positioned on screen, and doubled
only if the games require them to be
- Added an enum for VMD video flags

svn-id: r55003
2010-12-22 13:51:35 +00:00
Filippos Karapetis
dca3c8d8bf SCI: Play time related changes
- Added support for savegame play time
- Removed obsolete variables for calculating the play time (EngineState::gameStartTime and Console::_enterTime)
- Renamed some variables to camelCase

svn-id: r53974
2010-10-31 01:45:24 +00:00
Martin Kiewitz
fa7c6a9969 SCI: adding workaround for platform-specific
incompatibility with some sierra games. Some games open a new menu, set mouse cursor within that menu and expect the mouse cursor to be in there and will close it, if it's outside. In case of Wiimote/touch interfaces this logic won't work of course. Fixes island of dr. brain and QfG1VGA on Wii and touch-interface platforms

svn-id: r52474
2010-08-31 15:50:46 +00:00
Martin Kiewitz
ff7476d9f1 SCI: adding virtual lists for qfg-import rooms
now lists import files of all possible games, adds game title before that, removes game prefixes for all files

svn-id: r52441
2010-08-29 15:13:25 +00:00
Martin Kiewitz
45a87ffe3f SCI: some work on replacing sierra restore dialog
svn-id: r52305
2010-08-23 19:10:06 +00:00
Martin Kiewitz
7b8add291e SCI: multiple changes for mother goose vga
which is sci1 and sci1.1
fixes bug #3051145
- separating this mother goose from ega and sci2.1
- adding workaround when restoring saved games in these games, games try to calculate restored savedgameid instead of looking it up, we patch this code out and also set the global to the current savedgameid
- adding workaround for scripts checking savedgameid to be below 13 (our savedgameids begin at 100 now)
- changing official range for savedgameids from 1000->1999 to 100->199, otherwise mother goose would have required much larger patches and this range should be fine even if we replace savedgame dialogs later

svn-id: r52301
2010-08-23 16:33:19 +00:00
Martin Kiewitz
2d76fe0092 SCI: kGameIsRestarting returns 2 when we restored
fixes castle of dr. brain save issue in puzzle room, fixes island of dr. brain save issue when saving in first room

svn-id: r51538
2010-07-31 14:09:42 +00:00
Martin Kiewitz
6ff4dd2d91 SCI: changing how savegame ids are handled internally. Using range 0-999 so that scripts are able to signal us to create new slots, using range 1000-1999 for official slots. fixes lsl6 quicksave overwriting wrong save slots
svn-id: r50831
2010-07-12 22:26:48 +00:00
Martin Kiewitz
df6ead5f93 SCI: calling speed throttler as well from kPalette(setIntensity) if needed - fixes kq6 intro
svn-id: r50794
2010-07-10 22:27:28 +00:00
Filippos Karapetis
bff3e89e48 SCI: Removed the FreeSCI music code
svn-id: r50532
2010-06-30 13:49:05 +00:00
Filippos Karapetis
9f1320d5cc SCI: Made the SoundCommandParser a member of the SciEngine class and removed it from the EngineState, since it's static throughout the course of a game
svn-id: r50484
2010-06-29 09:00:08 +00:00
Filippos Karapetis
048ceb73d3 SCI: Removed the hack for loading games from the launcher from run_vm(). This is now done on startup. This should fix loading from the launcher for LSL6
svn-id: r50406
2010-06-27 23:20:08 +00:00
Filippos Karapetis
cfdbfaa28e SCI: Limit the screen refresh rate to 60fps
svn-id: r49647
2010-06-14 08:36:52 +00:00
Filippos Karapetis
711f679b7f camelCase changes
svn-id: r49570
2010-06-10 11:43:20 +00:00
Filippos Karapetis
93f33c7dab Resolved a FIXME with getSciLanguage(), by creating a separate setter. Also, some camelCase changes
svn-id: r49568
2010-06-10 11:18:10 +00:00
Filippos Karapetis
0ab7c908bb Removed the pointer to the game object from the EngineState class
svn-id: r49562
2010-06-10 08:11:38 +00:00
Filippos Karapetis
536b2614e8 Globals from script 0 are now initialized in script_init_engine(), and are accessed from the relevant variables pointer. Removed direct reference to script 0 from the engine state
svn-id: r49536
2010-06-09 09:17:48 +00:00
Filippos Karapetis
5cb311ee2c Renamed the SciEvent class to EventManager, to separate it from the sciEvent structure, and removed it from the engine state
svn-id: r49534
2010-06-09 07:59:42 +00:00
Filippos Karapetis
10aeb33a42 Merged restAdjust and restAdjustCur, as we don't save the restAdjust modifier inside saved games (rightfully so). Also, the segment manager is now reset inside the main loop, when the game is restarted, not in game_exit()
svn-id: r49533
2010-06-09 07:32:17 +00:00
Filippos Karapetis
9304b5fbeb Merged the restarting_flags, script_abort_flag, and restoring members of the EngineState class into one variable, abortScriptProcessing. The flag kept to signify a game restart has been placed in a boolean, gameWasRestarted
svn-id: r49518
2010-06-08 21:05:46 +00:00
Filippos Karapetis
2c950b321c Fixed regression from commit #49465 - there are in fact two restAdjust variables, the current and global one
svn-id: r49486
2010-06-07 15:14:58 +00:00