Commit Graph

38 Commits

Author SHA1 Message Date
Bill Currie 973ae0ad54 [gamecode] Add PR_Shutdown for tearing down a VM
This is meant for a "permanent" tear-down before freeing the memory
holding the VM state or at program shutdown. As a consequence, builtin
sub-systems registering resources are now required to pass a "destroy"
function pointer that will be called just before the memory holding
those resources is freed by the VM resource manager (ie, the manager
owns the resource memory block, but each subsystem is responsible for
cleaning up any resources held within that block).

This even enhances thread-safety in rua_obj (there are some problems
with cmd, cvar, and gib).
2022-05-12 19:58:18 +09:00
Bill Currie 978d0306c0 [hash] Rename the publicly visible hashlink_t to hashctx_t
I think my biggest problem with the hashlink freelist parameter was how
much implementation it exposed in just the name.
2022-05-12 18:02:01 +09:00
Bill Currie 73d6e97e7b [qwaq] Ensure PR_Init_Cvars is called only once
Registering the same cvar more than once is currently a fatal error, but
qwaq was calling PR_Init_Cvars for each thread. Oops.
2022-04-29 16:59:15 +09:00
Bill Currie 12c84046f3 [cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.

As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.

The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).

While not used yet (partly due to working out the design), cvars can
have a validation function.

Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.

nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-24 19:15:22 +09:00
Bill Currie 2a9566d380 [qwaq] Handle memory alignment for windows builds 2022-03-05 14:17:48 +09:00
Bill Currie f3559cedb0 [qwaq] Plug a file handle leak
Forgot to call Qclose in load_file.
2022-02-14 14:41:14 +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 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 f714b6fbea [qwaq] Up qwaq progs heap to 2MB
or 512kW (kilowatts? :P). Barely enough for vkgen to run (it runs out if
auto release is run during scan_types, probably due to fragmentation). I
imagine I need to look into better memory management schemes, especially
since I want to make zone allocations 64-byte aligned (instead of the
current 8). And it doesn't help that 16 words per allocation are
dedicated to the zone management.

Anyway, with this, vgken runs and produces sufficiently correct results
for the rest of QF to build, so long as qfcc is not optimizing.
2022-02-01 14:57:16 +09:00
Bill Currie bea1155e9e [qwaq] Give qwaq progs a stack of 64kB
16kW should be enough as a default (when I get around to making it
configurable). Stops vkgen from trashing its heap with the stack.
2022-02-01 14:57:16 +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 175cc408d8 [qwaq] Update bi_printf to work with Ruamoko's va_list
Same deal as for test_bi in qfcc's test harness.  I really need to
consolidate all these little functions.
2022-01-31 23:44:09 +09:00
Bill Currie e3f88b2b9c [qwaq] Align progs memory to 64 bytes
It doesn't do much good for dynamic progs memory because zone currently
aligns to 8 bytes (oops, forgot to fix that), but at least the stack and
globals are properly aligned.
2022-01-31 23:40:21 +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 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 2df64384c1 [gamecode] Clean up string_t and pointer_t
They are both gone, and pr_pointer_t is now pr_ptr_t (pointer may be a
little clearer than ptr, but ptr is consistent with things like intptr,
and keeps the type name short).
2022-01-18 12:11:14 +09:00
Bill Currie 14d95f81d1 [gamecode] Remove PR_Opcode_Init
It was idempotent, then it became impotent. Now it's just not needed.
2022-01-07 19:25:34 +09:00
Bill Currie ad83422c56 [qwaq] Adapt startup code for use in a game engine
Until now, the new qwaq startup was used only in command-line tools and
console applications where things like Ruamoko security and having a
hunk were not an issue. Now the start up code (qwaq-*.c) can specify
that Ruamoko is to be secured and provide a hunk on a per-thread basis,
and the thread data is passed into the progs code via a progs resource.
2021-12-24 06:45:13 +09:00
Bill Currie 0e7e88815c [qwaq] Fix up file headers 2021-12-24 06:45:13 +09:00
Bill Currie f18e1366ba [vulkan] Silence vkgen's debug output
It was hidden by qwaq-curses, but the switch to using qwaq-cmd made it
pretty obvious.
2021-07-06 12:27:21 +09:00
Bill Currie ae58a8ba5d [qwaq] Create a commandline-only version of qwaq
qwaq-curses has its place, but its use for running vkgen was really a
placeholder because I didn't feel like sorting out the different
initialization requirements at the time. qwaq-cmd has the (currently
unnecessary) threading power of qwaq-curses, but doesn't include any UI
stuff and thus doesn't need curses. The work also paves the way for
qwaq-x11 to become a proper engine (though sorting out its init will be
taken care of later).

Fixes #15.
2021-07-06 12:25:24 +09:00
Bill Currie e81d690b51 [input] Create QF input library using keys.c
This refactors (as such) keys.c so that it no longer depends on console
or gib, and pulls keys out of video targets. The eventual plan is to
move all high-level general input handling into libQFinput, and probably
low-level (eg, /dev/input handling for joysticks etc on Linux).

Fixes #8
2021-07-05 16:26:07 +09:00
Bill Currie f50d27ec11 [qwaq] Show dereferenced data for poitner defs
The code currently assumes a single value is referenced rather than the
beginning of an array.
2021-06-04 13:35:53 +09:00
Bill Currie 1e9329ccf6 [nq,qw] Stop wring to config.cfg
QF now uses its own configuration file (quakeforge.cfg for now) rather
than overwriting config.cfg so that people trying out QF in their normal
quake installs don't trash their config.cfg for other quake clients. If
quakeforge.cfg is present, all other config files are ignored except
that quake.rc is scanned for a startdemos command and that is executed.
2021-04-12 22:09:09 +09:00
Bill Currie 6fea5f5e1a [build] Add -Wformat-non-literal option
While this caused some trouble for pr_strings and configurable strftime
(evil hacks abound), it's the result of discovering an ancient (from
maybe as early as 2004, definitely before 2012) bug in qwaq's printing
that somehow got past months of trial-by-fire testing (origin understood
thanks to the warning finding it).
2021-03-29 17:27:06 +09:00
Bill Currie 88ff254f42 Get QF cross-compiling using MXE/mingw32
This includes -win clients (no clue if anything actually works yet).
2021-03-27 20:09:37 +09:00
Bill Currie 0bfb60775e [util] Ensure hunk allocs are cache alligned
This doesn't seem to make much difference in the vulkan renderer, but it
certainly doesn't hurt.
2021-02-03 13:19:19 +09:00
Bill Currie 7970525ef4 [util] Make va thread-safe
It now takes a context pointer (opaque data) that holds the buffers it
uses for the temporary strings. If the context pointer is null, a static
context is used (making those uses of va NOT thread-safe). Most calls to
va use the static context, but all such calls have been formatted
consistently so they are easy to find when it comes time to do a full
audit.
2021-01-31 16:05:48 +09:00
Bill Currie ab04a1915e [build] Fix a pile of gcc 10 issues
gcc got stricter about array accesses, complicating progs macros, and
much better at detecting buffer overflows.
2020-12-21 14:14:29 +09:00
Bill Currie 8290e3800f [qwaq] Ensure main thread return code gets returned
Needed for catching vkgen errors during the build.
2020-07-16 22:14:19 +09:00
Bill Currie 64100efe78 [qwaq] Fix a typo 2020-07-05 16:53:35 +09:00
Bill Currie 7f96b0fbed [qwaq] Fix incorrect setting of progs argc/argv 2020-06-28 18:30:01 +09:00
Bill Currie 6d5ffa9f8e [build] Move to non-recursive make
There's still some cleanup to do, but everything seems to be working
nicely: `make -j` works, `make distcheck` passes. There is probably
plenty of bitrot in the package directories (RPM, debian), though.

The vc project files have been removed since those versions are way out
of date and quakeforge is pretty much dependent on gcc now anyway.

Most of the old Makefile.am files  are now Makemodule.am.  This should
allow for new Makefile.am files that allow local building (to be added
on an as-needed bases).  The current remaining Makefile.am files are for
standalone sub-projects.a

The installable bins are currently built in the top-level build
directory. This may change if the clutter gets to be too much.

While this does make a noticeable difference in build times, the main
reason for the switch was to take care of the growing dependency issues:
now it's possible to build tools for code generation (eg, using qfcc and
ruamoko programs for code-gen).
2020-06-25 11:35:37 +09:00
Bill Currie 63caa5794d [qwaq] Implement step-over tracing
I decided that stopping in between function calls that are on the same
line is a good thing as it gives a chance to skip over the first but
step into the second.
2020-04-02 17:44:53 +09:00
Bill Currie c09f57c39e [gamecode] Delay .ctor calls if debugging
This allows a debugger to do any symbol lookups and other preparations
between loading progs and the first code execution. .ctors are called as
per normal if debug_handler is not set.
2020-04-02 17:39:11 +09:00
Bill Currie 6d8bc395f4 [qwaq] Make debug event data available 2020-04-02 12:30:59 +09:00
Bill Currie 1d5058d267 [qwaq] Move progs create and load into the threads
While this does answer the question of how I'll go about restarting the
target progs (when I get to that point), it was required just to start
full-on ruamoko progs because .ctor was getting run in the main thread
and blocking due to trace.
2020-04-02 00:11:47 +09:00
Bill Currie 6ff5b5c101 [qwaq] Clean up the qwaq directory
Things were getting rather cluttered with everything being qwaq-* and
all in one directory. Now most have lost the qwaq- prefix and have been
moved into subdirectories (non-recursive make).
2020-03-30 02:34:08 +09:00
Renamed from ruamoko/qwaq/main.c (Browse further)