Fix issues 1,2,3,4,5,6,8
This commit is contained in:
parent
5ff1f4b925
commit
cdd491da86
|
@ -1,8 +1,6 @@
|
||||||
Outstanding
|
Outstanding
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
5. Make setup mode less confusing
|
|
||||||
6. Allow jam clock adjustments in setup
|
|
||||||
7. Unified build with multiple firmware targets
|
7. Unified build with multiple firmware targets
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,3 +11,6 @@ Fixed
|
||||||
2. Konami Code position doesn't reset on non-sequence button
|
2. Konami Code position doesn't reset on non-sequence button
|
||||||
3. It is too easy to mess up scores when adjusting period clock time
|
3. It is too easy to mess up scores when adjusting period clock time
|
||||||
4. Period clock adjustments take forever
|
4. Period clock adjustments take forever
|
||||||
|
5. Make setup mode less confusing
|
||||||
|
6. Allow jam clock adjustments in setup
|
||||||
|
8. Debounce buttons
|
86
config.h
86
config.h
|
@ -4,14 +4,9 @@
|
||||||
#define CLOCK_MHZ 16
|
#define CLOCK_MHZ 16
|
||||||
#define CLOCK_HZ (CLOCK_MHZ * 1000000)
|
#define CLOCK_HZ (CLOCK_MHZ * 1000000)
|
||||||
|
|
||||||
#define SCORE_DIGITS 2
|
#define LINEUP_DEFAULT (-30 * 10)
|
||||||
#define JAM_DIGITS 3
|
#define JAM_DEFAULT (-2 * 60 * 10)
|
||||||
|
#define PERIOD_DEFAULT (-30 * 60 * 10)
|
||||||
// Show an indicator (J/L/t) to the left of the jam clock
|
|
||||||
//#define JAM_INDICATOR
|
|
||||||
|
|
||||||
// The jam clock is split across the period clock (easier folding, harder wiring)
|
|
||||||
//#define JAM_SPLIT
|
|
||||||
|
|
||||||
// Set these to the PORTA pins you use
|
// Set these to the PORTA pins you use
|
||||||
#define NESCLK 0
|
#define NESCLK 0
|
||||||
|
@ -21,4 +16,79 @@
|
||||||
#define SCLK 4
|
#define SCLK 4
|
||||||
#define SLTCH 5
|
#define SLTCH 5
|
||||||
|
|
||||||
|
#define JAM_DIGITS 3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if VARIANT == neale
|
||||||
|
//
|
||||||
|
// Neale variant
|
||||||
|
//
|
||||||
|
// With Jam indicator, split jam clock, and only 2 score digits.
|
||||||
|
// Also featuring goofy brain wiring.
|
||||||
|
//
|
||||||
|
|
||||||
|
#define SCORE_DIGITS 2
|
||||||
|
#define JAM_INDICATOR
|
||||||
|
#define JAM_SPLIT
|
||||||
|
|
||||||
|
// I wired mine differently and I'm too lazy to fix it.
|
||||||
|
#undef NESCLK
|
||||||
|
#undef NESLTCH
|
||||||
|
#undef NESOUT
|
||||||
|
#undef SIN
|
||||||
|
#undef SCLK
|
||||||
|
#undef SLTCH
|
||||||
|
|
||||||
|
#define NESCLK 3
|
||||||
|
#define NESLTCH 4
|
||||||
|
#define NESOUT 5
|
||||||
|
#define SIN 0
|
||||||
|
#define SCLK 1
|
||||||
|
#define SLTCH 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#elif VARIANT == susan1
|
||||||
|
//
|
||||||
|
// Susan 1 variant
|
||||||
|
//
|
||||||
|
// Like the neale variant but with correct brain wiring
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#define SCORE_DIGITS 2
|
||||||
|
#define JAM_INDICATOR
|
||||||
|
#define JAM_SPLIT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#elif VARIANT == susan2
|
||||||
|
//
|
||||||
|
// Susan 2 variant
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#define SCORE_DIGITS 3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
//
|
||||||
|
// Default variant
|
||||||
|
//
|
||||||
|
// Nobody has built this yet!
|
||||||
|
// But it's the one described by the instructions.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define SCORE_DIGITS 3
|
||||||
|
#define JAM_SPLIT
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
93
main.c
93
main.c
|
@ -21,14 +21,13 @@
|
||||||
volatile uint32_t jiffies = 0; // Elapsed time in deciseconds (tenths of a second)
|
volatile uint32_t jiffies = 0; // Elapsed time in deciseconds (tenths of a second)
|
||||||
volatile bool tick = false; // Set high when jiffy clock ticks
|
volatile bool tick = false; // Set high when jiffy clock ticks
|
||||||
|
|
||||||
|
|
||||||
// Clocks are in deciseconds
|
// Clocks are in deciseconds
|
||||||
int16_t score_a = 0;
|
int16_t score_a = 0;
|
||||||
int16_t score_b = 0;
|
int16_t score_b = 0;
|
||||||
int16_t period_clock = -(30 * 60 * 10);
|
int16_t period_clock = PERIOD_DEFAULT;
|
||||||
int16_t jam_duration = -(2 * 60 * 10);
|
int16_t jam_duration = JAM_DEFAULT;
|
||||||
int16_t lineup_duration = (-30 * 10);
|
int16_t lineup_duration = LINEUP_DEFAULT;
|
||||||
int16_t jam_clock = 0;
|
int16_t jam_clock = JAM_DEFAULT;
|
||||||
enum {
|
enum {
|
||||||
TIMEOUT = 0,
|
TIMEOUT = 0,
|
||||||
JAM,
|
JAM,
|
||||||
|
@ -65,18 +64,16 @@ const uint8_t seven_segment_digits[] = {
|
||||||
0x7b, 0x60, 0x37, 0x76, 0x6c, 0x5e, 0x5f, 0x70, 0x7f, 0x7e
|
0x7b, 0x60, 0x37, 0x76, 0x6c, 0x5e, 0x5f, 0x70, 0x7f, 0x7e
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t setup_digits[] = {
|
|
||||||
// [ = ]
|
|
||||||
0x1b, 0x12, 0x72
|
|
||||||
};
|
|
||||||
|
|
||||||
// keyed by state
|
// keyed by state
|
||||||
const uint8_t indicator[] = {
|
const uint8_t indicator[] = {
|
||||||
// '' J L T -
|
// t, J, L, -
|
||||||
0x00, 0x63, 0x0b, 0x0f, 0x04
|
0x0f, 0x63, 0x0b, 0x04
|
||||||
};
|
};
|
||||||
|
|
||||||
#define max(a, b) ((a)>(b)?(a):(b))
|
#define max(a, b) ((a)>(b)?(a):(b))
|
||||||
|
#define min(a, b) ((a)<(b)?(a):(b))
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
latch()
|
latch()
|
||||||
|
@ -235,17 +232,38 @@ nesprobe()
|
||||||
void
|
void
|
||||||
update_controller()
|
update_controller()
|
||||||
{
|
{
|
||||||
static uint8_t last_pressed = 0;
|
static uint8_t last_held = 0;
|
||||||
static uint32_t last_change = 0;
|
static uint32_t last_change = 0;
|
||||||
|
static uint32_t last_typematic = 0;
|
||||||
uint8_t held;
|
uint8_t held;
|
||||||
uint8_t pressed;
|
uint8_t pressed;
|
||||||
|
int typematic = 0;
|
||||||
int inc = 1;
|
int inc = 1;
|
||||||
|
|
||||||
held = nesprobe();
|
held = nesprobe();
|
||||||
pressed = (last_pressed ^ held) & held;
|
pressed = (last_held ^ held) & held;
|
||||||
if (last_pressed != held) {
|
|
||||||
|
// Set up typematic acceleration
|
||||||
|
if (last_held != held) {
|
||||||
|
// Debounce
|
||||||
|
if (last_change == jiffies) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
last_change = jiffies;
|
last_change = jiffies;
|
||||||
last_pressed = held;
|
last_typematic = jiffies;
|
||||||
|
last_held = held;
|
||||||
|
typematic = 1;
|
||||||
|
} else if (jiffies > last_typematic) {
|
||||||
|
last_typematic = jiffies;
|
||||||
|
if (jiffies - last_change < 6) {
|
||||||
|
typematic = 0;
|
||||||
|
} else if (jiffies - last_change < 40) {
|
||||||
|
typematic = 1;
|
||||||
|
} else if (jiffies - last_change < 80) {
|
||||||
|
typematic = 10;
|
||||||
|
} else {
|
||||||
|
typematic = 20;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pressed == konami_code[konami_pos]) {
|
if (pressed == konami_code[konami_pos]) {
|
||||||
|
@ -258,7 +276,7 @@ update_controller()
|
||||||
} else if (konami_pos > 3) {
|
} else if (konami_pos > 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (pressed) {
|
||||||
konami_pos = 0;
|
konami_pos = 0;
|
||||||
}
|
}
|
||||||
// Select means subtract
|
// Select means subtract
|
||||||
|
@ -266,6 +284,14 @@ update_controller()
|
||||||
inc = -1;
|
inc = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (setup && (held & BTN_START) && (pressed & BTN_SELECT)) {
|
||||||
|
jam_duration += 30 * 10;
|
||||||
|
if (jam_duration > -60 * 10) {
|
||||||
|
jam_duration = -120 * 10;
|
||||||
|
}
|
||||||
|
jam_clock = jam_duration;
|
||||||
|
}
|
||||||
|
|
||||||
if ((pressed & BTN_A) && ((state != JAM) || (jam_clock == 0))) {
|
if ((pressed & BTN_A) && ((state != JAM) || (jam_clock == 0))) {
|
||||||
state = JAM;
|
state = JAM;
|
||||||
jam_clock = jam_duration;
|
jam_clock = jam_duration;
|
||||||
|
@ -282,32 +308,25 @@ update_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((held & BTN_START) && (state == TIMEOUT)) {
|
if ((held & BTN_START) && (state == TIMEOUT)) {
|
||||||
int typematic;
|
|
||||||
|
|
||||||
// Set up typematic acceleration (issue #4)
|
|
||||||
if (pressed & (BTN_UP | BTN_DOWN)) {
|
|
||||||
typematic = 10;
|
|
||||||
} else if (jiffies - last_change < 20) {
|
|
||||||
typematic = 0;
|
|
||||||
} else if (jiffies - last_change < 500) {
|
|
||||||
typematic = 10;
|
|
||||||
} else {
|
|
||||||
typematic = 100;
|
|
||||||
}
|
|
||||||
if (held & BTN_UP) {
|
if (held & BTN_UP) {
|
||||||
period_clock -= typematic;
|
period_clock -= typematic * 10;
|
||||||
}
|
}
|
||||||
if (held & BTN_DOWN) {
|
if (held & BTN_DOWN) {
|
||||||
period_clock += typematic;
|
period_clock += typematic * 10;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Score adjustment and clock adjustment are mutually exclusive (issue #3)
|
|
||||||
if (pressed & BTN_LEFT) {
|
|
||||||
score_a = max(score_a + inc, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pressed & BTN_RIGHT) {
|
period_clock = min(period_clock, 0);
|
||||||
score_b = max(score_b + inc, 0);
|
period_clock = max(period_clock, -90 * 30 * 10);
|
||||||
|
} else {
|
||||||
|
// Score adjustment and clock adjustment are mutually exclusive
|
||||||
|
if (held & BTN_LEFT) {
|
||||||
|
score_a += typematic * inc;
|
||||||
|
score_a = max(score_a, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (held & BTN_RIGHT) {
|
||||||
|
score_b += typematic * inc;
|
||||||
|
score_b = max(score_b, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue