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
e5e12bf2
Commit
e5e12bf2
authored
May 6, 2021
by
Bradley Eaton
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
c53d1092
No related branches found
No related tags found
No related merge requests found
Pipeline
#7418
passed
May 6, 2021
Stage: build
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mines.c
+30
-3
30 additions, 3 deletions
mines.c
with
30 additions
and
3 deletions
mines.c
+
30
−
3
View file @
e5e12bf2
...
...
@@ -20,7 +20,7 @@ int position = 0;
// Minesweeper stuff
volatile
uint16_t
rng_state
;
volatile
uint16_t
rng_state
=
0
;
volatile
rectangle
selection_position
;
volatile
uint8_t
position_states
[
BOARD_ITEMS
];
volatile
uint8_t
scroll_direction
=
0
;
...
...
@@ -39,6 +39,7 @@ uint16_t rng() {
return
x
;
}
/*
** disallowed is a length 9 array which contains the elements surrounding the players position
** all disallowed values must be one more than they represent
...
...
@@ -455,11 +456,31 @@ void main(void) {
os_add_task
(
check_switches
,
100
,
1
);
os_add_task
(
freeram_output
,
20
,
1
);
rng_state
=
3
;
//setup seclection position
update_selection_position
(
0
,
BLUE
);
// //setup clock prescaler for rng seed (CSN12 and CSN10 for /1024 prescaler)
// TCCR1B |= 4;
//setup watchdog interrupt so we can get a TRNG value to give as seed for PRNG
// //clear watchdog timer
// MCUSR &= ~(1<<)
//
// //write logical 1 to both WDCE and WDE
// WDTCSR |= (1<<WDCE) | (1<<WDE);
//
// //disable WD timer
//
// WDTCSR = 0x00;
//
// //enable WD timer with Change enable WDCE and WDIE (interrupt enable) and prescaler to ~1s
// WDTCSR |= (1<<WDCE) | (1<<WDIE) | (1<<WDP2) | (1<<WDP1);
//Enable ADC and start conversion
ADCSRA
|=
(
1
<<
ADEN
)
|
(
1
<<
ADSC
);
printGrid
();
sei
();
...
...
@@ -485,7 +506,7 @@ int collect_delta(int state) {
uint16_t
oldPosColour
;
char
output
[
30
];
sprintf
(
output
,
"stat:%d
\n
pos:%d
\n
"
,
position_states
[
position
],
position
);
sprintf
(
output
,
"stat:%d
\n
pos:%d
\n
rng:%d;%d
"
,
position_states
[
position
],
position
,
ADCL
,
ADCH
);
display_string_xy
(
output
,
0
,
210
);
printCell
(
oldPos
);
update_selection_position
(
position
,
BLUE
);
...
...
@@ -514,6 +535,12 @@ int check_switches(int state) {
if
(
get_switch_press
(
_BV
(
SWC
)))
{
if
(
!
game_started
){
//setup seed based on time to press the first button
if
(
rng_state
==
0
){
rng_state
=
TCNT1L
;
TCCR1B
&=
~
4
;
}
generate_mines
(
position
);
printGrid
();
game_started
=
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