Commit graph

831 commits

Author SHA1 Message Date
Bill Currie
5e041ef3f8 [qwaq] Remove the shutdown builtin
It proved to be a bad idea with the error handler stack.
2023-09-15 13:53:46 +09:00
Bill Currie
bce2b7d767 [ruamoko] Add sincos and sincosh functions
sincos is just a wrapper around the GNU libc sincos. sincosh is the
equivalent for sinh and cosh, but there doesn't seem to be any such
function, so it's just the two wrapped. They both return their results
in a vec2/vec2d as (sih[h], cos[h]).
2023-09-10 14:13:56 +09:00
Bill Currie
8a0246c910 [ruamoko] Add type info for algebra types
And get vector type views working in the debugger.
2023-08-26 23:01:01 +09:00
Bill Currie
f2cb62f2c8 [qwaq] Use VID_SendSize
Takes care of a FIXME I'd forgotten about, but was rather relevant to
this morning's changes.
2023-07-14 15:38:55 +09:00
Bill Currie
4e7bd11415 [build] Clean up make distcheck issues 2023-07-10 11:12:22 +09:00
Bill Currie
bf05da26cc [ui] Make Canvas_SetLen operate on only one canvas
I plan on using sub-canvases to fix the imui window overlap issue and
don't want the windows being affected by (eg) hud canvas size changes.
2023-07-08 20:56:40 +09:00
Bill Currie
0b0271ee76 [console] Provide control of cursor visibility
It's usually desirable to hide the cursor when playing quake, but when
using the console, or in various other states, being able to see the
cursor can be quite important.
2023-06-30 14:57:04 +09:00
Bill Currie
dc61d15340 [qfcc] Add failing test for array-typedef interaction
Two variables declared as arrays (same size) of different typedefs to
the same base type have their type encodings both pointing to the same
short alias.

From vkgen:

    51d3  ty_array  [4={int32_t>i}]      207f  0 4
    51d9  ty_array  [4=i]                1035  0 4
    51df  ty_alias  {>[4=i]}              16  51d9  51e6
    51e6  ty_array  [4={uint32_t>i}]     2063  0 4
    51ec  ty_union  {tag VkClearColorValue-} tag VkClearColorValue
	    4ca0     0 float32
	    51df     0 int32
	    51df     0 uint32

uint32 should use 51e6 and int32 should use 513d,
2023-06-30 02:39:51 +09:00
Bill Currie
2bf52e748a Merge branch 'wip-shadow' 2023-06-26 18:21:37 +09:00
Bill Currie
331f3320e2 [gatest] Rearrange the 2d PGA groups
Following the suggestions of Hamish Todd, group 0 forms the planar
quaternions (with the "complex number" in the first two components) and
transflections in group 1.
2023-06-08 22:46:02 +09:00
Bill Currie
0fbcd90e37 [gatest] Fix up layout issues for null vectors
e0 is created only if there are null vectors in the algebra, and the 3d
and 2d basis groups have been rearranged to compensate in the changed
ordering in the basis blade array.
2023-06-08 22:13:23 +09:00
Bill Currie
a40fee2513 [gatest] Calculate correct sign for duals
I was aware in the beginning that the signs were probably incorrect, but
I had left them as I wasn't sure how they worked.  Thanks to enki
(bivector community), I was pointed in the right direction for getting
the calculations right: the product of a basis blade with its dual
(x !x) must product the positive pseudo-scalar.
2023-06-08 13:02:13 +09:00
Bill Currie
2858870153 [gatest] Fix use of uninitialized multivector components
I guess I had forgotten that new_mv() does *NOT* initialize the
components. Things just happened to work (usually) because memory was
not getting recycled.
2023-06-08 13:00:32 +09:00
Bill Currie
68ca8c7016 [gatest] Switch to using e0 for the null vector
According to enki (bivector community) when there are more than one null
vector in a geometry, usually all vectors are null, and it was what to
do with multiple null vectors that caused me to balk at using e0 for the
null vector. However, using e0 for the null vector makes life much
easier, especially as that's what most of the literature does. There
are plenty of places, particularly in layout handling, that still need
adjustment for the change, but things seem to work (minus duals, but
they were broken in the first place, thus the discussion with enki).
2023-06-08 12:56:23 +09:00
Bill Currie
d0e2c0a9d9 [gatest] Allow specifying the algebra on the command line
Saves having to recompile for a different algebra. Right now, just
`-a p,m,z` is supported.
2023-05-29 15:14:59 +09:00
Bill Currie
65764a06c0 [gatest] Don't lex . as a single character
Lexing . as a single character makes it impossible to enter fractions.
Unfortunately, this means that . as dot product requires white space on
either side.
2023-05-29 15:13:27 +09:00
Bill Currie
6bd9aceb28 [ruamoko] Correct signatures of strtol and strtoul
I had forgotten the base parameter in the ruamoko definitions (verified
there in the C wrapper).
2023-05-29 15:12:20 +09:00
Bill Currie
681629a5d1 [gatest] Parse division and dual operations 2023-05-29 09:52:10 +09:00
Bill Currie
4e441d359a [gatest] Write a simple parser for playing with GA
Currently only PGA(3) is supported, but that's because the parser is
rather simple (recursive descent with a lame lexer), but it works well
enough for playing with geometric algebra without having to recompile
every time.
2023-05-27 12:47:33 +09:00
Bill Currie
582423a019 [ruamoko] Extend the string api
Wrap the strtod, strtof, strtol, strtoul functions, supporting the end
pointer as well (if not nil, the int offset of the end pointer relative
to the string start is returned).

Also, str_unmutable creates a return string from a mutable string
(copying it).
2023-05-27 12:47:33 +09:00
Bill Currie
a22c2224e0 [ruamoko] Fortify and extend the script api
Meaning some leaks have been plugged, and some useful functions added:
loading a file (avoids polluting progs memory), setting the single
character lexeme string, and getting the line number.
2023-05-27 12:47:33 +09:00
Bill Currie
6d5e8922a5 [qfcc] Add a handle type for engine resources
I never liked the various hacks I had come up with for representing
resource handles in Ruamoko. Structs with an int were awkward to test,
pointers and ints could be modified, etc etc. The new @handle keyword (@
used to keep handle free for use) works just like struct, union and
enum in syntax, but creates an opaque type suitable for a 32-bit handle.
The backing type is a function so v6 progs can use it without (all the
necessary opcodes exist) and no modifications were needed for
type-checking in binary expressions, but only assignment and comparisons
are supported, and (of course) nil. Tested using cbuf_t and QFile: seems
to work as desired.

I had considered 64-bit handles, but really, if more than 4G resource
objects are needed, I'm not sure QF can handle the game. However, that
limit is per resource manager, not total.
2023-05-25 10:41:28 +09:00
Bill Currie
db9a6a9a5c [ruamoko] Make cbuf functions take a cbuf param
A nil param refers to the default cbuf if it has been set by the engine,
otherwise it is invalid. This is the first step to fleshing out the cbuf
API.
2023-05-24 21:01:07 +09:00
Bill Currie
b9cff7aae0 [gatest] Implement and use multi-vector reverse
This gives the resultant point the correct sign.  Though the projective
divide would take care of the sign, this makes reading the point a
little less confusing (still need to sort out automatic blade reversals
for the likes of e31).
2023-05-24 18:25:47 +09:00
Bill Currie
42b0608e65 [qwaq] Get the console working for qwaq-x11
And other graphics versions too, of course. A lot of it feels rather
like a hack, but I think the entire canvas/console setup and console
related event handling may need a rethink (it's not horribly wrong, but
it doesn't feel right), particularly the initial sizing and binding for
toggling the console.
2023-05-24 12:44:16 +09:00
Bill Currie
7c9b6aa0cc [gatest] Use the metric when computing the dot product
As the dot product is a metric product, using the metric is vital to
getting the correct results. This fixes the calculation of the closest
point on a line to a point other than the origin (and a whole pile of
other issues, I imagine).
2023-05-22 13:03:35 +09:00
Bill Currie
d01fc27dd5 [gatest] Remove the workarounds for array lifetime
Now that arrays work well enough for this case, no point in having the
workarounds (other than they're actually faster, but I'd like to
optimize *that* sometime).
2023-05-21 22:20:38 +09:00
Bill Currie
008a64ee9b [gatest] Add multivector constructors to Algebra
This makes it much easier to create vectors of a specific grade or
grouping. It even found some mistakes in the multivector product
implementations.
2023-05-19 11:15:29 +09:00
Bill Currie
c1c77bd64a [gatest] Add basic geometric algebra test
This is for developing methods of implementing geometric algebra and
eventually playing with it visually.
2023-05-19 00:34:05 +09:00
Bill Currie
5f75616655 [ruamoko] Implement -describe for Set
Being able to use printf directly is nice :)
2023-05-17 21:09:00 +09:00
Bill Currie
451a98d391 [ruamoko] Avoid copying a block of memory to itself
Not a big deal, but valgrind didn't like it.
2023-03-28 13:23:14 +09:00
Bill Currie
eb41231559 [ruamoko] Avoid copying a block of memory to itself
Not a big deal, but valgrind didn't like it.
2023-03-28 13:21:57 +09:00
Bill Currie
7d4c1d79b1 [plist] Use reference counts for items
This makes it much easier to share items between property lists (eg,
targets and the main entity list in cl_light).
2023-03-13 11:26:13 +09:00
Bill Currie
8f87407133 [ruamoko] Add wrappers for the new plist functions
With both file and string versions (as per PL_GetPropertyList).
2023-03-12 14:35:17 +09:00
Bill Currie
9982eb629d [ruamoko] Plug another memory leak
Now running vkgen is leak-free (and, by extension, qwaq-cmd, it seems).

I'm really not sure why I used a dynamic array for that case.
2023-03-05 22:41:59 +09:00
Bill Currie
b84bf16cab [util] Add a function to reverse delete cbuf stacks
I'm not 100% sure this is the best fix for the issue, but the way the
cbuf interpreter stack works (especially in the console code) meant that
the stack was built in the order opposite to how it could be safely
deleted with the existing function. Yeah, more leaks :P
2023-03-05 18:31:30 +09:00
Bill Currie
340127fff2 [ruamoko] Plug yet more memory leaks
Some of them, especially in rua_obj, were quite legitimate and even a
problem for thread-safety (rua_cmd is currently not thread-safe, but it
needs a lock, which I don't feel like doing at this stage).
2023-03-05 18:31:30 +09:00
Bill Currie
3e30b7b9e2 [image] Allow color conversion caches to be cleaned up
More leaks, but only ruamoko takes advantage of it so far.
2023-03-05 18:31:30 +09:00
Bill Currie
3f9873a754 [console] Plug more memory leaks 2023-03-05 18:31:30 +09:00
Bill Currie
f9e442d323 [util] Make sys globals all thread-local
This was mainly for the shutdown functions, thus allowing Sys_Shutdown
(and Sys_RegisterShutdown) to be per-thread, but it seemed like a good
idea to make everything per-thread.
2023-03-05 18:31:30 +09:00
Bill Currie
be9e6893e5 [util] Free up hash links
Finally, hash links can be freed when the hash context is no longer
relevant. The context is created automatically when needed, and the
owner can delete the context when its done with the relevant hash
tables.
2023-03-04 02:07:31 +09:00
Bill Currie
44ad372adb [ruamoko] Clean up some memory leaks
So many sieves.
2023-03-04 00:50:27 +09:00
Bill Currie
8b8bc42038 [ruamoko] Own created property list objects
If the PLItem classes create a property list object, they own it. Plugs
more leaks.
2023-03-04 00:39:37 +09:00
Bill Currie
70aa970c32 [gamecode] Make modules responsible for freeing resources
It should have been this way all along, and it seems I thought they were
when I did rua_gui.c as it already freed its resource block, which would
have been a double free (oops). Fixes an invalid write when shutting
down progs in qwaq-cmd (relevant change not committed).
2023-03-03 20:26:00 +09:00
Bill Currie
2748f1c9f7 [ruamoko] Add support for PL_KeyAtIndex
I'd forgotten to wrap the function when I added it, but didn't need it
until now.
2023-02-14 12:45:04 +09:00
Bill Currie
35df90cb3f [ruamoko] Add qfot_basic_t to qfot_type_t
qfot_basic_t is necessary for getting at the width of basic value types
(int, uint, float, long, ulong, double) in order to distinguish between
scalars and vectors of those types.

I had forgotten this when doing the Ruamoko VM and qfcc changes.
2023-02-14 12:45:04 +09:00
Bill Currie
a561558748 [console] Switch to using a canvas for the console
While the console background is broken in that alpha doesn't work, it's
now rendered correctly in all renderers.
2023-01-22 03:45:50 +09:00
Bill Currie
68c7003991 [console] Separate loading and initialization
This will make it easy for client code to set up data needed by the
console before the console initializes. It already separates console
cvar setup and initialization, which has generally been a good thing.
2023-01-20 13:27:17 +09:00
Bill Currie
41d25df0d2 [ui] Attach text views to passage entities
Instead of creating new entities for the text views. This approximately
halves the number of entities required to display flowed text, but also
tests the ability to have an entity in multiple hierarchies (the goal of
the ECS component and system changes).
2022-12-14 22:38:37 +09:00
Bill Currie
b93ab95c47 [ruamoko] Add some builtins for passages and text
Just some basic implementation so I can test shaping of passage text.
2022-12-09 15:18:47 +09:00