summaryrefslogtreecommitdiff
path: root/demo/source/start.c
blob: f7c2d0daaac5bf0de1859057a0551cfc9827a4fa (plain) (blame)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <ax-demo.h>

#include <ax/key.h>
#include <ax/gfx.h>

static ax_i8 const axd_logo[] = {
	0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u,

	0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x00u,0x00u, 0x00u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u,
	0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x00u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x00u, 0x04u,0x04u,0x04u,0x00u,0x04u,0x04u,0x04u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u,
	0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x00u, 0x00u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u,
	0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x00u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x00u,0x00u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u,
	0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x00u, 0x00u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u,
	0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x00u, 0x04u,0x04u,0x04u,0x00u,0x04u,0x04u,0x04u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u,
	0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x00u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u,

	0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x00u,
	0x04u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x04u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x04u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x04u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x04u,

	0x04u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x04u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x00u,0x00u, 0x04u, 0x04u,0x00u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x04u,
	0x04u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x00u,0x04u,0x00u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x04u,
	0x04u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x04u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x00u,0x00u, 0x04u,
	0x04u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x00u,0x00u,0x04u,0x04u,0x04u, 0x04u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x00u,0x00u, 0x04u,
	0x04u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x04u, 0x00u,0x00u,0x04u,0x00u,0x04u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x00u,0x00u, 0x04u,
	0x04u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x04u,
	0x04u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x04u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x04u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x00u,0x00u, 0x04u, 0x04u,0x00u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x04u,

	0x04u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x04u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x04u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x04u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x04u,
};

constexpr ax_i8 axd_logow = (0x7u * 0x4u) + (0x1u * 0x5u);
constexpr ax_i8 axd_logoh = (0x7u * 0x2u) + (0x2u) + (0x1u * 0x2u);

static_assert(sizeof (axd_logo) == axd_logow * axd_logoh);

static ax_i8 const axd_startmsg[] = {
	0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x00u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x00u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x00u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u,
	0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x00u,0x04u,0x04u,0x04u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x00u,0x00u,0x04u,0x04u,
	0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x00u,0x04u,0x04u, 0x0u, 0x00u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x00u,0x00u,0x00u,0x04u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x04u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x00u,0x04u,0x04u,
	0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x00u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x00u,0x00u,0x04u,0x04u,0x04u,0x00u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x00u,0x00u,0x00u,0x04u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x04u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,
	0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x00u,0x04u,0x04u,0x04u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x00u,0x00u,0x00u,0x04u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x04u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x04u,0x04u,0x04u,0x04u,
	0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x00u,0x00u,0x00u,0x04u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x04u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x04u,0x04u,0x04u,
	0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x00u,0x00u,0x00u,0x00u, 0x0u, 0x04u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x00u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x04u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x00u,0x00u,0x04u,0x00u,0x00u,0x00u, 0x0u, 0x00u,0x04u,0x04u,0x04u,0x04u,0x04u,0x00u, 0x0u, 0x04u,0x04u,0x00u,0x00u,0x00u,0x04u,0x04u,
};

constexpr ax_i8 axd_startmsgw = (0x7u * 0x10u) + (0x1u * 0xFu);
constexpr ax_i8 axd_startmsgh = (0x7u * 0x1u);

static_assert(sizeof (axd_startmsg) == axd_startmsgw * axd_startmsgh);

ax_err ax_start(void) {
	axd_dat dat;
	axd_initdat(&dat);
	axd_initgfx();
	ax_vsync();
	ax_blnk();
	ax_clrscrn1(dat.vaddr,0x0u);
	ax_plottex1(dat.vaddr,ax_scrnw3,axd_logo,ax_coord(ax_scrnw3,ax_scrnw3 / 0x2u - axd_logow / 0x2u,ax_scrnh3 / 0x2u - axd_logoh / 0x2u),axd_logow,axd_logoh);
	ax_plottex1(dat.vaddr,ax_scrnw3,axd_startmsg,ax_coord(ax_scrnw3,ax_scrnw3 / 0x2u - axd_startmsgw / 0x2u,ax_scrnh3 - 0x7u - axd_startmsgh),axd_startmsgw,axd_startmsgh);
	ax_key startkey;
	for (;;) {
		ax_keymap const keymap = ax_getkeymap();
		startkey = ax_key_a;
		if (ax_chkkey(keymap,startkey)) {
			break;
		}
		startkey = ax_key_b;
		if (ax_chkkey(keymap,startkey)) {
			break;
		}
		startkey = ax_key_l;
		if (ax_chkkey(keymap,startkey)) {
			break;
		}
		startkey = ax_key_pade;
		if (ax_chkkey(keymap,startkey)) {
			break;
		}
		startkey = ax_key_padn;
		if (ax_chkkey(keymap,startkey)) {
			break;
		}
		startkey = ax_key_pads;
		if (ax_chkkey(keymap,startkey)) {
			break;
		}
		startkey = ax_key_padw;
		if (ax_chkkey(keymap,startkey)) {
			break;
		}
		startkey = ax_key_r;
		if (ax_chkkey(keymap,startkey)) {
			break;
		}
		startkey = ax_key_sel;
		if (ax_chkkey(keymap,startkey)) {
			break;
		}
		startkey = ax_key_start;
		if (ax_chkkey(keymap,startkey)) {
			break;
		}
	}
	ax_vsync();
	ax_rec1(dat.vaddr,ax_scrnw3,ax_coord(ax_scrnw3,ax_scrnw3 / 0x2u - axd_startmsgw / 0x2u,ax_scrnh3 - 0x7u - axd_startmsgh),axd_startmsgw,axd_startmsgh,0x0u);
	for (;;) { /* Wait for the key to be released. */
		ax_keymap const keymap = ax_getkeymap();
		if (!ax_chkkey(keymap,startkey)) {
			break;
		}
	}
	ax_clrscrn1(dat.vaddr,0x0u);
	bool const err = axd_loop(&dat);
	if (err) {
		for (ax_i01 px = 0x0u;px != 0x9600u;++px) {
			ax_plot1(dat.vaddr,px,dat.col);
			axd_chgcol(&dat,0x1u);
		}
		return ax_err_max;
	}
	return ax_err_ok;
}