Bill Currie
256dee98a1
Make progs string resources management private
...
Strangely enough, using the progs resources system. This is a step
towards having progs that can be reset properly, or even dynamically
created VMs.
2020-02-25 00:23:08 +09:00
Bill Currie
7406e0308e
Fix some warnings picked up in an optimized build
2020-02-24 11:28:43 +09:00
Bill Currie
dda045bf96
Do lazy computation of def sizes from type encodings
...
The size is calculated when needed and cached.
2020-02-23 23:29:58 +09:00
Bill Currie
23573953a7
Change pr_type_size to pr_ushort_t
2020-02-23 22:25:08 +09:00
Bill Currie
d0dc0e15fb
Handle alias types in debug prints
2020-02-23 19:02:16 +09:00
Bill Currie
b173c35eb4
Rework progs debug to use the type encodings
...
It's only a start: the output is, if anything, slightly worse than
before, but it does have the basics going.
2020-02-23 19:01:59 +09:00
Bill Currie
4b7ecdf74a
Make PR_Init take an instance to initialize
...
This allows internal sub-systems to do per-instance initializations
without other engine systems having to know about them.
2020-02-23 18:32:16 +09:00
Bill Currie
806af85447
Remove reference to ddef_t from progs.h
...
This cleans up some horrible names and redundant fields that were a
result of the transition to pr_def_t
2020-02-22 22:44:08 +09:00
Bill Currie
81083698a8
Move to using an in-memory form of ddef_t
...
This allows the VM to work with extended ddefs transparently. It seems
to have uncovered a typedef alias relocation bug, though.
2020-02-22 22:33:44 +09:00
Bill Currie
c296514b95
Make pr.load_file 'return' the file size
2020-02-21 21:17:28 +09:00
Bill Currie
ed283a9e7f
Copy only the necessary number of vararg parameters
2020-02-16 18:00:29 +09:00
Bill Currie
12d2a0ff75
Copy the correct number of words for rcall
2020-02-16 17:58:36 +09:00
Bill Currie
f5741a979e
Implement parameter alignment in the engine
...
The engine now requires non-v6 progs to store the log2 alignment for the
param struct in .param_alignment.
PR_EnterFunction is clearer and possibly more efficient.
2020-02-16 17:13:45 +09:00
Bill Currie
32c21ec559
Make gcc accept the bitwise-boolean magic
...
Forgot to compile check...
2020-02-16 12:08:08 +09:00
Bill Currie
b4fd804e4e
Implement true modulo in the engine
2020-02-16 11:53:56 +09:00
Bill Currie
4269c8cb07
Rename the mod instruction to rem
...
Because % really implements remainder rather than true modulo, and I
plan on adding %% to implement true modulo.
2020-02-16 11:04:30 +09:00
Bill Currie
533fb8acc9
Implement double constants
2020-02-15 23:49:12 +09:00
Bill Currie
2cd62fe01b
Fix several double-related bug
...
float is promoted to double through ... for non-v6 code.
PR_Sprintf has custom param access via P_*, messed up doubles.
2020-02-15 23:49:12 +09:00
Bill Currie
df7c08a010
Add support for doubles to Ruamoko
...
Only as scalars, I still need to think about what to do for vectors and
quaternions due to param size issues. Also, doubles are not yet
guaranteed to be correctly aligned.
2020-02-15 23:49:12 +09:00
Bill Currie
13b608f40c
Don't truncat float % float
...
This allows full usage, eg, x % pi, but otherwise maintains
compatibility with integer %
2020-02-15 23:49:12 +09:00
Bill Currie
f68129dc0f
Try to use type encodings for function return type
...
Now return statements in traces make much more sense.
2019-06-09 18:11:56 +09:00
Bill Currie
0f5f2a125a
Use a reliable reference for calculating progs offsets.
...
Now that pr->zone can be null, it cannot be used as a reference. Fixes
random crashes when using qfprogs (random due to heap randomization).
2018-10-13 23:23:45 +09:00
Bill Currie
b7aa5bb8fe
Fix an oops messing up edict size.
2018-10-12 14:33:26 +09:00
Bill Currie
33cbc500e8
Fix a segfault when setting up the stack.
...
Yup, putting {}s around even single statements under flow control (if, etc)
is a good idea. Wonder if there's a gcc warning for that...
2018-10-11 13:34:08 +09:00
Bill Currie
6252faa069
Fix a size error in OP_LOAD_Q.
...
C&P from OP_LOAD_V :/
2018-10-11 13:25:32 +09:00
Bill Currie
364c2d2c2b
Add a stack and push and pop instructions.
...
The stack is for data, not return addresses.
2018-10-11 13:24:03 +09:00
Bill Currie
61185813fa
Cleaner handling of zone_size/zone.
2018-10-11 10:22:10 +09:00
Bill Currie
82809eb856
Simplify the call to PR_LoadProgsFile.
...
I've decided that setting pr.max_edicts and pr.zone_size as part of the
local progs initialization rather than in PR_LoadProgsFile makes more
sense. For one, it is unlikely for the limits to change every time progs is
reloaded. Also, they seem to be a property of the VM rather than the progs.
However, there is nothing stopping the caller from updating max_edicts and
zone_size every call.
2018-10-11 10:06:48 +09:00
Bill Currie
34bcf7faab
Do a pure/const/noreturn/format attribute pass.
...
I always wanted these, but as gcc now provides warnings for functions that
could do with such attributes, finding all the functions is much easier.
2018-10-09 12:42:21 +09:00
Bill Currie
59e85b7d5e
Fix a pile of dead assignments.
...
Some were actual bugs!
2018-09-08 22:23:57 +09:00
Bill Currie
8fd5be0ee0
Fix a pile of sizeof goofs.
...
While scan-build wasn't what I was looking for, it has proven useful
anyway: many of the sizeof errors were just noise, but a few were actual
bugs (allocating too much or too little memory).
2018-09-07 20:00:57 +09:00
Bill Currie
0de0eb2fc7
Fix a bunch of bit-rot.
2018-06-08 13:21:30 +09:00
Bill Currie
546e333a3c
Allow Sys_Error to be hooked.
...
This makes debugging builtins that wrap normal functions a little easier by
giving a progs dump when such an error occurs.
2016-01-03 23:04:00 +09:00
Bill Currie
7b350b2a1b
Indicate calls to builtins when tracing.
...
This makes following progs traces a little easier.
2016-01-03 16:13:59 +09:00
Bill Currie
3efb0c538f
Separate file search from loading.
...
QFS_LoadFile (and its wrappers) now take a file handle rather than a
path. This will make vpath usage a little cleaner to implement.
2014-01-28 16:22:05 +09:00
Bill Currie
4c6478c77f
Strip trailing spaces from field names.
...
A certain mod (glare at rogue) has a space at the end of a field name in
the bsp entity data causing a crash. Thanks to ccr for the report.
2013-11-26 14:27:49 +09:00
Bill Currie
f5501fbf24
Fix a pile of automake deprecation warnings.
...
s/INCLUDES/AM_CPPFLAGS/g
I <3 sed :)
2013-11-24 13:11:50 +09:00
Bill Currie
99a8e8f228
Fix the jump instruction.
...
The offset to compensate for st++ was missing.
Obviously, the code has never been tested. Found while looking at the
jump code and thinking about using 32-bit addresses for the jump tables.
2013-06-26 09:59:19 +09:00
Bill Currie
7c1d9d2b84
Make the angle and light hacks optional.
...
I'd forgotten that ED_ConvertToPlist mangled light into light_lev and
single component angle values into a vector. This fixes much of the
breakage in qflight (but not the light levels)
2013-03-07 09:11:23 +09:00
Bill Currie
675db274a6
Use Sys_Error instead of PR_Error in ED_ConvertToPlist.
...
ED_ConvertToPlist is now independent of the progs engine as its only use
for the progs_t * param was for PR_Error.
2013-03-07 09:11:22 +09:00
Bill Currie
7d2e938d37
Correct some error messages.
...
ED_ParseEntity has been ED_ConvertToPlist for a long time now.
2013-03-07 09:11:22 +09:00
Bill Currie
e27d7cbd2d
Handle alloca "correctly".
...
Use AC_FUNC_ALLOCA and the #ifdef mess suggested by the autoconf docs
(hidden in qfalloca.h).
2013-01-22 21:02:50 +09:00
Bill Currie
6b05a7e964
Add (%Ec) to OP_ADDRESS's format specifier.
...
This makes OP_ADDRESS and OP_LOAD_* consistent.
2013-01-17 16:43:54 +09:00
Bill Currie
c25e68ecaf
Use hex output for %E opcode format specifier.
...
This makes %E's addresses consistent with other address output.
2013-01-17 16:42:28 +09:00
Bill Currie
3c67e8f020
Fix the vector/quaternion scaling instructions.
...
It was pointed out by Blub\w (gmqcc) that OP_MUL_FV and friends were buggy
when the operands overlapped (eg, x = x.x * x) as the result would become
'x.x*x.x x.y*x.x*x.x x.z*x.x*x.x' (note the x.x squared for y and z). On
testing, sure enough the bug was present (and is a nice demonstration that
QF's VM does NOT have strict-aliasing bugs). As a very nice benefit: the
code produced by the fixes is actually faster than the broken version :).
The ruamoko code used for testing:
void (string fmt, ...) printf = #0 ;
vector foo (vector x)
{
x = x * x.x;
return x;
}
vector bar (vector x)
{
x = x.x * x;
return x;
}
int main ()
{
vector x = '2 3 4';
vector y = foo (x);
vector z = bar (x);
printf ("x=%v y=%v z=%v 2*x=%v\n", x, y, z, 2*x);
return 0;
}
2013-01-17 10:23:02 +09:00
Bill Currie
6b97967a68
Use g instead of e for the fp values.
...
Need to up the precision by one due to the difference between g and e, but
much prettier. Might need to rename that function :P I wish I'd thought to
check if g would work, but thanks to divVerent for the suggestion.
2013-01-08 20:15:24 +09:00
Bill Currie
b096a0242e
Write fp values to saved games with enough precision.
...
That is, enough precision to uniquely identify the fp values. No drifts!
2013-01-08 18:50:44 +09:00
Bill Currie
9155338404
Add support for int and quaternion values in saved games.
2013-01-08 18:09:22 +09:00
Bill Currie
3e2a40684c
Use dstring in PR_UglyValueString().
...
I should have done this a long time ago:P. This removes the really silly
255 char limit from strings in saved games (and thus fixes books in ITS).
2013-01-08 17:20:58 +09:00
Bill Currie
e0e69ac71a
Fix some signed/unsigned comparison warnings.
...
It seems mingw's gcc treats pointer subtraction differently to how linux's
gcc does.
2013-01-05 17:52:48 +09:00