]> git.draconx.ca Git - rrace.git/log
rrace.git
3 months agoBump dxcommon to get curses configure fixes. master
Nick Bowler [Sun, 7 Jan 2024 04:02:41 +0000 (23:02 -0500)]
Bump dxcommon to get curses configure fixes.

3 months agotests: Skip reference RNG test on old compilers.
Nick Bowler [Sun, 7 Jan 2024 03:34:22 +0000 (22:34 -0500)]
tests: Skip reference RNG test on old compilers.

The reference implementation for xoshiro256** uses C99-style for loop
declarations, which cannot be compiled on some implementations (incl.
all versions of GCC in gnu89 mode).

Rather than changing the reference code (which kinda defeats the point)
arrange for the test to be skipped unless compiler support is available.

3 months agoRemove some stray C++-style // comments.
Nick Bowler [Sun, 7 Jan 2024 03:20:44 +0000 (22:20 -0500)]
Remove some stray C++-style // comments.

A couple of these slipped in by mistake.

3 months agoImprove RNG compatibility with old compilers.
Nick Bowler [Sun, 7 Jan 2024 03:14:42 +0000 (22:14 -0500)]
Improve RNG compatibility with old compilers.

Some C89 compilers with 32-bit longs won't automatically widen integer
constants to (unsigned) long long in order to represent values that
don't fit in an (unsigned) long, even if those compilers otherwise
support 64-bit long long.

The "ll" and "ull" suffixes seem to get things working.

3 months agoDon't build locale/wcwidth junk if NLS is disabled.
Nick Bowler [Sun, 7 Jan 2024 02:29:50 +0000 (21:29 -0500)]
Don't build locale/wcwidth junk if NLS is disabled.

These functions are only used for NLS support, so it is silly to
compile them if NLS is disabled for any reason.

To do this, we create a local "dx-nls" gnulib module which can in
turn use conditional dependencies to pull in all the (now optional)
modules.

3 months agoBump dxcommon to pull in testsuite fixes.
Nick Bowler [Sat, 6 Jan 2024 20:57:47 +0000 (15:57 -0500)]
Bump dxcommon to pull in testsuite fixes.

3 months agoewmhicon: Fix colourmap generation in w32vga mode.
Nick Bowler [Sat, 6 Jan 2024 07:31:15 +0000 (02:31 -0500)]
ewmhicon: Fix colourmap generation in w32vga mode.

The bitmap tracking which colours are used is not properly initialized
to zero, so the generated XPM potentially includes a bunch of garbage
in the colourmap section.

No idea why this went unnoticed before as it is completely not working
today.

4 months agoTrivial manual fixes.
Nick Bowler [Fri, 1 Dec 2023 05:52:55 +0000 (00:52 -0500)]
Trivial manual fixes.

For the literal program name, we need to use \- instead of - since
some troff processors turn plain "-" into "proper" unicode hyphens
(as opposed to hyphen-minus), which breaks copy+paste and searching.

Ensure that .Os follows .Dt in the mdoc prologue as apparently not
doing this results in broken manpage headings with groff 1.23.

4 months agoReplace gnulib patch with new common helper macro.
Nick Bowler [Fri, 1 Dec 2023 05:50:34 +0000 (00:50 -0500)]
Replace gnulib patch with new common helper macro.

Using the new DX_PATCH_GNULIB macro allows m4 to implement the
conditional dependency patches that were previously being done in
bootstrap, as well as removing the gl_CC_GNULIB_WARNINGS stub.

10 months agoReplace TAP testsuite macros with dxcommon versions.
Nick Bowler [Tue, 13 Jun 2023 01:19:20 +0000 (21:19 -0400)]
Replace TAP testsuite macros with dxcommon versions.

These were imported into dxcommon, so adjust the testsuite to use them.

10 months agoFix some missing #includes.
Nick Bowler [Mon, 29 May 2023 00:52:14 +0000 (20:52 -0400)]
Fix some missing #includes.

Instead of relying on transitive includes, ensure that the standard C
headers needed by some source files are actually included directly.

10 months agoFix distribution of copysym.h.
Nick Bowler [Mon, 29 May 2023 00:51:02 +0000 (20:51 -0400)]
Fix distribution of copysym.h.

This needs to be listed as a source file somewhere otherwise the
distribution will not include it.  Fix that up.

10 months agoReplace Gnulib striconv with copyright_symbol from dxcommon.
Nick Bowler [Sun, 28 May 2023 20:20:13 +0000 (16:20 -0400)]
Replace Gnulib striconv with copyright_symbol from dxcommon.

The only use of the striconv module is to produce the copyright symbol
for --version output and the about dialog in the Motif GUI.  Using the
new, single-purpose function reduces code size quite a bit.

10 months agoStop using gnulib's flexmember module.
Nick Bowler [Sat, 27 May 2023 06:14:23 +0000 (02:14 -0400)]
Stop using gnulib's flexmember module.

The only thing we're actually using from this module is provided
directly by Autoconf, via AC_C_FLEXIBLE_ARRAY_MEMBER, so we can
just use that macro instead.

14 months agomotif: Don't query widget width every timer update.
Nick Bowler [Thu, 26 Jan 2023 02:18:13 +0000 (21:18 -0500)]
motif: Don't query widget width every timer update.

Turns out that just getting the widget width from Xt represents
the vast majority of the time spent on the timer update.  It is
very simple to query the width only when it changes, instead,
and save that result for later rendering.

14 months agoPull in packed options fix from dxcommon.
Nick Bowler [Wed, 25 Jan 2023 06:02:07 +0000 (01:02 -0500)]
Pull in packed options fix from dxcommon.

This fixes build failures on the Sun Studio compiler.

14 months agotests: Add missing returns from test programs.
Nick Bowler [Tue, 24 Jan 2023 02:26:19 +0000 (21:26 -0500)]
tests: Add missing returns from test programs.

Failing to "return" from main is well-defined in C99, but older
implementations will have undefined results.  Easily solved.

15 months agoMix in PID with initial seed.
Nick Bowler [Fri, 13 Jan 2023 03:46:24 +0000 (22:46 -0500)]
Mix in PID with initial seed.

This may give slightly better results if the game timer is not
too precise, by avoiding a scenario where two instances of the
game started very close together have very similar initial states.

In reality this may be an extremely rare or even impossible scenario
with the current implementation, as the (im)precision of system time
functions is often related to system scheduler behaviour.  But it
shouldn't hurt, and the plan is to alter how the timers work and
this will become needed.

To this end, split out the timekeeping functions which allows them
to be easily stubbed out in test cases, and a new test case checks
that (with the nonfunctional timer) we still get different results
on different runs.

15 months agoSeparate EWMH colour conversion from icon generation.
Nick Bowler [Fri, 13 Jan 2023 01:55:56 +0000 (20:55 -0500)]
Separate EWMH colour conversion from icon generation.

We don't need to recompute the ARGB colour values for every single
pixel, we can do this in advance once for each possible colour.  To
do this, we alter the behaviour to use the 'pixel' member of the
supplied XColor array, and create a new function that can be called
beforehand to populate it based on red/green/blue values.

Interestingly, the ewmhicon test program was already providing an
XColor array with 'pixel' values that are correct for this new
behaviour, so it needs no changes, except a new mode is added
as a basic sanity check for the new function.

15 months agoPerformance improvements for runtime icon generation.
Nick Bowler [Thu, 12 Jan 2023 05:51:41 +0000 (00:51 -0500)]
Performance improvements for runtime icon generation.

As most of the rows for any given icon tile are the same as the
previously-generated row, it is not necessary to recompute the
colour values every single time.  The code can be adjusted to
re-use the previously-computed row instead.

Since the generic code now works on bytes, we can also replace the
open-coded loops in the row generation with a couple of memset calls,
which should help modern compilers produce more efficient output.

All this reduces the amount of computation done by the generic code
substantially, to roughly a quarter of what it was previously.

Also take the time to remove some unneeded complexity in the EWMH
formatting implementation, which further helps a little bit on the
code size front.

15 months agoUse new packed option format from gen-options.awk.
Nick Bowler [Sun, 8 Jan 2023 05:41:32 +0000 (00:41 -0500)]
Use new packed option format from gen-options.awk.

This new format uses a compact, fully constant array to generate the
real struct option array at runtime.  This allows the full-sized array
to be dropped after command-line processing is finished, and with
position-independent executables, reduces the amount of relocation
processing needed.

15 months agoAvoid linking against libXt/libXm string tables.
Nick Bowler [Sat, 7 Jan 2023 16:19:27 +0000 (11:19 -0500)]
Avoid linking against libXt/libXm string tables.

The libXt and libXm libraries contain huge (about 25 kB in total)
constant string tables, and the header files define macros that
offset these tables rather than using normal C strings.

The trouble is, on ELF systems with position-independent libraries,
accessing these tables from a program is very expensive.  Compilers
most commonly emit copy relocations that literally just duplicate
the entire table at runtime into the program's data segment.

As far as I can tell, this completely eliminates any possible advantage
of these tables: you use twice as much memory in a single program, the
copied data is not shareable between processes, and there is extra work
to actually perform these relocations.

Letting the program define its own strings avoids these relocations
and is substantially smaller, because only a handful of strings from
the tables are actually used.

They can still be shared if the program itself is compiled as PIC,
which adds GOT indirection to all accesses to the string table.  But
this actually increases the size of the program more than just using
normal string literals does.

Maybe these made sense to have in the library at some point in the
past, maybe once upon a time C compilers didn't merge string literals
between translation units and these tables were the solution.

I don't think these tables make sense today.  Fortunately, the headers
provide an option to disable this nonsense, at least for our program,
which we can just define in config.h.

15 months agoClear goal overlay when starting a new game.
Nick Bowler [Fri, 6 Jan 2023 03:46:00 +0000 (22:46 -0500)]
Clear goal overlay when starting a new game.

While it doesn't crash the game anymore, starting a new game with
the goal overlay remaining active nevertheless feels very strange.

15 months agoFix bitmap generation in goal overlay feature.
Nick Bowler [Wed, 4 Jan 2023 07:20:16 +0000 (02:20 -0500)]
Fix bitmap generation in goal overlay feature.

The board initialization procedure no longer ensures that unused bits of
the goal bitmap are zeroed.  When these are ORed with the game bitmaps,
it can result in bogus values for the outer tiles, which will either
render incorrectly or trip the assertion if the tile value is 7.

Normally only the objective area tiles get redrawn when the feature
is toggled on or off, which hides the problem most of the time, as
something else needs to trigger redraw of the outer tiles.  One way
to make this happen is to use the keyboard to start a new game while
holding down the right mouse button.

The best solution seems to be to just mask the goal bitmaps where
they are used.  As the same fix is needed in both the curses and
motif UIs, implement this new logic into a common function and add
a new test case to check for this bug.

15 months agox11: Avoid unneeded border clears.
Nick Bowler [Wed, 4 Jan 2023 04:19:10 +0000 (23:19 -0500)]
x11: Avoid unneeded border clears.

In commit 1ad1b0dcce2a ("motif: simplify border_clear implementation.")
we went slightly too far and actually removed all checks of the tile
mask value, so the border clear calls are done on every draw (only
during the blank border win state).

This kind of defeats the point of the expose handler excluding the blank
border tiles when calculating the mask that is passed in, and means the
rationale that the code being removed did literally nothing was not quite
accurate.

So, we still don't need the fancy computations, but we should check that
the provided mask says to redraw any part of the border before doing it.

15 months agomotif: Remove console printout when game is finished.
Nick Bowler [Wed, 4 Jan 2023 04:06:36 +0000 (23:06 -0500)]
motif: Remove console printout when game is finished.

This was implemented early on before there was GUI feedback upon
finishing the game.  It is no longer necessary.

15 months agomotif: Optimize widget string table a bit.
Nick Bowler [Wed, 4 Jan 2023 04:01:44 +0000 (23:01 -0500)]
motif: Optimize widget string table a bit.

With a little tweaking of how the tables are generated, we can include
a few of the traversal strings into the same table as the widget names,
which compacts things a little bit.

15 months agox11: Shrink colour initialization code.
Nick Bowler [Wed, 4 Jan 2023 02:26:31 +0000 (21:26 -0500)]
x11: Shrink colour initialization code.

Remove the large global XtResource array which is only used once at
program startup and replace it with a much more compact encoding,
(basically just the strings) which is sufficient to generate the
rest at runtime.  This appears to reduce the overall program size
quite a lot.

A further (very small) improvement is also realized by adjusting the
order of the resources to match the order in the state structure.

15 months agomotif: Combine status details into a single flags member.
Nick Bowler [Mon, 2 Jan 2023 22:15:27 +0000 (17:15 -0500)]
motif: Combine status details into a single flags member.

The timer_tick, view_goal_on_game and use_ewmh_icons values all are used
to encode just a single bit of information.  We can combine them into
a single member to reduce the overall size of the state structure.

Dropping the timer ID further enables a slight reorganization of the
timer process which seems to reduce the overall code size somewhat.

15 months agomotif: State structure cleanup
Nick Bowler [Sat, 31 Dec 2022 01:52:23 +0000 (20:52 -0500)]
motif: State structure cleanup

- We don't actually need to store the render task IDs in the
  state structure; the only thing we actually care about is to
  avoid multiple registration.  We can use two otherwise-unused
  bits of the render mask to track this.

- The window size tracking is no longer used, so these members
  are just a waste of space and can be removed.

- The remaining members can be rearranged to avoid padding.

15 months agomotif: Avoid constantly recalculating tile size.
Nick Bowler [Fri, 30 Dec 2022 17:16:13 +0000 (12:16 -0500)]
motif: Avoid constantly recalculating tile size.

Instead of calculating tile size every time any drawing is needed,
we can just store the value calculated during window layout.  This
involves some code reorganization to give the ResizeGameArea action
implementation direct access to the state structure.

Moreover, avoid dealing with width/height separately in the drawing
functions, as by design the game/goal areas (and therefore the tiles)
are always square.

15 months agoReimplement xcounter based on pre-rendered pixmpas.
Nick Bowler [Sat, 24 Dec 2022 05:24:25 +0000 (00:24 -0500)]
Reimplement xcounter based on pre-rendered pixmpas.

This alters the xcounter idea, instead of caching XmStrings and doing
full-blown font rendering with each update, we can pre-render all the
needed strings to a pixmap and stitch them together using XCopyArea.

This achieves basically the same visual result but clears are eliminated
completely which should further reduce the chances of visible flicker.

While we are rejigging this, tune the state structure to be much
more focused to the actual usage, preferring fixed limits and compact
data representation over dynamic allocation.

15 months agoFix memory leak in ewmh_probe_wm_icon.
Nick Bowler [Fri, 23 Dec 2022 07:01:36 +0000 (02:01 -0500)]
Fix memory leak in ewmh_probe_wm_icon.

The data returned by XGetWindowProperty must be freed by the caller;
this didn't happen so there is a small leak in this function.  Simple
enough to fix.

16 months agoCombine x11_redraw_icon and x11_redraw_goal.
Nick Bowler [Tue, 13 Dec 2022 06:07:25 +0000 (01:07 -0500)]
Combine x11_redraw_icon and x11_redraw_goal.

These functions do basically the same thing -- the main difference is the
destination drawable.  They are also often called together.  No need for
this duplication.

16 months agoPack/unpack the tile planes arithmetically.
Nick Bowler [Wed, 14 Dec 2022 03:10:15 +0000 (22:10 -0500)]
Pack/unpack the tile planes arithmetically.

Instead of a bunch of if statements, add a macro to extract an
individual tile value from the game/goal bitmaps using bitwise
arithmetic, and restructure the drawing paths to use it.

A similar change is made to populate the bitmaps during game board
initialization.  This simplifies the code a bit and also seems to
reduce the compiled size somewhat.

16 months agoAdd Gnulib dependency libs to all build targets.
Nick Bowler [Fri, 9 Dec 2022 00:53:40 +0000 (19:53 -0500)]
Add Gnulib dependency libs to all build targets.

Put it all into a single make variable to help ensure that nothing is
missed.  Moreover, we can add gnulib to the default LDADD which works
for most test programs (that do not have additional library deps).

16 months agomotif: simplify border_clear implementation.
Nick Bowler [Wed, 7 Dec 2022 06:37:25 +0000 (01:37 -0500)]
motif: simplify border_clear implementation.

This was cute, but since we no longer draw empty tiles in response to
expose events there are only two situations where the optimized border
clear is actually used:

  - when the game is won, or
  - when the window is resized.

In both cases the entire border needs to be cleared, meaning all this
code to reduce the number of drawing calls is optimizing for a case
that literally never happens.

16 months agoAlter x11_queue_render interface to better match usage.
Nick Bowler [Wed, 7 Dec 2022 06:04:37 +0000 (01:04 -0500)]
Alter x11_queue_render interface to better match usage.

Every call to this function updates exactly one of the goal or game
render bitmaps.  Instead of two masks, update the function to take a
single mask and a new parameter selects the bitmap to update.

This change enables more rendering code paths for the game/goal
areas to be merged.

16 months agomotif: Combine game/goal expose functions.
Nick Bowler [Wed, 7 Dec 2022 05:44:19 +0000 (00:44 -0500)]
motif: Combine game/goal expose functions.

These functions are almost identical.  A single function can serve
both purposes, allowing the overall code size to be reduced a little
bit.

16 months agoImprove exposure mask calculation.
Nick Bowler [Wed, 7 Dec 2022 05:16:41 +0000 (00:16 -0500)]
Improve exposure mask calculation.

By assuming that a >= b, the computation of

  board_left(a) & board_right(b)

can be simplified to

  board_left(a-b) << a.

which avoids some computation.  A similar improvement can be done
for board_above/board_below.  Add a new board_rect function that
incorporates these improvements, and use it to generate exposure
update bitmaps in the Motif UI.

A new test case exhaustively tests all possible inputs to this
function.

Furthermore, update board_above and board_below to have simpler
implementations.

16 months agoImprove game_check_goal implementation slightly.
Nick Bowler [Wed, 7 Dec 2022 03:40:10 +0000 (22:40 -0500)]
Improve game_check_goal implementation slightly.

It seems that, at least on x86, GCC can generate very slightly more
compact code by "expanding" the goal bitmap to match the game format,
rather what is currently done ("shrinking" the game bitmap to match
the goal format).

Add a sanity test case that checks the result of this function, which
makes such a change straightforward to do.

16 months agoFix configuration w/ --with-x.
Nick Bowler [Wed, 7 Dec 2022 02:24:09 +0000 (21:24 -0500)]
Fix configuration w/ --with-x.

A typo in the condition which verifies --with-x means configuration
always fails if this option is specified.  Fix that up.

16 months agoGenerate and install "locolor" icons.
Nick Bowler [Wed, 30 Nov 2022 04:20:48 +0000 (23:20 -0500)]
Generate and install "locolor" icons.

Since we now have the capability to generate nice enough 16-colour
icons, let's install them into the "locolor" theme.

It also turns out that icon installation was broken by the recent
rework, so as a bonus the "hicolor" icons are installed again too.
In an attempt to avoid this happening in the future, add a new
installcheck procedure which does a very basic sanity check.

16 months agoAdd a funky dithered 16-colour mode to ewmhicon.
Nick Bowler [Wed, 30 Nov 2022 01:41:07 +0000 (20:41 -0500)]
Add a funky dithered 16-colour mode to ewmhicon.

This adds a new option, --w32vga, which generates icons targeting the
16-colour "VGA" palette used by Windows.  This is the 8 combinations
of 0/max RGB values, plus the same set with the values halved, plus
a light gray.

This option enables a hand-coded pattern that approximates the desired
colours, and gives much more pleasing results in low colour modes.

16 months agoImprove portability of icon generating rules.
Nick Bowler [Wed, 30 Nov 2022 02:24:52 +0000 (21:24 -0500)]
Improve portability of icon generating rules.

Using $* in target rules is not portable; POSIX specifies that it is
only valid in inference rules and this is the case with several make
implementations.

Although this is a minor issue since the icons won't normally be
generated when building from a release, it is easy enough to fix.

16 months agoMake colour macros more flexible.
Nick Bowler [Wed, 30 Nov 2022 01:57:25 +0000 (20:57 -0500)]
Make colour macros more flexible.

Instead of COLOUR0_PRIMARY et al. expanding directly to X11 colour
names, allow the process to be hooked to generate other forms of
colour definitions.

The ewmhicon test program is adapted to use this to generate its
colourmap.  This also avoids some apparently nonportable C macro
usage, as preprocessing the following code:

  #define A(x) x
  #define B(x) x
  #define C (x)
  A(B C)

expands to x (the desired result) with GCC but B(x) on HP-UX cc.

16 months agoMake EWMH icon generation more abstract.
Nick Bowler [Wed, 30 Nov 2022 01:42:42 +0000 (20:42 -0500)]
Make EWMH icon generation more abstract.

Replace the low level EWMH icon drawing functions with new ones that are
much more generic: instead of the specific icon format these new ones
produce 1-byte-per-pixel images with user-controlled byte values.

These new functions will hopefully be useful for other kinds of icon
formats.  In particular, to directly create colour-index bitmaps without
working backwards from the ARGB values generated currently.

Then for the actual EWMH icon support wrap it all up in a single
function that allocates and creates all of the icon data in one shot,
using the new generic functions under the hood.  This simplifies the
calling code somewhat.

As a bonus, the overall code size seems to be reduced.

16 months agoImprove configure --help output.
Nick Bowler [Tue, 29 Nov 2022 02:01:06 +0000 (21:01 -0500)]
Improve configure --help output.

The AC_PATH_XTRA macro includes a pretty non-specific help message, we
can hack it a bit to produce a description more consistent with other
UI options.

16 months agoFix configuration w/ --with-curses.
Nick Bowler [Tue, 29 Nov 2022 01:53:27 +0000 (20:53 -0500)]
Fix configuration w/ --with-curses.

A typo in the condition that verifies --with-curses means the check
always passes, defeating the point of this option.  Fix that up.

16 months agox11: Fix redraw on window resize.
Nick Bowler [Sun, 27 Nov 2022 16:43:01 +0000 (11:43 -0500)]
x11: Fix redraw on window resize.

It turns out that relying on expose events to trigger redraw of certain
tiles when enlarging is not actually a good idea.  No expose events will
be generated if the new portion of the window is obscured while resizing,
which means tiles along the bottom or right edge of the game/goal areas
may not get redrawn when they should be.

We can avoid the redundant drawing on resize another way.  Instead of
redrawing immediately in response to resize or expose events, we just
mark those tiles as needing update and only actually redraw after a
short delay, which is hopefully enough to catch the expose events
directly generated by the resize.

17 months agoRestructure icon rebuild rules a bit.
Nick Bowler [Fri, 18 Nov 2022 04:12:14 +0000 (23:12 -0500)]
Restructure icon rebuild rules a bit.

The way that the build-icons rule is currently handled means that
'make install' is triggering compilation of the ewmhicon test program,
even if the icons are already available.

This is undesirable as 'make install' should normally not cause anything
to be compiled like that.  Split up the rules so that nothing gets built
until after the rule has actually determined that one or more icons are
missing.

17 months agoFix distribution of src/cursesui.h.
Nick Bowler [Fri, 18 Nov 2022 04:02:00 +0000 (23:02 -0500)]
Fix distribution of src/cursesui.h.

This file is not mentioned as a source file, so it is missing from
the distribution.

17 months agoAvoid Gnulib std-gnu11 module.
Nick Bowler [Fri, 18 Nov 2022 03:45:07 +0000 (22:45 -0500)]
Avoid Gnulib std-gnu11 module.

It has come to my attention that this module rewrites AC_PROG_CC in
a way that actually breaks Automake's AM_PROG_CC_C_O functionality.
This results in the "compile" script not being included or used in
packages bootstrapped with Autoconf 2.69.

With later versions of Autoconf things work because this module
doesn't touch things and thus disables itself.

I don't care about building with C11 one way or the other.  Let's
just skip the module.

17 months agox11: Improve redraw of empty spaces.
Nick Bowler [Wed, 16 Nov 2022 05:16:29 +0000 (00:16 -0500)]
x11: Improve redraw of empty spaces.

When the game area is showing only the middle portion with the empty
border, we can clear this with 4 or fewer draw calls instead of 16.
Let's handle this as a special case in the tile drawing code.

Moreover, we don't need to draw anything in these spaces on expose
events, as the exposed areas are already filled with the background.

17 months agoFix build on older Motif without XmPIXMAP_AND_STRING.
Nick Bowler [Wed, 16 Nov 2022 03:25:18 +0000 (22:25 -0500)]
Fix build on older Motif without XmPIXMAP_AND_STRING.

It seems that not all versions of Motif support labels with a labelType
of XmPIXMAP_AND_STRING.  This mode is used in the about dialog to
display the program's icon, but it's silly to fail compilation over
this.

Add a configure test to check if this feature is available, and fall
back to XmSTRING (which will render without the icon).

17 months agoFix curses build on HP-UX.
Nick Bowler [Wed, 16 Nov 2022 03:09:48 +0000 (22:09 -0500)]
Fix curses build on HP-UX.

On HP-UX, it seems that "lines" and "label_width" are defined as
object-like macros in <term.h> which causes dumb build failures
since this code is using those identifiers as variables.

Not too much hassle to just use a different name instead.

19 months agoDocument that the curses UI exists in the README.
Nick Bowler [Tue, 13 Sep 2022 01:28:54 +0000 (21:28 -0400)]
Document that the curses UI exists in the README.

22 months agoFactor out build-conditional wresize calls.
Nick Bowler [Sat, 18 Jun 2022 01:56:33 +0000 (21:56 -0400)]
Factor out build-conditional wresize calls.

Instead of using #if HAVE_CURSES_WRESIZE at each call site, we can
make a simple wrapper function that "works" in either case.

22 months agoUse gen-tree.awk to produce curses menu labels.
Nick Bowler [Sat, 18 Jun 2022 01:53:25 +0000 (21:53 -0400)]
Use gen-tree.awk to produce curses menu labels.

Instead of hardcoding the labels, we can use gen-tree.awk to
produce a compact description.

22 months agoCombine motifgui.dat / motifstr.str into one file.
Nick Bowler [Sat, 18 Jun 2022 01:39:50 +0000 (21:39 -0400)]
Combine motifgui.dat / motifstr.str into one file.

Pull in updated gen-tree.awk with support for comments, and use a
special comment syntax to allow simple strtab definitions in a single
file.  This allows keeping the menu label definitions together with the
menu tree, and reduces the number of generated headers to worry about.

22 months agocurses: Begin to implement a game menu system.
Nick Bowler [Sun, 12 Jun 2022 15:51:27 +0000 (11:51 -0400)]
curses: Begin to implement a game menu system.

Add the skeleton for very simple control interface based on function
keys.  Show labels along the bottom row for up to 10 functions, with
each corresponding to the first 10 function keys (or esc+number).

For now, hardcode two functions: new game and exit.  More to come.

22 months agoAdd a debug mode to make the game stupidly easy.
Nick Bowler [Sun, 12 Jun 2022 02:57:55 +0000 (22:57 -0400)]
Add a debug mode to make the game stupidly easy.

Implement an alternate version of game_reset, selectable by editing
the code, which always produces games that are winnable in just one
move.

This makes it much faster to manually test behaviour after game end.

22 months agocurses: Make the game winnable.
Nick Bowler [Sun, 12 Jun 2022 02:02:44 +0000 (22:02 -0400)]
curses: Make the game winnable.

Implement the overlay goal view and make the game stop when the
the puzzle is solved.

22 months agocurses: Add timer display.
Nick Bowler [Sat, 11 Jun 2022 22:55:39 +0000 (18:55 -0400)]
curses: Add timer display.

It seems timeouts interact very weirdly with mouse support in ncurses,
but enabling all the button events appears to avoid serious problems.

22 months agocurses: Parameterize vertical position of the game.
Nick Bowler [Sat, 11 Jun 2022 22:42:21 +0000 (18:42 -0400)]
curses: Parameterize vertical position of the game.

Move a bunch of magic constants into a single definition so that the
game's vertical position on the screen can be adjusted more easily.

22 months agoDon't use leaveok() in curses.
Nick Bowler [Wed, 8 Jun 2022 03:55:32 +0000 (23:55 -0400)]
Don't use leaveok() in curses.

Hiding the cursor seems unreliable, so when curs_set doesn't actually
work I think it's better to keep the cursor in some innocuous location
rather than having it randomly move around in the game area.

22 months agoEnsure manpages are distributed.
Nick Bowler [Wed, 8 Jun 2022 03:51:59 +0000 (23:51 -0400)]
Ensure manpages are distributed.

It seems using dist_man_MANS in an Automake conditional doesn't actually
ensure the manpage is distributed, so we need to just use man_MANS in
the conditional and EXTRA_DIST unconditionally.

22 months agoAdd basic keyboard control to curses UI.
Nick Bowler [Wed, 8 Jun 2022 03:44:01 +0000 (23:44 -0400)]
Add basic keyboard control to curses UI.

Since the mouse support in curses is not always available, we need to
provide a keyboard-based alternative.  The arrow keys move a cursor
around the positions in the game area, and space moves the selected
tile.

22 months agoCurses UI improvements.
Nick Bowler [Wed, 8 Jun 2022 01:38:13 +0000 (21:38 -0400)]
Curses UI improvements.

Add the goal area to the curses UI, and also leverage additional
configure tests to allow building against a wider variety of
curses implementations.

22 months agoFix reconfiguration when using --without-x.
Nick Bowler [Tue, 7 Jun 2022 00:01:41 +0000 (20:01 -0400)]
Fix reconfiguration when using --without-x.

We need to consider the user's selection when checking whether or not
to build the Motif UI, because the cached result may have come from a
prior configure run.

22 months agoAdd initial curses-based UI.
Nick Bowler [Sun, 5 Jun 2022 20:42:45 +0000 (16:42 -0400)]
Add initial curses-based UI.

To start getting an idea of what it takes to implement a game like this
with many different frontends, let's start by implementing a text-mode
user interface based on curses.

22 months agoAdd initial README.
Nick Bowler [Fri, 3 Jun 2022 04:58:57 +0000 (00:58 -0400)]
Add initial README.

22 months agoAdd COPYING
Nick Bowler [Fri, 3 Jun 2022 04:17:17 +0000 (00:17 -0400)]
Add COPYING

22 months agoDisplay a warning if configuring without any UI.
Nick Bowler [Thu, 2 Jun 2022 01:45:21 +0000 (21:45 -0400)]
Display a warning if configuring without any UI.

2 years agoImplement the about dialog.
Nick Bowler [Thu, 17 Mar 2022 00:07:21 +0000 (20:07 -0400)]
Implement the about dialog.

2 years agoCall setlocale on startup.
Nick Bowler [Mon, 14 Mar 2022 04:33:47 +0000 (00:33 -0400)]
Call setlocale on startup.

Failing to call this seems to affect the default X11 font selection
(wrong encodings, perhaps?) causing some display problems on HP-UX.

2 years agoAdd timer display.
Nick Bowler [Sun, 13 Mar 2022 04:21:41 +0000 (23:21 -0500)]
Add timer display.

2 years agoReduce redrawing on resize events.
Nick Bowler [Sat, 12 Mar 2022 23:16:39 +0000 (18:16 -0500)]
Reduce redrawing on resize events.

It is a waste of time redrawing parts of the window on resize that
will be redrawn due to expose events immediately afterwards.  This
is particularly noticeable when the program is first started and
everything is drawn twice.

2 years agoRestructure motif code a bit.
Nick Bowler [Sat, 12 Mar 2022 22:36:07 +0000 (17:36 -0500)]
Restructure motif code a bit.

Move the game input callback into motif.c, which essentially brings all
the user input parts together in one file and all the display parts in
the other file.

2 years agoReport changed positions from game_do_move.
Nick Bowler [Sat, 12 Mar 2022 21:31:12 +0000 (16:31 -0500)]
Report changed positions from game_do_move.

Instead of manually comparing positions before and after the move,
we can just alter the definition of game_do_move to return this
information, since it has already done most of the work internally.

2 years agoOnly redraw changed tiles when right clicking.
Nick Bowler [Sat, 12 Mar 2022 21:11:02 +0000 (16:11 -0500)]
Only redraw changed tiles when right clicking.

By changing the definition of game_check_goal to return a bit-mask
of mismatched positions, we can just pass that to the redraw mask to
reduce the amount of rendering needed.

2 years agoAdd build-time option to help debug X11 rendering.
Nick Bowler [Sat, 12 Mar 2022 21:15:24 +0000 (16:15 -0500)]
Add build-time option to help debug X11 rendering.

Add #define that can be manually set in config.h to enable additional
debug drawing.  This is intended purely for development.  Currently this
causes the system to highlight tiles before they are redrawn, in order
to watch things like expose handling and tile movement.

2 years agoTrack elapsed time of the game.
Nick Bowler [Thu, 10 Mar 2022 04:44:39 +0000 (23:44 -0500)]
Track elapsed time of the game.

Since this is a speed solving game, it is kind of important to know
how much time it took to solve the puzzle.  Start by adding a timer to
the game state so we can print elapsed time at the end.  Related GUI
elements will be coming later.

The game will no longer start immediately.  When the program is
launched, it will begin in a winning state.

2 years agoAdd a more direct way to specify the game background.
Nick Bowler [Thu, 10 Mar 2022 04:18:18 +0000 (23:18 -0500)]
Add a more direct way to specify the game background.

Rather than the user needing to know any details of the widget
hierarchy, add an application resource to set the game background
too (along with the tile colours).

We can also leverage Xt to allocate colours for us, which simplifies
things a bit.

2 years agoAdd a man page to explain the game and program options.
Nick Bowler [Thu, 10 Mar 2022 03:58:11 +0000 (22:58 -0500)]
Add a man page to explain the game and program options.

2 years agoAvoid uninitialized value error in help output.
Nick Bowler [Thu, 10 Mar 2022 03:53:18 +0000 (22:53 -0500)]
Avoid uninitialized value error in help output.

Technically simply passing an unitialized (indeterminate) arg value
to the help_print_option function has undefined behaviour even though
it is only unset in cases where it will not actually be used by the
function.  But it is easy to just ensure it has a well-defined value.

2 years agoRight clicking on game area now shows the objective.
Nick Bowler [Thu, 10 Mar 2022 02:51:22 +0000 (21:51 -0500)]
Right clicking on game area now shows the objective.

2 years agoSet default program title.
Nick Bowler [Thu, 10 Mar 2022 02:29:57 +0000 (21:29 -0500)]
Set default program title.

2 years agoAvoid motif headers in x11.c.
Nick Bowler [Thu, 10 Mar 2022 01:37:10 +0000 (20:37 -0500)]
Avoid motif headers in x11.c.

We don't actually use any of motif in this module aside from a couple
macros which alias Xt string definitions.  So let's stick with the Xt
names.

2 years agoMake tile colours configurable via X resources.
Nick Bowler [Thu, 10 Mar 2022 01:29:53 +0000 (20:29 -0500)]
Make tile colours configurable via X resources.

2 years agoReduce the amount of redundant drawing in the goal area.
Nick Bowler [Wed, 9 Mar 2022 06:31:27 +0000 (01:31 -0500)]
Reduce the amount of redundant drawing in the goal area.

Same treatment as the game area: on expose events we only need to
redraw the tiles that actually intersect the exposed area.

2 years agoReduce the amount of redundant drawing in the game area.
Nick Bowler [Wed, 9 Mar 2022 05:43:36 +0000 (00:43 -0500)]
Reduce the amount of redundant drawing in the game area.

We only need to redraw tiles that have changed after a move, or
(in the case of expose events) that intersect the exposed region.

2 years agoGenerate and distribute some icon files.
Nick Bowler [Wed, 9 Mar 2022 02:03:48 +0000 (21:03 -0500)]
Generate and distribute some icon files.

Since we now have code that generates nifty icons in various sizes,
we can fairly easily make use of it to generate and install icon
files.  These files need to be distributed because the application
cannot be run in the cross-compilation case, which will also avoid
the distribution depending on external image conversion utilities.

2 years agoFactor out common parts of icon generation.
Nick Bowler [Wed, 9 Mar 2022 02:08:46 +0000 (21:08 -0500)]
Factor out common parts of icon generation.

The row formatting in the four different icon files is basically
the same, and can be adapted into a common function.

2 years agoVery slightly simplify game_reset implementation.
Nick Bowler [Wed, 9 Mar 2022 02:07:48 +0000 (21:07 -0500)]
Very slightly simplify game_reset implementation.

2 years agoUse XPM as icon test output format.
Nick Bowler [Tue, 8 Mar 2022 06:08:29 +0000 (01:08 -0500)]
Use XPM as icon test output format.

The output of this test program is very close to XPM format.
So why not make it actually produce XPM format.  This gives
us a good way to have it output actual colour icons too.

2 years agoAllow compilation without X11.
Nick Bowler [Tue, 8 Mar 2022 04:35:22 +0000 (23:35 -0500)]
Allow compilation without X11.

At the moment this means nothing useful gets installed, but "make check"
is possible.  The icon functions being tested don't _really_ depend on
X11, just the XColor structure for which we can supply a suitable
definition.

2 years agoImplement window icons.
Nick Bowler [Tue, 8 Mar 2022 03:47:18 +0000 (22:47 -0500)]
Implement window icons.

2 years agoClean up redundant/unused declarations.
Nick Bowler [Sat, 5 Mar 2022 21:37:36 +0000 (16:37 -0500)]
Clean up redundant/unused declarations.

2 years agoAdjust X11 include ordering.
Nick Bowler [Sat, 5 Mar 2022 21:35:39 +0000 (16:35 -0500)]
Adjust X11 include ordering.

Some versions of Motif require <X11/Intrinsic.h> to be included before
<Xm/XmStrDefs.h> which results in build failures on HP-UX.