diff options
author | Bad Diode <bd@badd10de.dev> | 2023-04-21 18:33:15 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-04-21 18:33:15 +0200 |
commit | 7ee1424be26f8f35e30b04ea4e078dbe12688487 (patch) | |
tree | 93bb09c13cb1c5dbc1b54d4a5bbfec6ed9c63acf | |
parent | edc24cc2cf127c86245b3488d5405e021ae2e63f (diff) | |
download | gba-link-cable-tester-7ee1424be26f8f35e30b04ea4e078dbe12688487.tar.gz gba-link-cable-tester-7ee1424be26f8f35e30b04ea4e078dbe12688487.zip |
Add movement stop to moving line test
-rw-r--r-- | src/main.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -84,18 +84,24 @@ test_moving_line(void) { | |||
84 | int y = 0; | 84 | int y = 0; |
85 | int inc_x = 1; | 85 | int inc_x = 1; |
86 | int inc_y = 0; | 86 | int inc_y = 0; |
87 | int should_move = 1; | ||
87 | while (true) { | 88 | while (true) { |
88 | poll_keys(); | 89 | poll_keys(); |
89 | if (key_tap(KEY_A)) { | 90 | if (key_tap(KEY_A)) { |
90 | break; | 91 | break; |
91 | } | 92 | } |
93 | if (key_pressed(KEY_B)) { | ||
94 | should_move = 0; | ||
95 | } else { | ||
96 | should_move = 1; | ||
97 | } | ||
92 | bios_vblank_wait(); | 98 | bios_vblank_wait(); |
93 | FRAME_START(); | 99 | FRAME_START(); |
94 | PROF(flip_buffer(), flip_cycles); | 100 | PROF(flip_buffer(), flip_cycles); |
95 | PROF(screen_fill(3), clear_cycles); | 101 | PROF(screen_fill(3), clear_cycles); |
96 | PROF(draw_line(x, y, 239 - x, 159 - y, 2), line_cycles); | 102 | PROF(draw_line(x, y, 239 - x, 159 - y, 2), line_cycles); |
97 | x += inc_x; | 103 | x += inc_x * should_move; |
98 | y += inc_y; | 104 | y += inc_y * should_move; |
99 | if (x == 239 && inc_x == 1) { | 105 | if (x == 239 && inc_x == 1) { |
100 | inc_x = 0; | 106 | inc_x = 0; |
101 | inc_y = 1; | 107 | inc_y = 1; |
@@ -141,10 +147,6 @@ test_sprites_bounce(void) { | |||
141 | 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x00, 0x00, 0x00, | 147 | 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x00, 0x00, 0x00, |
142 | 0x00, 0x00, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x00, | 148 | 0x00, 0x00, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x00, |
143 | }; | 149 | }; |
144 | int x = 50; | ||
145 | int y = 50; | ||
146 | int inc_x = 1; | ||
147 | int inc_y = 1; | ||
148 | typedef struct Sprite { | 150 | typedef struct Sprite { |
149 | int x; | 151 | int x; |
150 | int y; | 152 | int y; |