Commit Graph

1245 Commits

Author SHA1 Message Date
Walter Agazzi
5039b5f3a6 AGS: Engine: small refactor, rem duplicate list of restricted game options
From upstream c4efd74fd28b31ee786e85a0ecc4a7c1fcb0685a
2023-08-13 10:58:26 +02:00
Walter Agazzi
6ea6675b3c AGS: Engine: tidy some code related to the old save format constants
From upstream fac1a5bed8e84d210a7ac6878133e13c39bde20b
2023-08-13 10:58:26 +02:00
Walter Agazzi
e946f9f99d AGS: Engine: fixed GfxDriverSpriteEvtCallback return value for no room case
From upstream e3bb8a85d2af9c425528eb7a2f16741e2de7b9ab
2023-08-13 10:58:26 +02:00
Walter Agazzi
9e6dfbf258 AGS: Engine: ensure that restricted game options not loaded from save
This fixes occasional problem with save overriding game options that
must not be changed at runtime.
From upstream cf093f3a6ea657a2082edfc08c35cc7650961ab6
2023-08-13 10:58:26 +02:00
Walter Agazzi
7688ff025f AGS: Engine: sync audio in case of scheduled post-script actions
This fixes a case when a clip was ordered to Play right before
a Room change, or similar game mode change, but is delayed
 until after the change occurs.
From upstream d327b06bf5f3d8fff02b454d07560fcd5fc05b24
2023-08-13 10:58:26 +02:00
Walter Agazzi
793a5d6273 AGS: Engine: fixed System.Log() may cause exceptions with wrong format
From upstream ec9c494e391db23d587708cbe20cc6203b503396
2023-08-13 10:58:26 +02:00
Walter Agazzi
d9377bbb63 AGS: Engine: Fix typo in commit b81abc533f508e5831e7ca6d2512c66d506ef09d
loopIterations -> loopCheckIterations
2023-08-13 10:58:26 +02:00
Walter Agazzi
a6edbb5701 AGS: Engine: fixed few game warnings, may fill up the log in some games
Partially from upstream 8b2c97672d179f0ea33890c66bb2baa7131dd3a4
2023-08-13 10:58:26 +02:00
Walter Agazzi
3c4b80e14c AGS: Engine: report missing speech.vox as an "info", since this is optional
From upstream c6b5654a9cc7af05529c76b2a1d8ec3ad75c2c73
2023-08-13 10:58:26 +02:00
Walter Agazzi
4966d2a896 AGS: Engine: apply character's anim volume to portrait animation
+ process frame features for the first portrait frame too.
From upstream 59d4f740001b61af370ec0bca676a24d597f66b2
2023-08-13 10:58:26 +02:00
Walter Agazzi
ff0298be68 AGS: Engine: ignore mod and special keys when skipping speech and wait
Partially from upstream 8079c87ca11fa6b60ed2dd2ce345cda6c384c00b
2023-08-13 10:58:26 +02:00
Walter Agazzi
2e784f5cd0 AGS: Engine: report "voice available" only if Speech dir contains any files
This fixes IsSpeechVoxAvailable() returning positive when game is run from
 the Editor, because Speech folder is always created in the project.
From upstream 0ca660e998e69283484f74818e17e837889e5896
2023-08-13 10:58:26 +02:00
Walter Agazzi
cf90c85cd4 AGS: Engine: fixed crash upon resizing DynamicSprite while it's on screen
The bug is in UpdateSharedDDB(), the short-term texture cache did not test
whether the bitmap resolution is still matching the texture.
From upstream 1537ed77c875bbe660face3c07a3c4843b8bd95a
2023-08-13 10:58:26 +02:00
Walter Agazzi
8d3a2f07ce AGS: Engine: fixed crash upon resizing DynamicSprite while it's on screen
The bug is in UpdateSharedDDB(), the short-term texture cache did not
test whether the bitmap resolution is still matching the texture.
From upstream 1537ed77c875bbe660face3c07a3c4843b8bd95a
2023-08-13 10:58:26 +02:00
Walter Agazzi
a31aac3bf2 AGS: Engine: fixed GUI controls not updated on set OPT_RIGHTLEFTWRITE
From upstream 3360f4a2f279d135d1107dd4fcda2031eed95fae
2023-08-13 10:58:26 +02:00
Walter Agazzi
cd6a6ddc8c AGS; Engine: tidied SetGameOption()
* handle readonly options;
* don't do anything if new value equals old value;
* replace if/else sequence with a switch;
From upstream 2476bc3e517c13ef1abde83fca2e55571bcfff4a
2023-08-13 10:58:26 +02:00
Walter Agazzi
4d28890458 AGS: Engine: fixed loop check... again...
The latest change (c694126) was meant to fix a timeout test logic,
 but it broke the primary loop count check.

The incorrect behavior may be observed when a function with
many loops and `noloopcheck` modifier is called *repeatedly*
from another function. Normally in such case the iterations
passed withing a `noloopcheck` function should not be counted,
but they were.

Apparently the situation cannot be resolved without having 2 counters:
1. One is working all the time, and is used to detect timeouts, as these
may occur both in normal circumstances and in functions with
`noloopcheck` modifier.
2. Second is working only in functions without `noloopcheck` modifier
and is used to do the "stuck in a loop" test.

+ backported small optimization from 3.6.1 branch.
From upstream 70afd47f4879b4eaed5dab664af9e4485055875f
2023-08-13 10:58:26 +02:00
Walter Agazzi
e3bf334921 AGS: Engine: made run_interaction_script() safer in case evt is too high
From upstream 4d7565099652c019d0dcbac5c60f62d735dfae3e
2023-08-13 10:58:26 +02:00
Walter Agazzi
becd3070e8 AGS: Don't remove fallback speech.vox resource from AssetMgr when
changing voicepack

This is a tentative fix for bug #14459. Unfortunately I couldn't find other
games that change the speech pack "on the fly" for further testing
2023-07-19 22:25:42 +02:00
elasota
067626137e AGS: Fix cast of integer to pointer of greater size warning 2023-07-08 22:02:00 +03:00
Walter Agazzi
2b2fa06142 AGS: Inline some library functions + minor changes
This is the only relevant part of upstream commit
a46b97fc3bf7fdff82b84a863a3c0cacc37e7a2b
"Engine: explicitly search for plugins in a game's data dir too"

(ScummVM does not support external plugins)
2023-06-19 22:01:30 +03:00
Walter Agazzi
f0216eafc0 AGS: Engine: fixed Character resetting frame after Move()
Unlike Walk(), Move() is not supposed to animate character, or change frames.
From upstream 5e06350dece778db5e3007596ad2bb6272d7315d
2023-06-19 22:01:30 +03:00
Walter Agazzi
0690f14871 AGS: Engine: ccInstance: do not assert stack if script was aborted
from upstream a55d76322fca302c0668e3ab76f0c122b22341d3
2023-06-19 22:01:30 +03:00
Walter Agazzi
d2336f3b70 AGS: Removed Dustbowl steam username workaround
Return a proper string in ags_steam plugin stub, avoiding script
workaround
2023-06-17 10:14:46 +02:00
Walter Agazzi
c05887d3a4 AGS: Implement GAMEOPTION_NO_SAVE_THUMBNAIL
Added game option flag to disable screenshot/thumbnail creation
on save
2023-06-16 22:47:37 +01:00
Walter Agazzi
5a14999455 AGS: Don't create screenshot for Whispers of a Machine
Disable screenshot workaround for Whispers of a Machine, which autosaves frequently
and causes an annoying flicker
2023-06-14 11:18:53 +02:00
Walter Agazzi
a7d69a40cb AGS: Restore screenshot creation workaround on save
This commit restores the old workaround to force screenshot creation on save,
which was lost among the upstream commits
Fixes bug #14477
2023-06-08 14:40:05 +02:00
Walter Agazzi
2930c0cd8d AGS: Skip video in Donna: Avenger of blood instead of crashing
The game opens with a short video showing the developer logo and
playing some "music", which uses an unsupported codec.
Fixes #13816
2023-06-07 18:13:35 +02:00
Thierry Crozat
fa7e2fee49 AGS: emove include of std/math.h
It should have been part of 4dcde68f4, but I forgot that one file.
2023-06-06 09:21:27 +01:00
Thierry Crozat
22dae3061e AGS: Use C99 isnan instead of std::isnan 2023-06-06 09:00:36 +01:00
Thierry Crozat
4dcde68f4a AGS: Remove unnecessary include of std/math.h 2023-06-06 08:59:58 +01:00
Thierry Crozat
e4be1e25dc AGS: Remove std::numeric_limits replacement
As per bc6b225eed, we can use std::numeric_limits
directly.
2023-06-05 20:18:16 +01:00
Walter Agazzi
efdd2bdf27 AGS: Engine: fixed possible vector idx error in start_character_turning()
This replaces the previous commit, to keep in sync with upstream.
From upstream fca247a28fe2d0609cdbd71ab734929c1c451f1c
2023-06-03 13:13:49 +02:00
Walter Agazzi
e97a4ac06a AGS: Add sanity check for frame in turning animation
Before checking if an animation frame is not used (numFrames < 1),
make sure that the addressed frame is actually present in the loops vector.
Fixes #14491 affecting blackwell2, mountainsofmadness and possibly others
2023-06-01 14:57:50 +02:00
Walter Agazzi
20487eb9f4 AGS: Remap GameDataDirToken to saves directory
Games may attempt to create files in %appdata%, which is not supported.
Redirect to the saves directory, prepending the gameid.
This fixes an immediate crash in "Beat the Buzzer" and "There's Something in
the Pipes", which create .ini files using the iniFile2 module.
2023-05-30 11:51:39 +02:00
Walter Agazzi
4ad5e51016 AGS: Engine: fixed wrong mask upscale for low-res rooms in hi-res game
Instead of "physically" resizing masks we should adjust MaskResolution factor, used when converting coordinates.
This also relates to the situations when the low-res game is run in "upscale" mode (e.g. 320x200 -> 640x400).

This fixes lowered walking speed (#2004).
This is a (hopefully) proper alternative to an older fix 900f47b , and 60d79d1 (see #1383).
From upstream 1b4117a6d2bc9e5a70739d7d73ab77e616320fdb
2023-05-23 13:47:28 +02:00
Thierry Crozat
e9eba6ad20 AGS: Fix regression with translation setting change not saved
When the setting is changed in game (for example in the Options
dialog in Kathy Rain) that change used to be saved in the ScummVM
config file, but this got lost during one of the synchronisation
with upstream code. This commit adds that code back.
2023-05-16 01:12:32 +01:00
D G Turner
12d14752bd AGS: Fix Set But Unused Variable GCC Compiler Warning 2023-05-15 22:33:41 +01:00
Walter Agazzi
6055a5fe5a AGS: Engine: fixed script's timeout check was working incorrectly again
From upstream c694126d77503b9d5528bd95427a8ef6ee48aa6c
2023-05-14 23:04:38 +02:00
Walter Agazzi
b17f679a5f AGS: Engine: ClearSharedDDB() should reset ID of the remaining texture data
This complements the original idea, but also as a side-effect fixes a mistake introduced by another hotfix 38d0dd3.
Because the ID remained intact in the texture, the engine would not know to stop using it and replace after a dynamic sprite was deleted.
From upstream 87cc8e099169b82c2393282921e4d8295af4d0a9
2023-05-14 23:04:38 +02:00
Walter Agazzi
808e365805 AGS: Engine: fixed reset_objcache_for_sprite() resetting wrong char texture
This mistake was introduced early on in 7ed5186 and not fixed still in the later fix 38d0dd3
From upstream 1f27837ef14585d8050a4b49b46faa002f87a881
2023-05-14 23:04:38 +02:00
Walter Agazzi
1bf6a2025f AGS: Engine: improvements to the "timeout" check
* Fixed _lastAliveTs was not reset right after calling sys_evt_process_pending();
this caused events polling called continuously after timeout happened once.
* Set timeout to 60 fps (16.777 ms) instead of random 10ms.
* Do the timeout test only each 1000th loop iteration.
* Few other tiny adjustments in code.

Partially from upstream 60aaef003021fec2f75d4dc6db1b24f0b5d2be65
2023-05-14 23:04:38 +02:00
Walter Agazzi
84dbaf7226 AGS: Engine: fixed Game.StopAudio() fails to remove queue for "all types"
From upstream 8d1751508b7f7d9925931144de1e3cb8ed1d2f51
2023-05-14 23:04:38 +02:00
Walter Agazzi
bb3e0ed9fe AGS: Engine: in DynamicSprite.Create() adjust invalid sizes to min valid
Historically, this function could *happen* to create bitmaps of
0x0 or even -1x-1 sizes and return a valid DynamicSprite
object. Try to ensure the image library is passed valid
parameters in such case, and keep going, for backwards compatibility.
From upstream 82194b261b4649281742c45498a4c34f452fd350
2023-05-14 23:04:38 +02:00
Walter Agazzi
c98dd71ad6 AGS: Engine: when resetting objcache, invalidate spriteID, but not texture
Firstly, this is not necessarily optimal, as the next graphic
assigned to these objects may be of same size, in which case
the texture surface may be reused.

But there's another thing: there've been a bogus behavior in
the AGS, where a dynamic sprite, deleted right before the
room's exit transition, was still displayed for room objects (and
everything else really).
This is because although the sprite was disposed, the image
remained on a texture connected to these objects, at least
until the next object update. But object updates don't run
during room transitions, hence the effect.
From upstream 38d0dd3d7f0d6a4624d1f908f2e8d3c1abfee52a
2023-05-14 23:04:38 +02:00
Walter Agazzi
503e06a1a1 AGS: Engine: picked out basic Animate params check and warn instead of quit
This avoids the Gobliiins5 errors.
From upstream ecb4ae13031c32c2793d1d6a2b2af9f2af7bd911
2023-05-12 12:00:39 +02:00
Eugene Sandulenko
073d89eb66
AGS: Added more debug output 2023-05-03 12:20:13 +02:00
Walter Agazzi
118f6fde0a AGS: When quitting with an alertbox, also print error to console
Minor QoL improvement for easier bug reporting
2023-05-02 18:44:56 +02:00
elasota
5c5b456bfd AGS: Fix int-bool comparison. 2023-04-30 01:05:50 +02:00
Eugene Sandulenko
03460f9469
AGS: Fix bitwise operations 2023-04-29 20:28:20 +02:00
Walter Agazzi
150df392b4 AGS: Engine: fixed <3.6.0 Animate functions default volume parameter
From upstream d8d94b36a3e4e7fe201e93965952698fc6c8da5e
2023-04-29 14:32:39 +02:00
Walter Agazzi
2deb622aa9 AGS: Engine: fixed FadeIn/Out and ShakeScreen prevent audio from starting
From upstream 9634b6d3613f2b066998eaaf853945017f59fa01
2023-04-29 13:11:41 +02:00
Walter Agazzi
7ca114ea49 AGS: Engine: made FadeIn and FadeOut functions look consistent
From upstream 95c4362271734c5cb724b314d7cc555f752e06a8
2023-04-29 13:11:41 +02:00
Walter Agazzi
ea65074e6b AGS: Engine: expanded a compat comment in find_free_audio_channel()
From upstream 4392ef832f131c8fd1e5ded00b095f78cf4815ca
2023-04-29 13:11:41 +02:00
Walter Agazzi
37f97cc8b6 AGS: Engine: add bitness and endianess to the printed engine version
+ Use term "engine" instead of "ACI" (a legacy "Adventure
Creator Interpreter" title).
From upstream eaf298ae3f96db6e37bfd9ac99bad1dff48430ae
2023-04-29 13:11:41 +02:00
Walter Agazzi
f9de999bbe AGS: Engine: Update cursor and dependent "logic" in special game states
Because some things were previously updated during the
render, we also need to explicitly run these whenever we do
not update whole game, but need to keep cursor updated:
* Dialog options;
* blocking Display command
* built-in gui dialogs

From upstream e236f3ee05bb7e1e748fb050c99ba1afa564ec65
2023-04-29 13:11:41 +02:00
Walter Agazzi
72888a7a8c AGS: Engine: move cursor and cursor-over-gui updates to the game update fn
This is necessary for the touch-to-mouse emulation to work
properly (and perhaps true touch controls in the future).
The order of updates is a bit wrong historically, where cursor
position and gui control focus is updated later than the
handling of button events. This means, for example, that if the
cursor was positioned over button in game frame 1, then the
mouse click will only trigger button press not later than the frame 2.

Changes:
* moved "cursor over gui" poll from draw_gui_and_overlays()
to update_cursor_over_gui(), call it in the main game update fn.
* moved update_mouse_cursor() call from
construct_game_screen_overlay() to the game update fn
(renamed to update_cursor_view().
* picked out "cursor over location" trigger out of the "render"
function into update_cursor_over_location(), call it explicitly in
the main game update fn.

Effect on user script callbacks:
* the cursor position (and gui focus) will now be updated prior
to `late_repeatedly_execute_always()` callback. Other callbacks
will not be affected, as their relative order won't change
compared with these updates.

From upstream 23493a681d4f66ae0b1088cddb82241b0bc80dbb
2023-04-29 13:11:41 +02:00
Walter Agazzi
7808fb52e6 AGS: Engine: tidied few remaining old functions in Mouse namespace
* minstalled -> Mouse::GetButtonCount();
* msetgraphpos -> Mouse::SetSysPosition() (internal);
* mgetgraphpos -> Mouse::Poll();
* msetcursorlimit -> merged with Mouse::SetMoveLimit();
* msethotspot -> Mouse::SetHotspot().

From upstream 9211b07f36528776e6fabc34a29405b6d63f6c23
2023-04-29 13:11:41 +02:00
Walter Agazzi
dedc6e009d AGS: Engine: a fix for the queued sounds (PlayQueue) starting with a gap
This is a slightly "hacky" way to fix the queued sounds
starting with a small gap after the previous sound ends.
Because of the new audio playback subsystem in AGS 3.6.0,
the clip start timing changed a little, and there appear to be
small gap, about 1-2 game frame long, between previous and
next sound in queue. The queue in AGS is not implemented
ideally, because it relies on being updated once per game
frame, rather than on an audio thread etc, but this is
something we cannot change easily right now (maybe will
reimplement whole thing later).

This commit does 2 things:
1. Sync logical channels with the audio subsystem also *prior*
to updating queue and other things (crossfade etc). This fixes
a 1 game frame queue delay.
2. Additionally, force queued clips to start 1 extra game
frame earlier, by testing current playback position of active clips.

From upstream e87e3a8d862d39cd6eaab7a6245373fba84c4f78
2023-04-29 13:11:41 +02:00
Walter Agazzi
c537416279 AGS: Engine: renamed WalkArea.Light to PlayerView, matching its real purpose
Apparently, this field was used to store light level of the
walkable area in pre-2.55 engines, prior to introduction of the
Regions.
In current engine, when loading games that old, this value is
copied into Regions for backwards compatibility.
While in newer games it actually stores "player character
view" override.

Renamed update_shadow_areas() into update_player_view(),
and tidied the code for clarity.

From upstream 71e7dc880b4496dd6937cec00a56f0de66137482
2023-04-29 13:11:41 +02:00
Walter Agazzi
2db380f1d1 AGS: Engine: save vsync property when the result is known
From upstream 178a25b4384c3c96998fc6750a3bc0b4ebda3e5d
2023-04-29 13:11:41 +02:00
Walter Agazzi
863a3c485a AGS: Engine: push SDL_KEYUP when simulating a keypress
This fixes internal mod key counter not being reset, which
may break service key combos (alt+ctrl, and so forth).
From upstream 142e1aaa11e7de2995ddfd24c3f1df0ae6c1b072
2023-04-29 13:11:41 +02:00
Walter Agazzi
334e34407b AGS: Engine: try to remember when vsync is unsupported / failed
Partially from upstream 5a867c211abf3e288259e8103b2f948eb354aac4
2023-04-29 13:11:41 +02:00
Walter Agazzi
92f0189a0e AGS: Engine: for renderers, picked out SetVsync into base, add SetVsyncImpl
The base class will now take care of not applying vsync when
 not necessary, saving the new state, and anything else generic.
SetVsyncImpl() virtual method will be overridden by each
renderer to provide actual implementation. This also allows
setting vsync to be forced internally.

Partially from upstream 81aa25ab6af683f52ebf5a5054f59824fa8851fc
2023-04-29 13:11:41 +02:00
Walter Agazzi
430758510e AGS: Engine: center the SDL window ourselves on desktop platforms
This is not implemented and just add a  stub
Partially from upstream 82b19ca27b682c497422ad8eac532ceb88c67e62
2023-04-29 13:11:41 +02:00
Walter Agazzi
a80928712d AGS: Engine: restored --gfxfilter support for explicit scaling multipliers
The graphic mode config has now separate options for
window size, game scaling and filter, but command line is
lagging behind, so all the scaling is still set in `--gfxfilter`.
This is a hotfix for the time being, we shall think this over in
the future, maybe introduce more args.

Partially from upstream a28160b24a2f27b59cbb12a1de358cc9ec9c19ef and
f19043d902ff9a7e7d6478f51093ef3c807dd258
2023-04-29 13:11:41 +02:00
Walter Agazzi
7d7a6c6b4e AGS: Engine: improvements to ValidateWindowSize()
Screen limits are hardcoded in ScummVM's implementation, so this function
does not really validate anything
Partially from upstream cbe729f93c9b204db41ddd1b28c455d4a98ff703
2023-04-29 13:11:41 +02:00
Walter Agazzi
7b3ca8febf AGS: Engine: simplify PlayMP3File asset loading
From upstream 3653e184243e0eb6b559726c6b33b1e55f52d1f4
2023-04-29 13:11:41 +02:00
Walter Agazzi
7133cbfcdb AGS: Engine: fixed room objects with ID >= 100 fail to Animate
This is because of legacy AnimateObject behavior, which treated IDs >= 100
as a command to run AnimateCharacter(ID - 100) instead.

From upstream 8365802092cd3f704aecffe7d08b4d9f65f1f396
2023-04-29 13:11:41 +02:00
Walter Agazzi
a6335f0a8b AGS: Engine: bit more logging when loading a translation
From upstream 528c1374cee8d8e09654dc5d01698984dd29568a
2023-04-29 13:11:41 +02:00
Walter Agazzi
7676b9c23b AGS: Engine: hotfix master volume is not applied after restoring a game
Also restored a check in System_SetVolume(), where it skipped updating a volume if the value
is the same (this was removed unexpectedly when introducing a SDL2-based audio system).

From upstream 8d1772b90105ca5b4b150bfb303781af2ceac1a0
2023-04-29 13:11:41 +02:00
Walter Agazzi
2775d0e3d0 AGS: Engine: a fix for coincidental dynamic sprite replacement in old games
This is a (ugly) backward compatible workaround in game_sprite_deleted().
Apparently there are few games that may rely (either with or without author's intent) on newly
created dynamic sprite being assigned same index as a recently deleted one, which results in
new sprite "secretly" taking place of an old one on the GUI, etc.
One known example is "Kathy Rain" game.

For old games we keep only partial index reset (full cleanup is 3.5.0+).
From upstream e8409920049b2a8859856d3525a8f112227df4df
2023-04-29 13:11:41 +02:00
Walter Agazzi
0cc9cb6d22 AGS: Engine: always rely on absolute mouse coordinates in mgetgraphpos()
Assume that SDL2 devices, custom devices, and event handling unit have prepared a correct absolute mouse coordinates, in correspondence to the mouse settings.
From upstream c63e5e93657f2e525df8f3f5390f74a31a21858d
2023-04-29 13:11:41 +02:00
Walter Agazzi
c23db8fa2c AGS: Engine: removed redundant code from mgetgraphpos()
From upstream 07d72ac3e1c89883c9e9430a22596ac19c3c58b1
2023-04-29 13:11:41 +02:00
Walter Agazzi
6565ca8530 AGS: Engine: allow VSync in windowed mode
From upstream bcf90697ac93080d0edac3e99727041a4e2b461a
2023-04-29 13:11:41 +02:00
Walter Agazzi
6a463caba0 AGS: Add _gamma and RenderTarget variables (not used yet)
These are the only relevant changes from upstream:
62b2f42b53010f9db17a89365d4db73eeb5056d7 and
33a2417f2d63638e87e9a6199b571a7929664722
2023-04-29 13:11:41 +02:00
Walter Agazzi
0a7fba00a5 AGS: Properly implement sprite batches for legacy modes
This completes commit c06dc7dab97ba33d9fcf2edeffe37e8f36e0336a which was only
partial and completely broke the mouse pointer and UI in old games
2023-04-29 13:11:41 +02:00
Walter Agazzi
b554ab3bad AGS: Engine: fixed non-blocking speech disabling interface
Apparently, this is an ancient bug, but it became noticeable
now after some changes to the GUI update logic fixes and
optimizations.

From upstream e069c3f51c08c163df023157e99e14bbcefd317a
2023-04-29 13:11:41 +02:00
Walter Agazzi
9a801a02fd AGS: Engine: fixed preload image does not have a sprite batch
From upstream 84730a4bbfb971855c667241a9a47745f283f12e
2023-04-29 13:11:41 +02:00
Walter Agazzi
e402e69539 AGS: Engine: safety hotfix for render pass without sprite batches
Partially from upstream 7ad4f424f473f480c830faf3f7a2aca4388aa8fe
2023-04-29 13:11:41 +02:00
Walter Agazzi
d025390cfc AGS: Engine: safety hotfix for sprites met before 1st sprite batch
Partially from upstream 8e38f612d8b8fe834bdc8a55bb5ef543e6b45cb8
2023-04-29 13:11:41 +02:00
Walter Agazzi
30214dfb04 AGS: D3D/OGL: safety hotfix which deals with occasional "stray" sprites
Partially from upstream ae559b469fc5dc4b01d3497f5ca13c2961c98c82
2023-04-29 13:11:41 +02:00
Walter Agazzi
a099b5c976 AGS: Engine: define no batch parent as -1, and don't pre-init any batches
Partially from upstream 975e2192bce136d81275c93310d3de200de1bfba
2023-04-29 13:11:41 +02:00
Walter Agazzi
6dcabde06a AGS: Engine: for software drawing, also split room viewport / camera batches
From upstream 5446f80a4c95d4581991a52ea54781820f28244f
2023-04-29 13:11:41 +02:00
Walter Agazzi
3fec7f3d4a AGS: Engine: Software renderer supports parent-child sprite batches
From upstream f4f715f26c83be708da9c7dbfdcb0fa3196624b4
2023-04-29 13:11:41 +02:00
Walter Agazzi
976c757020 AGS: Engine: simplify sprite batches a little
From upstream 362ea919e9ffaf2407299fbf4e7815bc43ceac4c
2023-04-29 13:11:41 +02:00
Walter Agazzi
8ad4d50e07 AGS: Engine: base sprite batches use full global offset (inc main viewport)
This fixes legacy letterbox for Direct3D/OpenGL renderers.
Partially from upstream 29b62232b9c595cc05b5c6872e97544c1204f2b0
2023-04-29 13:11:41 +02:00
Walter Agazzi
a2e62d8391 AGS: Engine: simplified main viewport storage, from Viewport struct to Rect
Can't remember why did I make it so, the Rect is enough for now.
From upstream f7a408d6cea65a5279f3b5b4e980c87bc1e381ca
2023-04-29 13:11:41 +02:00
Walter Agazzi
74f58fd118 AGS: Engine: small fix in SDLRendererGraphicsDriver::RenderToBackBuffer()
From upstream dc22dfcd09f5e29aae8fefbbfe3c6cb0aca97937
2023-04-29 13:11:41 +02:00
Thierry Crozat
fd2bc62037 AGS: Fix crash when playing CLUT8 video in 16bit or 32bit games
The blitting code asserted on the palette pointer as it was not
passed to it.
2023-04-25 21:44:51 +01:00
Thierry Crozat
85b832d02e AGS: Fix wrong color when playing CLUT8 video in CLUT8 games
The palette from the video decoder was ignored, and it was using the
palette from the game instead.
2023-04-25 21:44:51 +01:00
Thierry Crozat
6e05d981b0 AGS: Fix video stretch
The original AGS uses a proportional stretch that preserves the
video aspect ratio, but we were doing a stretch to the full game
screen. As a result if the video and game do not have the same
aspect ratio we were losing the video aspect ratio. This could
for example be seen with the AGDI logo at the start of all the
AGDI games. The games re at 320x200, but the video are 320x160.
Before this commit the video was stretched incorrectly to
320x200.
2023-04-14 01:16:05 +01:00
Thierry Crozat
2808192828 AGS: fixed find_free_audio_channel() incorrect compat fix
From upstream b3f4909.

Fixes a regression from d2b0380 (86564e9 in upstream)  where the extra
channel allowance was added excessively for all cases.

Fixes bug #14353 (crash in unavowed).
2023-03-29 22:02:38 +01:00
Thierry Crozat
42838612d2 AGS: Fix double-free of room cameras surfaces
This fixes a crash in Dreams in a Witch House (bug #14338)
2023-03-27 01:01:55 +01:00
antoniou79
10a5566dab AGS: Fix formatting of debug message
About bad index of audio channel
2023-03-23 13:53:04 +02:00
marius david
9acaed1f89 AGS: auto-detect Linux games based on executable
ags64 (and also ags32) are the name of the engine executable on Linux.
These names seems to be exclusivelly used for that OS.
Fix a bug in Zniw Adventure (GOG, Linux) due to translation path being
different between Linux and Windows.
2023-03-20 00:17:20 +01:00
D G Turner
be309e97eb AGS: Fix GCC Compiler Warnings 2023-03-12 20:58:29 +00:00
Walter Agazzi
07bbbcd233 AGS: Engine: replaced couple more shared_ptr<char> with vector<char>
From upstream 1cccdfea5c1009123de7ba25be72b2757f74d06f
2023-03-12 20:58:28 +00:00
Walter Agazzi
9a4817653c AGS: Engine: resizable flag is necessary for fullscreen app rotation
From upstream 51a7e64efd628e62c73b1b1b8011d22ec83b0c38
2023-03-12 20:58:28 +00:00
Walter Agazzi
15d43b09ad AGS: Common: add AGS_PLATFORM_MOBILE for Android and iOS
Partially from upstream 4404881c6a49e3a74f316998ee46368b00895fc7
2023-03-12 20:58:28 +00:00
Walter Agazzi
9743b0dd6c AGS: Engine: restored GUI draw sort, where equal z is resolved with IDs
NOTE: the code theoretically allows any object to be sorted this
way, but the problem is, the ID sequences are not shared, and
multiple object types may have same IDs.
This is something to consider in the future.
2023-03-12 20:58:28 +00:00
Walter Agazzi
9a469f1e2b AGS: Engine: support fixing up RoomStatuses restored from older save formats
This allows to properly fixup (upgrade) RoomStatus structs
restored from a older format save in an upgraded game.
For example: game was upgraded from 3.4.0 to 3.6.0, but player
tries loading 3.4.0 save. In this situation the engine must know and
keep track of what version each RoomStatus was saved in.
This is necessary, because RoomStatus can only be updated upon
loading a corresponding room file (when entering a room). This
means that multiple RoomStatus objects will be staying in memory
not being upgraded yet, until player enters particular room.

From upstream 205232af5909e0a257494ff404f36003b004ebc4
2023-03-12 20:58:28 +00:00
Walter Agazzi
2daaef2d48 AGS: Engine: updated SavegameVersion (had few cmp changes since last one)
From upstream 84417e8c73815bcd35f4a6812d6f118cfb3acacb
2023-03-12 20:58:28 +00:00
Walter Agazzi
89ea094df1 AGS: Engine: fixed idle_anim_speed after restoring old save in updated game
From upstream 0f19fc3d2b9efbc4eb809032bcb7d60b652e1150
2023-03-12 20:58:28 +00:00
Walter Agazzi
3d91a8835e AGS: Engine: fixed button keeps "mouse over" pic after Visible = false
From upstream dcec61ba9825be21a0d2009a73b2af24df6a912d
2023-03-12 20:58:28 +00:00
Walter Agazzi
50d8eaddcf AGS: Engine: in IAGSEngine::SetVirtualScreen set Stage buffer, not whole VS
When plugin calls SetVirtualScreen (for software renderer), don't
replace whole virtual screen, instead replace only the current
render stage buffer.
This is complementary to the older changes in software renderer,
made during development of AGS 3.5.0, which featured advanced
room viewports and cameras. Since that change, separate render
stages could draw on sub-bitmaps of smaller size.

While IAGSEngine::GetVirtualScreen() was adjusted to follow that
change, and return not the whole virtual screen, but only a "stage
buffer" (which may be a VS sub-bitmap, or an intermediate bitmap
created specifically for this render stage), SetVirtualScreen() was
NOT adjusted accordingly and kept replacing whole VS. As a
result, this discrepancy could cause logical errors, as well as
crashes with plugins that use this API (e.g. original SnowRain
plugin).

The immediate reason of error is that plugin would remember a
pointer returned from GetVirtualScreen (which is a stage buffer),
and then try to set it back with SetVirtualScreen. As a result,
engine's own stage buffer is assigned as a full virtual screen.

From upstream 09143ea7fbf8474f78932116ae1c81ceff4de95a
2023-03-12 20:58:28 +00:00
Walter Agazzi
43723e170a AGS: Engine: in SetMemoryBackBuffer() don't reset batch surfs during render
In ALSoftwareGraphicsDriver:
* Save index of a currently rendered sprite batch (or none, if not inside
a render pass).
* In SetMemoryBackBuffer() don't reset virtual screen subbitmaps
  unless we are outside render pass.
* In InitSpriteBatch() also test if batch's surface is subbitmap to the
  current virtual screen (in case one was replaced, but batch's surface
  stayed).

Partially from upstream 5dd078961020da6478347dac01dea729471333d1
2023-03-12 20:58:28 +00:00
Walter Agazzi
e62a2c3504 AGS: Engine: don't reset batch surfaces in software driver's ResetAllBatches
From upstream 662318d0dc1e877a334e91b1a964a41de2b46573
2023-03-12 20:58:28 +00:00
Walter Agazzi
1bc1c49dbf AGS: Engine: fixed missing channels after restoring old save in updated game
From upstream d5ded80f8219b1f04e484c369d647bbc9ed8edd8
2023-03-12 20:58:28 +00:00
Walter Agazzi
f0c18ccacb AGS: Engine: fixed GUI sorting for cases when ZOrder is equal
Was broken by fcc873e
From upstream ff210b2ce50cea0e903cd1d09fa7ad1734a862b0
2023-03-12 20:58:28 +00:00
Walter Agazzi
7b5bcb881a AGS: Engine: fail when reading game data should return error
From upstream 416c456db0b20f5896506f86525faec0a353893f
2023-03-12 20:58:28 +00:00
Walter Agazzi
88a1083e0d AGS: Move strlen out of loops
From upstream b476dfca4b40bc2ca59b7f0fd793543524397ccf
2023-03-12 20:58:28 +00:00
Walter Agazzi
c6864a8a67 AGS: Engine: added _rendSpriteBatch counter to software renderer
From upstream 5d051d614cafe2a4f73cc4399eeb78cb38d8ed2d
2023-03-12 20:58:28 +00:00
Walter Agazzi
1e3bb9c241 AGS: Engine: support optional size and position for gfxdriver's stage screen
This is primarily for backwards compatibility with the older plugins,
that relied only on software drawing.

Previously we added "stage screens" to the hardware-accelerated
graphic drivers (Direct3D/OpenGL), which provide a surface for
plugins to draw upon. If used, these surfaces would then be rendered
as plain sprites in 3D scene at certain place in the sprite sequence.

The remaining problem (left unnoticed) was that the surfaces which
correspond to the two room render callbacks (right after background,
and right after all objects) did not follow the room camera position and
scaling correctly (not all, tbh). This commit addresses these problems by
letting the engine to request certain size and optional position for these
"stage screens" for particular sprite batches.

Partially from upstream 2d43bffc2cb07935ae72d7c5677ad622c8b4d37e
2023-03-12 20:58:28 +00:00
Walter Agazzi
823eda7991 AGS: Engine: renamed "NullSpriteCallback", give more meaningful name
From upstream e3c6f5f0b607b8d3a747fa56bdac723ff833f482
2023-03-12 20:58:28 +00:00
Walter Agazzi
6343759e09 AGS: Engine: changed member names in StageScreen to avoid conflicts
From upstream 874953aea46a23f2ea49ee571cbce28fdc701f25
2023-03-12 20:58:28 +00:00
Walter Agazzi
982abc24f3 AGS: Engine: create raw draw screens only on plugin's demand
This significantly reduces memory usage, as screens will be only
created for sprite batches, during which the plugin requested
memory backbuffer for drawing.
Partially from upstream 1b71780d6e94eca33ee3234fd138213874640ab1
2023-03-12 20:58:28 +00:00
Walter Agazzi
711ca20dd1 AGS: Engine: abort in case failed both to switch and restore gfx mode
This may be a temporary solution, but it's necessary, because otherwise
engine will fail later, with a seemingly unrelated error, which will
be harder to diagnose.
From upstream 902568c4eba9dba4eb762882890c6e8a308683aa
2023-03-12 20:58:28 +00:00
Walter Agazzi
f0887a3b9f AGS: Engine: in gfx drivers record sprite range for each batch
Partially from upstream eaa806927bf4608195fe58de405750836093032c
2023-03-12 20:58:28 +00:00
Walter Agazzi
b828199c25 AGS: Engine: renderers support creating DDB as a render target
Partially from upstream 4c8218e9ca4da7403ff14e45c57584517d2abc2f
2023-03-12 20:58:28 +00:00
Walter Agazzi
48592b9eee AGS: Engine: add screen functions to plugin exports
Reimplemented from upstream 5497c87cc1443d155bd89a76dddf91934b7e0bb5
2023-03-12 20:58:28 +00:00
Walter Agazzi
5a2405d291 AGS: Engine: debug use AppendFmt at send msg and clang-tidy fixes
From upstream 96f0b3d5e216fbba6df3cb47df3d28687b4dd5e4
2023-03-12 20:58:28 +00:00
Walter Agazzi
97d08215b5 AGS: Engine: Use a single function to send messages to editor debugger
From upstream 003243d6c925d176d6e206bed7c1c930952ba2da
2023-03-12 20:58:28 +00:00
Walter Agazzi
7e3ffd0161 AGS: Engine: unswitch loop in Bitmap to Video memory
bmp to video don't test depth per pixel
From upstream 85344c94e2367fe3bb8eb3b9249329c1d1b49f24
2023-03-12 20:58:28 +00:00
Walter Agazzi
b7080efc96 AGS: Engine: for hw renderers split viewport and camera in 2 sprite batches
Partially from upstream 5d6c075013a0c83fb2ad5b58f0313e5e2eb4f728
2023-03-12 20:58:28 +00:00
Walter Agazzi
2359c13d23 AGS: Engine: moved global sprite offset & flip to the parent batch transform
Partially from upstream 76a2a22ebfd5a8513337a64d6d4e857295ee38bc
2023-03-12 20:58:28 +00:00
Walter Agazzi
2b028c586f AGS: Engine: hotfixed BitmapToVideoMem after 6804e9f
From upstream 0b3d4dc8b72cce99920bea44094a8c7a3e423f49
2023-03-12 20:58:28 +00:00
Walter Agazzi
bfc5f63026 AGS :Engine: draw fix, true means texture don't change
From upstream d5958eab884c079c00845c35e46ef0302152ded5
2023-03-12 20:58:28 +00:00
Walter Agazzi
0f86678e2d AGS: Engine: only clear _stageScreen after it's dirty
From upstream d60022c715f15d0454ffe04d4ce8d331c34e3045
2023-03-12 20:58:28 +00:00
Walter Agazzi
afed888bb5 AGS: Engine: avoid dirty rects outside software render surface
From upstream c4dce7eb4a0ab4d2440a8b7e637ea8a7f9ed2c00
2023-03-12 20:58:28 +00:00
Walter Agazzi
818b670561 AGS: Engine: fixed text parser could substring with negative length
The example when this could happen:
    Parser.Said("climb,get in bed");
where "climb", "get" and "bed" are dictionary words.

From upstream b633ca77076137e2402faa903f5b6fbcd3f4c3bc
2023-03-12 20:58:28 +00:00
Walter Agazzi
3d4856d321 AGS: Engine: for HW renderers - don't create redundant object cache images
I'm baffled how I did not notice this behavior earlier, but engine was
created at least 2 redundant intermediate bitmaps meant to cache
transformed sprites per each object and character on screen for
HW-accelerated renderers, - which they do not need, as they don't
use software transformations.

The resulting effect won't be too notable for low-res games with low
amount of simultaneous objects, but may be quite significant for the
high-res games with multiple large objects in the room.

From upstream cca997fe83ec5f7014677a69095a7c9ec1494cd9
2023-03-12 20:58:28 +00:00
Walter Agazzi
2cffebe3a5 AGS: Engine: use unique_ptr to store raw image in ObjectCache
From upstream a06d97dc88887395f3f961ab8e3fbda277733795
2023-03-12 20:58:28 +00:00
Walter Agazzi
f58c4d9bdb AGS: Common: replaced couple of smart ptr arrays with std::vector
From upstream c1afae64fe348c64ee4a8c8888349ae267241395
2023-03-12 20:58:28 +00:00
Walter Agazzi
26375b823b AGS: Engine: Used std::vector for RoomStatus::tsdata
From upstream 849a0f3153511087bd93c4d7d1ba898d4ab28cfa
2023-03-12 20:58:28 +00:00
Walter Agazzi
88f0170696 AGS: Engine: Fixed RoomStatus::tsdata allocation of additional bytes
From upstream 894ec8a85bd2c78438c8bfabee632b26f5323b07
2023-03-12 20:58:28 +00:00
Walter Agazzi
e0d2bc8860 AGS: Engine: Fix malloc/delete mismatch with RoomStatus::tsdata
From upstream cf31083808f19ae314212e7b451709cfd5d6f05d
2023-03-12 20:58:28 +00:00
Walter Agazzi
91d7299405 AGS: Engine: (again) fixed buttons not updated visually on interface enable
Complements / reimplements f310a08
From upstream b0e2fe40c1d73674a7b868a87152be6029df6cac
2023-03-12 20:58:28 +00:00
Walter Agazzi
ecc1d17655 AGS: Engine: register missing SetProperty script functions for plugins
Reimplemented from upstream 96d52b258dd226bc8c2243c1a5bc95a9ceeecd2a
2023-03-12 20:58:28 +00:00
Walter Agazzi
0fbdbdfcdd AGS: Engine: fixed WaitInput() incorrect handling of a type arg
From upstream ca6620951ec013e3627d962701c3cc25c1ac8adb
2023-03-12 20:58:28 +00:00
Walter Agazzi
49e61b6ea2 AGS: Engine: let use dummy frame 0 if the speech view's loop is empty
This complements / fixes previous fix attempt 08aef03
From upstream 95c99fc325f8550f220e7a0f67d6555bb23c8c5a
2023-03-12 20:58:28 +00:00
Walter Agazzi
f77da38379 AGS: Engine: fixed view frames have a linked sound 0 by default
from upstream a4a98adfcb039e0f8f213d60e8b0b639b0217f9b
2023-03-12 20:58:28 +00:00
Walter Agazzi
c366ce5eef AGS: Removed update_polled_stuff_if_runtime() from data loading functions
Leave it with a new name as `update_polled_stuff()` only in functions
related to the game update.
From upstream 95dc139f51e704da19792e5480e69bbfe7ec27aa
2023-03-12 20:58:28 +00:00
Walter Agazzi
e7e7e4a446 AGS: Engine: keep mouse speed control enabled (by default, fullscreen only)
Partially from upstream 1f867858c46c8a2dde841022aed8631f1deeabb1
2023-03-12 20:58:27 +00:00
Walter Agazzi
3ddbd08585 AGS: Engine: in render_to_screen() do at least 1 delay in case of DEVICELOST
from upstream 27306da4cd0c1fa193f984644aa1915c8a944364
2023-03-12 20:58:27 +00:00
Walter Agazzi
d372745e35 AGS: Prevent savepath manipulation in ScummVM
Completes commit 8e77b04062d865e35bbadedce2fb7ba4971b837c.
We don't support subdirs in saves, the previous change causes some
games to be unable to save/restore
2023-03-12 20:58:27 +00:00
Walter Agazzi
61c7c0fcfe AGS: Engine: fixed gui controls not updated after interface is un-disabled
from upstream 126a5e4c97581aabadbbd4410441b83f371e18ea
2023-03-12 20:58:27 +00:00
Walter Agazzi
72592cc9e0 AGS: Engine: fixed ResolveScriptPath not handling subdirs correctly
from upstream 8d0e0cb3c20db0beddffc36c688ed33005a43d7c
2023-03-12 20:58:27 +00:00
Walter Agazzi
5ad85c6b42 AGS: Common: replaced GameSetupStruct::messages with an array of Strings
This also fixes an allocation/deallocation mismatch found in the code.
From upstream b47a086cbd589cd271c5fe1b3497f9b8e4ae4abf
2023-03-12 20:58:27 +00:00
Walter Agazzi
0263572d1c AGS: Common: fix mismatched free
uses new char[] on Create method.
From upstream ecfc238401183e210a1773c27724516f74272c8e
2023-03-12 20:58:27 +00:00