Solitaire for the TI-84 Plus CE!
1// Calculation Solitaire / CALCSLTR for the TI-84 Plus CE
2// Copyright (C) 2025 euphory
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17#include <fileioc.h>
18#include <stdlib.h>
19#include <math.h>
20#include <time.h>
21#include <sys/rtc.h>
22#include <keypadc.h>
23
24#include "variables.h"
25#include "input.h"
26#include "drawing.h"
27#include "save.h"
28#include "ops.h"
29
30card_t tableau[NUM_TABLSLOTS][TABL_STACK_SIZE];
31card_t freeCells[NUM_FREECELLS];
32unsigned char progress;
33
34bool run()
35{
36 start();
37
38 while (doInput())
39 {
40 clock_t frameTimer = clock();
41
42 drawFrame(true);
43
44 while (clock() - frameTimer < FRAME_TIME);
45 }
46
47 if (progress == PROGRESS_COMPLETE)
48 {
49 // this way we know not to try to resume
50 deleteSave();
51
52 drawFrame(true);
53
54 while (kb_AnyKey());
55
56 while (true)
57 {
58 kb_Scan();
59 if (kb_On) return false;
60 if (kb_IsDown(kb_Key2nd) || kb_IsDown(kb_KeyEnter)) return true;
61 }
62 }
63 else
64 {
65 // user exited mid-game
66 save();
67 return false;
68 }
69}
70
71int main(void)
72{
73 srand(rtc_Time());
74
75 gfx_Begin();
76 gfx_SetDrawBuffer();
77 gfx_SetPalette(global_palette, sizeof_global_palette, 0);
78 gfx_SetTransparentColor(3);
79
80 kb_EnableOnLatch();
81 kb_ClearOnLatch();
82
83 loadWins();
84
85 while (run());
86
87 gfx_End();
88
89 kb_ClearOnLatch();
90
91 return 0;
92}