As some of you are aware, for the past month, I've been working on a combination Solitaire game, containing both the popular Klondike kind found on most versions of Windows, as well as FreeCell. Today, I present a working beta.

Title & options screen:


Playing game:


I've managed to win a game twice, including on hardware. However, there is still much work to do. There is no scoring code (though you can indeed switch between draw-1 and draw-3 modes), the FreeCell mode isn't implemented at all, there are no graphics for the high-ranking cards, the save feature isn't implemented, the undo feature isn't implemented, and there is no code to detect the win condition.

If you find any bugs, you may report, but only if you can reproduce them. Which is difficult, considering that the RNG is not only implemented, but well-designed to prevent the same game from being generated twice.

Download working beta

Download source code
This looks fantastic! If I can get some time later today, I'll give it a shot Smile
As I said on IRC yesterday, I haven't the faintest clue how I overlooked this topic when you first created it. I've been following this project with great interest from its progress on Have Calc, Will Program, so I'm excited to see that both binaries and code are available. I just tried running the game and ran into a "bug", but I suspect it's more an obscure hardware feature you're abusing that jsTIfied doesn't emulate properly than an outright bug that's making the text not appear. Any thoughts before I dive into the code?

This week's update finishes the Klondike Solitaire feature, by adding the following features:
- ALPHA now implements move-to-home-cell
- If you empty the waste, it shows the card beneath if one is there
- Deck graphic changes to empty box if no more cards are in deck
- Down key moves to bottom-most card in stack
- Changed how the arrow keys move between stacks
- All illegal moves should now also unselect the currently selected card (So ALPHA will unselect the currently selected card.)
- HOPEFULLY fixed rare random freeze issue
- Implemented timer
- Implemented scoring
- APD now three minutes
- Every invocation of the build.bat file will now increment the build number, so every version has a unique ID.
You may find the app download here, and source code here.

I've added a routine call Panic that gets called in various places if the game fails a sanity check. If you see the panic screen, it doesn't necessarily mean the game has crashed. It just means that it's reporting a bug. Pressing ON will trigger a panic. If you see a panic unexpectedly, or need to use ON to terminate the app, please record the numbers it spews out and report them and what you were doing, including all options; the information will help me identify what happened.

This release was delayed a lot by a rare issue I encountered with the game very rarely freezing. I may have fixed the issue by ensuring the game never enters a key processing loop with interrupts disabled. However, I'm not certain interrupts were the issue in the first place. Nevertheless, I also restructured interrupts so the IVT can't be corrupted (by moving it into the app) and I added sanity checks for the PC and SP into the ISR.

The issue reported below was caused by jsTIfied behaving strangely when invalid screen coordinates were set. For some reason, it would simply discard the data instead of masking the coordinate mod 256 or 512 (like the real hardware does) or entering panic mode (like the real hardware would do if it felt it was in an inconsistent state). KermM may or may not have modified jsTIfied to behave like hardware does; I've modified Solitaire so that it doesn't do that anymore, because it seems I never intended for it to do that.
The game is nearing completion! I've added FreeCell, and I've added game saving. Now you can stop the game you're playing, and resume it at a later time. There are now two pending features: undo/redo, and adding some better graphics. I think I can do both in the remaining 2.3 K of space, and I can increase that to 2.8 K if needed by moving the IVT and ISR into RAM.

You can download Solitaire and its source code from the Cemetech archives.

Here are some new screen shots:

Main menu 1:

Main menu 2:

Klondike Solitaire:

FreeCell:

Game saving in action:


Full readme:

Code:



                                   Solitaire
                                 March 27 2014



====== Introduction ============================================================

    Since Windows 3.0, Windows has included two electronic versions of two
Solitaire (or Patience in UK English) type card games.  Windows called them
Solitaire and FreeCell.  This app currently implements a clone of both programs.

    For the precise rules of Klondike and FreeCell, please consult the Internet.


====== Usage ===================================================================

MAIN MENU

    Solitaire has a main menu which lets you select which game to play, and the
options applicable for the chosen game.  The currently selected menu item is
displayed in inverted color; that is, white text on black background.  The arrow
keys will select different items.  Press ENTER or 2ND to select an item.

    To quit, you must press the quit button at the bottom of the screen.

    Unlike in the OS, Solitaire will not dim the screen after a period of no
activity.  However, after three minutes, Solitaire will terminate itself and
turn the calculator off.  If this happens while a game is in progress, Solitaire
will save your game if there is sufficient free RAM (about 400 bytes).   

SAVING

    Solitaire uses an appvar named Solitair to save your settings and
statistics.  This appvar is about 100 bytes in size at a minimum, and is always
in RAM.  If you archive the appvar, Solitaire will unarchive it, and will not
rearchive it.

    Additionally, while you are playing a game, Solitaire can save your game and
restore it when you rerun the app.  This function can be invoked explicitly by
pressing MODE.  This will expand the save appvar to about 400 bytes.  If you are
playing a game, and press no buttons for more than three minutes, Solitaire will
attempt to save your game, and then turn the calculator off.

    There are some conditions that can prevent Solitaire's save feature from
working:
  - An appvar named Solitair was created by another application.  Solitaire
    cannot use any other appvar name.
  - There is not enough free RAM.  If there is enough free RAM for the appvar to
    save statistics, then they will be updated when you quit; however attempting
    to use the save feature (either by pressing MODE or waiting three minutes)
    will cause the app to update its statistics, but not save your game.
  - There is not enough RAM to unarchive the appvar when it is archived.  This
    is exactly like above, but statistics won't be saved, either, and any saved
    game cannot be resumed.
  - The appvar was created by an older version of Solitaire, and the new version
    cannot understand it.
In any of these circumstances, attempting to invoke the game saving feature---
either through pressing MODE or waiting three minutes---WILL NOT SAVE YOUR IN-
PROGRESS GAME.

    If you repeatedly get error messages when starting Solitaire and you are
sure there are not, in fact, any problems, try deleting the appvar Solitair.

GENERAL GAME PLAY

    Once you have started a game, use the arrow keys to move the cursor around.
Use ENTER or 2ND to select a card, move the cursor to another card, and then use
ENTER or 2ND again to place the card.  Cards that are hidden may be revealed
with ENTER or 2ND.

    If you do not a press any keys for three minutes, Solitaire will attempt to
save the in-progress game and then turn off the calculator, returning you to the
home screen; see above for more information.

BUG CHEKCS

    Solitaire contains sanity checks in certain areas, in which the game
verifies that its internal data is in a valid state.  If a sanity check fails,
it means that the app has a bug.  Therefore, the game will display an error
message saying BUG CHECK, followed by some numbers.  A BUG CHECK can also be
triggered by press ON at any time, which may be useful if the game appears to
have locked up.  If you see a BUG CHECK and you did not cause it purposefully,
please record the numbers, and send them to me, with a thorough description of
what you were doing when the BUG CHECK was triggered.  If at all possible, also
send an exact list of steps that cause the issue; you may also need to include
the appvar Solitair.


------ Klondike ----------------------------------------------------------------

    Klondike is the name for the specific version of Solitaire Windows is known
for.

    Unlike in Windows Solitaire, the four foundations that you must move cards
into is not on the top right.  Instead, they are on the left side of the screen;
this is purely due to the low resolution of the TI-84 Plus C SE screen.

    Y= will draw more cards from the deck.  Alternatively, you may simply click
on the deck.  Click on a hidden card to flip it.

    There are two main scoring modes: normal and Vegas.  In normal mode, the
score is always positive. 500 points is average for an un-timed game, 700-plus
is excellent.

    Vegas scoring has two sub-modes: non-cumulative and cumulative.  In Vegas
scoring, you only get one pass through the deck.  When you start the game, you
start 52 currency units (e.g. US dollars) in debt, and earn back 5 units for
every card moved to a home cell (or foundation).  With only pass through the
deck, your chances of winning are very small.  In fact, even earning back more
than 52 units is very hard.  In cumulative mode, you get to retain any debt (or
credit, however unlikely that may be) from previous hands.  Switching back to
normal scoring will erase your debt.  (Caution: May not work in real casions.)

    Basically, in Vegas mode, you're almost certain to lose.  That's why it's
called Vegas mode.

    If you enable the timer, in normal scoring mode, you lose two points every
ten seconds.  In Vegas mode, the timer serves no purpose.


------ FreeCell ----------------------------------------------------------------

    FreeCell is a game similar to Klondike Solitaire.  However, an important
difference is that all cards are visible when you start the game.  Also, you get
four free cells that can be used as a temporary holding area for exactly one
card.  Therefore, unlike Klondike, FreeCell is purely a logic/strategy game.

    Unlike in Windows FreeCell, the four home cells and free cells are not on
the top of the screen.  Instead, they are on the left side of the screen; this
is purely due to the low resolution of the TI-84 Plus C SE screen.

    This implementation of FreeCell provides the same 32000 unique games that
the original Windows FreeCell contained, the so-call Microsoft 32000.  Every
game except one is solvable with normal four free cells; the unsolvable game is
#11982, which can be solved with a fifth free cell.  Dozens of people have
claimed to have solved all 32000; if you attempt to solve all of them before
graduating, you are unlikely to graduate.  Numbers 1941 and 10692 are also
considered very hard, and 617 often trips up beginners, or so I'm told.

    You can find solutions to all 31999 games online in various places; be
forewarned, however, that this implementation does not currently support the
supermove.


====== About ===================================================================

------ Credits -----------------------------------------------------------------

    FloppusMaximus and BrandonW are responsible for nearly all of the OS
documentation that made this possible.  KermM provided the vital insight of the
identity of the specific LCD driver the TI-84 Plus C SE uses, without which this
game could not operate at a reasonable speed.

    Xeda helpfully provided some optimizations for some routines.

------ Change Log --------------------------------------------------------------

Build 461 (27 March 2014)
 - Added Random! button to GUI
 - Fixed glitch in Klondike where disabling the timer would also make the Draw
   text disappear
 - Added some basic statistics
 - Optimized some code
 - Added win detection logic
 - Added dialogs
 - Added FreeCell game mode
 - Fixed a bug in Klondike where moving a card onto a foundation would leave the
   card below the new top card still selected, so you could move the card onto
   another pile
 - Fixed points being deducted at the wrong time when turning over the waste
 - Fixed points being deducted after waste is empty
 - Added settings, stats, and game saving.  Now APDs correctly save your gave (if
   possible)!
 - Made FreeCell number entry and free cell count entry a little better
 - Changed a bunch of code relating to the card cursor positioning that I had been
   putting off until I implemented FreeCell

Build 259 (19 March 2014)
 - ALPHA now implements move-to-home-cell
 - If you empty the waste, it shows the card beneath if one is there
 - Deck graphic changes to empty box if no more cards are in deck
 - Down key moves to bottom-most card in stack
 - Changed how the arrow keys move between stacks
 - All illegal moves should now also unselect the currently selected card
    - So ALPHA will unselect the currently selected card
 - HOPEFULLY fixed rare random freeze issue
 - Implemented timer
 - Implemented scoring
 - APD now three minutes
 - Every invocation of the build.bat file will now increment the build number,
   so every version has a unique ID.

Initial release (12 March 2014)
 - Basic functionality
This just looks all sorts of awesome, can't wait to get the final game on my calculator. One that will stay on there, no matter what Smile
I forgot how to play Solitare Sad
Guess I'll just vhave to learn again.
I've uploaded a non-April-Fool's update. Yes, despite the date, this release contains no jokes (aside from the Vegas line that's been in the readme this whole time). This release adds the useful supermove feature to FreeCell, fixes some bugs, and adds minor enhancements. This also breaks compatibility with the old save appvar format, so you'll have to delete your save appvar.

You can download the game from the same place as before, whenever it gets approved by KermM.

- Fixed bug where selecting AGAIN after winning a game would prevent game saving from working in the new game.
- Minor changes to the modal dialog routine
- Fixed a bug where, after resuming game, the timer would not restart correctly.
- Added some comments in various places in the code
- Changed variables, so save compatibility is lost
- GUI cursor now blinks
- Fixed the YOU WIN dialog having a different score than the score under the KLONDIKE text. (The YOU WIN score was always the correct one.)
- Fixed a bug in FreeCell that would allow selection of an empty stack! This would generally cause a panic on any attempt to move the un-card.
- Made the free RAM required for game saving substantially smaller.
- Fixed a bug in clean-up termination code that could cause a crash in CLASSIC
- Implemented FreeCell supermove
Will you make a DoorsCSE icon or make it a program?
It's an application, not a program. Giving it the icon wouldn't let it show up in DoorsCSE, as that shell doesn't run other applications.
rw42 wrote:
Will you make a DoorsCSE icon or make it a program?

It's an application. There are couple reasons for this. First, and most importantly, I concluded early on that the game would take about 16 K of space, and I think I will meet that goal with less than five hundred bytes to spare. Since users will likely be keeping their games archived all the time, making it an app doesn't really waste any space. Second, being app means Solitaire can run even if you don't have much free RAM. Third, I have an affinity for my optimized custom font routines. It's about 600 bytes for the routines, and 1.5 K for the 96 printable ASCII glyphs. Duplicating the few DCSE routines I would use costs me about 1 K of space. I also get a performance boost by using 8-bit color (that, colors in which the high and low byte are the same).
AssemblyBandit did it.
ASMBandit's Pacman has a DCS Icon (an ASM program) that opens the PacMan app.
Hey, don't know if you got the message yet, but AssemblyBandit did it.
IKR. That was like six moths ago when they were added on Cemetech. Speaking of, he hasn't been active lately...
Today's update adds undo support, and also fixes several bugs related to FreeCell's supermove feature:
  • Fixed an issue with Panic not reporting correct register values, making it less useful
  • Fixed a bug in FreeCell's supermove where it would LDIR the wrong number of cards. Normally, it would copy too many, but the stack size counter would be updated correctly, so the extra cards were invisible.
  • Fixed a bug in FreeCell's supermove when you moved a stack to an empty cell
  • Fixed a bug where FreeCell's supermove counted foundations as free cells, instead of counting the free cells as free cells. (What? The names were similar.)
  • Implemented undo feature for both Klondike and FreeCell.

It is available now in the Cemetech archives.
This minor update fixes two small bugs, and adds a helpful feature for the ALPHA key: it will scan the tableau and move any cards that can be moved to a home cell (foundation). (Windows also does this.)

I want to add a little more graphics to the game. Namely, the face cards lack special graphics. There's enough room remaining in the app for eight 4-color 24w by 25h graphics, or sixteen 2-color graphics. I'm not having much success coming up with graphics of my own; is anybody able to lend some pixel art skills?
This update to build 922 (which you can as always download from the Cemetech archives) makes some minor changes, and adds a time bonus feature. Previously, enabling the timer would deduct points, but provide no time bonus. Unless new bugs are discovered, or 4-color graphics are added, this is probably the last update.

Changes:

  • Optimized some stuff
  • Tweaked the behavior of automove
  • ]Added automove to controls help text
  • Added some code to support having 4-color graphics for face cards
  • Added time bonus
  • Edited readme for completeness
  • About 1600 free bytes remaining
It is always on the recent programs list now. Razz
This update adds face card graphics! It also fixes an issue with supermove, and I made it so that if you archive the appvar, it will be rearchived when you quit. I also moved the IVT and ISR back into RAM, which might make any lurking bugs more likely to cause a crash. Maybe this will actually be the final update.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement