Commit graph

375 commits

Author SHA1 Message Date
Walter Agazzi
69ba09c5fd AGS: Add two methods for handling multiscreen
For completeness, this adds functions sys_window_fit_in_display
and sys_get_window_display_index.
Practically it has no effect as in ScummVM we don't support
multiscreen and the resolution is hardcoded.

Partially from upstream 1afc61df54681ffe2fddc0d30bb2221c38a0fa79 and
b17f58d90061c3b12c9e4c04183dc59b094d66cb
2024-11-27 16:45:50 +01:00
Walter Agazzi
8cbd20943e AGS: Engine: fix ypermove comparison
From upstream 9cf99a3583fcb05dd983d9ce06a513851e47dd57
2024-11-07 00:05:37 +01:00
Walter Agazzi
8e915febde AGS: Engine: fixed callstack not reported in case of script api errors
This was broken by 9e76800
From upstream 716a36aa0252a7481d299d4e409eed2d56239bb3
2024-10-30 18:07:42 +02:00
Walter Agazzi
fdab95b34b AGS: Engine: gui mouse handles accept mouse pos as arguments
* This also fixes GUI.ProcessClick, apparently it always had an issue of using mouse
coordinates instead of provided ones.
From upstream ab3561359eb23fe17ba0758741f139165eb1f13c
2024-10-30 18:07:42 +02:00
Walter Agazzi
4308801cae AGS: Engine: in GetDiskFreeSpaceMB() ensure we check the save dir's disk
Partially from upstream 220ada5413886e80f42c9f2950e20ea46c141283
2024-10-30 18:07:42 +02:00
Walter Agazzi
c8ddd881ae AGS: Engine: hotfix buffer usage when printing room debug info
From upstream 2e2e1578d60d482341574dc741a5c51aa5ce8dc6
2024-10-30 18:07:42 +02:00
Walter Agazzi
efc70d1e1d AGS: Engine: mark portrait sprite updated, as it's now a dynamic sprite
This is necessary since overlays keep custom images as dynamic sprites too.
From upstream b88167fd0ba608352482f9fd09e87e2c0246cdbc
2024-10-30 18:07:42 +02:00
Walter Agazzi
5d58384af2 AGS: remove "supersampling" setting, as not entirely supported
This setting comes from the original mobile port of AGS, but it's not clear whether it was
useful. More importantly, there are issues with this:
1. It was never implemented in another hardware accelerated driver (Direct3D), being
exclusive to OpenGL.
2. It was never added to standard setup, so not very visible.
3. It's not clear whether it was working properly all this time. There were multiple changes to graphic renderers, and some of them may assume that rendering at "native resolution" is done at exactly, well, native resolution.
2024-10-30 18:07:42 +02:00
Walter Agazzi
209ec5a953 AGS: Engine: hotfix room objects not visible if FadeIn called in "room load"
From upstream b25b9eebe3525433251d23298ba0339a7505ef8b
2024-10-30 18:07:42 +02:00
Walter Agazzi
73526c8f1c AGS: Engine: add SPF_OBJECTOWNED flag for dyn sprites owned by Overlays
Currently this is only to skip checking them when exiting the game.

Partially from upstream f535a4b7fec65bb00b13c883a0b3e1154509f651
2024-10-30 18:07:42 +02:00
Walter Agazzi
822842d038 AGS: Engine, Common: refactor guard using set_our_eip
Remove naked our_eip usages
From upstream 9f4371ab8c2fbc9ccf41b49f7b975ebe8bc5d1b8
2024-10-30 18:07:42 +02:00
Walter Agazzi
8b7b0df59c AGS: Engine: fixed MAX_WALK_AREAS value
From upstream 39228483259a05a3e3a5d60bc1330a90bef6ae75
2024-10-30 18:07:42 +02:00
Walter Agazzi
0ce4c45489 AGS: Engine: mention "--no-message-box" in help for all platforms
From upstream e848eeb4392ba995a12d56c708c45cf1be3d1e1f
2024-10-30 18:07:42 +02:00
Walter Agazzi
87c0bcdf7f AGS: Engine: fixed CharacterInfo breaking script compatibility again
This fixes a mistake introduced in commit 4be1556, which in turn followed b02814b

The problem is, that CCStaticArray does not work as intended, and seems won't (at
least not without some extra workarounds).

When the script compiler is told to get an Nth element of a global struct array, such
as character[n], it calculates the memory address as
    Character* ptr = (array address + sizeof(Character) * n).
If this address is used for the read/write operations, these ops can be intercepted by
interpreter and remapped into the real fields (see IScriptObject::ReadN, WriteN
interface).
But if this address is used IN POINTER COMPARISON BY VALUE, then we cannot do
anything. And if our real struct in the engine is stored on a different relative memory
offset than one expected by compiler, then this pointer comparison will fail.
This breaks script expressions like e.g.:
      if (player == character[n])
From upstream 97ed18e95b587544ae47497f0a5f1d1ba00a7e29
2024-10-30 18:07:42 +02:00
Walter Agazzi
96db95c255 AGS: Engine: fix some minor warnings
From upstream 28693377db7ae242782b313717ec9c476ecaff0f
2024-10-30 18:07:42 +02:00
Walter Agazzi
d904cac0c5 AGS: Script API: implemented Game.PrecacheSprite() and PrecacheView()
Partially from upstream 76aee247b7f8ae9eff613393a18192ceab4aca9f
2024-10-30 18:07:42 +02:00
Walter Agazzi
eefccd3067 AGS: Common: explicit LockSprite/UnlockSprite methods in SpriteCache
Reimplemented From upstream 8e2d2fc9329a393dcdcddbe29dd5cc7094793350
2024-10-30 18:07:42 +02:00
Walter Agazzi
e158764267 AGS: Engine: unrestricted game name and save folder name
From upstream 3b06711da90621b2ee5ba33ff82da91f797cabbb
2024-10-30 18:07:42 +02:00
Walter Agazzi
bdb34c01cc AGS: Engine: unrestricted scriptname and name in CharacterInfo
NOTE 1: we *must* keep the old fixed-sized fields for the time being,
 for compaibility with the plugin API. Would the plugin API be adjusted
  and have direct access to a character data struct removed, then these
   fields may be removed as well.

NOTE 2: we still read these old fields from game data, avoid changing the
 data format in the middle (in the sake of both backward and forward
 compatibility). These fixed-sized values are assigned to the character
  properties first. For unrestricted values we'll have to add a data extension,
   appended to the end of data format.
From upstream  b02814b8bb3bb7a2cd00110466e2bd3047e772d1
2024-10-30 18:07:42 +02:00
Walter Agazzi
8b4e30fa35 AGS: Engine: hardcode alignment padding in remaining legacy save parts
From upstream b3951c9d8c8cfdd75c4a1f412735de76e1476ceb
2024-10-30 18:07:42 +02:00
Walter Agazzi
db73bb6b68 AGS: Moved "antialias" config option to "graphics" section
From upstream 32958c6cb5e247c54de6c9d581beae7b2b31675b
2024-10-30 18:07:42 +02:00
Walter Agazzi
73e50455ab AGS: Engine: precache only player walk view
From upstream 20c7e57eecfec7b53a3067fd59de50c448a4d977
2024-10-30 18:07:42 +02:00
Walter Agazzi
ee82074a47 AGS: Engine: further tidy up around agsplugin.h/cpp
* Moved plugin API event constants to a separate header agsplugin_evts.h.
Engine should not include whole plugin API, this is unnecessary, and may
 create naming conflicts.
* Moved SimulateMouseClick to mouse.cpp.
* Minor cleanup in agsplugin.cpp

From upstream 510293c1fd277d853544534423ceea27b8ae3e2d
2024-10-30 18:07:42 +02:00
Walter Agazzi
dfaa12c25a AGS: Engine: disable auto SetRestartPoint at startup
From upstream b6008e1265648a9ab491cd630057812a3f388717
2024-10-30 18:07:42 +02:00
Walter Agazzi
1ee7c47af2 AGS: Engine: fixed a condition in movelist_handle_remainer()
Should compare xpermove and ypermove using abs values,
as they may have different signs.
From upstream 234db6dc918490c1e2e4a82da8c6bd30987c227e
2024-10-30 18:07:42 +02:00
Walter Agazzi
9c7e414387 AGS: Engine: another small fix in do_movelist_move()
From upstream 354917c602144f5f1c902bfb44f970af860e799b
2024-10-30 18:07:42 +02:00
Walter Agazzi
e3e6b75af5 AGS: Engine: reverted serializing movelist remainer, recalc on restore
Sorry for these changes, i decided that it's annoying to save the "fixup"
values used only in rare circumstances, that may be easily calculated
from basic MoveList members.
From upstream 13e59c4855a4ddcf9bfe5f935d6de1191debaf1e
2024-10-30 18:07:42 +02:00
Walter Agazzi
50b34a65c2 AGS: Engine: bit more refactor of movelist update, picked "move done" check
From upstream 36d18a543405b40f2259266707cc513e8e8f6646
2024-10-30 18:07:42 +02:00
Walter Agazzi
9021cd0f04 AGS: Engine: another small fix in do_movelist_move()
From upstream 5789ac12160f389fd880a494c154f740b3b9c715
2024-10-30 18:07:42 +02:00
Walter Agazzi
45f011ecd8 AGS; Engine: store MoveList final move as members, and serialize
This is to avoid recalculating exact same values on each movelist update.
The "final move" may continue for a while if the "short" axis of the move
vector is finished earlier than the "long" one.
When serializing, use 2 freed int32s, left after removing 2 unused member variables.

From upstream 57e369ec2bcf6a8eee61c45be8266f45e8a0c922
2024-10-30 18:07:42 +02:00
Walter Agazzi
56b3fd3299 AGS: Engine: converted MoveList::onpart to float
From upstream b0ba1ac225c0b4e5093e58ff70051cf0e297f06b
2024-10-30 18:07:42 +02:00
Walter Agazzi
2dc8b67350 AGS: Engine: in MoveList store steps as fractional values, for recalculation
Make MoveList::onpart a fixed point value too, allow more precise "current progress"
recalculation when the moving speed factor changes.
Possible TODO: on move update, the first step after recalculation should bring `onpart`
 the the nearest integer, to make the movement progress more consistent.

From upstream b28ca9f86b8b70a73e4f6fa6f1c72ce76f29ecf6
2024-10-30 18:07:42 +02:00
Walter Agazzi
19496a8e24 AGS: Engine: fixed walking remainer duplicates speed
This complements/fixes c3f03de
From upstream e699ca77b43da7c07691c52c50e6f786ec74a911
2024-10-30 18:07:42 +02:00
Walter Agazzi
f1a9a35758 AGS: Engine: a new fix for character stalling before finishing movement
AGS historically has a hidden problem: its pathfinder and walking algorithm uses math with relatively low precision.
 This may result in rounding mistakes. What this means in practice is that under some circumstances the
  "movement direction" (vector) is slightly off, e.g. more towards X than Y (or other way). In such case the character
   may reach the X destination while Y destination is still few pixels away.

How is this issue solved currently in AGS (and for a long time): when AGS finds out that one coordinate is complete,
 but another is not (for example X done and Y is still not reached), it starts waiting until character reaches Y, but also
  accepts a certain "mistake", in 2-3 pixels. If character is already within 2-3 pixels from the destination, then it just stops.
 This makes its real stopping point inaccurate, but nothing else happens.
 However, if character is further away, then it keeps "walking", but because the movement vector is still pointing
  in the same direction, usually it takes few moments for it to reach the proper Y coordinate.
   This results in a buggy effect known as "walking in place".

This commit introduces a new solution: turn the walking vector to make it point right along the unfinished axis,
 while keeping its length (that means - walking speed), in order to reach the destination faster.
This should make character make some extra short move, properly animating, but this may look more natural
 than just moving legs in place.

NOTE: I still keep the "destination fix" for the old games, as they may be scripted specifically to test
 where character has stopped moving.
 From upstream c3f03dea01a897b23795298e77db56506e44902f
2024-10-30 18:07:42 +02:00
Walter Agazzi
56c790c838 AGS: Engine: tidy do_movelist_move() and MoveList further
From upstream 3292c4cf7ff549832fdd0249ac1ee6d805e91f93
2024-10-30 18:07:42 +02:00
Walter Agazzi
22cb981566 AGS: Engine: rewrote MoveList to avoid packed shorts
From upstream d463adac63817fd08eb757038f90c730726124d3
and 09203df6efb19cf0f2eafd098c798733bd85cfe0
2024-10-30 18:07:42 +02:00
Walter Agazzi
5b66b860af AGS: Engine: separate functions for getting game's set and real fps
From upstream cacaa9be6f7a0194b89fd2255acc9b8b612622b4
2024-10-30 18:07:42 +02:00
Walter Agazzi
d7613f9653 AGS: Marked few more game script variables as readonly
Partially From upstream 4afaf73e6ff92959a75705f0ec962b6c90a72331
2024-10-30 18:07:42 +02:00
Walter Agazzi
f866475b7f AGS: Engine: REALLY apply character's anim volume to portrait animation
+ process frame features for the first portrait frame too.
From upstream efc3941fe335d0cf4a34dbb65a75c012f8d6df40
2024-10-30 18:07:42 +02:00
Walter Agazzi
f62f270423 AGS: Engine: use enum for Text script callback types
From upstream 047f6fb020564bca9c6d99d1f6c1474386e3da97
2024-10-30 18:07:42 +02:00
Walter Agazzi
2ae4a1ebd8 AGS: Engine: some refactor + apply volume for character face animations
From upstream a31beb6b76243902e75a49e901165c9565e8553a
2024-10-30 18:07:42 +02:00
Walter Agazzi
e572c4333c AGS: Engine: print cache sizes to log
Partially from upstream 98550532869e1e22a8f23c76cd000a3579167628
2024-10-30 18:07:42 +02:00
Walter Agazzi
a05c63e4df AGS: Engine: fix cache config and read legacy values too
From upstream 9b2880e8b7c31891cad672fec9dc1124f9f3cc7c
2024-10-30 18:07:42 +02:00
Walter Agazzi
6c8b82523d AGS: Engine: let configure texture cache size
Partially from upsteam e84ca2191319fc20426c91bc5719e2503a4ccbf0
2024-10-30 18:07:42 +02:00
Walter Agazzi
72a89a8bab AGS: Engine: proper GameState initialization
This should have been done at 5596736.
From upstream 2ba13acde4b686d73148bcf094f60e425f589cfe
2024-10-30 18:07:42 +02:00
Walter Agazzi
5c5b7fb026 AGS: Engine: force std message box for debug info
This is necessary, because game settings may include
"display all messages as speech".
From upstream 3c9e072ff1fa246524e39c0063a2c6dee1209304
2024-10-30 18:07:42 +02:00
Walter Agazzi
178826a9d8 AGS: Engine: init few more things along the GameState struct
This fixes more variables not initialized after 5596736 .
From upstream 99db1355bf9eb00f03ff2a10d01d9f1b80363945
2024-10-30 18:07:42 +02:00
Walter Agazzi
7ba6cf903c AGS: Engine: Removed redundant code from engine init
From upstream f0268dbd9bc40521132bd8465af06581abe6a27
2024-10-30 18:07:42 +02:00
Walter Agazzi
0bb33fcfc5 AGS: Engine: made sure game res inited in InitGameState()
This is more logical than calling this from "engine_setup",
 and also fixes running another AGS game from current game after commit 5596736 .
From upstream a82d8147d4424b0aa83762d810db96cff31d7af9
2024-10-30 18:07:42 +02:00
Walter Agazzi
f9087ab378 AGS: Engine: optimized ScreenOverlays storage (vector variant)
Keep ScreenOverlays in std::vector, but do not erase elements
 in the middle and invalidate them instead. Record free indexes
 in a helper stack.
 When creating a new overlay, first check for the recorded free indexes.
Overlay's type now equals storage index.

This speeds up both creation/deletion of overlays, and their access.

Removed the gap between "fixed" overlay types and custom ones,
 to save space. If we ever need more special overlays, these could
 be created as custom and their ids saved in a variable (similar to
 how background speech works). Previously present special overlay
  types are left for backwards compatibility (and to simplify the transition).
  From upstream f7d2f162fa55aa1b6f37195d890ebe047a204154
2024-10-30 18:07:42 +02:00