summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--src/main.c162
2 files changed, 92 insertions, 75 deletions
diff --git a/Makefile b/Makefile
index d5112f5..f6e5dda 100644
--- a/Makefile
+++ b/Makefile
@@ -81,3 +81,8 @@ run: main
81# Remove build directory. 81# Remove build directory.
82clean: 82clean:
83 rm -rf $(BUILD_DIR) 83 rm -rf $(BUILD_DIR)
84
85deploy:
86 mount /dev/sdf1 /mnt
87 cp $(BIN) /mnt
88 umount /mnt
diff --git a/src/main.c b/src/main.c
index f0be4d2..71cd690 100644
--- a/src/main.c
+++ b/src/main.c
@@ -20,36 +20,12 @@ WITH REGARD TO THIS SOFTWARE.
20#define PROF_ENABLE 0 20#define PROF_ENABLE 0
21#include "profiling.c" 21#include "profiling.c"
22 22
23// void 23static int input_received = 0;
24// test_text_rendering(void) { 24
25// while (true) { 25void
26// poll_keys(); 26serial_irq() {
27// if (key_tap(KEY_A)) { 27 input_received++;
28// break; 28}
29// }
30// bios_vblank_wait();
31// FRAME_START();
32// PROF(flip_buffer(), flip_cycles);
33// PROF(screen_fill(0), clear_cycles);
34// txt_color(2);
35// PROF(txt_drawf("The strongest bulwark of", 4, 8 * 2, 3), txt_drawf_cycles);
36// PROF(txt_drawf("authority is uniformity;", 2, 8 * 3, 3), txt_drawf_cycles);
37// PROF(txt_drawf("the least divergence from it", 8, 8 * 4, 3), txt_drawf_cycles);
38// PROF(txt_drawf("it's the greatest crime", 6, 8 * 5, 3), txt_drawf_cycles);
39// PROF(txt_drawf("- Emma Goldman", 100, 8 * 6 + 3, 3), txt_drawf_cycles);
40// txt_position(0, 10);
41// PROF(txt_printf("The only way to deal with an\n"
42// "unfree world is to become\n"
43// "so absolutely free,\n"
44// "that your very existence\n"
45// "is an act of rebellion.\n"), txt_printf_cycles);
46// PROF(txt_printf("\n - Albert Camus\n"), txt_printf_cycles);
47// PROF(txt_render(), txt_render_cycles);
48// PROF(txt_clear(), txt_clear_cycles);
49// FRAME_END();
50// PROF_SHOW();
51// }
52// }
53 29
54int main(void) { 30int main(void) {
55 // Adjust system wait times. 31 // Adjust system wait times.
@@ -61,67 +37,103 @@ int main(void) {
61 // Register interrupts. 37 // Register interrupts.
62 irq_init(); 38 irq_init();
63 irs_set(IRQ_VBLANK, irs_stub); 39 irs_set(IRQ_VBLANK, irs_stub);
40 irs_set(IRQ_SERIAL, serial_irq);
41
42 SIO_MODE = SIO_MODE_GP
43 | SIO_SC_OUT(0)
44 | SIO_SD_OUT(0)
45 | SIO_SI_OUT(0)
46 | SIO_SO_OUT(0)
47 | SIO_IRQ_ENABLE;
64 48
65 u8 sc = 0; 49 u8 sc = 0;
66 u8 sd = 0; 50 u8 sd = 0;
67 u8 si = 0; 51 u8 si = 0;
68 u8 so = 0; 52 u8 so = 0;
53 bool input_mode = false;
69 bool update = true; 54 bool update = true;
70 while (true) { 55 while (true) {
71 poll_keys(); 56 poll_keys();
72 flip_buffer(); 57 flip_buffer();
73 if (key_tap(KEY_A)) { 58 if (key_tap(KEY_START)) {
74 so = 1; 59 input_mode ^= 1;
75 update = true;
76 }
77 if (key_released(KEY_A)) {
78 so = 0;
79 update = true;
80 }
81 if (key_tap(KEY_B)) {
82 si = 1;
83 update = true;
84 }
85 if (key_released(KEY_B)) {
86 si = 0;
87 update = true; 60 update = true;
61 continue;
88 } 62 }
89 if (key_tap(KEY_L)) { 63 if (input_mode) {
90 sc = 1; 64 if (update) {
91 update = true; 65 SIO_MODE = SIO_MODE_GP
92 } 66 | SIO_SC_OUT(0)
93 if (key_released(KEY_L)) { 67 | SIO_SD_OUT(0)
94 sc = 0; 68 | SIO_SI_OUT(0)
95 update = true; 69 | SIO_SO_OUT(0)
96 } 70 | SIO_IRQ_ENABLE;
97 if (key_tap(KEY_R)) { 71 input_received = 0;
98 sd = 1; 72 update = false;
99 update = true; 73 }
100 } 74 } else {
101 if (key_released(KEY_R)) { 75 if (key_tap(KEY_A)) {
102 sd = 0; 76 so = 1;
103 update = true; 77 update = true;
104 } 78 }
105 if (update) { 79 if (key_released(KEY_A)) {
106 SIO_MODE = SIO_MODE_GP 80 so = 0;
107 | SIO_SC_OUT(1) 81 update = true;
108 | SIO_SD_OUT(1) 82 }
109 | SIO_SI_OUT(1) 83 if (key_tap(KEY_B)) {
110 | SIO_SO_OUT(1) 84 si = 1;
111 | SIO_SC(sc) 85 update = true;
112 | SIO_SD(sd) 86 }
113 | SIO_SI(si) 87 if (key_released(KEY_B)) {
114 | SIO_SO(so); 88 si = 0;
115 update = false; 89 update = true;
90 }
91 if (key_tap(KEY_L)) {
92 sc = 1;
93 update = true;
94 }
95 if (key_released(KEY_L)) {
96 sc = 0;
97 update = true;
98 }
99 if (key_tap(KEY_R)) {
100 sd = 1;
101 update = true;
102 }
103 if (key_released(KEY_R)) {
104 sd = 0;
105 update = true;
106 }
107 if (update) {
108 SIO_MODE = SIO_MODE_GP
109 | SIO_SC_OUT(1)
110 | SIO_SD_OUT(1)
111 | SIO_SI_OUT(1)
112 | SIO_SO_OUT(1)
113 | SIO_SC(sc)
114 | SIO_SD(sd)
115 | SIO_SI(si)
116 | SIO_SO(so);
117 update = false;
118 }
116 } 119 }
117 screen_fill(0); 120 screen_fill(0);
118 bios_vblank_wait(); 121 bios_vblank_wait();
119 txt_clear(); 122 txt_clear();
120 txt_printf("----- LINK CABLE TESTER -----\n\n"); 123 txt_printf("----- LINK CABLE TESTER -----\n\n");
121 txt_printf("SC: %d\n", sc); 124 if (input_mode) {
122 txt_printf("SD: %d\n", sd); 125 txt_printf("N INPUT: %d\n", input_received);
123 txt_printf("SI: %d\n", si); 126 } else {
124 txt_printf("SO: %d\n", so); 127 txt_printf("A: SO B: SI L: SC R: SD \n\n");
128 txt_printf("-----------------------------\n\n");
129 txt_printf("SC: %d\n", sc);
130 txt_printf("SD: %d\n", sd);
131 txt_printf("SI: %d\n", si);
132 txt_printf("SO: %d\n", so);
133 }
134 txt_printf("\n-----------------------------\n\n");
135 txt_printf("START: Switch test modes\n");
136 txt_printf("\n-----------------------------\n\n");
125 txt_render(); 137 txt_render();
126 } 138 }
127 139