Commit Graph

2164 Commits

Author SHA1 Message Date
Bill Currie 5b08ee768c [client] Clean up chase camera code
It's a lot easier to read (and see the difference between modes 2 and 3)
with all the ifs removed, and the state is properly is chasestate_t now
(though not handled properly on level reset etc).
2022-03-01 13:49:14 +09:00
Bill Currie 43a329dcb5 [client] Get the basic chase camera working
The more advanced modes are rather broken (continuous spinning), but
they may have been for a while. The bulk of the various changes were due
to renaming viewstate's origin and angles to make their meaning more
explicit.
2022-03-01 11:43:23 +09:00
Bill Currie fb83d87a0e Fix some distcheck issues
Just keeping up with myself.
2022-03-01 10:12:50 +09:00
Bill Currie 57dd4494cc [renderer] Pass in a camera transform
More r_data cleanup. Things could be better still, but this is a start.
2022-02-28 16:59:38 +09:00
Bill Currie ca9e8a3b68 [client] Pass time into locs_draw
This avoids unnecessary access to r_data.
2022-02-28 16:57:43 +09:00
Bill Currie 2477a44d15 [client] Move cshift info from viddef to viewstate
It makes much more sense for cshift state to be in viewstate because it
is very much an effect rather than anything specific to a renderer.
2022-02-28 16:55:12 +09:00
Bill Currie 7d059a0b56 [client] Merge nq and qw cl_view
They've been near-identical for years, now they're only one. It proved
necessary to start merging the HUD code which for now is just a few cvar
declarations (not even init), but that should be a separate set of
commits.
2022-02-28 12:12:51 +09:00
Bill Currie aac9069d9f [nq,qw] Clean up cl_view's use of the client struct
This is a huge step towards merging cl_view.
2022-02-25 16:54:45 +09:00
Bill Currie 5ad7c0fbd6 [scene] Add a camera object
It holds the data for a basic 3d camera (transform, fov, near and far
clip). Not used yet as there is much work to be done in cleaning up the
client code.
2022-02-25 10:41:50 +09:00
Bill Currie deff95f490 [client] Merge chase camera and much of input
Handling of view angles is a little hacky at the moment, but this gets
the chase camera code and most of the common input code into one place,
which will make cleaning up the camera code much easier.
2022-02-22 15:51:28 +09:00
Bill Currie 2615953e17 [scene] Move transform getters into inline functions 2022-02-21 08:33:41 +09:00
Bill Currie cd26073b6a [vulkan] Update the sky matrix
Regardless of whether the sky is spinning or not, the matrix needs to be
updated with the current origin in order to get the direction vector
right in the shader. Also, it's in the update that the required x-y
plane rotation gets in so the skies move in the correct direction.
2022-02-18 13:29:41 +09:00
Bill Currie 4f436e8245 [scene] Correct a comment
While the plethora of orientations for a reference frame is somewhat
annoying, having an incorrect description of the frame is much more
annoying.
2022-02-15 06:46:01 +09:00
Bill Currie 54f0af854b [ruamoko] Wrap the transform fuctions
Except for get/set name as I'm still pondering strings.
2022-02-15 00:06:39 +09:00
Bill Currie ba3879c6e0 [scene] Make transforms owned by the scene
This actually has at least two benefits: the transform id is managed by
the scene and thus does not need separate management by the Ruamoko
wrapper functions, and better memory handling of the transform objects.
Another benefit that isn't realized yet is that this is a step towards
breaking the renderers free of quake and quakeworld: although the
clients don't actually use the scene yet, it will be a good place to
store the rendering information (functions to run, etc).
2022-02-14 20:01:36 +09:00
Bill Currie 59044d3827 Fix a bunch of distcheck issues 2022-02-14 19:28:19 +09:00
Bill Currie afbca54faf [ruamoko] Add wrappers for the existing scene functions
I've run into a bit of an issue with transform management (really, just
need to make them owned by the scene, but that means creating a scene
for quake and quakeworld).
2022-02-14 16:43:10 +09:00
Bill Currie f6ac614e09 [scene] Add functions for scene and entity create/delete
Scene creation was already there, but now can be deleted, as can
entities.
2022-02-14 16:41:38 +09:00
Bill Currie 4d491a444d [gamecode] Fix handling of undefined builtins
The setup of the function descriptor for undefined builtins was
incomplete and led to the progs running code at address 0. It didn't end
well.
2022-02-14 14:28:19 +09:00
Bill Currie db8cf68ef3 [gamecode] Pass registered data pointer to builtins
This is the bulk of the work for recording the resource pointer with
with builtin data. I don't know how much of a difference it makes for
most things, but it's probably pretty big for qwaq-curses due to the
very high number of calls to the curses builtins.

Closes #26
2022-02-14 12:28:38 +09:00
Bill Currie 748f578856 [qw] Fix incorrect "server to client" log messages
It's not very helpful thinking all the packets are incoming to the
client.
2022-02-06 21:20:00 +09:00
Bill Currie 7c6ef06dfb [gamecode] Make PF_VarString v6p-only
It's not enforced a this stage, and it would be easy enough to handle,
but it turns out all the standard quake and quakeworld progs never used
... for the print functions: the behavior of PF_VarString was
undocumented and so... tough :P.
2022-02-06 21:20:00 +09:00
Bill Currie c10b09d41b [ruamoko] Make RUA_Sprintf more generally useful
It now takes the function name to print in error message (passed on to
PR_Sprintf) and the argument number of the format string. The variable
arguments (in ...) are assumed to be immediately after the format
argument.
2022-02-05 20:24:17 +09:00
Bill Currie 208cba85eb [gamecode] Move return buffer to end of progs memory map
With the return buffer in progs_t, it could not be addressed by the
progs on 64-bit machines (this was intentional, actually), but in order
to get obj_msg_sendv working properly, I needed a way to "bounce" the
return address of a calling function to the called function. The
cleanest solution I could think of was to add a mode to the with
instruction allowing the return pointer to be loaded into a register and
then calling the function with a 0 offset for the return value but using
the relevant register (next few commits). Testing promptly segfaulted
due to the 64-bit offset not fitting into a 32-bit value.
2022-02-05 18:37:23 +09:00
Bill Currie 9cf2740cb4 [gamecode] Create a globally accessible hash of type encodings
The plan is to use the types to extract the number of parameters for a
selector when it is necessary to know the count. However, it'll probably
become useful for something else alter (these things seem to always do
so).
2022-02-05 14:07:45 +09:00
Bill Currie 529253e6d9 [gamecode] Make edict macros more robust to null
A null edict pointer should product a null entity, not a segfault.
2022-02-05 10:17:57 +09:00
Bill Currie 974af36d13 [gamecode] Move profile out of the union
It happens to sit over the builtin data pointer and thus messes up
PR_Profile (any attempt to count calls to builtins).
2022-02-04 21:46:40 +09:00
Bill Currie 6514e09e7c [gamecode] Use an explicit size for the null page
It's currently only 4 (or even 3 for v6) words, but this fixes false
positives when checking for null pointers in Ruamoko progs due to
pr_return pointing to the return buffer and thus outside the progs
memory map resulting in an impossible to exceed value.
2022-02-01 16:43:29 +09:00
Bill Currie b8c2b7f856 [ruamoko] Make a common sprintf wrapper function
This takes care of converting from progs varargs to what PR_Sprintf
expects. I got tired of modifying the wrappers when I found a third one.
2022-02-01 09:27:03 +09:00
Bill Currie e1a0c31e3f [qfcc] Encode the new vector types
Thanks to the size of the type encoding being explicit in the encoding,
anything that tries to read the encodings without expecting the width
will simply skip over the width, as it is placed after the ev type in
the encoding.

Any code that needs to read both the old encodings and the new can check
the size of the basic encodings to see if the width field is present.
2022-01-30 16:00:49 +09:00
Bill Currie c467217b4b [simd] Use inttypes.h for long vector formats
Much nicer than cluttering up the headers with word-size checks.
2022-01-30 10:50:14 +09:00
Bill Currie 728c42e921 [gamecode] Use pr_type_names for debug views
I abandoned the reason for doing it (adding a pile of vector types), but
I liked the cleanup. All the implementations are hand-written still, but
at least the boilerplate stuff is automated.
2022-01-30 10:49:33 +09:00
Bill Currie 59ee723201 [gamecode] Rename parm to param
That misspelling bothered me from the very beginning, I'd always have
trouble getting the name right when trying to access one of those fields.
2022-01-27 10:55:06 +09:00
Bill Currie faa98d8198 [gamecode] Use a struct for offset/count pairs
This cleans up dprograms_t, making it easier to read and see what chunks
are in it (I was surprised to see only 6, the explicit pairs made it
seem to have more).
2022-01-26 19:30:25 +09:00
Bill Currie 00b7bced7f [gamecode] Rework PR_RESET_PARAMS to use PR_SetupParams
PR_SetupParams is new and sets up the parameter pointers so older code
that expects only up to 8 parameter will work with both v6p and Ruamoko
progs without having to check what progs are running. PR_SetupParams is
useful even when Ruamoko progs are expected as it reserves the required
space (respecting alignment) on the stack and returns a pointer to the
top (bottom? confusing) of the stack. PR_PushFrame and PR_PopFrame
need to be used around PR_SetupParams, regardless of using temp strings,
to avoid a stack leak (need to do an audit).
2022-01-24 12:50:15 +09:00
Bill Currie 9c51c3d2e1 [gamecode] Add a data pointer passed to builtin functions
This is part of the work for #26 (Record resource pointer with builtin
function data). Currently, the data pointer gets as far as the
per-instance VM function table (I don't feel like tackling the job of
converting all the builtin functions tonight). All the builtin modules
that register a resources data block pass that block on to
PR_RegisterBuiltins.
2022-01-24 00:20:05 +09:00
Bill Currie a818fa4b8e [gamecode] Rearrange bfunction_t in preparation for param offsets
The builtin and progs function data is overlaid so the extra data
doesn't cause too much memory to be used (it's actually 8 bytes smaller
now).  The plan is to pre-compute the offsets based on the parameter
size and alignment data.
2022-01-24 00:19:13 +09:00
Bill Currie a6b932025c [gamecode] Provide builtins with information about their parameters
This will make it possible for the engine to set up their parameter
pointers when running Ruamoko progs. At this stage, it doesn't matter
*too* much, except for varargs functions, because no builtin yet takes
anything larger than a float quaternion, but it will be critical when
double or long vec3 and vec4 values are passed.
2022-01-23 22:27:27 +09:00
Bill Currie e746e39738 [gamecode] Create macros for progs sizeof and alignof
I wound up needing the idioms in too many places.
2022-01-23 14:29:33 +09:00
Bill Currie 3c86660d4a [gamecode] Rename MAX_PARMS to PR_MAXPARAMS 2022-01-23 14:17:25 +09:00
Bill Currie cfaf158ebc [math] Add some bit-op functions
Just 32-bit rounding to next higher power of two, and base 2 logarithm.
Most importantly, they are suitable for use in initializers as they are
constant in, constant out.
2022-01-23 13:47:14 +09:00
Bill Currie 68d87de251 [gamecode] Clarify docs for PR_CallFunction
I found the docs in PR_ExecuteProgram and PR_CallFunction to be a little
confusing, so making it explicit that PR_ExecuteProgram calls
PR_CallFunction and that PR_CallFunction should be called only in a
builtin seemed like a good idea.
2022-01-22 11:38:26 +09:00
Bill Currie 06b1ea6837 [gamecode] Tweak some docs and macro names
And fix an incorrect definition for RETURN_QUAT.

Prefixed MAX_STACK_DEPTH and LOCALSTACK_SIZE (and LOCALSTACK_SIZE got an
extra _).

The rest is just edits to documentation comments.
2022-01-22 11:38:14 +09:00
Bill Currie 9199a0ee54 [gamecode] Don't check v6p progs for Ruamoko progs
It doesn't end well. For now, the Ruamoko check is just a stub, but I do
plan on doing similar checks.
2022-01-21 20:31:49 +09:00
Bill Currie 578314c5a3 [gamecode] Use a buffer for discarded return values
Due to how OP_RETURN works, a destination is required for any function
returning data, but the caller may not have allocated any space for the
value. Thus the VM maintains a buffer into which the data can be put and
ignored. It also makes a good place for return values when the engine
calls Ruamoko code as trusting progs code with return sizes seems like a
recipe for disaster, especially if the return location is on the C
stack.
2022-01-21 10:09:02 +09:00
Bill Currie 8d20997b2b [gamecode] Move pr_void_t to pr_comp.h
I think I had decided to put it there but forgot before committing the
size change, but I wound up needing it for qfcc.
2022-01-18 22:58:26 +09:00
Bill Currie 068c04ece6 [gamecode] Add ev_ushort and partial support
Really, only just enough to get everything compiling (which does include
vkgen running correctly).
2022-01-18 22:08:37 +09:00
Bill Currie ed501b7734 [gamecode] Specify the alignment for progs types
And provide a table for such for qfcc and the like. With this, using
pr_double_t (for example) in C will cause the double value to always be
8-byte aligned and thus structures shared between gcc and qfcc will be
consistent (with a little fuss to take care of the warts).
2022-01-18 18:41:39 +09:00
Bill Currie 25f8d3a23d [gamecode] Use pr_type_names.h for type sizes
The goal of the previous mess of commits. Ruamoko needs to wait until
qfcc has the new types.
2022-01-18 17:05:12 +09:00
Bill Currie cd30408675 [gamecode] Rename ev_quat to ev_quaternion
I much prefer the full name, though the short version is easier to type.
2022-01-18 17:05:12 +09:00