Commit Graph

1565 Commits

Author SHA1 Message Date
Bill Currie 4df926e531 Write extended ddef information to progs far data
I was originally going to put it in the debug syms file, but I realized
that the data persistence code would need access to both def type and
certainly correct def offsets for defs in far data.
2020-02-22 14:11:15 +09:00
Bill Currie c296514b95 Make pr.load_file 'return' the file size 2020-02-21 21:17:28 +09:00
Bill Currie fe796eee68 Move the meta type enum ino pr_type.h 2020-02-21 17:58:19 +09:00
Bill Currie 3c9e2a6451 Rename the sys documentation group 2020-02-21 17:54:42 +09:00
Bill Currie caf78b5422 Rename ty_none to ty_basic
This far better reflects the actual meaning. It is very likely that
ty_none is a holdover from long before there was full type encoding and
it meant that the union in qfcc's type_t had no data. This is still
true for basic types, but only if not a function, field or pointer type.
If the type was function, field or pointer, it was not true, so it was
misnamed pretty much from the start.
2020-02-21 17:52:00 +09:00
Bill Currie 2f18364364 Start work on encoding typedef chains 2020-02-19 21:41:46 +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 7a399c956b Encode function parameter alignment
The encoding is 3:5 giving 3 bits for alignment (log2) and 5 bits for
size, with alignment in the 3 most significant bits. This keeps the
format backwards compatible as until doubles were added, all types were
aligned to 1 word which gets encoded as 0, and the size is unaffected.
2020-02-16 17:10:43 +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 98216c6eb0 Fixed some missed doxygen updates 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 c50dda1d08 Document segmented text 2020-02-15 23:48:47 +09:00
Bill Currie 31501ad641 Add some docs for linked lists
Found in an old stash
2020-02-12 10:52:47 +09:00
Bill Currie 9248e8cf01 Update for doxygen 1.8.16 2020-02-11 15:22:42 +09:00
Bill Currie ab71311174 Correct some comments 2019-07-06 14:44:22 +09:00
Bill Currie 2ee36e8b99 Rename qfot_type_t.ty to meta
When I did up a ruamoko implementation of a type encoding dumper, I
named the field meta, which feels much better than ty.
2019-06-09 18:10:07 +09:00
Bill Currie f093516962 Move qfo type encoding structs
This makes them available to the gamecode VM, and thus the debugger.
2019-06-09 18:07:58 +09:00
Bill Currie f58c2fef5a Switch QF's quaterions from wxyz to xyzw.
After messing with SIMD stuff for a little, I think I now understand why
the industry went with xyzw instead of the mathematical wxyz. Anyway, this
will make for less pain in the future (assuming I got everything).
2018-10-12 14:33:55 +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 9501d30a8f Fix up a missing const attribute.
The problem with having such a complex build system :P
2018-10-11 11:29:12 +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 4872c56e2d Mark the end of the v6 opcodes. 2018-10-11 10:05:36 +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 89daf15215 Fix a c&p error in a doc comment. 2018-08-26 15:05:13 +09:00
Bill Currie 4f58429137 Fix an unhealthy pile of gcc 8 warnings.
While some of the warnings were merely annoying, some where actual bugs or
unearthed bugs in related code.
2018-08-20 00:05:00 +09:00
Bill Currie 0de0eb2fc7 Fix a bunch of bit-rot. 2018-06-08 13:21:30 +09:00
Bill Currie e1f9cb2028 Create an input subsection for the docs. 2016-01-04 17:24:13 +09:00
Bill Currie fb3396a21d Fix a typo in the key docs. 2016-01-04 16:20:57 +09:00
Bill Currie aecea5c350 Document most of they key binding system. 2016-01-04 16:11:15 +09:00
Bill Currie 7c16acf4aa Make Key_GetBinding take an imt instead of a name. 2016-01-04 16:06:48 +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 f0dc995c67 Handle c99 inline vs gnu89 inline.
The meaning of "extern inline" and "inline" swaps between the two, and
gcc-5 uses c99 inline.
2015-08-18 00:11:03 +09:00
Bill Currie d1f1375df5 Increase number of supported joystick buttons.
Also fix a bug where despite supporting 32 buttons, only 18 were actually
supported, and a similar issue for the number of axes.

My saitek x52 has 34 buttons and 10 axes. Whee.
2014-08-17 11:35:40 +09:00
Bill Currie 3fb9fb9373 Attempt to autoconfiscate gcc_struct.
It seems some tool-chains get rather picky about such things.
2014-02-03 16:47:51 +09:00
Bill Currie d80342e0a8 Fix some compile errors from Johnny's patch.
Turns out he has to compile without -Werror.
2014-02-02 16:42:08 +09:00
Bill Currie 9d71d9bb7a Remove maxwarpwidth and maxwarpheight.
Only the sw32 renderer even tried to use them, and they didn't get set
properly. This fixes JohnnyonFlame's waterwarp issue.
2014-02-02 14:41:58 +09:00
Bill Currie 8bea6a66ca Create _QFS_VOpenFile and QFS_VOpenFile.
_QFS_VOpenFile is actually _QFS_FOpenFile reimplemented to take vpath start
and end parameters so the search can be limited. QFS_VOpenFile,
_QFS_FOpenFile, and QFS_FOpenFile are all wrappers for _QFS_VOpenFile.
2014-01-28 16:22:05 +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 328b997843 Save the vpath in the model.
This will be used for restricting searches for auxiliary model files.
2014-01-28 16:22:05 +09:00
Bill Currie a561477274 Nuke QFS_LoadStackFile().
It was used in only one place and is really not necessary (these days,
anyway).
2014-01-28 16:22:05 +09:00
Bill Currie 25a060f369 Remove the foundname param from _QFS_FOpenFile.
It's now obsolete with qfs_foundfile.
2014-01-28 16:22:05 +09:00
Bill Currie 576c73cf7c Replace qfs_file_from_pak with qfs_foundfile.
This exposes the found name, vpath and in_pak status.
2014-01-28 16:22:05 +09:00
Bill Currie e5148493db Prepend qfs_ to file_from_pak.
A little better name-spacing.
2014-01-28 16:22:05 +09:00
Bill Currie 53d267c030 Correct some doc comments. 2014-01-28 16:22:05 +09:00
Bill Currie 6b87ddbb7c Add QFS_FindFile.
QFS_FindFile's search can be constrained to begin or end at a certain
vpath.
2014-01-28 16:22:04 +09:00
Bill Currie a5db0b1a65 Remove the now unnecessary GLSL_CompileShaderS().
Now that the transition to using shader effects is comlete, there's no
need for the wrapper.
2014-01-28 16:22:04 +09:00
Bill Currie 4bd82eb2b8 Add some documentation.
Nowhere near adequate.
2014-01-28 16:22:04 +09:00
Bill Currie 96c40cb9a1 Add basic support for shader "effects".
Again, based on The OpenGL Shader Wrangler. The wrangling part is not used
yet, but the shader compiler has been modified to take the built up shader.
Just to keep things compiling, a wrapper has been temporarily created.
2014-01-28 16:22:03 +09:00
Bill Currie d912970cd3 Add support for segmented text files.
The idea comes from The OpenGL Shader Wrangler
(http://prideout.net/blog/?p=11). Text files are broken up into chunks via
lines beginning with -- (^-- in regex). The chunks are optionally named
with tags of the form: [0-9A-Za-z._]+. Unnamed chunks cannot be found.
Searching for chunks looks for the longest tag that matches the beginning
of the search tag (eg, a chunk named "Vertex" will be found with a search
tag of "Vertex.foo"). Note that '.' forms the units for the searc
("Vertex.foo" will not find "Vertex.f").

Unlike glsw, this implementation does not have the concept of effects keys
as that will be separate. Also, this implementation takes strings rather
than file names (thus is more generally useful).
2014-01-28 16:22:03 +09:00
Bill Currie 247f3be0c0 Create reentrant versions of the set functions that need it.
Only the functions that allocate or delete sets or iterators.
2013-03-18 13:20:39 +09:00
Bill Currie 27bb337a60 Use set_bits_t for holding set elements.
set_bits_t is now 64 bits for x86_64 machines (in linux, anyway). This gave
qfvis a huge speed boost: from ~815s to ~720s.

Also, expose some of the set internals so custom set operators can be
created.
2013-03-16 21:26:49 +09:00
Bill Currie 6eec76dd49 Implement Fischer's SEB algorithm (for 3d).
Now we can get tight (<1e-6 * radius_squared error) bounding spheres. More
importantly (for qfvis, anyway) very quickly: 1.7Mspheres/second for a 5
point cloud on my 2.33GHz Core 2 :)
2013-03-13 17:10:55 +09:00
Bill Currie b6d4766201 Add a function to find the circumsphere of up to 4 points.
It seems to be a little sloppy (an error of a bit less than 1e-4). This
might be why I'm having trouble with my SEB code.
2013-03-13 14:35:30 +09:00
Bill Currie 0cd6d93030 Add a function to get the barycentric coords of a point.
It "works" for lines, triangles and tetrahedrons. For lines and triangles,
it gives the barycentric coordinates of the perpendicular projection of the
point onto to features. Only tetrahedrons are guaranteed to reproduce the
original point.
2013-03-12 14:16:42 +09:00
Bill Currie ca0b03687f Change the naming of ALLOC's free-list.
Rather than prefixing free_ to the supplied name, suffix _freelist to the
supplied name. The biggest advantage of this is it allows the free-list to
be a structure member. It also cleans up the name-space a little.
2013-03-08 22:16:31 +09:00
Bill Currie cb025838aa Fix a silly error in QF/alloc.h's FREE.
FREE was effectively a nop :P This fixes the crazy memory leak in qfvis.
2013-03-07 14:11:51 +09:00
Bill Currie eb2828e11c Add a function to pre-allocate space for a large set.
When the maximum set size is large but constant, and members will be added
one at a time, growing the set dynamically is not very efficient.
2013-03-07 10:27:30 +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 8e86ce9de9 Implement Sys_LongTime and wrap it with Sys_DoubleTime.
Sys_LongTime returns time in microseconds as a 64-bit int. Sys_DoubleTime
uses Sys_LongTime, converts to double and offsets 0 time by 4G (2**32).
This gives us consistent sub-microsecond precision for a very long time.

See http://randomascii.wordpress.com/2012/02/13/dont-store-that-in-a-float/
2013-02-27 14:29:28 +09:00
Bill Currie a611ad57de Add Sys_isdir. 2013-02-20 13:59:31 +09:00
Bill Currie 4e7e7c3ab0 Rename Sys_FileTime to Sys_FileExists.
The function never did anything but check the readability of the file.
2013-02-07 15:43:26 +09:00
Bill Currie bc2fa38468 Provide support for axis names.
x/y/z and pitch/yaw/roll (or p/y/r). Johnny's numbers still work, too, of
course.
2013-01-28 21:09:21 +09:00
Bill Currie 475d90e96f Expose Key_StringToKeynum. 2013-01-28 16:34:29 +09:00
Bill Currie 1a33d2f682 Do a whitespace run.
Just for long-term sanity's sake.
2013-01-27 14:05:24 +09:00
Johnny on Flame e3e0d6aaa9 Add menu commands + fixes 2013-01-27 13:17:13 +09:00
Johnny on Flame 637d751aa7 Saves axes behaviours on the config file. 2013-01-27 13:17:12 +09:00
Johnny on Flame 4f92bceb4f Joystick configuration commands. 2013-01-27 13:17:12 +09:00
Bill Currie b2e92c2864 Rewrite joy_axis and JOY_Move for axis buttons.
First, this completely smashes joystick input: it will not work (though it
doesn't crash). This is because there is, as of yet, no means to configure
the system.

Each joystick axis has:
    - per-axis amplification (both pre and post).
    - per-axis offset (offset applied after pre-amp but before post amp)
    - selectable destination:
        - linear delta: position and angles (as before)
        - axis button: if the value crosses the threshold, the given key is
          pressed or released as appropriate.

The axis amplification still uses joy_amp and joy_pre_amp (and
in_amp/in_pre_amp), but now also has the per-axis settings.

The per-axis offset is most useful for axis buttons. For example, the xbox
360 controller triggers are analong but go "all the way to negative on 0
state". Offsetting the input keeps axis button thresholds simple.

Amplification and offset is applied before anything is done with the axis
value. The formula is:

    joy_amp * in_amp * axis-amp *
        (offset + value * joy_pre_amp * in_pre_amp * axis-pre_amp)

Axis button thresholds are very simple: if the sign of the value is the
same as the sign of the threshold and abs(value) >= abs(threshold), the
button is pressed. While multiple thresholds and keys can be placed on an
axis, only one can be pressed at a time. The threshold furthest from 0
wins.
2013-01-23 13:15:02 +09:00
Bill Currie 35edfae2a0 Add keys for joystick axis buttons.
The idea is to allow a joystick axis to be mapped to button presses. These
allow the buttons to be bound without consuming other possibly valid keys.
2013-01-23 13:15:02 +09:00
Bill Currie ea7f446eff Add qfalloca.h to EXTRA_DIST.
make distcheck now passes again.
2013-01-23 11:58:45 +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 5188644e75 Implement the Mersenne Twister PRNG.
This gives QF a consistent qualilty PRNG on all platforms. The
implementation is slightly different from the standard, but gives the same
results for the same speed (details in mersenne.c).
2013-01-21 20:05:16 +09:00
Bill Currie e8721122b1 Use __attribute__((gcc_struct)) on dstatement_t.
Trust Microsoft to have really weird structure layout rules. Ah, well, this
fixes the weird progs errors Sock was getting.
2013-01-20 22:13:55 +09:00
Bill Currie ace8d9ebc5 Implement dynamic IMTs.
Now the user can create and destroy IMTs at will, though currently
destroying IMTs is currently all or nothing (imt_drop_all).

An IMT is created via imt_create which takes the keydest name (key_game
etc), the name of the IMT (must be unique for all IMTs) and optionally the
name of the IMT to which the key binding search will fall back if there is
no binding in the current IMT, but must be already defined and on the same
keydest. This means that IMTs now have user determined fallback paths. The
requirements for the fallback IMT prevent loops and other weird behaviour.

Actual key binding via in_bind is unaffected. This is why the IMT name must
be unique across all IMTs.

The "imt" command works with the key_game keydest, but imt_keydest is
provided for specifying the active IMT for a specific keydest.

At startup, default IMTs are setup to emulate the previous static IMTs so
old configs will continue to work (mostly). New config files will be
written with commands to drop all of the current IMTs and build new ones,
with the bindings and active IMT set as well.
2013-01-16 19:48:54 +09:00
Bill Currie ec6ba8a03c Make key_dest private to keys.c
This has the bonus feature of making nq pause the game when input focus is
lost (same conditions as dropping the console or bringing up the menu).
2013-01-16 19:48:54 +09:00
Bill Currie 5d8aab744f Eliminate key_none.
It is no longer needed as it was a hack to get key repeat control working
properly.
2013-01-16 19:48:54 +09:00
Bill Currie cf0729c818 Support more than one keydest callback. 2013-01-16 19:48:54 +09:00
Bill Currie 3cb0f3e183 Remove viddef in favor of vid in the renderers.
This fixes the status bar refresh issues in sw. The problem was that with
two viddef's hanging around, things got a little confused and recalc_refdef
wasn't getting into the renderer.
2013-01-16 11:23:47 +09:00
Bill Currie a8542c2d48 Correct the spelling of QFK_HIRAGANA_KATAKANA.
'twas QFK_HIRAGANA_kATAKANA. Took a while to spot it :P
2013-01-13 18:54:23 +09:00
Bill Currie e3b8157469 Create a new imt_menu imt.
It seems to work nicely as F10 no longer tries to quit while the menu is
displayed.
2013-01-13 18:19:00 +09:00
Bill Currie 86b95629cf Complete the move of some vars into vid_render_data.
scr_fullupdate and scr_copyeverything were missed. Possibly others too, but
this is enough for the moment.
2013-01-13 16:46:41 +09:00
Bill Currie 1503626847 Remove a stray variable declaration.
Quite bogus. How that got in there is beyond me.
2013-01-13 15:10:39 +09:00
Bill Currie 167977dfd9 Ensure ShortNoSwap is always uint16_t.
It turns out gcc on little endian machines didn't guarantee the type of
ShortNoSwap due to it being a macro that just returned its parameter. At
the same time, LongNoSwap and FloatNoSwap have been fixed.
2012-12-30 13:29:12 +09:00
Bill Currie 6eb6b6c0ba Change pointer_t to unsigned and clean up the mess.
It doesn't make sense to have negative pointers. The size of the commit is
from enabling gcc's -Wtype-limits warning and cleaning up that mess too.
2012-12-21 21:53:13 +09:00
Bill Currie 84a68b139e Rename set_iter_t's value to element.
Correct terminology and all :)
2012-12-21 14:09:00 +09:00
Bill Currie e17d8ac9db Add ruamoko wrappers for the set api.
This includes both normal functions and a Set class (and SetIterator
class). Most of the methods are implemented as builtins.
2012-12-16 13:48:36 +09:00
Bill Currie 3e38c4aa48 Merge branch 'qfcc-cse'
qfcc now does local common subexpression elimination. It seems to work, but
is optional (default off): use -O to enable. Also, uninitialized variable
detection is finally back :)

The progs engine now has very basic valgrind-like functionality for
checking pointer accesses. Enable with pr_boundscheck 2
2012-12-13 20:17:28 +09:00
Bill Currie 061e2be5d4 Re-write the set testing code.
Getting everything right with an enum proved to be too difficult if not
impossible. Also use better tests for equivalence and intersection.

Many more tests have been added. All pass :)
2012-12-09 13:52:48 +09:00
Bill Currie f3328a61c7 More tests and update a comment. 2012-12-07 22:16:07 +09:00
Bill Currie dbcf8f3774 Make the default map size smaller.
256 is pretty big. Now, set_t is always 32 bytes, giving 64 members for 64
bit machines and (probably) 128 members for 32 bit machines.
2012-12-07 20:41:23 +09:00
Bill Currie e0c92b6089 Rename set_iter_t's member to value.
Makes more sense now that the membership of the value depends on the
inversion of the set.
2012-12-06 21:11:38 +09:00
Bill Currie eb8fd55677 Move set.c into libQFutil.
Also move the ALLOC/FREE macros from qfcc.h to QF/alloc.h (needed to for
set.c).

Both modules are more generally useful than just for qfcc (eg, set
builtins for ruamoko).
2012-12-06 20:52:53 +09:00
Bill Currie a12eb940f1 Remove the hard-coded bsp maximum depths.
The depth limits in the gl and glsl renderers and in the trace code really
bothered me, but then the fix hit me: at load-time, recurse the trees
normally and record the depth in the appropriate place. The node stacks can
then be allocated as necessary (I chose to add a paranoia buffer of 2, but
I expect the maximum depth will rarely be used).
2012-11-28 21:29:03 +09:00
Bill Currie eb8dfd78d0 Fix a comment.
The information I most wanted wasn't there :P
2012-11-22 21:59:00 +09:00
Bill Currie 49ad301d3d Add improved memory checking to progs.
With pr_boundscheck >= 2, pointer access will be checked against allocated
blocks (qfvalgrind?:). Currently extremely basic, but it seems to work.
2012-11-19 20:03:21 +09:00
Bill Currie d5c831b6da Add a little test case for accessing types.
Using ruamoko to access ruamoko type encodings is actually quite pleasant
:)
2012-11-15 13:40:11 +09:00
Bill Currie ec42bde527 Make hash tables more const correct.
And clean up the resulting mess :/
2012-10-27 11:44:31 +09:00
Ozkan Sezer 6e04fd5ff6 signed int viddef_t members
The attached patch (against quakeforge git) changes the [con]width,
[con]height, and most importantly the rowbytes members of viddef_t
from unsigned to signed int, like in q2.  This allows for a properly
negative vid.rowbytes which may be needed in, e.g. a DIB sections
windows driver if needed.  Along with it, I changed a few places
where unsigned int is used along with comparisons against the relevant
vid.* members.
One thing I am not 100% sure is the signedness requirements of
d_zrowbytes and d_zwidth: q2 has them as unsigned but I am not sure
whether that is because they are needed as unsigned or it was just an
oversight of the id developers. They do look like they should be OK
as signed int to me, though: comments?

==
Note from Bill Currie: I had to do some extra changes as many
signed/unsigned comparisons were somehow missed.
2012-10-21 09:00:50 +09:00