Переглянути джерело

and more refractoring, documentation

SBird1337 8 роки тому
джерело
коміт
21b1d2606c

+ 74
- 74
src/battle_engine/battle_test.c Переглянути файл

@@ -8,112 +8,112 @@
8 8
 #define TEST_AMOUNT 10000
9 9
 
10 10
 void test_speed() {
11
-    print("Initiating Initiative Unit\nTest...\n");
11
+    debug_print("Initiating Initiative Unit\nTest...\n");
12 12
     u8 pass = true;
13 13
     battle_participants[0].spd = 10;
14 14
     battle_participants[1].spd = 11;
15
-    printf("bank_one.spd: %d\n", battle_participants[0].spd);
16
-    printf("bank_two.spd: %d\n", battle_participants[1].spd);
17
-    print("testing (await TWO):");
15
+    debug_printf("bank_one.spd: %d\n", battle_participants[0].spd);
16
+    debug_printf("bank_two.spd: %d\n", battle_participants[1].spd);
17
+    debug_print("testing (await TWO):");
18 18
     enum init_enum result = get_first_to_strike(0, 1, 0);
19 19
     if (result == TWO)
20
-        print("\xFE\x1 pass\n\xFE\x0");
20
+        debug_print("\xFE\x1 pass\n\xFE\x0");
21 21
     else {
22 22
         pass = false;
23
-        print("\xFE\x2 fail\n\xFE\x0");
23
+        debug_print("\xFE\x2 fail\n\xFE\x0");
24 24
     }
25 25
     battle_participants[0].spd = 12;
26
-    printf("bank_one.spd: %d\n", battle_participants[0].spd);
27
-    printf("bank_two.spd: %d\n", battle_participants[1].spd);
28
-    print("testing (await ONE):");
26
+    debug_printf("bank_one.spd: %d\n", battle_participants[0].spd);
27
+    debug_printf("bank_two.spd: %d\n", battle_participants[1].spd);
28
+    debug_print("testing (await ONE):");
29 29
     result = get_first_to_strike(0, 1, 0);
30 30
     if (result == ONE)
31
-        print("\xFE\x1 pass\n\xFE\x0");
31
+        debug_print("\xFE\x1 pass\n\xFE\x0");
32 32
     else {
33 33
         pass = false;
34
-        print("\xFE\x2 fail\n\xFE\x0");
34
+        debug_print("\xFE\x2 fail\n\xFE\x0");
35 35
     }
36 36
     battle_participants[0].spd = 10;
37 37
     battle_participants[1].spd = 11;
38
-    printf("bank_one.spd: %d\n", battle_participants[0].spd);
39
-    printf("bank_two.spd: %d\n", battle_participants[1].spd);
38
+    debug_printf("bank_one.spd: %d\n", battle_participants[0].spd);
39
+    debug_printf("bank_two.spd: %d\n", battle_participants[1].spd);
40 40
 
41 41
     //trick room
42 42
     custom_battle_elements.ptr->field_affecting.trick_room = 1;
43
-    print("activating trick room...\n");
44
-    print("testing (await ONE):");
43
+    debug_print("activating trick room...\n");
44
+    debug_print("testing (await ONE):");
45 45
     result = get_first_to_strike(0, 1, 0);
46 46
     if (result == ONE)
47
-        print("\xFE\x1 pass\n\xFE\x0");
47
+        debug_print("\xFE\x1 pass\n\xFE\x0");
48 48
     else {
49 49
         pass = false;
50
-        print("\xFE\x2 fail\n\xFE\x0");
50
+        debug_print("\xFE\x2 fail\n\xFE\x0");
51 51
     }
52 52
 
53 53
     battle_participants[0].spd = 12;
54
-    printf("bank_one.spd: %d\n", battle_participants[0].spd);
55
-    printf("bank_two.spd: %d\n", battle_participants[1].spd);
56
-    print("testing (await TWO):");
54
+    debug_printf("bank_one.spd: %d\n", battle_participants[0].spd);
55
+    debug_printf("bank_two.spd: %d\n", battle_participants[1].spd);
56
+    debug_print("testing (await TWO):");
57 57
     result = get_first_to_strike(0, 1, 0);
58 58
     if (result == TWO)
59
-        print("\xFE\x1 pass\n\xFE\x0");
59
+        debug_print("\xFE\x1 pass\n\xFE\x0");
60 60
     else {
61 61
         pass = false;
62
-        print("\xFE\x2 fail\n\xFE\x0");
62
+        debug_print("\xFE\x2 fail\n\xFE\x0");
63 63
     }
64 64
 
65 65
     battle_participants[1].ability_id = ABILITY_STALL;
66
-    print("stall test (+tr): ");
66
+    debug_print("stall test (+tr): ");
67 67
     result = get_first_to_strike(0, 1, 0);
68 68
     if (result == ONE)
69
-        print("\xFE\x1 pass\n\xFE\x0");
69
+        debug_print("\xFE\x1 pass\n\xFE\x0");
70 70
     else {
71 71
         pass = false;
72
-        print("\xFE\x2 fail\n\xFE\x0");
72
+        debug_print("\xFE\x2 fail\n\xFE\x0");
73 73
     }
74 74
     custom_battle_elements.ptr->field_affecting.trick_room = 0;
75
-    print("stall test (-tr): ");
75
+    debug_print("stall test (-tr): ");
76 76
     
77 77
     result = get_first_to_strike(0, 1, 0);
78 78
     if (result == ONE)
79
-        print("\xFE\x1 pass\n\xFE\x0");
79
+        debug_print("\xFE\x1 pass\n\xFE\x0");
80 80
     else {
81 81
         pass = false;
82
-        print("\xFE\x2 fail\n\xFE\x0");
82
+        debug_print("\xFE\x2 fail\n\xFE\x0");
83 83
     }
84 84
 
85 85
     battle_participants[1].ability_id = 0;
86 86
 
87
-    print("\nPRESS A TO CONTINUE...");
88
-    wait_for_btn(1);
87
+    debug_print("\nPRESS A TO CONTINUE...");
88
+    debug_wait_for_btn(1);
89 89
     debug_clean();
90 90
 
91
-    print("speed value tests...\n");
91
+    debug_print("speed value tests...\n");
92 92
     battle_participants[0].spd = 75;
93 93
     battle_participants[1].spd = 60;
94
-    printf("bank_one.spd: %d\n", battle_participants[0].spd);
95
-    printf("bank_two.spd: %d\n", battle_participants[1].spd);
94
+    debug_printf("bank_one.spd: %d\n", battle_participants[0].spd);
95
+    debug_printf("bank_two.spd: %d\n", battle_participants[1].spd);
96 96
     u16 speed_one = get_speed(0);
97 97
     u16 speed_two = get_speed(1);
98
-    printf("unaffected speed: %d", speed_one);
99
-    printf(": %d", speed_two);
98
+    debug_printf("unaffected speed: %d", speed_one);
99
+    debug_printf(": %d", speed_two);
100 100
     if (speed_one == 75 && speed_two == 60) {
101
-        print(" \xFE\x1pass\xFE\x0\n");
101
+        debug_print(" \xFE\x1pass\xFE\x0\n");
102 102
     } else {
103
-        print("\xFE\x02 fail\xFE\x0\n");
103
+        debug_print("\xFE\x02 fail\xFE\x0\n");
104 104
         pass = false;
105 105
     }
106 106
     battle_participants[0].status.flags.paralysis = 1;
107 107
     battle_participants[1].status.flags.paralysis = 1;
108 108
     speed_one = get_speed(0);
109 109
     speed_two = get_speed(1);
110
-    printf("para speed: %d", speed_one);
111
-    printf(": %d", speed_two);
110
+    debug_printf("para speed: %d", speed_one);
111
+    debug_printf(": %d", speed_two);
112 112
 
113 113
     if (speed_one == 18 && speed_two == 15) {
114
-        print(" \xFE\x1pass\xFE\x0\n");
114
+        debug_print(" \xFE\x1pass\xFE\x0\n");
115 115
     } else {
116
-        print("\xFE\x02 fail\xFE\x0\n");
116
+        debug_print("\xFE\x02 fail\xFE\x0\n");
117 117
         pass = false;
118 118
     }
119 119
     battle_participants[0].spd_buff = 12;
@@ -121,13 +121,13 @@ void test_speed() {
121 121
     speed_one = get_speed(0);
122 122
     speed_two = get_speed(1);
123 123
 
124
-    printf("para/speed+6: %d", speed_one);
125
-    printf(": %d", speed_two);
124
+    debug_printf("para/speed+6: %d", speed_one);
125
+    debug_printf(": %d", speed_two);
126 126
 
127 127
     if (speed_one == 75 && speed_two == 60) {
128
-        print(" \xFE\x1pass\xFE\x0\n");
128
+        debug_print(" \xFE\x1pass\xFE\x0\n");
129 129
     } else {
130
-        print("\xFE\x02 fail\xFE\x0\n");
130
+        debug_print("\xFE\x02 fail\xFE\x0\n");
131 131
         pass = false;
132 132
     }
133 133
     battle_participants[0].status.flags.paralysis = 0;
@@ -135,13 +135,13 @@ void test_speed() {
135 135
     speed_one = get_speed(0);
136 136
     speed_two = get_speed(1);
137 137
 
138
-    printf("speed+6: %d", speed_one);
139
-    printf(": %d", speed_two);
138
+    debug_printf("speed+6: %d", speed_one);
139
+    debug_printf(": %d", speed_two);
140 140
 
141 141
     if (speed_one == 300 && speed_two == 240) {
142
-        print(" \xFE\x1pass\xFE\x0\n");
142
+        debug_print(" \xFE\x1pass\xFE\x0\n");
143 143
     } else {
144
-        print("\xFE\x02 fail\xFE\x0\n");
144
+        debug_print("\xFE\x02 fail\xFE\x0\n");
145 145
         pass = false;
146 146
     }
147 147
 
@@ -150,19 +150,19 @@ void test_speed() {
150 150
     speed_one = get_speed(0);
151 151
     speed_two = get_speed(1);
152 152
 
153
-    printf("speed-3: %d", speed_one);
154
-    printf(": %d", speed_two);
153
+    debug_printf("speed-3: %d", speed_one);
154
+    debug_printf(": %d", speed_two);
155 155
 
156 156
     if (speed_one == 30 && speed_two == 24) {
157
-        print(" \xFE\x1pass\xFE\x0\n");
157
+        debug_print(" \xFE\x1pass\xFE\x0\n");
158 158
     } else {
159
-        print("\xFE\x02 fail\xFE\x0\n");
159
+        debug_print("\xFE\x02 fail\xFE\x0\n");
160 160
         pass = false;
161 161
     }
162 162
 
163 163
     battle_participants[0].spd_buff = 6;
164 164
     battle_participants[1].spd_buff = 6;
165
-    print("activating chemtrails...\n");
165
+    debug_print("activating chemtrails...\n");
166 166
     battle_weather.flags.rain = 1;
167 167
     battle_weather.flags.sun = 1;
168 168
     battle_weather.flags.sandstorm = 1;
@@ -180,12 +180,12 @@ void test_speed() {
180 180
     speed_one = get_speed(0);
181 181
     if (speed_one != 150)
182 182
         weather_pass = false;
183
-    print("weather test:");
184
-    print(weather_pass ? "\xFE\x1 pass\xFE\x0\n" : "\xFE\x2 fail\xFE\x0\n");
183
+    debug_print("weather test:");
184
+    debug_print(weather_pass ? "\xFE\x1 pass\xFE\x0\n" : "\xFE\x2 fail\xFE\x0\n");
185 185
     if (!weather_pass)
186 186
         pass = false;
187 187
 
188
-    print("tailwind + weather: ");
188
+    debug_print("tailwind + weather: ");
189 189
     custom_battle_elements.ptr->side_affecting[0].tailwind = 1;
190 190
     custom_battle_elements.ptr->side_affecting[0].tailwind_bank = 0;
191 191
     custom_battle_elements.ptr->side_affecting[1].tailwind = 1;
@@ -194,9 +194,9 @@ void test_speed() {
194 194
     speed_two = get_speed(1);
195 195
 
196 196
     if (speed_one == 300 && speed_two == 240) {
197
-        print(" \xFE\x1pass\xFE\x0\n");
197
+        debug_print(" \xFE\x1pass\xFE\x0\n");
198 198
     } else {
199
-        print("\xFE\x02 fail\xFE\x0\n");
199
+        debug_print("\xFE\x02 fail\xFE\x0\n");
200 200
         pass = false;
201 201
     }
202 202
     custom_battle_elements.ptr->side_affecting[0].tailwind = 0;
@@ -208,7 +208,7 @@ void test_speed() {
208 208
     battle_weather.flags.sandstorm = 0;
209 209
 
210 210
 
211
-    print("quick feet: ");
211
+    debug_print("quick feet: ");
212 212
     battle_participants[0].ability_id = ABILITY_QUICK_FEET;
213 213
     battle_participants[1].ability_id = ABILITY_QUICK_FEET;
214 214
     battle_participants[0].status.flags.paralysis = 1;
@@ -230,21 +230,21 @@ void test_speed() {
230 230
         quick_feet_pass = false;
231 231
 
232 232
     if (quick_feet_pass) {
233
-        print(" \xFE\x1pass\xFE\x0\n");
233
+        debug_print(" \xFE\x1pass\xFE\x0\n");
234 234
     } else {
235
-        print("\xFE\x02 fail\xFE\x0\n");
235
+        debug_print("\xFE\x02 fail\xFE\x0\n");
236 236
         pass = false;
237 237
     }
238 238
     battle_participants[0].status.flags.sleep = 0;
239 239
     battle_participants[0].ability_id = 0;
240 240
     battle_participants[1].ability_id = 0;
241
-    wait_for_btn(8);
241
+    debug_wait_for_btn(8);
242 242
     debug_clean();
243 243
     //stress
244 244
     battle_participants[0].spd = 20;
245 245
     battle_participants[1].spd = 20;
246
-    printf("bank_one.spd: %d\n", battle_participants[0].spd);
247
-    printf("bank_two.spd: %d\n", battle_participants[1].spd);
246
+    debug_printf("bank_one.spd: %d\n", battle_participants[0].spd);
247
+    debug_printf("bank_two.spd: %d\n", battle_participants[1].spd);
248 248
     int count_one = 0;
249 249
     int count_two = 0;
250 250
     for (int i = 0; i < TEST_AMOUNT; ++i) {
@@ -255,23 +255,23 @@ void test_speed() {
255 255
             count_two++;
256 256
     }
257 257
 
258
-    printf("tie stress test...\ncount \xFE\x1%d\xFE\x0 / ", count_one);
259
-    printf(" \xFE\x2%d\xFE\x0\n", count_two);
258
+    debug_printf("tie stress test...\ncount \xFE\x1%d\xFE\x0 / ", count_one);
259
+    debug_printf(" \xFE\x2%d\xFE\x0\n", count_two);
260 260
     int ratio_one = (count_one * 100) / TEST_AMOUNT;
261 261
     int ratio_two = (count_two * 100) / TEST_AMOUNT;
262
-    printf("%d%% / ", ratio_one);
263
-    printf("%d%%\n", ratio_two);
264
-    print("\nPRESS A TO CONTINUE...");
262
+    debug_printf("%d%% / ", ratio_one);
263
+    debug_printf("%d%%\n", ratio_two);
264
+    debug_print("\nPRESS A TO CONTINUE...");
265 265
 
266
-    wait_for_btn(1);
266
+    debug_wait_for_btn(1);
267 267
     debug_clean();
268 268
 
269 269
 
270 270
     if (pass)
271
-        set_debug_background(0x3E0);
271
+        debug_set_bg(0x3E0);
272 272
     else
273
-        set_debug_background(0x1F);
274
-    print("test complete\n(entering deadlock)");
273
+        debug_set_bg(0x1F);
274
+    debug_print("test complete\n(entering deadlock)");
275 275
     while (true) {
276 276
     }
277 277
     return;

+ 1
- 1
src/battle_engine/scripts/test.S Переглянути файл

@@ -5,7 +5,7 @@
5 5
 .text
6 6
 .global bs_test
7 7
 bs_test:
8
-    callasm some_test+1
8
+    callasm debug_some_test+1
9 9
     end
10 10
 
11 11
 

+ 170
- 26
src/debug/debug.c Переглянути файл

@@ -1,14 +1,158 @@
1
-#include <bpre.h>
1
+/****************************************************************************
2
+ * Copyright (C) 2015-2016 by the SotS Team                                 *
3
+ *                                                                          *
4
+ * This file is part of Sovereign of the Skies.                             *
5
+ *                                                                          *
6
+ *   Sovereign of the Skies is free software: you can redistribute it       *
7
+ *   and/or modify it                                                       *
8
+ *   under the terms of the GNU Lesser General Public License as published  *
9
+ *   by the Free Software Foundation, either version 3 of the License, or   *
10
+ *   (at your option) any later version provided you include a copy of the  *
11
+ *   licence and this header.                                               *
12
+ *                                                                          *
13
+ *   Sovereign of the Skies is distributed in the hope that it will be      *
14
+ *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU Lesser General Public License for more details.                    *
17
+ *                                                                          *
18
+ *   You should have received a copy of the GNU Lesser General Public       *
19
+ *   License along with Sovereign of the Skies.                             *
20
+ *   If not, see <http://www.gnu.org/licenses/>.                            *
21
+ ****************************************************************************/
22
+
23
+/**
24
+ * @file debug.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Operate with the sots debug engine, very temporary
28
+ */
29
+
30
+/* === INCLUDE === */
31
+
32
+#include <types.h>
33
+#include <callback.h>
34
+#include <lcd.h>
2 35
 #include <debug.h>
36
+#include <memory.h>
3 37
 #include <assets/ascii.h>
4 38
 #include <battle_test.h>
39
+#include <math.h>
40
+#include <fade.h>
41
+
42
+/* === STATICS === */
43
+
44
+static struct print_engine* print_memory = (struct print_engine*)(0x0203FFF0);
45
+
46
+/* === PROTOTYPES === */
47
+
48
+/**
49
+ * @brief set bg color
50
+ * @param color color to set bg to
51
+ */
52
+void debug_set_bg(u16 color);
53
+
54
+/**
55
+ * @brief clean debug screen from any text and reset cursor
56
+ */
57
+void debug_clean();
58
+
59
+/**
60
+ * @brief wait for button press
61
+ * @param field bitfield to specify buttom combination
62
+ */
63
+void debug_wait_for_btn(u16 field);
64
+
65
+/**
66
+ * @brief convert int to char
67
+ * @param i integer
68
+ * @param ref buffer to output to
69
+ */
70
+void debug_int_to_char(u32 i, char* ref);
71
+
72
+/**
73
+ * @get length of integer
74
+ * @param i integer
75
+ * @return length
76
+ */
77
+u32 debug_dec_len(u32 i);
78
+
79
+/**
80
+ * @brief update debug environment
81
+ */
82
+void debug_update();
83
+
84
+/**
85
+ * @brief reset scrolling (from overworld e.g.)
86
+ */
87
+void debug_reset_scrolling();
88
+
89
+/**
90
+ * @brief start a unit test function
91
+ */
92
+void debug_init_unit_test();
93
+
94
+/**
95
+ * @brief handle for the debug scene
96
+ */
97
+void debug_scene();
98
+
99
+/**
100
+ * @brief convert character to byte
101
+ * @param character character
102
+ * @return byte from character
103
+ */
104
+u8 char_to_byte(char character);
105
+
106
+/**
107
+ * @brief print a character on the debug environment
108
+ * @param line line to print to
109
+ * @param row row to print to
110
+ * @param character character to print
111
+ * @param color color to print in
112
+ */
113
+void debug_print_char(u16 line, u16 row, char character, u8 color);
114
+
115
+/**
116
+ * @brief print a string to the debug environment
117
+ * @param line line to print to
118
+ * @param row row to start
119
+ * @param color color to print in
120
+ * @param pBuf string buffer to print (null terminated)
121
+ */
122
+void debug_print_string(u16 line, u16 row, u8 color, char* pBuf);
123
+
124
+/**
125
+ * @brief print string onto debug environment at current position with parsing
126
+ * @param str string to print
127
+ */
128
+void debug_print(char* str);
129
+
130
+/**
131
+ * @brief build power
132
+ * @param n integer to power
133
+ * @param power exponent
134
+ * @return n^power
135
+ */
136
+u32 debug_power(u32 n, u32 power);
137
+
138
+/**
139
+ * @brief print in format to debug environment
140
+ * @param str string with format
141
+ * @param arg argument to print (only one, not an array)
142
+ */
143
+void debug_printf(char* str, int arg);
5 144
 
6
-void set_debug_background(u16 color) {
145
+/**
146
+ * @brief set bg color of debug environment
147
+ * @param color color to set to
148
+ */
149
+void debug_set_bg(u16 color) {
7 150
     u16* bgc = (u16*) 0x020375f8;
8 151
     *bgc = color;
9 152
     return;
10 153
 }
11 154
 
155
+/* === IMPLEMENTATIONS === */
12 156
 void debug_scene() {
13 157
     if (superstate.multi_purpose_state_tracker == 0) {
14 158
         print_memory->row = 0;
@@ -27,7 +171,7 @@ void debug_scene() {
27 171
         gpu_bg_show(3);
28 172
 
29 173
         gpu_sync_bg_visibility_and_mode();
30
-        reset_scrolling_debug();
174
+        debug_reset_scrolling();
31 175
         obj_delete_all();
32 176
         memset((void*) 0x06000000, 0, 0x17fe0);
33 177
         memset((void*) 0x020375F8, 0, 0x400);
@@ -35,16 +179,16 @@ void debug_scene() {
35 179
     } else if (superstate.multi_purpose_state_tracker == 1) {
36 180
         vram_decompress((void*) asciiTiles, (void*) 0x06000000);
37 181
         memcpy((void*) 0x020375F8, (void*) asciiPal, 0x60);
38
-        set_debug_background(0x0000);
182
+        debug_set_bg(0x0000);
39 183
         superstate.multi_purpose_state_tracker++;
40 184
     } else if (superstate.multi_purpose_state_tracker == 2) {
41
-        init_unit_test();
185
+        debug_init_unit_test();
42 186
         superstate.multi_purpose_state_tracker++;
43 187
     }
44 188
     return;
45 189
 }
46 190
 
47
-u8 some_test() {
191
+u8 debug_some_test() {
48 192
     set_callback2(debug_scene);
49 193
     vblank_handler_set(debug_update);
50 194
     superstate.multi_purpose_state_tracker = 0;
@@ -52,7 +196,7 @@ u8 some_test() {
52 196
     return 0;
53 197
 }
54 198
 
55
-void reset_scrolling_debug() {
199
+void debug_reset_scrolling() {
56 200
     lcd_io_set_func(0x12, 0x0);
57 201
     lcd_io_set_func(0x14, 0x0);
58 202
     lcd_io_set_func(0x16, 0x0);
@@ -64,18 +208,18 @@ void reset_scrolling_debug() {
64 208
     return;
65 209
 }
66 210
 
67
-void init_unit_test() {
211
+void debug_init_unit_test() {
68 212
     test_speed();
69 213
 }
70 214
 
71
-void print_string(u16 line, u16 row, u8 color, char* pBuf) {
215
+void debug_print_string(u16 line, u16 row, u8 color, char* pBuf) {
72 216
     while (*pBuf) {
73
-        print_character(line, row++, *pBuf++, color);
217
+        debug_print_char(line, row++, *pBuf++, color);
74 218
     }
75 219
     return;
76 220
 }
77 221
 
78
-void print(char* str) {
222
+void debug_print(char* str) {
79 223
     while (*str) {
80 224
         if (*str == '\n') {
81 225
             print_memory->line++;
@@ -87,7 +231,7 @@ void print(char* str) {
87 231
                 c = 0;
88 232
             print_memory->color = c;
89 233
         } else {
90
-            print_character(print_memory->line, print_memory->row, *str, print_memory->color);
234
+            debug_print_char(print_memory->line, print_memory->row, *str, print_memory->color);
91 235
             print_memory->row++;
92 236
         }
93 237
         str++;
@@ -95,7 +239,7 @@ void print(char* str) {
95 239
     return;
96 240
 }
97 241
 
98
-void printf(char* str, int arg) {
242
+void debug_printf(char* str, int arg) {
99 243
     while (*str) {
100 244
         if (*str == '\n') {
101 245
             print_memory->line++;
@@ -109,21 +253,21 @@ void printf(char* str, int arg) {
109 253
         } else if (*str == '%') {
110 254
             str++;
111 255
             if (*str == '%') {
112
-                print_character(print_memory->line, print_memory->row, *str, print_memory->color);
256
+                debug_print_char(print_memory->line, print_memory->row, *str, print_memory->color);
113 257
                 print_memory->row++;
114 258
             } else if (*str == 'd') {
115
-                u32 len = dec_len(arg);
116
-                char temp[dec_len(len + 1)];
259
+                u32 len = debug_dec_len(arg);
260
+                char temp[debug_dec_len(len + 1)];
117 261
                 temp[len] = 0;
118
-                int_to_char(arg, temp);
119
-                print(temp);
262
+                debug_int_to_char(arg, temp);
263
+                debug_print(temp);
120 264
             } else if (*str == 'c') {
121 265
                 char print_char = (char) (arg);
122
-                print_character(print_memory->line, print_memory->row, print_char, print_memory->color);
266
+                debug_print_char(print_memory->line, print_memory->row, print_char, print_memory->color);
123 267
                 print_memory->row++;
124 268
             }
125 269
         } else {
126
-            print_character(print_memory->line, print_memory->row, *str, print_memory->color);
270
+            debug_print_char(print_memory->line, print_memory->row, *str, print_memory->color);
127 271
             print_memory->row++;
128 272
         }
129 273
         str++;
@@ -138,14 +282,14 @@ void debug_clean() {
138 282
     return;
139 283
 }
140 284
 
141
-void wait_for_btn(u16 field) {
285
+void debug_wait_for_btn(u16 field) {
142 286
     volatile u16* control_io = (volatile u16*) (0x04000130);
143 287
     while (*control_io & field) {
144 288
     }
145 289
     return;
146 290
 }
147 291
 
148
-void print_character(u16 line, u16 row, char character, u8 color) {
292
+void debug_print_char(u16 line, u16 row, char character, u8 color) {
149 293
     if (color > 2)
150 294
         color = 0;
151 295
     u16 position = (32 * line) + row;
@@ -173,12 +317,12 @@ void debug_update() {
173 317
     obj_gpu_sprites_upload();
174 318
 }
175 319
 
176
-void int_to_char(u32 i, char* ref) {
320
+void debug_int_to_char(u32 i, char* ref) {
177 321
     if (i == 0) {
178 322
         ref[0] = '0';
179 323
         return;
180 324
     }
181
-    u32 len = dec_len(i);
325
+    u32 len = debug_dec_len(i);
182 326
     while (i > 0) {
183 327
 
184 328
         ref[len - 1] = '0' + (__aeabi_uidivmod(i, 10));
@@ -189,7 +333,7 @@ void int_to_char(u32 i, char* ref) {
189 333
     return;
190 334
 }
191 335
 
192
-u32 power(u32 n, u32 power) {
336
+u32 debug_power(u32 n, u32 power) {
193 337
     u32 out = 1;
194 338
     for (int i = 0; i < power; ++i) {
195 339
         out = out * n;
@@ -197,7 +341,7 @@ u32 power(u32 n, u32 power) {
197 341
     return out;
198 342
 }
199 343
 
200
-u32 dec_len(u32 i) {
344
+u32 debug_dec_len(u32 i) {
201 345
     u32 len = 1;
202 346
     while ((i /= 10) > 0) {
203 347
         len++;

+ 1
- 18
src/include/debug.h Переглянути файл

@@ -7,24 +7,7 @@ struct print_engine{
7 7
     u8 color;
8 8
 };
9 9
 
10
-static struct print_engine* print_memory = (struct print_engine*)(0x0203FFF0);
11
-
12
-void set_debug_background(u16 color);
13
-void debug_clean();
14
-void wait_for_btn(u16 field);
15
-void int_to_char(u32 i, char* ref);
16
-u32 dec_len(u32 i);
17
-void debug_update();
18
-u8 some_test();
19
-void reset_scrolling_debug();
20
-void init_unit_test();
21
-void debug_scene();
22
-u8 char_to_byte(char character);
23
-void print_character(u16 line, u16 row, char character, u8 color);
24
-void print_string(u16 line, u16 row, u8 color, char* pBuf);
25
-void print(char* str);
26
-u32 power(u32 n, u32 power);
27
-void printf(char* str, int arg);
10
+u8 debug_some_test();
28 11
 
29 12
 #endif /* DEBUG_H */
30 13
 

+ 1
- 1
src/specials/custom_specials.c Переглянути файл

@@ -22,7 +22,7 @@ static callback special_routines[5] = {
22 22
 	met_play,
23 23
 	sp_move_camera,
24 24
 	init_script,
25
-        some_test,
25
+        debug_some_test,
26 26
         dns_switch,
27 27
 };
28 28