浏览代码

more unit testing...

SBird1337 8 年前
父节点
当前提交
adf23d610a

+ 2
- 2
data/moves/effect_table.S 查看文件

@@ -4,9 +4,9 @@
4 4
 
5 5
 .global m_effect_table
6 6
 m_effect_table:
7
-	@.word bs_test           @for unit tests
7
+	.word bs_test           @for unit tests
8 8
         @.word bs_power_trick    @for testing
9
-        .word 0x081D6900 @0
9
+        @.word 0x081D6900 @0
10 10
 	.word 0x081D696D @1
11 11
 	.word 0x081D69DC @2
12 12
 	.word 0x081D69E7 @3

+ 1
- 1
makefile 查看文件

@@ -73,7 +73,7 @@ all: rom
73 73
 .PHONY: rom
74 74
 rom: main.asm $(MAIN_OBJ)
75 75
 	$(ARS) $<
76
-	$(NM) $(BLDPATH)/linked.o -l -n -g --defined-only | \
76
+	$(NM) $(BLDPATH)/linked.o -n -g --defined-only | \
77 77
 		sed -e '{s/^/0x/g};{/.*\sA\s.*/d};{s/\sT\s/ /g}' > $(OUTPATH)/__symbols.sym
78 78
 	@echo "*** SUCCESSFULLY BUILT PROJECT ***"
79 79
 	

+ 8
- 4
src/battle_engine/battle_initiative.c 查看文件

@@ -5,7 +5,7 @@
5 5
 struct move_info move_table[1024];
6 6
 
7 7
 u16 get_speed(u8 bank) {
8
-    u16 speed = battle_participants[bank].spd;
8
+    u32 speed = battle_participants[bank].spd << 16;
9 9
     switch (get_item_effect(bank, 1)) {
10 10
         case ITEM_EFFECT_IRONBALL:
11 11
             speed >>= 1;
@@ -35,19 +35,23 @@ u16 get_speed(u8 bank) {
35 35
                 break;
36 36
             case ABILITY_QUICK_FEET:
37 37
                 if (battle_participants[bank].status.flags.burn || battle_participants[bank].status.flags.poison || battle_participants[bank].status.flags.toxic_poison)
38
-                    speed *= 2;
38
+                    speed = speed + ((speed * 50) / 100);
39 39
                 else if (battle_participants[bank].status.flags.paralysis)
40
+                {
41
+                    //cancel para
40 42
                     speed *= 4;
43
+                    speed = speed + ((speed * 50) / 100);
44
+                }
41 45
                 break;
42 46
         }
43 47
     }
44 48
     if (battle_participants[bank].status.flags.paralysis)
45
-        speed >= 2;
49
+        speed >>= 2;
46 50
     if (custom_battle_elements.ptr->side_affecting[get_side_from_bank(bank)].tailwind)
47 51
         speed *= 2;
48 52
     //TODO: unburden
49 53
     speed = (speed * stat_buffs[battle_participants[bank].spd_buff].dividend) / (stat_buffs[battle_participants[bank].spd_buff].divisor);
50
-    return speed;
54
+    return (u16)(speed >> 16);
51 55
 }
52 56
 
53 57
 enum init_enum get_first_to_strike(u8 bank_one, u8 bank_two, u8 ignore_prio) {

+ 194
- 7
src/battle_engine/battle_test.c 查看文件

@@ -3,8 +3,11 @@
3 3
 #include <bpre.h>
4 4
 #include <debug.h>
5 5
 #include <battle_initiative.h>
6
+#include <abilities.h>
6 7
 
7
-void test_battle() {
8
+#define TEST_AMOUNT 10000
9
+
10
+void test_speed() {
8 11
     print("Initiating Initiative Unit\nTest...\n");
9 12
     u8 pass = true;
10 13
     battle_participants[0].spd = 10;
@@ -58,10 +61,185 @@ void test_battle() {
58 61
         pass = false;
59 62
         print("\xFE\x2 fail\n\xFE\x0");
60 63
     }
64
+
65
+    battle_participants[1].ability_id = ABILITY_STALL;
66
+    print("stall test (+tr): ");
67
+    result = get_first_to_strike(0, 1, 0);
68
+    if (result == ONE)
69
+        print("\xFE\x1 pass\n\xFE\x0");
70
+    else {
71
+        pass = false;
72
+        print("\xFE\x2 fail\n\xFE\x0");
73
+    }
74
+    custom_battle_elements.ptr->field_affecting.trick_room = 0;
75
+    print("stall test (-tr): ");
61 76
     
77
+    result = get_first_to_strike(0, 1, 0);
78
+    if (result == ONE)
79
+        print("\xFE\x1 pass\n\xFE\x0");
80
+    else {
81
+        pass = false;
82
+        print("\xFE\x2 fail\n\xFE\x0");
83
+    }
84
+
85
+    battle_participants[1].ability_id = 0;
86
+
87
+    print("\nPRESS A TO CONTINUE...");
62 88
     wait_for_btn(1);
63 89
     debug_clean();
64
-    
90
+
91
+    print("speed value tests...\n");
92
+    battle_participants[0].spd = 75;
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);
96
+    u16 speed_one = get_speed(0);
97
+    u16 speed_two = get_speed(1);
98
+    printf("unaffected speed: %d", speed_one);
99
+    printf(": %d", speed_two);
100
+    if (speed_one == 75 && speed_two == 60) {
101
+        print(" \xFE\x1pass\xFE\x0\n");
102
+    } else {
103
+        print("\xFE\x02 fail\xFE\x0\n");
104
+        pass = false;
105
+    }
106
+    battle_participants[0].status.flags.paralysis = 1;
107
+    battle_participants[1].status.flags.paralysis = 1;
108
+    speed_one = get_speed(0);
109
+    speed_two = get_speed(1);
110
+    printf("para speed: %d", speed_one);
111
+    printf(": %d", speed_two);
112
+
113
+    if (speed_one == 18 && speed_two == 15) {
114
+        print(" \xFE\x1pass\xFE\x0\n");
115
+    } else {
116
+        print("\xFE\x02 fail\xFE\x0\n");
117
+        pass = false;
118
+    }
119
+    battle_participants[0].spd_buff = 12;
120
+    battle_participants[1].spd_buff = 12;
121
+    speed_one = get_speed(0);
122
+    speed_two = get_speed(1);
123
+
124
+    printf("para/speed+6: %d", speed_one);
125
+    printf(": %d", speed_two);
126
+
127
+    if (speed_one == 75 && speed_two == 60) {
128
+        print(" \xFE\x1pass\xFE\x0\n");
129
+    } else {
130
+        print("\xFE\x02 fail\xFE\x0\n");
131
+        pass = false;
132
+    }
133
+    battle_participants[0].status.flags.paralysis = 0;
134
+    battle_participants[1].status.flags.paralysis = 0;
135
+    speed_one = get_speed(0);
136
+    speed_two = get_speed(1);
137
+
138
+    printf("speed+6: %d", speed_one);
139
+    printf(": %d", speed_two);
140
+
141
+    if (speed_one == 300 && speed_two == 240) {
142
+        print(" \xFE\x1pass\xFE\x0\n");
143
+    } else {
144
+        print("\xFE\x02 fail\xFE\x0\n");
145
+        pass = false;
146
+    }
147
+
148
+    battle_participants[0].spd_buff = 3;
149
+    battle_participants[1].spd_buff = 3;
150
+    speed_one = get_speed(0);
151
+    speed_two = get_speed(1);
152
+
153
+    printf("speed-3: %d", speed_one);
154
+    printf(": %d", speed_two);
155
+
156
+    if (speed_one == 30 && speed_two == 24) {
157
+        print(" \xFE\x1pass\xFE\x0\n");
158
+    } else {
159
+        print("\xFE\x02 fail\xFE\x0\n");
160
+        pass = false;
161
+    }
162
+
163
+    battle_participants[0].spd_buff = 6;
164
+    battle_participants[1].spd_buff = 6;
165
+    print("activating chemtrails...\n");
166
+    battle_weather.flags.rain = 1;
167
+    battle_weather.flags.sun = 1;
168
+    battle_weather.flags.sandstorm = 1;
169
+    u8 weather_pass = true;
170
+    battle_participants[0].ability_id = ABILITY_CHLOROPHYLL;
171
+    speed_one = get_speed(0);
172
+    if (speed_one != 150)
173
+        weather_pass = false;
174
+    battle_participants[0].ability_id = ABILITY_SWIFT_SWIM;
175
+    speed_one = get_speed(0);
176
+    if (speed_one != 150)
177
+        weather_pass = false;
178
+    battle_participants[0].ability_id = ABILITY_SAND_RUSH;
179
+    battle_participants[1].ability_id = ABILITY_SAND_RUSH;
180
+    speed_one = get_speed(0);
181
+    if (speed_one != 150)
182
+        weather_pass = false;
183
+    print("weather test:");
184
+    print(weather_pass ? "\xFE\x1 pass\xFE\x0\n" : "\xFE\x2 fail\xFE\x0\n");
185
+    if (!weather_pass)
186
+        pass = false;
187
+
188
+    print("tailwind + weather: ");
189
+    custom_battle_elements.ptr->side_affecting[0].tailwind = 1;
190
+    custom_battle_elements.ptr->side_affecting[0].tailwind_bank = 0;
191
+    custom_battle_elements.ptr->side_affecting[1].tailwind = 1;
192
+    custom_battle_elements.ptr->side_affecting[1].tailwind_bank = 1;
193
+    speed_one = get_speed(0);
194
+    speed_two = get_speed(1);
195
+
196
+    if (speed_one == 300 && speed_two == 240) {
197
+        print(" \xFE\x1pass\xFE\x0\n");
198
+    } else {
199
+        print("\xFE\x02 fail\xFE\x0\n");
200
+        pass = false;
201
+    }
202
+    custom_battle_elements.ptr->side_affecting[0].tailwind = 0;
203
+    custom_battle_elements.ptr->side_affecting[0].tailwind_bank = 0;
204
+    custom_battle_elements.ptr->side_affecting[1].tailwind = 0;
205
+    custom_battle_elements.ptr->side_affecting[1].tailwind_bank = 0;
206
+    battle_weather.flags.rain = 0;
207
+    battle_weather.flags.sun = 0;
208
+    battle_weather.flags.sandstorm = 0;
209
+
210
+
211
+    print("quick feet: ");
212
+    battle_participants[0].ability_id = ABILITY_QUICK_FEET;
213
+    battle_participants[1].ability_id = ABILITY_QUICK_FEET;
214
+    battle_participants[0].status.flags.paralysis = 1;
215
+    battle_participants[1].status.flags.poison = 1;
216
+
217
+    speed_one = get_speed(0);
218
+    speed_two = get_speed(1);
219
+    u8 quick_feet_pass = true;
220
+    if (speed_one == 112 && speed_two == 90) {
221
+        battle_participants[0].status.flags.sleep = 1;
222
+        battle_participants[1].status.flags.poison = 0;
223
+        battle_participants[0].status.flags.paralysis = 0;
224
+        speed_one = get_speed(0);
225
+        speed_two = get_speed(1);
226
+        if (!(speed_one == 75 && speed_two == 60)) {
227
+            quick_feet_pass = false;
228
+        }
229
+    } else
230
+        quick_feet_pass = false;
231
+
232
+    if (quick_feet_pass) {
233
+        print(" \xFE\x1pass\xFE\x0\n");
234
+    } else {
235
+        print("\xFE\x02 fail\xFE\x0\n");
236
+        pass = false;
237
+    }
238
+    battle_participants[0].status.flags.sleep = 0;
239
+    battle_participants[0].ability_id = 0;
240
+    battle_participants[1].ability_id = 0;
241
+    wait_for_btn(8);
242
+    debug_clean();
65 243
     //stress
66 244
     battle_participants[0].spd = 20;
67 245
     battle_participants[1].spd = 20;
@@ -69,23 +247,32 @@ void test_battle() {
69 247
     printf("bank_two.spd: %d\n", battle_participants[1].spd);
70 248
     int count_one = 0;
71 249
     int count_two = 0;
72
-    for (int i = 0; i < 5000; ++i) {
250
+    for (int i = 0; i < TEST_AMOUNT; ++i) {
73 251
         result = get_first_to_strike(0, 1, 0);
74 252
         if (result == ONE)
75 253
             count_one++;
76 254
         else
77 255
             count_two++;
78 256
     }
257
+
79 258
     printf("tie stress test...\ncount \xFE\x1%d\xFE\x0 / ", count_one);
80 259
     printf(" \xFE\x2%d\xFE\x0\n", count_two);
260
+    int ratio_one = (count_one * 100) / TEST_AMOUNT;
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...");
265
+
81 266
     wait_for_btn(1);
82 267
     debug_clean();
83
-    if(pass)
268
+
269
+
270
+    if (pass)
84 271
         set_debug_background(0x3E0);
85 272
     else
86
-        set_debug_background(0x31);
273
+        set_debug_background(0x1F);
87 274
     print("test complete\n(entering deadlock)");
88
-    while(true)
89
-    {}
275
+    while (true) {
276
+    }
90 277
     return;
91 278
 }

+ 1
- 1
src/debug/debug.c 查看文件

@@ -65,7 +65,7 @@ void reset_scrolling_debug() {
65 65
 }
66 66
 
67 67
 void init_unit_test() {
68
-    test_battle();
68
+    test_speed();
69 69
 }
70 70
 
71 71
 void print_string(u16 line, u16 row, u8 color, char* pBuf) {

+ 1
- 1
src/include/battle_initiative.h 查看文件

@@ -6,6 +6,6 @@
6 6
 enum init_enum {ONE, TWO, TIE};
7 7
 
8 8
 enum init_enum get_first_to_strike(u8 bank1, u8 bank2, u8 ignore_prio);
9
-
9
+u16 get_speed(u8 bank);
10 10
 #endif /* BATTLE_INITIATIVE_H */
11 11
 

+ 1
- 1
src/include/battle_test.h 查看文件

@@ -1,7 +1,7 @@
1 1
 #ifndef BATTLE_TEST_H
2 2
 #define BATTLE_TEST_H
3 3
 
4
-void test_battle();
4
+void test_speed();
5 5
 
6 6
 #endif /* BATTLE_TEST_H */
7 7