]> git.draconx.ca Git - rrace.git/log
rrace.git
17 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.

17 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.

17 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.

17 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.

17 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.

23 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.

23 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.

23 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.

23 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.

23 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.

23 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.

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

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

23 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.

2 years agoFix boardmove testcase typo.
Nick Bowler [Sat, 5 Mar 2022 21:32:48 +0000 (16:32 -0500)]
Fix boardmove testcase typo.

Comparing "if (argv > 0)" is an obvious typo, totally invalid and bogus.
Weirdly GCC fails to complain without "-pedantic", but HP-UX cc is happy
to inform us about the error.

2 years agoFix distribution.
Nick Bowler [Sat, 5 Mar 2022 20:51:40 +0000 (15:51 -0500)]
Fix distribution.

2 years agoPull in gnulib for its portability features.
Nick Bowler [Sat, 5 Mar 2022 20:43:33 +0000 (15:43 -0500)]
Pull in gnulib for its portability features.

2 years agoCheck victory condition so the game is winnable.
Nick Bowler [Sat, 5 Mar 2022 07:58:34 +0000 (02:58 -0500)]
Check victory condition so the game is winnable.

2 years agoAdd a menu bar.
Nick Bowler [Sat, 5 Mar 2022 07:56:20 +0000 (02:56 -0500)]
Add a menu bar.

Including a "new game" option to reset the board.

2 years agoBetter colours
Nick Bowler [Fri, 4 Mar 2022 07:32:01 +0000 (02:32 -0500)]
Better colours

2 years agoImplement some basic gameplay.
Nick Bowler [Fri, 4 Mar 2022 07:17:05 +0000 (02:17 -0500)]
Implement some basic gameplay.

2 years agoInitial commit
Nick Bowler [Thu, 3 Mar 2022 04:37:18 +0000 (23:37 -0500)]
Initial commit