Explorar el Código

added unit test for initiatibve (normal + trickroom)

tied to bs_test
SBird1337 hace 8 años
padre
commit
77e945f856

+ 4
- 1
bpre.sym Ver fichero

@@ -115,4 +115,7 @@ mplay_table = 0x084A329C;
115 115
 m4aSongNumStart = 0x081DD0F5;
116 116
 MPlayStart_rev01 = 0x081DD859;
117 117
 MPlayContinue = 0x081DCFF9;
118
-__aeabi_idiv = 0x081E460C|1;
118
+__aeabi_idiv = 0x081E4018|1;
119
+__aeabi_idivmod = 0x081E40F4|1;
120
+__aeabi_uidiv = 0x081E460C|1;
121
+__aeabi_uidivmod = 0x081E4684|1;

+ 2
- 1
data/moves/effect_table.S Ver fichero

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

+ 2
- 1
linker.ld Ver fichero

@@ -14,10 +14,11 @@ SECTIONS {
14 14
                 *(.text)
15 15
                 *(.ctors)
16 16
                 *(.dtors)
17
-                *(.rodata)
18 17
                 *(.fini)
19 18
                 *(COMMON)
20 19
                 __text_end  = . ;
20
+                *(.rodata*)
21
+                *(.rdata)
21 22
                 *(.data)
22 23
                 __bss_start__ = . ;
23 24
                 *(.bss)

+ 2
- 2
makefile Ver fichero

@@ -13,7 +13,7 @@ export PATH := $(realpath ../tools):$(PATH)
13 13
 
14 14
 DEFINES   := -DBPRE -DSOFTWARE_VERSION=0
15 15
 ASFLAGS   := -mthumb
16
-CFLAGS    := -g -mthumb -mno-thumb-interwork -mcpu=arm7tdmi -fno-inline -mlong-calls -march=armv4t -O3 -std=gnu99 -Isrc/include $(DEFINES)
16
+CFLAGS    := -g -mthumb -mno-thumb-interwork -mcpu=arm7tdmi -fno-inline -mlong-calls -march=armv4t -O3 -std=c99 -Wall -Isrc/include $(DEFINES)
17 17
 GRITFLAGS := -ftc -fa
18 18
 LDFLAGS   := -z muldefs
19 19
 BLDPATH   := object
@@ -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 -n -g --defined-only | \
76
+	$(NM) $(BLDPATH)/linked.o -l -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
 	

+ 12
- 6
nbproject/configurations.xml Ver fichero

@@ -4592,12 +4592,13 @@
4592 4592
         <df name="battle_engine">
4593 4593
           <df name="scripts">
4594 4594
             <in>hazards.S</in>
4595
+            <in>test.S</in>
4595 4596
           </df>
4596 4597
           <in>battle_abilities.c</in>
4597 4598
           <in>battle_help.c</in>
4598 4599
           <in>battle_initiative.c</in>
4599
-          <in>battle_initiative.h</in>
4600 4600
           <in>battle_switch_in_hook.S</in>
4601
+          <in>battle_test.c</in>
4601 4602
           <in>custom_structs_malloc.c</in>
4602 4603
           <in>custom_structs_malloc_hook.S</in>
4603 4604
           <in>entry_hazards.c</in>
@@ -4612,6 +4613,8 @@
4612 4613
         </df>
4613 4614
         <df name="include">
4614 4615
           <in>battle_abilities.h</in>
4616
+          <in>battle_initiative.h</in>
4617
+          <in>battle_test.h</in>
4615 4618
           <in>debug.h</in>
4616 4619
           <in>item_effects.h</in>
4617 4620
           <in>items.h</in>
@@ -27181,16 +27184,13 @@
27181 27184
             tool="0"
27182 27185
             flavor2="0">
27183 27186
       </item>
27184
-      <item path="src/battle_engine/battle_initiative.h"
27185
-            ex="false"
27186
-            tool="3"
27187
-            flavor2="0">
27188
-      </item>
27189 27187
       <item path="src/battle_engine/battle_switch_in_hook.S"
27190 27188
             ex="false"
27191 27189
             tool="4"
27192 27190
             flavor2="0">
27193 27191
       </item>
27192
+      <item path="src/battle_engine/battle_test.c" ex="false" tool="0" flavor2="0">
27193
+      </item>
27194 27194
       <item path="src/battle_engine/custom_structs_malloc.c"
27195 27195
             ex="false"
27196 27196
             tool="0"
@@ -27215,12 +27215,18 @@
27215 27215
             tool="4"
27216 27216
             flavor2="0">
27217 27217
       </item>
27218
+      <item path="src/battle_engine/scripts/test.S" ex="false" tool="4" flavor2="0">
27219
+      </item>
27218 27220
       <item path="src/debug/debug.c" ex="false" tool="0" flavor2="0">
27219 27221
       </item>
27220 27222
       <item path="src/encode/crc32.c" ex="false" tool="0" flavor2="0">
27221 27223
       </item>
27222 27224
       <item path="src/include/battle_abilities.h" ex="false" tool="3" flavor2="0">
27223 27225
       </item>
27226
+      <item path="src/include/battle_initiative.h" ex="false" tool="3" flavor2="0">
27227
+      </item>
27228
+      <item path="src/include/battle_test.h" ex="false" tool="3" flavor2="0">
27229
+      </item>
27224 27230
       <item path="src/include/debug.h" ex="false" tool="3" flavor2="0">
27225 27231
       </item>
27226 27232
       <item path="src/include/item_effects.h" ex="false" tool="3" flavor2="0">

+ 5
- 4
nbproject/private/configurations.xml Ver fichero

@@ -5467,13 +5467,13 @@
5467 5467
         <df name="battle_engine">
5468 5468
           <df name="scripts">
5469 5469
             <in>hazards.S</in>
5470
+            <in>test.S</in>
5470 5471
           </df>
5471 5472
           <in>battle_abilities.c</in>
5472 5473
           <in>battle_help.c</in>
5473
-          <in>battle_help.h</in>
5474 5474
           <in>battle_initiative.c</in>
5475
-          <in>battle_initiative.h</in>
5476 5475
           <in>battle_switch_in_hook.S</in>
5476
+          <in>battle_test.c</in>
5477 5477
           <in>custom_structs_malloc.c</in>
5478 5478
           <in>custom_structs_malloc.h</in>
5479 5479
           <in>custom_structs_malloc_hook.S</in>
@@ -5496,9 +5496,12 @@
5496 5496
           <in>attack_names.h</in>
5497 5497
           <in>battle.h</in>
5498 5498
           <in>battle_abilities.h</in>
5499
+          <in>battle_help.h</in>
5500
+          <in>battle_initiative.h</in>
5499 5501
           <in>battle_locations.h</in>
5500 5502
           <in>battle_script.h</in>
5501 5503
           <in>battle_structs.h</in>
5504
+          <in>battle_test.h</in>
5502 5505
           <in>bpre.h</in>
5503 5506
           <in>callback.h</in>
5504 5507
           <in>config.h</in>
@@ -5612,8 +5615,6 @@
5612 5615
         <gdb_interceptlist>
5613 5616
           <gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/>
5614 5617
         </gdb_interceptlist>
5615
-        <gdb_signals>
5616
-        </gdb_signals>
5617 5618
         <gdb_options>
5618 5619
           <DebugOptions>
5619 5620
             <option name="gdb_init_file"

+ 1
- 1
src/battle_engine/battle_help.c Ver fichero

@@ -1,4 +1,4 @@
1
-#include "battle_help.h"
1
+#include <battle_help.h>
2 2
 
3 3
 //from kds emerald battle engine upgrade
4 4
 

+ 21
- 22
src/battle_engine/battle_initiative.c Ver fichero

@@ -1,4 +1,7 @@
1
-#include "battle_initiative.h"
1
+#include <battle_initiative.h>
2
+#include <battle.h>
3
+#include <battle_help.h>
4
+#include <bpre.h>
2 5
 struct move_info move_table[1024];
3 6
 
4 7
 u16 get_speed(u8 bank) {
@@ -15,34 +18,32 @@ u16 get_speed(u8 bank) {
15 18
                 speed <<= 1;
16 19
             break;
17 20
     }
18
-    if(has_ability_effect(bank, 0, 1))
19
-    {
21
+    if (has_ability_effect(bank, 0, 1)) {
20 22
         u8 weather_effects = weather_abilities_effect();
21
-        switch (battle_participants[bank].ability_id)
22
-        {
23
+        switch (battle_participants[bank].ability_id) {
23 24
             case ABILITY_CHLOROPHYLL:
24
-                if(weather_effects && (battle_weather.flags.harsh_sun || battle_weather.flags.permament_sun || battle_weather.flags.sun))
25
-                    speed *=2;
25
+                if (weather_effects && (battle_weather.flags.harsh_sun || battle_weather.flags.permament_sun || battle_weather.flags.sun))
26
+                    speed *= 2;
26 27
                 break;
27 28
             case ABILITY_SWIFT_SWIM:
28
-                if(weather_effects && (battle_weather.flags.rain || battle_weather.flags.downpour || battle_weather.flags.permament_rain || battle_weather.flags.heavy_rain))
29
-                    speed *=2;
29
+                if (weather_effects && (battle_weather.flags.rain || battle_weather.flags.downpour || battle_weather.flags.permament_rain || battle_weather.flags.heavy_rain))
30
+                    speed *= 2;
30 31
                 break;
31 32
             case ABILITY_SAND_RUSH:
32
-                if(weather_effects && (battle_weather.flags.sandstorm || battle_weather.flags.permament_sandstorm))
33
+                if (weather_effects && (battle_weather.flags.sandstorm || battle_weather.flags.permament_sandstorm))
33 34
                     speed *= 2;
34 35
                 break;
35 36
             case ABILITY_QUICK_FEET:
36
-                if(battle_participants[bank].status.flags.burn || battle_participants[bank].status.flags.poison || battle_participants[bank].status.flags.toxic_poison)
37
+                if (battle_participants[bank].status.flags.burn || battle_participants[bank].status.flags.poison || battle_participants[bank].status.flags.toxic_poison)
37 38
                     speed *= 2;
38
-                else if(battle_participants[bank].status.flags.paralysis)
39
+                else if (battle_participants[bank].status.flags.paralysis)
39 40
                     speed *= 4;
40 41
                 break;
41 42
         }
42 43
     }
43
-    if(battle_participants[bank].status.flags.paralysis)
44
+    if (battle_participants[bank].status.flags.paralysis)
44 45
         speed >= 2;
45
-    if(custom_battle_elements.ptr->side_affecting[get_side_from_bank(bank)].tailwind)
46
+    if (custom_battle_elements.ptr->side_affecting[get_side_from_bank(bank)].tailwind)
46 47
         speed *= 2;
47 48
     //TODO: unburden
48 49
     speed = (speed * stat_buffs[battle_participants[bank].spd_buff].dividend) / (stat_buffs[battle_participants[bank].spd_buff].divisor);
@@ -73,23 +74,21 @@ enum init_enum get_first_to_strike(u8 bank_one, u8 bank_two, u8 ignore_prio) {
73 74
         //TODO: calculate speed
74 75
         u8 stall_one = has_ability(bank_one, ABILITY_STALL);
75 76
         u8 stall_two = has_ability(bank_two, ABILITY_STALL);
76
-        if(stall_one && !stall_two)
77
+        if (stall_one && !stall_two)
77 78
             result = TWO;
78
-        else if(stall_two && !stall_one)
79
+        else if (stall_two && !stall_one)
79 80
             result = ONE;
80
-        else
81
-        {
81
+        else {
82 82
             u16 speed_one = get_speed(bank_one);
83 83
             u16 speed_two = get_speed(bank_two);
84
-            if(custom_battle_elements.ptr->field_affecting.trick_room || (stall_one && stall_two))
85
-            {
84
+            if (custom_battle_elements.ptr->field_affecting.trick_room || (stall_one && stall_two)) {
86 85
                 u16 swap_speed = speed_one;
87 86
                 speed_one = speed_two;
88 87
                 speed_two = swap_speed;
89 88
             }
90
-            if(speed_one > speed_two)
89
+            if (speed_one > speed_two)
91 90
                 result = ONE;
92
-            else if(speed_two > speed_one)
91
+            else if (speed_two > speed_one)
93 92
                 result = TWO;
94 93
             else if (random() & 1)
95 94
                 result = ONE;

+ 91
- 0
src/battle_engine/battle_test.c Ver fichero

@@ -0,0 +1,91 @@
1
+#include <battle_test.h>
2
+#include <battle.h>
3
+#include <bpre.h>
4
+#include <debug.h>
5
+#include <battle_initiative.h>
6
+
7
+void test_battle() {
8
+    print("Initiating Initiative Unit\nTest...\n");
9
+    u8 pass = true;
10
+    battle_participants[0].spd = 10;
11
+    battle_participants[1].spd = 11;
12
+    printf("bank_one.spd: %d\n", battle_participants[0].spd);
13
+    printf("bank_two.spd: %d\n", battle_participants[1].spd);
14
+    print("testing (await TWO):");
15
+    enum init_enum result = get_first_to_strike(0, 1, 0);
16
+    if (result == TWO)
17
+        print("\xFE\x1 pass\n\xFE\x0");
18
+    else {
19
+        pass = false;
20
+        print("\xFE\x2 fail\n\xFE\x0");
21
+    }
22
+    battle_participants[0].spd = 12;
23
+    printf("bank_one.spd: %d\n", battle_participants[0].spd);
24
+    printf("bank_two.spd: %d\n", battle_participants[1].spd);
25
+    print("testing (await ONE):");
26
+    result = get_first_to_strike(0, 1, 0);
27
+    if (result == ONE)
28
+        print("\xFE\x1 pass\n\xFE\x0");
29
+    else {
30
+        pass = false;
31
+        print("\xFE\x2 fail\n\xFE\x0");
32
+    }
33
+    battle_participants[0].spd = 10;
34
+    battle_participants[1].spd = 11;
35
+    printf("bank_one.spd: %d\n", battle_participants[0].spd);
36
+    printf("bank_two.spd: %d\n", battle_participants[1].spd);
37
+
38
+    //trick room
39
+    custom_battle_elements.ptr->field_affecting.trick_room = 1;
40
+    print("activating trick room...\n");
41
+    print("testing (await ONE):");
42
+    result = get_first_to_strike(0, 1, 0);
43
+    if (result == ONE)
44
+        print("\xFE\x1 pass\n\xFE\x0");
45
+    else {
46
+        pass = false;
47
+        print("\xFE\x2 fail\n\xFE\x0");
48
+    }
49
+
50
+    battle_participants[0].spd = 12;
51
+    printf("bank_one.spd: %d\n", battle_participants[0].spd);
52
+    printf("bank_two.spd: %d\n", battle_participants[1].spd);
53
+    print("testing (await TWO):");
54
+    result = get_first_to_strike(0, 1, 0);
55
+    if (result == TWO)
56
+        print("\xFE\x1 pass\n\xFE\x0");
57
+    else {
58
+        pass = false;
59
+        print("\xFE\x2 fail\n\xFE\x0");
60
+    }
61
+    
62
+    wait_for_btn(1);
63
+    debug_clean();
64
+    
65
+    //stress
66
+    battle_participants[0].spd = 20;
67
+    battle_participants[1].spd = 20;
68
+    printf("bank_one.spd: %d\n", battle_participants[0].spd);
69
+    printf("bank_two.spd: %d\n", battle_participants[1].spd);
70
+    int count_one = 0;
71
+    int count_two = 0;
72
+    for (int i = 0; i < 5000; ++i) {
73
+        result = get_first_to_strike(0, 1, 0);
74
+        if (result == ONE)
75
+            count_one++;
76
+        else
77
+            count_two++;
78
+    }
79
+    printf("tie stress test...\ncount \xFE\x1%d\xFE\x0 / ", count_one);
80
+    printf(" \xFE\x2%d\xFE\x0\n", count_two);
81
+    wait_for_btn(1);
82
+    debug_clean();
83
+    if(pass)
84
+        set_debug_background(0x3E0);
85
+    else
86
+        set_debug_background(0x31);
87
+    print("test complete\n(entering deadlock)");
88
+    while(true)
89
+    {}
90
+    return;
91
+}

+ 2
- 0
src/battle_engine/custom_structs_malloc.c Ver fichero

@@ -2,10 +2,12 @@
2 2
 #include <battle.h>
3 3
 #include "custom_structs.h"
4 4
 #include "custom_structs_malloc.h"
5
+#include <debug.h>
5 6
 
6 7
 void malloc_battle_structs()
7 8
 {
8 9
 	custom_battle_elements.ptr=(struct custom_battle_struct*)malloc(sizeof(struct custom_battle_struct));
10
+        some_test();
9 11
 }
10 12
 
11 13
 void free_battle_structs()

+ 1
- 1
src/battle_engine/entry_hazards.c Ver fichero

@@ -1,4 +1,4 @@
1
-#include "battle_help.h"
1
+#include <battle_help.h>
2 2
 #include <bpre.h>
3 3
 
4 4
 extern void* bs_stealth_rock;

+ 11
- 0
src/battle_engine/scripts/test.S Ver fichero

@@ -0,0 +1,11 @@
1
+#include <battle_script.h>
2
+
3
+.align 2
4
+.thumb
5
+.text
6
+.global bs_test
7
+bs_test:
8
+    callasm some_test+1
9
+    end
10
+
11
+

+ 105
- 17
src/debug/debug.c Ver fichero

@@ -1,8 +1,9 @@
1 1
 #include <bpre.h>
2 2
 #include <debug.h>
3 3
 #include <assets/ascii.h>
4
+#include <battle_test.h>
4 5
 
5
-void set_background(u16 color) {
6
+void set_debug_background(u16 color) {
6 7
     u16* bgc = (u16*) 0x020375f8;
7 8
     *bgc = color;
8 9
     return;
@@ -34,7 +35,7 @@ void debug_scene() {
34 35
     } else if (superstate.multi_purpose_state_tracker == 1) {
35 36
         vram_decompress((void*) asciiTiles, (void*) 0x06000000);
36 37
         memcpy((void*) 0x020375F8, (void*) asciiPal, 0x60);
37
-        set_background(0x0000);
38
+        set_debug_background(0x0000);
38 39
         superstate.multi_purpose_state_tracker++;
39 40
     } else if (superstate.multi_purpose_state_tracker == 2) {
40 41
         init_unit_test();
@@ -43,14 +44,16 @@ void debug_scene() {
43 44
     return;
44 45
 }
45 46
 
46
-void some_test() {
47
+u8 some_test() {
47 48
     set_callback2(debug_scene);
49
+    vblank_handler_set(debug_update);
48 50
     superstate.multi_purpose_state_tracker = 0;
49 51
 
50
-    return;
52
+    return 0;
51 53
 }
52 54
 
53 55
 void reset_scrolling_debug() {
56
+    lcd_io_set_func(0x12, 0x0);
54 57
     lcd_io_set_func(0x14, 0x0);
55 58
     lcd_io_set_func(0x16, 0x0);
56 59
     lcd_io_set_func(0x18, 0x0);
@@ -62,7 +65,7 @@ void reset_scrolling_debug() {
62 65
 }
63 66
 
64 67
 void init_unit_test() {
65
-    print("Hello\nWorld!\xFE\x2\nHello\nWorld!");
68
+    test_battle();
66 69
 }
67 70
 
68 71
 void print_string(u16 line, u16 row, u8 color, char* pBuf) {
@@ -73,28 +76,72 @@ void print_string(u16 line, u16 row, u8 color, char* pBuf) {
73 76
 }
74 77
 
75 78
 void print(char* str) {
76
-    while(*str)
77
-    {
78
-        if(*str== '\n')
79
-        {
79
+    while (*str) {
80
+        if (*str == '\n') {
80 81
             print_memory->line++;
81 82
             print_memory->row = 0;
82
-        }
83
-        else if(*str == '\xFE')
84
-        {
83
+        } else if (*str == '\xFE') {
85 84
             str++;
86 85
             u8 c = *str;
87
-            if(c > 2)
86
+            if (c > 2)
88 87
                 c = 0;
89
-            print_memory->color=c;
88
+            print_memory->color = c;
89
+        } else {
90
+            print_character(print_memory->line, print_memory->row, *str, print_memory->color);
91
+            print_memory->row++;
90 92
         }
91
-        else
92
-        {
93
+        str++;
94
+    }
95
+    return;
96
+}
97
+
98
+void printf(char* str, int arg) {
99
+    while (*str) {
100
+        if (*str == '\n') {
101
+            print_memory->line++;
102
+            print_memory->row = 0;
103
+        } else if (*str == '\xFE') {
104
+            str++;
105
+            u8 c = *str;
106
+            if (c > 2)
107
+                c = 0;
108
+            print_memory->color = c;
109
+        } else if (*str == '%') {
110
+            str++;
111
+            if (*str == '%') {
112
+                print_character(print_memory->line, print_memory->row, *str, print_memory->color);
113
+                print_memory->row++;
114
+            } else if (*str == 'd') {
115
+                u32 len = dec_len(arg);
116
+                char temp[dec_len(len + 1)];
117
+                temp[len] = 0;
118
+                int_to_char(arg, temp);
119
+                print(temp);
120
+            } else if (*str == 'c') {
121
+                char print_char = (char) (arg);
122
+                print_character(print_memory->line, print_memory->row, print_char, print_memory->color);
123
+                print_memory->row++;
124
+            }
125
+        } else {
93 126
             print_character(print_memory->line, print_memory->row, *str, print_memory->color);
94 127
             print_memory->row++;
95 128
         }
96 129
         str++;
97 130
     }
131
+}
132
+
133
+void debug_clean() {
134
+    memset((void*) 0x0600C800, 0, 0x800);
135
+    print_memory->row = 0;
136
+    print_memory->line = 0;
137
+    print_memory->color = 0;
138
+    return;
139
+}
140
+
141
+void wait_for_btn(u16 field) {
142
+    volatile u16* control_io = (volatile u16*) (0x04000130);
143
+    while (*control_io & field) {
144
+    }
98 145
     return;
99 146
 }
100 147
 
@@ -105,7 +152,7 @@ void print_character(u16 line, u16 row, char character, u8 color) {
105 152
     union t_map_entry map_entry;
106 153
     map_entry.entry.tile = char_to_byte(character);
107 154
     map_entry.entry.pal = color;
108
-    u16* ptr = (u16*) (0x0600C800 + (position * 2));
155
+    u16* ptr = (u16*) (0x0600c800 + (position * 2));
109 156
     *ptr = map_entry.short_map;
110 157
     return;
111 158
 }
@@ -115,4 +162,45 @@ u8 char_to_byte(char character) {
115 162
         return character - 0x20;
116 163
     else
117 164
         return 3;
165
+}
166
+
167
+void debug_update() {
168
+    fade_update();
169
+    task_exec();
170
+    objc_exec();
171
+    obj_sync();
172
+    gpu_pal_upload();
173
+    gpu_sprites_upload();
174
+}
175
+
176
+void int_to_char(u32 i, char* ref) {
177
+    if (i == 0) {
178
+        ref[0] = '0';
179
+        return;
180
+    }
181
+    u32 len = dec_len(i);
182
+    while (i > 0) {
183
+
184
+        ref[len - 1] = '0' + (__aeabi_uidivmod(i, 10));
185
+        i /= 10;
186
+        len--;
187
+    }
188
+
189
+    return;
190
+}
191
+
192
+u32 power(u32 n, u32 power) {
193
+    u32 out = 1;
194
+    for (int i = 0; i < power; ++i) {
195
+        out = out * n;
196
+    }
197
+    return out;
198
+}
199
+
200
+u32 dec_len(u32 i) {
201
+    u32 len = 1;
202
+    while ((i /= 10) > 0) {
203
+        len++;
204
+    }
205
+    return len;
118 206
 }

src/battle_engine/battle_help.h → src/include/battle_help.h Ver fichero


src/battle_engine/battle_initiative.h → src/include/battle_initiative.h Ver fichero

@@ -1,9 +1,7 @@
1 1
 #ifndef BATTLE_INITIATIVE_H
2 2
 #define BATTLE_INITIATIVE_H
3 3
 
4
-#include <battle.h>
5
-#include "battle_help.h"
6
-#include <bpre.h>
4
+#include <types.h>
7 5
 
8 6
 enum init_enum {ONE, TWO, TIE};
9 7
 

+ 7
- 0
src/include/battle_test.h Ver fichero

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

+ 3
- 1
src/include/bpre.h Ver fichero

@@ -8,13 +8,15 @@
8 8
 #include <callback.h>
9 9
 #include <config.h>
10 10
 
11
+u32 __aeabi_uidivmod(u32 a, u32 b);
11 12
 u16 *var_access(int index);
12 13
 u8 flag_check(int flag);
13 14
 void clear_flag(u16 flag);
14 15
 u16 random();
15 16
 void* malloc(int size);
16 17
 void free(void* address);
17
-void* memcpy (void * destination, const void* source, u32 num);
18
+void* memcpy (void * destination, const void* source, size_t num);
19
+void* memset (void* dst, int value, size_t size);
18 20
 
19 21
 //debug
20 22
 void agbprintf(const char* pBuf, ...);

+ 10
- 1
src/include/debug.h Ver fichero

@@ -9,13 +9,22 @@ struct print_engine{
9 9
 
10 10
 static struct print_engine* print_memory = (struct print_engine*)(0x0203FFF0);
11 11
 
12
-void some_test();
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();
13 19
 void reset_scrolling_debug();
14 20
 void init_unit_test();
15 21
 void debug_scene();
16 22
 u8 char_to_byte(char character);
17 23
 void print_character(u16 line, u16 row, char character, u8 color);
18 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);
19 28
 
20 29
 #endif /* DEBUG_H */
21 30
 

+ 2
- 0
src/include/types.h Ver fichero

@@ -14,6 +14,8 @@ typedef     signed long long int    s64;
14 14
 typedef     float                   f32;
15 15
 typedef     double                  f64;
16 16
 
17
+typedef     unsigned int            size_t;
18
+
17 19
 #define true 1
18 20
 #define false 0
19 21