Shisen1K - A 1k version of Shisen

a public domain minigame by Paolo Ferraris (pieffe8@libero.it)

For ZX Spectrum 16k/48k/128k/+2/... blah blah blah!

This minigame does not work with hardware devices like Microdrive
and Interface 1 that change the memory address where BASIC programs
are loaded.

What is new in version 1.2

- Fixed a bug introduced in version 1.1. That caused improper reinsertion
  of tiles with the back command, in the non-gravity variant.

What is new in version 1.1

- Shisen1K now hilights all tiles of the same kind of the one under the
  cursor (that's for compensating the fact that in the real Shisen
  tiles are more distinguishable)
- Sound effects, when removing two tiles, added


Shisen is a game similar to Mahjongg, and it uses the same tile set.
The goal of the game is the also same: remove pairs of tiles
of the same kind. What changes is the removal criteria. A pair of such
tiles can be removed only if they can be connected by at most three
horizontal and vertical lines.

The gravity variant is implemented also. With gravity, tiles fall down
when a tile below them is removed. Shisen1K starts with gravity.

Shisen1K differs from the original game in the tile sets - alphabet
letters - and in the board size: 14x6 tiles instead of 18x8.

The main keys are (the key combinations for the 40-keys Spectrum 16/48k
are reported in parentheses)

    four arrows (CAPS+5,6,7,8)   : move the cursor
    ENTER			 : select the tile under the cursor
    H				 : show available moves - see below

To remove two tiles, select them in sequence.
To deselect a selected tile, just press ENTER on it again.
Each time 'H' is pressed, a different pair of tiles that can be removed
is shown, until there are no pairs left. Pressing ENTER when a pair is
shown removes such pair.
If 'H' is pressed when a tile is selected, only pairs that contain
that tile are shown.

There are various commands to start a new game

    N	               : start a new game
    backspace (CAPS+0) : toggle the gravity on/off and start a new game
    S		       : choose a seed

Each board is generated by a seed - a number between 1 and 65535
inclusive. The seed of the current board is shown on the screen.
The board generally is chosen randomly, but with 'S' you can choose the
seed. That is useful if you want to try the same board in different
days: just write the number down and insert it another time. Note that
writing 0 as a seed indicates a random seed.

Shisen1K remembers all removals done so far, and allows to go back and
forward these moves. The keys that can be used for that are

    B	   : back
    F	   : forward
    R	   : restart (i.e. all removed tiles go back on the board)
    L	   : last move (i.e. remove all "re-placed" tiles again)

Note that using these keys is considered cheating.

The border color changes to give some information.
    Cyan   : (no message)
    White  : you won!
    Black  : sorry, no moves left
    Red	   : you cheated!

I hope you will enjoy the game for at least a few minutes :-)


- A few notes about the development of this minigame.

I know Shisen since the '80s (from a coin-op) and I like it more than
Mahjongg. I first implemented the game for PC in QuickBasic in text
mode about ten years ago. Last year I saw an implementation of the game
(the best, in my opinion) for KDE. Then I decided to write it again for
the 2002 minigame compo.

My initial idea was to implement the basic features and fill the
remaining memory with tile pictures, but the space left was enough for
small pictures only. I then decided to use alphabet letters and
fill the remaining space with additional features, like the back/forward
commands and a very basic help system: only one move.

The program was exactly 1024 bytes, but some code rearrangments allowed
me to save 100 bytes! The audio routine for the 128k version that I
tried to write at this point was too big and then discarded.

Then the gravity variant, that is present in the KDE implementation,
came into my mind. I decided to implement it into a separate 1k program,
but 1024 bytes were enough for mode toggling code also, so that a
single program contains both versions. Finally, further optimizations
allowed me to complete the help system as it is now and add the seed
choosing.
