Commit Graph
113 Commits
Author SHA1 Message Date
Walter Agazzi 9b56d15ef7 AGS: Engine: fixed stack unwind assert was hiding other errors
This complements 2697c95
from upstream ec693e5b74b437745d98bf3bcba26f891f857525
2024-10-30 18:07:42 +02:00
Walter Agazzi 66560d9717 AGS: Engine: ccInstance: added ASSERT_STACK_UNWINDED for both cases of Run()
from upstream 2697c95ba185cd371412da86cb47fbe39484f891
2024-10-30 18:07:42 +02:00
Walter Agazzi 69327ac20b AGS: Engine: fixed stackptr increment on SCMD_ADD
This fixes 338afc2
From upstream 38a9d7dae7ad7045121e2d6efa65b54a70c5f14b
2024-10-30 18:07:42 +02:00
Walter Agazzi 0bf9768151 AGS: Engine: ccInstance ScriptCommandInfo is const
from upstream 412f6fcd606084abedca8744024c25a676c29f98
2024-10-30 18:07:42 +02:00
Walter Agazzi 4dc7347a4f AGS: Engine: ccInstance: only do fixups for ops/args where expected
This explicitly calls FixupArgument() only for the 2 instructions where a fixup may be expected to be applied to a literal arg. These are:
* SCMD_WRITELIT
* SCMD_LITTOREG
2024-10-30 18:07:42 +02:00
Walter Agazzi f5c0b75160 AGS: Engine: ccInstance: replaced fixups for loop with a switch
Based on the idea by @ericoporto
This is more code lines, and looks kind of ugly, but proved to be significantly faster enough to justify this change.
Maybe there are more ways to refactor and tidy this in the future.

From upstream 9f255eab2343896928039dbca71576718f5f7380
2024-10-30 18:07:42 +02:00
Walter Agazzi 57d7544f08 AGS: Engine: ccInstance: hid couple more frequent asserts under DEBUG
From upstream f52c96c64d0508addd440a7060ea5e939ebc6a67
2024-10-30 18:07:42 +02:00
Walter Agazzi 4f32ca32cb AGS: Engine: ccInstance: refactored to alloc arg values per opcode
Although this means more code lines, it reduces redundant variable
initialization and assertions, which may lead to slightly optimized execution.
In addition, this change makes argument read explicit, under each individual opcode.
From upstream 777cd4a4effd1c1785582e847f9fcdadef5fe7e0
2024-10-30 18:07:42 +02:00
Walter Agazzi b1e4aba613 AGS: Engine: ccInstance: tiny optimizations in SCMD_MEMREAD/WRITE/INITPTR
From upstream eb0b0020cf4168862a7ddb01af24684486691804
2024-10-30 18:07:42 +02:00
Walter Agazzi 03214f54eb AGS: Engine: ccInstance: move stackdata_ptr for each stack op, be consistent
Stack stores either "values" or arrays. Values are always stored as int32:
these are ints, floats, managed handles, also "pointers".
Although we don't store things like pointers in the stack buffer for real,
we store them as stack "entries" as RuntimeScriptValues.
But we keep stack pointer consistent by moving along the buffer,
to avoid unnecessary data type tests. Basically, the stack buffer will be
holding 32-bit placeholders.
From upstream 338afc27ece7ff4030101887c9f00ab4f24ca3ca
2024-10-30 18:07:42 +02:00
Walter Agazzi 650c93b7d0 AGS: Engine: ccInstance: have stack-related asserts under DEBUG_CC_EXEC
from upstream e16b94226fd1a67799f032c42ea3ff0d382ba423
2024-10-30 18:07:42 +02:00
Walter Agazzi 96ddb49fd0 AGS: Engine: ccInstance: hide DumpInstruction under DEBUG_CC_EXEC flag
from upstream 9735b097abdb58a2d17d58cbe6b45e3b66c9cba8
2024-10-30 18:07:42 +02:00
Walter Agazzi 91b699106f AGS: Engine: ccInstance: minor parameter adjustments
from upstream d9284d8c1a265f0c4b329c27dde2997f465375d4
2024-10-30 18:07:42 +02:00
Walter Agazzi f2ddfc90f5 AGS: Engine: ccInstance: cleaned up old commented code
This was an early attempt to pick out few operations into separate functions,
but IIRC this caused additional slowdown. Maybe was not done in an optimal way.
In any case, it's better to remove the old commented code, as there may be slight
differences between that and current inlined code now.
They may be recreated if necessary for another refactor. Just need to be aware of
potential performance issues, and do tests.
From upstream 961569db426af1c09c7d9da38f5f4e4a0e09b499
2024-10-30 18:07:42 +02:00
Le Philousophe 49b4c1b3c4 AGS: Revert to use std namespace
This allows to minimize changes from upstream
2024-07-08 21:37:28 +02:00
Paul Gilbert c2a476411c AGS: Move std namespace into common/std/ 2024-07-07 15:28:31 -07:00
Walter Agazzi cc6bbd1083 AGS: Engine: hotfix potential exception if cc_error is called during quit()
From upstream a64e3424f70677f9393e4f8c506f03ed628aee47
2024-04-02 23:09:17 +02:00
Walter Agazzi a660cd67a4 AGS: Engine: fixed bytecode fixup assertion done for unapplicable case
Was broken by 973845a
From upstream 9d86d5ab1a6e84115c33ffbfc8a96185e6b9fd63
2024-01-17 03:12:32 +01:00
Walter Agazzi 46b14a21c6 AGS: Engine: safety check for fixups with out of range code reference
From upstream 973845a15ed9726956895161c8847bc668c3e787
2024-01-17 03:12:31 +01:00
Walter Agazzi d9377bbb63 AGS: Engine: Fix typo in commit b81abc533f508e5831e7ca6d2512c66d506ef09d
loopIterations -> loopCheckIterations
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
elasota 067626137e AGS: Fix cast of integer to pointer of greater size warning 2023-07-08 22:02:00 +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
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 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 88a1083e0d AGS: Move strlen out of loops
From upstream b476dfca4b40bc2ca59b7f0fd793543524397ccf
2023-03-12 20:58:28 +00:00
Donovan Watteau 2c804b9c71 AGS: Fix AmigaOS and NDS builds 2022-12-18 14:03:39 +01:00
Thierry Crozat 5772893340 AGS: Engine: fixed CallScriptFunction for the ancient games + added comments
Was broken by dec92f05ea
(e38df03c5d1658a2c44a26ba4ee6f22663c1e701 in upstream).

Some games do not have function arg count appended to the function names in
the export table; in that case `export_args` remained uninitialized.

From upstream cdbb7a7367db57e14983015232ecc97f6a3dd212
2022-12-17 22:10:55 +01:00
Hubert Maier 255730b227 AGS: Correct spelling mistake
occured -> occurred
2022-10-27 15:56:08 +02:00
Donovan Watteau 27f9a460b5 JANITORIAL: Fix "the the" and similar typos 2022-07-29 19:36:40 +03:00
Thierry Crozat 4f90db8fb4 AGS: Small correction to the hung script loop check 2022-06-24 20:54:42 +01:00
D G Turner 7f2f42e4a1 AGS: Fix Signed vs. Unsigned Comparison GCC Compiler Warning 2022-06-24 01:28:37 +01:00
Thierry Crozat 08db4be24c AGS: As a hotfix, restored the old way to test for hung script loops
The timeout method introduced by 6f665dfe is not working very well and
gives "false positives", so I'll disable it for the time being.

From upstream e0edb28b6606c360a1ea3fdcc487c2b05929ed02
2022-06-23 23:57:49 +01:00
Thierry Crozat 6f665dfe68 AGS: Test for hanging script using timeout instead of while loops
From upstream c34f0c96596f1a7814c15e7a06c2c498cb95ebfc
2022-06-23 23:57:27 +01:00
Thierry Crozat 305fdb853a AGS: Abort current scripts on close window event
This helps kill "hanging" scripts if user closed the window while
there's no real engine update.

From upstream a758fd6de2dccd0c948fc7f9e5b65200df902a65
2022-06-23 23:57:26 +01:00
Paul Gilbert 8e55de7b77 AGS: Changed sccmd_info array from being global objects 2022-05-31 18:33:21 -07:00
Paul Gilbert 13f40609c7 AGS: Reset currentline when exiting script function, for cc_errors
From upstream 538e9072b03b0441853ac0022d17f8990065f8de
2022-05-05 22:41:10 -07:00
Paul Gilbert b1649597d7 AGS: Replaced Math/std Min/Max with ScummVM macros
Inspired by 6dee5ee6f271c600e30879d892295ea6069e8cc9
2022-05-05 22:41:10 -07:00
Paul Gilbert 8e132f7b3f AGS: cc_error returns stack from all script threads
From upstream 9e76800d668d8d0af7d47d815e6d1b781c7601f6
2022-05-05 22:41:07 -07:00
Paul Gilbert 16d0d89787 AGS: Grouped ccError variables in a struct
From upstream 48ef387226e4d420dc62d0a0b204cf4cd89a1139
2022-05-05 22:41:07 -07:00
Paul Gilbert a2a5f2575d AGS: Reorganized few cc_ headers
From upstream ea1f8b9ece69fc7c49c4d3aa7b9af51c4ca736e5
2022-05-05 22:41:07 -07:00
Paul Gilbert 480be2134b AGS: Added script instance thread stack, replacing current_instance
From upstream f3443cb7a4ae5858e5d2d28131aaf6cf138bc0ec
2022-05-05 22:41:06 -07:00
Paul Gilbert 68e5184afa AGS: Replaced some (v)sprintfs with sNprintf counterparts
From upstream a34bd392249f87a152dc470d90c67a7d193a28d8
2022-04-27 20:51:30 -07:00
Paul Gilbert a633e9d72f AGS: Fixing various type-cast warnings
From upstream 6c42c7331e96386721f28c92ec3cb4cd039e10cd
2022-04-25 20:06:19 -07:00
Paul Gilbert 608389c4c5 AGS: made SystemImports index an unsigned value
From upstream 30b8f4016c815f01b49398ddb697b454f1565218
2022-04-24 16:00:05 -07:00
Le Philousophe edcce8744f AGS: Fix build on AmigaOS and NDS 2022-04-19 18:37:09 +02:00
Paul Gilbert 99cc27e840 AGS: Fixed few comments in ccInstance::Run()
From upstream 109346cf4cc747c9a3bef72c234a18a5f63d30fe
2022-04-18 19:10:40 -07:00
Paul Gilbert dec92f05ea AGS: Support passing partial argument list to a script callback
From upstream e38df03c5d1658a2c44a26ba4ee6f22663c1e701
2022-04-18 19:10:40 -07:00
Paul Gilbert 2fa13bb149 AGS: Compilation fix 2022-04-13 22:12:16 -07:00