<feed xmlns='http://www.w3.org/2005/Atom'>
<title>puzzles/samegame.c, branch master</title>
<subtitle>My sgt-puzzles tree</subtitle>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/'/>
<entry>
<title>Use move_cursor() for cursor movement in Same Game</title>
<updated>2023-08-09T13:32:31+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-08-09T13:32:31+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=7e9228f15472ed1d9a691ac9b41ae52436e10cdf'/>
<id>7e9228f15472ed1d9a691ac9b41ae52436e10cdf</id>
<content type='text'>
No significant behavioural change.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
No significant behavioural change.
</pre>
</div>
</content>
</entry>
<entry>
<title>Same Game: level-triggered keyboard cursor hiding</title>
<updated>2023-08-01T22:07:08+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-08-01T22:07:08+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=ff860360c3eb6b146674384a15d10fde788bd545'/>
<id>ff860360c3eb6b146674384a15d10fde788bd545</id>
<content type='text'>
Same Game doesn't want to show the keyboard cursor when the game is in a
state where no move is possible.  Previously, it did this by having
game_changed_state() hide the cursor on entry to such a state.  That
meant that reaching a dead end and undoing out of it hid the cursor,
which was confusing.

Now the cursor is hidden in game_redraw() if the game is in a dead-end
state without changing the displaysel flag in the game_ui.  That way, if
you undo out of a dead end, the cursor becomes visible again if it was
visible before.

This does mean that you can move the cursor in a dead-end state without
being able to see where it's going.  I think that's tolerable, but maybe
the cursor keys should be disabled in that state as well.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Same Game doesn't want to show the keyboard cursor when the game is in a
state where no move is possible.  Previously, it did this by having
game_changed_state() hide the cursor on entry to such a state.  That
meant that reaching a dead end and undoing out of it hid the cursor,
which was confusing.

Now the cursor is hidden in game_redraw() if the game is in a dead-end
state without changing the displaysel flag in the game_ui.  That way, if
you undo out of a dead end, the cursor becomes visible again if it was
visible before.

This does mean that you can move the cursor in a dead-end state without
being able to see where it's going.  I think that's tolerable, but maybe
the cursor keys should be disabled in that state as well.
</pre>
</div>
</content>
</entry>
<entry>
<title>Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Same Game</title>
<updated>2023-07-31T22:08:20+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-07-31T22:08:20+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=0dd01866627e82ea21ed0e85021abdb070e0159c'/>
<id>0dd01866627e82ea21ed0e85021abdb070e0159c</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Same Game: don't hide keyboard cursor on unrecognised keys</title>
<updated>2023-07-31T22:02:45+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-07-31T22:02:45+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=ecb3a9d6f219e95c694d7857f579c9ef2ebad064'/>
<id>ecb3a9d6f219e95c694d7857f579c9ef2ebad064</id>
<content type='text'>
Pressing "undo", for instance, should leave the keyboard cursor
visible if it's visible already.  Only mouse clicks should hide it.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pressing "undo", for instance, should leave the keyboard cursor
visible if it's visible already.  Only mouse clicks should hide it.
</pre>
</div>
</content>
</entry>
<entry>
<title>Same Game: scale TILE_GAP with tilesize</title>
<updated>2023-07-31T21:39:33+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-07-31T21:39:33+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=56237fa5fa0c2c56785f3667cb7d013dc9779352'/>
<id>56237fa5fa0c2c56785f3667cb7d013dc9779352</id>
<content type='text'>
TILE_GAP represents the gap between the coloured parts of adjacent
different-coloured tiles.  Rather than a fixed 2 pixels, it's now 1/16
of the tilesize (rounded to nearest).

This looks the same at the default tilesize of 32, but behaves better
with larger or smaller tilesizes.  At tilesizes below 8, the gap
disappears altogether, but that seems appropriate: at 7 pixels there's
not much space for the inner and outer squares and the cursor, and those
are all more important than the gap..
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
TILE_GAP represents the gap between the coloured parts of adjacent
different-coloured tiles.  Rather than a fixed 2 pixels, it's now 1/16
of the tilesize (rounded to nearest).

This looks the same at the default tilesize of 32, but behaves better
with larger or smaller tilesizes.  At tilesizes below 8, the gap
disappears altogether, but that seems appropriate: at 7 pixels there's
not much space for the inner and outer squares and the cursor, and those
are all more important than the gap..
</pre>
</div>
</content>
</entry>
<entry>
<title>Same Game: more efficient tile_redraw</title>
<updated>2023-07-30T10:52:05+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-07-30T10:30:19+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=58511aa009c672cc2ade783d537a5830806fd02c'/>
<id>58511aa009c672cc2ade783d537a5830806fd02c</id>
<content type='text'>
I've rewritten tile_redraw to reduce the number of calls to
draw_rect().  Before, it would generally make five calls to
draw_rect() when drawing a tile.  Now it makes at most three, and
usually two.  That's one draw_rect() for each colour that appears in
the tile, which is as good as it can get.  This reduces the time to
draw a large puzzle by about 35% on Firefox 102.

This is of significance to me because CanvasRenderingContext2D on my
test KaiOS device seems to have a limit on the number of fill() and
fillRect() calls that it will tolerate in a short time.  This means
that if you issue more than 1024 fillRect() calls in rapid succession,
the later ones are simply ignored.

Same Game's largest preset called draw_rect() so much that it hit this
limit.  That meant that the right-hand side of the grid didn't get
properly drawn when starting a new game.  Now that it is less
profligate with draw_rect() it fits comfortably within the limit and I
get to see the entire grid.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I've rewritten tile_redraw to reduce the number of calls to
draw_rect().  Before, it would generally make five calls to
draw_rect() when drawing a tile.  Now it makes at most three, and
usually two.  That's one draw_rect() for each colour that appears in
the tile, which is as good as it can get.  This reduces the time to
draw a large puzzle by about 35% on Firefox 102.

This is of significance to me because CanvasRenderingContext2D on my
test KaiOS device seems to have a limit on the number of fill() and
fillRect() calls that it will tolerate in a short time.  This means
that if you issue more than 1024 fillRect() calls in rapid succession,
the later ones are simply ignored.

Same Game's largest preset called draw_rect() so much that it hit this
limit.  That meant that the right-hand side of the grid didn't get
properly drawn when starting a new game.  Now that it is less
profligate with draw_rect() it fits comfortably within the limit and I
get to see the entire grid.
</pre>
</div>
</content>
</entry>
<entry>
<title>Use the standard game_mkhighlight in Same Game</title>
<updated>2023-07-27T22:06:46+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-07-27T22:06:46+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=9e4e15fda22e0ed8e5c6ea671f17bd76ead0d317'/>
<id>9e4e15fda22e0ed8e5c6ea671f17bd76ead0d317</id>
<content type='text'>
This should ensure that the cursor is visible on the background.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This should ensure that the cursor is visible on the background.
</pre>
</div>
</content>
</entry>
<entry>
<title>Same Game: darken light colours to make keyboard cursor visible</title>
<updated>2023-07-27T21:50:51+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-07-27T21:46:50+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=d4d8e5bfc878b99f422daf1ec2a7d0974698e98d'/>
<id>d4d8e5bfc878b99f422daf1ec2a7d0974698e98d</id>
<content type='text'>
The keyboard cursor in Same Game is white.  The default yellow,
cyan, and light green were light enough to make the cursor hard to
see.  I've darkened them all (without changing their hues) so that the
cursor is acceptably visible.  This doesn't leave an ideal set of
colours, but they are at least still adequately distinct from one
another.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The keyboard cursor in Same Game is white.  The default yellow,
cyan, and light green were light enough to make the cursor hard to
see.  I've darkened them all (without changing their hues) so that the
cursor is acceptably visible.  This doesn't leave an ideal set of
colours, but they are at least still adequately distinct from one
another.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix some unused-variable warnings.</title>
<updated>2023-06-16T18:04:50+00:00</updated>
<author>
<name>Simon Tatham</name>
<email>anakin@pobox.com</email>
</author>
<published>2023-06-16T18:03:56+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=c82537b4574d45aa16e50b7f8dc1f075cfdb69f9'/>
<id>c82537b4574d45aa16e50b7f8dc1f075cfdb69f9</id>
<content type='text'>
A test-build with a modern clang points out a number of 'set but not
used' variables, which clang seems to have got better at recently.

In cases where there's conditioned-out or commented-out code using the
variable, I've left it in and added a warning-suppressing cast to
void. Otherwise I've just deleted the variables.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A test-build with a modern clang points out a number of 'set but not
used' variables, which clang seems to have got better at recently.

In cases where there's conditioned-out or commented-out code using the
variable, I've left it in and added a warning-suppressing cast to
void. Otherwise I've just deleted the variables.
</pre>
</div>
</content>
</entry>
<entry>
<title>Rename UI_UPDATE as MOVE_UI_UPDATE</title>
<updated>2023-06-10T23:33:27+00:00</updated>
<author>
<name>Ben Harris</name>
<email>bjh21@bjh21.me.uk</email>
</author>
<published>2023-06-04T17:42:58+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/puzzles/commit/?id=a9af3fda1d784c42d486a019a0a4e947f762af70'/>
<id>a9af3fda1d784c42d486a019a0a4e947f762af70</id>
<content type='text'>
All the other constants named UI_* are special key names that can be
passed to midend_process_key(), but UI_UPDATE is a special return value
from the back-end interpret_move() function instead.  This renaming
makes the distinction clear and provides a naming convention for future
special return values from interpret_move().
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
All the other constants named UI_* are special key names that can be
passed to midend_process_key(), but UI_UPDATE is a special return value
from the back-end interpret_move() function instead.  This renaming
makes the distinction clear and provides a naming convention for future
special return values from interpret_move().
</pre>
</div>
</content>
</entry>
</feed>
