Commit graph

746 commits

Author SHA1 Message Date
Bill Currie
c6aa061229 [qwaq] Fetch Ruamoko progs locals from the stack frame
Now that the data is fetched from the correct location, the locals view
is useful again :). However, there seems to be a problem with array
views: not sure they're showing the correct data as I was getting
unexpected values in the display but normal vars seem to be ok.
2022-02-12 10:19:45 +09:00
Bill Currie
39583a959e [qwaq] Show only user local defs
While the .tmp defs weren't too much clutter in v6p progs, the .arg defs
in Ruamoko progs make for a lot of noise. Showing only user defs (those
without a leading .) makes for a much more usable locals display.
2022-02-12 10:19:21 +09:00
Bill Currie
fbb67419f2 [qwaq] Use RUA_Sprintf for non-va_list printers
This fixes the runtime error when the debugger gets to the end of the
gcd test program.
2022-02-05 20:26:06 +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
f4b81d30b0 [qwaq] Pass the correct selector when listeners respond
This is actually an old bug in qwaq that was masked by v6p progs
parameter passing: it was just luck that event got put in the correct
parameter and not trampled until the responder saw it. Ruamoko progs,
however, simply lost the event entirely because it never got explicitly
passed by the listener implementation.
2022-02-05 19:30:08 +09:00
Bill Currie
ab8692bd96 [qwaq] Allow return values through forwarded messages
This was easy to achieve in v6p progs because all return values passed
through .return and thus could not be lost. However, Ruamoko progs use a
return pointer which can wind up pointed into the void (the return
buffer) and thus cause the return value to be lost. Using @return on
obj_msg_sendv bounces the return pointer through to the called function.
In addition, nil is returned when the forwarding target is nil.
2022-02-05 19:30:08 +09:00
Bill Currie
1fa3acf2d7 [ruamoko] Support return values in message forwarding
This is the libr side of the return pointer bouncing.
2022-02-05 19:30:08 +09:00
Bill Currie
f94d5e9fdb [ruamoko] Correct decls for functions using PF_VarString
Need to ensure va_list gets into the arguments so PF_VarString can work
with Ruamoko progs.
2022-02-04 22:31:36 +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
98215b46ad [ruamoko] Cast autoreleaseIMP to avoid ...
The ABI for the Ruamoko ISA set currently puts va_list into the
parameter stream whenever a varargs function is called. Unfortunately,
IMP is declared with ... and thus cannot be used directly unless all
methods become varargs, but I think that would cause even more
headaches.
2022-01-31 23:37:03 +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
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
f72e8ef551 [qwaq] Fix a couple of errors in debug
Update qdb_get_string's mangling for qfcc's new unsigned int support and
fix an incorrect cast of the param pointer passed by prd_runerror that
caused a segfault when trying to use the string. Attempting to use
qwaq-app (ie, the qc debugger) on Ruamoko ISA progs mostly works, but
the defs are decidedly unhappy (due to the base registers).
2022-01-23 02:04:28 +09:00
Bill Currie
ac785ca752 [qwaq] Send app focus event on startup
Terminal apps effectively always have focus (unless I find a way to know
when an xterm loses/gains focus). Fixes input-app not updating on evdev
events.
2022-01-21 00:44:04 +09:00
Bill Currie
4ae9474396 [ruamoko] Use pr_type_names for type sizes
short and ushort are "wrong" (1 instead of 0, because qfcc currently
uses int for short), but now the array will always be in sync with the
enum.
2022-01-19 21:26:44 +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
e9e54d08c0 [gamecode] Rename func_t to pr_func_t
Even more consistency.
2022-01-18 15:36:58 +09:00
Bill Currie
afd1eb775b [gamecode] Rename ev_pointer to ev_ptr
Rather short (no worse than ev_int, though) but more consistency is
usually a good thing.
2022-01-18 14:36:06 +09:00
Bill Currie
2f6c3c8ffb [ruamoko] Use pr_type_names.h for Ruamoko
Keeping the two sets of definitions in sync has always been a pain.
2022-01-18 14:21:09 +09:00
Bill Currie
cfe7c44df0 [gamecode] Rename ev_integer to ev_int
And other related fields so integer is now int (and uinteger is uint). I
really don't know why I went with integer in the first place, but this
will make using macros easier for dealing with types.
2022-01-18 13:27:19 +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
4111d44dcc [gamecode] Move progs auxiliary headers into a subdirectory
Just another step along the road of tidying up the QF include directory
(and desirable for generated data).
2022-01-09 00:26:52 +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
be474d9937 [gamecode] Remove the wart from def and function names
I never liked the leading s_ (though I guess it means one is supposed to
interpret the int as a string pointer, but meh).
2021-12-31 15:02:31 +09:00
Bill Currie
2dc806cff5 [ruamoko] Clean up Entity a little
Hide own, and add some class spawn methods.
2021-12-30 13:26:36 +09:00
Bill Currie
8385046486 [qfcc] Warn when super dealloc invocation is missing
Forgetting to invoke [super dealloc] in a derived class's -dealloc
method has caused me to waste far too much time chasing down the
resulting memory leaks and crashes. This is actually the main focus of
issue #24, but I want to take care of multiple paths before I consider
the issue to be done.

However, as a bonus, four cases were found :)
2021-12-24 22:45:43 +09:00
Bill Currie
bcf80650f3 [ruamoko] Use the right index in disabled code
I have no idea why the code is disabled (especially considering the
comment), so leaving it that way for now, but this makes the code
compile when enabled.
2021-12-24 06:45:13 +09:00
Bill Currie
2b25748cc4 [ruamoko] Correct SetIterator memory handling
This makes SetIterator more compatible with autorelease.
2021-12-24 06:45:13 +09:00
Bill Currie
3ffdaccd50 [qwaq] Add an event handler for graphics
It's very much a hack, but it will do for now until I can rewrite the
whole thing: it's not at all thread safe, but it is over eight years
old and has survived a lot of bit-rot.
2021-12-24 06:45:13 +09:00
Bill Currie
f3918471d5 [ruamoko] Add bindings for the main IMT functions
IMT_SetContextCbuf is not bound as that requires cbuf to be bound.
However, imt contexts can be created, fetched and set.
2021-12-24 06:45:13 +09:00
Bill Currie
241785e952 [ruamoko] Move older math functions
The old math functions from quake and quakeworld don't belong with the
newer ones as their presence in the same object file causes invalid
builtin warnings when pr_cmds isn't present.
2021-12-24 06:45:13 +09:00
Bill Currie
a89aa7fc33 [ruamoko] Clean up ruamoko/lib rules
They were ok before the update to non-recursive make, but with the extra
bits of path, the rules got very hard to read.
2021-12-24 06:45:13 +09:00
Bill Currie
dcd1fa28ba [ruamoko] Get the input bindings working
With some hacks that are not included (plan on handling events and
contexts properly), button inputs, including using listeners, are
working nicely: my little game is working again. While the trampoline
code was a bit repetitive (and I do want to clean that up), connecting
button listeners directly to Ruamoko instance methods proved to be quite
nice.
2021-12-24 06:45:13 +09:00
Bill Currie
23e3b4c2e5 [ruamoko] Retrieve a plitem_t from PropertyList
And also internally for cross-builtin use.
2021-12-24 06:45:13 +09:00
Bill Currie
5e273a3693 [ruamoko] Make plitem_t easier to use
Or more accurately, struct plitem_s. Including the pointer in the
typedef made things a little awkward.
2021-12-24 06:45:13 +09:00
Bill Currie
f1d097c0c4 [ruamoko] Add bindings for Mercenne Twister 2021-12-24 06:45:13 +09:00
Bill Currie
6411518603 [ruamoko] Make some progress on the input bindings 2021-12-24 06:45:13 +09:00
Bill Currie
33e48025dd [ruamoko] Replace rua_key with rua_input
And create rua_game to coordinate other game builtins.

Menus are broken for key handling, but have been since the input rewrite
anyway. rua_input adds the ability to create buttons and axes (but not
destroy them). More work needs to be done to flesh things out, though.
2021-12-24 06:45:13 +09:00
Bill Currie
8e08f5f84e [qwaq] Drop qwaq-graphics.log
For now, at least. The client console takes over Sys_Printf and breaks
the logging.
2021-12-24 06:45:13 +09:00
Bill Currie
2cb987fdb5 [build] Clean up a pile of distcheck issues 2021-12-24 06:45:13 +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
d3853a2430 [qwaq] Update qwaq-x11's initialization
It now uses the advanced command line parsing used by qwaq-curses and
qwaq-cmd, but currently disables multi-threading (I don't want to deal
with threading in the engine just yet). The int file is -graphics
because qwaq-x11 is really just the X11 target, qwaq-win is built for
windows, but they use the same basic startup (I hope).
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
97c3cbf719 [qwaq] Rename input.c
It's very specialized toward terminal input (ie, for qwaq-curses).
2021-12-24 06:45:13 +09:00