Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fortuna-mines
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
be1g19
fortuna-mines
Commits
1c838988
Commit
1c838988
authored
4 years ago
by
Bradley Eaton
Browse files
Options
Downloads
Patches
Plain Diff
Game now has multiple modes
parent
a8010506
No related branches found
No related tags found
No related merge requests found
Pipeline
#7430
passed
4 years ago
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mines.c
+74
-10
74 additions, 10 deletions
mines.c
mines.h
+4
-4
4 additions, 4 deletions
mines.h
with
78 additions
and
14 deletions
mines.c
+
74
−
10
View file @
1c838988
...
...
@@ -54,6 +54,7 @@ void printMinesLeft();
void
printMenuSelected
(
uint8_t
,
uint8_t
);
void
main_menu
();
// position stuff
int
position
=
0
;
uint8_t
menuPosition
=
0
;
uint8_t
menuEntries
=
0
;
...
...
@@ -66,7 +67,7 @@ uint8_t menuStatus = MENU_NONE;
volatile
uint16_t
rng_state
=
0
;
static
uint16_t
EEMEM
RNG_STATE
;
volatile
rectangle
selection_position
;
volatile
uint8_t
position_states
[
BOARD_ITEMS
];
volatile
uint8_t
position_states
[
30
*
16
];
volatile
uint8_t
scroll_direction
=
0
;
volatile
uint8_t
game_state
=
GAME_STATE_NONE
;
volatile
uint8_t
mines_untagged
=
0
;
...
...
@@ -74,6 +75,12 @@ volatile uint8_t cells_tagged = 0;
volatile
uint16_t
cells_discovered
=
0
;
volatile
uint16_t
rng_count
=
0
;
//board sizing
uint8_t
BOARD_SIZE_X
=
30
;
uint8_t
BOARD_SIZE_Y
=
16
;
uint8_t
MAX_MINES
=
99
;
//XORSHIFT16
uint16_t
rng
()
{
uint16_t
x
=
rng_state
;
...
...
@@ -600,13 +607,15 @@ void main(void) {
void
main_menu
(){
clear_screen
();
char
arr
[
3
][
MAX_LETTERS_IN_MENU
]
=
{
" "
,
"Play (99 mines)"
,
char
arr
[
4
][
MAX_LETTERS_IN_MENU
]
=
{
"Play Beginner"
,
"Play Intermediate"
,
"Play Expert"
,
"Instructions"
};
menuStatus
=
MENU_START
;
printMenu
(
"Fortuna Mines"
,(
char
*
)
arr
,
3
);
game_state
=
GAME_STATE_NONE
;
printMenu
(
"Fortuna Mines"
,(
char
*
)
arr
,
4
);
}
...
...
@@ -645,6 +654,14 @@ int collect_delta(int state) {
return
state
;
}
/*
** Sets up the game to before start state
*/
void
setup_game
(){
menuStatus
=
0
;
game_state
=
GAME_STATE_STARTING
;
printGrid
();
}
int
check_switches
(
int
state
)
{
...
...
@@ -662,8 +679,17 @@ int check_switches(int state) {
if
(
get_switch_press
(
_BV
(
SWS
)))
{
if
(
!
menuStatus
){
//TODO put up a menu here
printMines
();
menuStatus
=
MENU_PAUSE
;
char
items
[][
MAX_LETTERS_IN_MENU
]
=
{
" "
,
"Resume"
,
#ifdef DEBUG
"[DEBUG] cheat"
,
#endif //DEBUG
"Quit to menu"
};
clear_screen
();
printMenu
(
"Paused"
,
(
char
*
)
items
,
sizeof
(
items
)
/
(
MAX_LETTERS_IN_MENU
*
sizeof
(
char
)));
}
}
...
...
@@ -693,15 +719,53 @@ int check_switches(int state) {
break
;
case
MENU_START
:
switch
(
menuPosition
)
{
case
0
:
//10 mines
BOARD_SIZE_X
=
9
;
BOARD_SIZE_Y
=
9
;
MAX_MINES
=
10
;
setup_game
();
break
;
case
1
:
//20 mines
BOARD_SIZE_X
=
16
;
BOARD_SIZE_Y
=
16
;
MAX_MINES
=
20
;
setup_game
();
break
;
case
2
:
//99 mines
menuStatus
=
0
;
game_state
=
GAME_STATE_STARTING
;
BOARD_SIZE_X
=
30
;
BOARD_SIZE_Y
=
16
;
MAX_MINES
=
99
;
setup_game
();
break
;
case
3
:
instructions
();
break
;
default:
break
;
}
break
;
case
MENU_PAUSE
:
switch
(
menuPosition
){
case
1
:
//resume
menuStatus
=
MENU_NONE
;
clear_screen
();
printGrid
();
break
;
case
2
:
instructions
();
//cheat
#ifdef DEBUG
menuStatus
=
MENU_NONE
;
clear_screen
();
printMines
();
break
;
case
3
:
#endif //DEBUG
//quit to menu
main_menu
();
default:
break
;
}
...
...
This diff is collapsed.
Click to expand it.
mines.h
+
4
−
4
View file @
1c838988
...
...
@@ -43,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define MINES_H_
// if debug mode define this here
#define DEBUG
//
#define DEBUG
//
// Cell
...
...
@@ -56,10 +56,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 00000y11 - means it is questioned
// 00000x00 - refers to whether a mine (1 means it is )
#define BOARD_SIZE_X 30
#define BOARD_SIZE_Y 16
//
#define BOARD_SIZE_X 30
//
#define BOARD_SIZE_Y 16
#define BOARD_ITEMS (BOARD_SIZE_X * BOARD_SIZE_Y)
#define MAX_MINES 99
//
#define MAX_MINES 99
#define SCROLL_HORIZONTAL 0
#define SCROLL_VERTICAL 1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment