1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#include <stdio.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <stdlib.h>
#define EXITEST_STATE_INTERNAL
#include "../state.h"
#include "../term.h"
#include "../test.h"
static void print_setup_menu(int selected_slot) {
fputs(TERM_CUR_UP(2), stdout);
printf(TERM_CLEARLINE "- [DL/DR] EXI Slot %c\n", selected_slot == 0 ? 'A' : 'B');
printf(TERM_CLEARLINE "Press A to begin testing.\n");
}
static int st_setup_init(const struct et_state *state, void *state_data, et_state_init_data init_data) {
u32 *setup_data = state_data;
*setup_data = 0;
printf("\nTest setup menu:\n\n\n\n");
print_setup_menu(*setup_data);
return 0;
}
static int begin_testing(u32 menu_state, struct et_next_state *next_state) {
struct et_test_plan *plan = calloc(1, sizeof(struct et_test_plan));
if (!plan) {
puts("Failed to allocate new test plan!");
return -1;
}
size_t num_tests;
const struct et_test *const *all_tests = et_get_tests(&num_tests);
struct et_test_plan_entry *plan_entries = calloc(num_tests, sizeof(struct et_test_plan_entry));
if (!plan_entries) {
puts("Failed to allocate new test plan entries!");
free(plan);
return -1;
}
for (size_t i = 0; i < num_tests; ++i) {
plan_entries[i].test = all_tests[i];
plan_entries[i].status = TEST_PRIMORDIAL;
plan_entries[i].ext_status = NULL;
plan_entries[i].ext_status_free = NULL;
}
plan->exi_channel = (int)menu_state;
plan->next_state = et_state_summarize_test_plan;
plan->next_state_init.p = plan;
plan->num_tests = num_tests;
plan->current_test = 0;
plan->tests = plan_entries;
next_state->state = et_state_begin_testing;
next_state->init_data.p = plan;
return 1;
}
static int st_setup_tick(const struct et_state *state, void *state_data, struct et_next_state *next_state) {
u32 *setup_data = state_data;
u32 wpad_pressed = WPAD_ButtonsDown(0);
u32 pad_pressed = PAD_ButtonsDown(0);
if (wpad_pressed & WPAD_BUTTON_LEFT || wpad_pressed & WPAD_BUTTON_RIGHT || pad_pressed & PAD_BUTTON_LEFT || pad_pressed & PAD_BUTTON_RIGHT) {
*setup_data = !*setup_data;
print_setup_menu(*setup_data);
}
if (wpad_pressed & WPAD_BUTTON_A || pad_pressed & PAD_BUTTON_A) {
/* set up test plan */
return begin_testing(*setup_data, next_state);
}
return 0;
}
static void st_setup_cleanup(const struct et_state *state, void *state_data) {
/* do nothing */
}
const et_state_init_data et_init_data_null = { .p = NULL };
static struct et_state et__state_setup = {
.init_f = &st_setup_init,
.tick_f = &st_setup_tick,
.cleanup_f = &st_setup_cleanup,
.private_size = sizeof(u32)
};
const struct et_state *et_state_setup = &et__state_setup;
|