Browse Source

fix some warnings, finish documentation (for now)

SBird1337 7 years ago
parent
commit
84344b9ade
71 changed files with 2199 additions and 27926 deletions
  1. 323
    27411
      nbproject/configurations.xml
  2. 1
    0
      nbproject/private/CodeAssistancePathMapper.properties
  3. 0
    0
      nbproject/private/Default.properties
  4. 75
    0
      nbproject/private/c_standard_headers_indexer.c
  5. 7
    21
      nbproject/private/configurations.xml
  6. 135
    0
      nbproject/private/cpp_standard_headers_indexer.cpp
  7. 37
    77
      nbproject/private/private.xml
  8. BIN
      nbproject/private/tools/localhost/Cygwin/g++.exe
  9. BIN
      nbproject/private/tools/localhost/Cygwin/gcc.exe
  10. 5
    5
      patches/dns/core.asm
  11. 1
    1
      patches/special.asm
  12. 37
    7
      src/battle_engine/battle_abilities.c
  13. 41
    1
      src/battle_engine/battle_end_of_turn.c
  14. 55
    13
      src/battle_engine/battle_help.c
  15. 53
    9
      src/battle_engine/battle_initiative.c
  16. 34
    3
      src/battle_engine/battle_test.c
  17. 61
    10
      src/battle_engine/custom_structs_malloc.c
  18. 0
    8
      src/battle_engine/custom_structs_malloc.h
  19. 55
    4
      src/battle_engine/entry_hazards.c
  20. 100
    58
      src/debug/debug.c
  21. 217
    61
      src/dns/dns_core.c
  22. 45
    0
      src/encode/crc32.c
  23. 29
    0
      src/include/attack_names.h
  24. 0
    34
      src/include/battle.h
  25. 54
    4
      src/include/battle_abilities.h
  26. 17
    0
      src/include/battle_common.h
  27. 0
    0
      src/include/battle_custom_structs.h
  28. 12
    0
      src/include/battle_fractions.h
  29. 95
    8
      src/include/battle_help.h
  30. 46
    0
      src/include/battle_initiative.h
  31. 32
    0
      src/include/battle_locations.h
  32. 30
    1
      src/include/battle_script.h
  33. 76
    1
      src/include/debug.h
  34. 9
    13
      src/include/dns_core.h
  35. 8
    0
      src/include/game_engine.h
  36. 5
    9
      src/include/lcd.h
  37. 2
    2
      src/include/memory.h
  38. 0
    0
      src/include/pkmn_abilities.h
  39. 0
    0
      src/include/pkmn_item_effects.h
  40. 0
    0
      src/include/pkmn_items.h
  41. 2
    2
      src/interface/lcd_io_test.S
  42. 156
    102
      src/interface/textbox_mugshots.c
  43. 1
    1
      src/interface/trans_mug_close_fix.S
  44. 7
    1
      src/moves/ability_changers/ability_change.c
  45. 3
    2
      src/moves/assurance/assurance.c
  46. 2
    2
      src/moves/bride/bride.c
  47. 3
    1
      src/moves/close_combat/close_combat.c
  48. 2
    1
      src/moves/crush_grip_like/hp_damage_mod.c
  49. 4
    1
      src/moves/defog/defog.c
  50. 5
    2
      src/moves/feint/feint.c
  51. 3
    1
      src/moves/gastro_acid/gastro_acid.c
  52. 5
    2
      src/moves/healing_wish/healing_wish.c
  53. 4
    1
      src/moves/lucky_chant/lucky_chant.c
  54. 4
    1
      src/moves/magnet_rise/magnet_rise.c
  55. 2
    1
      src/moves/metal_burst/metal_burst.c
  56. 1
    1
      src/moves/pay_back/pay_back.c
  57. 3
    2
      src/moves/power_trick/power_trick.c
  58. 2
    1
      src/moves/punishment/punishment.c
  59. 5
    1
      src/moves/rooms/rooms.c
  60. 2
    1
      src/moves/roost/roost.c
  61. 3
    1
      src/moves/split_moves/split_moves.c
  62. 4
    1
      src/moves/swap_moves/swap_moves.c
  63. 4
    1
      src/moves/tailwind/tailwind.c
  64. 2
    1
      src/moves/veno_shock/venoshock_has_multiplier.c
  65. 40
    0
      src/music/music_override.c
  66. 50
    7
      src/overworld/overworld.c
  67. 59
    7
      src/specials/camera_move.c
  68. 43
    3
      src/specials/camera_move.h
  69. 70
    15
      src/specials/custom_specials.c
  70. 10
    1
      src/specials/cutscene_meteor.c
  71. 1
    1
      string/de/item_data.txt

+ 323
- 27411
nbproject/configurations.xml
File diff suppressed because it is too large
View File


+ 1
- 0
nbproject/private/CodeAssistancePathMapper.properties View File

@@ -0,0 +1 @@
1
+# Automatic path mapper. CRC = 1

+ 0
- 0
nbproject/private/Default.properties View File


+ 75
- 0
nbproject/private/c_standard_headers_indexer.c View File

@@ -0,0 +1,75 @@
1
+/*
2
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
+ *
4
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
5
+ *
6
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
+ * Other names may be trademarks of their respective owners.
8
+ *
9
+ * The contents of this file are subject to the terms of either the GNU
10
+ * General Public License Version 2 only ("GPL") or the Common
11
+ * Development and Distribution License("CDDL") (collectively, the
12
+ * "License"). You may not use this file except in compliance with the
13
+ * License. You can obtain a copy of the License at
14
+ * http://www.netbeans.org/cddl-gplv2.html
15
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
+ * specific language governing permissions and limitations under the
17
+ * License.  When distributing the software, include this License Header
18
+ * Notice in each file and include the License file at
19
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
+ * particular file as subject to the "Classpath" exception as provided
21
+ * by Oracle in the GPL Version 2 section of the License file that
22
+ * accompanied this code. If applicable, add the following below the
23
+ * License Header, with the fields enclosed by brackets [] replaced by
24
+ * your own identifying information:
25
+ * "Portions Copyrighted [year] [name of copyright owner]"
26
+ *
27
+ * If you wish your version of this file to be governed by only the CDDL
28
+ * or only the GPL Version 2, indicate your decision by adding
29
+ * "[Contributor] elects to include this software in this distribution
30
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
+ * single choice of license, a recipient has the option to distribute
32
+ * your version of this file under either the CDDL, the GPL Version 2 or
33
+ * to extend the choice of license to its licensees as provided above.
34
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
35
+ * Version 2 license, then the option applies only if the new code is
36
+ * made subject to such option by the copyright holder.
37
+ *
38
+ * Contributor(s):
39
+ */
40
+
41
+// List of standard headers was taken in http://en.cppreference.com/w/c/header
42
+
43
+#include <assert.h> 	 // Conditionally compiled macro that compares its argument to zero
44
+#include <ctype.h> 	 // Functions to determine the type contained in character data
45
+#include <errno.h> 	 // Macros reporting error conditions
46
+#include <float.h> 	 // Limits of float types
47
+#include <limits.h> 	 // Sizes of basic types
48
+#include <locale.h> 	 // Localization utilities
49
+#include <math.h> 	 // Common mathematics functions
50
+#include <setjmp.h> 	 // Nonlocal jumps
51
+#include <signal.h> 	 // Signal handling
52
+#include <stdarg.h> 	 // Variable arguments
53
+#include <stddef.h> 	 // Common macro definitions
54
+#include <stdio.h> 	 // Input/output
55
+#include <string.h> 	 // String handling
56
+#include <stdlib.h> 	 // General utilities: memory management, program utilities, string conversions, random numbers
57
+#include <time.h> 	 // Time/date utilities
58
+#include <iso646.h>      // (since C95) Alternative operator spellings
59
+#include <wchar.h>       // (since C95) Extended multibyte and wide character utilities
60
+#include <wctype.h>      // (since C95) Wide character classification and mapping utilities
61
+#ifdef _STDC_C99
62
+#include <complex.h>     // (since C99) Complex number arithmetic
63
+#include <fenv.h>        // (since C99) Floating-point environment
64
+#include <inttypes.h>    // (since C99) Format conversion of integer types
65
+#include <stdbool.h>     // (since C99) Boolean type
66
+#include <stdint.h>      // (since C99) Fixed-width integer types
67
+#include <tgmath.h>      // (since C99) Type-generic math (macros wrapping math.h and complex.h)
68
+#endif
69
+#ifdef _STDC_C11
70
+#include <stdalign.h>    // (since C11) alignas and alignof convenience macros
71
+#include <stdatomic.h>   // (since C11) Atomic types
72
+#include <stdnoreturn.h> // (since C11) noreturn convenience macros
73
+#include <threads.h>     // (since C11) Thread library
74
+#include <uchar.h>       // (since C11) UTF-16 and UTF-32 character utilities
75
+#endif

+ 7
- 21
nbproject/private/configurations.xml View File

@@ -4256,16 +4256,6 @@
4256 4256
         </df>
4257 4257
       </df>
4258 4258
       <df name="object">
4259
-        <df name="data">
4260
-          <df name="item">
4261
-          </df>
4262
-          <df name="moves">
4263
-          </df>
4264
-          <df name="overworld">
4265
-          </df>
4266
-          <df name="pkmn_tables">
4267
-          </df>
4268
-        </df>
4269 4259
         <df name="src">
4270 4260
           <df name="assets">
4271 4261
             <df name="meteor">
@@ -4363,7 +4353,7 @@
4363 4353
           </df>
4364 4354
         </df>
4365 4355
         <df name="string">
4366
-          <df name="de">
4356
+          <df name="DE">
4367 4357
           </df>
4368 4358
         </df>
4369 4359
       </df>
@@ -5700,7 +5690,6 @@
5700 5690
               <in>snd_127_soft_snare.s</in>
5701 5691
               <in>snd_127_sticks.s</in>
5702 5692
               <in>snd_127_tambourine.s</in>
5703
-              <in>snd_127_tom.s</in>
5704 5693
               <in>snd_127_tom_45.s</in>
5705 5694
               <in>snd_127_tom_48.s</in>
5706 5695
               <in>snd_127_triangle.s</in>
@@ -6025,7 +6014,6 @@
6025 6014
           <in>battle_switch_in_hook.S</in>
6026 6015
           <in>battle_test.c</in>
6027 6016
           <in>custom_structs_malloc.c</in>
6028
-          <in>custom_structs_malloc.h</in>
6029 6017
           <in>custom_structs_malloc_hook.S</in>
6030 6018
           <in>entry_hazards.c</in>
6031 6019
           <in>entry_hazards_hook.S</in>
@@ -6044,10 +6032,11 @@
6044 6032
             <in>ascii.c</in>
6045 6033
             <in>ascii.h</in>
6046 6034
           </df>
6047
-          <in>abilities.h</in>
6048 6035
           <in>attack_names.h</in>
6049
-          <in>battle.h</in>
6050 6036
           <in>battle_abilities.h</in>
6037
+          <in>battle_common.h</in>
6038
+          <in>battle_custom_structs.h</in>
6039
+          <in>battle_fractions.h</in>
6051 6040
           <in>battle_help.h</in>
6052 6041
           <in>battle_initiative.h</in>
6053 6042
           <in>battle_locations.h</in>
@@ -6057,20 +6046,20 @@
6057 6046
           <in>bpre.h</in>
6058 6047
           <in>callback.h</in>
6059 6048
           <in>config.h</in>
6060
-          <in>custom_structs.h</in>
6061 6049
           <in>debug.h</in>
6062 6050
           <in>dns_core.h</in>
6063 6051
           <in>fade.h</in>
6064 6052
           <in>game_engine.h</in>
6065
-          <in>item_effects.h</in>
6066
-          <in>items.h</in>
6067 6053
           <in>lcd.h</in>
6068 6054
           <in>math.h</in>
6069 6055
           <in>memory.h</in>
6070 6056
           <in>moves.h</in>
6071 6057
           <in>objects.h</in>
6072 6058
           <in>oe_animation.h</in>
6059
+          <in>pkmn_abilities.h</in>
6073 6060
           <in>pkmn_attributes.h</in>
6061
+          <in>pkmn_item_effects.h</in>
6062
+          <in>pkmn_items.h</in>
6074 6063
           <in>pkmn_types.h</in>
6075 6064
           <in>pokemon.h</in>
6076 6065
           <in>sound.h</in>
@@ -6234,11 +6223,8 @@
6234 6223
       </df>
6235 6224
       <df name="string">
6236 6225
         <df name="de">
6237
-          <in>move_descriptions.txt</in>
6238
-          <in>move_names.txt</in>
6239 6226
         </df>
6240 6227
         <df name="en">
6241
-          <in>move_strings.txt</in>
6242 6228
         </df>
6243 6229
       </df>
6244 6230
       <df name="todo">

+ 135
- 0
nbproject/private/cpp_standard_headers_indexer.cpp View File

@@ -0,0 +1,135 @@
1
+/*
2
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
+ *
4
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
5
+ *
6
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
+ * Other names may be trademarks of their respective owners.
8
+ *
9
+ * The contents of this file are subject to the terms of either the GNU
10
+ * General Public License Version 2 only ("GPL") or the Common
11
+ * Development and Distribution License("CDDL") (collectively, the
12
+ * "License"). You may not use this file except in compliance with the
13
+ * License. You can obtain a copy of the License at
14
+ * http://www.netbeans.org/cddl-gplv2.html
15
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
+ * specific language governing permissions and limitations under the
17
+ * License.  When distributing the software, include this License Header
18
+ * Notice in each file and include the License file at
19
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
+ * particular file as subject to the "Classpath" exception as provided
21
+ * by Oracle in the GPL Version 2 section of the License file that
22
+ * accompanied this code. If applicable, add the following below the
23
+ * License Header, with the fields enclosed by brackets [] replaced by
24
+ * your own identifying information:
25
+ * "Portions Copyrighted [year] [name of copyright owner]"
26
+ *
27
+ * If you wish your version of this file to be governed by only the CDDL
28
+ * or only the GPL Version 2, indicate your decision by adding
29
+ * "[Contributor] elects to include this software in this distribution
30
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
+ * single choice of license, a recipient has the option to distribute
32
+ * your version of this file under either the CDDL, the GPL Version 2 or
33
+ * to extend the choice of license to its licensees as provided above.
34
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
35
+ * Version 2 license, then the option applies only if the new code is
36
+ * made subject to such option by the copyright holder.
37
+ *
38
+ * Contributor(s):
39
+ */
40
+
41
+// List of standard headers was taken in http://en.cppreference.com/w/cpp/header
42
+
43
+#include <cstdlib> 	    // General purpose utilities: program control, dynamic memory allocation, random numbers, sort and search
44
+#include <csignal> 	    // Functions and macro constants for signal management
45
+#include <csetjmp> 	    // Macro (and function) that saves (and jumps) to an execution context
46
+#include <cstdarg> 	    // Handling of variable length argument lists
47
+#include <typeinfo> 	    // Runtime type information utilities
48
+#include <bitset> 	    // std::bitset class template
49
+#include <functional> 	    // Function objects, designed for use with the standard algorithms
50
+#include <utility> 	    // Various utility components
51
+#include <ctime> 	    // C-style time/date utilites
52
+#include <cstddef> 	    // typedefs for types such as size_t, NULL and others
53
+#include <new> 	            // Low-level memory management utilities
54
+#include <memory> 	    // Higher level memory management utilities
55
+#include <climits>          // limits of integral types
56
+#include <cfloat> 	    // limits of float types
57
+#include <limits> 	    // standardized way to query properties of arithmetic types
58
+#include <exception> 	    // Exception handling utilities
59
+#include <stdexcept> 	    // Standard exception objects
60
+#include <cassert> 	    // Conditionally compiled macro that compares its argument to zero
61
+#include <cerrno>           // Macro containing the last error number
62
+#include <cctype>           // functions to determine the type contained in character data
63
+#include <cwctype>          // functions for determining the type of wide character data
64
+#include <cstring> 	    // various narrow character string handling functions
65
+#include <cwchar> 	    // various wide and multibyte string handling functions
66
+#include <string> 	    // std::basic_string class template
67
+#include <vector> 	    // std::vector container
68
+#include <deque> 	    // std::deque container
69
+#include <list> 	    // std::list container
70
+#include <set> 	            // std::set and std::multiset associative containers
71
+#include <map> 	            // std::map and std::multimap associative containers
72
+#include <stack> 	    // std::stack container adaptor
73
+#include <queue> 	    // std::queue and std::priority_queue container adaptors
74
+#include <algorithm> 	    // Algorithms that operate on containers
75
+#include <iterator> 	    // Container iterators
76
+#include <cmath>            // Common mathematics functions
77
+#include <complex>          // Complex number type
78
+#include <valarray>         // Class for representing and manipulating arrays of values
79
+#include <numeric>          // Numeric operations on values in containers
80
+#include <iosfwd>           // forward declarations of all classes in the input/output library
81
+#include <ios>              // std::ios_base class, std::basic_ios class template and several typedefs
82
+#include <istream>          // std::basic_istream class template and several typedefs
83
+#include <ostream>          // std::basic_ostream, std::basic_iostream class templates and several typedefs
84
+#include <iostream>         // several standard stream objects
85
+#include <fstream>          // std::basic_fstream, std::basic_ifstream, std::basic_ofstream class templates and several typedefs
86
+#include <sstream>          // std::basic_stringstream, std::basic_istringstream, std::basic_ostringstream class templates and several typedefs
87
+#include <strstream>        // std::strstream, std::istrstream, std::ostrstream(deprecated)
88
+#include <iomanip>          // Helper functions to control the format or input and output
89
+#include <streambuf>        // std::basic_streambuf class template
90
+#include <cstdio>           // C-style input-output functions
91
+#include <locale>           // Localization utilities
92
+#include <clocale>          // C localization utilities
93
+#include <ciso646>          // empty header. The macros that appear in iso646.h in C are keywords in C++
94
+#if __cplusplus >= 201103L
95
+#include <typeindex>        // (since C++11) 	std::type_index
96
+#include <type_traits>      // (since C++11) 	Compile-time type information
97
+#include <chrono>           // (since C++11) 	C++ time utilites
98
+#include <initializer_list> // (since C++11) 	std::initializer_list class template
99
+#include <tuple>            // (since C++11) 	std::tuple class template
100
+#include <scoped_allocator> // (since C++11) 	Nested allocator class
101
+#include <cstdint>          // (since C++11) 	fixed-size types and limits of other types
102
+#include <cinttypes>        // (since C++11) 	formatting macros , intmax_t and uintmax_t math and conversions
103
+#include <system_error>     // (since C++11) 	defines std::error_code, a platform-dependent error code
104
+#include <cuchar>           // (since C++11) 	C-style Unicode character conversion functions
105
+#include <array>            // (since C++11) 	std::array container
106
+#include <forward_list>     // (since C++11) 	std::forward_list container
107
+#include <unordered_set>    // (since C++11) 	std::unordered_set and std::unordered_multiset unordered associative containers
108
+#include <unordered_map>    // (since C++11) 	std::unordered_map and std::unordered_multimap unordered associative containers
109
+#include <random>           // (since C++11) 	Random number generators and distributions
110
+#include <ratio>            // (since C++11) 	Compile-time rational arithmetic
111
+#include <cfenv>            // (since C++11) 	Floating-point environment access functions
112
+#include <codecvt>          // (since C++11) 	Unicode conversion facilities
113
+#include <regex>            // (since C++11) 	Classes, algorithms and iterators to support regular expression processing
114
+#include <atomic>           // (since C++11) 	Atomic operations library
115
+#include <ccomplex>         // (since C++11)(deprecated in C++17) 	simply includes the header <complex>
116
+#include <ctgmath>          // (since C++11)(deprecated in C++17) 	simply includes the headers <ccomplex> (until C++17)<complex> (since C++17) and <cmath>: the overloads equivalent to the contents of the C header tgmath.h are already provided by those headers
117
+#include <cstdalign>        // (since C++11)(deprecated in C++17) 	defines one compatibility macro constant
118
+#include <cstdbool>         // (since C++11)(deprecated in C++17) 	defines one compatibility macro constant
119
+#include <thread>           // (since C++11) 	std::thread class and supporting functions
120
+#include <mutex>            // (since C++11) 	mutual exclusion primitives
121
+#include <future>           // (since C++11) 	primitives for asynchronous computations
122
+#include <condition_variable> // (since C++11) 	thread waiting conditions
123
+#endif
124
+#if __cplusplus >= 201300L
125
+#include <shared_mutex>     // (since C++14) 	shared mutual exclusion primitives
126
+#endif
127
+#if __cplusplus >= 201500L
128
+#include <any>              // (since C++17) 	std::any class template
129
+#include <optional>         // (since C++17) 	std::optional class template
130
+#include <variant>          // (since C++17) 	std::variant class template
131
+#include <memory_resource>  // (since C++17) 	Polymorphic allocators and memory resources
132
+#include <string_view>      // (since C++17) 	std::basic_string_view class template
133
+#include <execution>        // (since C++17) 	Predefined execution policies for parallel versions of the algorithms
134
+#include <filesystem>       // (since C++17) 	std::path class and supporting functions
135
+#endif

+ 37
- 77
nbproject/private/private.xml View File

@@ -19,83 +19,43 @@
19 19
     </editor-bookmarks>
20 20
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
21 21
         <group>
22
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/bpre.h</file>
23
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/string/table.tbl</file>
24
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/battle_engine/battle_end_of_turn_hook.S</file>
25
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/main.asm</file>
26
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/metal_burst/metal_burst_script.S</file>
27
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/config.h</file>
28
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/roost/roost_scripts.S</file>
29
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/moves.h</file>
30
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/overworld/trainer_run.S</file>
31
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/move_table.asm</file>
32
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/battle_engine/custom_structs_malloc.c</file>
33
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/disable_cry_table_blocks.s</file>
34
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/battle_engine/custom_structs_malloc.h</file>
35
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/battle_locations.h</file>
36
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/bride/bride.c</file>
37
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/item_effects.h</file>
38
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/battle_engine/entry_hazards.c</file>
39
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/music.asm</file>
40
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/battle_engine/battle_end_of_turn.c</file>
41
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/specials/custom_specials.c</file>
42
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/sprites.makefile</file>
43
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/overworlds/overworld.asm</file>
44
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/data/moves/effect_table.S</file>
45
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/makefile</file>
46
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/overworld/overworld.c</file>
47
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/string/de/item_data.txt</file>
48
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/dynamic_overworld_hooks.asm</file>
49
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/battle.h</file>
50
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/moves.asm</file>
51
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/data/pkmn_tables/pokemon_moveset_table.S</file>
52
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/types.h</file>
53
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/overworld/overworld_hooks.S</file>
54
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/battle_engine/battle_engine.asm</file>
55
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/feint/feint.c</file>
56
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/icons.makefile</file>
57
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/items/item_limits.asm</file>
58
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/items/tm_fixes.asm</file>
59
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/string/de/item_descriptions.txt</file>
60
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/hooks.asm</file>
61
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/battle_engine/battle_switch_in_hook.S</file>
62
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/data/item/tm_hm_move_table.S</file>
63
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/items/item_routines.asm</file>
64
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/dns/dns_core.c</file>
65
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/data/moves/animation_table.S</file>
66
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/uturn/u_turn_script.S</file>
67
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/data/item/item_scripts.S</file>
68
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/gfx_build/overworlds/.gitignore</file>
69
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/linker.ld</file>
70
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/tailwind/tailwind_scripts.S</file>
71
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/tailwind/tailwind.c</file>
72
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/overworlds/trainer.asm</file>
73
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/battle_engine/bs_table.S</file>
74
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/battle_structs.h</file>
75
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/battle_engine/battle_initiative.c</file>
76
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/special.asm</file>
77
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/custom_structs.h</file>
78
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/metal_burst/metal_burst.c</file>
79
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/string/de/hazards.txt</file>
80
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/battle_engine/custom_structs_malloc_hook.S</file>
81
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/battle_engine/battle_test.c</file>
82
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/assets.makefile</file>
83
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/bride/bride_scripts.S</file>
84
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/feint/feint_scripts.S</file>
85
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/items/item_tables.asm</file>
86
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/gfx_build/sprites/back_sprites/.gitignore</file>
87
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/split_physical_special.asm</file>
88
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/battle_engine/malloc.asm</file>
89
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/bpre.sym</file>
90
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/roost/roost.c</file>
91
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/hazards/hazards_scripts.S</file>
92
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/battle_script.h</file>
93
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/battle_engine/entry_hazards_hook.S</file>
94
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/data/moves/move_data.S</file>
95
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/interface/textbox_mugshots.c</file>
96
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/string/de/move_strings.txt</file>
97
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/battle_abilities.h</file>
98
-            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/items/items.asm</file>
22
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/battle_engine/battle_help.c</file>
23
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/moves.h</file>
24
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/battle_engine/custom_structs_malloc.c</file>
25
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/specials/cutscene_meteor.c</file>
26
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/battle.h</file>
27
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/makefile</file>
28
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/battle_script.h</file>
29
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/memory.h</file>
30
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/overworld/overworld.c</file>
31
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/battle_locations.h</file>
32
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/attack_names.h</file>
33
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/battle_abilities.h</file>
34
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/pkmn_abilities.h</file>
35
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/game_engine.h</file>
36
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/battle_engine/battle_initiative.c</file>
37
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/interface/textbox_mugshots.c</file>
38
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/patches/hooks.asm</file>
39
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/battle_engine/battle_abilities.c</file>
40
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/types.h</file>
41
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/battle_test.h</file>
42
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/battle_initiative.h</file>
43
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/pkmn_item_effects.h</file>
44
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/moves/ability_changers/ability_change.c</file>
45
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/specials/custom_specials.c</file>
46
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/pkmn_attributes.h</file>
47
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/lcd.h</file>
48
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/math.h</file>
49
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/moves/feint/feint.c</file>
50
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/battle_help.h</file>
51
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/battle_engine/battle_test.c</file>
52
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/specials/camera_move.c</file>
53
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/debug.h</file>
54
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/string/de/item_data.txt</file>
55
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/include/battle_structs.h</file>
56
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/debug/debug.c</file>
57
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/battle_engine/entry_hazards.c</file>
58
+            <file>file:/C:/cygwin64/home/Philipp/sots/engine/source_of_the_sovereign/src/moves/assurance/assurance.c</file>
99 59
         </group>
100 60
     </open-files>
101 61
 </project-private>

BIN
nbproject/private/tools/localhost/Cygwin/g++.exe View File


BIN
nbproject/private/tools/localhost/Cygwin/gcc.exe View File


+ 5
- 5
patches/dns/core.asm View File

@@ -1,24 +1,24 @@
1 1
 .org 0x08059A90
2
-    ldr r3, =mapdata_load_palette_one+1
2
+    ldr r3, =dns_mapdata_load_palette_one+1
3 3
     bx r3
4 4
     .pool
5 5
 
6 6
 .org 0x08059AA0
7
-    ldr r3, =mapdata_load_palette_two+1
7
+    ldr r3, =dns_mapdata_load_palette_two+1
8 8
     bx r3
9 9
     .pool
10 10
 
11 11
 .org 0x0805F538
12
-    ldr r2, =pal_patch_for_npc+1
12
+    ldr r2, =dns_pal_patch_for_npc+1
13 13
     bx r2
14 14
     .pool
15 15
 
16 16
 .org 0x08083614
17
-    ldr r1, =overworld_anim_load_pal+1
17
+    ldr r1, =dns_overworld_anim_load_pal+1
18 18
     bx r1
19 19
     .pool
20 20
 
21 21
 .org 0x08056578
22
-    ldr r0, =overworld_loop+1
22
+    ldr r0, =dns_cb_overworld_hacked+1
23 23
     bx r0
24 24
     .pool

+ 1
- 1
patches/special.asm View File

@@ -1,2 +1,2 @@
1 1
 .org 0x0815FD60 + (4 * 0x68) //special 0x68
2
-.word special_asm|1
2
+.word sp_special_casm|1

+ 37
- 7
src/battle_engine/battle_abilities.c View File

@@ -1,9 +1,39 @@
1
-#include <battle_abilities.h>
2
-#include <custom_structs.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 battle_abilities.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Some methods concerning in-battle abilities
28
+ */
3 29
 
4
-#include "battle_structs.h"
30
+/* === INCLUDE === */
31
+#include <battle_abilities.h>
32
+#include <battle_custom_structs.h>
33
+#include <battle_structs.h>
5 34
 
6
-u8 has_ability_effect(u8 bank, u8 mold_breaker, u8 gastro)
35
+/* === IMPLEMENTATIONS === */
36
+u8 ability_has_effect(u8 bank, u8 mold_breaker, u8 gastro)
7 37
 {
8 38
     if(gastro && custom_battle_elements.ptr->bank_affecting[bank].gastro_acided)
9 39
         return false;
@@ -11,12 +41,12 @@ u8 has_ability_effect(u8 bank, u8 mold_breaker, u8 gastro)
11 41
     //TODO: MOLD BREAKER
12 42
 }
13 43
 
14
-u8 weather_abilities_effect()
44
+u8 ability_weather_effects()
15 45
 {
16 46
     //TODO: AIR LOCK AND CLOUD NINE
17 47
     return true;
18 48
 }
19
-u8 has_ability(u8 bank, u8 ability)
49
+u8 ability_has_ability(u8 bank, u8 ability)
20 50
 {
21
-    return (has_ability_effect(bank,0,1) && battle_participants[bank].ability_id == ability);
51
+    return (ability_has_effect(bank,0,1) && battle_participants[bank].ability_id == ability);
22 52
 }

+ 41
- 1
src/battle_engine/battle_end_of_turn.c View File

@@ -1,5 +1,45 @@
1
-#include <battle.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
+ ****************************************************************************/
2 22
 
23
+/**
24
+ * @file battle_end_of_turn.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Handle end of turn effects
28
+ */
29
+
30
+/* === INCLUDE === */
31
+
32
+#include <battle_structs.h>
33
+#include <pkmn_types.h>
34
+
35
+/* === PROTOTYPES === */
36
+
37
+/**
38
+ * @brief handle the end of turn stuff
39
+ */
40
+void battle_end_of_turn();
41
+
42
+/* === IMPLEMENTATIONS === */
3 43
 void battle_end_of_turn() {
4 44
     for (int i = 0; i < 4; ++i) {
5 45
         if (battle_participants[i].type1 == TYPE_EGG)

+ 55
- 13
src/battle_engine/battle_help.c View File

@@ -1,7 +1,48 @@
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 battle_help.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Some general helper methods for battle
28
+ */
29
+
30
+/* === INCLUDE === */
31
+
1 32
 #include <battle_help.h>
33
+#include <battle_locations.h>
34
+#include <battle_custom_structs.h>
35
+#include <game_engine.h>
36
+#include <pkmn_types.h>
37
+#include <pkmn_abilities.h>
38
+#include <pkmn_item_effects.h>
39
+#include <pkmn_items.h>
40
+#include <pkmn_attributes.h>
41
+#include <battle_common.h>
2 42
 
3
-//from kds emerald battle engine upgrade
43
+/* === STATICS === */
4 44
 
45
+/* from kds emerald battle engine upgrade */
5 46
 u8 type_effectiveness_table[TYPE_FAIRY - 0x4][TYPE_FAIRY - 0x4] = {
6 47
     {10, 10, 10, 10, 10, 05, 10, 00, 05, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, //normal
7 48
     {20, 10, 05, 05, 10, 20, 05, 00, 20, 10, 10, 10, 10, 10, 05, 20, 10, 20, 05}, //fight
@@ -24,7 +65,8 @@ u8 type_effectiveness_table[TYPE_FAIRY - 0x4][TYPE_FAIRY - 0x4] = {
24 65
     {10, 20, 10, 05, 10, 10, 10, 10, 05, 10, 05, 10, 10, 10, 10, 10, 20, 20, 10} //fairy
25 66
 };
26 67
 
27
-u16 damage_type_effectiveness_update(u8 attacking_type, u8 defending_type, u8 atk_bank, u8 def_bank, u16 chained_effect, u8 airstatus) {
68
+/* === IMPLEMENTATIONS === */
69
+u16 battle_damage_type_effectiveness_update(u8 attacking_type, u8 defending_type, u8 atk_bank, u8 def_bank, u16 chained_effect, u8 airstatus) {
28 70
     u8 effect, atype = attacking_type, dtype = defending_type;
29 71
     if (!chained_effect || atype == TYPE_EGG || dtype == TYPE_EGG)
30 72
         return chained_effect;
@@ -64,32 +106,32 @@ u16 damage_type_effectiveness_update(u8 attacking_type, u8 defending_type, u8 at
64 106
 
65 107
 }
66 108
 
67
-u16 apply_type_effectiveness(u16 chained_effect, u8 move_type, u8 target_bank, u8 atk_bank, u8 airstatus) {
109
+u16 battle_apply_type_effectiveness(u16 chained_effect, u8 move_type, u8 target_bank, u8 atk_bank, u8 airstatus) {
68 110
     u8 defender_type1 = battle_participants[target_bank].type1;
69 111
     u8 defender_type2 = battle_participants[target_bank].type2;
70 112
     //set different types
71 113
     if (defender_type2 == defender_type1)
72 114
         defender_type2 = TYPE_EGG;
73
-    chained_effect = damage_type_effectiveness_update(move_type, defender_type1, atk_bank, target_bank, chained_effect, airstatus);
74
-    chained_effect = damage_type_effectiveness_update(move_type, defender_type2, atk_bank, target_bank, chained_effect, airstatus);
115
+    chained_effect = battle_damage_type_effectiveness_update(move_type, defender_type1, atk_bank, target_bank, chained_effect, airstatus);
116
+    chained_effect = battle_damage_type_effectiveness_update(move_type, defender_type2, atk_bank, target_bank, chained_effect, airstatus);
75 117
     return chained_effect;
76 118
 }
77 119
 
78
-u16 type_effectiveness_calc(u16 move, u8 move_type, u8 atk_bank, u8 def_bank, u8 effects_handling_and_recording) {
120
+u16 battle_type_effectiveness_calc(u16 move, u8 move_type, u8 atk_bank, u8 def_bank, u8 effects_handling_and_recording) {
79 121
     u16 chained_effect = 64;
80 122
     //TODO: double_type moves
81 123
     //TODO: get air status
82
-    chained_effect = apply_type_effectiveness(chained_effect, move_type, def_bank, atk_bank, 2);
124
+    chained_effect = battle_apply_type_effectiveness(chained_effect, move_type, def_bank, atk_bank, 2);
83 125
     //TODO: save into structs
84
-    //TODO: effect_handling_and_recoring
126
+    //TODO: effect_handling_and_recording
85 127
     return chained_effect;
86 128
 }
87 129
 
88
-u8 has_type(u8 bank, u8 type) {
130
+u8 battle_bank_has_type(u8 bank, u8 type) {
89 131
     return battle_participants[bank].type1 == type || battle_participants[bank].type2 == type;
90 132
 }
91 133
 
92
-u8 get_item_effect(u8 bank, u8 check_negating_effects) {
134
+u8 battle_item_get_effect(u8 bank, u8 check_negating_effects) {
93 135
     if (check_negating_effects) {
94 136
         if (battle_participants[bank].ability_id == ABILITY_KLUTZ || custom_battle_elements.ptr->bank_affecting[bank].embargo)
95 137
             return ITEM_EFFECT_NOEFFECT;
@@ -101,7 +143,7 @@ u8 get_item_effect(u8 bank, u8 check_negating_effects) {
101 143
     }
102 144
 }
103 145
 
104
-u8 cant_poison(u8 bank, u8 self_inflicted) { //0 == can poison
146
+u8 battle_bank_is_poison_resistant(u8 bank, u8 self_inflicted) { //0 == can poison
105 147
     //1 == is already poisoned
106 148
     //2 == has other major condition
107 149
     //3 == type doesn't allow it
@@ -112,7 +154,7 @@ u8 cant_poison(u8 bank, u8 self_inflicted) { //0 == can poison
112 154
         return 1;
113 155
     if (battle_participants[bank].status.int_status)
114 156
         return 2;
115
-    if (has_type(bank, TYPE_POISON) || has_type(bank, TYPE_STEEL))
157
+    if (battle_bank_has_type(bank, TYPE_POISON) || battle_bank_has_type(bank, TYPE_STEEL))
116 158
         return 3;
117 159
     if (((battle_participants[bank].ability_id == ABILITY_IMMUNITY || (battle_participants[bank].ability_id == ABILITY_LEAF_GUARD && (battle_weather.flags.sun || battle_weather.flags.permament_sun || battle_weather.flags.harsh_sun)))))
118 160
         return 4;
@@ -121,7 +163,7 @@ u8 cant_poison(u8 bank, u8 self_inflicted) { //0 == can poison
121 163
     return 0;
122 164
 }
123 165
 
124
-u8 count_party_pokemon(u8 bank)
166
+u8 battle_count_party_pokemon(u8 bank)
125 167
 {
126 168
     struct pokemon* poke;
127 169
     if (get_side_from_bank(bank))

+ 53
- 9
src/battle_engine/battle_initiative.c View File

@@ -1,12 +1,56 @@
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 battle_initiative.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Methods calculating speed based stats in-battle
28
+ */
29
+
30
+/* === INCLUDE === */
31
+
1 32
 #include <battle_initiative.h>
2
-#include <battle.h>
33
+#include <pkmn_item_effects.h>
34
+#include <pokemon.h>
3 35
 #include <battle_help.h>
4
-#include <bpre.h>
36
+#include <pkmn_abilities.h>
37
+#include <math.h>
38
+#include <battle_common.h>
39
+#include <battle_abilities.h>
40
+#include <battle_structs.h>
41
+#include <battle_locations.h>
42
+#include <battle_custom_structs.h>
43
+#include <battle_fractions.h>
44
+
45
+/* === EXTERN STRUCTS === */
46
+
5 47
 struct move_info move_table[1024];
6 48
 
49
+/* === IMPLEMENTATIONS === */
50
+
7 51
 u16 get_speed(u8 bank) {
8 52
     u32 speed = battle_participants[bank].spd << 16;
9
-    switch (get_item_effect(bank, 1)) {
53
+    switch (battle_item_get_effect(bank, 1)) {
10 54
         case ITEM_EFFECT_IRONBALL:
11 55
             speed >>= 1;
12 56
             break;
@@ -18,8 +62,8 @@ u16 get_speed(u8 bank) {
18 62
                 speed <<= 1;
19 63
             break;
20 64
     }
21
-    if (has_ability_effect(bank, 0, 1)) {
22
-        u8 weather_effects = weather_abilities_effect();
65
+    if (ability_has_effect(bank, 0, 1)) {
66
+        u8 weather_effects = ability_weather_effects();
23 67
         switch (battle_participants[bank].ability_id) {
24 68
             case ABILITY_CHLOROPHYLL:
25 69
                 if (weather_effects && (battle_weather.flags.harsh_sun || battle_weather.flags.permament_sun || battle_weather.flags.sun))
@@ -96,15 +140,15 @@ enum init_enum get_first_to_strike(u8 bank_one, u8 bank_two, u8 ignore_prio) {
96 140
             result = TWO;
97 141
     }
98 142
     if (result == TIE) {
99
-        s8 brack_one = speed_alt_from_item(bank_one, get_item_effect(bank_one, true));
100
-        s8 brack_two = speed_alt_from_item(bank_two, get_item_effect(bank_two, true));
143
+        s8 brack_one = speed_alt_from_item(bank_one, battle_item_get_effect(bank_one, true));
144
+        s8 brack_two = speed_alt_from_item(bank_two, battle_item_get_effect(bank_two, true));
101 145
         if (brack_one > brack_two)
102 146
             result = ONE;
103 147
         else if (brack_two > brack_one)
104 148
             result = TWO;
105 149
         else {
106
-            u8 stall_one = has_ability(bank_one, ABILITY_STALL);
107
-            u8 stall_two = has_ability(bank_two, ABILITY_STALL);
150
+            u8 stall_one = ability_has_ability(bank_one, ABILITY_STALL);
151
+            u8 stall_two = ability_has_ability(bank_two, ABILITY_STALL);
108 152
             if (stall_one && !stall_two)
109 153
                 result = TWO;
110 154
             else if (stall_two && !stall_one)

+ 34
- 3
src/battle_engine/battle_test.c View File

@@ -1,9 +1,40 @@
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 battle_test.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Unit tests for battles, very temporary and undocumented
28
+ */
29
+
30
+#include <types.h>
1 31
 #include <battle_test.h>
2
-#include <battle.h>
3
-#include <bpre.h>
4 32
 #include <debug.h>
5 33
 #include <battle_initiative.h>
6
-#include <abilities.h>
34
+#include <pkmn_abilities.h>
35
+#include <battle_structs.h>
36
+#include <battle_common.h>
37
+#include <battle_custom_structs.h>
7 38
 
8 39
 #define TEST_AMOUNT 10000
9 40
 

+ 61
- 10
src/battle_engine/custom_structs_malloc.c View File

@@ -1,19 +1,70 @@
1
-#include <bpre.h>
2
-#include <battle.h>
3
-#include "custom_structs.h"
4
-#include "custom_structs_malloc.h"
5
-#include <debug.h>
6
-#include <items.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 custom_structs_malloc.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Patch hacks for handling custom battle structures
28
+ */
29
+
30
+
31
+/* === INCLUDE === */
32
+
33
+#include <battle_custom_structs.h>
34
+#include <game_engine.h>
35
+#include <memory.h>
36
+#include <moves.h>
37
+#include <battle_common.h>
38
+#include <battle_locations.h>
39
+
40
+/* === PROTOTYPES === */
41
+
42
+/**
43
+ * @brief allocate the new battle struct memory
44
+ */
45
+void malloc_battle_structs();
46
+
47
+/**
48
+ * @brief free the new battle struct memory
49
+ */
50
+void free_battle_structs();
51
+
52
+/**
53
+ * @brief handle switch in uptates on structures
54
+ */
55
+void battle_switch_in();
56
+
57
+/* === IMPLEMENTATIONS === */
7 58
 
8 59
 void malloc_battle_structs()
9 60
 {
10
-	custom_battle_elements.ptr=(struct custom_battle_struct*)malloc(sizeof(struct custom_battle_struct));
61
+    custom_battle_elements.ptr=(struct custom_battle_struct*)malloc(sizeof(struct custom_battle_struct));
11 62
 }
12 63
 
13 64
 void free_battle_structs()
14 65
 {
15
-	free(custom_battle_elements.ptr);
16
-	custom_battle_elements.ptr=0;
66
+    free(custom_battle_elements.ptr);
67
+    custom_battle_elements.ptr=0;
17 68
 }
18 69
 
19 70
 //hijack switch in command, clean up battle structs and carry over baton pass
@@ -52,4 +103,4 @@ void battle_switch_in()
52 103
     active_side->lunardance_done = 0;
53 104
     
54 105
     return;
55
-}
106
+}

+ 0
- 8
src/battle_engine/custom_structs_malloc.h View File

@@ -1,8 +0,0 @@
1
-#ifndef CUSTOM_S_MAL_H_
2
-#define CUSTOM_S_MAL_H_
3
-
4
-void malloc_battle_structs();
5
-void free_battle_structs();
6
-void battle_switch_in();
7
-
8
-#endif

+ 55
- 4
src/battle_engine/entry_hazards.c View File

@@ -1,5 +1,42 @@
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 entry_hazards.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Handle entry hazards
28
+ */
29
+
30
+/* === INCLUDE === */
1 31
 #include <battle_help.h>
2
-#include <bpre.h>
32
+#include <battle_locations.h>
33
+#include <moves.h>
34
+#include <battle_structs.h>
35
+#include <battle_custom_structs.h>
36
+#include <pkmn_types.h>
37
+#include <battle_common.h>
38
+
39
+/* === EXTERN STATICS === */
3 40
 
4 41
 extern void* bs_stealth_rock;
5 42
 extern void* bs_toxic_spikes;
@@ -16,6 +53,20 @@ extern void* bs_lunar_dance_exec;
16 53
 
17 54
 extern void* str_lunardance_executed_ref;
18 55
 
56
+/* === PROTOTYPES === */
57
+/**
58
+ * @brief execute entry hazards scripts if they are lain
59
+ * @return true if there was an effect, false otherwise
60
+ */
61
+u8 execute_entry_hazards();
62
+
63
+/**
64
+ * @brief execute a lay script for entry hazards
65
+ * @return true
66
+ */
67
+u8 lay_entry_hazards();
68
+
69
+/* === IMPLEMENTATIONS === */
19 70
 u8 execute_entry_hazards() {
20 71
     u8 active_side = get_side_from_bank(battle_active_bank);
21 72
     u8 has_effect = 0;
@@ -47,7 +98,7 @@ u8 execute_entry_hazards() {
47 98
         active_side_affecting->stealth_rock_done = 1;
48 99
         //check for magic guard here
49 100
         u32 damage = battle_participants[battle_active_bank].max_hp;
50
-        switch (type_effectiveness_calc(MOVE_STEALTH_ROCK, TYPE_ROCK, battle_active_bank^1, battle_active_bank, 0) >> 4) {
101
+        switch (battle_type_effectiveness_calc(MOVE_STEALTH_ROCK, TYPE_ROCK, battle_active_bank^1, battle_active_bank, 0) >> 4) {
51 102
             case 1:
52 103
                 damage = damage >> 5;
53 104
                 break;
@@ -73,13 +124,13 @@ u8 execute_entry_hazards() {
73 124
         has_effect = 1;
74 125
     } else if (active_side_affecting->toxic_spikes_psn && !(active_side_affecting->toxic_spikes_done)) {
75 126
         active_side_affecting->toxic_spikes_done = 1;
76
-        if (has_type(battle_active_bank, TYPE_POISON)) {
127
+        if (battle_bank_has_type(battle_active_bank, TYPE_POISON)) {
77 128
             has_effect = 1;
78 129
             active_side_affecting->toxic_spikes_psn = 0;
79 130
             active_side_affecting->toxic_spikes_badpsn = 0;
80 131
             battle_script_push();
81 132
             battlescript_cursor = bs_toxic_resolve;
82
-        } else if (!cant_poison(battle_active_bank, 0)) {
133
+        } else if (!battle_bank_is_poison_resistant(battle_active_bank, 0)) {
83 134
             if (active_side_affecting->toxic_spikes_badpsn) {
84 135
                 battle_participants[battle_active_bank].status.flags.toxic_poison = 1;
85 136
                 battle_script_push();

+ 100
- 58
src/debug/debug.c View File

@@ -39,30 +39,22 @@
39 39
 #include <math.h>
40 40
 #include <fade.h>
41 41
 
42
-/* === STATICS === */
42
+/* === STRUCTURES === */
43
+
44
+struct assert_memory
45
+{
46
+    char* file;
47
+    int line;
48
+    char* expression;
49
+};
43 50
 
51
+/* === STATICS === */
52
+struct assert_memory* assert_global = (struct assert_memory*)0x0203FEC4;
44 53
 static struct print_engine* print_memory = (struct print_engine*)(0x0203FFF0);
45 54
 
46 55
 /* === PROTOTYPES === */
47 56
 
48 57
 /**
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 58
  * @brief convert int to char
67 59
  * @param i integer
68 60
  * @param ref buffer to output to
@@ -122,12 +114,6 @@ void debug_print_char(u16 line, u16 row, char character, u8 color);
122 114
 void debug_print_string(u16 line, u16 row, u8 color, char* pBuf);
123 115
 
124 116
 /**
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 117
  * @brief build power
132 118
  * @param n integer to power
133 119
  * @param power exponent
@@ -135,12 +121,8 @@ void debug_print(char* str);
135 121
  */
136 122
 u32 debug_power(u32 n, u32 power);
137 123
 
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);
124
+void debug_init_stage_one();
125
+void debug_init_stage_two();
144 126
 
145 127
 /**
146 128
  * @brief set bg color of debug environment
@@ -152,34 +134,34 @@ void debug_set_bg(u16 color) {
152 134
     return;
153 135
 }
154 136
 
137
+/* === STATIC STRUCTURES === */
138
+
139
+static struct bg_config debug_bg_config[4] = {
140
+    {0, 0, 0x19, 0, 0, 0},
141
+    {1, 1, 0x1A, 0, 0, 1},
142
+    {2, 2, 0x1B, 0, 0, 2},
143
+    {3, 3, 0x1C, 0, 0, 3}
144
+};
145
+
155 146
 /* === IMPLEMENTATIONS === */
147
+
148
+void as_assert(char* expression, char* file, int line)
149
+{
150
+    assert_global->file = file;
151
+    assert_global->line = line;
152
+    assert_global->expression = expression;
153
+    
154
+    set_callback2(debug_assert_scene);
155
+    vblank_handler_set(debug_update);
156
+    superstate.multi_purpose_state_tracker = 0;
157
+}
158
+
156 159
 void debug_scene() {
157 160
     if (superstate.multi_purpose_state_tracker == 0) {
158
-        print_memory->row = 0;
159
-        print_memory->line = 0;
160
-        print_memory->color = 0;
161
-        gpu_tile_bg_drop_all_sets(0);
162
-        gpu_tile_bg_drop_all_sets(1);
163
-        gpu_tile_bg_drop_all_sets(2);
164
-        gpu_tile_bg_drop_all_sets(3);
165
-
166
-        gpu_bg_vram_setup(0, standard_bg, 4);
167
-
168
-        gpu_bg_show(0);
169
-        gpu_bg_show(1);
170
-        gpu_bg_show(2);
171
-        gpu_bg_show(3);
172
-
173
-        gpu_sync_bg_visibility_and_mode();
174
-        debug_reset_scrolling();
175
-        obj_delete_all();
176
-        memset((void*) 0x06000000, 0, 0x17fe0);
177
-        memset((void*) 0x020375F8, 0, 0x400);
161
+        debug_init_stage_one();
178 162
         superstate.multi_purpose_state_tracker++;
179 163
     } else if (superstate.multi_purpose_state_tracker == 1) {
180
-        vram_decompress((void*) asciiTiles, (void*) 0x06000000);
181
-        memcpy((void*) 0x020375F8, (void*) asciiPal, 0x60);
182
-        debug_set_bg(0x0000);
164
+        debug_init_stage_two();
183 165
         superstate.multi_purpose_state_tracker++;
184 166
     } else if (superstate.multi_purpose_state_tracker == 2) {
185 167
         debug_init_unit_test();
@@ -188,12 +170,12 @@ void debug_scene() {
188 170
     return;
189 171
 }
190 172
 
191
-u8 debug_some_test() {
173
+void debug_some_test() {
192 174
     set_callback2(debug_scene);
193 175
     vblank_handler_set(debug_update);
194 176
     superstate.multi_purpose_state_tracker = 0;
195
-
196
-    return 0;
177
+    
178
+    return;
197 179
 }
198 180
 
199 181
 void debug_reset_scrolling() {
@@ -221,10 +203,15 @@ void debug_print_string(u16 line, u16 row, u8 color, char* pBuf) {
221 203
 
222 204
 void debug_print(char* str) {
223 205
     while (*str) {
206
+        if(print_memory->row > 29)
207
+        {
208
+            print_memory->line++;
209
+            print_memory->row = 0;
210
+        }
224 211
         if (*str == '\n') {
225 212
             print_memory->line++;
226 213
             print_memory->row = 0;
227
-        } else if (*str == '\xFE') {
214
+        } if (*str == '\xFE') {
228 215
             str++;
229 216
             u8 c = *str;
230 217
             if (c > 2)
@@ -241,10 +228,15 @@ void debug_print(char* str) {
241 228
 
242 229
 void debug_printf(char* str, int arg) {
243 230
     while (*str) {
231
+        if(print_memory->row > 29)
232
+        {
233
+            print_memory->line++;
234
+            print_memory->row = 0;
235
+        }
244 236
         if (*str == '\n') {
245 237
             print_memory->line++;
246 238
             print_memory->row = 0;
247
-        } else if (*str == '\xFE') {
239
+        } if (*str == '\xFE') {
248 240
             str++;
249 241
             u8 c = *str;
250 242
             if (c > 2)
@@ -289,6 +281,56 @@ void debug_wait_for_btn(u16 field) {
289 281
     return;
290 282
 }
291 283
 
284
+void debug_init_stage_one()
285
+{
286
+    print_memory->row = 0;
287
+    print_memory->line = 0;
288
+    print_memory->color = 0;
289
+    gpu_tile_bg_drop_all_sets(0);
290
+    gpu_tile_bg_drop_all_sets(1);
291
+    gpu_tile_bg_drop_all_sets(2);
292
+    gpu_tile_bg_drop_all_sets(3);
293
+
294
+    gpu_bg_vram_setup(0, debug_bg_config, 4);
295
+
296
+    gpu_bg_show(0);
297
+    gpu_bg_show(1);
298
+    gpu_bg_show(2);
299
+    gpu_bg_show(3);
300
+
301
+    gpu_sync_bg_visibility_and_mode();
302
+    debug_reset_scrolling();
303
+    obj_delete_all();
304
+    memset((void*) 0x06000000, 0, 0x17fe0);
305
+    memset((void*) 0x020375F8, 0, 0x400);
306
+}
307
+
308
+void debug_init_stage_two()
309
+{
310
+    vram_decompress((void*) asciiTiles, (void*) 0x06000000);
311
+    memcpy((void*) 0x020375F8, (void*) asciiPal, 0x60);
312
+    debug_set_bg(0x0000);
313
+}
314
+
315
+void debug_assert_scene() {
316
+    if (superstate.multi_purpose_state_tracker == 0) {
317
+        debug_init_stage_one();
318
+        superstate.multi_purpose_state_tracker++;
319
+    } else if (superstate.multi_purpose_state_tracker == 1) {
320
+        debug_init_stage_two();
321
+        superstate.multi_purpose_state_tracker++;
322
+    } else if (superstate.multi_purpose_state_tracker == 2) {
323
+        debug_print("Assertion Failed: ");
324
+        debug_print(assert_global->expression);
325
+        debug_print("\n\nFile: ");
326
+        debug_print(assert_global->file);
327
+        debug_printf("\n\nLine: %d", assert_global->line);
328
+        superstate.multi_purpose_state_tracker++;
329
+    }
330
+    /* Loop Endlessly in this stage */
331
+    return;
332
+}
333
+
292 334
 void debug_print_char(u16 line, u16 row, char character, u8 color) {
293 335
     if (color > 2)
294 336
         color = 0;

+ 217
- 61
src/dns/dns_core.c View File

@@ -1,7 +1,160 @@
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 dns_core.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief interact with the dns system
28
+ *
29
+ */
30
+
31
+/* === INCLUDE === */
2 32
 #include <dns_core.h>
3 33
 #include <memory.h>
34
+#include <lcd.h>
35
+#include <callback.h>
36
+
37
+/* === PROTOTYPES === */
38
+
39
+/**
40
+ * @brief hacked overworld callback to update palettes
41
+ */
42
+void dns_cb_overworld_hacked();
43
+
44
+/**
45
+ * @brief get current time of day type
46
+ * @return enum containing respective day type
47
+ */
48
+enum dns_rtc_time_type dns_get_time_of_day();
49
+
50
+/**
51
+ * @brief load virtual pal of npc
52
+ * @param dst destination to load to
53
+ * @param tag tag to load
54
+ * @param slot slot to load
55
+ * @param shade shade immediatly if true
56
+ */
57
+void dns_npc_load_virtual_pal(struct color* dst, u16 tag, u8 slot, u8 shade);
58
+
59
+/**
60
+ * @brief allocate a virtual pal and load it
61
+ * @return pointer to allocated color array
62
+ */
63
+struct color* dns_alloc_virtual_pal_and_load();
64
+
65
+/**
66
+ * @brief update palettes
67
+ */
68
+void dns_update_palettes();
69
+
70
+/**
71
+ * @brief load pal of overworld animation i.e. grass
72
+ * @param oe_script_pointer pointer to oe_script controlling the animation
73
+ */
74
+void dns_overworld_anim_load_pal(void** oe_script_pointer);
75
+
76
+/**
77
+ * @brief load blockset to virtual space
78
+ * @param blockset pointer to blockset to load
79
+ * @param start start range
80
+ * @param len end range
81
+ * @param destination virtual destination to load to
82
+ */
83
+void dns_blockset_load_virtual_palette_and_shade(struct blockset* blockset, u16 start, u16 len, struct color* destination);
84
+
85
+/**
86
+ * @brief load blockset into palram and shade it
87
+ * @param blockset pointer to blockset to load
88
+ * @param start start range
89
+ * @param len end range
90
+ */
91
+void dns_blockset_load_palette_to_gpu_and_shade(struct blockset* blockset, u16 start, u16 len);
92
+
93
+/**
94
+ * @brief load second pal of mapheader given
95
+ * @param data_header pointer to mapdata header
96
+ */
97
+void dns_mapdata_load_palette_two(struct mapdata_header* data_header);
98
+
99
+/**
100
+ * @brief load second pal of mapheader given
101
+ * @param data_header pointer to mapdata header
102
+ */
103
+void dns_mapdata_load_palette_one(struct mapdata_header* data_header);
4 104
 
105
+/**
106
+ * @brief apply light effects to given color array
107
+ * @param blockset pointer to blockset
108
+ * @param secondary is the blockset a secondary blockset
109
+ * @param buffer color buffer to apply lighting to
110
+ */
111
+void dns_apply_lighting(void* blockset, u8 secondary, struct color* buffer);
112
+
113
+/**
114
+ * @brief apply shaders to color buffer
115
+ * @param pal pal to apply shader to
116
+ * @param fade_copy copy to unfaded immediatly if true
117
+ * @param buffer color buffer
118
+ */
119
+void dns_apply_shaders(u8 pal, u8 fade_copy, struct color* buffer);
120
+
121
+/**
122
+ * @brief copy slot to faded buffer
123
+ * @param slot palette slot
124
+ */
125
+void dns_copy_unfaded(u8 slot);
126
+
127
+/**
128
+ * @brief should the map allow shading?
129
+ * @param current_type maptype to check for
130
+ * @return 
131
+ */
132
+u8 dns_should_shade(enum map_type current_type);
133
+
134
+/**
135
+ * @brief get color shade struct from time of day
136
+ * @param current_time current time of day
137
+ * @return color_shade struct with respective information
138
+ */
139
+struct color_shade dns_get_shade_from_time(enum dns_rtc_time_type current_time);
140
+
141
+/**
142
+ * @brief blend color a over color b
143
+ * @param a first color
144
+ * @param b second color
145
+ * @param alpha alpha value
146
+ * @return blended color
147
+ */
148
+struct color dns_alpha_blend(struct color a, struct color b, u8 alpha);
149
+
150
+/**
151
+ * @brief patch hack for npc and pal slot
152
+ * @param tag tag to apply hack to
153
+ * @param pal_slot pal slot to apply hack to
154
+ */
155
+void dns_pal_patch_for_npc(u16 tag, u8 pal_slot);
156
+
157
+/* === STATICS === */
5 158
 
6 159
 static struct pal_replace lightmap[] = {
7 160
     {(void*) 0x082D4AAC, 9, 10, {
@@ -19,7 +172,24 @@ static struct pal_replace lightmap[] = {
19 172
         }}
20 173
 };
21 174
 
22
-void overworld_loop() {
175
+static struct color_shade color_shade_day = {
176
+    {0, 0, 0}, 255
177
+};
178
+static struct color_shade color_shade_night = {
179
+    {0, 6, 16}, 120
180
+};
181
+
182
+static struct color_shade color_shade_evening = {
183
+    {12, 7, 17}, 120
184
+};
185
+
186
+static struct color_shade color_shade_morning = {
187
+    {6, 16, 6}, 150
188
+};
189
+
190
+/* === IMPLEMENTATIONS === */
191
+
192
+void dns_cb_overworld_hacked() {
23 193
     script_something();
24 194
     task_exec();
25 195
     objc_exec();
@@ -33,80 +203,65 @@ void overworld_loop() {
33 203
 
34 204
     volatile u8* test_pointer = (u8*) (0x0203FAB0);
35 205
     if (*test_pointer == 1 && (fade_controller.mix_color & 0x8000) == 0) {
36
-        update_dns_palettes();
206
+        dns_update_palettes();
37 207
         *test_pointer = 0;
38 208
     }
39 209
 }
40 210
 
41
-enum time_type get_time_of_day() {
211
+enum dns_rtc_time_type dns_get_time_of_day() {
42 212
     volatile u8* time_pointer = (u8*) (0x0203FAB1);
43 213
     return *time_pointer;
44 214
 }
45 215
 
46
-static struct color_shade color_shade_day = {
47
-    {0, 0, 0}, 255
48
-};
49
-static struct color_shade color_shade_night = {
50
-    {0, 6, 16}, 120
51
-};
52
-
53
-static struct color_shade color_shade_evening = {
54
-    {12, 7, 17}, 120
55
-};
56
-
57
-static struct color_shade color_shade_morning = {
58
-    {6, 16, 6}, 150
59
-};
60
-
61
-void npc_load_virtual_pal(struct color* dst, u16 tag, u8 slot, u8 shade) {
216
+void dns_npc_load_virtual_pal(struct color* dst, u16 tag, u8 slot, u8 shade) {
62 217
     u16 npc_map_entry = npc_pal_idx_for_given_tag(tag);
63 218
     memcpy(dst + (16 + slot)*16, npc_palettes[npc_map_entry].palette, 32);
64 219
     if (shade) {
65 220
         tint_palette(slot);
66
-        apply_shaders(slot + 16, 0, dst);
221
+        dns_apply_shaders(slot + 16, 0, dst);
67 222
     }
68 223
 }
69 224
 
70 225
 struct color* dns_alloc_virtual_pal_and_load() {
71 226
     struct color* destination = malloc(0x400);
72
-    blockset_load_virtual_palette_and_shade(current_mapheader.data_header->blockset_one, 0x0, 0xE0, destination);
73
-    blockset_load_virtual_palette_and_shade(current_mapheader.data_header->blockset_two, 0x70, 0xC0, destination);
227
+    dns_blockset_load_virtual_palette_and_shade(current_mapheader.data_header->blockset_one, 0x0, 0xE0, destination);
228
+    dns_blockset_load_virtual_palette_and_shade(current_mapheader.data_header->blockset_two, 0x70, 0xC0, destination);
74 229
     
75
-    npc_load_virtual_pal(destination, 0x1120, 0, false);
230
+    dns_npc_load_virtual_pal(destination, 0x1120, 0, false);
76 231
     load_palette_3(0x0, 0xD0);
77 232
     for (int i = 0; i < 16; ++i) {
78 233
         if (dynamic_palettes[i].tag >= 0x1100) {
79
-            npc_load_virtual_pal(destination, dynamic_palettes[i].tag, i, true);
234
+            dns_npc_load_virtual_pal(destination, dynamic_palettes[i].tag, i, true);
80 235
         } else if (dynamic_palettes[i].tag == 0x1004) {
81 236
             //oe_0001
82 237
             struct color* oe_pal_1 = (struct color*) (0x08398FA8);
83 238
             memcpy(destination + (16 + i) * 16, oe_pal_1, 32);
84
-            apply_shaders(16 + i, 0, destination);
239
+            dns_apply_shaders(16 + i, 0, destination);
85 240
 
86 241
         } else if (dynamic_palettes[i].tag == 0x1005) {
87 242
             //oe_0002
88 243
             struct color* oe_pal_2 = (struct color*) (0x08398FC8);
89 244
             memcpy(destination + (16 + i) * 16, oe_pal_2, 32);
90
-            apply_shaders(16 + 1, 0, destination);
245
+            dns_apply_shaders(16 + 1, 0, destination);
91 246
         }
92 247
     }
93 248
     return destination;
94 249
 }
95 250
 
96
-void update_dns_palettes() {
251
+void dns_update_palettes() {
97 252
     struct color* destination = dns_alloc_virtual_pal_and_load();
98 253
     gpu_pal_apply(destination, 0x0, 0x1A0);
99 254
     gpu_pal_apply(destination + 0x100, 0x100, 0x200);
100 255
     free(destination);
101 256
 }
102 257
 
103
-void overworld_anim_load_pal(void** oe_script_pointer) {
258
+void dns_overworld_anim_load_pal(void** oe_script_pointer) {
104 259
     struct npc_palette* pal_to_apply = oe_read_word(oe_script_pointer);
105 260
     u16 current_idx = gpu_pal_tags_index_of(pal_to_apply->tag);
106 261
 
107 262
     struct color* temp_color = malloc(32);
108 263
     memcpy(temp_color, pal_to_apply->palette, 32);
109
-    apply_shaders(0, 0, temp_color);
264
+    dns_apply_shaders(0, 0, temp_color);
110 265
 
111 266
     struct obj_resource temp_resource = {temp_color, pal_to_apply->tag, pal_to_apply->fill};
112 267
     obj_gpu_pal_alloc_tag_and_apply(&temp_resource);
@@ -121,15 +276,15 @@ void overworld_anim_load_pal(void** oe_script_pointer) {
121 276
     return;
122 277
 }
123 278
 
124
-void blockset_load_virtual_palette_and_shade(struct blockset* blockset, u16 start, u16 len, struct color* destination) {
279
+void dns_blockset_load_virtual_palette_and_shade(struct blockset* blockset, u16 start, u16 len, struct color* destination) {
125 280
     if (blockset == 0)
126 281
         return;
127 282
     if (blockset->is_secondary) {
128 283
         if (blockset->is_secondary == 1) {
129 284
             memcpy(destination + start, blockset->palette + (start * 2), len);
130 285
             for (u8 i = 7; i < 7 + 6; ++i)
131
-                apply_shaders(i, 0, destination);
132
-            apply_lighting(blockset, 0, destination);
286
+                dns_apply_shaders(i, 0, destination);
287
+            dns_apply_lighting(blockset, 0, destination);
133 288
             //gpu_pal_apply((color_memory), start, len);
134 289
             //load_palette_3(start, len >> 1);
135 290
         } else {
@@ -137,8 +292,8 @@ void blockset_load_virtual_palette_and_shade(struct blockset* blockset, u16 star
137 292
             lz77u_wram(blockset->palette, pal_buffer);
138 293
             memcpy(destination + start, pal_buffer + (start * 2), len);
139 294
             for (u8 i = 7; i < 7 + 6; ++i)
140
-                apply_shaders(i, 0, destination);
141
-            apply_lighting(blockset, 0, destination);
295
+                dns_apply_shaders(i, 0, destination);
296
+            dns_apply_lighting(blockset, 0, destination);
142 297
             //gpu_pal_apply(pal_buffer, start, len);
143 298
             //load_palette_3(start, len >> 1);
144 299
         }
@@ -146,8 +301,8 @@ void blockset_load_virtual_palette_and_shade(struct blockset* blockset, u16 star
146 301
         //struct color* color_memory = malloc(224);
147 302
         memcpy(destination, blockset->palette, len);
148 303
         for (u8 i = 0; i < 7; ++i)
149
-            apply_shaders(i, 0, destination);
150
-        apply_lighting(blockset, 0, destination);
304
+            dns_apply_shaders(i, 0, destination);
305
+        dns_apply_lighting(blockset, 0, destination);
151 306
         //gpu_pal_apply(color_memory, start, len);
152 307
         //load_palette_3(start, len >> 1);
153 308
         //free(color_memory);
@@ -155,7 +310,7 @@ void blockset_load_virtual_palette_and_shade(struct blockset* blockset, u16 star
155 310
     return;
156 311
 }
157 312
 
158
-void blockset_load_palette_to_gpu_and_shade(struct blockset* blockset, u16 start, u16 len) {
313
+void dns_blockset_load_palette_to_gpu_and_shade(struct blockset* blockset, u16 start, u16 len) {
159 314
     if (blockset == 0)
160 315
         return;
161 316
     if (blockset->is_secondary) {
@@ -163,8 +318,8 @@ void blockset_load_palette_to_gpu_and_shade(struct blockset* blockset, u16 start
163 318
             struct color* color_memory = malloc(224);
164 319
             memcpy(color_memory, blockset->palette + 0xE0, 224);
165 320
             for (u8 i = 0; i < 7; ++i)
166
-                apply_shaders(i, 0, color_memory);
167
-            apply_lighting(blockset, 1, color_memory);
321
+                dns_apply_shaders(i, 0, color_memory);
322
+            dns_apply_lighting(blockset, 1, color_memory);
168 323
             gpu_pal_apply((color_memory), start, len);
169 324
             load_palette_3(start, len >> 1);
170 325
             free(color_memory);
@@ -172,8 +327,8 @@ void blockset_load_palette_to_gpu_and_shade(struct blockset* blockset, u16 start
172 327
             struct color* pal_buffer = (struct color*) (0x02037ACC);
173 328
             lz77u_wram(blockset->palette, pal_buffer);
174 329
             for (u8 i = 7; i < 7 + 6; ++i)
175
-                apply_shaders(i, 0, pal_buffer);
176
-            apply_lighting(blockset, 0, pal_buffer);
330
+                dns_apply_shaders(i, 0, pal_buffer);
331
+            dns_apply_lighting(blockset, 0, pal_buffer);
177 332
             gpu_pal_apply(pal_buffer, start, len);
178 333
             load_palette_3(start, len >> 1);
179 334
         }
@@ -181,8 +336,8 @@ void blockset_load_palette_to_gpu_and_shade(struct blockset* blockset, u16 start
181 336
         struct color* color_memory = malloc(224);
182 337
         memcpy(color_memory, blockset->palette, 224);
183 338
         for (u8 i = 0; i < 7; ++i)
184
-            apply_shaders(i, 0, color_memory);
185
-        apply_lighting(blockset, 0, color_memory);
339
+            dns_apply_shaders(i, 0, color_memory);
340
+        dns_apply_lighting(blockset, 0, color_memory);
186 341
         gpu_pal_apply(color_memory, start, len);
187 342
         load_palette_3(start, len >> 1);
188 343
         free(color_memory);
@@ -190,27 +345,27 @@ void blockset_load_palette_to_gpu_and_shade(struct blockset* blockset, u16 start
190 345
     return;
191 346
 }
192 347
 
193
-void mapdata_load_palette_two(struct mapdata_header* data_header) {
348
+void dns_mapdata_load_palette_two(struct mapdata_header* data_header) {
194 349
     //struct color* destination = malloc(0x200);
195 350
     //blockset_load_virtual_palette_and_shade(data_header->blockset_two, 0x70, 0xC0, destination);
196 351
     //gpu_pal_apply(destination, 0x70, 0xC0);
197 352
     //load_palette_3(0x70, 0xC0 >> 1);
198
-    blockset_load_palette_to_gpu_and_shade(data_header->blockset_two, 0x70, 0xC0);
353
+    dns_blockset_load_palette_to_gpu_and_shade(data_header->blockset_two, 0x70, 0xC0);
199 354
     return;
200 355
 }
201 356
 
202
-void mapdata_load_palette_one(struct mapdata_header* data_header) {
357
+void dns_mapdata_load_palette_one(struct mapdata_header* data_header) {
203 358
     //struct color* destination = malloc(0x200);
204 359
     //blockset_load_virtual_palette_and_shade(data_header->blockset_one, 0x0, 0xE0, destination);
205 360
     //gpu_pal_apply(destination, 0x0, 0xE0);
206 361
     //load_palette_3(0x0, 0xE0 >> 1);
207 362
 
208
-    blockset_load_palette_to_gpu_and_shade(data_header->blockset_one, 0x0, 0xE0);
363
+    dns_blockset_load_palette_to_gpu_and_shade(data_header->blockset_one, 0x0, 0xE0);
209 364
     return;
210 365
 }
211 366
 
212
-void apply_lighting(void* blockset, u8 secondary, struct color* buffer) {
213
-    if (get_time_of_day() != NIGHT)
367
+void dns_apply_lighting(void* blockset, u8 secondary, struct color* buffer) {
368
+    if (dns_get_time_of_day() != NIGHT)
214 369
         return;
215 370
     for (int i = 0; i < (sizeof (lightmap) / sizeof (lightmap[0])); ++i) {
216 371
         if (blockset == lightmap[i].blockset) {
@@ -220,26 +375,26 @@ void apply_lighting(void* blockset, u8 secondary, struct color* buffer) {
220 375
     return;
221 376
 }
222 377
 
223
-void apply_shaders(u8 pal, u8 fade_copy, struct color* buffer) {
378
+void dns_apply_shaders(u8 pal, u8 fade_copy, struct color* buffer) {
224 379
     if (tint_filter != 0)
225 380
         return;
226
-    if (!is_current_map_dn_valid(current_mapheader.maptype))
381
+    if (!dns_should_shade(current_mapheader.maptype))
227 382
         return;
228 383
     for (int i = pal * 16; i < (pal * 16) + 16; ++i) {
229
-        struct color_shade current_shade = get_color_from_time(get_time_of_day());
230
-        buffer[i] = alpha_blend(buffer[i], current_shade.color, current_shade.alpha);
384
+        struct color_shade current_shade = dns_get_shade_from_time(dns_get_time_of_day());
385
+        buffer[i] = dns_alpha_blend(buffer[i], current_shade.color, current_shade.alpha);
231 386
     }
232 387
     if (fade_copy)
233
-        copy_unfaded(pal);
388
+        dns_copy_unfaded(pal);
234 389
 }
235 390
 
236
-void copy_unfaded(u8 slot) {
391
+void dns_copy_unfaded(u8 slot) {
237 392
     for (int i = slot * 16; i < (slot * 16) + 16; ++i) {
238 393
         palette_faded_buffer[i] = palette_unfaded_buffer[i];
239 394
     }
240 395
 }
241 396
 
242
-u8 is_current_map_dn_valid(enum map_type current_type) {
397
+u8 dns_should_shade(enum map_type current_type) {
243 398
     switch (current_type) {
244 399
         case VILLAGE:
245 400
         case CITY:
@@ -251,7 +406,7 @@ u8 is_current_map_dn_valid(enum map_type current_type) {
251 406
     return 0;
252 407
 }
253 408
 
254
-struct color_shade get_color_from_time(enum time_type current_time) {
409
+struct color_shade dns_get_shade_from_time(enum dns_rtc_time_type current_time) {
255 410
     switch (current_time) {
256 411
         case NIGHT:
257 412
             return color_shade_night;
@@ -266,7 +421,7 @@ struct color_shade get_color_from_time(enum time_type current_time) {
266 421
     }
267 422
 }
268 423
 
269
-struct color alpha_blend(struct color a, struct color b, u8 alpha) {
424
+struct color dns_alpha_blend(struct color a, struct color b, u8 alpha) {
270 425
     if (alpha == 255)
271 426
         return a;
272 427
     if (alpha == 0)
@@ -280,10 +435,11 @@ struct color alpha_blend(struct color a, struct color b, u8 alpha) {
280 435
     return output;
281 436
 }
282 437
 
283
-void pal_patch_for_npc(u16 tag, u8 pal_slot) {
438
+
439
+void dns_pal_patch_for_npc(u16 tag, u8 pal_slot) {
284 440
     u16 npc_map_entry = npc_pal_idx_for_given_tag(tag);
285 441
     gpu_pal_apply(npc_palettes[npc_map_entry].palette, (pal_slot + 16) * 16, 32);
286 442
     tint_palette(pal_slot);
287
-    apply_shaders(pal_slot + 16, 1, palette_unfaded_buffer);
443
+    dns_apply_shaders(pal_slot + 16, 1, palette_unfaded_buffer);
288 444
 }
289 445
 /*use fade in animation, load palettes according to current fade state*/

+ 45
- 0
src/encode/crc32.c View File

@@ -1,6 +1,51 @@
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 crc32.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief cyclic redundancy check algorithm
28
+ *
29
+ */
30
+
31
+
32
+/* === INCLUDE === */
1 33
 #include <config.h>
2 34
 #include <types.h>
3 35
 
36
+/* === PROTOTYPES === */
37
+
38
+/**
39
+ * @brief performs crc32 on data in buf
40
+ * @param crc starting value
41
+ * @param buf data buffer 
42
+ * @param size data size
43
+ * @return crc32
44
+ */
45
+u32 crc32(u32 crc, const void *buf, u32 size);
46
+
47
+/* === STATICS === */
48
+
4 49
 static u32 crc32_tab[] = {
5 50
 	0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
6 51
 	0xe963a535, 0x9e6495a3,	0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,

+ 29
- 0
src/include/attack_names.h View File

@@ -1,3 +1,32 @@
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 attack_names.h
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Abilities in Assembler notation
28
+ */
29
+
1 30
 .equ ABSORB, 0x47
2 31
 .equ ACID, 0x33
3 32
 .equ ACID_ARMOR, 0x97

+ 0
- 34
src/include/battle.h View File

@@ -1,34 +0,0 @@
1
-#include <battle_structs.h>
2
-#include <custom_structs.h>
3
-#include <battle_locations.h>
4
-#include <pkmn_types.h>
5
-#include <abilities.h>
6
-#include <moves.h>
7
-#include <item_effects.h>
8
-#include <items.h>
9
-#include <pokemon.h>
10
-#include <battle_abilities.h>
11
-
12
-#ifndef BATTLE_H_
13
-#define BATTLE_H_
14
-
15
-#define REQUEST_HELDITEM_BATTLE 0x2
16
-#define REQUEST_STATUS_BATTLE 0x28
17
-
18
-struct stat_fractions{
19
-    u8 dividend;
20
-    u8 divisor;
21
-};
22
-
23
-struct stat_fractions stat_buffs[] = { {2, 8}, {2, 7}, {2, 6}, {2, 5}, {2, 4}, {2, 3}, {2, 2}, {3, 2}, {4, 2}, {5, 2}, {6, 2}, {7, 2}, {8, 2} };
24
-
25
-u8 get_side_from_bank(u8 bank);
26
-u16 battle_turn_random;
27
-
28
-void mark_buffer_bank_for_execution(u8 bank);
29
-void prepare_setattributes_in_battle(u8 buffer, u8 data_request, u8 unkown, u8 data_to_add, void* ptr_to_attribute);
30
-u8 item_get_quality(u8 item_id);
31
-u8 get_item_x12_battle_function(u16 item_id);
32
-void battle_script_push();
33
-
34
-#endif

+ 54
- 4
src/include/battle_abilities.h View File

@@ -1,11 +1,61 @@
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 battle_abilities.h
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Some methods concerning in-battle abilities
28
+ */
29
+
1 30
 #ifndef BATTLE_ABILITIES_H
2 31
 #define BATTLE_ABILITIES_H
3 32
 
4
-#include <bpre.h>
33
+/* === INCLUDES === */
34
+
35
+#include <types.h>
36
+
37
+/**
38
+ * @brief checks if ability is blocked
39
+ * @param bank bank to check for
40
+ * @param mold_breaker check for mold breaker?
41
+ * @param gastro check for gastro acid?
42
+ * @return true if the ability has an effect, false otherwise.
43
+ */
44
+u8 ability_has_effect(u8 bank, u8 mold_breaker, u8 gastro);
45
+
46
+/**
47
+ * @brief do weather abilities have an effect?
48
+ * @return false if weather abilities are blocked, true otherwise
49
+ */
50
+u8 ability_weather_effects();
5 51
 
6
-u8 has_ability_effect(u8 bank, u8 mold_breaker, u8 gastro);
7
-u8 weather_abilities_effect();
8
-u8 has_ability(u8 bank, u8 ability);
52
+/**
53
+ * @brief has bank ability
54
+ * @param bank bank to check
55
+ * @param ability ability to check for
56
+ * @return true if bank has ability, false otherwise
57
+ */
58
+u8 ability_has_ability(u8 bank, u8 ability);
9 59
 
10 60
 #endif /* BATTLE_ABILITIES_H */
11 61
 

+ 17
- 0
src/include/battle_common.h View File

@@ -0,0 +1,17 @@
1
+#ifndef BATTLE_H_
2
+#define BATTLE_H_
3
+
4
+#include <types.h>
5
+
6
+#define REQUEST_HELDITEM_BATTLE 0x2
7
+#define REQUEST_STATUS_BATTLE 0x28
8
+
9
+u8 get_side_from_bank(u8 bank);
10
+u16 battle_turn_random;
11
+void mark_buffer_bank_for_execution(u8 bank);
12
+void prepare_setattributes_in_battle(u8 buffer, u8 data_request, u8 unkown, u8 data_to_add, void* ptr_to_attribute);
13
+u8 item_get_quality(u8 item_id);
14
+u8 get_item_x12_battle_function(u16 item_id);
15
+void battle_script_push();
16
+
17
+#endif

src/include/custom_structs.h → src/include/battle_custom_structs.h View File


+ 12
- 0
src/include/battle_fractions.h View File

@@ -0,0 +1,12 @@
1
+#ifndef BATTLE_FRACTIONS_H
2
+#define BATTLE_FRACTIONS_H
3
+
4
+struct stat_fractions{
5
+    u8 dividend;
6
+    u8 divisor;
7
+};
8
+
9
+struct stat_fractions stat_buffs[] = { {2, 8}, {2, 7}, {2, 6}, {2, 5}, {2, 4}, {2, 3}, {2, 2}, {3, 2}, {4, 2}, {5, 2}, {6, 2}, {7, 2}, {8, 2} };
10
+
11
+#endif /* BATTLE_FRACTIONS_H */
12
+

+ 95
- 8
src/include/battle_help.h View File

@@ -1,13 +1,100 @@
1
-#include <battle.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 battle_help.h
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Some helper methods to calculate in-battle outcomes etc.
28
+ */
2 29
 
3 30
 #ifndef BATTLE_HELP_H_
4 31
 #define BATTLE_HELP_H_
5 32
 
6
-u8 get_item_effect(u8 bank, u8 check_negating_effects);
7
-u16 damage_type_effectiveness_update(u8 attacking_type, u8 defending_type, u8 atk_bank, u8 def_bank, u16 chained_effect, u8 airstatus);
8
-u16 apply_type_effectiveness(u16 chained_effect, u8 move_type, u8 target_bank, u8 atk_bank, u8 airstatus);
9
-u16 type_effectiveness_calc(u16 move, u8 move_type, u8 atk_bank, u8 def_bank, u8 effects_handling_and_recording);
10
-u8 has_type(u8 bank, u8 type);
11
-u8 cant_poison(u8 bank, u8 self_inflicted);
12
-u8 count_party_pokemon(u8 bank);
33
+#include <types.h>
34
+
35
+/**
36
+ * @brief get item effect of bank
37
+ * @param bank bank to check effect
38
+ * @param check_negating_effects if true only return effect if it can be executed
39
+ * @return item effect of item held by bank
40
+ */
41
+u8 battle_item_get_effect(u8 bank, u8 check_negating_effects);
42
+
43
+/**
44
+ * @brief update the chained effectiveness according to parameters
45
+ * @param attacking_type type of attacking move
46
+ * @param defending_type type of defender
47
+ * @param atk_bank bank of attacker
48
+ * @param def_bank bank of defender
49
+ * @param chained_effect previously chained effect
50
+ * @param airstatus airborne status according to enumeration
51
+ * @return new chained effect
52
+ */
53
+u16 battle_damage_type_effectiveness_update(u8 attacking_type, u8 defending_type, u8 atk_bank, u8 def_bank, u16 chained_effect, u8 airstatus);
54
+
55
+/**
56
+ * @brief fully calculate effectiveness from a base effectiveness (def: 64)
57
+ * @param chained_effect chained input (def: 64)
58
+ * @param move_type attacking move type
59
+ * @param target_bank bank of target
60
+ * @param atk_bank bank of attacker
61
+ * @param airstatus airstatus of defender
62
+ * @return chained effectiveness
63
+ */
64
+u16 battle_apply_type_effectiveness(u16 chained_effect, u8 move_type, u8 target_bank, u8 atk_bank, u8 airstatus);
65
+
66
+/**
67
+ * @brief calculate type effectiveness from front to back
68
+ * @param move executed move
69
+ * @param move_type type of executed move according to type enumeration
70
+ * @param atk_bank bank of attacker
71
+ * @param def_bank bank of defender
72
+ * @param effects_handling_and_recording TO BE DONE
73
+ * @return effectiveness of made attack
74
+ */
75
+u16 battle_type_effectiveness_calc(u16 move, u8 move_type, u8 atk_bank, u8 def_bank, u8 effects_handling_and_recording);
76
+
77
+/**
78
+ * @brief has bank type
79
+ * @param bank bank to check
80
+ * @param type type to check for
81
+ * @return true if bank has type, false otherwise
82
+ */
83
+u8 battle_bank_has_type(u8 bank, u8 type);
84
+
85
+/**
86
+ * @brief check if bank is resistant to poison
87
+ * @param bank bank to check for
88
+ * @param self_inflicted was poison self_inflicted?
89
+ * @return 0 if pokemon can be poisoned; 1 if already poisoned; 2 if other status condition e.g. burn; 3 if blocked by type; 4 if blocked by ability; 5 if blocked by safeguard; 6 if blocked by misty terrain (TODO)
90
+ * 
91
+ */
92
+u8 battle_bank_is_poison_resistant(u8 bank, u8 self_inflicted);
93
+
94
+/**
95
+ * @brief counts usable party pokemon of side from bank
96
+ * @param bank bank of which usable pokemon should be counted
97
+ * @return usable (not dead) pokemon on side from bank
98
+ */
99
+u8 battle_count_party_pokemon(u8 bank);
13 100
 #endif

+ 46
- 0
src/include/battle_initiative.h View File

@@ -1,11 +1,57 @@
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 battle_initiative.h
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Methods calculating speed based stats in-battle
28
+ */
29
+
1 30
 #ifndef BATTLE_INITIATIVE_H
2 31
 #define BATTLE_INITIATIVE_H
3 32
 
33
+/* === INCLUDES === */
4 34
 #include <types.h>
5 35
 
36
+/* === ENUMERATIONS === */
6 37
 enum init_enum {ONE, TWO, TIE};
7 38
 
39
+/* === PROTOTYPES === */
40
+
41
+/**
42
+ * @brief calculate who strikes first
43
+ * @param bank1 first contrahend
44
+ * @param bank2 second contrahend
45
+ * @param ignore_prio ignore priority of moves
46
+ * @return bank to strike first as described in enumeration
47
+ */
8 48
 enum init_enum get_first_to_strike(u8 bank1, u8 bank2, u8 ignore_prio);
49
+
50
+/**
51
+ * @brief get the (modified) speed of bank
52
+ * @param bank bank to get speed of
53
+ * @return modified speed value of pokemon in bank
54
+ */
9 55
 u16 get_speed(u8 bank);
10 56
 #endif /* BATTLE_INITIATIVE_H */
11 57
 

+ 32
- 0
src/include/battle_locations.h View File

@@ -1,6 +1,38 @@
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 attack_names.h
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Some globals used in-battle
28
+ */
29
+
30
+
1 31
 #ifndef BATTLE_LOC_H_
2 32
 #define BATTLE_LOC_H_
3 33
 
34
+#include <types.h>
35
+
4 36
 u8 battle_active_bank;
5 37
 u8 battle_stat_changer;
6 38
 void* battle_string_chooser;

+ 30
- 1
src/include/battle_script.h View File

@@ -1,3 +1,33 @@
1
+/****************************************************************************
2
+ * Copyright (C) 2015-2016 by KDS                                           *
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 battle_script.h
25
+ * @author KDS
26
+ * @date 15 dec 2016
27
+ * @brief Preprocessor Macros for writing PKMN Battle Scripts
28
+ */
29
+
30
+
1 31
 #include <attack_names.h>
2 32
 
3 33
 @@ Banks
@@ -60,7 +90,6 @@
60 90
 .byte 4
61 91
 .endm
62 92
 
63
-
64 93
 .macro cmd5
65 94
 .byte 5
66 95
 .endm

+ 76
- 1
src/include/debug.h View File

@@ -1,13 +1,88 @@
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.h
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Operate with the sots debug engine, very temporary
28
+ */
29
+
1 30
 #ifndef DEBUG_H
2 31
 #define DEBUG_H
3 32
 
33
+/* === MACROS === */
34
+#define STRINGIFY(x) #x
35
+#define TOSTRING(x) STRINGIFY(x)
36
+#define assert(EX)  if(!EX) {as_assert(STRINGIFY(EX), __FILE__, __LINE__);}
37
+
4 38
 struct print_engine{
39
+    
5 40
     u8 line;
6 41
     u8 row;
7 42
     u8 color;
8 43
 };
9 44
 
10
-u8 debug_some_test();
45
+/**
46
+ * @brief temporary method to initiate a debug process / unit test
47
+ */
48
+void debug_some_test();
49
+
50
+/**
51
+ * @brief set bg color
52
+ * @param color color to set bg to
53
+ */
54
+void debug_set_bg(u16 color);
55
+
56
+/**
57
+ * @brief clean debug screen from any text and reset cursor
58
+ */
59
+void debug_clean();
60
+
61
+/**
62
+ * @brief print string onto debug environment at current position with parsing
63
+ * @param str string to print
64
+ */
65
+void debug_print(char* str);
66
+
67
+/**
68
+ * @brief wait for button press
69
+ * @param field bitfield to specify buttom combination
70
+ */
71
+void debug_wait_for_btn(u16 field);
72
+
73
+/**
74
+ * @brief print in format to debug environment
75
+ * @param str string with format
76
+ * @param arg argument to print (only one, not an array)
77
+ */
78
+void debug_printf(char* str, int arg);
79
+
80
+/**
81
+ * @brief handle for the assert scene
82
+ */
83
+void debug_assert_scene();
84
+
85
+void as_assert(char* expression, char* file, int line);
11 86
 
12 87
 #endif /* DEBUG_H */
13 88
 

+ 9
- 13
src/include/dns_core.h View File

@@ -1,7 +1,12 @@
1 1
 #ifndef DNS_CORE_H
2 2
 #define DNS_CORE_H
3 3
 
4
-enum time_type {
4
+#include <types.h>
5
+#include <lcd.h>
6
+#include <objects.h>
7
+#include <fade.h>
8
+
9
+enum dns_rtc_time_type {
5 10
     DAY,
6 11
     NIGHT,
7 12
     EVENING,
@@ -89,31 +94,22 @@ struct dynamic_pal {
89 94
 
90 95
 #define dynamic_palettes ((struct dynamic_pal*) 0x0203FF00)
91 96
 
92
-void blockset_load_virtual_palette_and_shade(struct blockset* blockset, u16 start, u16 len, struct color* destination);
93 97
 extern struct npc_palette* npc_palettes;
94 98
 extern volatile u8 tint_filter;
95
-void apply_shaders(u8 pal, u8 fade_copy, struct color* to_apply);
96
-struct color alpha_blend(struct color a, struct color b, u8 alpha);
97 99
 extern void blockset_load_palette_to_gpu(void* blockset, u16 start, u16 len);
98
-extern void gpu_pal_apply(struct color* src, u16 dst, u16 len);
99 100
 extern void load_palette_3(u16 start, u16 len);
100 101
 extern void tint_palette(u8 pal_slot);
101 102
 extern u8 gpu_pal_tags_index_of(u16 pal_tag);
102 103
 extern void lz77u_wram(void* src, void* dst);
103 104
 extern void* oe_read_word(void* oe_script_pointer);
104 105
 extern void some_weather_func(u8 pal_index);
105
-void copy_unfaded(u8 slot);
106
-void pal_patch_for_npc(u16 tag, u8 pal);
107
-u8 is_current_map_dn_valid(enum map_type current_type);
108 106
 //care, this has to be manually patched to be u16
109 107
 extern u16 npc_pal_idx_for_given_tag(u16 tag);
110
-struct color_shade get_color_from_time(enum time_type current_time);
111
-enum time_type get_time_of_day();
112
-void update_dns_palettes();
113
-void apply_lighting(void* blockset, u8 copy, struct color* to_apply);
108
+struct color_shade dns_get_shade_from_time(enum dns_rtc_time_type current_time);
109
+enum dns_rtc_time_type dns_get_time_of_day();
110
+void dns_update_palettes();
114 111
 
115 112
 extern void mapdata_load_palettes_to_gpu(struct mapdata_header* data_header);
116
-extern u16 npc_paltag_by_palslot(u8 slot);
117 113
 
118 114
 extern void script_something();
119 115
 extern void camera_update();

+ 8
- 0
src/include/game_engine.h View File

@@ -36,6 +36,7 @@
36 36
 
37 37
 /* === INCLUDE === */
38 38
 #include <types.h>
39
+#include <battle_structs.h>
39 40
 
40 41
 /* === EXTERN METHODS === */
41 42
 
@@ -76,5 +77,12 @@ extern u32 pokemon_get_attribute(struct pokemon* poke_address, u8 request, void*
76 77
  */
77 78
 void pokemon_set_attribute(struct pokemon* poke_address, u8 request, void* new_value);
78 79
 
80
+/**
81
+ * @brief gets x12 value of item
82
+ * @param item_id item to get value of
83
+ * @return corresponding x12 value 
84
+ */
85
+extern u8 item_get_x12(u16 item_id);
86
+
79 87
 #endif /* GAME_ENGINE_H */
80 88
 

+ 5
- 9
src/include/lcd.h View File

@@ -64,15 +64,6 @@ struct color {
64 64
     u16 b : 5;
65 65
 };
66 66
 
67
-/* === STATIC STRUCTURES === */
68
-
69
-static struct bg_config standard_bg[4] = {
70
-    {0, 0, 0x19, 0, 0, 0},
71
-    {1, 1, 0x1A, 0, 0, 1},
72
-    {2, 2, 0x1B, 0, 0, 2},
73
-    {3, 3, 0x1C, 0, 0, 3}
74
-};
75
-
76 67
 /* === EXTERN METHODS === */
77 68
 
78 69
 /**
@@ -131,6 +122,11 @@ extern void* virtual_bg_get_tilemap(u8 bg_id);
131 122
  */
132 123
 extern void virtual_bg_send_tilemap(u8 bg_id);
133 124
 
125
+/**
126
+ * @brief TODO DOCUMENT
127
+ */
128
+extern void gpu_pal_apply();
129
+
134 130
 
135 131
 /**
136 132
  * @brief decompress palette and copy to f/u buffers

+ 2
- 2
src/include/memory.h View File

@@ -59,7 +59,7 @@ extern void free(void* address);
59 59
  * @param num amount of bytes to copy
60 60
  * @return destination pointer
61 61
  */
62
-extern void* memcpy (void * destination, const void* source, size_t num);
62
+extern void* memcpy(void * destination, const void* source, size_t num);
63 63
 
64 64
 /**
65 65
  * @brief set bytes in memory
@@ -68,7 +68,7 @@ extern void* memcpy (void * destination, const void* source, size_t num);
68 68
  * @param size number of bytes to set
69 69
  * @return 
70 70
  */
71
-extern void* memset (void* dst, int value, size_t size);
71
+extern void* memset(void* dst, int value, size_t size);
72 72
 
73 73
 /**
74 74
  * @brief decompress data into wram using interrupt

src/include/abilities.h → src/include/pkmn_abilities.h View File


src/include/item_effects.h → src/include/pkmn_item_effects.h View File


src/include/items.h → src/include/pkmn_items.h View File


+ 2
- 2
src/interface/lcd_io_test.S View File

@@ -37,7 +37,7 @@ get_flag_val:
37 37
 .global trans_activate
38 38
 trans_activate:
39 39
     push {r0-r7}
40
-    bl create_mugshot_on_variable
40
+    bl mug_create_on_variable
41 41
     bl get_flag_val
42 42
     cmp r0, #0
43 43
     bne no_activate
@@ -65,7 +65,7 @@ no_activate:
65 65
 .global trans_deactivate
66 66
 trans_deactivate:
67 67
     push {r0-r3}
68
-    bl delete_mugshot
68
+    bl mug_delete
69 69
     mov r0, #LCD_WIN_IN
70 70
     ldrh r1, =0x1F1F
71 71
     bl do_lcd_io_set

+ 156
- 102
src/interface/textbox_mugshots.c View File

@@ -1,126 +1,180 @@
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 textbox_mugshots.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Display little mugshot icons over the textbox
28
+ *
29
+ */
30
+
31
+/* === INCLUDES === */
1 32
 #include <objects.h>
2 33
 #include <callback.h>
3 34
 #include <config.h>
4 35
 #include <lcd.h>
5
-typedef struct mugshot {
6
-	void *gfx;
7
-	void *pal;
8
-} mugshot;
36
+#include <debug.h>
37
+#include <game_engine.h>
38
+#include <memory.h>
39
+
40
+/* === PROTOTYPES === */
41
+
42
+/**
43
+ * @brief null callback
44
+ * @param self object
45
+ */
46
+void mug_cb_null(struct obj_entity *self);
47
+
48
+/**
49
+ * @brief called when tb is opened to create mugshot
50
+ */
51
+void mug_create_on_variable();
52
+
53
+
54
+/**
55
+ * @brief called when tb is closed to delete mugshot
56
+ */
57
+void mug_delete();
58
+
59
+/* === STRUCTURES === */
60
+
61
+typedef struct mug_mugshot {
62
+    void *gfx;
63
+    void *pal;
64
+} mug_mugshot;
65
+
66
+/* TODO: USE GRIT AND ASM SYMBOL */
67
+
68
+/* === STATIC GLOBALS === */
69
+
70
+mug_mugshot *mugshots = (mug_mugshot(*)) 0x097007E0;
9 71
 
10
-//extern mugshot* mugshots;
11
-mugshot *mugshots = (mugshot (*) ) 0x097007E0;
12 72
 u8 *temp_obj_id1 = (u8*) OBJ_1_TEMP;
13 73
 u8 *temp_obj_id2 = (u8*) OBJ_2_TEMP;
14
-void* memset(void* ptr, int value, u32 num);
15
-
16
-u16* var_access(u16 num);
17 74
 
18 75
 struct obj_oam_attributes mug_sprite = {0, 0x8000, 0, 0};
19 76
 
20
-void null_callback(struct obj_entity *self);
21
-
22
-struct obj_template mugshot_1_template = {MUGSHOT_1_TAG, MUGSHOT_1_TAG, &mug_sprite, (struct obj_frame **)0x08231CF0, 0, (struct obj_rotscale_frame **)0x08231CFC, null_callback};
23
-struct obj_template mugshot_2_template = {MUGSHOT_2_TAG, MUGSHOT_2_TAG, &mug_sprite, (struct obj_frame **)0x08231CF0, 0, (struct obj_rotscale_frame **)0x08231CFC, null_callback};
24
-
25
-void create_mugshot_on_variable()
26
-{
27
-	u16 *mug1_var = var_access(MUGHSOT_1_TABLE);
28
-	u16 c_mug1_var = *mug1_var;
29
-	u16 mug_id_1 = c_mug1_var & 0x3FFF;
30
-	if(mug_id_1 != 0)
31
-	{
32
-		bool h_flip = (c_mug1_var & 0x8000) > 0;
33
-		bool v_flip = (c_mug1_var & 0x4000) > 0;
34
-		u16 *mug1_x = var_access(MUGSHOT_1_X);
35
-		u16 *mug1_y = var_access(MUGSHOT_1_Y);
36
-
37
-		mug_id_1--;
38
-		struct obj_resource gfx_mugshot_1 = {(mugshots[mug_id_1].gfx), 0x1C00, MUGSHOT_1_TAG};
39
-		struct obj_resource pal_mugshot_1 = {(mugshots[mug_id_1].pal), MUGSHOT_1_TAG};
40
-
41
-
42
-		obj_gpu_pal_alloc_tag_and_apply(&pal_mugshot_1);
43
-		obj_gpu_tile_decompress_alloc_tag_and_upload(&gfx_mugshot_1);
44
-
45
-		*temp_obj_id1 = (u16)obj_template_instanciate_forward_search(&mugshot_1_template, 0, 100, 1);
46
-
47
-		if(h_flip)
48
-			superstate.sprites[*temp_obj_id1].final_oam.attr1 |= 0x1000;
49
-		if(v_flip)
50
-			superstate.sprites[*temp_obj_id1].final_oam.attr1 |= 0x2000;
51
-
52
-		superstate.sprites[*temp_obj_id1].x = *mug1_x;
53
-		superstate.sprites[*temp_obj_id1].y = *mug1_y;
54
-	}
55
-	//return;
56
-	u16 *mug2_var = var_access(MUGHSOT_2_TABLE);
57
-	u16 c_mug2_var = *mug2_var;
58
-	u16 mug_id_2 = c_mug2_var & 0x3FFF;
59
-	if(mug_id_2 != 0)
60
-	{
61
-		bool h_flip = (c_mug2_var & 0x8000) > 0;
62
-		bool v_flip = (c_mug2_var & 0x4000) > 0;
63
-		u16 *mug2_x = var_access(MUGSHOT_2_X);
64
-		u16 *mug2_y = var_access(MUGSHOT_2_Y);
65
-
66
-		mug_id_2--;
67
-		struct obj_resource gfx_mugshot_2 = {(mugshots[mug_id_2].gfx), 0x1C00, MUGSHOT_2_TAG};
68
-		struct obj_resource pal_mugshot_2 = {(mugshots[mug_id_2].pal), MUGSHOT_2_TAG};
69
-
70
-
71
-		obj_gpu_pal_alloc_tag_and_apply(&pal_mugshot_2);
72
-		obj_gpu_tile_decompress_alloc_tag_and_upload(&gfx_mugshot_2);
73
-
74
-		c_mug2_var = *mug2_var;
75
-		*temp_obj_id2 = (u16)obj_template_instanciate_forward_search(&mugshot_2_template, 0, 100, 1);
76
-
77
-		if(h_flip)
78
-			superstate.sprites[*temp_obj_id2].final_oam.attr1 |= 0x1000;
79
-		if(v_flip)
80
-			superstate.sprites[*temp_obj_id2].final_oam.attr1 |= 0x2000;
81
-
82
-		superstate.sprites[*temp_obj_id2].x = *mug2_x;
83
-		superstate.sprites[*temp_obj_id2].y = *mug2_y;
84
-	}
77
+struct obj_template mugshot_1_template = {MUGSHOT_1_TAG, MUGSHOT_1_TAG, &mug_sprite, (struct obj_frame **) 0x08231CF0, 0, (struct obj_rotscale_frame **) 0x08231CFC, mug_cb_null};
78
+struct obj_template mugshot_2_template = {MUGSHOT_2_TAG, MUGSHOT_2_TAG, &mug_sprite, (struct obj_frame **) 0x08231CF0, 0, (struct obj_rotscale_frame **) 0x08231CFC, mug_cb_null};
79
+
80
+
81
+
82
+/* === IMPLEMENTATIONS === */
83
+
84
+void mug_create_on_variable() {
85
+    /* this is just some debug code! */
86
+    assert(NULL);
87
+
88
+    u16 *mug1_var = var_access(MUGHSOT_1_TABLE);
89
+    u16 c_mug1_var = *mug1_var;
90
+    u16 mug_id_1 = c_mug1_var & 0x3FFF;
91
+    if (mug_id_1 != 0) {
92
+        bool h_flip = (c_mug1_var & 0x8000) > 0;
93
+        bool v_flip = (c_mug1_var & 0x4000) > 0;
94
+        u16 *mug1_x = var_access(MUGSHOT_1_X);
95
+        u16 *mug1_y = var_access(MUGSHOT_1_Y);
96
+
97
+        mug_id_1--;
98
+        struct obj_resource gfx_mugshot_1 = {(mugshots[mug_id_1].gfx), 0x1C00, MUGSHOT_1_TAG};
99
+        struct obj_resource pal_mugshot_1 = {(mugshots[mug_id_1].pal), MUGSHOT_1_TAG};
100
+
101
+
102
+        obj_gpu_pal_alloc_tag_and_apply(&pal_mugshot_1);
103
+        obj_gpu_tile_decompress_alloc_tag_and_upload(&gfx_mugshot_1);
104
+
105
+        *temp_obj_id1 = (u16) obj_template_instanciate_forward_search(&mugshot_1_template, 0, 100, 1);
106
+
107
+        if (h_flip)
108
+            superstate.sprites[*temp_obj_id1].final_oam.attr1 |= 0x1000;
109
+        if (v_flip)
110
+            superstate.sprites[*temp_obj_id1].final_oam.attr1 |= 0x2000;
111
+
112
+        superstate.sprites[*temp_obj_id1].x = *mug1_x;
113
+        superstate.sprites[*temp_obj_id1].y = *mug1_y;
114
+    }
115
+    u16 *mug2_var = var_access(MUGHSOT_2_TABLE);
116
+    u16 c_mug2_var = *mug2_var;
117
+    u16 mug_id_2 = c_mug2_var & 0x3FFF;
118
+    if (mug_id_2 != 0) {
119
+        bool h_flip = (c_mug2_var & 0x8000) > 0;
120
+        bool v_flip = (c_mug2_var & 0x4000) > 0;
121
+        u16 *mug2_x = var_access(MUGSHOT_2_X);
122
+        u16 *mug2_y = var_access(MUGSHOT_2_Y);
123
+
124
+        mug_id_2--;
125
+        struct obj_resource gfx_mugshot_2 = {(mugshots[mug_id_2].gfx), 0x1C00, MUGSHOT_2_TAG};
126
+        struct obj_resource pal_mugshot_2 = {(mugshots[mug_id_2].pal), MUGSHOT_2_TAG};
127
+
128
+
129
+        obj_gpu_pal_alloc_tag_and_apply(&pal_mugshot_2);
130
+        obj_gpu_tile_decompress_alloc_tag_and_upload(&gfx_mugshot_2);
131
+
132
+        c_mug2_var = *mug2_var;
133
+        *temp_obj_id2 = (u16) obj_template_instanciate_forward_search(&mugshot_2_template, 0, 100, 1);
134
+
135
+        if (h_flip)
136
+            superstate.sprites[*temp_obj_id2].final_oam.attr1 |= 0x1000;
137
+        if (v_flip)
138
+            superstate.sprites[*temp_obj_id2].final_oam.attr1 |= 0x2000;
139
+
140
+        superstate.sprites[*temp_obj_id2].x = *mug2_x;
141
+        superstate.sprites[*temp_obj_id2].y = *mug2_y;
142
+    }
85 143
 }
86 144
 
87
-void delete_mugshot()
88
-{
89
-	u16 *mug1_var = var_access(MUGHSOT_1_TABLE);
90
-	u16 *mug2_var = var_access(MUGHSOT_2_TABLE);
145
+void mug_delete() {
146
+    //u16 *mug1_var = var_access(MUGHSOT_1_TABLE);
147
+    //u16 *mug2_var = var_access(MUGHSOT_2_TABLE);
91 148
 
92
-	if(*temp_obj_id1 != 0)
93
-	{
94
-		gpu_pal_free_by_tag(MUGSHOT_1_TAG);
95
-		obj_gpu_tile_free_by_tag(MUGSHOT_1_TAG);
149
+    if (*temp_obj_id1 != 0) {
150
+        gpu_pal_free_by_tag(MUGSHOT_1_TAG);
151
+        obj_gpu_tile_free_by_tag(MUGSHOT_1_TAG);
96 152
 
97
-		//*mug1_var = 0;
98
-		//do reset mugshot var ; set it to old value instead
153
+        //*mug1_var = 0;
154
+        //do reset mugshot var ; set it to old value instead
99 155
 
100
-		//*mug1_var = objects[object_id_1].private[0];
156
+        //*mug1_var = objects[object_id_1].private[0];
101 157
 
102
-		obj_delete_and_free_tiles(&(superstate.sprites[*temp_obj_id1]));
103
-		*temp_obj_id1 = 0;
104
-	}
158
+        obj_delete_and_free_tiles(&(superstate.sprites[*temp_obj_id1]));
159
+        *temp_obj_id1 = 0;
160
+    }
105 161
 
106
-	//return;
107
-	if(*temp_obj_id2 != 0)
108
-	{
109
-		gpu_pal_free_by_tag(MUGSHOT_2_TAG);
110
-		obj_gpu_tile_free_by_tag(MUGSHOT_2_TAG);
162
+    //return;
163
+    if (*temp_obj_id2 != 0) {
164
+        gpu_pal_free_by_tag(MUGSHOT_2_TAG);
165
+        obj_gpu_tile_free_by_tag(MUGSHOT_2_TAG);
111 166
 
112
-		//*mug2_var = 0;
113
-		//do reset mugshot var ; set it to old value instead
167
+        //*mug2_var = 0;
168
+        //do reset mugshot var ; set it to old value instead
114 169
 
115
-		//*mug2_var = objects[object_id_2].private[0];
170
+        //*mug2_var = objects[object_id_2].private[0];
116 171
 
117
-		obj_delete_and_free_tiles(&(superstate.sprites[*temp_obj_id2]));
118
-		*temp_obj_id2 = 0;
119
-	}
172
+        obj_delete_and_free_tiles(&(superstate.sprites[*temp_obj_id2]));
173
+        *temp_obj_id2 = 0;
174
+    }
120 175
 
121 176
 }
122 177
 
123
-void null_callback(struct obj_entity *self)
124
-{
125
-	//null_callback
178
+void mug_cb_null(struct obj_entity *self) {
179
+    return;
126 180
 }

+ 1
- 1
src/interface/trans_mug_close_fix.S View File

@@ -33,5 +33,5 @@ sub_08069B34:
33 33
 .align 2
34 34
 trans_deactivate_2:
35 35
 	push {lr}
36
-	bl delete_mugshot
36
+	bl mug_delete
37 37
 	pop {pc}

+ 7
- 1
src/moves/ability_changers/ability_change.c View File

@@ -1,4 +1,8 @@
1
-#include <battle.h>
1
+#include <battle_locations.h>
2
+#include <types.h>
3
+#include <battle_structs.h>
4
+#include <pkmn_abilities.h>
5
+#include <moves.h>
2 6
 
3 7
 extern void* str_worry_seed_ref;
4 8
 extern void* str_entrainment_ref;
@@ -102,5 +106,7 @@ u8 ability_change() {
102 106
             return role_play();
103 107
         case MOVE_SKILL_SWAP:
104 108
             return skill_swap();
109
+        default:
110
+            return false;
105 111
     }
106 112
 }

+ 3
- 2
src/moves/assurance/assurance.c View File

@@ -1,6 +1,7 @@
1
-#include <battle.h>
1
+#include <battle_locations.h>
2
+#include <battle_structs.h>
2 3
 
3
-u8 assurance_damage_modifier()
4
+void assurance_damage_modifier()
4 5
 {
5 6
     if((battle_protect[battle_defender_bank].physical_damage + battle_protect[battle_defender_bank].special_damage) > 0)
6 7
         battle_damage_multiplier *=2;

+ 2
- 2
src/moves/bride/bride.c View File

@@ -1,5 +1,5 @@
1
-#include <battle.h>
2
-
1
+#include <battle_structs.h>
2
+#include <battle_locations.h>
3 3
 u8 bride_has_multiplier()
4 4
 {
5 5
     if(battle_participants[battle_defender_bank].current_hp <= battle_participants[battle_defender_bank].max_hp >> 1)

+ 3
- 1
src/moves/close_combat/close_combat.c View File

@@ -1,4 +1,6 @@
1
-#include <battle.h>
1
+#include <battle_locations.h>
2
+#include <battle_structs.h>
3
+#include <types.h>
2 4
 
3 5
 extern void* bs_cc_lower_def;
4 6
 extern void* bs_cc_lower_sdef;

+ 2
- 1
src/moves/crush_grip_like/hp_damage_mod.c View File

@@ -1,4 +1,5 @@
1
-#include <battle.h>
1
+#include <battle_structs.h>
2
+#include <battle_locations.h>
2 3
 
3 4
 u8 hp_damage_mod()
4 5
 {

+ 4
- 1
src/moves/defog/defog.c View File

@@ -1,4 +1,7 @@
1
-#include <battle.h>
1
+#include <battle_locations.h>
2
+#include <battle_structs.h>
3
+#include <battle_common.h>
4
+#include <battle_custom_structs.h>
2 5
 
3 6
 u8 defog_field()
4 7
 {

+ 5
- 2
src/moves/feint/feint.c View File

@@ -1,9 +1,11 @@
1
-#include <battle.h>
1
+#include <battle_structs.h>
2
+#include <battle_locations.h>
3
+#include <battle_custom_structs.h>
4
+#include <battle_common.h>
2 5
 
3 6
 extern void* bs_feint_no_break_ptr;
4 7
 
5 8
 u8 break_shields() {
6
-    u8 side = get_side_from_bank(battle_defender_bank);
7 9
     u8 effect = false;
8 10
     struct bank_affecting* defender_bank = &custom_battle_elements.ptr->bank_affecting[battle_defender_bank];
9 11
     struct side_affecting* defender_side = &custom_battle_elements.ptr->side_affecting[get_side_from_bank(battle_defender_bank)];
@@ -38,4 +40,5 @@ u8 break_shields() {
38 40
     if(effect)
39 41
         return false;
40 42
     battlescript_cursor = bs_feint_no_break_ptr;
43
+    return true;
41 44
 }

+ 3
- 1
src/moves/gastro_acid/gastro_acid.c View File

@@ -1,4 +1,6 @@
1
-#include <battle.h>
1
+#include <battle_locations.h>
2
+#include <battle_structs.h>
3
+#include <battle_custom_structs.h>
2 4
 
3 5
 u8 gastro_acid_set() {
4 6
     if (custom_battle_elements.ptr->bank_affecting[battle_defender_bank].gastro_acided) {

+ 5
- 2
src/moves/healing_wish/healing_wish.c View File

@@ -1,8 +1,11 @@
1
-#include <battle.h>
1
+#include <battle_common.h>
2 2
 #include <battle_help.h>
3
+#include <battle_locations.h>
4
+#include <battle_custom_structs.h>
5
+#include <battle_structs.h>
3 6
 
4 7
 u8 set_healing_wish() {
5
-    if (count_party_pokemon(battle_attacker_bank) <= 1) {
8
+    if (battle_count_party_pokemon(battle_attacker_bank) <= 1) {
6 9
         //it will fail
7 10
         battlescript_cursor = (void*) (0x081D7DF0);
8 11
         return true;

+ 4
- 1
src/moves/lucky_chant/lucky_chant.c View File

@@ -1,4 +1,7 @@
1
-#include <battle.h>
1
+#include <battle_locations.h>
2
+#include <battle_common.h>
3
+#include <battle_custom_structs.h>
4
+#include <battle_structs.h>
2 5
 
3 6
 u8 lucky_chant_set()
4 7
 {

+ 4
- 1
src/moves/magnet_rise/magnet_rise.c View File

@@ -1,4 +1,7 @@
1
-#include <battle.h>
1
+#include <battle_common.h>
2
+#include <battle_locations.h>
3
+#include <battle_custom_structs.h>
4
+#include <battle_structs.h>
2 5
 
3 6
 u8 set_magnet_rise() {
4 7
     struct bank_affecting* user = &custom_battle_elements.ptr->bank_affecting[battle_attacker_bank];

+ 2
- 1
src/moves/metal_burst/metal_burst.c View File

@@ -1,4 +1,5 @@
1
-#include <battle.h>
1
+#include <battle_locations.h>
2
+#include <types.h>
2 3
 
3 4
 u8 metal_burst_dmg_reduction()
4 5
 {

+ 1
- 1
src/moves/pay_back/pay_back.c View File

@@ -1,4 +1,4 @@
1
-#include <battle.h>
1
+#include <battle_locations.h>
2 2
 
3 3
 u8 pay_back_damage_modifier()
4 4
 {

+ 3
- 2
src/moves/power_trick/power_trick.c View File

@@ -1,5 +1,6 @@
1
-#include <battle.h>
2
-#include <bpre.h>
1
+#include <battle_structs.h>
2
+#include <battle_locations.h>
3
+#include <battle_custom_structs.h>
3 4
 
4 5
 u8 power_trick_swap() 
5 6
 {

+ 2
- 1
src/moves/punishment/punishment.c View File

@@ -1,4 +1,5 @@
1
-#include <battle.h>
1
+#include <battle_structs.h>
2
+#include <battle_locations.h>
2 3
 
3 4
 u8 punishment_damage_mod() {
4 5
     struct battle_participant* defender = &battle_participants[battle_defender_bank];

+ 5
- 1
src/moves/rooms/rooms.c View File

@@ -1,4 +1,8 @@
1
-#include <battle.h>
1
+#include <battle_common.h>
2
+#include <moves.h>
3
+#include <battle_custom_structs.h>
4
+#include <battle_structs.h>
5
+#include <battle_locations.h>
2 6
 
3 7
 extern void* str_trick_room_off_ref;
4 8
 extern void* str_trick_room_on_ref;

+ 2
- 1
src/moves/roost/roost.c View File

@@ -1,5 +1,6 @@
1 1
 #include <battle_structs.h>
2
-#include <battle.h>
2
+#include <pkmn_types.h>
3
+#include <battle_locations.h>
3 4
 
4 5
 u8 roost_change_type()
5 6
 {

+ 3
- 1
src/moves/split_moves/split_moves.c View File

@@ -1,4 +1,6 @@
1
-#include <battle.h>
1
+#include <battle_locations.h>
2
+#include <battle_structs.h>
3
+#include <moves.h>
2 4
 
3 5
 extern void* str_guard_split_ref;
4 6
 extern void* str_power_split_ref;

+ 4
- 1
src/moves/swap_moves/swap_moves.c View File

@@ -1,4 +1,7 @@
1
-#include <battle.h>
1
+#include <battle_common.h>
2
+#include <moves.h>
3
+#include <battle_structs.h>
4
+#include <battle_locations.h>
2 5
 
3 6
 extern void* str_power_swap_ref;
4 7
 extern void* str_guard_swap_ref;

+ 4
- 1
src/moves/tailwind/tailwind.c View File

@@ -1,4 +1,7 @@
1
-#include <battle.h>
1
+#include <battle_locations.h>
2
+#include <battle_structs.h>
3
+#include <battle_custom_structs.h>
4
+#include <battle_common.h>
2 5
 
3 6
 extern void* bs_tailwind_failed_ptr;
4 7
 

+ 2
- 1
src/moves/veno_shock/venoshock_has_multiplier.c View File

@@ -1,4 +1,5 @@
1
-#include <battle.h>
1
+#include <battle_locations.h>
2
+#include <battle_structs.h>
2 3
 
3 4
 u8 venoshock_has_multiplier()
4 5
 {

+ 40
- 0
src/music/music_override.c View File

@@ -1,7 +1,47 @@
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 music_override.c
25
+ * @author ipatix
26
+ * @date 15 dec 2016
27
+ * @brief Play some custom music
28
+ * 
29
+ */
30
+
31
+/* === INCLUDES === */
32
+
1 33
 #include <sound.h>
2 34
 #include <game_engine.h>
3 35
 #include <config.h>
4 36
 
37
+/* === PROTTYPES === */
38
+/**
39
+ * @brief overrides a music routine to load music ids from a custom variable
40
+ * @param songid song_id to be overridden
41
+ */
42
+void music_override(u16 songid);
43
+
44
+/* === IMPLEMENTATIONS === */
5 45
 void music_override(u16 songid) {
6 46
     int skip = 0;
7 47
     if (flag_check(FLAG_ENABLE_MUSIC_OVERRIDES)) {

+ 50
- 7
src/overworld/overworld.c View File

@@ -1,9 +1,42 @@
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 overworld.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Routines to work with the new overworld npc table
28
+ * 
29
+ */
30
+
31
+/* === INCLUDES === */
1 32
 #include <game_engine.h>
2 33
 
34
+/* === DEFINES === */
3 35
 #define OW_REPLACE_VAR  0x500A
4 36
 #define OW_REPLACE_TO_VAR   0x500B
5 37
 
6
-struct coords16{
38
+/* === STRUCTURES === */
39
+struct ow_point{
7 40
     u16 x;
8 41
     u16 y;
9 42
 };
@@ -13,7 +46,7 @@ struct npc_type {
13 46
     u16 pal_num;
14 47
     u16 pal_tag_2;
15 48
     u16 field_6;
16
-    struct coords16 pos_neg_center;
49
+    struct ow_point pos_neg_center;
17 50
     u8 pal_slot_unk;
18 51
     u8 field_D;
19 52
     u16 pal_table;
@@ -24,15 +57,25 @@ struct npc_type {
24 57
     u32 rot_scale_anims;
25 58
 };
26 59
 
27
-extern struct npc_type* ow_main_table;
28
-extern struct npc_type* ow_second_table;
29
-extern struct npc_type* ow_third_table;
30
-
60
+/* === PROTOTYPES === */
61
+/**
62
+ * @brief get the npc type struct by given 16 bit npc id
63
+ * @param npc_id short npc id
64
+ * @return pointer to corresponding npc_type structure
65
+ */
66
+struct npc_type* npc_get_type(u16 npc_id);
31 67
 
68
+/* === EXTERN STATICS ===*/
69
+struct npc_type** ow_main_table;
70
+struct npc_type** ow_second_table;
71
+struct npc_type** ow_third_table;
32 72
 
73
+/* === IMPLEMENTATIONS === */
33 74
 struct npc_type* npc_get_type(u16 npc_id)
34 75
 {
35
-    struct npc_type** npc_tables[] = {ow_main_table, ow_second_table, ow_third_table};
76
+    /* Not possible in a global scope because of gcc cow magic */
77
+    struct npc_type** npc_tables[3] = {ow_main_table, ow_second_table, ow_third_table};
78
+    //struct npc_type** npc_tables[] = {ow_main_table, ow_second_table, ow_third_table};
36 79
     u16* replace_ow = var_access(OW_REPLACE_VAR);
37 80
     if(*replace_ow > 0 && *replace_ow - 1 == npc_id)
38 81
     {

+ 59
- 7
src/specials/camera_move.c View File

@@ -1,17 +1,69 @@
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 camera_move.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Scene to update the camera
28
+ * 
29
+ * This provides implementations to move the game camera
30
+ */
31
+
32
+/* === INCLUDES === */
33
+
1 34
 #include <game_engine.h>
2 35
 #include "camera_move.h"
3 36
 #include <callback.h>
4 37
 #include <fade.h>
5 38
 #include <config.h>
39
+#include <lcd.h>
40
+
41
+/* === PROTOTYPES === */
42
+
43
+/**
44
+ * @brief special to handle the camera update scene
45
+ */
46
+void cam_cb_move_camera();
6 47
 
7
-struct point** sav_data_map = (struct point**)(0x03005008);
48
+/**
49
+ * @brief vblank screen update method for the camera scene
50
+ */
51
+void cam_update_screen();
8 52
 
9
-struct point {
53
+/* === STRUCTURES === */
54
+
55
+struct cam_point {
10 56
   u16 x;
11 57
   u16 y;
12 58
 };
13 59
 
14
-void update_screen_cam()
60
+/* === STATIC STRUCTURES === */
61
+
62
+struct cam_point** sav_data_map = (struct cam_point**)(0x03005008);
63
+
64
+/* === IMPLEMENTATIONS === */
65
+
66
+void cam_update_screen()
15 67
 {
16 68
 	fade_update();
17 69
 	task_exec();
@@ -21,14 +73,14 @@ void update_screen_cam()
21 73
 	obj_gpu_sprites_upload();
22 74
 }
23 75
 
24
-void sp_move_camera()
76
+void cam_sp_move_camera()
25 77
 {
26
-  set_callback2(sp_move_camera_callback);
78
+  set_callback2(cam_cb_move_camera);
27 79
   fade_screen(0xFFFFFFFF, 0, 0, 0x10, 0x0000);
28
-  vblank_handler_set(update_screen_cam);
80
+  vblank_handler_set(cam_update_screen);
29 81
 }
30 82
 
31
-void sp_move_camera_callback()
83
+void cam_cb_move_camera()
32 84
 {
33 85
     if((fade_controller.mix_color & 0x8000) == 0)
34 86
     {

+ 43
- 3
src/specials/camera_move.h View File

@@ -1,3 +1,43 @@
1
-void camera_move_and_redraw(int x, int y);
2
-void sp_move_camera();
3
-void sp_move_camera_callback();
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 camera_move.h
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Scene to update the camera
28
+ * 
29
+ * This provides prototypes to move the game camera
30
+ */
31
+
32
+#ifndef CAMERA_MOVE_H_
33
+#define CAMERA_MOVE_H_
34
+
35
+/* === PROTOTYPES === */
36
+
37
+/**
38
+ * @brief move camera to position specified in CAMERA_VAR_X and CAMERA_VAR_Y
39
+ */
40
+void cam_sp_move_camera();
41
+
42
+
43
+#endif

+ 70
- 15
src/specials/custom_specials.c View File

@@ -1,16 +1,80 @@
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 custom_specials.c
25
+ * @author Sturmvogel
26
+ * @date 15 dec 2016
27
+ * @brief Special 0x68 implementation to read from LASTRESULT and execute
28
+ * 
29
+ */
30
+
31
+/* === INCLUDES === */
32
+
2 33
 #include "cutscene_meteor.h"
3 34
 #include "camera_move.h"
35
+#include <callback.h>
4 36
 #include <debug.h>
37
+#include <game_engine.h>
38
+#include <config.h>
39
+
40
+/* === PROTOTYPES === */
41
+
42
+/**
43
+ * @brief test routine to switch dns
44
+ */
45
+void sp_dns_switch();
46
+
47
+/**
48
+ * @brief clear some flags at the beginning of the game
49
+ */
50
+void sp_init_script();
51
+
52
+
53
+/**
54
+ * @brief callasm to call a var-based routine as defined
55
+ */
56
+void sp_special_casm();
57
+
58
+/* === STATICS === */
5 59
 
6
-void dns_switch()
60
+static callback special_routines[5] = {
61
+    met_play,
62
+    cam_sp_move_camera,
63
+    sp_init_script,
64
+    debug_some_test,
65
+    sp_dns_switch,
66
+};
67
+
68
+/* === IMPLEMENTATIONS === */
69
+
70
+void sp_dns_switch()
7 71
 {
8 72
     volatile u8* test_pointer = (u8*) (0x0203FAB0);
9 73
     *(test_pointer+1) = (*(test_pointer+1) == 3 ? 0 : (*(test_pointer+1)) + 1);
10 74
     *test_pointer = 1;
11 75
 }
12 76
 
13
-void init_script()
77
+void sp_init_script()
14 78
 {
15 79
   for(u16 i = 0x1000; i < 0x1800; ++i)
16 80
   {
@@ -18,17 +82,8 @@ void init_script()
18 82
   }
19 83
 }
20 84
 
21
-static callback special_routines[5] = {
22
-	met_play,
23
-	sp_move_camera,
24
-	init_script,
25
-        debug_some_test,
26
-        dns_switch,
27
-};
28
-
29
-
30
-void special_asm() //special 0x68
85
+void sp_special_casm() //special 0x68
31 86
 {
32
-	u16* var_special = var_access(CALLASM_VAR);
33
-	special_routines[*var_special]();
87
+    u16* var_special = var_access(CALLASM_VAR);
88
+    special_routines[*var_special]();
34 89
 }

+ 10
- 1
src/specials/cutscene_meteor.c View File

@@ -74,6 +74,15 @@ struct meteor_memory{
74 74
 	u16 delay_end;
75 75
 };
76 76
 
77
+/* === STATIC STRUCTURES === */
78
+
79
+static struct bg_config met_bg_config[4] = {
80
+    {0, 0, 0x19, 0, 0, 0},
81
+    {1, 1, 0x1A, 0, 0, 1},
82
+    {2, 2, 0x1B, 0, 0, 2},
83
+    {3, 3, 0x1C, 0, 0, 3}
84
+};
85
+
77 86
 /* === PROTOTYPES === */
78 87
 
79 88
 /**
@@ -274,7 +283,7 @@ void met_setup_vram()
274 283
 	gpu_tile_bg_drop_all_sets(2);
275 284
 	gpu_tile_bg_drop_all_sets(3);
276 285
 
277
-	gpu_bg_vram_setup(0, standard_bg, 4);
286
+	gpu_bg_vram_setup(0, met_bg_config, 4);
278 287
 
279 288
 	gpu_bg_show(0);
280 289
 	gpu_bg_show(1);

+ 1
- 1
string/de/item_data.txt View File

@@ -1,4 +1,4 @@
1
-@include <item_effects.h>
1
+@include <pkmn_item_effects.h>
2 2
 
3 3
 @string_len=14
4 4